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
 * Fixture for fake course format testing course format API.
19
 *
20
 * @package    core_course
21
 * @copyright  2014 Marina Glancy
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
class format_theunittest extends core_courseformat\base {
25
 
26
    /**
27
     * Definitions of the additional options that format uses
28
     *
29
     * @param bool $foreditform
30
     * @return array of options
31
     */
32
    public function course_format_options($foreditform = false) {
33
        static $courseformatoptions = false;
34
        if ($courseformatoptions === false) {
35
            $courseformatoptions = array(
36
                'hideoddsections' => array(
37
                    'default' => 0,
38
                    'type' => PARAM_INT,
39
                ),
40
                'summary_editor' => array(
41
                    'default' => '',
42
                    'type' => PARAM_RAW,
43
                ),
44
            );
45
        }
46
        if ($foreditform && !isset($courseformatoptions['hideoddsections']['label'])) {
47
            $sectionmenu = array(
48
 
49
                1 => 'Hide without notice',
50
                2 => 'Hide with notice'
51
            );
52
            $courseformatoptionsedit = array(
53
                'hideoddsections' => array(
54
                    'label' => 'Hide odd sections',
55
                    'element_type' => 'select',
56
                    'element_attributes' => array($sectionmenu),
57
                ),
58
                'summary_editor' => array(
59
                    'label' => 'Summary Text',
60
                    'element_type' => 'editor',
61
                ),
62
            );
63
            $courseformatoptions = array_merge_recursive($courseformatoptions, $courseformatoptionsedit);
64
        }
65
        return $courseformatoptions;
66
    }
67
 
68
    /**
69
     * Allows to specify for modinfo that section is not available even when it is visible and conditionally available.
70
     *
71
     * @param section_info $section
72
     * @param bool $available
73
     * @param string $availableinfo
74
     */
75
    public function section_get_available_hook(section_info $section, &$available, &$availableinfo) {
76
        if (($section->section % 2) && ($hideoddsections = $this->get_course()->hideoddsections)) {
77
            $available = false;
78
            if ($hideoddsections == 2) {
79
                $availableinfo = 'Odd sections are oddly hidden';
80
            } else {
81
                $availableinfo = '';
82
            }
83
        }
84
    }
85
}