Class: SakaiInfo::PendingQuizAuthorization

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



1487
1488
1489
# File 'lib/sakai-info/quiz.rb', line 1487

def self.clear_cache
  @@cache = {}
end

.count_by_quiz_id(quiz_id) ⇒ Object



1513
1514
1515
# File 'lib/sakai-info/quiz.rb', line 1513

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

.find(id) ⇒ Object



1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
# File 'lib/sakai-info/quiz.rb', line 1492

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(PendingQuizAuthorization, id)
    end

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

.find_by_quiz_id(quiz_id) ⇒ Object



1517
1518
1519
1520
# File 'lib/sakai-info/quiz.rb', line 1517

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

.query_by_quiz_id(quiz_id) ⇒ Object



1509
1510
1511
# File 'lib/sakai-info/quiz.rb', line 1509

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

Instance Method Details

#quizObject



1505
1506
1507
# File 'lib/sakai-info/quiz.rb', line 1505

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