diff --git a/grade/report/grader/index.php b/grade/report/grader/index.php index 85074109b92..e6cbbb3f807 100644 --- a/grade/report/grader/index.php +++ b/grade/report/grader/index.php @@ -40,12 +40,19 @@ if (!empty($grades)) { } // get the params -$courseid = required_param('id', PARAM_INT); -$context = get_context_instance(CONTEXT_COURSE, $courseid); -$page = optional_param('page', 0, PARAM_INT); -$sortitemid = optional_param('sortitemid', 0, PARAM_ALPHANUM); // sort by which grade item -$report = optional_param('report', 0, PARAM_ALPHANUM); -$perpage = optional_param('perpage', 3, PARAM_INT); // number of users on a page +$courseid = required_param('id', PARAM_INT); +$context = get_context_instance(CONTEXT_COURSE, $courseid); +$page = optional_param('page', 0, PARAM_INT); +$sortitemid = optional_param('sortitemid', 0, PARAM_ALPHANUM); // sort by which grade item +$report = optional_param('report', 0, PARAM_ALPHANUM); +$perpage = optional_param('perpage', 3, PARAM_INT); // number of users on a page +$action = optional_param('action', 0, PARAM_ALPHA); +$move = optional_param('move', 0, PARAM_INT); +$type = optional_param('type', 0, PARAM_ALPHA); +$target = optional_param('target', 0, PARAM_INT); + +// Grab the grade_tree for this course +$gtree = new grade_tree($courseid, false); // setting the sort order, this depends on last state // all this should be in the new table class that we might need to use @@ -87,6 +94,62 @@ if ($sortitemid) { /// end of setting sort order code +// Perform actions on categories, items and grades +if (!empty($target) && !empty($action) && confirm_sesskey()) { + $element = $gtree->locate_element($target); + switch ($action) { + case 'edit': + break; + case 'delete': + if ($confirm == 1) { // Perform the deletion + $gtree->remove_element($target); + $gtree->renumber(); + $gtree->update_db(); + // Print result message + + } else { // Print confirmation dialog + $strdeletecheckfull = get_string('deletecheck', '', $element->element['object']->get_name()); + $linkyes = "category.php?target=$target&action=delete&confirm=1$gtree->commonvars"; + $linkno = "category.php?$gtree->commonvars"; + notice_yesno($strdeletecheckfull, $linkyes, $linkno); + } + break; + + case 'hide': + // TODO Implement calendar for selection of a date to hide element until + if (!$element->element['object']->set_hidden(1)) { + debugging("Could not update the element's hidden state!"); + } else { + $gtree = new grade_tree($courseid); + } + break; + case 'show': + if (!$element->element['object']->set_hidden(0)) { + debugging("Could not update the element's hidden state!"); + } else { + $gtree = new grade_tree($courseid); + } + break; + case 'lock': + // TODO Implement calendar for selection of a date to lock element after + if (!$element->element['object']->set_locked(1)) { + debugging("Could not update the element's locked state!"); + } else { + $gtree = new grade_tree($courseid); + } + break; + case 'unlock': + if (!$element->element['object']->set_locked(0)) { + debugging("Could not update the element's locked state!"); + } else { + $gtree = new grade_tree($courseid); + } + break; + default: + break; + } +} + // first make sure we have all final grades // TODO: check that no grade_item has needsupdate set @@ -169,174 +232,179 @@ $pbarurl = 'report.php?id='.$courseid.'&report=grader&'; print_paging_bar($numusers, $page, $perpage, $pbarurl); /// With the users in an sorted array and grades fetched, we can not print the main html table -if ($gtree = new grade_tree($courseid, false)) { - // 1. Fetch all top-level categories for this course, with all children preloaded, sorted by sortorder - $tree = $gtree->tree_filled; +// 1. Fetch all top-level categories for this course, with all children preloaded, sorted by sortorder +$tree = $gtree->tree_filled; - if (empty($gtree->tree_filled)) { - debugging("The tree_filled array wasn't initialised, grade_tree could not display the grades correctly."); - } - - // Fetch array of students enroled in this course - if (!$context = get_context_instance(CONTEXT_COURSE, $gtree->courseid)) { - return false; - } - //$users = get_role_users(@implode(',', $CFG->gradebookroles), $context); +if (empty($gtree->tree_filled)) { + debugging("The tree_filled array wasn't initialised, grade_tree could not display the grades correctly."); +} + + // Fetch array of students enroled in this course +if (!$context = get_context_instance(CONTEXT_COURSE, $gtree->courseid)) { + return false; +} +//$users = get_role_users(@implode(',', $CFG->gradebookroles), $context); - $topcathtml = '
';
- } else {
- $lastarrow = '
';
- }
+if ($sortitemid === 'lastname') {
+ if ($sortorder == 'ASC') {
+ $lastarrow = '
';
} else {
- $lastarrow = '';
+ $lastarrow = '
';
}
-
- if ($sortitemid === 'firstname') {
- if ($sortorder == 'ASC') {
- $firstarrow = '
';
- } else {
- $firstarrow = '
';
- }
- } else {
- $firstarrow = '';
- }
-
- // first name/last name column
- $itemhtml = '
';
- } else {
- $arrow = '
';
- }
- } else {
- $arrow = '';
- }
- $itemhtml .= '
';
+ } else {
+ $firstarrow = '
';
+ }
+} else {
+ $firstarrow = '';
+}
+
+// first name/last name column
+$itemhtml = '
';
+ } else {
+ $arrow = '
';
+ }
+ } else {
+ $arrow = '';
+ }
+ $itemhtml .= '
'. "\n";
+
+ // Hide/Show icon
+ $hide_show = 'hide';
+ if ($object->is_hidden()) {
+ $hide_show = 'show';
+ }
+
+ $html .= 'commonvars\">\n";
+ $html .= '
'. "\n";
+
+ // Prepare lock/unlock string
+ $lock_unlock = 'lock';
+ if ($object->is_locked()) {
+ $lock_unlock = 'unlock';
+ }
+ // Print lock/unlock icon
+ $html .= 'commonvars\">\n";
+ $html .= '
'. "\n";
+
+
+ // Lock/Unlock icon
+ return $html;
+}
?>