Beispiel #1
0
 /**
  * Analyse responses for an array of questions or sub questions.
  *
  * @param object[] $questions  as returned by self::load_and_initialise_questions_for_calculations.
  * @param qubaid_condition $qubaids the question usages whose responses to analyse.
  * @param string $whichtries which tries to analyse \question_attempt::FIRST_TRY, LAST_TRY or ALL_TRIES.
  * @param null|\core\progress\base $progress Used to indicate progress of task.
  * @param int[] $done array keys are ids of questions that have been analysed before calling method.
  * @return array array keys are ids of questions that were analysed after this method call.
  */
 protected function analyse_responses_for_questions($questions, $qubaids, $whichtries, $progress = null, $done = array())
 {
     $countquestions = count($questions);
     if (!$countquestions) {
         return array();
     }
     if ($progress === null) {
         $progress = new \core\progress\none();
     }
     $progress->start_progress('', $countquestions, $countquestions);
     foreach ($questions as $question) {
         $progress->increment_progress();
         if (question_bank::get_qtype($question->qtype, false)->can_analyse_responses() && !isset($done[$question->id])) {
             $responesstats = new \core_question\statistics\responses\analyser($question, $whichtries);
             if ($responesstats->get_last_analysed_time($qubaids, $whichtries) === false) {
                 $responesstats->calculate($qubaids, $whichtries);
             }
         }
         $done[$question->id] = 1;
     }
     $progress->end_progress();
     return $done;
 }
Beispiel #2
0
 protected function analyse_responses_for_all_questions_and_subquestions($qubaids, $questions, $subquestionstats)
 {
     $done = array();
     foreach ($questions as $question) {
         if (!question_bank::get_qtype($question->qtype, false)->can_analyse_responses()) {
             continue;
         }
         $done[$question->id] = 1;
         $responesstats = new \core_question\statistics\responses\analyser($question);
         $responesstats->calculate($qubaids);
     }
     foreach ($subquestionstats as $subquestionstat) {
         if (!question_bank::get_qtype($subquestionstat->question->qtype, false)->can_analyse_responses() || isset($done[$subquestionstat->question->id])) {
             continue;
         }
         $done[$subquestionstat->question->id] = 1;
         $responesstats = new \core_question\statistics\responses\analyser($subquestionstat->question);
         $responesstats->calculate($qubaids);
     }
 }