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