From 42dfbb54163ce96e2ccc2b4f2c0ca8a040ddc971 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Wed, 25 May 2016 21:21:19 +0800 Subject: [PATCH] MDL-49943 mod_choice: display multiple answers in complete report --- mod/choice/lib.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mod/choice/lib.php b/mod/choice/lib.php index 0deb0a822e7..666df96b9dd 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -79,20 +79,23 @@ function choice_user_outline($course, $user, $mod, $choice) { } /** - * @global object + * Callback for the "Complete" report - prints the activity summary for the given user + * * @param object $course * @param object $user * @param object $mod * @param object $choice - * @return string|void */ function choice_user_complete($course, $user, $mod, $choice) { global $DB; - if ($answer = $DB->get_record('choice_answers', array("choiceid" => $choice->id, "userid" => $user->id))) { - $result = new stdClass(); - $result->info = "'".format_string(choice_get_option_text($choice, $answer->optionid))."'"; - $result->time = $answer->timemodified; - echo get_string("answered", "choice").": $result->info. ".get_string("updated", '', userdate($result->time)); + if ($answers = $DB->get_records('choice_answers', array("choiceid" => $choice->id, "userid" => $user->id))) { + $info = []; + foreach ($answers as $answer) { + $info[] = "'" . format_string(choice_get_option_text($choice, $answer->optionid)) . "'"; + } + core_collator::asort($info); + echo get_string("answered", "choice") . ": ". join(', ', $info) . ". " . + get_string("updated", '', userdate($answer->timemodified)); } else { print_string("notanswered", "choice"); }