Class: SakaiInfo::QuizSection
Instance Attribute Summary collapse
Attributes inherited from SakaiObject
#id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from ModProps
included
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 QuizSection.
405
406
407
408
409
410
411
412
413
414
415
|
# File 'lib/sakai-info/quiz.rb', line 405
def initialize(dbrow)
@dbrow = dbrow
@id = dbrow[:sectionid]
@quiz = Quiz.find(dbrow[:assessmentid])
@sequence = dbrow[:sequence]
@title = dbrow[:title]
@description = dbrow[:description]
@typeid = dbrow[:typeid]
@status = dbrow[:status]
end
|
Instance Attribute Details
#dbrow ⇒ Object
Returns the value of attribute dbrow.
392
393
394
|
# File 'lib/sakai-info/quiz.rb', line 392
def dbrow
@dbrow
end
|
#description ⇒ Object
Returns the value of attribute description.
392
393
394
|
# File 'lib/sakai-info/quiz.rb', line 392
def description
@description
end
|
#quiz ⇒ Object
Returns the value of attribute quiz.
392
393
394
|
# File 'lib/sakai-info/quiz.rb', line 392
def quiz
@quiz
end
|
#sequence ⇒ Object
Returns the value of attribute sequence.
392
393
394
|
# File 'lib/sakai-info/quiz.rb', line 392
def sequence
@sequence
end
|
#status ⇒ Object
Returns the value of attribute status.
392
393
394
|
# File 'lib/sakai-info/quiz.rb', line 392
def status
@status
end
|
#title ⇒ Object
Returns the value of attribute title.
392
393
394
|
# File 'lib/sakai-info/quiz.rb', line 392
def title
@title
end
|
#typeid ⇒ Object
Returns the value of attribute typeid.
392
393
394
|
# File 'lib/sakai-info/quiz.rb', line 392
def typeid
@typeid
end
|
Class Method Details
.all_serializations ⇒ Object
500
501
502
|
# File 'lib/sakai-info/quiz.rb', line 500
def self.all_serializations
[:default, :items, :mod]
end
|
.clear_cache ⇒ Object
400
401
402
|
# File 'lib/sakai-info/quiz.rb', line 400
def self.clear_cache
@@cache = {}
end
|
.count_by_quiz_id(quiz_id) ⇒ Object
449
450
451
|
# File 'lib/sakai-info/quiz.rb', line 449
def self.count_by_quiz_id(quiz_id)
QuizSection.query_by_quiz_id(quiz_id).count
end
|
.find_by_quiz_id(quiz_id) ⇒ Object
442
443
444
445
446
447
|
# File 'lib/sakai-info/quiz.rb', line 442
def self.find_by_quiz_id(quiz_id)
section_class = Quiz.find(quiz_id).section_class
QuizSection.query_by_quiz_id(quiz_id).all.collect do |row|
section_class.new(row)
end
end
|
.query_by_quiz_id(quiz_id) ⇒ Object
433
434
435
436
437
438
439
440
|
# File 'lib/sakai-info/quiz.rb', line 433
def self.query_by_quiz_id(quiz_id)
table = if Quiz.find(quiz_id).quiz_type == "pending"
:sam_section_t
else
:sam_publishedsection_t
end
DB.connect[table].where(:assessmentid => quiz_id).order(:sequence)
end
|
Instance Method Details
#default_serialization ⇒ Object
465
466
467
468
469
470
471
472
473
474
475
476
477
|
# File 'lib/sakai-info/quiz.rb', line 465
def default_serialization
{
"id" => self.id,
"title" => self.title,
"quiz" => self.quiz.serialize(:summary),
"sequence" => self.sequence,
"item_count" => self.item_count,
"description" => self.description,
"type" => self.section_type,
"typeid" => self.typeid,
"status" => self.status
}
end
|
#items_serialization ⇒ Object
494
495
496
497
498
|
# File 'lib/sakai-info/quiz.rb', line 494
def items_serialization
{
"items" => self.items.collect{|i|i.serialize(:section_summary)}
}
end
|
#quiz_summary_serialization ⇒ Object
488
489
490
491
492
|
# File 'lib/sakai-info/quiz.rb', line 488
def quiz_summary_serialization
result = summary_serialization
result.delete("quiz_id")
result
end
|
#section_type ⇒ Object
453
454
455
|
# File 'lib/sakai-info/quiz.rb', line 453
def section_type
nil
end
|
#summary_serialization ⇒ Object
479
480
481
482
483
484
485
486
|
# File 'lib/sakai-info/quiz.rb', line 479
def summary_serialization
{
"id" => self.id,
"title" => self.title,
"quiz_id" => self.quiz.id,
"sequence" => self.sequence
}
end
|