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\userreport;
|
|
|
32 |
use block_dedication\lib\utils;
|
|
|
33 |
|
|
|
34 |
$courseid = required_param('id', PARAM_INT);
|
|
|
35 |
$userid = required_param('userid', PARAM_INT);
|
|
|
36 |
|
|
|
37 |
$course = $DB->get_record('course', ['id' => $courseid], '*', MUST_EXIST);
|
|
|
38 |
require_login($course);
|
|
|
39 |
$context = context_course::instance($course->id);
|
|
|
40 |
if ($userid <> $USER->id) {
|
|
|
41 |
require_capability('block/dedication:viewreports', $context);
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
$user = $DB->get_record('user', ['id' => $userid], '*', MUST_EXIST);
|
|
|
45 |
|
|
|
46 |
$PAGE->set_url('/block/dedication/user.php', ['id' => $courseid, 'userid' => $userid]);
|
|
|
47 |
$PAGE->set_pagelayout('report');
|
|
|
48 |
$PAGE->add_body_class('limitedwidth');
|
|
|
49 |
$PAGE->set_title("$course->fullname: ".get_string('sessionduration', 'block_dedication').": ".fullname($user));
|
|
|
50 |
$PAGE->set_heading($course->fullname);
|
|
|
51 |
$PAGE->set_context($context);
|
|
|
52 |
|
|
|
53 |
echo $OUTPUT->header();
|
|
|
54 |
echo $OUTPUT->heading(get_string('timespentincourse', 'block_dedication'));
|
|
|
55 |
$lastupdated = get_config('block_dedication', 'lastcalculated');
|
|
|
56 |
if (!empty($lastupdated)) {
|
|
|
57 |
echo html_writer::span(get_string('lastupdated', 'block_dedication',
|
|
|
58 |
userdate($lastupdated, get_string('strftimedatetimeshort', 'core_langconfig'))), 'dimmed_text');
|
|
|
59 |
}
|
|
|
60 |
$usercontext = context_user::instance($user->id);
|
|
|
61 |
$headerinfo = array('heading' => fullname($user), 'user' => $user, 'usercontext' => $usercontext);
|
|
|
62 |
echo $OUTPUT->context_header($headerinfo, 2);
|
|
|
63 |
$sessionlimit = get_config('block_dedication', 'ignore_sessions_limit');
|
|
|
64 |
if (!empty($sessionlimit)) {
|
|
|
65 |
echo html_writer::div(get_string('excludesessionslessthan', 'block_dedication', utils::format_dedication($sessionlimit)));
|
|
|
66 |
}
|
|
|
67 |
$report = system_report_factory::create(userreport::class, context_course::instance($courseid));
|
|
|
68 |
|
|
|
69 |
echo $report->output();
|
|
|
70 |
echo $OUTPUT->footer();
|