protected function initEvaluation()
 {
     $this->evaluation = $this->app->getCacheValue($this->getCacheKey());
     if ($this->evaluation === false) {
         if (!$this->front_matter->evaluation instanceof CMEEvaluation) {
             throw new SiteNotFoundException('Evaluation not found for CME front matter.');
         }
         if (!$this->progress->evaluation instanceof CMEEvaluation) {
             $this->progress->evaluation = $this->generateEvaluation();
             $this->progress->save();
         }
         $this->evaluation = $this->progress->evaluation;
         // efficiently load questions
         $bindings = $this->evaluation->visible_question_bindings;
         $questions = $bindings->loadAllSubDataObjects('question', $this->app->db, 'select * from InquisitionQuestion where id in (%s)', SwatDBClassMap::get('InquisitionQuestionWrapper'));
         // efficiently load question options
         if ($questions instanceof InquisitionQuestionWrapper) {
             $options = $questions->loadAllSubRecordsets('options', SwatDBClassMap::get('InquisitionQuestionOptionWrapper'), 'InquisitionQuestionOption', 'question', '', 'displayorder, id');
         }
         $this->addCacheValue($this->evaluation, $this->getCacheKey());
     } else {
         $this->evaluation->setDatabase($this->app->db);
     }
 }
Exemple #2
0
 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);
     }
 }