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
namespace format_singleactivity\output;
18
 
19
use core_courseformat\output\section_renderer;
20
 
21
/**
22
 * Renderer for outputting the singleactivity course format.
23
 *
24
 * @package    format_singleactivity
25
 * @copyright  2013 Marina Glancy
26
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 */
28
class renderer extends section_renderer {
29
 
30
    /**
31
     * Displays the activities list in cases when course view page is not
32
     * redirected to the activity page.
33
     *
34
     * @param stdClass $course record from table course
35
     * @param bool $orphaned if false displays the main activity (if present)
36
     *     if true displays all other activities
37
     */
38
    public function display($course, $orphaned) {
39
 
40
        $format = course_get_format($course);
41
        $modinfo = $format->get_modinfo();
42
        $cmlistclass = $format->get_output_classname('content\\section\\cmlist');
43
 
44
        $output = '';
45
 
46
        if ($orphaned) {
47
            if (!empty($modinfo->sections[1])) {
48
                $output .= $this->output->heading(get_string('orphaned', 'format_singleactivity'), 3, 'sectionname');
49
                $output .= $this->output->box(get_string('orphanedwarning', 'format_singleactivity'));
50
 
51
                $section = $modinfo->get_section_info(1);
52
                $output .= $this->render(new $cmlistclass($format, $section));
53
            }
54
        } else {
55
            $section = $modinfo->get_section_info(0);
56
            $output .= $this->render(new $cmlistclass($format, $section));
57
 
58
            if (empty($modinfo->sections[0]) && course_get_format($course)->activity_has_subtypes()) {
59
                // Course format was unable to automatically redirect to add module page.
60
                $output .= $this->course_section_add_cm_control($course, 0, 0);
61
            }
62
        }
63
        return $output;
64
    }
65
}