Example #1
0
 private function load_unmarked_enhancedcalc()
 {
     $this->unmarked_enhancedcalc = false;
     if (!isset($this->questions)) {
         $this->load_questions();
     }
     $enhancedcalc_ids = array();
     $paperID = $this->get_property_id();
     $excluded = new Exclusion($paperID, $this->db);
     $excluded->load();
     if (is_array($this->questions) and count($this->questions) > 0) {
         // Calculation questions may be hidden in random blocks of keyword baed questions so we have to check all possibilities.
         foreach ($this->questions as $question) {
             // Skip excluded questions.
             if (!$excluded->is_question_excluded($question['q_id'])) {
                 switch ($question['type']) {
                     case 'random':
                         foreach (QuestionUtils::get_random_calc_question($question['q_id'], $this->db) as $possible) {
                             $enhancedcalc_ids[] = $possible;
                         }
                         break;
                     case 'keyword_based':
                         foreach (QuestionUtils::get_keyword_calc_question($question['q_id'], $this->db) as $possible) {
                             $enhancedcalc_ids[] = $possible;
                         }
                         break;
                     case 'enhancedcalc':
                         $enhancedcalc_ids[] = $question['q_id'];
                         break;
                     default:
                         break;
                 }
             }
         }
     }
     // Find unmarked questions.
     if (count($enhancedcalc_ids) > 0) {
         $result = $this->db->prepare("SELECT log2.id FROM log2, log_metadata WHERE log2.metadataID = log_metadata.id " . "AND q_id IN (" . implode(',', $enhancedcalc_ids) . ") AND paperID = ? AND mark IS NULL LIMIT 1");
         $result->bind_param('i', $paperID);
         $result->execute();
         $result->store_result();
         $result->bind_result($id);
         if ($result->num_rows > 0) {
             $this->unmarked_enhancedcalc = true;
         }
         $result->close();
     }
 }