Class: SakaiInfo::AssignmentSubmission
Instance Attribute Summary collapse
#attributes, #properties, #xml, #xmldoc
Attributes inherited from SakaiObject
#id
Class Method Summary
collapse
Instance Method Summary
collapse
all_serializations, #attributes_serialization, #dbrow_serialization, #parse_xml, #properties_serialization, #xml_serialization
Methods included from ModProps
included
Methods inherited from SakaiObject
all_serializations, #dbrow_only_serialization, #dbrow_serialization, descendants, #object_type_serialization, #serialize, #shell_serialization, #to_csv, #to_json, #to_yaml
Constructor Details
Returns a new instance of AssignmentSubmission.
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/sakai-info/assignment.rb', line 107
def initialize(dbrow)
@dbrow = dbrow
@id = dbrow[:submission_id]
@assignment_id = dbrow[:context]
@submitter_id = dbrow[:submitter_id]
@is_submitted = (dbrow[:submitted] == "true")
@is_graded = (dbrow[:graded] == "true")
parse_xml
end
|
Instance Attribute Details
#assignment_id ⇒ Object
Returns the value of attribute assignment_id.
100
101
102
|
# File 'lib/sakai-info/assignment.rb', line 100
def assignment_id
@assignment_id
end
|
#dbrow ⇒ Object
Returns the value of attribute dbrow.
100
101
102
|
# File 'lib/sakai-info/assignment.rb', line 100
def dbrow
@dbrow
end
|
#submitter_id ⇒ Object
Returns the value of attribute submitter_id.
100
101
102
|
# File 'lib/sakai-info/assignment.rb', line 100
def submitter_id
@submitter_id
end
|
Class Method Details
.clear_cache ⇒ Object
102
103
104
|
# File 'lib/sakai-info/assignment.rb', line 102
def self.clear_cache
@@cache = {}
end
|
.count_by_assignment_id(assignment_id) ⇒ Object
.count_by_user_id(user_id) ⇒ Object
.find_by_assignment_id(assignment_id) ⇒ Object
.find_by_user_id(user_id) ⇒ Object
.query_by_assignment_id(assignment_id) ⇒ Object
151
152
153
|
# File 'lib/sakai-info/assignment.rb', line 151
def self.query_by_assignment_id(assignment_id)
DB.connect[:assignment_submission].where(:context => assignment_id)
end
|
.query_by_user_id(user_id) ⇒ Object
164
165
166
|
# File 'lib/sakai-info/assignment.rb', line 164
def self.query_by_user_id(user_id)
DB.connect[:assignment_submission].where(:submitter_id => user_id)
end
|
Instance Method Details
#assignment ⇒ Object
135
136
137
|
# File 'lib/sakai-info/assignment.rb', line 135
def assignment
@assignment ||= Assignment.find(self.assignment_id)
end
|
#assignment_summary_serialization ⇒ Object
203
204
205
206
207
208
209
|
# File 'lib/sakai-info/assignment.rb', line 203
def assignment_summary_serialization
{
"id" => self.id,
"submitter" => User.get_eid(self.submitter_id),
"is_submitted" => self.submitted?
}
end
|
#default_serialization ⇒ Object
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
# File 'lib/sakai-info/assignment.rb', line 178
def default_serialization
result = {
"id" => self.id,
"assignment" => self.assignment.serialize(:summary),
"submitter" => self.submitter.serialize(:summary),
"is_submitted" => self.submitted?,
"submitted_at" => self.submitted_at,
"is_graded" => self.graded?,
}
if not self.submitted?
result.delete("submitted_at")
result.delete("is_graded")
end
result
end
|
#graded? ⇒ Boolean
143
144
145
|
# File 'lib/sakai-info/assignment.rb', line 143
def graded?
@is_graded || false
end
|
#submitted? ⇒ Boolean
139
140
141
|
# File 'lib/sakai-info/assignment.rb', line 139
def submitted?
( self.created_by_id == self.submitter_id && @is_submitted ) || false
end
|
#submitted_at ⇒ Object
147
148
149
|
# File 'lib/sakai-info/assignment.rb', line 147
def submitted_at
@submitted_at ||= Util.format_entity_date(@attributes["datesubmitted"])
end
|
#submitter ⇒ Object
131
132
133
|
# File 'lib/sakai-info/assignment.rb', line 131
def submitter
@submitter ||= User.find(self.submitter_id)
end
|
#summary_serialization ⇒ Object
194
195
196
197
198
199
200
201
|
# File 'lib/sakai-info/assignment.rb', line 194
def summary_serialization
{
"id" => self.id,
"assignment_id" => self.assignment_id,
"submitter" => User.get_eid(self.submitter_id),
"is_submitted" => self.submitted?
}
end
|