Merge branch 'MDL-29327_none_23' of git://github.com/andyjdavis/moodle into MOODLE_23...
[moodle.git] / grade / edit / tree / lib.php
CommitLineData
e060e33d 1<?php
e060e33d 2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
dc482cfa 16
a153c9f2
AD
17/**
18 * A library of classes used by the grade edit pages
19 *
20 * @package core_grades
21 * @copyright 2009 Nicolas Connault
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
dc482cfa 25class grade_edit_tree {
26 public $columns = array();
27
28 /**
29 * @var object $gtree @see grade/lib.php
30 */
31 public $gtree;
32
33 /**
34 * @var grade_plugin_return @see grade/lib.php
35 */
36 public $gpr;
37
38 /**
39 * @var string $moving The eid of the category or item being moved
40 */
41 public $moving;
42
43 public $deepest_level;
44
653a8648 45 public $uses_extra_credit = false;
46
47 public $uses_weight = false;
71297a3f 48
54a007e8 49 public $table;
71297a3f 50
54a007e8 51 public $categories = array();
dc482cfa 52 /**
53 * Constructor
54 */
55 public function __construct($gtree, $moving=false, $gpr) {
54a007e8 56 global $USER, $OUTPUT, $COURSE;
57
dc482cfa 58 $this->gtree = $gtree;
59 $this->moving = $moving;
60 $this->gpr = $gpr;
61 $this->deepest_level = $this->get_deepest_level($this->gtree->top_element);
62
63 $this->columns = array(grade_edit_tree_column::factory('name', array('deepest_level' => $this->deepest_level)),
653a8648 64 grade_edit_tree_column::factory('aggregation', array('flag' => true)));
65
66 if ($this->uses_weight) {
67 $this->columns[] = grade_edit_tree_column::factory('weight', array('adv' => 'aggregationcoef'));
68 }
69 if ($this->uses_extra_credit) {
70 $this->columns[] = grade_edit_tree_column::factory('extracredit', array('adv' => 'aggregationcoef'));
71 }
72
73 $this->columns[] = grade_edit_tree_column::factory('range'); // This is not a setting... How do we deal with it?
74 $this->columns[] = grade_edit_tree_column::factory('aggregateonlygraded', array('flag' => true));
75 $this->columns[] = grade_edit_tree_column::factory('aggregatesubcats', array('flag' => true));
76 $this->columns[] = grade_edit_tree_column::factory('aggregateoutcomes', array('flag' => true));
77 $this->columns[] = grade_edit_tree_column::factory('droplow', array('flag' => true));
78 $this->columns[] = grade_edit_tree_column::factory('keephigh', array('flag' => true));
79 $this->columns[] = grade_edit_tree_column::factory('multfactor', array('adv' => true));
80 $this->columns[] = grade_edit_tree_column::factory('plusfactor', array('adv' => true));
81 $this->columns[] = grade_edit_tree_column::factory('actions');
82 $this->columns[] = grade_edit_tree_column::factory('select');
54a007e8 83
84 $mode = ($USER->gradeediting[$COURSE->id]) ? 'advanced' : 'simple';
71297a3f 85
54a007e8 86 $widthstyle = '';
87 if ($mode == 'simple') {
88 $widthstyle = ' style="width:auto;" ';
89 }
90
91 $this->table = new html_table();
92 $this->table->id = "grade_edit_tree_table";
93 $this->table->cellpadding = 5;
16be8974 94 $this->table->attributes['class'] = 'generaltable ' . $mode;
54a007e8 95 $this->table->style = $widthstyle;
96
97 foreach ($this->columns as $column) {
98 if (!($this->moving && $column->hide_when_moving) && !$column->is_hidden($mode)) {
99 $this->table->head[] = $column->get_header_cell();
100 }
101 }
102
103 $rowcount = 0;
104 $this->table->data = $this->build_html_tree($this->gtree->top_element, true, array(), 0, $rowcount);
dc482cfa 105 }
106
107 /**
108 * Recursive function for building the table holding the grade categories and items,
109 * with CSS indentation and styles.
110 *
1c1f64a2 111 * @param array $element The current tree element being rendered
112 * @param boolean $totals Whether or not to print category grade items (category totals)
113 * @param array $parents An array of parent categories for the current element (used for indentation and row classes)
dc482cfa 114 *
115 * @return string HTML
116 */
54a007e8 117 public function build_html_tree($element, $totals, $parents, $level, &$row_count) {
6b608f8f 118 global $CFG, $COURSE, $USER, $OUTPUT;
71297a3f 119
dc482cfa 120 $object = $element['object'];
121 $eid = $element['eid'];
122 $object->name = $this->gtree->get_element_header($element, true, true, false);
123 $object->stripped_name = $this->gtree->get_element_header($element, false, false, false);
124
125 $is_category_item = false;
126 if ($element['type'] == 'categoryitem' || $element['type'] == 'courseitem') {
127 $is_category_item = true;
128 }
129
54a007e8 130 $rowclasses = array();
dc482cfa 131 foreach ($parents as $parent_eid) {
54a007e8 132 $rowclasses[] = $parent_eid;
dc482cfa 133 }
134
135 $actions = '';
136
137 if (!$is_category_item) {
138 $actions .= $this->gtree->get_edit_icon($element, $this->gpr);
139 }
140
141 $actions .= $this->gtree->get_calculation_icon($element, $this->gpr);
142
143 if ($element['type'] == 'item' or ($element['type'] == 'category' and $element['depth'] > 1)) {
144 if ($this->element_deletable($element)) {
8ae8bf8a 145 $aurl = new moodle_url('index.php', array('id' => $COURSE->id, 'action' => 'delete', 'eid' => $eid, 'sesskey' => sesskey()));
c63923bd 146 $actions .= $OUTPUT->action_icon($aurl, new pix_icon('t/delete', get_string('delete')));
dc482cfa 147 }
1c1f64a2 148
8ae8bf8a 149 $aurl = new moodle_url('index.php', array('id' => $COURSE->id, 'action' => 'moveselect', 'eid' => $eid, 'sesskey' => sesskey()));
c63923bd 150 $actions .= $OUTPUT->action_icon($aurl, new pix_icon('t/move', get_string('move')));
dc482cfa 151 }
152
153 $actions .= $this->gtree->get_hiding_icon($element, $this->gpr);
154 $actions .= $this->gtree->get_locking_icon($element, $this->gpr);
155
156 $mode = ($USER->gradeediting[$COURSE->id]) ? 'advanced' : 'simple';
157
54a007e8 158 $returnrows = array();
dc482cfa 159 $root = false;
160
dc482cfa 161 $id = required_param('id', PARAM_INT);
162
163 /// prepare move target if needed
164 $last = '';
165
166 /// print the list items now
167 if ($this->moving == $eid) {
dc482cfa 168 // do not diplay children
54a007e8 169 $cell = new html_table_cell();
170 $cell->colspan = 12;
16be8974 171 $cell->attributes['class'] = $element['type'] . ' moving';
54a007e8 172 $cell->text = $object->name.' ('.get_string('move').')';
8cea545e 173 return array(new html_table_row(array($cell)));
dc482cfa 174 }
175
176 if ($element['type'] == 'category') {
177 $level++;
54a007e8 178 $this->categories[$object->id] = $object->stripped_name;
dc482cfa 179 $category = grade_category::fetch(array('id' => $object->id));
180 $item = $category->get_grade_item();
181
182 // Add aggregation coef input if not a course item and if parent category has correct aggregation type
54a007e8 183 $dimmed = ($item->is_hidden()) ? 'dimmed' : '';
dc482cfa 184
185 // Before we print the category's row, we must find out how many rows will appear below it (for the filler cell's rowspan)
186 $aggregation_position = grade_get_setting($COURSE->id, 'aggregationposition', $CFG->grade_aggregationposition);
187 $category_total_data = null; // Used if aggregationposition is set to "last", so we can print it last
188
54a007e8 189 $html_children = array();
dc482cfa 190
191 $row_count = 0;
192
193 foreach($element['children'] as $child_el) {
54a007e8 194 $moveto = null;
dc482cfa 195
196 if (empty($child_el['object']->itemtype)) {
197 $child_el['object']->itemtype = false;
198 }
199
200 if (($child_el['object']->itemtype == 'course' || $child_el['object']->itemtype == 'category') && !$totals) {
201 continue;
202 }
203
54a007e8 204 $child_eid = $child_el['eid'];
dc482cfa 205 $first = '';
206
207 if ($child_el['object']->itemtype == 'course' || $child_el['object']->itemtype == 'category') {
1c1f64a2 208 $first = array('first' => 1);
dc482cfa 209 $child_eid = $eid;
210 }
211
212 if ($this->moving && $this->moving != $child_eid) {
213
214 $strmove = get_string('move');
215 $strmovehere = get_string('movehere');
216 $actions = ''; // no action icons when moving
217
8ae8bf8a 218 $aurl = new moodle_url('index.php', array('id' => $COURSE->id, 'action' => 'move', 'eid' => $this->moving, 'moveafter' => $child_eid, 'sesskey' => sesskey()));
1c1f64a2 219 if ($first) {
8ae8bf8a 220 $aurl->params($first);
1c1f64a2 221 }
71297a3f 222
54a007e8 223 $cell = new html_table_cell();
224 $cell->colspan = 12;
6ef4878b 225
84d32de3
AD
226 $icon = new pix_icon('movehere', $strmovehere, null, array('class'=>'movetarget'));
227 $cell->text = $OUTPUT->action_icon($aurl, $icon);
1c1f64a2 228
8cea545e 229 $moveto = new html_table_row(array($cell));
dc482cfa 230 }
231
232 $newparents = $parents;
233 $newparents[] = $eid;
234
235 $row_count++;
236 $child_row_count = 0;
237
238 // If moving, do not print course and category totals, but still print the moveto target box
239 if ($this->moving && ($child_el['object']->itemtype == 'course' || $child_el['object']->itemtype == 'category')) {
54a007e8 240 $html_children[] = $moveto;
dc482cfa 241 } elseif ($child_el['object']->itemtype == 'course' || $child_el['object']->itemtype == 'category') {
242 // We don't build the item yet because we first need to know the deepest level of categories (for category/name colspans)
54a007e8 243 $category_total_item = $this->build_html_tree($child_el, $totals, $newparents, $level, $child_row_count);
dc482cfa 244 if (!$aggregation_position) {
54a007e8 245 $html_children = array_merge($html_children, $category_total_item);
dc482cfa 246 }
247 } else {
54a007e8 248 $html_children = array_merge($html_children, $this->build_html_tree($child_el, $totals, $newparents, $level, $child_row_count));
249 if (!empty($moveto)) {
250 $html_children[] = $moveto;
251 }
dc482cfa 252
253 if ($this->moving) {
254 $row_count++;
255 }
256 }
257
258 $row_count += $child_row_count;
259
260 // If the child is a category, increment row_count by one more (for the extra coloured row)
261 if ($child_el['type'] == 'category') {
262 $row_count++;
263 }
264 }
265
266 // Print category total at the end if aggregation position is "last" (1)
267 if (!empty($category_total_item) && $aggregation_position) {
54a007e8 268 $html_children = array_merge($html_children, $category_total_item);
dc482cfa 269 }
270
54a007e8 271 // Determine if we are at the root
dc482cfa 272 if (isset($element['object']->grade_item) && $element['object']->grade_item->is_course_item()) {
dc482cfa 273 $root = true;
274 }
275
54a007e8 276 $levelclass = "level$level";
2be6ca78 277
b189277f 278 $courseclass = '';
279 if ($level == 1) {
280 $courseclass = 'coursecategory';
281 }
71297a3f 282
54a007e8 283 $row = new html_table_row();
16be8974 284 $row->attributes['class'] = $courseclass . ' category ' . $dimmed;
54a007e8 285 foreach ($rowclasses as $class) {
16be8974 286 $row->attributes['class'] .= ' ' . $class;
54a007e8 287 }
dc482cfa 288
54a007e8 289 $headercell = new html_table_cell();
290 $headercell->header = true;
291 $headercell->scope = 'row';
16be8974
DM
292 $headercell->attributes['title'] = $object->stripped_name;
293 $headercell->attributes['class'] = 'cell rowspan ' . $levelclass;
d674a0e1 294 $headercell->rowspan = $row_count + 1;
54a007e8 295 $row->cells[] = $headercell;
dc482cfa 296
297 foreach ($this->columns as $column) {
298 if (!($this->moving && $column->hide_when_moving) && !$column->is_hidden($mode)) {
54a007e8 299 $row->cells[] = $column->get_category_cell($category, $levelclass, array('id' => $id, 'name' => $object->name, 'level' => $level, 'actions' => $actions, 'eid' => $eid));
dc482cfa 300 }
301 }
71297a3f 302
54a007e8 303 $returnrows[] = $row;
dc482cfa 304
54a007e8 305 $returnrows = array_merge($returnrows, $html_children);
dc482cfa 306
6ef4878b 307 // Print a coloured row to show the end of the category across the table
54a007e8 308 $endcell = new html_table_cell();
309 $endcell->colspan = (19 - $level);
16be8974 310 $endcell->attributes['class'] = 'colspan ' . $levelclass;
54a007e8 311
8cea545e 312 $returnrows[] = new html_table_row(array($endcell));;
dc482cfa 313
314 } else { // Dealing with a grade item
315
316 $item = grade_item::fetch(array('id' => $object->id));
317 $element['type'] = 'item';
318 $element['object'] = $item;
2be6ca78 319
b189277f 320 $categoryitemclass = '';
321 if ($item->itemtype == 'category') {
322 $categoryitemclass = 'categoryitem';
323 }
dc482cfa 324
54a007e8 325 $dimmed = ($item->is_hidden()) ? "dimmed_text" : "";
326 $gradeitemrow = new html_table_row();
16be8974 327 $gradeitemrow->attributes['class'] = $categoryitemclass . ' item ' . $dimmed;
54a007e8 328 foreach ($rowclasses as $class) {
16be8974 329 $gradeitemrow->attributes['class'] .= ' ' . $class;
54a007e8 330 }
dc482cfa 331
332 foreach ($this->columns as $column) {
333 if (!($this->moving && $column->hide_when_moving) && !$column->is_hidden($mode)) {
54a007e8 334 $gradeitemrow->cells[] = $column->get_item_cell($item, array('id' => $id, 'name' => $object->name, 'level' => $level, 'actions' => $actions,
dc482cfa 335 'element' => $element, 'eid' => $eid, 'itemtype' => $object->itemtype));
336 }
337 }
338
54a007e8 339 $returnrows[] = $gradeitemrow;
dc482cfa 340 }
341
54a007e8 342 return $returnrows;
dc482cfa 343
344 }
345
346 /**
347 * Given a grade_item object, returns a labelled input if an aggregation coefficient (weight or extra credit) applies to it.
348 * @param grade_item $item
653a8648 349 * @param string type "extra" or "weight": the type of the column hosting the weight input
dc482cfa 350 * @return string HTML
351 */
e2bb3c92 352 static function get_weight_input($item, $type) {
1c1f64a2 353 global $OUTPUT;
354
dc482cfa 355 if (!is_object($item) || get_class($item) !== 'grade_item') {
356 throw new Exception('grade_edit_tree::get_weight_input($item) was given a variable that is not of the required type (grade_item object)');
357 return false;
358 }
359
360 if ($item->is_course_item()) {
361 return '';
362 }
363
364 $parent_category = $item->get_parent_category();
dc482cfa 365 $parent_category->apply_forced_settings();
653a8648 366 $aggcoef = $item->get_coefstring();
dc482cfa 367
653a8648 368 if ((($aggcoef == 'aggregationcoefweight' || $aggcoef == 'aggregationcoef') && $type == 'weight') ||
3869ab1a 369 ($aggcoef == 'aggregationcoefextraweight' && $type == 'extra')) {
916276fc 370 return '<input type="text" size="6" id="aggregationcoef_'.$item->id.'" name="aggregationcoef_'.$item->id.'"
3cf33f51 371 value="'.grade_edit_tree::format_number($item->aggregationcoef).'" />';
653a8648 372 } elseif ($aggcoef == 'aggregationcoefextrasum' && $type == 'extra') {
cd3a391c 373 $checked = ($item->aggregationcoef > 0) ? 'checked="checked"' : '';
916276fc
PS
374 return '<input type="hidden" name="extracredit_'.$item->id.'" value="0" />
375 <input type="checkbox" id="extracredit_'.$item->id.'" name="extracredit_'.$item->id.'" value="1" '."$checked />\n";
cd3a391c 376 } else {
377 return '';
dc482cfa 378 }
cd3a391c 379 }
dc482cfa 380
6ef4878b 381 //Trims trailing zeros
4592df46 382 //Used on the 'categories and items' page for grade items settings like aggregation co-efficient
e229506d 383 //Grader report has its own decimal place settings so they are handled elsewhere
e2bb3c92 384 static function format_number($number) {
4592df46 385 $formatted = rtrim(format_float($number, 4),'0');
35cf43cb 386 if (substr($formatted, -1)==get_string('decsep', 'langconfig')) { //if last char is the decimal point
4592df46
AD
387 $formatted .= '0';
388 }
389 return $formatted;
3cf33f51
AD
390 }
391
dc482cfa 392 /**
393 * Given an element of the grade tree, returns whether it is deletable or not (only manual grade items are deletable)
394 *
395 * @param array $element
396 * @return bool
397 */
398 function element_deletable($element) {
399 global $COURSE;
400
401 if ($element['type'] != 'item') {
402 return true;
403 }
404
405 $grade_item = $element['object'];
406
407 if ($grade_item->itemtype != 'mod' or $grade_item->is_outcome_item() or $grade_item->gradetype == GRADE_TYPE_NONE) {
408 return true;
409 }
410
411 $modinfo = get_fast_modinfo($COURSE);
412 if (!isset($modinfo->instances[$grade_item->itemmodule][$grade_item->iteminstance])) {
413 // module does not exist
414 return true;
415 }
416
417 return false;
418 }
419
420 /**
421 * Given the grade tree and an array of element ids (e.g. c15, i42), and expecting the 'moveafter' URL param,
422 * moves the selected items to the requested location. Then redirects the user to the given $returnurl
423 *
424 * @param object $gtree The grade tree (a recursive representation of the grade categories and grade items)
425 * @param array $eids
426 * @param string $returnurl
427 */
428 function move_elements($eids, $returnurl) {
429 $moveafter = required_param('moveafter', PARAM_INT);
430
431 if (!is_array($eids)) {
432 $eids = array($eids);
433 }
434
435 if(!$after_el = $this->gtree->locate_element("c$moveafter")) {
436 print_error('invalidelementid', '', $returnurl);
437 }
438
439 $after = $after_el['object'];
440 $parent = $after;
441 $sortorder = $after->get_sortorder();
442
443 foreach ($eids as $eid) {
444 if (!$element = $this->gtree->locate_element($eid)) {
445 print_error('invalidelementid', '', $returnurl);
446 }
447 $object = $element['object'];
448
449 $object->set_parent($parent->id);
450 $object->move_after_sortorder($sortorder);
4d2f7923 451 $sortorder++;
dc482cfa 452 }
453
454 redirect($returnurl, '', 0);
455 }
456
457 /**
458 * Recurses through the entire grade tree to find and return the maximum depth of the tree.
459 * This should be run only once from the root element (course category), and is used for the
460 * indentation of the Name column's cells (colspan)
461 *
462 * @param array $element An array of values representing a grade tree's element (all grade items in this case)
463 * @param int $level The level of the current recursion
464 * @param int $deepest_level A value passed to each subsequent level of recursion and incremented if $level > $deepest_level
465 * @return int Deepest level
466 */
467 function get_deepest_level($element, $level=0, $deepest_level=1) {
468 $object = $element['object'];
469
470 $level++;
653a8648 471 $coefstring = $element['object']->get_coefstring();
dc482cfa 472 if ($element['type'] == 'category') {
653a8648 473 if ($coefstring == 'aggregationcoefweight') {
474 $this->uses_weight = true;
3869ab1a 475 } elseif ($coefstring == 'aggregationcoefextraweight' || $coefstring == 'aggregationcoefextrasum') {
653a8648 476 $this->uses_extra_credit = true;
477 }
478
dc482cfa 479 foreach($element['children'] as $child_el) {
480 if ($level > $deepest_level) {
481 $deepest_level = $level;
482 }
483 $deepest_level = $this->get_deepest_level($child_el, $level, $deepest_level);
484 }
485 }
486
487 return $deepest_level;
488 }
489}
490
491abstract class grade_edit_tree_column {
492 public $forced;
493 public $hidden;
494 public $forced_hidden;
495 public $advanced_hidden;
496 public $hide_when_moving = true;
54a007e8 497 /**
498 * html_table_cell object used as a template for header cells in all categories.
499 * It must be cloned before being used.
500 * @var html_table_cell $headercell
501 */
502 public $headercell;
503 /**
504 * html_table_cell object used as a template for category cells in all categories.
505 * It must be cloned before being used.
506 * @var html_table_cell $categorycell
507 */
508 public $categorycell;
509 /**
510 * html_table_cell object used as a template for item cells in all categories.
511 * It must be cloned before being used.
512 * @var html_table_cell $itemcell
513 */
514 public $itemcell;
dc482cfa 515
516 public static function factory($name, $params=array()) {
517 $class_name = "grade_edit_tree_column_$name";
518 if (class_exists($class_name)) {
519 return new $class_name($params);
520 }
521 }
522
523 public abstract function get_header_cell();
524
525 public abstract function get_category_cell($category, $levelclass, $params);
526
527 public abstract function get_item_cell($item, $params);
528
529 public abstract function is_hidden($mode='simple');
54a007e8 530
531 public function __construct() {
532 $this->headercell = new html_table_cell();
533 $this->headercell->header = true;
534 $this->headercell->style = 'whitespace: normal;';
16be8974 535 $this->headercell->attributes['class'] = 'header';
54a007e8 536
537 $this->categorycell = new html_table_cell();
16be8974 538 $this->categorycell->attributes['class'] = 'cell';
54a007e8 539
540 $this->itemcell = new html_table_cell();
16be8974 541 $this->itemcell->attributes['class'] = 'cell';
54a007e8 542 }
dc482cfa 543}
544
545abstract class grade_edit_tree_column_category extends grade_edit_tree_column {
546
547 public $forced;
548 public $advanced;
549
550 public function __construct($name) {
551 global $CFG;
552 $this->forced = (int)$CFG->{"grade_$name"."_flag"} & 1;
553 $this->advanced = (int)$CFG->{"grade_$name"."_flag"} & 2;
54a007e8 554 parent::__construct();
dc482cfa 555 }
556
557 public function is_hidden($mode='simple') {
558 global $CFG;
559 if ($mode == 'simple') {
560 return $this->advanced;
561 } elseif ($mode == 'advanced') {
562 if ($this->forced && $CFG->grade_hideforcedsettings) {
563 return true;
564 } else {
565 return false;
566 }
567 }
568 }
569}
570
571class grade_edit_tree_column_name extends grade_edit_tree_column {
572 public $forced = false;
573 public $hidden = false;
574 public $forced_hidden = false;
575 public $advanced_hidden = false;
576 public $deepest_level = 1;
577 public $hide_when_moving = false;
578
579 public function __construct($params) {
580 if (empty($params['deepest_level'])) {
581 throw new Exception('Tried to instantiate a grade_edit_tree_column_name object without the "deepest_level" param!');
582 }
583
584 $this->deepest_level = $params['deepest_level'];
54a007e8 585 parent::__construct();
dc482cfa 586 }
587
588 public function get_header_cell() {
54a007e8 589 $headercell = clone($this->headercell);
16be8974 590 $headercell->attributes['class'] .= ' name';
54a007e8 591 $headercell->colspan = $this->deepest_level + 1;
592 $headercell->text = get_string('name');
593 return $headercell;
dc482cfa 594 }
595
596 public function get_category_cell($category, $levelclass, $params) {
54a007e8 597 global $OUTPUT;
dc482cfa 598 if (empty($params['name']) || empty($params['level'])) {
599 throw new Exception('Array key (name or level) missing from 3rd param of grade_edit_tree_column_name::get_category_cell($category, $levelclass, $params)');
600 }
54a007e8 601 $categorycell = clone($this->categorycell);
16be8974 602 $categorycell->attributes['class'] .= ' name ' . $levelclass;
54a007e8 603 $categorycell->colspan = ($this->deepest_level +1) - $params['level'];
604 $categorycell->text = $OUTPUT->heading($params['name'], 4);
605 return $categorycell;
dc482cfa 606 }
607
608 public function get_item_cell($item, $params) {
609 global $CFG;
610
611 if (empty($params['element']) || empty($params['name']) || empty($params['level'])) {
612 throw new Exception('Array key (name, level or element) missing from 2nd param of grade_edit_tree_column_name::get_item_cell($item, $params)');
613 }
614
615 $name = $params['name'];
616
54a007e8 617 $itemcell = clone($this->itemcell);
16be8974 618 $itemcell->attributes['class'] .= ' name';
54a007e8 619 $itemcell->colspan = ($this->deepest_level + 1) - $params['level'];
620 $itemcell->text = $name;
621 return $itemcell;
dc482cfa 622 }
623
624 public function is_hidden($mode='simple') {
625 return false;
626 }
627}
628
629class grade_edit_tree_column_aggregation extends grade_edit_tree_column_category {
630
631 public function __construct($params) {
632 parent::__construct('aggregation');
633 }
634
635 public function get_header_cell() {
c3b834b4 636 global $OUTPUT;
54a007e8 637 $headercell = clone($this->headercell);
f89b71eb 638 $headercell->text = get_string('aggregation', 'grades').$OUTPUT->help_icon('aggregation', 'grades');
54a007e8 639 return $headercell;
dc482cfa 640 }
641
642 public function get_category_cell($category, $levelclass, $params) {
0a95bebf 643 global $CFG, $OUTPUT;
dc482cfa 644 if (empty($params['id'])) {
645 throw new Exception('Array key (id) missing from 3rd param of grade_edit_tree_column_aggregation::get_category_cell($category, $levelclass, $params)');
646 }
647
648 $options = array(GRADE_AGGREGATE_MEAN => get_string('aggregatemean', 'grades'),
649 GRADE_AGGREGATE_WEIGHTED_MEAN => get_string('aggregateweightedmean', 'grades'),
650 GRADE_AGGREGATE_WEIGHTED_MEAN2 => get_string('aggregateweightedmean2', 'grades'),
651 GRADE_AGGREGATE_EXTRACREDIT_MEAN => get_string('aggregateextracreditmean', 'grades'),
652 GRADE_AGGREGATE_MEDIAN => get_string('aggregatemedian', 'grades'),
653 GRADE_AGGREGATE_MIN => get_string('aggregatemin', 'grades'),
654 GRADE_AGGREGATE_MAX => get_string('aggregatemax', 'grades'),
655 GRADE_AGGREGATE_MODE => get_string('aggregatemode', 'grades'),
656 GRADE_AGGREGATE_SUM => get_string('aggregatesum', 'grades'));
657
653a8648 658 $visible = explode(',', $CFG->grade_aggregations_visible);
659 foreach ($options as $constant => $string) {
660 if (!in_array($constant, $visible) && $constant != $category->aggregation) {
661 unset($options[$constant]);
662 }
663 }
664
dc482cfa 665 if ($this->forced) {
666 $aggregation = $options[$category->aggregation];
064527d6
PS
667 } else {
668 $attributes = array();
669 $attributes['id'] = 'aggregation_'.$category->id;
aa15bd56
RW
670 $aggregation = html_writer::label(get_string('aggregation', 'grades'), 'aggregation_'.$category->id, false, array('class' => 'accesshide'));
671 $aggregation .= html_writer::select($options, 'aggregation_'.$category->id, $category->aggregation, null, $attributes);
064527d6 672 $action = new component_action('change', 'update_category_aggregation', array('courseid' => $params['id'], 'category' => $category->id, 'sesskey' => sesskey()));
c80877aa 673 $OUTPUT->add_action_handler($action, 'aggregation_'.$category->id);
dc482cfa 674 }
675
54a007e8 676 $categorycell = clone($this->categorycell);
16be8974 677 $categorycell->attributes['class'] .= ' ' . $levelclass;
54a007e8 678 $categorycell->text = $aggregation;
679 return $categorycell;
dc482cfa 680
681 }
682
683 public function get_item_cell($item, $params) {
54a007e8 684 $itemcell = clone($this->itemcell);
685 $itemcell->text = ' - ';
686 return $itemcell;
dc482cfa 687 }
688}
689
653a8648 690class grade_edit_tree_column_extracredit extends grade_edit_tree_column {
691
692 public function get_header_cell() {
c3b834b4 693 global $OUTPUT;
54a007e8 694 $headercell = clone($this->headercell);
3869ab1a 695 $headercell->text = get_string('aggregationcoefextra', 'grades').$OUTPUT->help_icon('aggregationcoefextra', 'grades');
54a007e8 696 return $headercell;
653a8648 697 }
698
699 public function get_category_cell($category, $levelclass, $params) {
653a8648 700 $item = $category->get_grade_item();
54a007e8 701 $categorycell = clone($this->categorycell);
16be8974 702 $categorycell->attributes['class'] .= ' ' . $levelclass;
54a007e8 703 $categorycell->text = grade_edit_tree::get_weight_input($item, 'extra');
704 return $categorycell;
653a8648 705 }
706
707 public function get_item_cell($item, $params) {
708 if (empty($params['element'])) {
709 throw new Exception('Array key (element) missing from 2nd param of grade_edit_tree_column_weightorextracredit::get_item_cell($item, $params)');
710 }
711
54a007e8 712 $itemcell = clone($this->itemcell);
713 $itemcell->text = '&nbsp;';
653a8648 714
715 if (!in_array($params['element']['object']->itemtype, array('courseitem', 'categoryitem', 'category'))) {
54a007e8 716 $itemcell->text = grade_edit_tree::get_weight_input($item, 'extra');
653a8648 717 }
718
54a007e8 719 return $itemcell;
653a8648 720 }
721
722 public function is_hidden($mode='simple') {
723 global $CFG;
724 if ($mode == 'simple') {
725 return strstr($CFG->grade_item_advanced, 'aggregationcoef');
726 } elseif ($mode == 'advanced') {
727 return false;
728 }
729 }
730}
731
732class grade_edit_tree_column_weight extends grade_edit_tree_column {
dc482cfa 733
734 public function get_header_cell() {
c3b834b4 735 global $OUTPUT;
54a007e8 736 $headercell = clone($this->headercell);
3869ab1a 737 $headercell->text = get_string('weightuc', 'grades').$OUTPUT->help_icon('aggregationcoefweight', 'grades');
54a007e8 738 return $headercell;
dc482cfa 739 }
740
741 public function get_category_cell($category, $levelclass, $params) {
742
743 $item = $category->get_grade_item();
54a007e8 744 $categorycell = clone($this->categorycell);
16be8974 745 $categorycell->attributes['class'] .= ' ' . $levelclass;
54a007e8 746 $categorycell->text = grade_edit_tree::get_weight_input($item, 'weight');
747 return $categorycell;
dc482cfa 748 }
749
750 public function get_item_cell($item, $params) {
751 if (empty($params['element'])) {
752 throw new Exception('Array key (element) missing from 2nd param of grade_edit_tree_column_weightorextracredit::get_item_cell($item, $params)');
753 }
54a007e8 754 $itemcell = clone($this->itemcell);
755 $itemcell->text = '&nbsp;';
dc482cfa 756
b8436ccb 757 if (!in_array($params['element']['object']->itemtype, array('courseitem', 'categoryitem', 'category'))) {
54a007e8 758 $itemcell->text = grade_edit_tree::get_weight_input($item, 'weight');
dc482cfa 759 }
760
54a007e8 761 return $itemcell;
dc482cfa 762 }
763
764 public function is_hidden($mode='simple') {
765 global $CFG;
766 if ($mode == 'simple') {
767 return strstr($CFG->grade_item_advanced, 'aggregationcoef');
768 } elseif ($mode == 'advanced') {
769 return false;
770 }
771 }
772}
773
774class grade_edit_tree_column_range extends grade_edit_tree_column {
775
776 public function get_header_cell() {
54a007e8 777 $headercell = clone($this->headercell);
778 $headercell->text = get_string('maxgrade', 'grades');
779 return $headercell;
dc482cfa 780 }
781
782 public function get_category_cell($category, $levelclass, $params) {
54a007e8 783 $categorycell = clone($this->categorycell);
16be8974 784 $categorycell->attributes['class'] .= ' range ' . $levelclass;
54a007e8 785 $categorycell->text = ' - ';
786 return $categorycell;
dc482cfa 787 }
788
789 public function get_item_cell($item, $params) {
1c1f64a2 790 global $DB, $OUTPUT;
46409b20 791
792 // If the parent aggregation is Sum of Grades, this cannot be changed
793 $parent_cat = $item->get_parent_category();
794 if ($parent_cat->aggregation == GRADE_AGGREGATE_SUM) {
795 $grademax = format_float($item->grademax, $item->get_decimals());
796 } elseif ($item->gradetype == GRADE_TYPE_SCALE) {
3998cc5c 797 $scale = $DB->get_record('scale', array('id' => $item->scaleid));
e2a84477
AD
798 $scale_items = null;
799 if (empty($scale)) { //if the item is using a scale that's been removed
800 $scale_items = array();
801 } else {
802 $scale_items = explode(',', $scale->scale);
803 }
dc482cfa 804 $grademax = end($scale_items) . ' (' . count($scale_items) . ')';
805 } elseif ($item->is_external_item()) {
806 $grademax = format_float($item->grademax, $item->get_decimals());
807 } else {
24050190 808 $grademax = '<input type="text" size="6" id="grademax'.$item->id.'" name="grademax_'.$item->id.'" value="'.format_float($item->grademax, $item->get_decimals()).'" />';
dc482cfa 809 }
810
54a007e8 811 $itemcell = clone($this->itemcell);
812 $itemcell->text = $grademax;
813 return $itemcell;
dc482cfa 814 }
815
816 public function is_hidden($mode='simple') {
817 global $CFG;
818 if ($mode == 'simple') {
819 return strstr($CFG->grade_item_advanced, 'grademax');
820 } elseif ($mode == 'advanced') {
821 return false;
822 }
823 }
824}
825
826class grade_edit_tree_column_aggregateonlygraded extends grade_edit_tree_column_category {
827
828 public function __construct($params) {
829 parent::__construct('aggregateonlygraded');
830 }
831
832 public function get_header_cell() {
c3b834b4 833 global $OUTPUT;
54a007e8 834 $headercell = clone($this->headercell);
835 $headercell->style .= 'width: 40px;';
71297a3f 836 $headercell->text = get_string('aggregateonlygraded', 'grades')
be3df7fb 837 . $OUTPUT->help_icon('aggregateonlygraded', 'grades');
54a007e8 838 return $headercell;
dc482cfa 839 }
840
841 public function get_category_cell($category, $levelclass, $params) {
916276fc
PS
842 $onlygradedcheck = ($category->aggregateonlygraded == 1) ? 'checked="checked"' : '';
843 $hidden = '<input type="hidden" name="aggregateonlygraded_'.$category->id.'" value="0" />';
844 $aggregateonlygraded ='<input type="checkbox" id="aggregateonlygraded_'.$category->id.'" name="aggregateonlygraded_'.$category->id.'" value="1" '.$onlygradedcheck . ' />';
dc482cfa 845
846 if ($this->forced) {
847 $aggregateonlygraded = ($category->aggregateonlygraded) ? get_string('yes') : get_string('no');
848 }
849
54a007e8 850 $categorycell = clone($this->categorycell);
16be8974 851 $categorycell->attributes['class'] .= ' ' . $levelclass;
916276fc 852 $categorycell->text = $hidden.$aggregateonlygraded;
54a007e8 853 return $categorycell;
dc482cfa 854 }
855
856 public function get_item_cell($item, $params) {
54a007e8 857 $itemcell = clone($this->itemcell);
858 $itemcell->text = ' - ';
859 return $itemcell;
dc482cfa 860 }
861}
862
863class grade_edit_tree_column_aggregatesubcats extends grade_edit_tree_column_category {
864
865 public function __construct($params) {
866 parent::__construct('aggregatesubcats');
867 }
868
869 public function get_header_cell() {
c3b834b4 870 global $OUTPUT;
54a007e8 871 $headercell = clone($this->headercell);
872 $headercell->style .= 'width: 40px;';
873 $headercell->text = get_string('aggregatesubcats', 'grades')
cb616be8 874 .$OUTPUT->help_icon('aggregatesubcats', 'grades');
54a007e8 875 return $headercell;
dc482cfa 876 }
877
878 public function get_category_cell($category, $levelclass, $params) {
916276fc
PS
879 $subcatscheck = ($category->aggregatesubcats == 1) ? 'checked="checked"' : '';
880 $hidden = '<input type="hidden" name="aggregatesubcats_'.$category->id.'" value="0" />';
881 $aggregatesubcats = '<input type="checkbox" id="aggregatesubcats_'.$category->id.'" name="aggregatesubcats_'.$category->id.'" value="1" ' . $subcatscheck.' />';
dc482cfa 882
883 if ($this->forced) {
884 $aggregatesubcats = ($category->aggregatesubcats) ? get_string('yes') : get_string('no');
885 }
886
54a007e8 887 $categorycell = clone($this->categorycell);
16be8974 888 $categorycell->attributes['class'] .= ' ' . $levelclass;
916276fc 889 $categorycell->text = $hidden.$aggregatesubcats;
54a007e8 890 return $categorycell;
dc482cfa 891
892 }
893
894 public function get_item_cell($item, $params) {
54a007e8 895 $itemcell = clone($this->itemcell);
896 $itemcell->text = ' - ';
897 return $itemcell;
dc482cfa 898 }
899}
900
901class grade_edit_tree_column_aggregateoutcomes extends grade_edit_tree_column_category {
902
903 public function __construct($params) {
904 parent::__construct('aggregateoutcomes');
905 }
906
907 public function get_header_cell() {
c3b834b4 908 global $OUTPUT;
54a007e8 909 $headercell = clone($this->headercell);
910 $headercell->style .= 'width: 40px;';
911 $headercell->text = get_string('aggregateoutcomes', 'grades')
3f781a22 912 .$OUTPUT->help_icon('aggregateoutcomes', 'grades');
54a007e8 913 return $headercell;
dc482cfa 914 }
915
916 public function get_category_cell($category, $levelclass, $params) {
916276fc
PS
917 $outcomescheck = ($category->aggregateoutcomes == 1) ? 'checked="checked"' : '';
918 $hidden = '<input type="hidden" name="aggregateoutcomes_'.$category->id.'" value="0" />';
919 $aggregateoutcomes = '<input type="checkbox" id="aggregateoutcomes_'.$category->id.'" name="aggregateoutcomes_'.$category->id.'" value="1" ' . $outcomescheck.' />';
dc482cfa 920
921 if ($this->forced) {
922 $aggregateoutcomes = ($category->aggregateoutcomes) ? get_string('yes') : get_string('no');
923 }
924
54a007e8 925 $categorycell = clone($this->categorycell);
16be8974 926 $categorycell->attributes['class'] .= ' ' . $levelclass;
916276fc 927 $categorycell->text = $hidden.$aggregateoutcomes;
54a007e8 928 return $categorycell;
dc482cfa 929 }
930
931 public function get_item_cell($item, $params) {
54a007e8 932 $itemcell = clone($this->itemcell);
933 $itemcell->text = ' - ';
934 return $itemcell;
dc482cfa 935 }
936
937 public function is_hidden($mode='simple') {
938 global $CFG;
939 if ($CFG->enableoutcomes) {
940 return parent::is_hidden($mode);
941 } else {
942 return true;
943 }
944 }
945}
946
947class grade_edit_tree_column_droplow extends grade_edit_tree_column_category {
948
949 public function __construct($params) {
950 parent::__construct('droplow');
951 }
952
953 public function get_header_cell() {
c3b834b4 954 global $OUTPUT;
54a007e8 955 $headercell = clone($this->headercell);
b37760fc 956 $headercell->text = get_string('droplow', 'grades').$OUTPUT->help_icon('droplow', 'grades');
54a007e8 957 return $headercell;
dc482cfa 958 }
959
960 public function get_category_cell($category, $levelclass, $params) {
916276fc 961 $droplow = '<input type="text" size="3" id="droplow_'.$category->id.'" name="droplow_'.$category->id.'" value="'.$category->droplow.'" />';
dc482cfa 962
963 if ($this->forced) {
964 $droplow = $category->droplow;
965 }
966
54a007e8 967 $categorycell = clone($this->categorycell);
16be8974 968 $categorycell->attributes['class'] .= ' ' . $levelclass;
54a007e8 969 $categorycell->text = $droplow;
970 return $categorycell;
dc482cfa 971 }
972
973 public function get_item_cell($item, $params) {
54a007e8 974 $itemcell = clone($this->itemcell);
975 $itemcell->text = ' - ';
976 return $itemcell;
dc482cfa 977 }
978}
979
980class grade_edit_tree_column_keephigh extends grade_edit_tree_column_category {
981
982 public function __construct($params) {
983 parent::__construct('keephigh');
984 }
985
986 public function get_header_cell() {
c3b834b4 987 global $OUTPUT;
54a007e8 988 $headercell = clone($this->headercell);
cb616be8 989 $headercell->text = get_string('keephigh', 'grades').$OUTPUT->help_icon('keephigh', 'grades');
54a007e8 990 return $headercell;
dc482cfa 991 }
992
993 public function get_category_cell($category, $levelclass, $params) {
916276fc 994 $keephigh = '<input type="text" size="3" id="keephigh_'.$category->id.'" name="keephigh_'.$category->id.'" value="'.$category->keephigh.'" />';
dc482cfa 995
996 if ($this->forced) {
997 $keephigh = $category->keephigh;
998 }
999
54a007e8 1000 $categorycell = clone($this->categorycell);
16be8974 1001 $categorycell->attributes['class'] .= ' ' . $levelclass;
54a007e8 1002 $categorycell->text = $keephigh;
1003 return $categorycell;
dc482cfa 1004 }
1005
1006 public function get_item_cell($item, $params) {
54a007e8 1007 $itemcell = clone($this->itemcell);
1008 $itemcell->text = ' - ';
1009 return $itemcell;
dc482cfa 1010 }
1011}
1012
1013class grade_edit_tree_column_multfactor extends grade_edit_tree_column {
1014
1015 public function __construct($params) {
54a007e8 1016 parent::__construct();
dc482cfa 1017 }
1018
1019 public function get_header_cell() {
c3b834b4 1020 global $OUTPUT;
54a007e8 1021 $headercell = clone($this->headercell);
d4a11ee5 1022 $headercell->text = get_string('multfactor', 'grades').$OUTPUT->help_icon('multfactor', 'grades');
54a007e8 1023 return $headercell;
dc482cfa 1024 }
1025
1026 public function get_category_cell($category, $levelclass, $params) {
54a007e8 1027 $categorycell = clone($this->categorycell);
16be8974 1028 $categorycell->attributes['class'] .= ' ' . $levelclass;
54a007e8 1029 $categorycell->text = ' - ';
1030 return $categorycell;
dc482cfa 1031 }
1032
1033 public function get_item_cell($item, $params) {
54a007e8 1034 global $OUTPUT;
1035
1036 $itemcell = clone($this->itemcell);
a043086f 1037 if (!$item->is_raw_used()) {
54a007e8 1038 $itemcell->text = '&nbsp;';
1039 return $itemcell;
a043086f 1040 }
54a007e8 1041
67485c7f 1042 $multfactor = '<input type="text" size="4" id="multfactor'.$item->id.'" name="multfactor_'.$item->id.'" value="'.grade_edit_tree::format_number($item->multfactor).'" />';
54a007e8 1043
7d89f0b0 1044 $itemcell->text = $multfactor;
54a007e8 1045 return $itemcell;
dc482cfa 1046 }
1047
1048 public function is_hidden($mode='simple') {
1049 global $CFG;
1050 if ($mode == 'simple') {
1051 return strstr($CFG->grade_item_advanced, 'multfactor');
1052 } elseif ($mode == 'advanced') {
1053 return false;
1054 }
1055 }
1056}
1057
1058class grade_edit_tree_column_plusfactor extends grade_edit_tree_column {
1059
1060 public function get_header_cell() {
c3b834b4 1061 global $OUTPUT;
54a007e8 1062 $headercell = clone($this->headercell);
12b0938c 1063 $headercell->text = get_string('plusfactor', 'grades').$OUTPUT->help_icon('plusfactor', 'grades');
54a007e8 1064 return $headercell;
dc482cfa 1065 }
1066
1067 public function get_category_cell($category, $levelclass, $params) {
54a007e8 1068 $categorycell = clone($this->categorycell);
16be8974 1069 $categorycell->attributes['class'] .= ' ' . $levelclass;
54a007e8 1070 $categorycell->text = ' - ';
1071 return $categorycell;
dc482cfa 1072
1073 }
1074
1075 public function get_item_cell($item, $params) {
54a007e8 1076 global $OUTPUT;
1077
1078 $itemcell = clone($this->itemcell);
a043086f 1079 if (!$item->is_raw_used()) {
54a007e8 1080 $itemcell->text = '&nbsp;';
1081 return $itemcell;
a043086f 1082 }
54a007e8 1083
67485c7f 1084 $plusfactor = '<input type="text" size="4" id="plusfactor_'.$item->id.'" name="plusfactor_'.$item->id.'" value="'.grade_edit_tree::format_number($item->plusfactor).'" />';
916276fc 1085
7d89f0b0 1086 $itemcell->text = $plusfactor;
54a007e8 1087 return $itemcell;
dc482cfa 1088
1089 }
1090
1091 public function is_hidden($mode='simple') {
1092 global $CFG;
1093 if ($mode == 'simple') {
1094 return strstr($CFG->grade_item_advanced, 'plusfactor');
1095 } elseif ($mode == 'advanced') {
1096 return false;
1097 }
1098 }
1099}
1100
1101class grade_edit_tree_column_actions extends grade_edit_tree_column {
1102
1103 public function __construct($params) {
71297a3f 1104 parent::__construct();
dc482cfa 1105 }
1106
1107 public function get_header_cell() {
54a007e8 1108 $headercell = clone($this->headercell);
16be8974 1109 $headercell->attributes['class'] .= ' actions';
54a007e8 1110 $headercell->text = get_string('actions');
1111 return $headercell;
dc482cfa 1112 }
1113
1114 public function get_category_cell($category, $levelclass, $params) {
1115
1116 if (empty($params['actions'])) {
1117 throw new Exception('Array key (actions) missing from 3rd param of grade_edit_tree_column_actions::get_category_actions($category, $levelclass, $params)');
1118 }
1119
54a007e8 1120 $categorycell = clone($this->categorycell);
16be8974 1121 $categorycell->attributes['class'] .= ' ' . $levelclass;
54a007e8 1122 $categorycell->text = $params['actions'];
1123 return $categorycell;
dc482cfa 1124 }
1125
1126 public function get_item_cell($item, $params) {
1127 if (empty($params['actions'])) {
1128 throw new Exception('Array key (actions) missing from 2nd param of grade_edit_tree_column_actions::get_item_cell($item, $params)');
1129 }
54a007e8 1130 $itemcell = clone($this->itemcell);
16be8974 1131 $itemcell->attributes['class'] .= ' actions';
54a007e8 1132 $itemcell->text = $params['actions'];
1133 return $itemcell;
dc482cfa 1134 }
1135
1136 public function is_hidden($mode='simple') {
1137 return false;
1138 }
1139}
1140
1141class grade_edit_tree_column_select extends grade_edit_tree_column {
1142
1143 public function get_header_cell() {
54a007e8 1144 $headercell = clone($this->headercell);
16be8974 1145 $headercell->attributes['class'] .= ' selection';
54a007e8 1146 $headercell->text = get_string('select');
1147 return $headercell;
dc482cfa 1148 }
1149
1150 public function get_category_cell($category, $levelclass, $params) {
54a007e8 1151 global $OUTPUT;
dc482cfa 1152 if (empty($params['eid'])) {
1153 throw new Exception('Array key (eid) missing from 3rd param of grade_edit_tree_column_select::get_category_cell($category, $levelclass, $params)');
1154 }
4ee753eb
PS
1155 $selectall = new action_link(new moodle_url('#'), get_string('all'), new component_action('click', 'togglecheckboxes', array('eid' => $params['eid'], 'check' => true)));
1156 $selectnone = new action_link(new moodle_url('#'), get_string('none'), new component_action('click', 'togglecheckboxes', array('eid' => $params['eid'], 'check' => false)));
dc482cfa 1157
54a007e8 1158 $categorycell = clone($this->categorycell);
16be8974 1159 $categorycell->attributes['class'] .= ' last ' . $levelclass;
54a007e8 1160 $categorycell->style .= 'text-align: center;';
4ee753eb 1161 $categorycell->text = $OUTPUT->render($selectall) . '<br />' . $OUTPUT->render($selectnone);
54a007e8 1162 return $categorycell;
dc482cfa 1163 }
1164
1165 public function get_item_cell($item, $params) {
54a007e8 1166 if (empty($params['itemtype']) || empty($params['eid'])) {
2f0e96e4 1167 error('Array key (itemtype or eid) missing from 2nd param of grade_edit_tree_column_select::get_item_cell($item, $params)');
54a007e8 1168 }
1169 $itemselect = '';
1170
1171 if ($params['itemtype'] != 'course' && $params['itemtype'] != 'category') {
2f0e96e4 1172 $itemselect = '<input class="itemselect" type="checkbox" name="select_'.$params['eid'].'" onchange="toggleCategorySelector();"/>'; // TODO: convert to YUI handler
dc482cfa 1173 }
5174f3c5
AD
1174 //html_writer::table() will wrap the item cell contents in a <TD> so don't do it here
1175 return $itemselect;
dc482cfa 1176 }
1177
1178 public function is_hidden($mode='simple') {
1179 return false;
1180 }
1181}
6c3ef410 1182