/** * Set up the columns and headers and other properties of the table and then * call flexible_table::setup() method. * * @param moodle_url $reporturl the URL to redisplay this report. * @param object $question a question with a _stats field * @param bool $hassubqs */ public function question_setup($reporturl, $questiondata, quiz_statistics_response_analyser $responesstats) { $this->questiondata = $questiondata; $this->define_baseurl($reporturl->out()); $this->collapsible(false); $this->set_attribute('class', 'generaltable generalbox boxaligncenter'); // Define the table columns. $columns = array(); $headers = array(); if ($responesstats->has_subparts()) { $columns[] = 'part'; $headers[] = get_string('partofquestion', 'quiz_statistics'); } if ($responesstats->has_response_classes()) { $columns[] = 'responseclass'; $headers[] = get_string('modelresponse', 'quiz_statistics'); if ($responesstats->has_actual_responses()) { $columns[] = 'response'; $headers[] = get_string('actualresponse', 'quiz_statistics'); } } else { $columns[] = 'response'; $headers[] = get_string('response', 'quiz_statistics'); } $columns[] = 'fraction'; $headers[] = get_string('optiongrade', 'quiz_statistics'); $columns[] = 'count'; $headers[] = get_string('count', 'quiz_statistics'); $columns[] = 'frequency'; $headers[] = get_string('frequency', 'quiz_statistics'); $this->define_columns($columns); $this->define_headers($headers); $this->sortable(false); $this->column_class('fraction', 'numcol'); $this->column_class('count', 'numcol'); $this->column_class('frequency', 'numcol'); $this->column_suppress('part'); $this->column_suppress('responseclass'); parent::setup(); }
protected function analyse_responses($quizstatisticsid, $quizid, $currentgroup, $nostudentsingroup, $useallattempts, $groupstudents, $questions, $subquestions) { $qubaids = quiz_statistics_qubaids_condition( $quizid, $currentgroup, $groupstudents, $useallattempts); $done = array(); foreach ($questions as $question) { if (!question_bank::get_qtype($question->qtype, false)->can_analyse_responses()) { continue; } $done[$question->id] = 1; $responesstats = new quiz_statistics_response_analyser($question); $responesstats->analyse($qubaids); $responesstats->store_cached($quizstatisticsid); } foreach ($subquestions as $question) { if (!question_bank::get_qtype($question->qtype, false)->can_analyse_responses() || isset($done[$question->id])) { continue; } $done[$question->id] = 1; $responesstats = new quiz_statistics_response_analyser($question); $responesstats->analyse($qubaids); $responesstats->store_cached($quizstatisticsid); } }