diff --git a/lang/en_utf8/help/quiz/showuserpicture.html b/lang/en_utf8/help/quiz/showuserpicture.html
new file mode 100644
index 00000000000..9aa119717d0
--- /dev/null
+++ b/lang/en_utf8/help/quiz/showuserpicture.html
@@ -0,0 +1,7 @@
+
Show the user's picture
+
+If you enable this option, the student's name and picture will be
+ shown on-screen during the attempt, and on the review screen.
+
+One example when you might want to do this is in invigilated (proctored) exams
+ to make it easier to check that the user is logged in as themself.
diff --git a/lang/en_utf8/quiz.php b/lang/en_utf8/quiz.php
index 664190df8e9..2ecde429eee 100644
--- a/lang/en_utf8/quiz.php
+++ b/lang/en_utf8/quiz.php
@@ -155,6 +155,7 @@ $string['configpopup'] = 'Use JavaScript tricks to try to restrict copy and past
$string['configrequirepassword'] = 'Students must enter this password before they can attempt the quiz.';
$string['configrequiresubnet'] = 'Students can only attempt the quiz from these computers.';
$string['configreviewoptions'] = 'These options control what information users can see when they review a quiz attempt or look at the quiz reports.';
+$string['configshowuserpicture'] = 'Show the user\'s picture on screen during attempts.';
$string['configshufflequestions'] = 'If you enable this option, then the order of questions in the quiz will be randomly shuffled each time a student attempts the quiz.';
$string['configshufflewithin'] = 'If you enable this option, then the parts making up the individual questions will be randomly shuffled each time a student starts an attempt at this quiz, provided the option is also enabled in the question settings.';
$string['configtimelimit'] = 'Default time limit for quizzes in minutes. 0 mean no time limit.';
@@ -642,6 +643,7 @@ $string['shownoattempts'] = 'Show students with no attempts';
$string['shownoattemptsonly'] = 'Show only students with no attempts';
$string['showquestiontext'] = 'Show question text in the question list';
$string['showteacherattempts'] = 'Show teacher attempts';
+$string['showuserpicture'] = 'Show the user\'s picture';
$string['shuffle'] = 'Shuffle';
$string['shuffleanswers'] = 'Shuffle answers';
$string['shufflequestions'] = 'Shuffle questions';
diff --git a/mod/quiz/attemptlib.php b/mod/quiz/attemptlib.php
index 541fe508c6d..47fa2c720bf 100644
--- a/mod/quiz/attemptlib.php
+++ b/mod/quiz/attemptlib.php
@@ -896,6 +896,17 @@ abstract class quiz_nav_panel_base {
abstract protected function get_end_bits();
+ protected function get_user_picture() {
+ global $DB;
+ $user = $DB->get_record('user', array('id' => $this->attemptobj->get_userid()));
+ $output = '';
+ $output .= '';
+ $output .= print_user_picture($user, $this->attemptobj->get_courseid(), NULL, 0, true, false);
+ $output .= ' ' . fullname($user);
+ $output .= '
';
+ return $output;
+ }
+
protected function get_question_state_classes($question) {
// The current status of the question.
$classes = $this->attemptobj->get_question_status($question->id);
@@ -914,8 +925,12 @@ abstract class quiz_nav_panel_base {
public function display() {
$strquiznavigation = get_string('quiznavigation', 'quiz');
- $content = $this->get_question_buttons() . "\n" . '' .
- "\n" . $this->get_end_bits() . "\n
\n";
+ $content = '';
+ if ($this->attemptobj->get_quiz()->showuserpicture) {
+ $content .= $this->get_user_picture() . "\n";
+ }
+ $content .= $this->get_question_buttons() . "\n";
+ $content .= '' . "\n" . $this->get_end_bits() . "\n
\n";
print_side_block($strquiznavigation, $content, NULL, NULL, '', array('id' => 'quiznavigation'), $strquiznavigation);
}
}
diff --git a/mod/quiz/db/install.xml b/mod/quiz/db/install.xml
index 0901e614a47..d819845f070 100755
--- a/mod/quiz/db/install.xml
+++ b/mod/quiz/db/install.xml
@@ -1,5 +1,5 @@
-
@@ -32,7 +32,8 @@
-
+
+
diff --git a/mod/quiz/db/upgrade.php b/mod/quiz/db/upgrade.php
index a72b24718d4..6c813ccc9a0 100644
--- a/mod/quiz/db/upgrade.php
+++ b/mod/quiz/db/upgrade.php
@@ -212,6 +212,21 @@ function xmldb_quiz_upgrade($oldversion) {
upgrade_mod_savepoint($result, 2008112101, 'quiz');
}
+ if ($result && $oldversion < 2009010700) {
+
+ /// Define field showuserpicture to be added to quiz
+ $table = new xmldb_table('quiz');
+ $field = new xmldb_field('showuserpicture', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null, null, '0', 'delay2');
+
+ /// Conditionally launch add field showuserpicture
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+
+ /// quiz savepoint reached
+ upgrade_mod_savepoint($result, 2009010700, 'quiz');
+ }
+
return $result;
}
diff --git a/mod/quiz/mod_form.php b/mod/quiz/mod_form.php
index aa16ff235b0..05dce8451fe 100644
--- a/mod/quiz/mod_form.php
+++ b/mod/quiz/mod_form.php
@@ -98,6 +98,11 @@ class mod_quiz_mod_form extends moodleform_mod {
$mform->setAdvanced('shuffleanswers', $quizconfig->fix_shuffleanswers);
$mform->setDefault('shuffleanswers', $quizconfig->shuffleanswers);
+ $mform->addElement('selectyesno', 'showuserpicture', get_string('showuserpicture', 'quiz'));
+ $mform->setHelpButton('showuserpicture', array('showuserpicture', get_string('showuserpicture', 'quiz'), 'quiz'));
+ $mform->setAdvanced('showuserpicture', $quizconfig->fix_showuserpicture);
+ $mform->setDefault('showuserpicture', $quizconfig->showuserpicture);
+
//-------------------------------------------------------------------------------
$mform->addElement('header', 'attemptshdr', get_string('attempts', 'quiz'));
$attemptoptions = array('0' => get_string('unlimited'));
diff --git a/mod/quiz/review.php b/mod/quiz/review.php
index 7b885fa5df2..9c48ac108fe 100644
--- a/mod/quiz/review.php
+++ b/mod/quiz/review.php
@@ -136,7 +136,8 @@
/// First we assemble all the rows that are appopriate to the current situation in
/// an array, then later we only output the table if there are any rows to show.
$rows = array();
- if ($attemptobj->get_userid() <> $USER->id) {
+ if (!$attemptobj->get_quiz()->showuserpicture && $attemptobj->get_userid() <> $USER->id) {
+ /// If showuserpicture is true, the picture is shown elsewhere, so don't repeat it.
$student = $DB->get_record('user', array('id' => $attemptobj->get_userid()));
$picture = print_user_picture($student, $attemptobj->get_courseid(), $student->picture, false, true);
$rows[] = '| ' . $picture . ' | |
|---|