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
 * Contains the class responsible for data generation during unit tests
19
 *
20
 * @package mod_customcert
21
 * @category test
22
 * @copyright 2017 Mark Nelson <markn@moodle.com>
23
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
/**
27
 * The class responsible for data generation during unit tests
28
 *
29
 * @package mod_customcert
30
 * @category test
31
 * @copyright 2017 Mark Nelson <markn@moodle.com>
32
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33
 */
34
class mod_customcert_generator extends testing_module_generator {
35
 
36
    /**
37
     * Creates an instance of the custom certificate.
38
     *
39
     * @param array|stdClass|null $record
40
     * @param array|null $options
41
     * @return stdClass
42
     */
43
    public function create_instance($record = null, array $options = null) {
44
        $record = (object)(array)$record;
45
 
46
        $defaultsettings = [
47
            'requiredtime' => 0,
48
            'emailstudents' => 0,
49
            'emailteachers' => 0,
50
            'emailothers' => '',
51
            'protection' => '',
52
        ];
53
 
54
        foreach ($defaultsettings as $name => $value) {
55
            if (!isset($record->{$name})) {
56
                $record->{$name} = $value;
57
            }
58
        }
59
 
60
        return parent::create_instance($record, (array)$options);
61
    }
62
}