MDL-49943 mod_choice: display multiple answers in complete report

This commit is contained in:
Marina Glancy 2016-05-25 21:21:19 +08:00
parent 6a74e76fb8
commit 42dfbb5416

View File

@ -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");
}