Class: SakaiInfo::PublishedQuizMetadata

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



1413
1414
1415
# File 'lib/sakai-info/quiz.rb', line 1413

def self.clear_cache
  @@cache = {}
end

.count_by_quiz_id(quiz_id) ⇒ Object



1439
1440
1441
# File 'lib/sakai-info/quiz.rb', line 1439

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

.find(id) ⇒ Object



1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
# File 'lib/sakai-info/quiz.rb', line 1418

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

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

.find_by_quiz_id(quiz_id) ⇒ Object



1443
1444
1445
1446
# File 'lib/sakai-info/quiz.rb', line 1443

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

.query_by_quiz_id(quiz_id) ⇒ Object



1435
1436
1437
# File 'lib/sakai-info/quiz.rb', line 1435

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

Instance Method Details

#quizObject



1431
1432
1433
# File 'lib/sakai-info/quiz.rb', line 1431

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