2009-07-07 02:26:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
2007-06-15 08:24:45 +00:00
|
|
|
|
2007-07-23 22:20:07 +00:00
|
|
|
require_once '../../../config.php';
|
|
|
|
require_once $CFG->libdir.'/gradelib.php';
|
|
|
|
require_once $CFG->dirroot.'/grade/lib.php';
|
|
|
|
require_once $CFG->dirroot.'/grade/report/user/lib.php';
|
2007-07-14 03:46:24 +00:00
|
|
|
|
2009-04-23 19:27:21 +00:00
|
|
|
$courseid = required_param('id', PARAM_INT);
|
2008-01-17 16:25:48 +00:00
|
|
|
$userid = optional_param('userid', $USER->id, PARAM_INT);
|
2007-07-23 22:20:07 +00:00
|
|
|
|
2010-05-05 03:27:22 +00:00
|
|
|
$PAGE->set_url(new moodle_url('/grade/report/user/index.php', array('id'=>$courseid)));
|
2009-10-15 06:58:21 +00:00
|
|
|
|
2007-07-23 22:20:07 +00:00
|
|
|
/// basic access checks
|
2008-06-03 16:10:57 +00:00
|
|
|
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
2007-07-23 22:20:07 +00:00
|
|
|
print_error('nocourseid');
|
|
|
|
}
|
|
|
|
require_login($course);
|
2010-11-05 02:53:47 +00:00
|
|
|
$PAGE->set_pagelayout('report');
|
2007-07-23 22:20:07 +00:00
|
|
|
|
2009-04-23 19:27:21 +00:00
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
2008-01-17 16:25:48 +00:00
|
|
|
require_capability('gradereport/user:view', $context);
|
2008-01-17 15:08:09 +00:00
|
|
|
|
2008-01-17 16:25:48 +00:00
|
|
|
if (empty($userid)) {
|
|
|
|
require_capability('moodle/grade:viewall', $context);
|
|
|
|
|
|
|
|
} else {
|
2009-04-30 20:09:23 +00:00
|
|
|
if (!$DB->get_record('user', array('id'=>$userid, 'deleted'=>0)) or isguestuser($userid)) {
|
2009-04-23 19:27:21 +00:00
|
|
|
print_error('invaliduser');
|
|
|
|
}
|
2008-01-17 16:25:48 +00:00
|
|
|
}
|
2007-07-23 22:20:07 +00:00
|
|
|
|
2009-04-23 19:27:21 +00:00
|
|
|
$access = false;
|
2007-07-23 22:20:07 +00:00
|
|
|
if (has_capability('moodle/grade:viewall', $context)) {
|
|
|
|
//ok - can view all course grades
|
2009-04-23 19:27:21 +00:00
|
|
|
$access = true;
|
2007-07-23 22:20:07 +00:00
|
|
|
|
2008-01-17 15:08:09 +00:00
|
|
|
} else if ($userid == $USER->id and has_capability('moodle/grade:view', $context) and $course->showgrades) {
|
2007-07-23 22:20:07 +00:00
|
|
|
//ok - can view own grades
|
2009-04-23 19:27:21 +00:00
|
|
|
$access = true;
|
2007-07-23 22:20:07 +00:00
|
|
|
|
2008-08-17 20:18:30 +00:00
|
|
|
} else if (has_capability('moodle/grade:viewall', get_context_instance(CONTEXT_USER, $userid)) and $course->showgrades) {
|
2007-07-23 22:20:07 +00:00
|
|
|
// ok - can view grades of this user- parent most probably
|
2009-04-23 19:27:21 +00:00
|
|
|
$access = true;
|
|
|
|
}
|
2007-07-24 07:45:15 +00:00
|
|
|
|
2009-04-23 19:27:21 +00:00
|
|
|
if (!$access) {
|
|
|
|
// no access to grades!
|
2009-09-30 07:20:31 +00:00
|
|
|
print_error('nopermissiontoviewgrades', 'error', $CFG->wwwroot.'/course/view.php?id='.$courseid);
|
2007-06-15 09:13:13 +00:00
|
|
|
}
|
|
|
|
|
2007-07-23 22:20:07 +00:00
|
|
|
/// return tracking object
|
|
|
|
$gpr = new grade_plugin_return(array('type'=>'report', 'plugin'=>'user', 'courseid'=>$courseid, 'userid'=>$userid));
|
|
|
|
|
|
|
|
/// last selected report session tracking
|
|
|
|
if (!isset($USER->grade_last_report)) {
|
|
|
|
$USER->grade_last_report = array();
|
|
|
|
}
|
|
|
|
$USER->grade_last_report[$course->id] = 'user';
|
|
|
|
|
2007-07-12 19:40:28 +00:00
|
|
|
|
2009-04-23 19:27:21 +00:00
|
|
|
//first make sure we have proper final grades - this must be done before constructing of the grade tree
|
|
|
|
grade_regrade_final_grades($courseid);
|
2007-07-23 22:20:07 +00:00
|
|
|
|
2009-04-23 19:27:21 +00:00
|
|
|
if (has_capability('moodle/grade:viewall', $context)) { //Teachers will see all student reports
|
|
|
|
$groupmode = groups_get_course_groupmode($course); // Groups are being used
|
|
|
|
$currentgroup = groups_get_course_group($course, true);
|
2007-07-23 22:20:07 +00:00
|
|
|
|
2009-04-23 19:27:21 +00:00
|
|
|
if (!$currentgroup) { // To make some other functions work better later
|
|
|
|
$currentgroup = NULL;
|
|
|
|
}
|
2008-02-04 14:29:45 +00:00
|
|
|
|
2009-04-23 19:27:21 +00:00
|
|
|
$isseparategroups = ($course->groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context));
|
2009-02-09 10:49:41 +00:00
|
|
|
|
2009-04-23 19:27:21 +00:00
|
|
|
if ($isseparategroups and (!$currentgroup)) {
|
2009-05-04 12:55:20 +00:00
|
|
|
// no separate group access, can view only self
|
|
|
|
$userid = $USER->id;
|
2010-05-05 03:27:22 +00:00
|
|
|
$user_selector = false;
|
2009-05-04 12:55:20 +00:00
|
|
|
} else {
|
2010-05-05 03:27:22 +00:00
|
|
|
$user_selector = true;
|
2009-04-23 19:27:21 +00:00
|
|
|
}
|
|
|
|
|
2009-04-23 20:29:30 +00:00
|
|
|
if (empty($userid)) {
|
2009-04-23 19:27:21 +00:00
|
|
|
$gui = new graded_users_iterator($course, null, $currentgroup);
|
|
|
|
$gui->init();
|
|
|
|
// Add tabs
|
|
|
|
print_grade_page_head($courseid, 'report', 'user');
|
|
|
|
groups_print_course_menu($course, $gpr->get_return_url('index.php?id='.$courseid, array('userid'=>0)));
|
|
|
|
|
2010-05-05 03:27:22 +00:00
|
|
|
if ($user_selector) {
|
|
|
|
$renderer = $PAGE->get_renderer('gradereport_user');
|
2011-12-02 09:48:36 +08:00
|
|
|
echo $renderer->graded_users_selector('user', $course, $userid, $currentgroup, true);
|
2010-05-05 03:27:22 +00:00
|
|
|
}
|
|
|
|
|
2009-04-23 19:27:21 +00:00
|
|
|
while ($userdata = $gui->next_user()) {
|
|
|
|
$user = $userdata->user;
|
|
|
|
$report = new grade_report_user($courseid, $gpr, $context, $user->id);
|
2011-12-12 15:57:04 +08:00
|
|
|
|
|
|
|
$studentnamelink = html_writer::link(new moodle_url('/user/view.php', array('id' => $report->user->id, 'course' => $courseid)), fullname($report->user));
|
|
|
|
echo $OUTPUT->heading(get_string('pluginname', 'gradereport_user') . ' - ' . $studentnamelink);
|
2009-02-09 10:49:41 +00:00
|
|
|
|
2008-01-17 15:08:09 +00:00
|
|
|
if ($report->fill_table()) {
|
2009-02-09 10:49:41 +00:00
|
|
|
echo '<br />'.$report->print_table(true);
|
2008-06-03 16:10:57 +00:00
|
|
|
}
|
2009-04-23 19:27:21 +00:00
|
|
|
echo "<p style = 'page-break-after: always;'></p>";
|
2008-01-17 15:08:09 +00:00
|
|
|
}
|
2009-04-23 19:27:21 +00:00
|
|
|
$gui->close();
|
2009-04-23 20:29:30 +00:00
|
|
|
} else { // Only show one user's report
|
2008-06-03 16:10:57 +00:00
|
|
|
$report = new grade_report_user($courseid, $gpr, $context, $userid);
|
2011-12-12 15:57:04 +08:00
|
|
|
|
|
|
|
$studentnamelink = html_writer::link(new moodle_url('/user/view.php', array('id' => $report->user->id, 'course' => $courseid)), fullname($report->user));
|
|
|
|
print_grade_page_head($courseid, 'report', 'user', get_string('pluginname', 'gradereport_user') . ' - ' . $studentnamelink);
|
2009-04-23 19:27:21 +00:00
|
|
|
groups_print_course_menu($course, $gpr->get_return_url('index.php?id='.$courseid, array('userid'=>0)));
|
|
|
|
|
2010-05-05 03:27:22 +00:00
|
|
|
if ($user_selector) {
|
|
|
|
$renderer = $PAGE->get_renderer('gradereport_user');
|
2010-09-02 04:09:31 +00:00
|
|
|
$showallusersoptions = true;
|
|
|
|
echo $renderer->graded_users_selector('user', $course, $userid, $currentgroup, $showallusersoptions);
|
2010-05-05 03:27:22 +00:00
|
|
|
}
|
2007-07-24 07:45:15 +00:00
|
|
|
|
2009-04-23 19:27:21 +00:00
|
|
|
if ($currentgroup and !groups_is_member($currentgroup, $userid)) {
|
2009-08-18 04:59:57 +00:00
|
|
|
echo $OUTPUT->notification(get_string('groupusernotmember', 'error'));
|
2009-04-23 20:29:30 +00:00
|
|
|
} else {
|
|
|
|
if ($report->fill_table()) {
|
|
|
|
echo '<br />'.$report->print_table(true);
|
|
|
|
}
|
2008-01-17 15:08:09 +00:00
|
|
|
}
|
2007-07-23 22:20:07 +00:00
|
|
|
}
|
2009-04-23 19:27:21 +00:00
|
|
|
} else { //Students will see just their own report
|
2007-07-23 22:20:07 +00:00
|
|
|
|
2009-04-23 19:27:21 +00:00
|
|
|
// Create a report instance
|
|
|
|
$report = new grade_report_user($courseid, $gpr, $context, $userid);
|
|
|
|
|
|
|
|
// print the page
|
MDL-23071 standardising gradebook plugin names
AMOS BEGIN
MOV [modulename,gradeimport_csv],[pluginname,gradeimport_csv]
MOV [modulename,gradeimport_xml],[pluginname,gradeimport_xml]
MOV [modulename,gradeexport_ods],[pluginname,gradeexport_ods]
MOV [modulename,gradeexport_txt],[pluginname,gradeexport_txt]
MOV [modulename,gradeexport_xls],[pluginname,gradeexport_xls]
MOV [modulename,gradeexport_xml],[pluginname,gradeexport_xml]
MOV [modulename,gradereport_grader],[pluginname,gradereport_grader]
MOV [modulename,gradereport_outcomes],[pluginname,gradereport_outcomes]
MOV [modulename,gradereport_overview],[pluginname,gradereport_overview]
MOV [modulename,gradereport_user],[pluginname,gradereport_user]
AMOS END
2010-07-04 13:08:11 +00:00
|
|
|
print_grade_page_head($courseid, 'report', 'user', get_string('pluginname', 'gradereport_user'). ' - '.fullname($report->user));
|
2009-04-23 19:27:21 +00:00
|
|
|
|
|
|
|
if ($report->fill_table()) {
|
|
|
|
echo '<br />'.$report->print_table(true);
|
|
|
|
}
|
2007-07-14 03:46:24 +00:00
|
|
|
}
|
2009-04-23 19:27:21 +00:00
|
|
|
|
2011-01-18 16:24:41 +08:00
|
|
|
echo $OUTPUT->footer();
|