Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
use mod_quiz\local\reports\attempts_report;
18
use mod_quiz\local\reports\attempts_report_options_form;
19
 
20
/**
21
 * Quiz responses report settings form.
22
 *
23
 * @copyright 2008 Jean-Michel Vedrine
24
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 */
26
class quiz_responses_settings_form extends attempts_report_options_form {
27
 
28
    protected function other_preference_fields(MoodleQuickForm $mform) {
29
        $mform->addGroup([
30
            $mform->createElement('advcheckbox', 'qtext', '',
31
                get_string('questiontext', 'quiz_responses')),
32
            $mform->createElement('advcheckbox', 'resp', '',
33
                get_string('response', 'quiz_responses')),
34
            $mform->createElement('advcheckbox', 'right', '',
35
                get_string('rightanswer', 'quiz_responses')),
36
        ], 'coloptions', get_string('showthe', 'quiz_responses'), [' '], false);
37
        $mform->disabledIf('qtext', 'attempts', 'eq', attempts_report::ENROLLED_WITHOUT);
38
        $mform->disabledIf('resp',  'attempts', 'eq', attempts_report::ENROLLED_WITHOUT);
39
        $mform->disabledIf('right', 'attempts', 'eq', attempts_report::ENROLLED_WITHOUT);
40
    }
41
 
42
    public function validation($data, $files) {
43
        $errors = parent::validation($data, $files);
44
 
45
        if ($data['attempts'] != attempts_report::ENROLLED_WITHOUT && !(
46
                $data['qtext'] || $data['resp'] || $data['right'])) {
47
            $errors['coloptions'] = get_string('reportmustselectstate', 'quiz');
48
        }
49
 
50
        return $errors;
51
    }
52
 
53
    protected function other_attempt_fields(MoodleQuickForm $mform) {
54
        parent::other_attempt_fields($mform);
55
        if (quiz_allows_multiple_tries($this->_customdata['quiz'])) {
56
            $mform->addElement('select', 'whichtries', get_string('whichtries', 'question'), [
57
                                           question_attempt::FIRST_TRY    => get_string('firsttry', 'question'),
58
                                           question_attempt::LAST_TRY     => get_string('lasttry', 'question'),
59
                                           question_attempt::ALL_TRIES    => get_string('alltries', 'question')]
60
            );
61
            $mform->setDefault('whichtries', question_attempt::LAST_TRY);
62
            $mform->disabledIf('whichtries', 'attempts', 'eq', attempts_report::ENROLLED_WITHOUT);
63
        }
64
    }
65
}