mod quiz: MDL-3156 Add an option to display the current user's photo and name on the Quiz attempt and review pages.

This commit is contained in:
tjhunt
2009-01-07 06:32:13 +00:00
parent efacb22422
commit a733c4b98b
10 changed files with 65 additions and 6 deletions
@@ -0,0 +1,7 @@
<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>
+2
View File
@@ -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';
+17 -2
View File
@@ -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 .= '<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);
@@ -914,8 +925,12 @@ abstract class quiz_nav_panel_base {
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);
}
}
+3 -2
View File
@@ -1,5 +1,5 @@
<?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"
>
@@ -32,7 +32,8 @@
<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"/>
+15
View File
@@ -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;
}
+5
View File
@@ -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'));
+2 -1
View File
@@ -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[] = '<tr><th scope="row" class="cell">' . $picture . '</th><td class="cell"><a href="' .
+5
View File
@@ -86,6 +86,11 @@ $quizsettings->add(new admin_setting_yesno_with_advanced('quiz/shuffleanswers',
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++) {
+1 -1
View File
@@ -5,7 +5,7 @@
// 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)?
+8
View File
@@ -4438,6 +4438,14 @@ table.quizreviewsummary td.cell {
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;
}