From d75a2367c3f537ba2febeaa14424b1c6d4c97f4b Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Thu, 2 Oct 2014 18:35:10 +0800 Subject: [PATCH] MDL-47520 core_grades: added CSS classes to the setup page Part of: MDL-46576 --- grade/edit/tree/lib.php | 81 +++++++++++++--------- grade/report/user/lib.php | 12 ++-- theme/base/style/grade.css | 3 +- theme/bootstrapbase/less/moodle/grade.less | 3 +- theme/bootstrapbase/style/moodle.css | 2 +- 5 files changed, 58 insertions(+), 43 deletions(-) diff --git a/grade/edit/tree/lib.php b/grade/edit/tree/lib.php index 6888600cc57..177fdb44af4 100644 --- a/grade/edit/tree/lib.php +++ b/grade/edit/tree/lib.php @@ -90,7 +90,10 @@ class grade_edit_tree { $this->table = new html_table(); $this->table->id = "grade_edit_tree_table"; - $this->table->attributes['class'] = 'generaltable simple'; + $this->table->attributes['class'] = 'generaltable simple setup-grades'; + if ($this->moving) { + $this->table->attributes['class'] .= ' moving'; + } foreach ($this->columns as $column) { if (!($this->moving && $column->hide_when_moving)) { @@ -168,7 +171,8 @@ class grade_edit_tree { // do not diplay children $cell = new html_table_cell(); $cell->colspan = 12; - $cell->attributes['class'] = $element['type'] . ' moving'; + $cell->attributes['class'] = $element['type'] . ' moving column-name level' . + ($level + 1) . ' level' . ($level % 2 ? 'even' : 'odd'); $cell->text = $object->name.' ('.get_string('move').')'; return array(new html_table_row(array($cell))); } @@ -222,6 +226,7 @@ class grade_edit_tree { $cell = new html_table_cell(); $cell->colspan = 12; + $cell->attributes['class'] = 'movehere level' . ($level + 1) . ' level' . ($level % 2 ? 'even' : 'odd'); $icon = new pix_icon('movehere', $strmovehere, null, array('class'=>'movetarget')); $cell->text = $OUTPUT->action_icon($aurl, $icon); @@ -273,7 +278,7 @@ class grade_edit_tree { $root = true; } - $levelclass = "level$level"; + $levelclass = "level$level level" . ($level % 2 ? 'odd' : 'even'); $courseclass = ''; if ($level == 1) { @@ -290,7 +295,7 @@ class grade_edit_tree { $headercell->header = true; $headercell->scope = 'row'; $headercell->attributes['title'] = $object->stripped_name; - $headercell->attributes['class'] = 'cell rowspan ' . $levelclass; + $headercell->attributes['class'] = 'cell column-rowspan rowspan ' . $levelclass; $headercell->rowspan = $row_count + 1; $row->cells[] = $headercell; @@ -309,7 +314,7 @@ class grade_edit_tree { // Print a coloured row to show the end of the category across the table $endcell = new html_table_cell(); $endcell->colspan = (19 - $level); - $endcell->attributes['class'] = 'colspan ' . $levelclass; + $endcell->attributes['class'] = 'emptyrow colspan ' . $levelclass; $returnrows[] = new html_table_row(array($endcell)); @@ -323,6 +328,9 @@ class grade_edit_tree { if ($item->itemtype == 'category') { $categoryitemclass = 'categoryitem'; } + if ($item->itemtype == 'course') { + $categoryitemclass = 'courseitem'; + } $dimmed = ($item->is_hidden()) ? "dimmed_text" : ""; $gradeitemrow = new html_table_row(); @@ -576,14 +584,27 @@ abstract class grade_edit_tree_column { public abstract function get_header_cell(); - public abstract function get_category_cell($category, $levelclass, $params); + public function get_category_cell($category, $levelclass, $params) { + $cell = clone($this->categorycell); + $cell->attributes['class'] .= ' ' . $levelclass; + $cell->attributes['text'] = ''; + return $cell; + } - public abstract function get_item_cell($item, $params); + public function get_item_cell($item, $params) { + $cell = clone($this->itemcell); + $cell->attributes['text'] = ''; + if (isset($params['level'])) { + $level = $params['level'] + (($item->itemtype == 'category' || $item->itemtype == 'course') ? 0 : 1); + $cell->attributes['class'] .= ' level' . $level; + $cell->attributes['class'] .= ' level' . ($level % 2 ? 'odd' : 'even'); + } + return $cell; + } public function __construct() { $this->headercell = new html_table_cell(); $this->headercell->header = true; - $this->headercell->style = 'whitespace: normal;'; $this->headercell->attributes['class'] = 'header'; $this->categorycell = new html_table_cell(); @@ -591,6 +612,12 @@ abstract class grade_edit_tree_column { $this->itemcell = new html_table_cell(); $this->itemcell->attributes['class'] = 'cell'; + + if (preg_match('/^grade_edit_tree_column_(\w*)$/', get_class($this), $matches)) { + $this->headercell->attributes['class'] .= ' column-' . $matches[1]; + $this->categorycell->attributes['class'] .= ' column-' . $matches[1]; + $this->itemcell->attributes['class'] .= ' column-' . $matches[1]; + } } } @@ -619,7 +646,6 @@ class grade_edit_tree_column_name extends grade_edit_tree_column { public function get_header_cell() { $headercell = clone($this->headercell); - $headercell->attributes['class'] .= ' name'; $headercell->colspan = $this->deepest_level + 1; $headercell->text = get_string('name'); return $headercell; @@ -631,8 +657,7 @@ class grade_edit_tree_column_name extends grade_edit_tree_column { throw new Exception('Array key (name or level) missing from 3rd param of grade_edit_tree_column_name::get_category_cell($category, $levelclass, $params)'); } $moveaction = isset($params['moveaction']) ? $params['moveaction'] : ''; - $categorycell = clone($this->categorycell); - $categorycell->attributes['class'] .= ' name ' . $levelclass; + $categorycell = parent::get_category_cell($category, $levelclass, $params); $categorycell->colspan = ($this->deepest_level +1) - $params['level']; $categorycell->text = $OUTPUT->heading($moveaction . $params['name'], 4); return $categorycell; @@ -648,8 +673,7 @@ class grade_edit_tree_column_name extends grade_edit_tree_column { $name = $params['name']; $moveaction = isset($params['moveaction']) ? $params['moveaction'] : ''; - $itemcell = clone($this->itemcell); - $itemcell->attributes['class'] .= ' name'; + $itemcell = parent::get_item_cell($item, $params); $itemcell->colspan = ($this->deepest_level + 1) - $params['level']; $itemcell->text = $moveaction . $name; return $itemcell; @@ -684,15 +708,14 @@ class grade_edit_tree_column_aggregation extends grade_edit_tree_column { $options = grade_helper::get_aggregation_strings(); $aggregation = $options[$category->aggregation]; - $categorycell = clone($this->categorycell); - $categorycell->attributes['class'] .= ' ' . $levelclass; + $categorycell = parent::get_category_cell($category, $levelclass, $params); $categorycell->text = $aggregation; return $categorycell; } public function get_item_cell($item, $params) { - $itemcell = clone($this->itemcell); + $itemcell = parent::get_item_cell($item, $params); $itemcell->text = ' - '; return $itemcell; } @@ -716,8 +739,7 @@ class grade_edit_tree_column_weight extends grade_edit_tree_column { public function get_category_cell($category, $levelclass, $params) { $item = $category->get_grade_item(); - $categorycell = clone($this->categorycell); - $categorycell->attributes['class'] .= ' ' . $levelclass; + $categorycell = parent::get_category_cell($category, $levelclass, $params); $categorycell->text = grade_edit_tree::get_weight_input($item); return $categorycell; } @@ -726,7 +748,7 @@ class grade_edit_tree_column_weight extends grade_edit_tree_column { if (empty($params['element'])) { throw new Exception('Array key (element) missing from 2nd param of grade_edit_tree_column_weightorextracredit::get_item_cell($item, $params)'); } - $itemcell = clone($this->itemcell); + $itemcell = parent::get_item_cell($item, $params); $itemcell->text = ' '; if (!in_array($params['element']['object']->itemtype, array('courseitem', 'categoryitem', 'category'))) { @@ -752,8 +774,7 @@ class grade_edit_tree_column_range extends grade_edit_tree_column { } public function get_category_cell($category, $levelclass, $params) { - $categorycell = clone($this->categorycell); - $categorycell->attributes['class'] .= ' range ' . $levelclass; + $categorycell = parent::get_category_cell($category, $levelclass, $params); $categorycell->text = ' - '; return $categorycell; } @@ -784,7 +805,7 @@ class grade_edit_tree_column_range extends grade_edit_tree_column { $grademax = format_float($item->grademax, $item->get_decimals()); } - $itemcell = clone($this->itemcell); + $itemcell = parent::get_item_cell($item, $params); $itemcell->text = $grademax; return $itemcell; } @@ -804,7 +825,6 @@ class grade_edit_tree_column_actions extends grade_edit_tree_column { public function get_header_cell() { $headercell = clone($this->headercell); - $headercell->attributes['class'] .= ' actions'; $headercell->text = get_string('actions'); return $headercell; } @@ -815,8 +835,7 @@ class grade_edit_tree_column_actions extends grade_edit_tree_column { throw new Exception('Array key (actions) missing from 3rd param of grade_edit_tree_column_actions::get_category_actions($category, $levelclass, $params)'); } - $categorycell = clone($this->categorycell); - $categorycell->attributes['class'] .= ' ' . $levelclass; + $categorycell = parent::get_category_cell($category, $levelclass, $params); $categorycell->text = $params['actions']; return $categorycell; } @@ -825,8 +844,7 @@ class grade_edit_tree_column_actions extends grade_edit_tree_column { if (empty($params['actions'])) { throw new Exception('Array key (actions) missing from 2nd param of grade_edit_tree_column_actions::get_item_cell($item, $params)'); } - $itemcell = clone($this->itemcell); - $itemcell->attributes['class'] .= ' actions'; + $itemcell = parent::get_item_cell($item, $params); $itemcell->text = $params['actions']; return $itemcell; } @@ -842,7 +860,6 @@ class grade_edit_tree_column_select extends grade_edit_tree_column { public function get_header_cell() { $headercell = clone($this->headercell); - $headercell->attributes['class'] .= ' selection'; $headercell->text = get_string('select'); return $headercell; } @@ -855,8 +872,7 @@ class grade_edit_tree_column_select extends grade_edit_tree_column { $selectall = new action_link(new moodle_url('#'), get_string('all'), new component_action('click', 'togglecheckboxes', array('eid' => $params['eid'], 'check' => true))); $selectnone = new action_link(new moodle_url('#'), get_string('none'), new component_action('click', 'togglecheckboxes', array('eid' => $params['eid'], 'check' => false))); - $categorycell = clone($this->categorycell); - $categorycell->attributes['class'] .= ' selection ' . $levelclass; + $categorycell = parent::get_category_cell($category, $levelclass, $params); $categorycell->text = $OUTPUT->render($selectall) . '
' . $OUTPUT->render($selectnone); return $categorycell; } @@ -865,9 +881,7 @@ class grade_edit_tree_column_select extends grade_edit_tree_column { if (empty($params['itemtype']) || empty($params['eid'])) { error('Array key (itemtype or eid) missing from 2nd param of grade_edit_tree_column_select::get_item_cell($item, $params)'); } - $itemcell = clone($this->itemcell); - $itemcell->attributes['class'] .= ' selection'; - $itemcell->text = ''; + $itemcell = parent::get_item_cell($item, $params); if ($params['itemtype'] != 'course' && $params['itemtype'] != 'category') { $itemcell->text = '