MDL-60938 mod_choice: Fix rendering of users for choice results
authorJun Pataleta <jun@moodle.com>
Thu, 14 Dec 2017 23:07:57 +0000 (12:07 +1300)
committerJun Pataleta <jun@moodle.com>
Thu, 14 Dec 2017 23:52:16 +0000 (12:52 +1300)
mod/choice/renderer.php

index f33d48a..3d85c7c 100644 (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;
                     }