コード例 #1
0
ファイル: CMEQuizPage.php プロジェクト: nrfredrickson/Cme
 protected function initQuiz()
 {
     $this->quiz = $this->app->getCacheValue($this->getCacheKey());
     if ($this->quiz === false) {
         if (!$this->progress->quiz instanceof CMEQuiz) {
             $this->progress->quiz = $this->generateQuiz();
             $this->progress->save();
         }
         $this->quiz = $this->progress->quiz;
         if (!$this->quiz instanceof CMEQuiz) {
             throw new SiteNotFoundException('Quiz not found for CME credit.');
         }
         $questions = $this->quiz->question_bindings->loadAllSubDataObjects('question', $this->app->db, 'select * from InquisitionQuestion where id in (%s)', SwatDBClassMap::get('InquisitionQuestionWrapper'));
         if ($questions instanceof InquisitionQuestionWrapper) {
             // efficiently load correct options
             $questions->loadAllSubDataObjects('correct_option', $this->app->db, 'select * from InquisitionQuestionOption where id in (%s)', SwatDBClassMap::get('InquisitionQuestionOptionWrapper'));
             // efficiently load question options
             $questions->loadAllSubRecordsets('options', SwatDBClassMap::get('InquisitionQuestionOptionWrapper'), 'InquisitionQuestionOption', 'question', '', 'displayorder, id');
         }
         $this->addCacheValue($this->quiz, $this->getCacheKey());
     } else {
         $this->quiz->setDatabase($this->app->db);
     }
 }