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 the customcert module for 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
/**
18
 * This files contains the form for verifying a certificate.
19
 *
20
 * @package    mod_customcert
21
 * @copyright  2017 Mark Nelson <markn@moodle.com>
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
namespace mod_customcert;
26
 
27
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
28
 
29
require_once($CFG->libdir . '/formslib.php');
30
 
31
/**
32
 * The form for verifying a certificate.
33
 *
34
 * @package    mod_customcert
35
 * @copyright  2017 Mark Nelson <markn@moodle.com>
36
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37
 */
38
class verify_certificate_form extends \moodleform {
39
 
40
    /**
41
     * Form definition.
42
     */
43
    public function definition() {
44
        $mform =& $this->_form;
45
 
46
        $mform->addElement('text', 'code', get_string('code', 'customcert'));
47
        $mform->setType('code', PARAM_ALPHANUM);
48
 
49
        $mform->addElement('submit', 'verify', get_string('verify', 'customcert'));
50
    }
51
 
52
    /**
53
     * Validation.
54
     *
55
     * @param array $data
56
     * @param array $files
57
     * @return array the errors that were found
58
     */
59
    public function validation($data, $files) {
60
        $errors = [];
61
 
62
        if ($data['code'] === '') {
63
            $errors['code'] = get_string('invalidcode', 'customcert');
64
        }
65
 
66
        return $errors;
67
    }
68
}