本文整理汇总了PHP中quiz_get_grading_options函数的典型用法代码示例。如果您正苦于以下问题:PHP quiz_get_grading_options函数的具体用法?PHP quiz_get_grading_options怎么用?PHP quiz_get_grading_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了quiz_get_grading_options函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load_choices
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_grading_options();
return true;
}
示例2: definition
protected function definition()
{
$mform = $this->_form;
$mform->addElement('header', 'preferencespage', get_string('reportsettings', 'quiz_statistics'));
$options = array();
foreach (array_keys(quiz_get_grading_options()) as $which) {
$options[$which] = \quiz_statistics_calculator::using_attempts_lang_string($which);
}
$mform->addElement('select', 'whichattempts', get_string('calculatefrom', 'quiz_statistics'), $options);
$mform->addElement('submit', 'submitbutton', get_string('preferencessave', 'quiz_overview'));
}
示例3: definition
protected function definition()
{
$mform = $this->_form;
$mform->addElement('header', 'preferencespage', get_string('reportsettings', 'quiz_statistics'));
$options = array();
foreach (array_keys(quiz_get_grading_options()) as $which) {
$options[$which] = \quiz_statistics\calculator::using_attempts_lang_string($which);
}
$mform->addElement('select', 'whichattempts', get_string('calculatefrom', 'quiz_statistics'), $options);
if (quiz_allows_multiple_tries($this->_customdata['quiz'])) {
$mform->addElement('select', 'whichtries', get_string('whichtries', 'quiz_statistics'), array(question_attempt::FIRST_TRY => get_string('firsttry', 'question'), question_attempt::LAST_TRY => get_string('lasttry', 'question'), question_attempt::ALL_TRIES => get_string('alltries', 'question')));
$mform->setDefault('whichtries', question_attempt::LAST_TRY);
}
$mform->addElement('submit', 'submitbutton', get_string('preferencessave', 'quiz_overview'));
}
示例4: quiz_get_grading_option_name
/**
* @param int $option one of the values QUIZ_GRADEHIGHEST, QUIZ_GRADEAVERAGE, QUIZ_ATTEMPTFIRST or QUIZ_ATTEMPTLAST.
* @return the lang string for that option.
*/
function quiz_get_grading_option_name($option)
{
$strings = quiz_get_grading_options();
return $strings[$option];
}
示例5: definition
protected function definition()
{
global $COURSE, $CFG, $DB, $PAGE;
$quizconfig = get_config('quiz');
$mform = $this->_form;
// -------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
// Name.
$mform->addElement('text', 'name', get_string('name'), array('size' => '64'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
} else {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
// Introduction.
$this->add_intro_editor(false, get_string('introduction', 'quiz'));
// -------------------------------------------------------------------------------
$mform->addElement('header', 'timing', get_string('timing', 'quiz'));
// Open and close dates.
$mform->addElement('date_time_selector', 'timeopen', get_string('quizopen', 'quiz'), self::$datefieldoptions);
$mform->addHelpButton('timeopen', 'quizopenclose', 'quiz');
$mform->addElement('date_time_selector', 'timeclose', get_string('quizclose', 'quiz'), self::$datefieldoptions);
// Time limit.
$mform->addElement('duration', 'timelimit', get_string('timelimit', 'quiz'), array('optional' => true));
$mform->addHelpButton('timelimit', 'timelimit', 'quiz');
$mform->setAdvanced('timelimit', $quizconfig->timelimit_adv);
$mform->setDefault('timelimit', $quizconfig->timelimit);
// What to do with overdue attempts.
$mform->addElement('select', 'overduehandling', get_string('overduehandling', 'quiz'), quiz_get_overdue_handling_options());
$mform->addHelpButton('overduehandling', 'overduehandling', 'quiz');
$mform->setAdvanced('overduehandling', $quizconfig->overduehandling_adv);
$mform->setDefault('overduehandling', $quizconfig->overduehandling);
// TODO Formslib does OR logic on disableif, and we need AND logic here.
// $mform->disabledIf('overduehandling', 'timelimit', 'eq', 0);
// $mform->disabledIf('overduehandling', 'timeclose', 'eq', 0);
// Grace period time.
$mform->addElement('duration', 'graceperiod', get_string('graceperiod', 'quiz'), array('optional' => true));
$mform->addHelpButton('graceperiod', 'graceperiod', 'quiz');
$mform->setAdvanced('graceperiod', $quizconfig->graceperiod_adv);
$mform->setDefault('graceperiod', $quizconfig->graceperiod);
$mform->disabledIf('graceperiod', 'overduehandling', 'neq', 'graceperiod');
// -------------------------------------------------------------------------------
// Grade settings.
$this->standard_grading_coursemodule_elements();
$mform->removeElement('grade');
$mform->addElement('hidden', 'grade', $quizconfig->maximumgrade);
$mform->setType('grade', PARAM_FLOAT);
// Number of attempts.
$attemptoptions = array('0' => get_string('unlimited'));
for ($i = 1; $i <= QUIZ_MAX_ATTEMPT_OPTION; $i++) {
$attemptoptions[$i] = $i;
}
$mform->addElement('select', 'attempts', get_string('attemptsallowed', 'quiz'), $attemptoptions);
$mform->setAdvanced('attempts', $quizconfig->attempts_adv);
$mform->setDefault('attempts', $quizconfig->attempts);
// Grading method.
$mform->addElement('select', 'grademethod', get_string('grademethod', 'quiz'), quiz_get_grading_options());
$mform->addHelpButton('grademethod', 'grademethod', 'quiz');
$mform->setAdvanced('grademethod', $quizconfig->grademethod_adv);
$mform->setDefault('grademethod', $quizconfig->grademethod);
if ($this->get_max_attempts_for_any_override() < 2) {
$mform->disabledIf('grademethod', 'attempts', 'eq', 1);
}
// -------------------------------------------------------------------------------
$mform->addElement('header', 'layouthdr', get_string('layout', 'quiz'));
// Shuffle questions.
$shuffleoptions = array(0 => get_string('asshownoneditscreen', 'quiz'), 1 => get_string('shuffledrandomly', 'quiz'));
$mform->addElement('select', 'shufflequestions', get_string('questionorder', 'quiz'), $shuffleoptions, array('id' => 'id_shufflequestions'));
$mform->setAdvanced('shufflequestions', $quizconfig->shufflequestions_adv);
$mform->setDefault('shufflequestions', $quizconfig->shufflequestions);
// Questions per page.
$pageoptions = array();
$pageoptions[0] = get_string('neverallononepage', 'quiz');
$pageoptions[1] = get_string('everyquestion', 'quiz');
for ($i = 2; $i <= QUIZ_MAX_QPP_OPTION; ++$i) {
$pageoptions[$i] = get_string('everynquestions', 'quiz', $i);
}
$pagegroup = array();
$pagegroup[] = $mform->createElement('select', 'questionsperpage', get_string('newpage', 'quiz'), $pageoptions, array('id' => 'id_questionsperpage'));
$mform->setDefault('questionsperpage', $quizconfig->questionsperpage);
if (!empty($this->_cm)) {
$pagegroup[] = $mform->createElement('checkbox', 'repaginatenow', '', get_string('repaginatenow', 'quiz'), array('id' => 'id_repaginatenow'));
$mform->disabledIf('repaginatenow', 'shufflequestions', 'eq', 1);
$PAGE->requires->js('/question/qengine.js');
$module = array('name' => 'mod_quiz_edit', 'fullpath' => '/mod/quiz/edit.js', 'requires' => array('yui2-dom', 'yui2-event', 'yui2-container'), 'strings' => array(), 'async' => false);
$PAGE->requires->js_init_call('quiz_settings_init', null, false, $module);
}
$mform->addGroup($pagegroup, 'questionsperpagegrp', get_string('newpage', 'quiz'), null, false);
$mform->addHelpButton('questionsperpagegrp', 'newpage', 'quiz');
$mform->setAdvanced('questionsperpagegrp', $quizconfig->questionsperpage_adv);
// Navigation method.
$mform->addElement('select', 'navmethod', get_string('navmethod', 'quiz'), quiz_get_navigation_options());
$mform->addHelpButton('navmethod', 'navmethod', 'quiz');
$mform->setAdvanced('navmethod', $quizconfig->navmethod_adv);
$mform->setDefault('navmethod', $quizconfig->navmethod);
// -------------------------------------------------------------------------------
$mform->addElement('header', 'interactionhdr', get_string('questionbehaviour', 'quiz'));
// Shuffle within questions.
//.........这里部分代码省略.........
示例6: attempt_counts_and_averages
/**
* Calculating count and mean of marks for first and ALL attempts by students.
*
* See : http://docs.moodle.org/dev/Quiz_item_analysis_calculations_in_practise
* #Calculating_MEAN_of_grades_for_all_attempts_by_students
* @param int $quizid
* @param \core\dml\sql_join $groupstudentsjoins Contains joins, wheres, params for students in this group.
* @return \stdClass with properties with count and avg with prefixes firstattempts, highestattempts, etc.
*/
protected function attempt_counts_and_averages($quizid, \core\dml\sql_join $groupstudentsjoins)
{
global $DB;
$attempttotals = new \stdClass();
foreach (array_keys(quiz_get_grading_options()) as $which) {
list($fromqa, $whereqa, $qaparams) = quiz_statistics_attempts_sql($quizid, $groupstudentsjoins, $which);
$fromdb = $DB->get_record_sql("SELECT COUNT(*) AS rcount, AVG(sumgrades) AS average FROM {$fromqa} WHERE {$whereqa}", $qaparams);
$fieldprefix = static::using_attempts_string_id($which);
$attempttotals->{$fieldprefix . 'avg'} = $fromdb->average;
$attempttotals->{$fieldprefix . 'count'} = $fromdb->rcount;
}
return $attempttotals;
}
示例7: get_string
} else {
$pagetitle = get_string('generalsettings', 'admin');
}
$quizsettings = new admin_settingpage('modsettingquiz', $pagetitle, 'moodle/site:config');
// Introductory explanation that all the settings are defaults for the add quiz form.
$quizsettings->add(new admin_setting_heading('quizintro', '', get_string('configintro', 'quiz')));
// Time limit
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/timelimit', get_string('timelimitsec', 'quiz'), get_string('configtimelimitsec', 'quiz'), array('value' => '0', 'fix' => false), PARAM_INT));
// Number of attempts
$options = array(get_string('unlimited'));
for ($i = 1; $i <= QUIZ_MAX_ATTEMPT_OPTION; $i++) {
$options[$i] = $i;
}
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/attempts', get_string('attemptsallowed', 'quiz'), get_string('configattemptsallowed', 'quiz'), array('value' => 0, 'fix' => false), $options));
// Grading method.
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/grademethod', get_string('grademethod', 'quiz'), get_string('configgrademethod', 'quiz'), array('value' => QUIZ_GRADEHIGHEST, 'fix' => false), quiz_get_grading_options()));
// Maximum grade
$quizsettings->add(new admin_setting_configtext('quiz/maximumgrade', get_string('maximumgrade'), get_string('configmaximumgrade', 'quiz'), 10, PARAM_INT));
// Shuffle questions
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/shufflequestions', get_string('shufflequestions', 'quiz'), get_string('configshufflequestions', 'quiz'), array('value' => 0, 'adv' => false)));
// Questions per page
$perpage = array();
$perpage[0] = get_string('never');
$perpage[1] = get_string('aftereachquestion', 'quiz');
for ($i = 2; $i <= QUIZ_MAX_QPP_OPTION; ++$i) {
$perpage[$i] = get_string('afternquestions', 'quiz', $i);
}
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/questionsperpage', get_string('newpageevery', 'quiz'), get_string('confignewpageevery', 'quiz'), array('value' => 1, 'fix' => false), $perpage));
// Shuffle within questions
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/shuffleanswers', get_string('shufflewithin', 'quiz'), get_string('configshufflewithin', 'quiz'), array('value' => 1, 'adv' => false)));
// Adaptive mode.
示例8: definition
function definition()
{
global $COURSE, $CFG;
$mform =& $this->_form;
//-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
$mform->addElement('text', 'name', get_string('name'), array('size' => '64'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
} else {
$mform->setType('name', PARAM_CLEAN);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addElement('htmleditor', 'intro', get_string("introduction", "quiz"));
$mform->setType('intro', PARAM_RAW);
$mform->setHelpButton('intro', array('richtext', get_string('helprichtext')));
//-------------------------------------------------------------------------------
$mform->addElement('header', 'timinghdr', get_string('timing', 'form'));
$mform->addElement('date_time_selector', 'timeopen', get_string('quizopen', 'quiz'), array('optional' => true));
$mform->setHelpButton('timeopen', array('timeopen', get_string('quizopen', 'quiz'), 'quiz'));
$mform->addElement('date_time_selector', 'timeclose', get_string('quizclose', 'quiz'), array('optional' => true));
$mform->setHelpButton('timeclose', array('timeopen', get_string('quizclose', 'quiz'), 'quiz'));
$timelimitgrp = array();
$timelimitgrp[] =& $mform->createElement('text', 'timelimit');
$timelimitgrp[] =& $mform->createElement('checkbox', 'timelimitenable', '', get_string('enable'));
$mform->addGroup($timelimitgrp, 'timelimitgrp', get_string('timelimitmin', 'quiz'), array(' '), false);
$mform->setType('timelimit', PARAM_TEXT);
$timelimitgrprules = array();
$timelimitgrprules['timelimit'][] = array(null, 'numeric', null, 'client');
$mform->addGroupRule('timelimitgrp', $timelimitgrprules);
$mform->disabledIf('timelimitgrp', 'timelimitenable');
$mform->setAdvanced('timelimitgrp', $CFG->quiz_fix_timelimit);
$mform->setHelpButton('timelimitgrp', array("timelimit", get_string("quiztimer", "quiz"), "quiz"));
$mform->setDefault('timelimit', $CFG->quiz_timelimit);
$mform->setDefault('timelimitenable', !empty($CFG->quiz_timelimit));
//enforced time delay between quiz attempts add-on
$timedelayoptions = array();
$timedelayoptions[0] = get_string('none');
$timedelayoptions[1800] = get_string('numminutes', '', 30);
$timedelayoptions[3600] = get_string('numminutes', '', 60);
for ($i = 2; $i <= 23; $i++) {
$seconds = $i * 3600;
$timedelayoptions[$seconds] = get_string('numhours', '', $i);
}
$timedelayoptions[86400] = get_string('numhours', '', 24);
for ($i = 2; $i <= 7; $i++) {
$seconds = $i * 86400;
$timedelayoptions[$seconds] = get_string('numdays', '', $i);
}
$mform->addElement('select', 'delay1', get_string("delay1", "quiz"), $timedelayoptions);
$mform->setHelpButton('delay1', array("timedelay1", get_string("delay1", "quiz"), "quiz"));
$mform->setAdvanced('delay1', $CFG->quiz_fix_delay1);
$mform->setDefault('delay1', $CFG->quiz_delay1);
$mform->addElement('select', 'delay2', get_string("delay2", "quiz"), $timedelayoptions);
$mform->setHelpButton('delay2', array("timedelay2", get_string("delay2", "quiz"), "quiz"));
$mform->setAdvanced('delay2', $CFG->quiz_fix_delay2);
$mform->setDefault('delay2', $CFG->quiz_delay2);
//-------------------------------------------------------------------------------
$mform->addElement('header', 'displayhdr', get_string('display', 'form'));
$perpage = array();
for ($i = 0; $i <= 50; ++$i) {
$perpage[$i] = $i;
}
$perpage[0] = get_string('allinone', 'quiz');
$mform->addElement('select', 'questionsperpage', get_string('questionsperpage', 'quiz'), $perpage);
$mform->setHelpButton('questionsperpage', array('questionsperpage', get_string('questionsperpage', 'quiz'), 'quiz'));
$mform->setAdvanced('questionsperpage', $CFG->quiz_fix_questionsperpage);
$mform->setDefault('questionsperpage', $CFG->quiz_questionsperpage);
$mform->addElement('selectyesno', 'shufflequestions', get_string("shufflequestions", "quiz"));
$mform->setHelpButton('shufflequestions', array("shufflequestions", get_string("shufflequestions", "quiz"), "quiz"));
$mform->setAdvanced('shufflequestions', $CFG->quiz_fix_shufflequestions);
$mform->setDefault('shufflequestions', $CFG->quiz_shufflequestions);
$mform->addElement('selectyesno', 'shuffleanswers', get_string("shufflewithin", "quiz"));
$mform->setHelpButton('shuffleanswers', array("shufflewithin", get_string("shufflewithin", "quiz"), "quiz"));
$mform->setAdvanced('shuffleanswers', $CFG->quiz_fix_shuffleanswers);
$mform->setDefault('shuffleanswers', $CFG->quiz_shuffleanswers);
//-------------------------------------------------------------------------------
$mform->addElement('header', 'attemptshdr', get_string('attempts', 'quiz'));
$attemptoptions = array('0' => get_string('unlimited'));
for ($i = 1; $i <= 10; $i++) {
$attemptoptions[$i] = $i;
}
$mform->addElement('select', 'attempts', get_string("attemptsallowed", "quiz"), $attemptoptions);
$mform->setHelpButton('attempts', array("attempts", get_string("attemptsallowed", "quiz"), "quiz"));
$mform->setAdvanced('attempts', $CFG->quiz_fix_attempts);
$mform->setDefault('attempts', $CFG->quiz_attempts);
$mform->addElement('selectyesno', 'attemptonlast', get_string("eachattemptbuildsonthelast", "quiz"));
$mform->setHelpButton('attemptonlast', array("repeatattempts", get_string("eachattemptbuildsonthelast", "quiz"), "quiz"));
$mform->setAdvanced('attemptonlast', $CFG->quiz_fix_attemptonlast);
$mform->setDefault('attemptonlast', $CFG->quiz_attemptonlast);
$mform->addElement('selectyesno', 'adaptive', get_string("adaptive", "quiz"));
$mform->setHelpButton('adaptive', array("adaptive", get_string("adaptive", "quiz"), "quiz"));
$mform->setAdvanced('adaptive', $CFG->quiz_fix_adaptive);
$mform->setDefault('adaptive', $CFG->quiz_optionflags & QUESTION_ADAPTIVE);
//-------------------------------------------------------------------------------
$mform->addElement('header', 'gradeshdr', get_string('grades', 'grades'));
$mform->addElement('select', 'grademethod', get_string("grademethod", "quiz"), quiz_get_grading_options());
$mform->setHelpButton('grademethod', array("grademethod", get_string("grademethod", "quiz"), "quiz"));
$mform->setAdvanced('grademethod', $CFG->quiz_fix_grademethod);
$mform->setDefault('grademethod', $CFG->quiz_grademethod);
//.........这里部分代码省略.........
示例9: definition
protected function definition() {
global $COURSE, $CFG, $DB, $PAGE;
$quizconfig = get_config('quiz');
$mform = $this->_form;
//-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
// Name.
$mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
} else {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
// Introduction.
$this->add_intro_editor(false, get_string('introduction', 'quiz'));
// Open and close dates.
$mform->addElement('date_time_selector', 'timeopen', get_string('quizopen', 'quiz'),
array('optional' => true, 'step' => 1));
$mform->addHelpButton('timeopen', 'quizopenclose', 'quiz');
$mform->addElement('date_time_selector', 'timeclose', get_string('quizclose', 'quiz'),
array('optional' => true, 'step' => 1));
// Time limit.
$mform->addElement('duration', 'timelimit', get_string('timelimit', 'quiz'),
array('optional' => true));
$mform->addHelpButton('timelimit', 'timelimit', 'quiz');
$mform->setAdvanced('timelimit', $quizconfig->timelimit_adv);
$mform->setDefault('timelimit', $quizconfig->timelimit);
// Number of attempts.
$attemptoptions = array('0' => get_string('unlimited'));
for ($i = 1; $i <= QUIZ_MAX_ATTEMPT_OPTION; $i++) {
$attemptoptions[$i] = $i;
}
$mform->addElement('select', 'attempts', get_string('attemptsallowed', 'quiz'),
$attemptoptions);
$mform->setAdvanced('attempts', $quizconfig->attempts_adv);
$mform->setDefault('attempts', $quizconfig->attempts);
// Grading method.
$mform->addElement('select', 'grademethod', get_string('grademethod', 'quiz'),
quiz_get_grading_options());
$mform->addHelpButton('grademethod', 'grademethod', 'quiz');
$mform->setAdvanced('grademethod', $quizconfig->grademethod_adv);
$mform->setDefault('grademethod', $quizconfig->grademethod);
$mform->disabledIf('grademethod', 'attempts', 'eq', 1);
//-------------------------------------------------------------------------------
// Grade settings
$this->standard_grading_coursemodule_elements();
$mform->removeElement('grade');
$mform->addElement('hidden', 'grade', $quizconfig->maximumgrade);
$mform->setType('grade', PARAM_NUMBER);
//-------------------------------------------------------------------------------
$mform->addElement('header', 'layouthdr', get_string('layout', 'quiz'));
// Shuffle questions.
$shuffleoptions = array(
0 => get_string('asshownoneditscreen', 'quiz'),
1 => get_string('shuffledrandomly', 'quiz')
);
$mform->addElement('select', 'shufflequestions', get_string('questionorder', 'quiz'),
$shuffleoptions, array('id' => 'id_shufflequestions'));
$mform->setAdvanced('shufflequestions', $quizconfig->shufflequestions_adv);
$mform->setDefault('shufflequestions', $quizconfig->shufflequestions);
// Questions per page.
$pageoptions = array();
$pageoptions[0] = get_string('neverallononepage', 'quiz');
$pageoptions[1] = get_string('everyquestion', 'quiz');
for ($i = 2; $i <= QUIZ_MAX_QPP_OPTION; ++$i) {
$pageoptions[$i] = get_string('everynquestions', 'quiz', $i);
}
$pagegroup = array();
$pagegroup[] = $mform->createElement('select', 'questionsperpage',
get_string('newpage', 'quiz'), $pageoptions, array('id' => 'id_questionsperpage'));
$mform->setDefault('questionsperpage', $quizconfig->questionsperpage);
if (!empty($this->_cm)) {
$pagegroup[] = $mform->createElement('checkbox', 'repaginatenow', '',
get_string('repaginatenow', 'quiz'), array('id' => 'id_repaginatenow'));
$mform->disabledIf('repaginatenow', 'shufflequestions', 'eq', 1);
$PAGE->requires->yui2_lib('event');
$PAGE->requires->js('/mod/quiz/edit.js');
$PAGE->requires->js_init_call('quiz_settings_init');
}
$mform->addGroup($pagegroup, 'questionsperpagegrp',
get_string('newpage', 'quiz'), null, false);
$mform->addHelpButton('questionsperpagegrp', 'newpage', 'quiz');
$mform->setAdvanced('questionsperpagegrp', $quizconfig->questionsperpage_adv);
//.........这里部分代码省略.........
示例10: definition
function definition() {
global $COURSE, $CFG, $DB, $PAGE;
$quizconfig = get_config('quiz');
$mform =& $this->_form;
//-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
/// Name.
$mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
} else {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
/// Introduction.
$this->add_intro_editor(false, get_string('introduction', 'quiz'));
/// Open and close dates.
$mform->addElement('date_time_selector', 'timeopen', get_string('quizopen', 'quiz'), array('optional' => true));
$mform->addElement('date_time_selector', 'timeclose', get_string('quizclose', 'quiz'), array('optional' => true));
/// Time limit.
$mform->addElement('duration', 'timelimit', get_string('timelimit', 'quiz'), array('optional' => true));
$mform->addHelpButton('timelimit', 'timelimit', 'quiz');
$mform->setAdvanced('timelimit', $quizconfig->timelimit_adv);
$mform->setDefault('timelimit', $quizconfig->timelimit);
/// Number of attempts.
$attemptoptions = array('0' => get_string('unlimited'));
for ($i = 1; $i <= QUIZ_MAX_ATTEMPT_OPTION; $i++) {
$attemptoptions[$i] = $i;
}
$mform->addElement('select', 'attempts', get_string('attemptsallowed', 'quiz'), $attemptoptions);
$mform->setAdvanced('attempts', $quizconfig->attempts_adv);
$mform->setDefault('attempts', $quizconfig->attempts);
/// Grading method.
$mform->addElement('select', 'grademethod', get_string('grademethod', 'quiz'), quiz_get_grading_options());
$mform->addHelpButton('grademethod', 'grademethod', 'quiz');
$mform->setAdvanced('grademethod', $quizconfig->grademethod_adv);
$mform->setDefault('grademethod', $quizconfig->grademethod);
$mform->disabledIf('grademethod', 'attempts', 'eq', 1);
//-------------------------------------------------------------------------------
$mform->addElement('header', 'layouthdr', get_string('layout', 'quiz'));
/// Shuffle questions.
$shuffleoptions = array(0 => get_string('asshownoneditscreen', 'quiz'), 1 => get_string('shuffledrandomly', 'quiz'));
$mform->addElement('select', 'shufflequestions', get_string('questionorder', 'quiz'), $shuffleoptions, array('id' => 'id_shufflequestions'));
$mform->setAdvanced('shufflequestions', $quizconfig->shufflequestions_adv);
$mform->setDefault('shufflequestions', $quizconfig->shufflequestions);
/// Questions per page.
$pageoptions = array();
$pageoptions[0] = get_string('neverallononepage', 'quiz');
$pageoptions[1] = get_string('everyquestion', 'quiz');
for ($i = 2; $i <= QUIZ_MAX_QPP_OPTION; ++$i) {
$pageoptions[$i] = get_string('everynquestions', 'quiz', $i);
}
$pagegroup = array();
$pagegroup[] = &$mform->createElement('select', 'questionsperpage', get_string('newpage', 'quiz'), $pageoptions, array('id' => 'id_questionsperpage'));
$mform->setDefault('questionsperpage', $quizconfig->questionsperpage);
if (!empty($this->_cm)) {
$pagegroup[] = &$mform->createElement('checkbox', 'repaginatenow', '', get_string('repaginatenow', 'quiz'), array('id' => 'id_repaginatenow'));
$mform->disabledIf('repaginatenow', 'shufflequestions', 'eq', 1);
$PAGE->requires->yui2_lib('event');
$PAGE->requires->js('/mod/quiz/edit.js');
}
$mform->addGroup($pagegroup, 'questionsperpagegrp', get_string('newpage', 'quiz'), null, false);
$mform->addHelpButton('questionsperpagegrp', 'newpage', 'quiz');
$mform->setAdvanced('questionsperpagegrp', $quizconfig->questionsperpage_adv);
//-------------------------------------------------------------------------------
$mform->addElement('header', 'interactionhdr', get_string('questionbehaviour', 'quiz'));
/// Shuffle within questions.
$mform->addElement('selectyesno', 'shuffleanswers', get_string('shufflewithin', 'quiz'));
$mform->addHelpButton('shuffleanswers', 'shufflewithin', 'quiz');
$mform->setAdvanced('shuffleanswers', $quizconfig->shuffleanswers_adv);
$mform->setDefault('shuffleanswers', $quizconfig->shuffleanswers);
/// Adaptive mode.
$mform->addElement('selectyesno', 'adaptive', get_string('adaptive', 'quiz'));
$mform->addHelpButton('adaptive', 'adaptive', 'quiz');
$mform->setAdvanced('adaptive', $quizconfig->optionflags_adv);
$mform->setDefault('adaptive', $quizconfig->optionflags & QUESTION_ADAPTIVE);
/// Apply penalties.
$mform->addElement('selectyesno', 'penaltyscheme', get_string('penaltyscheme', 'quiz'));
$mform->addHelpButton('penaltyscheme', 'penaltyscheme', 'quiz');
$mform->setAdvanced('penaltyscheme', $quizconfig->penaltyscheme_adv);
$mform->setDefault('penaltyscheme', $quizconfig->penaltyscheme);
$mform->disabledIf('penaltyscheme', 'adaptive', 'neq', 1);
//.........这里部分代码省略.........
示例11: attempt_counts_and_averages
/**
* Calculating count and mean of marks for first and ALL attempts by students.
*
* See : http://docs.moodle.org/dev/Quiz_item_analysis_calculations_in_practise
* #Calculating_MEAN_of_grades_for_all_attempts_by_students
* @param int $quizid
* @param array $groupstudents
* @return stdClass with properties with count and avg with prefixes firstattempts, highestattempts, etc.
*/
protected function attempt_counts_and_averages($quizid, $groupstudents)
{
global $DB;
list($fromqa, $whereqa, $qaparams) = quiz_statistics_attempts_sql($quizid, $groupstudents);
$selects = array();
foreach (array_keys(quiz_get_grading_options()) as $which) {
$fieldprefix = static::using_attempts_string_id($which);
$condition = quiz_report_grade_method_sql($which);
if ($condition == '') {
$case = '1';
} else {
$case = "CASE WHEN ({$condition}) THEN 1 ELSE 0 END";
}
$selects[] = "\n SUM({$case}) AS {$fieldprefix}count,\n SUM(sumgrades * {$case}) AS {$fieldprefix}total";
}
$select = join(',', $selects);
$attempttotals = $DB->get_record_sql("\n SELECT {$select}\n FROM {$fromqa}\n WHERE {$whereqa}", $qaparams);
foreach (array_keys(quiz_get_grading_options()) as $which) {
$fieldprefix = static::using_attempts_string_id($which);
$attempttotals->{$fieldprefix . 'avg'} = $attempttotals->{$fieldprefix . 'total'} / $attempttotals->{$fieldprefix . 'count'};
unset($attempttotals->{$fieldprefix . 'total'});
}
return $attempttotals;
}