where a question in a slot has subquestions and/or variants.
$string['recalculatenow'] = 'Recalculate now';
$string['reportsettings'] = 'Statistics calculation settings';
$string['response'] = 'Response';
+$string['slotstructureanalysis'] = 'Structural analysis for question number {$a}';
$string['skewness'] = 'Score distribution skewness (for {$a})';
$string['standarddeviation'] = 'Standard deviation (for {$a})';
$string['standarddeviationq'] = 'Standard deviation';
print_error('questiondoesnotexist', 'question');
}
- $this->output_individual_question_data($quiz, $questionstats->for_slot($slot));
- $this->output_individual_question_response_analysis($questions[$slot],
- $questionstats->for_slot($slot)->s,
- $reporturl,
- $qubaids);
+ if ($questionstats->for_slot($slot)->get_sub_question_ids() || $questionstats->for_slot($slot)->get_variants()) {
+ if (!$this->table->is_downloading()) {
+ $number = $questionstats->for_slot($slot)->question->number;
+ echo $OUTPUT->heading(get_string('slotstructureanalysis', 'quiz_statistics', $number), 3);
+ }
+ $this->table->define_baseurl(new moodle_url($reporturl, array('slot' => $slot)));
+ $this->table->format_and_add_array_of_rows($questionstats->structure_analysis_for_one_slot($slot));
+ } else {
+ $this->output_individual_question_data($quiz, $questionstats->for_slot($slot));
+ $this->output_individual_question_response_analysis($questions[$slot],
+ $questionstats->for_slot($slot)->s,
+ $reporturl,
+ $qubaids);
- // Back to overview link.
- echo $OUTPUT->box('<a href="' . $reporturl->out() . '">' .
- get_string('backtoquizreport', 'quiz_statistics') . '</a>',
- 'backtomainstats boxaligncenter generalbox boxwidthnormal mdl-align');
+ }
+ if (!$this->table->is_downloading()) {
+ // Back to overview link.
+ echo $OUTPUT->box('<a href="' . $reporturl->out() . '">' .
+ get_string('backtoquizreport', 'quiz_statistics') . '</a>',
+ 'backtomainstats boxaligncenter generalbox boxwidthnormal mdl-align');
+ } else {
+ $this->table->finish_output();
+ }
} else if ($qid) {
// Report on an individual sub-question indexed questionid.
*/
protected function output_quiz_structure_analysis_table($questionstats) {
$tooutput = array();
+ $limitvariants = !$this->table->is_downloading();
foreach ($questionstats->get_all_slots() as $slot) {
// Output the data for these question statistics.
- $tooutput[] = $questionstats->for_slot($slot);
-
- $limitvariants = !$this->table->is_downloading();
- $tooutput = array_merge($tooutput, $questionstats->all_subq_and_variant_stats_for_slot($slot, $limitvariants));
+ $tooutput = array_merge($tooutput, $questionstats->structure_analysis_for_one_slot($slot, $limitvariants));
}
$this->table->format_and_add_array_of_rows($tooutput);
}
return $name;
}
- $url = null;
- if ($questionstat->subquestion) {
- $url = new moodle_url($this->baseurl, array('qid' => $questionstat->questionid));
- } else if ($questionstat->slot && $questionstat->question->qtype != 'random') {
- $url = new moodle_url($this->baseurl, array('slot' => $questionstat->slot));
+ $baseurl = new moodle_url($this->baseurl);
+ if (is_null($questionstat->variant)) {
+ if ($questionstat->subquestion && !$questionstat->get_variants()) {
+ $url = new moodle_url($baseurl, array('qid' => $questionstat->questionid));
+ $name = html_writer::link($url, $name, array('title' => get_string('detailedanalysis', 'quiz_statistics')));
+ } else if ($baseurl->param('slot') === null && $questionstat->slot) {
+ $number = $questionstat->question->number;
+ $url = new moodle_url($baseurl, array('slot' => $questionstat->slot));
+ if ($questionstat->get_variants() || $questionstat->get_sub_question_ids()) {
+ $name = html_writer::link($url,
+ $name,
+ array('title' => get_string('slotstructureanalysis', 'quiz_statistics', $number)));
+ } else {
+ $name = html_writer::link($url,
+ $name,
+ array('title' => get_string('detailedanalysis', 'quiz_statistics')));
+ }
+ }
}
- if ($url) {
- $name = html_writer::link($url, $name,
- array('title' => get_string('detailedanalysis', 'quiz_statistics')));
- }
if ($this->is_dubious_question($questionstat)) {
$name = html_writer::tag('div', $name, array('class' => 'dubious'));
protected function col_effective_weight($questionstat) {
global $OUTPUT;
- if ($questionstat->subquestion) {
+ if (is_null($questionstat->effectiveweight)) {
return '';
}
}
}
- /**
- * Array of variants that have appeared in the attempt data for a question in one slot.
- *
- * @param $slot
- * @return int[]
- */
- public function get_variants_for_slot($slot) {
- if (count($this->questionstats[$slot]->variantstats) > 1) {
- return array_keys($this->questionstats[$slot]->variantstats);
- } else {
- return false;
- }
- }
-
/**
* Reference to position stats instance for a slot and optional variant no.
*
*/
protected function all_variant_stats_for_one_slot($slot) {
$toreturn = array();
- if ($variants = $this->get_variants_for_slot($slot)){
- foreach ($variants as $variant) {
- $toreturn[] = $this->for_slot($slot, $variant);
- }
+ foreach ($this->for_slot($slot)->get_variants() as $variant) {
+ $toreturn[] = $this->for_slot($slot, $variant);
}
return $toreturn;
}
* - variants of randomly selected questions
* - randomly selected questions
*
- * @param int $slot
- * @param bool $limited
- * @return calculated[]
+ * @param int $slot the slot no
+ * @param bool $limited limit number of variants and sub-questions displayed?
+ * @return calculated|calculated_for_subquestion[] stats to display
*/
- public function all_subq_and_variant_stats_for_slot($slot, $limited) {
+ protected function all_subq_and_variant_stats_for_slot($slot, $limited) {
// Random question in this slot?
if ($this->for_slot($slot)->get_sub_question_ids()) {
if ($limited) {
}
+ /**
+ * Return all stats for one slot, stats for the slot itself, and either :
+ * - variants of question
+ * - variants of randomly selected questions
+ * - randomly selected questions
+ *
+ * @param int $slot the slot no
+ * @param int $limitvariants limit number of variants and sub-questions displayed?
+ * @return calculated|calculated_for_subquestion[] stats to display
+ */
+ public function structure_analysis_for_one_slot($slot, $limitvariants = false) {
+ return array_merge(array($this->for_slot($slot)),
+ $this->all_subq_and_variant_stats_for_slot($slot, $limitvariants));
+ }
+
/**
* We need a new object for display. Sub-question stats can appear more than once in different slots.
* So we create a clone of the object and then we can set properties on the object that are per slot.
return array();
}
}
+
+ /**
+ * Array of variants that have appeared in the attempt data for this question.
+ *
+ * @return int[]
+ */
+ public function get_variants() {
+ $variants = array_keys($this->variantstats);
+ if (count($variants) > 1) {
+ return $variants;
+ } else {
+ return array();
+ }
+ }
}