MDL-32322 quiz reports: eliminate more duplication.

This commit is contained in:
Tim Hunt 2012-04-04 18:52:23 +01:00
parent 5bf8a1695d
commit 5ca45fddab
3 changed files with 15 additions and 12 deletions

View File

@ -88,4 +88,17 @@ abstract class mod_quiz_attempt_report_form extends moodleform {
* @param MoodleQuickForm $mform the form we are building. * @param MoodleQuickForm $mform the form we are building.
*/ */
protected abstract function definition_inner(MoodleQuickForm $mform); protected abstract function definition_inner(MoodleQuickForm $mform);
/**
* Create the standard checkbox for the 'include highest graded only' option.
*
* @param MoodleQuickForm $mform the form we are building.
*/
protected function create_qmfilter_checkbox(MoodleQuickForm $mform) {
$gm = html_writer::tag('span', quiz_get_grading_option_name(
$this->_customdata['quiz']->grademethod), array('class' => 'highlight'));
return $mform->createElement('advcheckbox', 'qmfilter',
get_string('showattempts', 'quiz_overview'),
get_string('optonlygradedattempts', 'quiz_overview', $gm), null, array(0, 1));
}
} }

View File

@ -38,12 +38,7 @@ class quiz_overview_settings_form extends mod_quiz_attempt_report_form {
protected function definition_inner(MoodleQuickForm $mform) { protected function definition_inner(MoodleQuickForm $mform) {
$showattemptsgrp = array(); $showattemptsgrp = array();
if ($this->_customdata['qmsubselect']) { if ($this->_customdata['qmsubselect']) {
$gm = '<span class="highlight">' . $showattemptsgrp[] = $this->create_qmfilter_checkbox($mform);
quiz_get_grading_option_name($this->_customdata['quiz']->grademethod) .
'</span>';
$showattemptsgrp[] = $mform->createElement('advcheckbox', 'qmfilter',
get_string('showattempts', 'quiz_overview'),
get_string('optonlygradedattempts', 'quiz_overview', $gm), null, array(0, 1));
} }
if (has_capability('mod/quiz:regrade', $this->_customdata['context'])) { if (has_capability('mod/quiz:regrade', $this->_customdata['context'])) {
$showattemptsgrp[] = $mform->createElement('advcheckbox', 'regradefilter', $showattemptsgrp[] = $mform->createElement('advcheckbox', 'regradefilter',

View File

@ -37,12 +37,7 @@ require_once($CFG->dirroot . '/mod/quiz/report/attemptsreport_form.php');
class quiz_responses_settings_form extends mod_quiz_attempt_report_form { class quiz_responses_settings_form extends mod_quiz_attempt_report_form {
protected function definition_inner(MoodleQuickForm $mform) { protected function definition_inner(MoodleQuickForm $mform) {
if ($this->_customdata['qmsubselect']) { if ($this->_customdata['qmsubselect']) {
$gm = '<span class="highlight">' . $mform->addElement($this->create_qmfilter_checkbox($mform));
quiz_get_grading_option_name($this->_customdata['quiz']->grademethod) .
'</span>';
$mform->addElement('advcheckbox', 'qmfilter',
get_string('showattempts', 'quiz_overview'),
get_string('optonlygradedattempts', 'quiz_overview', $gm), null, array(0, 1));
} }
$colsgroup = array(); $colsgroup = array();