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
 * Class containing data for competency_page page
19
 *
20
 * @package    tool_lp
21
 * @copyright  2015 Issam Taboubi <issam.taboubi@umontreal.ca>
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
namespace tool_lp\output;
25
defined('MOODLE_INTERNAL') || die();
26
 
27
use renderable;
28
use templatable;
29
use renderer_base;
30
use stdClass;
31
use core_competency\api;
32
use tool_lp\external\competency_summary_exporter;
33
 
34
/**
35
 * Class containing data for competency summary
36
 *
37
 * @copyright  2015 Issam Taboubi <issam.taboubi@umontreal.ca>
38
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
39
 */
40
class competency_summary implements renderable, templatable {
41
 
42
    /** @var \core_competency\competency_framework $framework This competency framework. */
43
    protected $framework = null;
44
 
45
    /** @var \core_competency\competency $competency. */
46
    protected $competency = null;
47
 
48
    /** @var \core_competency\competency[] $relatedcompetencies List of competencies. */
49
    protected $relatedcompetencies = array();
50
 
51
    /** @var course[] $courses List of courses. */
52
    protected $courses = array();
53
 
54
    /**
55
     * Construct this renderable.
56
     *
57
     * @param \core_competency\competency $competency Competency persistent.
58
     * @param \core_competency\competency_framework $framework framework persistent.
59
     * @param boolean $includerelated Include or not related competencies.
60
     * @param boolean $includecourses Include or not competency courses.
61
     */
62
    public function __construct($competency, $framework, $includerelated, $includecourses) {
63
        $this->competency = $competency;
64
        $this->framework = $framework;
65
        if ($includerelated) {
66
            $this->relatedcompetencies = api::list_related_competencies($competency->get('id'));
67
        }
68
 
69
        if ($includecourses) {
70
            $this->courses = api::list_courses_using_competency($competency->get('id'));
71
        }
72
    }
73
 
74
    /**
75
     * Export this data so it can be used as the context for a mustache template.
76
     *
77
     * @param renderer_base $output Renderer base.
78
     * @return stdClass
79
     */
80
    public function export_for_template(renderer_base $output) {
81
        $related = array(
82
            'context' => $this->framework->get_context(),
83
            'framework' => $this->framework,
84
            'linkedcourses' => $this->courses,
85
            'relatedcompetencies' => $this->relatedcompetencies,
86
            'competency' => $this->competency
87
        );
88
 
89
        $exporter = new competency_summary_exporter($this->competency, $related);
90
        $data = $exporter->export($output);
91
 
92
        return $data;
93
    }
94
}