diff --git a/mod/quiz/attemptlib.php b/mod/quiz/attemptlib.php index 73164340e5a..b4c2c2fcc90 100644 --- a/mod/quiz/attemptlib.php +++ b/mod/quiz/attemptlib.php @@ -745,6 +745,28 @@ class quiz_attempt { array_intersect(array_keys($teachersgroups), array_keys($studentsgroups)); } + /** + * Get extra summary information about this attempt. + * + * Some behaviours may be able to provide interesting summary information + * about the attempt as a whole, and this method provides access to that data. + * To see how this works, try setting a quiz to one of the CBM behaviours, + * and then look at the extra information displayed at the top of the quiz + * review page once you have sumitted an attempt. + * + * In the return value, the array keys are identifiers of the form + * qbehaviour_behaviourname_meaningfullkey. For qbehaviour_deferredcbm_highsummary. + * The values are arrays with two items, title and content. Each of these + * will be either a string, or a renderable. + * + * @param question_display_options $options display options. Indicates what types + * of information should, or should not, be returned. + * @return array as described above. + */ + public function get_additional_summary_data(question_display_options $options) { + return $this->quba->get_summary_information($options); + } + /** * Get the overall feedback corresponding to a particular mark. * @param $grade a particular grade. diff --git a/mod/quiz/lang/en/quiz.php b/mod/quiz/lang/en/quiz.php index 432fb24af4d..e73c79a26d7 100644 --- a/mod/quiz/lang/en/quiz.php +++ b/mod/quiz/lang/en/quiz.php @@ -527,7 +527,7 @@ To arrange the questions over a number of pages, click the Repaginate button and $string['orderingquiz'] = 'Order and paging'; $string['orderingquizx'] = 'Order and paging: {$a}'; $string['outcomesadvanced'] = 'Outcomes are advanced settings'; -$string['outof'] = '{$a->grade} out of a maximum of {$a->maxgrade}'; +$string['outof'] = '{$a->grade} out of {$a->maxgrade}'; $string['outofpercent'] = '{$a->grade} out of a maximum of {$a->maxgrade} ({$a->percent}%)'; $string['outofshort'] = '{$a->grade}/{$a->maxgrade}'; $string['overallfeedback'] = 'Overall feedback'; diff --git a/mod/quiz/review.php b/mod/quiz/review.php index eacc703e27b..ad34fa55633 100644 --- a/mod/quiz/review.php +++ b/mod/quiz/review.php @@ -228,6 +228,9 @@ if ($options->marks >= question_display_options::MARK_AND_MAX && quiz_has_grades } } +// Any additional summary data from the behaviour. +$summarydata = array_merge($summarydata, $attemptobj->get_additional_summary_data($options)); + // Feedback if there is any, and the user is allowed to see it now. $feedback = $attemptobj->get_overall_feedback($grade); if ($options->overallfeedback && $feedback) { diff --git a/question/behaviour/behaviourtypebase.php b/question/behaviour/behaviourtypebase.php index 22134ddb0b0..f2437022831 100644 --- a/question/behaviour/behaviourtypebase.php +++ b/question/behaviour/behaviourtypebase.php @@ -69,6 +69,31 @@ abstract class question_behaviour_type { public function adjust_random_guess_score($fraction) { return $fraction; } + + /** + * Get summary information about a queston usage. + * + * Behaviours are not obliged to do anything here, but this is an opportunity + * to provide additional information that can be displayed in places like + * at the top of the quiz review page. + * + * In the return value, the array keys should be identifiers of the form + * qbehaviour_behaviourname_meaningfullkey. For qbehaviour_deferredcbm_highsummary. + * The values should be arrays with two items, title and content. Each of these + * should be either a string, or a renderable. + * + * To understand how to implement this method, look at the CBM behaviours, + * and their unit tests. + * + * @param question_usage_by_activity $quba the usage to provide summary data for. + * @param question_display_options $options display options. Indicates what types + * of information should, or should not, be returned. + * @return array as described above. + */ + public function summarise_usage(question_usage_by_activity $quba, + question_display_options $options) { + return array(); + } } diff --git a/question/engine/questionusage.php b/question/engine/questionusage.php index be165b488d8..b478f6726b0 100644 --- a/question/engine/questionusage.php +++ b/question/engine/questionusage.php @@ -326,6 +326,29 @@ class question_usage_by_activity { return $mark; } + /** + * Get summary information about this usage. + * + * Some behaviours may be able to provide interesting summary information + * about the attempt as a whole, and this method provides access to that data. + * To see how this works, try setting a quiz to one of the CBM behaviours, + * and then look at the extra information displayed at the top of the quiz + * review page once you have sumitted an attempt. + * + * In the return value, the array keys are identifiers of the form + * qbehaviour_behaviourname_meaningfullkey. For qbehaviour_deferredcbm_highsummary. + * The values are arrays with two items, title and content. Each of these + * will be either a string, or a renderable. + * + * @param question_display_options $options display options. Indicates what types + * of information should, or should not, be returned. + * @return array as described above. + */ + public function get_summary_information(question_display_options $options) { + return question_engine::get_behaviour_type($this->preferredbehaviour) + ->summarise_usage($this, $options); + } + /** * @return string a simple textual summary of the question that was asked. */