Class: SakaiInfo::PendingQuiz

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

Constant Summary

Constants inherited from Quiz

Quiz::ACTIVE, Quiz::DELETED, Quiz::INACTIVE, Quiz::RETRACTED_FOR_EDITING

Instance Attribute Summary

Attributes inherited from Quiz

#dbrow, #site, #title

Attributes inherited from SakaiObject

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Quiz

#access_control, #access_control_summary_serialization, all_serializations, #authorizations, #authorizations_serialization, #auths_serialization, #default_serialization, #initialize, #item_count, #items, #items_serialization, #metadata, #metadata_serialization, #section_count, #sections, #sections_serialization, #site_summary_serialization, #status, #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::Quiz

Class Method Details

.clear_cacheObject



232
233
234
# File 'lib/sakai-info/quiz.rb', line 232

def self.clear_cache
  @@cache = {}
end

.count_by_site_id(site_id) ⇒ Object



264
265
266
# File 'lib/sakai-info/quiz.rb', line 264

def self.count_by_site_id(site_id)
  PendingQuiz.query_by_site_id(site_id).count
end

.find(id) ⇒ Object



237
238
239
240
241
242
243
244
245
246
247
# File 'lib/sakai-info/quiz.rb', line 237

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

.find_by_site_id(site_id) ⇒ Object



258
259
260
261
262
# File 'lib/sakai-info/quiz.rb', line 258

def self.find_by_site_id(site_id)
  PendingQuiz.query_by_site_id(site_id).all.collect do |row|
    @@cache[row[:id]] = PendingQuiz.new(row, site_id)
  end
end

.find_ids_by_site_id(site_id) ⇒ Object



268
269
270
# File 'lib/sakai-info/quiz.rb', line 268

def self.find_ids_by_site_id(site_id)
  PendingQuiz.query_by_site_id(site_id).select(:id).all.collect { |row| row[:id] }
end

.query_by_site_id(site_id) ⇒ Object



249
250
251
252
253
254
255
256
# File 'lib/sakai-info/quiz.rb', line 249

def self.query_by_site_id(site_id)
  db = DB.connect
  db[:sam_assessmentbase_t].
    where(:id =>
          db[:sam_authzdata_t].select(:qualifierid).
          where(:agentid => site_id,
                :functionid => "EDIT_ASSESSMENT"))
end

Instance Method Details

#access_control_classObject



284
285
286
# File 'lib/sakai-info/quiz.rb', line 284

def access_control_class
  PendingQuizAccessControl
end

#authorization_classObject



292
293
294
# File 'lib/sakai-info/quiz.rb', line 292

def authorization_class
  PendingQuizAuthorization
end

#item_classObject



280
281
282
# File 'lib/sakai-info/quiz.rb', line 280

def item_class
  PendingQuizItem
end

#metadata_classObject



288
289
290
# File 'lib/sakai-info/quiz.rb', line 288

def 
  PendingQuizMetadata
end

#quiz_typeObject



272
273
274
# File 'lib/sakai-info/quiz.rb', line 272

def quiz_type
  "pending"
end

#section_classObject



276
277
278
# File 'lib/sakai-info/quiz.rb', line 276

def section_class
  PendingQuizSection
end