Merge branch 'MDL-44278' of git://github.com/timhunt/moodle
[moodle.git] / mod / quiz / override_form.php
index f526107..8089449 100644 (file)
@@ -158,10 +158,15 @@ class quiz_override_form extends moodleform {
                 }
 
                 $userchoices = array();
+                $canviewemail = in_array('email', get_extra_user_fields($this->context));
                 foreach ($users as $id => $user) {
                     if (empty($invalidusers[$id]) || (!empty($override) &&
                             $id == $override->userid)) {
-                        $userchoices[$id] = fullname($user) . ', ' . $user->email;
+                        if ($canviewemail) {
+                            $userchoices[$id] = fullname($user) . ', ' . $user->email;
+                        } else {
+                            $userchoices[$id] = fullname($user);
+                        }
                     }
                 }
                 unset($users);