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
 * Front-end class.
19
 *
20
 * @package   availability_coursecompleted
21
 * @copyright 2015 iplusacademy (www.iplusacademy.org)
22
 * @author    Renaat Debleu <info@eWallah.net>
23
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
namespace availability_coursecompleted;
27
 
28
use cm_info;
29
use completion_info;
30
use section_info;
31
use stdClass;
32
 
33
/**
34
 * Front-end class.
35
 *
36
 * @package   availability_coursecompleted
37
 * @copyright 2015 iplusacademy (www.iplusacademy.org)
38
 * @author    Renaat Debleu <info@eWallah.net>
39
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40
 */
41
class frontend extends \core_availability\frontend {
42
    /**
43
     * Decides whether this plugin should be available in a given course. The
44
     * plugin can do this depending on course or system settings.
45
     *
46
     * @param stdClass $course Course object
47
     * @param cm_info $cm Course-module currently being edited (null if none)
48
     * @param section_info $section Section currently being edited (null if Course object)
49
     * @return bool True if there are completion criteria
50
     */
51
    protected function allow_add($course, cm_info $cm = null, section_info $section = null) {
52
        $return = false;
53
        if ($course->enablecompletion == 1) {
54
            $completioninfo = new \completion_info($course);
55
            if (count($completioninfo->get_criteria()) > 0) {
56
                $return = true;
57
            }
58
            unset($completioninfo);
59
        }
60
        return $return;
61
    }
62
}