MDL-60938 mod_choice: Fix rendering of users for choice results

This commit is contained in:
Jun Pataleta 2017-12-15 12:07:57 +13:00
parent 95b7be7f05
commit af6c39045e

View File

@ -222,32 +222,30 @@ class mod_choice_renderer extends plugin_renderer_base {
$optionusers = '';
foreach ($options->user as $user) {
$data = '';
if (empty($user->imagealt)){
if (empty($user->imagealt)) {
$user->imagealt = '';
}
$userfullname = fullname($user, $choices->fullnamecapability);
$mediabody = '';
$checkbox = '';
if ($choices->viewresponsecapability && $choices->deleterepsonsecapability) {
$checkboxid = 'attempt-user'.$user->id.'-option'.$optionid;
$attemptaction = html_writer::label($userfullname . ' ' . $optionsnames[$optionid],
$checkboxid, false, array('class' => 'accesshide'));
$checkboxid = 'attempt-user' . $user->id . '-option' . $optionid;
$checkbox .= html_writer::label($userfullname . ' ' . $optionsnames[$optionid],
$checkboxid, false, array('class' => 'accesshide'));
if ($optionid > 0) {
$attemptaction .= html_writer::checkbox('attemptid[]', $user->answerid, '', null,
array('id' => $checkboxid));
$checkboxname = 'attemptid[]';
$checkboxvalue = $user->answerid;
} else {
$attemptaction .= html_writer::checkbox('userid[]', $user->id, '', null,
array('id' => $checkboxid));
$checkboxname = 'userid[]';
$checkboxvalue = $user->id;
}
$mediabody .= html_writer::tag('div', $attemptaction, array('class'=>'media-left media-middle p-t-1'));
$checkbox .= html_writer::checkbox($checkboxname, $checkboxvalue, '', null,
array('id' => $checkboxid, 'class' => 'm-r-1'));
}
$userimage = $this->output->user_picture($user, array('courseid' => $choices->courseid));
$mediabody .= html_writer::tag('div', $userimage, array('class' => 'media-left media-middle'));
$userlink = new moodle_url('/user/view.php', array('id'=>$user->id,'course' => $choices->courseid));
$name = html_writer::tag('a', $userfullname, array('href' => $userlink));
$mediabody .= html_writer::tag('div', $name, array('class' => 'media-body media-middle'));
$data .= html_writer::tag('div', $mediabody, array('class' => 'media m-b-1'));
$userimage = $this->output->user_picture($user, array('courseid' => $choices->courseid, 'link' => false));
$profileurl = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $choices->courseid));
$profilelink = html_writer::link($profileurl, $userimage . $userfullname);
$data .= html_writer::div($checkbox . $profilelink, 'm-b-1');
$optionusers .= $data;
}