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
 * Template statistics class
19
 *
20
 * @package    tool_lp
21
 * @copyright  2016 Damyon Wiese
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
namespace tool_lp;
26
defined('MOODLE_INTERNAL') || die();
27
 
28
use core_competency\api;
29
use core_competency\plan;
30
use core_competency\template;
31
 
32
/**
33
 * Template statistics class.
34
 *
35
 * @package    tool_lp
36
 * @copyright  2016 Damyon Wiese
37
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38
 */
39
class template_statistics {
40
 
41
    /** @var $competencycount The number of competencies in the template */
42
    public $competencycount = 0;
43
 
44
    /** @var $unlinkedcompetencycount The number of unlinked competencies in the template */
45
    public $unlinkedcompetencycount = 0;
46
 
47
    /** @var $plancount The number of plans for the template */
48
    public $plancount = 0;
49
 
50
    /** @var $completedplancount The number of completed plans for the template */
51
    public $completedplancount = 0;
52
 
53
    /** @var $usercompetencyplancount The number of competencies in completed plans for the template */
54
    public $usercompetencyplancount = 0;
55
 
56
    /** @var $proficientusercompetencyplancount The number of proficient competencies in completed plans for the template */
57
    public $proficientusercompetencyplancount = 0;
58
 
59
    /** @var $leastproficientcompetencies The competencies in this template that were proficient the least times */
60
    public $leastproficientcompetencies = array();
61
 
62
    /**
63
     * Return the custom definition of the properties of this model.
64
     *
65
     * @param int $templateid The template we want to generate statistics for.
66
     */
67
    public function __construct($templateid) {
68
        $template = new template($templateid);
69
        $this->competencycount = api::count_competencies_in_template($template);
70
        $this->unlinkedcompetencycount = api::count_competencies_in_template_with_no_courses($template);
71
 
72
        $this->plancount = api::count_plans_for_template($template, 0);
73
        $this->completedplancount = api::count_plans_for_template($template, plan::STATUS_COMPLETE);
74
 
75
        $this->usercompetencyplancount = api::count_user_competency_plans_for_template($template);
76
        $this->proficientusercompetencyplancount = api::count_user_competency_plans_for_template($template, true);
77
 
78
        $this->leastproficientcompetencies = api::get_least_proficient_competencies_for_template($template, 0, 3);
79
    }
80
}