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 |
* Strings for component 'report_coursestats', language 'en'
|
|
|
19 |
*
|
|
|
20 |
* @package report
|
|
|
21 |
* @subpackage coursestats
|
|
|
22 |
* @copyright 2017 Paulo Jr.
|
|
|
23 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
24 |
*/
|
|
|
25 |
|
|
|
26 |
require(dirname(__FILE__).'/../../config.php');
|
|
|
27 |
require_once($CFG->libdir.'/adminlib.php');
|
|
|
28 |
require(__DIR__. '/constants.php');
|
|
|
29 |
|
|
|
30 |
$usagetype = optional_param('usagetype', ALL_USAGE_TYPE, PARAM_ALPHA); // usage type
|
|
|
31 |
$category = optional_param('category', ALL_CATEGORIES, PARAM_INT);
|
|
|
32 |
|
|
|
33 |
admin_externalpage_setup('reportcoursestats', '', null, '', array('pagelayout'=>'report'));
|
|
|
34 |
|
|
|
35 |
$url = new moodle_url($CFG->wwwroot . '/report/coursestats/main.php?category=' . $category);
|
|
|
36 |
$link = html_writer::link($url, get_string('link_back', 'report_coursestats'));
|
|
|
37 |
|
|
|
38 |
echo $OUTPUT->header();
|
|
|
39 |
|
|
|
40 |
if ($category == ALL_CATEGORIES) {
|
|
|
41 |
$catname = get_string('lb_all_categories', 'report_coursestats');
|
|
|
42 |
$rs = $DB->get_recordset_sql('SELECT * FROM {report_coursestats} cs JOIN {course} co ON co.id = cs.courseid WHERE cs.curr_usage_type = :type AND co.visible = :visible ORDER BY co.shortname',
|
|
|
43 |
array('type'=>$usagetype, 'visible'=>'1'));
|
|
|
44 |
} else {
|
|
|
45 |
$cat = $DB->get_record(COURSE_CATEGORIES_TABLE_NAME, array('id'=>$category));
|
|
|
46 |
$catname = $cat->name;
|
|
|
47 |
|
|
|
48 |
$rs = $DB->get_recordset_sql('SELECT * FROM {report_coursestats} cs JOIN {course} co ON co.id = cs.courseid WHERE cs.curr_usage_type = :type AND co.category = :cat AND co.visible = :visible ORDER BY co.shortname',
|
|
|
49 |
array('type'=>$usagetype, 'cat'=>$category, 'visible'=>'1'));
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
echo $OUTPUT->heading(get_string('lb_category', 'report_coursestats') . ': ' . $catname . ' - ' . $link);
|
|
|
53 |
|
|
|
54 |
$table = new html_table();
|
|
|
55 |
$table->head = array( get_string('lb_course_name', 'report_coursestats'),
|
|
|
56 |
get_string('lb_prev_usage_type', 'report_coursestats'),
|
|
|
57 |
get_string('lb_curr_usage_type', 'report_coursestats'),
|
|
|
58 |
get_string('lb_last_update', 'report_coursestats'));
|
|
|
59 |
foreach ($rs as $cs) {
|
|
|
60 |
$row = array();
|
|
|
61 |
$row[] = '<a href=' . $CFG->wwwroot . '/course/view.php?id=' . $cs->courseid . '>' . $cs->shortname . '</a>';
|
|
|
62 |
|
|
|
63 |
if ($cs->prev_usage_type === FORUM_USAGE_TYPE) {
|
|
|
64 |
$row[] = get_string('lb_forum_usage', 'report_coursestats');
|
|
|
65 |
} else if ($cs->prev_usage_type === REPOSITORY_USAGE_TYPE) {
|
|
|
66 |
$row[] = get_string('lb_repository_usage', 'report_coursestats');
|
|
|
67 |
} else if ($cs->prev_usage_type === ACTIVITY_USAGE_TYPE) {
|
|
|
68 |
$row[] = get_string('lb_activity_usage', 'report_coursestats');
|
|
|
69 |
} else {
|
|
|
70 |
$row[] = get_string('lb_null_usage', 'report_coursestats');
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
if ($cs->curr_usage_type === FORUM_USAGE_TYPE) {
|
|
|
74 |
$row[] = get_string('lb_forum_usage', 'report_coursestats');
|
|
|
75 |
} else if ($cs->curr_usage_type === REPOSITORY_USAGE_TYPE) {
|
|
|
76 |
$row[] = get_string('lb_repository_usage', 'report_coursestats');
|
|
|
77 |
} else if ($cs->curr_usage_type === ACTIVITY_USAGE_TYPE) {
|
|
|
78 |
$row[] = get_string('lb_activity_usage', 'report_coursestats');
|
|
|
79 |
} else {
|
|
|
80 |
$row[] = get_string('lb_null_usage', 'report_coursestats');
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
$row[] = userdate($cs->last_update, get_string('strftimedatefullshort'));
|
|
|
84 |
|
|
|
85 |
$table->data[] = $row;
|
|
|
86 |
}
|
|
|
87 |
$rs->close();
|
|
|
88 |
|
|
|
89 |
echo html_writer::table($table);
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
echo $OUTPUT->footer();
|