Skip to content

Commit

Permalink
MDL-47541 core_grades: hints about aggregation settings on setup page
Browse files Browse the repository at this point in the history
Also do not indicate 'Natural' aggregation method
  • Loading branch information
marinaglancy committed Oct 8, 2014
1 parent c5d4fd7 commit 2be0d5c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 58 deletions.
54 changes: 1 addition & 53 deletions grade/edit/tree/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ class grade_edit_tree {

public $uses_weight = false;

/** @var bool indicates if tree has categories with aggregation method other than Natural. */
protected $uses_non_natural = false;

public $table;

public $categories = array();
Expand All @@ -73,10 +70,6 @@ public function __construct($gtree, $moving=false, $gpr) {

$this->columns = array(grade_edit_tree_column::factory('name', array('deepest_level' => $this->deepest_level)));

if ($this->uses_non_natural) {
$this->columns[] = grade_edit_tree_column::factory('aggregation', array('flag' => true));
}

if ($this->uses_weight) {
$this->columns[] = grade_edit_tree_column::factory('weight', array('adv' => 'weight'));
}
Expand Down Expand Up @@ -120,7 +113,7 @@ public function build_html_tree($element, $totals, $parents, $level, &$row_count

$object = $element['object'];
$eid = $element['eid'];
$object->name = $this->gtree->get_element_header($element, true, true, false);
$object->name = $this->gtree->get_element_header($element, true, true, true, true);
$object->stripped_name = $this->gtree->get_element_header($element, false, false, false);

$is_category_item = false;
Expand Down Expand Up @@ -523,10 +516,6 @@ function get_deepest_level($element, $level=0, $deepest_level=1) {
$level++;
$coefstring = $element['object']->get_coefstring();
if ($element['type'] == 'category') {
if ($element['object']->aggregation != GRADE_AGGREGATE_SUM) {
$this->uses_non_natural = true;
}

if ($coefstring == 'aggregationcoefweight' || $coefstring == 'aggregationcoefextraweightsum' ||
$coefstring == 'aggregationcoefextraweight') {
$this->uses_weight = true;
Expand Down Expand Up @@ -680,47 +669,6 @@ public function get_item_cell($item, $params) {
}
}

/**
* Class grade_edit_tree_column_aggregation
*
* @package core_grades
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class grade_edit_tree_column_aggregation extends grade_edit_tree_column {

public function __construct($params) {
parent::__construct('aggregation');
}

public function get_header_cell() {
global $OUTPUT;
$headercell = clone($this->headercell);
$headercell->text = get_string('aggregation', 'grades').$OUTPUT->help_icon('aggregation', 'grades');
return $headercell;
}

public function get_category_cell($category, $levelclass, $params) {
global $CFG, $OUTPUT;
if (empty($params['id'])) {
throw new Exception('Array key (id) missing from 3rd param of grade_edit_tree_column_aggregation::get_category_cell($category, $levelclass, $params)');
}

$options = grade_helper::get_aggregation_strings();
$aggregation = $options[$category->aggregation];

$categorycell = parent::get_category_cell($category, $levelclass, $params);
$categorycell->text = $aggregation;
return $categorycell;

}

public function get_item_cell($item, $params) {
$itemcell = parent::get_item_cell($item, $params);
$itemcell->text = ' - ';
return $itemcell;
}
}

/**
* Class grade_edit_tree_column_weight
*
Expand Down
13 changes: 9 additions & 4 deletions lib/grade/grade_category.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class grade_category extends grade_object {
* A constant pointing to one of the predefined aggregation strategies (none, mean, median, sum etc) .
* @var int $aggregation
*/
public $aggregation = GRADE_AGGREGATE_MEAN;
public $aggregation = GRADE_AGGREGATE_SUM;

/**
* Keep only the X highest items.
Expand Down Expand Up @@ -1965,8 +1965,10 @@ public function get_name() {
*/
public function get_description() {
$allhelp = array();
$aggrstrings = grade_helper::get_aggregation_strings();
$allhelp[] = $aggrstrings[$this->aggregation];
if ($this->aggregation != GRADE_AGGREGATE_SUM) {
$aggrstrings = grade_helper::get_aggregation_strings();
$allhelp[] = $aggrstrings[$this->aggregation];
}

if ($this->droplow && $this->can_apply_limit_rules()) {
$allhelp[] = get_string('droplowestvalues', 'grades', $this->droplow);
Expand All @@ -1980,7 +1982,10 @@ public function get_description() {
if ($this->aggregatesubcats) {
$allhelp[] = get_string('aggregatesubcatsshort', 'grades');
}
return implode('. ', $allhelp) . '.';
if ($allhelp) {
return implode('. ', $allhelp) . '.';
}
return '';
}

/**
Expand Down
9 changes: 9 additions & 0 deletions theme/base/style/grade.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,12 @@
.path-grade-edit-tree table.setup-grades .column-select {
text-align: center;
}

.path-grade-edit-tree table.setup-grades .column-weight {
white-space: nowrap;
}

.path-grade-edit-tree table.setup-grades .gradeitemdescription {
font-weight: normal;
font-style: italic;
}
9 changes: 9 additions & 0 deletions theme/bootstrapbase/less/moodle/grade.less
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,12 @@
.path-grade-edit-tree table.setup-grades .column-select {
text-align: center;
}

.path-grade-edit-tree table.setup-grades .column-weight {
white-space: nowrap;
}

.path-grade-edit-tree table.setup-grades .gradeitemdescription {
font-weight: normal;
font-style: italic;
}
2 changes: 1 addition & 1 deletion theme/bootstrapbase/style/moodle.css

Large diffs are not rendered by default.

0 comments on commit 2be0d5c

Please sign in to comment.