-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.php
95 lines (85 loc) · 2.57 KB
/
view.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
require_once '../../config.php';
require_once 'lib.php';
global $DB, $OUTPUT, $PAGE, $USER;
// Get required parameters
$courseid = required_param('courseid', PARAM_INT);
$blockid = required_param('blockid', PARAM_INT);
$type = required_param('type', PARAM_TEXT);
// Next look for optional variables.
$studentid = optional_param('studentid', $USER->id, PARAM_INT);
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
print_error('invalidcourse', 'block_analytics', $courseid);
}
require_login($course);
$PAGE->set_url('/blocks/analytics/view.php', array('id' => $courseid));
$PAGE->set_pagelayout('standard');
$PAGE->set_heading('Statistic');
$PAGE->set_title('Statistic');
$settingsnode = $PAGE->settingsnav->add(ucfirst($type));
$editurl = new moodle_url('/blocks/analytics/view.php', array('type' => $type, 'courseid' => $courseid, 'blockid' => $blockid));
$editnode = $settingsnode->add('Statistic', $editurl);
$editnode->make_active();
$backurl = new moodle_url('/course/view.php', array('id' => $courseid));
// Check permission
$permission = 0;
$context = context_course::instance($courseid);
if ( has_capability('block/analytics:managepages', $context) ) {
// Teacher Mode
$permission = 2;
} else if ( has_capability('block/analytics:studentview', $context) ) {
$permission = 1;
} else {
// Guest Mode
$permission = 0;
}
// Set view based on type and permission
if ($permission == 2) {
echo $OUTPUT->header();
require_once 'views/print.php';
switch ($type) {
case 'student' : {
require_once 'views/students.php';
echo view_print();
echo view_students($courseid, $blockid);
break;
}
case 'class' : {
require_once 'views/classreport.php';
echo view_print();
echo view_classreport($courseid);
break;
}
case 'correlation' : {
require_once 'views/correlation.php';
echo view_print();
echo view_correlation($courseid);
break;
}
case 'progress' : {
require_once 'views/quiz.php';
require_once 'views/groups.php';
require_once 'views/performance.php';
echo view_print();
echo view_quiz($studentid);
echo view_groups($studentid);
echo view_performance($studentid);
break;
}
}
echo $OUTPUT->footer();
} else if ($permission == 1 && $type == 'progress') {
echo $OUTPUT->header();
require_once 'views/quiz.php';
require_once 'views/groups.php';
require_once 'views/performance.php';
require_once 'views/print.php';
echo view_print();
echo view_quiz($studentid);
echo view_groups($studentid);
echo view_performance($studentid);
echo $OUTPUT->footer();
} else {
// Unathorized
redirect($backurl);
}