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
/**
18
 * User evidence form.
19
 *
20
 * @package    tool_lp
21
 * @copyright  2015 Frédéric Massart - FMCorz.net
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
namespace tool_lp\form;
26
defined('MOODLE_INTERNAL') || die();
27
 
28
use core\form\persistent;
29
 
30
/**
31
 * User evidence form class.
32
 *
33
 * @package    tool_lp
34
 * @copyright  2015 Frédéric Massart - FMCorz.net
35
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36
 */
37
class user_evidence extends persistent {
38
 
39
    protected static $persistentclass = 'core_competency\\user_evidence';
40
 
41
    protected static $foreignfields = array('files');
42
 
43
    public function definition() {
44
        $mform = $this->_form;
45
 
46
        $mform->addElement('hidden', 'userid');
47
        $mform->setType('userid', PARAM_INT);
48
        $mform->setConstant('userid', $this->_customdata['userid']);
49
 
50
        $mform->addElement('header', 'generalhdr', get_string('general'));
51
 
52
        // Name.
53
        $mform->addElement('text', 'name', get_string('userevidencename', 'tool_lp'), 'maxlength="100"');
54
        $mform->setType('name', PARAM_TEXT);
55
        $mform->addRule('name', null, 'required', null, 'client');
56
        $mform->addRule('name', get_string('maximumchars', '', 100), 'maxlength', 100, 'client');
57
        // Description.
58
        $mform->addElement('editor', 'description', get_string('userevidencedescription', 'tool_lp'), array('rows' => 10));
59
        $mform->setType('description', PARAM_CLEANHTML);
60
 
61
        $mform->addElement('url', 'url', get_string('userevidenceurl', 'tool_lp'), array('size' => '60'), array('usefilepicker' => false));
62
        $mform->setType('url', PARAM_RAW_TRIMMED);      // Can not use PARAM_URL, it silently converts bad URLs to ''.
63
        $mform->addHelpButton('url', 'userevidenceurl', 'tool_lp');
64
 
65
        $mform->addElement('filemanager', 'files', get_string('userevidencefiles', 'tool_lp'), array(),
66
            $this->_customdata['fileareaoptions']);
67
        // Disable short forms.
68
        $mform->setDisableShortforms();
69
 
70
        $this->add_action_buttons();
71
    }
72
 
73
}