$edit = optional_param('edit', -1, PARAM_BOOL); // sticky editting mode
$sortitemid = optional_param('sortitemid', 0, PARAM_ALPHANUM); // sort by which grade item
-$action = optional_param('action', 0, PARAM_ALPHA);
+$action = optional_param('action', 0, PARAM_ALPHAEXT);
$move = optional_param('move', 0, PARAM_INT);
$type = optional_param('type', 0, PARAM_ALPHA);
$target = optional_param('target', 0, PARAM_ALPHANUM);
function get_headerhtml() {
global $CFG, $USER;
- $strsortasc = $this->get_lang_string('sortasc', 'grades');
- $strsortdesc = $this->get_lang_string('sortdesc', 'grades');
+ $strsortasc = $this->get_lang_string('sortasc', 'grades');
+ $strsortdesc = $this->get_lang_string('sortdesc', 'grades');
+ $strfirstname = $this->get_lang_string('firstname');
+ $strlastname = $this->get_lang_string('lastname');
+
if ($this->sortitemid === 'lastname') {
if ($this->sortorder == 'ASC') {
$lastarrow = print_arrow('up', $strsortasc, true);
$headerhtml .= '<tr class="heading">';
if ($key == $numrows - 1) {
- $headerhtml .= '<th class="user"><a href="'.$this->baseurl.'&sortitemid=firstname">Firstname</a> ' //TODO: localize
- . $firstarrow. '/ <a href="'.$this->baseurl.'&sortitemid=lastname">Lastname </a>'. $lastarrow .'</th>';
+ $headerhtml .= '<th class="user"><a href="'.$this->baseurl.'&sortitemid=firstname">' . $strfirstname . '</a> ' //TODO: localize
+ . $firstarrow. '/ <a href="'.$this->baseurl.'&sortitemid=lastname">' . $strlastname . '</a>'. $lastarrow .'</th>';
} else {
$headerhtml .= '<td class="topleft"> </td>';
}
$categoryid = $element['object']->id;
$aggregationview = $this->get_pref('aggregationview', $categoryid);
+
if ($aggregationview == GRADE_REPORT_AGGREGATION_VIEW_COMPACT) {
$categorystate = get_user_preferences('grade_report_categorystate' . $categoryid, GRADE_CATEGORY_EXPANDED);
+ $hideall = false;
+ if (in_array($eid, $columns_to_unset)) {
+ $categorystate = GRADE_CATEGORY_CONTRACTED;
+ $hideall = true;
+ }
+
// Expand/Contract icon must be set appropriately
if ($categorystate == GRADE_CATEGORY_CONTRACTED) {
// The category is contracted: this means we only show 1 item for this category: the
// category's aggregation item. The others must be removed from the grade_tree
$element['colspan'] = 1;
foreach ($element['children'] as $index => $child) {
- if ($child['type'] != 'categoryitem') {
+ if ($child['type'] != 'categoryitem' OR $hideall) {
$columns_to_unset[] = $child['eid'];
}
}
$columns_to_unset[] = $child['eid'];
}
}
+ } else {
+ debugging("The category state ($categorystate) was not amongst the allowed values (0 or 1)");
+ var_dump($element);
}
}
- }
+ } // End of category handling
if (!empty($element['colspan'])) {
$colspan = 'colspan="'.$element['colspan'].'"';
$strswitch_minus = $this->get_lang_string('contract', 'grades');
$strswitch_plus = $this->get_lang_string('expand', 'grades');
$expand_contract = 'switch_minus'; // Default: expanded
- $state = get_user_preferences('grade_category_'.$element['object']->id, GRADE_CATEGORY_EXPANDED);
+
+ $state = get_user_preferences('grade_report_categorystate' . $element['object']->id, GRADE_CATEGORY_EXPANDED);
+
if ($state == GRADE_CATEGORY_CONTRACTED) {
$expand_contract = 'switch_plus';
}
return '<div class="grade_icons">'.$edit_icon.$edit_calculation_icon.$show_hide_icon.$lock_unlock_icon.$contract_expand_icon.'</div>';
}
+
+ /**
+ * Processes a single action against a category, grade_item or grade.
+ * @param string $target eid ({type}{id}, e.g. c4 for category4)
+ * @param string $action Which action to take (edit, delete etc...)
+ * @return
+ */
+ function process_action($target, $action) {
+ $targettype = substr($target, 0, 1);
+ $targetid = substr($target, 1);
+ switch ($action) {
+ case 'switch_minus':
+ set_user_preference('grade_report_categorystate' . $targetid, GRADE_CATEGORY_CONTRACTED);
+ break;
+ case 'switch_plus':
+ set_user_preference('grade_report_categorystate' . $targetid, GRADE_CATEGORY_EXPANDED);
+ break;
+ default:
+ break;
+ }
+
+ return true;
+ }
}
?>