Class: SakaiInfo::PublishedQuizAuthorization

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

Instance Attribute Summary

Attributes inherited from QuizAuthorization

#dbrow, #ends_at, #id, #name, #starts_at

Attributes inherited from SakaiObject

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from QuizAuthorization

#default_serialization, #initialize, #quiz_summary_serialization

Methods included from ModProps

included

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::QuizAuthorization

Class Method Details

.clear_cacheObject



1524
1525
1526
# File 'lib/sakai-info/quiz.rb', line 1524

def self.clear_cache
  @@cache = {}
end

.count_by_quiz_id(quiz_id) ⇒ Object



1550
1551
1552
# File 'lib/sakai-info/quiz.rb', line 1550

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

.find(id) ⇒ Object



1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
# File 'lib/sakai-info/quiz.rb', line 1529

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

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

.find_by_quiz_id(quiz_id) ⇒ Object



1554
1555
1556
1557
# File 'lib/sakai-info/quiz.rb', line 1554

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

.query_by_quiz_id(quiz_id) ⇒ Object



1546
1547
1548
# File 'lib/sakai-info/quiz.rb', line 1546

def self.query_by_quiz_id(quiz_id)
  DB.connect[:sam_authzdata_t].where(:qualifierid => quiz_id).where(Sequel.like(:functionid, "%_PUBLISHED_ASSESSMENT%"))
end

Instance Method Details

#quizObject



1542
1543
1544
# File 'lib/sakai-info/quiz.rb', line 1542

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