mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-10579 Implement capability checks in grade import/export/report/edit pages - work in progress
refactoring - reports now use real index.php
This commit is contained in:
parent
7229af7890
commit
65dd61bda6
12 changed files with 332 additions and 348 deletions
|
@ -156,9 +156,9 @@ class block_admin extends block_list {
|
|||
}
|
||||
|
||||
/// View course grades (or just your own grades, same link)
|
||||
if ((has_capability('moodle/grade:view', $context) or
|
||||
(has_capability('moodle/grade:viewown', $context) && $course->showgrades)) && ($course->id!==SITEID)) {
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/grade/report.php?id='.$this->instance->pageid.'">'.get_string('grades').'</a>';
|
||||
if ((has_capability('moodle/grade:viewall', $context) or
|
||||
(has_capability('moodle/grade:view', $context) && $course->showgrades)) && ($course->id!==SITEID)) {
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/grade/report/index.php?id='.$this->instance->pageid.'">'.get_string('grades').'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" class="icon" alt="" />';
|
||||
}
|
||||
|
||||
|
|
144
grade/index.php
144
grade/index.php
|
@ -1,142 +1,12 @@
|
|||
<?PHP
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
<?php //$Id$
|
||||
|
||||
$id = required_param('id'); // course id
|
||||
$download = optional_param('download');
|
||||
$user = optional_param('user', -1);
|
||||
$action = optional_param('action', 'grades');
|
||||
$cview = optional_param('cview', -1);
|
||||
/*
|
||||
* Compatibility redirection to reports
|
||||
*/
|
||||
|
||||
if (!$course = get_record('course', 'id', $id)) {
|
||||
error('No course ID');
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
// if the user set new prefs make sure they happen now
|
||||
if ($action == 'set_grade_preferences' && $prefs = data_submitted()) {
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
grade_set_preferences($course, $prefs);
|
||||
}
|
||||
|
||||
$preferences = grade_get_preferences($course->id);
|
||||
|
||||
|
||||
// we want this in its own window
|
||||
if ($action == 'stats') {
|
||||
grade_stats();
|
||||
exit();
|
||||
} else if ($action == 'ods') {
|
||||
grade_download('ods', $id);
|
||||
exit();
|
||||
} else if ($action == 'excel') {
|
||||
grade_download('xls', $id);
|
||||
exit();
|
||||
} else if ($action == 'text') {
|
||||
grade_download('txt', $id);
|
||||
exit();
|
||||
}
|
||||
|
||||
print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
|
||||
|
||||
print_heading('This old gradebook may not work properly. See the <a href="report.php?id='.$course->id.'">new 1.9 gradebook</a>');
|
||||
|
||||
/// find out current groups mode
|
||||
$groupmode = groupmode($course);
|
||||
$currentgroup = setup_and_print_groups($course, $groupmode, 'index.php?id=' . $course->id);
|
||||
echo '<div class="clearer"></div>';
|
||||
|
||||
grade_preferences_menu($action, $course);
|
||||
|
||||
grade_set_uncategorized();
|
||||
|
||||
if (has_capability('moodle/course:viewcoursegrades', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
switch ($action) {
|
||||
case "cats":
|
||||
grade_set_categories();
|
||||
break;
|
||||
case "insert_category":
|
||||
grade_insert_category();
|
||||
grade_set_categories();
|
||||
break;
|
||||
case "assign_categories":
|
||||
grade_assign_categories();
|
||||
grade_set_categories();
|
||||
break;
|
||||
case "set_grade_weights":
|
||||
grade_set_grade_weights();
|
||||
grade_display_grade_weights();
|
||||
break;
|
||||
case "weights":
|
||||
grade_display_grade_weights();
|
||||
break;
|
||||
case "grades":
|
||||
if ($preferences->use_advanced == 1) {
|
||||
grade_view_all_grades($user);
|
||||
}
|
||||
else {
|
||||
// all the grades will be in the 'uncategorized' category
|
||||
grade_view_category_grades($user);
|
||||
}
|
||||
break;
|
||||
case "vcats":
|
||||
grade_view_category_grades($user);
|
||||
break;
|
||||
case "prefs":
|
||||
case "set_grade_preferences":
|
||||
grade_display_grade_preferences($course, $preferences);
|
||||
break;
|
||||
case "letters":
|
||||
grade_display_letter_grades();
|
||||
break;
|
||||
case "set_letter_grades":
|
||||
grade_set_letter_grades();
|
||||
grade_display_letter_grades();
|
||||
break;
|
||||
case "delete_category":
|
||||
grade_delete_category();
|
||||
// re-run set_uncategorized as they may have deleted a category that had items in it
|
||||
grade_set_uncategorized();
|
||||
grade_set_categories();
|
||||
break;
|
||||
case "view_student_grades":
|
||||
grade_view_all_grades($user);
|
||||
break;
|
||||
case "view_student_category_grades":
|
||||
grade_view_category_grades($user);
|
||||
break;
|
||||
default:
|
||||
if ($preferences->use_advanced == 1) {
|
||||
grade_view_all_grades($user);
|
||||
}
|
||||
else {
|
||||
grade_view_category_grades($user);
|
||||
}
|
||||
} // end switch
|
||||
} // end if isTeacher
|
||||
else {
|
||||
if ($preferences->show_weighted || $preferences->show_points || $preferences->show_percent) {
|
||||
|
||||
if ($preferences->use_advanced == 1) {
|
||||
if($action != 'vcats') {
|
||||
grade_view_all_grades($USER->id);
|
||||
}
|
||||
else {
|
||||
grade_view_category_grades($USER->id);
|
||||
}
|
||||
} else {
|
||||
grade_view_category_grades($USER->id);
|
||||
}
|
||||
|
||||
} else {
|
||||
error(get_string('gradebookhiddenerror','grades'));
|
||||
}
|
||||
} // end else (!teacher)
|
||||
|
||||
print_footer($course);
|
||||
require '../config.php';
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
redirect('report/index.php?id='.$id);
|
||||
|
||||
?>
|
|
@ -29,7 +29,7 @@ function print_grade_plugin_selector($courseid, $active_type, $active_plugin, $r
|
|||
$reportnames = array();
|
||||
if (!empty($reports)) {
|
||||
foreach ($reports as $plugin) {
|
||||
$url = 'report.php?id='.$courseid.'&report='.$plugin;
|
||||
$url = 'report/'.$plugin.'/index.php?id='.$courseid;
|
||||
if ($active_type == 'report' and $active_plugin == $plugin ) {
|
||||
$active = $url;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ function print_grade_plugin_selector($courseid, $active_type, $active_plugin, $r
|
|||
if (!empty($imports)) {
|
||||
foreach ($imports as $plugin) {
|
||||
$url = 'import/'.$plugin.'/index.php?id='.$courseid;
|
||||
if ($active_type == 'impot' and $active_plugin == $plugin ) {
|
||||
if ($active_type == 'import' and $active_plugin == $plugin ) {
|
||||
$active = $url;
|
||||
}
|
||||
$importnames[$url] = get_string('modulename', 'gradeimport_'.$plugin, NULL, $CFG->dirroot.'/grade/import/'.$plugin.'lang/');
|
||||
|
@ -78,7 +78,7 @@ function print_grade_plugin_selector($courseid, $active_type, $active_plugin, $r
|
|||
if (!empty($exports)) {
|
||||
foreach ($exports as $plugin) {
|
||||
$url = 'export/'.$plugin.'/index.php?id='.$courseid;
|
||||
if ($active_type == 'impot' and $active_plugin == $plugin ) {
|
||||
if ($active_type == 'export' and $active_plugin == $plugin ) {
|
||||
$active = $url;
|
||||
}
|
||||
$exportnames[$url] = get_string('modulename', 'gradeexport_'.$plugin, NULL, $CFG->dirroot.'/grade/export/'.$plugin.'lang/');
|
||||
|
@ -168,21 +168,15 @@ class grade_plugin_return {
|
|||
* @param string $default default url when params not set
|
||||
* @return string url
|
||||
*/
|
||||
function get_return_url($default) {
|
||||
function get_return_url($default, $extras=null) {
|
||||
global $CFG;
|
||||
|
||||
if (empty($this->type) or empty($this->plugin)) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
if ($this->type == 'report') {
|
||||
$url = $CFG->wwwroot.'/grade/report.php?report='.$this->plugin;
|
||||
$glue = '&';
|
||||
|
||||
} else {
|
||||
$url = $CFG->wwwroot.'/grade/'.$this->type.'/'.$this->plugin.'/index.php';
|
||||
$glue = '?';
|
||||
}
|
||||
|
||||
if (!empty($this->courseid)) {
|
||||
$url .= $glue.'id='.$this->courseid;
|
||||
|
@ -196,6 +190,14 @@ class grade_plugin_return {
|
|||
|
||||
if (!empty($this->page)) {
|
||||
$url .= $glue.'page='.$this->page;
|
||||
$glue = '&';
|
||||
}
|
||||
|
||||
if (!empty($extras)) {
|
||||
foreach($extras as $key=>$value) {
|
||||
$url .= $glue.$key.'='.$value;
|
||||
$glue = '&';
|
||||
}
|
||||
}
|
||||
|
||||
return $url;
|
||||
|
|
134
grade/report.php
134
grade/report.php
|
@ -1,134 +0,0 @@
|
|||
<?php // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
|
||||
// //
|
||||
// This program 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 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program 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: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
require_once '../config.php';
|
||||
require_once $CFG->libdir.'/gradelib.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
|
||||
$courseid = required_param('id'); // course id
|
||||
$report = optional_param('report', get_user_preferences('grade_defaultreport', 'user'), PARAM_SAFEDIR);
|
||||
$userid = optional_param('userid', 0, PARAM_INT); // user detail
|
||||
$page = optional_param('page', 0, PARAM_INT); // active page
|
||||
$edit = optional_param('edit', -1, PARAM_BOOL); // sticky editting mode
|
||||
|
||||
/// Make sure they can even access this course
|
||||
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
|
||||
/// Now check what reports are available
|
||||
|
||||
if ($reports = get_list_of_plugins('grade/report', 'CVS')) { // Get all installed reports
|
||||
foreach ($reports as $key => $plugin) { // Remove ones we can't see
|
||||
if (!has_capability('gradereport/'.$plugin.':view', $context)) {
|
||||
unset($reports[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$reports) {
|
||||
print_error('nogradereports', 'grade');
|
||||
}
|
||||
|
||||
|
||||
/// Make sure the currently selected one makes sense
|
||||
|
||||
if (!in_array($report, $reports)) {
|
||||
reset($reports);
|
||||
list($key, $report) = each($reports); // Just pick the first one
|
||||
}
|
||||
|
||||
if ($report != get_user_preferences('grade_defaultreport', 'user')) {
|
||||
set_user_preference('grade_defaultreport', $report);
|
||||
}
|
||||
|
||||
/// return tracking object
|
||||
$gpr = new grade_plugin_return(array('type'=>'report', 'plugin'=>$report, 'courseid'=>$courseid,
|
||||
'userid'=>$userid, 'page'=>$page));
|
||||
|
||||
/// Build navigation
|
||||
|
||||
$strgrades = get_string('grades');
|
||||
$reportname = get_string('modulename', 'gradereport_'.$report);
|
||||
$navlinks = array();
|
||||
$navlinks[] = array('name' => $strgrades, 'link' => $CFG->wwwroot . '/grade/index.php?id='.$courseid, 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $reportname, 'link' => '', 'type' => 'misc');
|
||||
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
|
||||
/// Build editing on/off buttons
|
||||
|
||||
if (!isset($USER->gradeediting)) {
|
||||
$USER->gradeediting = 0;
|
||||
}
|
||||
|
||||
if (($edit == 1) and confirm_sesskey()) {
|
||||
$USER->gradeediting = 1;
|
||||
} else if (($edit == 0) and confirm_sesskey()) {
|
||||
$USER->gradeediting = 0;
|
||||
}
|
||||
|
||||
// params for the turn editting on
|
||||
$options = $gpr->get_options();
|
||||
|
||||
if ($USER->gradeediting) {
|
||||
$options['edit'] = 0;
|
||||
$string = get_string('turneditingoff');
|
||||
} else {
|
||||
$options['edit'] = 1;
|
||||
$string = get_string('turneditingon');
|
||||
}
|
||||
|
||||
$options['sesskey'] = sesskey();
|
||||
$link = 'report.php';
|
||||
|
||||
|
||||
$buttons = print_single_button($link, $options, $string, 'get', '_self', true);
|
||||
|
||||
|
||||
/// Print header
|
||||
|
||||
print_header_simple($strgrades.':'.$reportname, ':'.$strgrades, $navigation,
|
||||
'', '', true, $buttons, navmenu($course));
|
||||
|
||||
/// Print the plugin selector at the top
|
||||
print_grade_plugin_selector($courseid, 'report', $report);
|
||||
|
||||
|
||||
/// Now simply include the report here and we're done
|
||||
|
||||
include_once($CFG->dirroot.'/grade/report/'.$report.'/index.php');
|
||||
|
||||
print_footer($course);
|
||||
|
||||
|
||||
?>
|
|
@ -1,12 +1,38 @@
|
|||
<?php // $Id$
|
||||
|
||||
/// This creates and handles the whole grader report interface, sans header and footer
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
|
||||
// //
|
||||
// This program 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 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program 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: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once($CFG->dirroot.'/grade/report/grader/lib.php');
|
||||
|
||||
$gradeserror = array();
|
||||
require_once '../../../config.php';
|
||||
require_once $CFG->libdir.'/gradelib.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once $CFG->dirroot.'/grade/report/grader/lib.php';
|
||||
|
||||
$courseid = required_param('id'); // course id
|
||||
$page = optional_param('page', 0, PARAM_INT); // active page
|
||||
$perpageurl = optional_param('perpage', 0, PARAM_INT);
|
||||
$edit = optional_param('edit', -1, PARAM_BOOL); // sticky editting mode
|
||||
|
||||
// get the params ($report, $courseid and $context are already set in grade/report.php)
|
||||
$sortitemid = optional_param('sortitemid', 0, PARAM_ALPHANUM); // sort by which grade item
|
||||
$action = optional_param('action', 0, PARAM_ALPHA);
|
||||
$move = optional_param('move', 0, PARAM_INT);
|
||||
|
@ -15,6 +41,61 @@ $target = optional_param('target', 0, PARAM_ALPHANUM);
|
|||
$toggle = optional_param('toggle', NULL, PARAM_INT);
|
||||
$toggle_type = optional_param('toggle_type', 0, PARAM_ALPHANUM);
|
||||
|
||||
/// basic access checks
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('gradereport/grader:view', $context);
|
||||
|
||||
/// return tracking object
|
||||
$gpr = new grade_plugin_return(array('type'=>'report', 'plugin'=>'grader', 'courseid'=>$courseid, 'page'=>$page));
|
||||
|
||||
/// last selected report session tracking
|
||||
if (!isset($USER->grade_last_report)) {
|
||||
$USER->grade_last_report = array();
|
||||
}
|
||||
$USER->grade_last_report[$course->id] = 'grader';
|
||||
|
||||
/// Build navigation
|
||||
|
||||
$strgrades = get_string('grades');
|
||||
$reportname = get_string('modulename', 'gradereport_grader');
|
||||
|
||||
$navlinks = array(array('name'=>$strgrades, 'link'=>$CFG->wwwroot.'/grade/index.php?id='.$courseid, 'type'=>'misc'),
|
||||
array('name'=>$reportname, 'link'=>'', 'type'=>'misc'));
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
|
||||
/// Build editing on/off buttons
|
||||
|
||||
if (!isset($USER->gradeediting)) {
|
||||
$USER->gradeediting = 0;
|
||||
}
|
||||
|
||||
if (($edit == 1) and confirm_sesskey()) {
|
||||
$USER->gradeediting = 1;
|
||||
} else if (($edit == 0) and confirm_sesskey()) {
|
||||
$USER->gradeediting = 0;
|
||||
}
|
||||
|
||||
// page params for the turn editting on
|
||||
$options = $gpr->get_options();
|
||||
$options['sesskey'] = sesskey();
|
||||
|
||||
if ($USER->gradeediting) {
|
||||
$options['edit'] = 0;
|
||||
$string = get_string('turneditingoff');
|
||||
} else {
|
||||
$options['edit'] = 1;
|
||||
$string = get_string('turneditingon');
|
||||
}
|
||||
|
||||
$buttons = print_single_button('index.php', $options, $string, 'get', '_self', true);
|
||||
|
||||
$gradeserror = array();
|
||||
|
||||
// Handle toggle change request
|
||||
if (!is_null($toggle) && !empty($toggle_type)) {
|
||||
set_user_preferences(array('grade_report_show'.$toggle_type => $toggle));
|
||||
|
@ -32,7 +113,7 @@ if ($data = data_submitted() and confirm_sesskey()) {
|
|||
}
|
||||
|
||||
// Override perpage if set in URL
|
||||
if ($perpageurl = optional_param('perpage', 0, PARAM_INT)) {
|
||||
if ($perpageurl) {
|
||||
$report->user_prefs['studentsperpage'] = $perpageurl;
|
||||
}
|
||||
|
||||
|
@ -45,13 +126,16 @@ $report->load_users();
|
|||
$numusers = $report->get_numusers();
|
||||
$report->load_final_grades();
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_COURSE, $report->gtree->courseid)) {
|
||||
return false;
|
||||
}
|
||||
/// Print header
|
||||
print_header_simple($strgrades.':'.$reportname, ':'.$strgrades, $navigation,
|
||||
'', '', true, $buttons, navmenu($course));
|
||||
|
||||
/// Print the plugin selector at the top
|
||||
print_grade_plugin_selector($courseid, 'report', 'grader');
|
||||
|
||||
// Add tabs
|
||||
$currenttab = 'graderreport';
|
||||
include('tabs.php');
|
||||
require('tabs.php');
|
||||
|
||||
echo $report->group_selector;
|
||||
|
||||
|
@ -70,7 +154,7 @@ $reporthtml .= "</table>";
|
|||
|
||||
// print submit button
|
||||
if ($USER->gradeediting) {
|
||||
echo '<form action="report.php" method="post">';
|
||||
echo '<form action="index.php" method="post">';
|
||||
echo '<div>';
|
||||
echo '<input type="hidden" value="'.$courseid.'" name="id" />';
|
||||
echo '<input type="hidden" value="'.sesskey().'" name="sesskey" />';
|
||||
|
@ -89,4 +173,7 @@ if ($USER->gradeediting && ($report->get_pref('quickfeedback') || $report->get_p
|
|||
if ($report->get_pref('studentsperpage') >= 20) {
|
||||
print_paging_bar($numusers, $report->page, $report->get_pref('studentsperpage'), $report->pbarurl);
|
||||
}
|
||||
|
||||
print_footer($course);
|
||||
|
||||
?>
|
||||
|
|
|
@ -66,11 +66,10 @@ class grade_report_grader extends grade_report {
|
|||
$this->sortitemid = $sortitemid;
|
||||
|
||||
// base url for sorting by first/last name
|
||||
$this->baseurl = 'report.php?id='.$this->courseid.'&perpage='.$this->get_pref('studentsperpage')
|
||||
.'&report=grader&page='.$this->page;
|
||||
$this->baseurl = 'index.php?id='.$this->courseid.'&perpage='.$this->get_pref('studentsperpage')
|
||||
.'&page='.$this->page;
|
||||
//
|
||||
$this->pbarurl = 'report.php?id='.$this->courseid.'&perpage='.$this->get_pref('studentsperpage')
|
||||
.'&report=grader&';
|
||||
$this->pbarurl = 'index.php?id='.$this->courseid.'&perpage='.$this->get_pref('studentsperpage');
|
||||
|
||||
// Setup groups if requested
|
||||
if ($this->get_pref('showgroups')) {
|
||||
|
@ -968,7 +967,7 @@ class grade_report_grader extends grade_report {
|
|||
$hide_show = 'show';
|
||||
}
|
||||
|
||||
$show_hide_icon = '<a href="report.php?report=grader&target='.$eid
|
||||
$show_hide_icon = '<a href="index.php?target='.$eid
|
||||
. "&action=$hide_show" . $this->gtree->commonvars . "\">\n"
|
||||
. '<img src="'.$CFG->pixpath.'/t/'.$hide_show.'.gif" class="iconsmall" alt="'
|
||||
. ${'str' . $hide_show}.'" title="'.${'str' . $hide_show}.'" /></a>'. "\n";
|
||||
|
@ -981,7 +980,7 @@ class grade_report_grader extends grade_report {
|
|||
|
||||
// Print lock/unlock icon
|
||||
|
||||
$lock_unlock_icon = '<a href="report.php?report=grader&target='.$eid
|
||||
$lock_unlock_icon = '<a href="index.php?target='.$eid
|
||||
. "&action=$lock_unlock" . $this->gtree->commonvars . "\">\n"
|
||||
. '<img src="'.$CFG->pixpath.'/t/'.$lock_unlock.'.gif" class="iconsmall" alt="'
|
||||
. ${'str' . $lock_unlock}.'" title="'.${'str' . $lock_unlock}.'" /></a>'. "\n";
|
||||
|
@ -993,7 +992,7 @@ class grade_report_grader extends grade_report {
|
|||
$expand_contract = 'switch_plus';
|
||||
}
|
||||
|
||||
$contract_expand_icon = '<a href="report.php?report=grader&target=' . $eid
|
||||
$contract_expand_icon = '<a href="index.php?target=' . $eid
|
||||
. "&action=$expand_contract" . $this->gtree->commonvars . "\">\n"
|
||||
. '<img src="'.$CFG->pixpath.'/t/'.$expand_contract.'.gif" class="iconsmall" alt="'
|
||||
. ${'str' . $expand_contract}.'" title="'.${'str' . $expand_contract}.'" /></a>'. "\n";
|
||||
|
|
|
@ -57,7 +57,7 @@ if ($form = data_submitted()) {
|
|||
}
|
||||
}
|
||||
|
||||
redirect($CFG->wwwroot . '/grade/report.php?report=grader&id='.$courseid, get_string('changessaved'), 1);
|
||||
redirect($CFG->wwwroot . '/grade/report/grader/index.php?id='.$courseid, get_string('changessaved'), 1);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ $strgradepreferences = get_string('gradepreferences', 'grades');
|
|||
$navlinks = array();
|
||||
$navlinks[] = array('name' => $strgrades, 'link' => $CFG->wwwroot . '/grade/index.php?id='.$courseid, 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $strgraderreport,
|
||||
'link' => $CFG->wwwroot . '/grade/report.php?id=' . $courseid . '&report=grader', 'type' => 'misc');
|
||||
'link' => $CFG->wwwroot . '/grade/report/grader/index.php?id=' . $courseid, 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $strgradepreferences, 'link' => '', 'type' => 'misc');
|
||||
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php // $Id$
|
||||
$row = $tabs = array();
|
||||
$row[] = new tabobject('graderreport',
|
||||
$CFG->wwwroot.'/grade/report.php?id='.$courseid.'&report=grader',
|
||||
$CFG->wwwroot.'/grade/report/grader/index.php?id='.$courseid,
|
||||
get_string('modulename', 'gradereport_grader'));
|
||||
|
||||
$row[] = new tabobject('preferences',
|
||||
|
|
78
grade/report/index.php
Normal file
78
grade/report/index.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php //$Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
|
||||
// //
|
||||
// This program 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 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program 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: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require '../../config.php';
|
||||
|
||||
$courseid = required_param('id', PARAM_INT);
|
||||
|
||||
/// basic access checks
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
/// find all accessible reports
|
||||
if ($reports = get_list_of_plugins('grade/report', 'CVS')) { // Get all installed reports
|
||||
foreach ($reports as $key => $plugin) { // Remove ones we can't see
|
||||
if (!has_capability('gradereport/'.$plugin.':view', $context)) {
|
||||
unset($reports[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($reports)) {
|
||||
error('No reports accessible', $CFG->wwwroot.'/course/view.php:id='.$course->id); // TODO: localize
|
||||
}
|
||||
|
||||
if (!isset($USER->grade_last_report)) {
|
||||
$USER->grade_last_report = array();
|
||||
}
|
||||
|
||||
if (!empty($USER->grade_last_report[$course->id])) {
|
||||
$last = $USER->grade_last_report[$course->id];
|
||||
} else {
|
||||
$last = null;
|
||||
}
|
||||
|
||||
if (!in_array($last, $reports)) {
|
||||
$last = null;
|
||||
}
|
||||
|
||||
if (empty($last)) {
|
||||
if (in_array('grader', $reports)) {
|
||||
$last = 'grader';
|
||||
|
||||
} else if (in_array('user', $reports)) {
|
||||
$last = 'user';
|
||||
|
||||
} else {
|
||||
$last = reset($reports);
|
||||
}
|
||||
}
|
||||
|
||||
//redirect to last or guessed report
|
||||
redirect($CFG->wwwroot.'/grade/report/'.$last.'/index.php?id='.$course->id);
|
||||
|
||||
?>
|
|
@ -1,28 +1,110 @@
|
|||
<?php // $Id$
|
||||
|
||||
/// This creates and handles the whole user report interface, sans header and footer
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
|
||||
// //
|
||||
// This program 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 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program 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: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once($CFG->dirroot.'/grade/report/user/lib.php');
|
||||
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';
|
||||
|
||||
// get the params
|
||||
if (!$userid = optional_param('user', 0, PARAM_INT)) {
|
||||
// current user
|
||||
$userid = $USER->id;
|
||||
$courseid = required_param('id');
|
||||
$userid = optional_param('userid', $USER->id, PARAM_INT);
|
||||
|
||||
/// basic access checks
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
|
||||
if (!$user = get_complete_user_data('id', $userid)) {
|
||||
error("Incorrect userid");
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$usercontext = get_context_instance(CONTEXT_PERSONAL, $user->id);
|
||||
require_capability('gradereport/user:view', $context);
|
||||
|
||||
$access = true;
|
||||
if (has_capability('moodle/grade:viewall', $context)) {
|
||||
//ok - can view all course grades
|
||||
|
||||
} else if ($user->id == $USER->id and has_capability('moodle/grade:view', $context) and $course->showgrades) {
|
||||
//ok - can view own grades
|
||||
|
||||
} else if (has_capability('moodle/grade:view', $usercontext) and $course->showgrades) {
|
||||
// ok - can view grades of this user- parent most probably
|
||||
|
||||
} else {
|
||||
$acces = false;
|
||||
}
|
||||
|
||||
/// 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';
|
||||
|
||||
/// Build navigation
|
||||
$strgrades = get_string('grades');
|
||||
$reportname = get_string('modulename', 'gradereport_user');
|
||||
|
||||
$navlinks = array(array('name'=>$strgrades, 'link'=>$CFG->wwwroot.'/grade/index.php?id='.$courseid, 'type'=>'misc'),
|
||||
array('name'=>$reportname, 'link'=>'', 'type'=>'misc'));
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
|
||||
/// Print header
|
||||
print_header_simple($strgrades.':'.$reportname, ':'.$strgrades, $navigation,
|
||||
'', '', true, '', navmenu($course));
|
||||
|
||||
/// Print the plugin selector at the top
|
||||
print_grade_plugin_selector($courseid, 'report', 'user');
|
||||
|
||||
if ($access) {
|
||||
|
||||
//first make sure we have proper final grades - this must be done before constructing of the grade tree
|
||||
grade_regrade_final_grades($courseid);
|
||||
|
||||
// Create a report instance
|
||||
$report = new grade_report_user($courseid, $gpr, $context, $userid);
|
||||
|
||||
// find total number of participants
|
||||
$numusers = $report->get_numusers();
|
||||
|
||||
$gradetotal = 0;
|
||||
$gradesum = 0;
|
||||
|
||||
// print the page
|
||||
print_heading(get_string('modulename', 'gradereport_user'). " - ".fullname($report->user));
|
||||
print_heading(get_string('modulename', 'gradereport_user'). ' - '.fullname($report->user));
|
||||
|
||||
if ($report->fill_table()) {
|
||||
echo $report->print_table(true);
|
||||
}
|
||||
|
||||
} else {
|
||||
// no access to grades!
|
||||
echo "Can not view grades."; //TODO: localize
|
||||
}
|
||||
print_footer($course);
|
||||
|
||||
?>
|
||||
|
|
|
@ -702,17 +702,17 @@ body#grade-index .grades .r1 {
|
|||
|
||||
/* new grades css*/
|
||||
|
||||
#grade-report .catlevel1 {
|
||||
.grade-report-grader .catlevel1 {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
#grade-report .catlevel2 {
|
||||
.grade-report-grader .catlevel2 {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
#grade-report .catlevel3 {
|
||||
.grade-report-grader .catlevel3 {
|
||||
background-color: #dddddd;
|
||||
}
|
||||
|
||||
#grade-report td.overridden {
|
||||
.grade-report-grader td.overridden {
|
||||
background-color: #dddddd;
|
||||
}
|
||||
|
||||
|
|
|
@ -2051,88 +2051,88 @@ body#doc-contents ul {
|
|||
***/
|
||||
|
||||
|
||||
#grade-report table {
|
||||
.grade-report-grader table {
|
||||
border-width:1px;
|
||||
border-style:solid;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
#grade-report div.submit {
|
||||
.grade-report-grader div.submit {
|
||||
margin-top: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#grade-report table td {
|
||||
.grade-report-grader table td {
|
||||
border-width:1px;
|
||||
border-style:solid;
|
||||
}
|
||||
|
||||
#grade-report tr.heading {
|
||||
.grade-report-grader tr.heading {
|
||||
border-width:0px 0px 0px 0px;
|
||||
border-style:solid;
|
||||
}
|
||||
|
||||
#grade-report .heading td {
|
||||
.grade-report-grader .heading td {
|
||||
border-width:0px 0px 0px 0px;
|
||||
border-style:solid;
|
||||
}
|
||||
|
||||
#grade-report th.category {
|
||||
.grade-report-grader th.category {
|
||||
border-width:1px 1px 0px 1px;
|
||||
border-style:solid;
|
||||
}
|
||||
|
||||
#grade-report th.user {
|
||||
.grade-report-grader th.user {
|
||||
border-width:0px 0px 1px 0px;
|
||||
border-style:solid;
|
||||
}
|
||||
|
||||
#grade-report th.categoryitem,
|
||||
#grade-report th.courseitem,
|
||||
#grade-report td.topleft {
|
||||
.grade-report-grader th.categoryitem,
|
||||
.grade-report-grader th.courseitem,
|
||||
.grade-report-grader td.topleft {
|
||||
border-width:0px 1px 0px 1px;
|
||||
border-style:solid;
|
||||
}
|
||||
|
||||
#grade-report td.fillerfirst {
|
||||
.grade-report-grader td.fillerfirst {
|
||||
border-width:0px 0px 0px 1px;
|
||||
border-style:solid;
|
||||
}
|
||||
|
||||
#grade-report td.fillerlast {
|
||||
.grade-report-grader td.fillerlast {
|
||||
border-width:0px 1px 0px 0px;
|
||||
border-style:solid;
|
||||
}
|
||||
|
||||
#grade-report th.item {
|
||||
.grade-report-grader th.item {
|
||||
border-width:1px 1px 1px 1px;
|
||||
border-style:solid;
|
||||
}
|
||||
|
||||
#grade-report div.gradertoggle {
|
||||
.grade-report-grader div.gradertoggle {
|
||||
display: inline;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
#grade-report table.gradestable {
|
||||
.grade-report-grader table.gradestable {
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
}
|
||||
|
||||
#grade-report .gradestable th.user {
|
||||
.grade-report-grader .gradestable th.user {
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
#grade-report .gradestable td {
|
||||
.grade-report-grader .gradestable td {
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
#grade-report th.range {
|
||||
.grade-report-grader th.range {
|
||||
border-width:1px 1px 1px 1px;
|
||||
border-style:solid;
|
||||
}
|
||||
|
||||
#grade-report .userpic {
|
||||
.grade-report-grader .userpic {
|
||||
display: inline;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue