From 1ecd3c304d82c5f4263ddc3963b4a60467ddda2c Mon Sep 17 00:00:00 2001 From: Jayesh Anandani Date: Thu, 9 May 2013 19:55:26 +0530 Subject: [PATCH] MDL-39155 Quiz: Provide 3 image-size options on the settings page --- mod/quiz/attemptlib.php | 7 ++++--- mod/quiz/lang/en/quiz.php | 3 +++ mod/quiz/locallib.php | 15 +++++++++++++++ mod/quiz/mod_form.php | 6 ++++-- mod/quiz/settings.php | 10 ++++++++-- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/mod/quiz/attemptlib.php b/mod/quiz/attemptlib.php index 0585941dcdc..2da7835dd8d 100644 --- a/mod/quiz/attemptlib.php +++ b/mod/quiz/attemptlib.php @@ -1683,14 +1683,15 @@ abstract class quiz_nav_panel_base { public function user_picture() { global $DB; - - if (!$this->attemptobj->get_quiz()->showuserpicture) { + if ($this->attemptobj->get_quiz()->showuserpicture == QUIZ_SHOWIMAGE_NONE) { return null; } - $user = $DB->get_record('user', array('id' => $this->attemptobj->get_userid())); $userpicture = new user_picture($user); $userpicture->courseid = $this->attemptobj->get_courseid(); + if ($this->attemptobj->get_quiz()->showuserpicture == QUIZ_SHOWIMAGE_LARGE) { + $userpicture->size = true; + } return $userpicture; } } diff --git a/mod/quiz/lang/en/quiz.php b/mod/quiz/lang/en/quiz.php index 7c902dbd95e..c6a4f8b059c 100644 --- a/mod/quiz/lang/en/quiz.php +++ b/mod/quiz/lang/en/quiz.php @@ -770,9 +770,12 @@ $string['showdetailedmarks'] = 'Show mark details'; $string['showeachpage'] = 'Show one page at a time'; $string['showfeedback'] = 'After answering, show feedback?'; $string['showinsecurepopup'] = 'Use a \'secure\' popup window for attempts'; +$string['showlargeimage'] = 'Large image'; $string['shownoattempts'] = 'Show students with no attempts'; $string['shownoattemptsonly'] = 'Show only students with no attempts'; +$string['shownoimage'] = 'No image'; $string['showreport'] = 'Show report'; +$string['showsmallimage'] = 'Small image'; $string['showteacherattempts'] = 'Show teacher attempts'; $string['showuserpicture'] = 'Show the user\'s picture'; $string['showuserpicture_help'] = 'If enabled, the student\'s name and picture will be shown on-screen during the attempt, and on the review screen, making it easier to check that the student is logged in as themself in an invigilated (proctored) exam.'; diff --git a/mod/quiz/locallib.php b/mod/quiz/locallib.php index a366a8425b3..fd9a9fb50bf 100644 --- a/mod/quiz/locallib.php +++ b/mod/quiz/locallib.php @@ -55,6 +55,21 @@ define('QUIZ_SHOW_TIME_BEFORE_DEADLINE', '3600'); */ define('QUIZ_MIN_TIME_TO_CONTINUE', '2'); +/** + * @var int We show no image when user selects No image from dropdown menu in quiz settings. + */ +define('QUIZ_SHOWIMAGE_NONE', 0); + +/** + * @var int We show small image when user selects small image from dropdown menu in quiz settings. + */ +define('QUIZ_SHOWIMAGE_SMALL', 1); + +/** + * @var int We show Large image when user selects Large image from dropdown menu in quiz settings. + */ +define('QUIZ_SHOWIMAGE_LARGE', 2); + // Functions related to attempts /////////////////////////////////////////////// diff --git a/mod/quiz/mod_form.php b/mod/quiz/mod_form.php index a7b98a1fd3c..2580b2839b2 100644 --- a/mod/quiz/mod_form.php +++ b/mod/quiz/mod_form.php @@ -249,8 +249,10 @@ class mod_quiz_mod_form extends moodleform_mod { $mform->addElement('header', 'display', get_string('display', 'form')); // Show user picture. - $mform->addElement('selectyesno', 'showuserpicture', - get_string('showuserpicture', 'quiz')); + $mform->addElement('select', 'showuserpicture', get_string('showuserpicture', 'quiz'), array( + QUIZ_SHOWIMAGE_NONE => get_string('shownoimage', 'quiz'), + QUIZ_SHOWIMAGE_SMALL => get_string('showsmallimage', 'quiz'), + QUIZ_SHOWIMAGE_LARGE => get_string('showlargeimage', 'quiz'))); $mform->addHelpButton('showuserpicture', 'showuserpicture', 'quiz'); $mform->setAdvanced('showuserpicture', $quizconfig->showuserpicture_adv); $mform->setDefault('showuserpicture', $quizconfig->showuserpicture); diff --git a/mod/quiz/settings.php b/mod/quiz/settings.php index 66ca1bad1b7..cc99350d9d6 100644 --- a/mod/quiz/settings.php +++ b/mod/quiz/settings.php @@ -28,6 +28,7 @@ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot . '/mod/quiz/lib.php'); require_once($CFG->dirroot . '/mod/quiz/settingslib.php'); +require_once($CFG->dirroot . '/mod/quiz/locallib.php'); // First get a list of quiz reports with there own settings pages. If there none, // we use a simpler overall menu structure. @@ -152,9 +153,14 @@ foreach (mod_quiz_admin_review_setting::fields() as $field => $name) { } // Show the user's picture. -$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/showuserpicture', +$options = array( + QUIZ_SHOWIMAGE_NONE => get_string('shownoimage', 'quiz'), + QUIZ_SHOWIMAGE_SMALL => get_string('showsmallimage', 'quiz'), + QUIZ_SHOWIMAGE_LARGE => get_string('showlargeimage', 'quiz')); + +$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/showuserpicture', get_string('showuserpicture', 'quiz'), get_string('configshowuserpicture', 'quiz'), - array('value' => 0, 'adv' => false))); + array('value' => QUIZ_SHOWIMAGE_NONE, 'adv' => false), $options)); // Decimal places for overall grades. $options = array();