Class: SakaiInfo::QuizAccessControl
Instance Attribute Summary collapse
Instance Method Summary
collapse
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 QuizAccessControl.
1112
1113
1114
1115
|
# File 'lib/sakai-info/quiz.rb', line 1112
def initialize(dbrow)
@dbrow = dbrow
@id = dbrow[:assessmentid]
end
|
Instance Attribute Details
#dbrow ⇒ Object
Returns the value of attribute dbrow.
1110
1111
1112
|
# File 'lib/sakai-info/quiz.rb', line 1110
def dbrow
@dbrow
end
|
#id ⇒ Object
Returns the value of attribute id.
1110
1111
1112
|
# File 'lib/sakai-info/quiz.rb', line 1110
def id
@id
end
|
Instance Method Details
#authenticated? ⇒ Boolean
1199
1200
1201
|
# File 'lib/sakai-info/quiz.rb', line 1199
def authenticated?
not (self.username.nil? and self.password.nil?)
end
|
#automatic_submission? ⇒ Boolean
1215
1216
1217
|
# File 'lib/sakai-info/quiz.rb', line 1215
def automatic_submission?
@dbrow[:autosubmit] == 1
end
|
#default_serialization ⇒ Object
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
|
# File 'lib/sakai-info/quiz.rb', line 1259
def default_serialization
result = {
"id" => self.id,
"quiz" => self.quiz.serialize(:access_control_summary),
"unlimited_submissions" => self.unlimited_submissions?,
"submissions_allowed" => self.submissions_allowed,
"timed" => self.timed?,
"time_limit" => self.time_limit,
"question_layout" => self.question_layout,
"late_handling" => self.late_handling,
"item_navigation" => self.item_navigation,
"item_numbering" => self.item_numbering,
"release_to" => self.release_to,
"authenticated" => self.authenticated?,
"automatic_submission" => self.automatic_submission?,
"mark_for_review_allowed" => self.mark_for_review_allowed?,
}
if not self.timed?
result.delete("time_limit")
end
if self.unlimited_submissions?
result.delete("submissions_allowed")
end
%w(username start_date due_date score_date retract_date feedback_date submission_message final_page_url).each do |field_name|
value = self.method(field_name.to_sym).call
if not value.nil?
result[field_name] = value
end
end
result
end
|
#due_date ⇒ Object
1227
1228
1229
1230
1231
1232
1233
|
# File 'lib/sakai-info/quiz.rb', line 1227
def due_date
if @dbrow[:duedate].nil?
nil
else
@dbrow[:duedate].strftime("%Y-%m-%d %H:%M:%S")
end
end
|
#feedback_date ⇒ Object
1243
1244
1245
1246
1247
1248
1249
|
# File 'lib/sakai-info/quiz.rb', line 1243
def feedback_date
if @dbrow[:feedbackdate].nil?
nil
else
@dbrow[:feedbackdate].strftime("%Y-%m-%d %H:%M:%S")
end
end
|
#final_page_url ⇒ Object
1191
1192
1193
|
# File 'lib/sakai-info/quiz.rb', line 1191
def final_page_url
@dbrow[:finalpageurl]
end
|
#item_navigation ⇒ Object
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
|
# File 'lib/sakai-info/quiz.rb', line 1153
def item_navigation
case @dbrow[:itemnavigation]
when 1
"Linear"
when 2
"Random"
else
@dbrow[:itemnavigation]
end
end
|
#item_numbering ⇒ Object
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
|
# File 'lib/sakai-info/quiz.rb', line 1164
def item_numbering
case @dbrow[:itemnumbering]
when 1
"Continuous through parts"
when 2
"Restart numbering at each part"
else
@dbrow[:itemnumbering]
end
end
|
#late_handling ⇒ Object
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
|
# File 'lib/sakai-info/quiz.rb', line 1142
def late_handling
case @dbrow[:latehandling]
when 1
"Late submissions accepted"
when 2
"Late submissions NOT accepted"
else
@dbrow[:latehandling]
end
end
|
#mark_for_review_allowed? ⇒ Boolean
1195
1196
1197
|
# File 'lib/sakai-info/quiz.rb', line 1195
def mark_for_review_allowed?
@dbrow[:markforreview] == 1
end
|
#password ⇒ Object
1187
1188
1189
|
# File 'lib/sakai-info/quiz.rb', line 1187
def password
@dbrow[:password]
end
|
#question_layout ⇒ Object
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
|
# File 'lib/sakai-info/quiz.rb', line 1129
def question_layout
case @dbrow[:assessmentformat]
when 1
"One question per page"
when 2
"One part per page"
when 3
"Single page quiz"
else
@dbrow[:assessmentformat]
end
end
|
#quiz_summary_serialization ⇒ Object
1291
1292
1293
1294
1295
1296
|
# File 'lib/sakai-info/quiz.rb', line 1291
def quiz_summary_serialization
result = default_serialization
result.delete("quiz")
result.delete("id")
result
end
|
#release_to ⇒ Object
1179
1180
1181
|
# File 'lib/sakai-info/quiz.rb', line 1179
def release_to
@dbrow[:releaseto]
end
|
#retract_date ⇒ Object
1235
1236
1237
1238
1239
1240
1241
|
# File 'lib/sakai-info/quiz.rb', line 1235
def retract_date
if @dbrow[:retractdate].nil?
nil
else
@dbrow[:retractdate].strftime("%Y-%m-%d %H:%M:%S")
end
end
|
#score_date ⇒ Object
1251
1252
1253
1254
1255
1256
1257
|
# File 'lib/sakai-info/quiz.rb', line 1251
def score_date
if @dbrow[:scoredate].nil?
nil
else
@dbrow[:scoredate].strftime("%Y-%m-%d %H:%M:%S")
end
end
|
#start_date ⇒ Object
1219
1220
1221
1222
1223
1224
1225
|
# File 'lib/sakai-info/quiz.rb', line 1219
def start_date
if @dbrow[:startdate].nil?
nil
else
@dbrow[:startdate].strftime("%Y-%m-%d %H:%M:%S")
end
end
|
#submission_message ⇒ Object
1175
1176
1177
|
# File 'lib/sakai-info/quiz.rb', line 1175
def submission_message
@dbrow[:submissionmessage]
end
|
#submissions_allowed ⇒ Object
1121
1122
1123
|
# File 'lib/sakai-info/quiz.rb', line 1121
def submissions_allowed
@dbrow[:submissionsallowed]
end
|
#submissions_saved ⇒ Object
1125
1126
1127
|
# File 'lib/sakai-info/quiz.rb', line 1125
def submissions_saved
@dbrow[:submissionssaved] == 1
end
|
#summary_serialization ⇒ Object
1298
1299
1300
1301
1302
|
# File 'lib/sakai-info/quiz.rb', line 1298
def summary_serialization
{
"id" => self.id,
}
end
|
#time_limit ⇒ Object
1203
1204
1205
|
# File 'lib/sakai-info/quiz.rb', line 1203
def time_limit
@dbrow[:timelimit]
end
|
#timed? ⇒ Boolean
1207
1208
1209
1210
1211
1212
1213
|
# File 'lib/sakai-info/quiz.rb', line 1207
def timed?
if time_limit.nil?
false
else
time_limit > 0
end
end
|
#unlimited_submissions? ⇒ Boolean
1117
1118
1119
|
# File 'lib/sakai-info/quiz.rb', line 1117
def unlimited_submissions?
@dbrow[:unlimitedsubmissions] == 1
end
|
#username ⇒ Object
1183
1184
1185
|
# File 'lib/sakai-info/quiz.rb', line 1183
def username
@dbrow[:username]
end
|