--- /dev/null
+<h1>Show the user's picture</h1>
+
+<p>If you enable this option, the student's name and picture will be
+ shown on-screen during the attempt, and on the review screen.</p>
+
+<p>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.</p>
$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.';
$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';
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 .= '<div id="user-picture" class="clearfix">';
+ $output .= print_user_picture($user, $this->attemptobj->get_courseid(), NULL, 0, true, false);
+ $output .= ' ' . fullname($user);
+ $output .= '</div>';
+ return $output;
+ }
+
protected function get_question_state_classes($question) {
// The current status of the question.
$classes = $this->attemptobj->get_question_status($question->id);
public function display() {
$strquiznavigation = get_string('quiznavigation', 'quiz');
- $content = $this->get_question_buttons() . "\n" . '<div class="othernav">' .
- "\n" . $this->get_end_bits() . "\n</div>\n";
+ $content = '';
+ if ($this->attemptobj->get_quiz()->showuserpicture) {
+ $content .= $this->get_user_picture() . "\n";
+ }
+ $content .= $this->get_question_buttons() . "\n";
+ $content .= '<div class="othernav">' . "\n" . $this->get_end_bits() . "\n</div>\n";
print_side_block($strquiznavigation, $content, NULL, NULL, '', array('id' => 'quiznavigation'), $strquiznavigation);
}
}
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/quiz/db" VERSION="20081121" COMMENT="XMLDB file for Moodle mod/quiz"
+<XMLDB PATH="mod/quiz/db" VERSION="20090107" COMMENT="XMLDB file for Moodle mod/quiz"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<FIELD NAME="subnet" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="password" NEXT="popup"/>
<FIELD NAME="popup" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="subnet" NEXT="delay1"/>
<FIELD NAME="delay1" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="popup" NEXT="delay2"/>
- <FIELD NAME="delay2" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="delay1"/>
+ <FIELD NAME="delay2" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="delay1" NEXT="showuserpicture"/>
+ <FIELD NAME="showuserpicture" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Option to show the user's picture during the attempt and on the review page." PREVIOUS="delay2"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
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;
}
$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'));
/// 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[] = '<tr><th scope="row" class="cell">' . $picture . '</th><td class="cell"><a href="' .
get_string('shufflewithin', 'quiz'), get_string('configshufflewithin', 'quiz'),
array('value' => 1, 'fix' => false)));
+// showuserpicture
+$quizsettings->add(new admin_setting_yesno_with_advanced('quiz/showuserpicture',
+ get_string('showuserpicture', 'quiz'), get_string('configshowuserpicture', 'quiz'),
+ array('value' => 0, 'fix' => false)));
+
// attempts
$options = array(get_string('unlimited'));
for ($i = 1; $i <= 6; $i++) {
// This fragment is called by moodle_needs_upgrading() and /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2008112101; // The (date) version of this module
+$module->version = 2009010700; // The (date) version of this module
$module->requires = 2008072401; // Requires this Moodle version
$module->cron = 0; // How often should cron check this module (seconds)?
cursor: pointer;
white-space: normal;
}
+#quiznavigation #user-picture {
+ margin: 0.5em 0;
+}
+#quiznavigation #user-picture img {
+ width: auto;
+ height: auto;
+ float: left;
+}
#quiznavigation .othernav {
clear: both;
}