Class: SakaiInfo::QuizAttemptItem
Instance Attribute Summary collapse
Attributes inherited from SakaiObject
#id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from SakaiObject
#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 QuizAttemptItem.
937
938
939
940
941
942
943
944
945
946
|
# File 'lib/sakai-info/quiz.rb', line 937
def initialize(dbrow)
@dbrow = dbrow
@id = dbrow[:itemgradingid]
@submitted_at = dbrow[:submitteddate]
@user_id = dbrow[:agentid]
@attempt_id = dbrow[:assessmentgradingid]
@item_id = dbrow[:publisheditemid]
@answer = dbrow[:answertext]
end
|
Instance Attribute Details
#answer ⇒ Object
Returns the value of attribute answer.
930
931
932
|
# File 'lib/sakai-info/quiz.rb', line 930
def answer
@answer
end
|
#attempt_id ⇒ Object
Returns the value of attribute attempt_id.
930
931
932
|
# File 'lib/sakai-info/quiz.rb', line 930
def attempt_id
@attempt_id
end
|
#dbrow ⇒ Object
Returns the value of attribute dbrow.
930
931
932
|
# File 'lib/sakai-info/quiz.rb', line 930
def dbrow
@dbrow
end
|
#item_id ⇒ Object
Returns the value of attribute item_id.
930
931
932
|
# File 'lib/sakai-info/quiz.rb', line 930
def item_id
@item_id
end
|
#submitted_at ⇒ Object
Returns the value of attribute submitted_at.
930
931
932
|
# File 'lib/sakai-info/quiz.rb', line 930
def submitted_at
@submitted_at
end
|
#user_id ⇒ Object
Returns the value of attribute user_id.
930
931
932
|
# File 'lib/sakai-info/quiz.rb', line 930
def user_id
@user_id
end
|
Class Method Details
.all_serializations ⇒ Object
1027
1028
1029
|
# File 'lib/sakai-info/quiz.rb', line 1027
def self.all_serializations
[:default, :attachments]
end
|
.clear_cache ⇒ Object
932
933
934
|
# File 'lib/sakai-info/quiz.rb', line 932
def self.clear_cache
@@cache = {}
end
|
.count_by_attempt_id(attempt_id) ⇒ Object
.find(id) ⇒ Object
960
961
962
963
964
965
966
967
968
969
970
971
|
# File 'lib/sakai-info/quiz.rb', line 960
def self.find(id)
id = id.to_s
if @@cache[id].nil?
row = DB.connect[:sam_itemgrading_t].where(:itemgradingid => id).first
if row.nil?
raise ObjectNotFoundException.new(QuizAttemptItem, id)
end
@@cache[id] = QuizAttemptItem.new(row)
end
@@cache[id]
end
|
.find_by_attempt_id(attempt_id) ⇒ Object
.query_by_attempt_id(attempt_id) ⇒ Object
973
974
975
|
# File 'lib/sakai-info/quiz.rb', line 973
def self.query_by_attempt_id(attempt_id)
DB.connect[:sam_itemgrading_t].where(:assessmentgradingid => attempt_id)
end
|
Instance Method Details
#attachments_serialization ⇒ Object
1021
1022
1023
1024
1025
|
# File 'lib/sakai-info/quiz.rb', line 1021
def attachments_serialization
{
"attachments" => self.attachments.collect{|a|a.serialize(:attempt_item_summary)}
}
end
|
#attempt ⇒ Object
952
953
954
|
# File 'lib/sakai-info/quiz.rb', line 952
def attempt
@attempt ||= QuizAttempt.find(@attempt_id)
end
|
#attempt_summary_serialization ⇒ Object
1013
1014
1015
1016
1017
1018
1019
|
# File 'lib/sakai-info/quiz.rb', line 1013
def attempt_summary_serialization
{
"id" => self.id,
"item_id" => self.item_id,
"submitted_at" => self.submitted_at,
}
end
|
#default_serialization ⇒ Object
991
992
993
994
995
996
997
998
999
1000
1001
|
# File 'lib/sakai-info/quiz.rb', line 991
def default_serialization
{
"id" => self.id,
"user" => self.user.serialize(:summary),
"attempt" => self.attempt.serialize(:summary),
"item" => self.item.serialize(:summary),
"answer" => self.answer,
"attachment_count" => self.attachments.length,
"submitted_at" => self.submitted_at,
}
end
|
#item ⇒ Object
956
957
958
|
# File 'lib/sakai-info/quiz.rb', line 956
def item
@item ||= PublishedQuizItem.find(@item_id)
end
|
#summary_serialization ⇒ Object
1003
1004
1005
1006
1007
1008
1009
1010
1011
|
# File 'lib/sakai-info/quiz.rb', line 1003
def summary_serialization
{
"id" => self.id,
"eid" => User.get_eid(self.user_id),
"attempt_id" => self.attempt_id,
"item_id" => self.item_id,
"submitted_at" => self.submitted_at,
}
end
|
#user ⇒ Object
948
949
950
|
# File 'lib/sakai-info/quiz.rb', line 948
def user
@user ||= User.find(@user_id)
end
|