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
 * Dedication report.
19
 *
20
 * @package    block_dedication
21
 * @copyright  2022 Canterbury University
22
 * @author     Dan Marsden
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
require('../../config.php');
27
require_once("{$CFG->libdir}/adminlib.php");
28
require_once($CFG->dirroot.'/grade/lib.php');
29
 
30
use core_reportbuilder\system_report_factory;
31
use block_dedication\local\systemreports\course;
32
use block_dedication\lib\utils;
33
 
34
$courseid = required_param('id', PARAM_INT);
35
 
36
if (!$course = $DB->get_record('course', ['id' => $courseid])) {
37
    throw new \moodle_exception('invalidcourseid');
38
}
39
require_login($course);
40
$context = context_course::instance($course->id);
41
require_capability('block/dedication:viewreports', $context);
42
 
43
$PAGE->set_url('/blocks/dedication/index.php', ['id' => $courseid]);
44
$PAGE->set_context($context);
45
$PAGE->set_pagelayout('report');
46
$PAGE->add_body_class('limitedwidth');
47
$PAGE->set_title("$course->fullname: ".get_string('sessionduration', 'block_dedication'));
48
$PAGE->set_heading($course->fullname);
49
 
50
echo $OUTPUT->header();
51
$average = \block_dedication\lib\utils::get_average($course->id);
52
 
53
echo $OUTPUT->heading(get_string('timespentincourse', 'block_dedication'));
54
echo html_writer::div(get_string('totaltimespent', 'block_dedication', $average['total']));
55
echo html_writer::div(get_string('averagetimespent', 'block_dedication', $average['average']));
56
 
57
$config = get_config('block_dedication');
58
 
59
if (!empty($config->ignore_sessions_limit)) {
60
    echo html_writer::div(get_string('excludesessionslessthan', 'block_dedication',
61
                              utils::format_dedication($config->ignore_sessions_limit)));
62
}
63
if (!empty($config->lastcalculated)) {
64
    echo html_writer::span(get_string('lastupdated', 'block_dedication',
65
        userdate($config->lastcalculated, get_string('strftimedatetimeshort', 'core_langconfig'))), 'dimmed_text');
66
}
67
 
68
$report = system_report_factory::create(course::class, context_course::instance($courseid));
69
 
70
echo $report->output();
71
echo $OUTPUT->footer();