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 competency plan page class.
19
 *
20
 * @package    tool_lp
21
 * @copyright  2016 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
 
26
use renderable;
27
use renderer_base;
28
use templatable;
29
use context_course;
30
use core_competency\external\competency_exporter;
31
use core_competency\external\performance_helper;
32
use stdClass;
33
 
34
/**
35
 * User competency plan navigation class.
36
 *
37
 * @package    tool_lp
38
 * @copyright  2016 Issam Taboubi <issam.taboubi@umontreal.ca>
39
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40
 */
41
class competency_plan_navigation implements renderable, templatable {
42
 
43
    /** @var userid */
44
    protected $userid;
45
 
46
    /** @var competencyid */
47
    protected $competencyid;
48
 
49
    /** @var planid */
50
    protected $planid;
51
 
52
    /** @var baseurl */
53
    protected $baseurl;
54
 
55
    /**
56
     * Construct.
57
     *
58
     * @param int $userid
59
     * @param int $competencyid
60
     * @param int $planid
61
     * @param string $baseurl
62
     */
63
    public function __construct($userid, $competencyid, $planid, $baseurl) {
64
        $this->userid = $userid;
65
        $this->competencyid = $competencyid;
66
        $this->planid = $planid;
67
        $this->baseurl = $baseurl;
68
    }
69
 
70
    /**
71
     * Export the data.
72
     *
73
     * @param renderer_base $output
74
     * @return stdClass
75
     */
76
    public function export_for_template(renderer_base $output) {
77
 
78
        $data = new stdClass();
79
        $data->userid = $this->userid;
80
        $data->competencyid = $this->competencyid;
81
        $data->planid = $this->planid;
82
        $data->baseurl = $this->baseurl;
83
 
84
        $plancompetencies = \core_competency\api::list_plan_competencies($data->planid);
85
        $data->competencies = array();
86
        $helper = new performance_helper();
87
        foreach ($plancompetencies as $plancompetency) {
88
            $context = $helper->get_context_from_competency($plancompetency->competency);
89
            $exporter = new competency_exporter($plancompetency->competency, array('context' => $context));
90
            $competency = $exporter->export($output);
91
            if ($competency->id == $this->competencyid) {
92
                $competency->selected = true;
93
            }
94
            $data->competencies[] = $competency;
95
        }
96
        $data->hascompetencies = count($data->competencies);
97
        return $data;
98
    }
99
}