Class: SakaiInfo::QuizAttempt
Constant Summary
collapse
- ATTEMPT_STATUS =
status definitions from samigo-api/src/java/org/sakaiproject/tool/assessment/data/ifc/grading/AssessmentGradingIfc.java
{
"0" => "unsubmitted",
"1" => "submitted-ungraded",
"2" => "submitted-auto-graded",
"3" => "submitted-needs-human-attention",
"4" => "needs-resubmit",
"5" => "unsubmitted-but-graded",
"6" => "updated-in-progress",
}
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 QuizAttempt.
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
|
# File 'lib/sakai-info/quiz.rb', line 779
def initialize(dbrow)
@dbrow = dbrow
@id = dbrow[:assessmentgradingid]
@submitted_at = dbrow[:submitteddate]
@user_id = dbrow[:agentid]
@quiz_id = dbrow[:publishedassessmentid]
@total_auto_score = dbrow[:totalautoscore]
@status = dbrow[:status]
@attempted_at = dbrow[:attemptdate]
@time_elapsed = dbrow[:timeelapsed]
@is_auto_submitted = dbrow[:isautosubmitted]
@is_late = dbrow[:islate]
@comments = dbrow[:comments]
end
|
Instance Attribute Details
Returns the value of attribute comments.
772
773
774
|
# File 'lib/sakai-info/quiz.rb', line 772
def
@comments
end
|
#dbrow ⇒ Object
Returns the value of attribute dbrow.
772
773
774
|
# File 'lib/sakai-info/quiz.rb', line 772
def dbrow
@dbrow
end
|
#quiz_id ⇒ Object
Returns the value of attribute quiz_id.
772
773
774
|
# File 'lib/sakai-info/quiz.rb', line 772
def quiz_id
@quiz_id
end
|
#status ⇒ Object
Returns the value of attribute status.
772
773
774
|
# File 'lib/sakai-info/quiz.rb', line 772
def status
@status
end
|
#time_elapsed ⇒ Object
Returns the value of attribute time_elapsed.
772
773
774
|
# File 'lib/sakai-info/quiz.rb', line 772
def time_elapsed
@time_elapsed
end
|
#total_auto_score ⇒ Object
Returns the value of attribute total_auto_score.
772
773
774
|
# File 'lib/sakai-info/quiz.rb', line 772
def total_auto_score
@total_auto_score
end
|
#user_id ⇒ Object
Returns the value of attribute user_id.
772
773
774
|
# File 'lib/sakai-info/quiz.rb', line 772
def user_id
@user_id
end
|
Class Method Details
.all_serializations ⇒ Object
924
925
926
|
# File 'lib/sakai-info/quiz.rb', line 924
def self.all_serializations
[:default, :items]
end
|
.clear_cache ⇒ Object
774
775
776
|
# File 'lib/sakai-info/quiz.rb', line 774
def self.clear_cache
@@cache = {}
end
|
.count_by_quiz_id(quiz_id) ⇒ Object
812
813
814
|
# File 'lib/sakai-info/quiz.rb', line 812
def self.count_by_quiz_id(quiz_id)
QuizAttempt.query_by_quiz_id(quiz_id).count
end
|
.find(id) ⇒ Object
795
796
797
798
799
800
801
802
803
804
805
806
|
# File 'lib/sakai-info/quiz.rb', line 795
def self.find(id)
id = id.to_s
if @@cache[id].nil?
row = DB.connect[:sam_assessmentgrading_t].where(:assessmentgradingid => id).first
if row.nil?
raise ObjectNotFoundException.new(QuizAttempt, id)
end
@@cache[id] = QuizAttempt.new(row)
end
@@cache[id]
end
|
.find_by_quiz_id(quiz_id) ⇒ Object
.find_by_user_id_and_quiz_id(user_id, quiz_id) ⇒ Object
.query_by_quiz_id(quiz_id) ⇒ Object
808
809
810
|
# File 'lib/sakai-info/quiz.rb', line 808
def self.query_by_quiz_id(quiz_id)
DB.connect[:sam_assessmentgrading_t].where(:publishedassessmentid => quiz_id)
end
|
.query_by_user_id_and_quiz_id(user_id, quiz_id) ⇒ Object
821
822
823
|
# File 'lib/sakai-info/quiz.rb', line 821
def self.query_by_user_id_and_quiz_id(user_id, quiz_id)
DB.connect[:sam_assessmentgrading_t].where(:publishedassessmentid => quiz_id, :agentid => user_id)
end
|
Instance Method Details
#attempted_at ⇒ Object
854
855
856
857
858
859
860
|
# File 'lib/sakai-info/quiz.rb', line 854
def attempted_at
if @attempted_at.nil?
nil
else
@attempted_at.strftime("%Y-%m-%d %H:%M:%S")
end
end
|
#auto_submitted? ⇒ Boolean
846
847
848
|
# File 'lib/sakai-info/quiz.rb', line 846
def auto_submitted?
@is_auto_submitted == 1
end
|
#default_serialization ⇒ Object
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
|
# File 'lib/sakai-info/quiz.rb', line 885
def default_serialization
{
"id" => self.id,
"user" => self.user.serialize(:summary),
"quiz" => self.quiz.serialize(:summary),
"item_count" => self.item_count,
"attempted_at" => self.attempted_at,
"submitted_at" => self.submitted_at,
"time_elapsed" => self.time_elapsed,
"is_auto_submitted" => self.auto_submitted?,
"is_late" => self.late?,
"status" => self.status,
"total_auto_score" => self.total_auto_score
}
end
|
#items_serialization ⇒ Object
918
919
920
921
922
|
# File 'lib/sakai-info/quiz.rb', line 918
def items_serialization
{
"items" => self.items.collect { |i| i.serialize(:attempt_summary) }
}
end
|
#late? ⇒ Boolean
850
851
852
|
# File 'lib/sakai-info/quiz.rb', line 850
def late?
@is_late == 1
end
|
#quiz ⇒ Object
842
843
844
|
# File 'lib/sakai-info/quiz.rb', line 842
def quiz
@quiz ||= PublishedQuiz.find(@quiz_id)
end
|
#quiz_summary_serialization ⇒ Object
910
911
912
913
914
915
916
|
# File 'lib/sakai-info/quiz.rb', line 910
def quiz_summary_serialization
{
"id" => self.id,
"eid" => User.get_eid(self.user_id),
"status" => self.status
}
end
|
#submitted_at ⇒ Object
862
863
864
865
866
867
868
|
# File 'lib/sakai-info/quiz.rb', line 862
def submitted_at
if @submitted_at.nil?
nil
else
@submitted_at.strftime("%Y-%m-%d %H:%M:%S")
end
end
|
#summary_serialization ⇒ Object
901
902
903
904
905
906
907
908
|
# File 'lib/sakai-info/quiz.rb', line 901
def summary_serialization
{
"id" => self.id,
"eid" => User.get_eid(self.user_id),
"quiz_id" => self.quiz_id,
"status" => self.status
}
end
|
#user ⇒ Object
838
839
840
|
# File 'lib/sakai-info/quiz.rb', line 838
def user
@user ||= User.find(@user_id)
end
|