mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
MDL-45273 remove the need for quiz settings.php to include locallib.php.
This commit is contained in:
parent
de4cd1e047
commit
9ec7a71661
50
mod/quiz/classes/admin_setting_user_image.php
Normal file
50
mod/quiz/classes/admin_setting_user_image.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Admin settings class for the choices for how to display the user's image
|
||||
*
|
||||
* @package mod_quiz
|
||||
* @copyright 2008 Tim Hunt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* Admin settings class for the choices for how to display the user's image.
|
||||
*
|
||||
* Just so we can lazy-load the choices.
|
||||
*
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_quiz_admin_setting_user_image extends admin_setting_configselect_with_advanced {
|
||||
public function load_choices() {
|
||||
global $CFG;
|
||||
|
||||
if (is_array($this->choices)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
$this->choices = quiz_get_user_image_options();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1125,6 +1125,17 @@ function quiz_get_overdue_handling_options() {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array string => lang string the options for whether to display the user's picture.
|
||||
*/
|
||||
function quiz_get_user_image_options() {
|
||||
return array(
|
||||
QUIZ_SHOWIMAGE_NONE => get_string('shownoimage', 'quiz'),
|
||||
QUIZ_SHOWIMAGE_SMALL => get_string('showsmallimage', 'quiz'),
|
||||
QUIZ_SHOWIMAGE_LARGE => get_string('showlargeimage', 'quiz'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $state one of the state constants like IN_PROGRESS.
|
||||
* @return string the human-readable state name.
|
||||
|
@ -252,10 +252,8 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
$mform->addElement('header', 'display', get_string('appearance'));
|
||||
|
||||
// Show user picture.
|
||||
$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->addElement('select', 'showuserpicture', get_string('showuserpicture', 'quiz'),
|
||||
quiz_get_user_image_options());
|
||||
$mform->addHelpButton('showuserpicture', 'showuserpicture', 'quiz');
|
||||
$mform->setAdvanced('showuserpicture', $quizconfig->showuserpicture_adv);
|
||||
$mform->setDefault('showuserpicture', $quizconfig->showuserpicture);
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
require_once($CFG->dirroot . '/mod/quiz/lib.php');
|
||||
|
||||
// First get a list of quiz reports with there own settings pages. If there none,
|
||||
// we use a simpler overall menu structure.
|
||||
@ -150,14 +150,9 @@ foreach (mod_quiz_admin_review_setting::fields() as $field => $name) {
|
||||
}
|
||||
|
||||
// Show the user's picture.
|
||||
$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',
|
||||
$quizsettings->add(new mod_quiz_admin_setting_user_image('quiz/showuserpicture',
|
||||
get_string('showuserpicture', 'quiz'), get_string('configshowuserpicture', 'quiz'),
|
||||
array('value' => QUIZ_SHOWIMAGE_NONE, 'adv' => false), $options));
|
||||
array('value' => 0, 'adv' => false), $options));
|
||||
|
||||
// Decimal places for overall grades.
|
||||
$options = array();
|
||||
|
Loading…
x
Reference in New Issue
Block a user