Class: SakaiInfo::PendingQuizMetadata

Inherits:
QuizMetadata show all
Defined in:
lib/sakai-info/quiz.rb

Instance Attribute Summary

Attributes inherited from QuizMetadata

#dbrow, #id, #key, #value

Attributes inherited from SakaiObject

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from QuizMetadata

#default_serialization, #initialize

Methods inherited from SakaiObject

all_serializations, #dbrow_only_serialization, #dbrow_serialization, #default_serialization, descendants, #object_type_serialization, #serialize, #shell_serialization, #summary_serialization, #to_csv, #to_json, #to_yaml

Constructor Details

This class inherits a constructor from SakaiInfo::QuizMetadata

Class Method Details

.clear_cacheObject



1376
1377
1378
# File 'lib/sakai-info/quiz.rb', line 1376

def self.clear_cache
  @@cache = {}
end

.count_by_quiz_id(quiz_id) ⇒ Object



1402
1403
1404
# File 'lib/sakai-info/quiz.rb', line 1402

def self.count_by_quiz_id(quiz_id)
  PendingQuizMetadata.query_by_quiz_id(quiz_id).count
end

.find(id) ⇒ Object



1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
# File 'lib/sakai-info/quiz.rb', line 1381

def self.find(id)
  id = id.to_s
  if @@cache[id].nil?
    row = DB.connect[:sam_assessmetadata_t].where(:assessmentmetadataid => id.to_i).first
    if row.nil?
      raise ObjectNotFoundException.new(PendingQuizMetadata, id)
    end

    @@cache[id] = PendingQuizMetadata.new(row)
  end
  @@cache[id]
end

.find_by_quiz_id(quiz_id) ⇒ Object



1406
1407
1408
1409
# File 'lib/sakai-info/quiz.rb', line 1406

def self.find_by_quiz_id(quiz_id)
  PendingQuizMetadata.query_by_quiz_id(quiz_id).
    all.collect { |row| PendingQuizMetadata.new(row) }
end

.query_by_quiz_id(quiz_id) ⇒ Object



1398
1399
1400
# File 'lib/sakai-info/quiz.rb', line 1398

def self.query_by_quiz_id(quiz_id)
  DB.connect[:sam_assessmetadata_t].where(:assessmentid => quiz_id)
end

Instance Method Details

#quizObject



1394
1395
1396
# File 'lib/sakai-info/quiz.rb', line 1394

def quiz
  @quiz ||= PendingQuiz.find(@quiz_id)
end