Skip to content

Commit

Permalink
Merge branch 'MDL-77849-master' of https://github.com/ilyatregubov/mo…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Apr 21, 2023
2 parents e07f28e + bc977c3 commit ba81947
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 41 deletions.
104 changes: 73 additions & 31 deletions grade/report/grader/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,23 @@ public function get_right_rows(bool $displayaverages) : array {
$strpass = get_string('pass', 'grades');
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->context);

// Preload scale objects for items with a scaleid and initialize tab indices.
$scaleslist = [];
$tabindices = [];

foreach ($this->gtree->get_items() as $itemid => $item) {
if (!empty($item->scaleid)) {
$scaleslist[] = $item->scaleid;
}
$tabindices[$item->id]['grade'] = $gradetabindex;
$gradetabindex += $numusers * 2;
}
$scalesarray = [];

if (!empty($scaleslist)) {
$scalesarray = $DB->get_records_list('scale', 'id', $scaleslist);
}

foreach ($this->gtree->get_levels() as $row) {
$headingrow = new html_table_row();
$headingrow->attributes['class'] = 'heading_name_row';
Expand Down Expand Up @@ -874,16 +891,43 @@ public function get_right_rows(bool $displayaverages) : array {
$itemcell->attributes['class'] .= ' statusicons';
}

switch ($element['object']->gradetype) {
case GRADE_TYPE_SCALE:
$itemcell->attributes['class'] .= ' grade_type_scale';
break;
case GRADE_TYPE_VALUE:
$itemcell->attributes['class'] .= ' grade_type_value';
break;
case GRADE_TYPE_TEXT:
if (!empty($USER->editing)) {
switch ($element['object']->gradetype) {
case GRADE_TYPE_SCALE:
$itemcell->attributes['class'] .= ' grade_type_scale';
break;
case GRADE_TYPE_VALUE:
$itemcell->attributes['class'] .= ' grade_type_value';
break;
case GRADE_TYPE_TEXT:
$itemcell->attributes['class'] .= ' grade_type_text';
break;
}
} else {
$gradedisplaytype = $element['object']->get_displaytype();

// Letter grades, scales and text grades are left aligned.
$textgrade = false;
$textgrades = [GRADE_DISPLAY_TYPE_LETTER,
GRADE_DISPLAY_TYPE_REAL_LETTER,
GRADE_DISPLAY_TYPE_LETTER_REAL,
GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE,
GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER];
if (in_array($gradedisplaytype, $textgrades)) {
$textgrade = true;
}

if ($textgrade || ($element['object']->gradetype == GRADE_TYPE_TEXT)) {
$itemcell->attributes['class'] .= ' grade_type_text';
break;
} else if ($element['object']->scaleid && !empty($scalesarray[$element['object']->scaleid])) {
if ($gradedisplaytype == GRADE_DISPLAY_TYPE_PERCENTAGE) {
$itemcell->attributes['class'] .= ' grade_type_value';
} else {
$itemcell->attributes['class'] .= ' grade_type_scale';
}
} else {
$itemcell->attributes['class'] .= ' grade_type_value';
}
}

$itemcell->colspan = $colspan;
Expand All @@ -905,23 +949,6 @@ public function get_right_rows(bool $displayaverages) : array {
$rows[] = $headingrow;
}

// Preload scale objects for items with a scaleid and initialize tab indices.
$scaleslist = [];
$tabindices = [];

foreach ($this->gtree->get_items() as $itemid => $item) {
if (!empty($item->scaleid)) {
$scaleslist[] = $item->scaleid;
}
$tabindices[$item->id]['grade'] = $gradetabindex;
$gradetabindex += $numusers * 2;
}
$scalesarray = [];

if (!empty($scaleslist)) {
$scalesarray = $DB->get_records_list('scale', 'id', $scaleslist);
}

// Get all the grade items if the user can not view hidden grade items.
// It is possible that the user is simply viewing the 'Course total' by switching to the 'Aggregates only' view
// and that this user does not have the ability to view hidden items. In this case we still need to pass all the
Expand Down Expand Up @@ -1118,12 +1145,27 @@ public function get_right_rows(bool $displayaverages) : array {
// Not editing.
$gradedisplaytype = $item->get_displaytype();

if ($item->scaleid && !empty($scalesarray[$item->scaleid])) {
$itemcell->attributes['class'] .= ' grade_type_scale';
} else if ($item->gradetype == GRADE_TYPE_VALUE) {
$itemcell->attributes['class'] .= ' grade_type_value';
} else if ($item->gradetype == GRADE_TYPE_TEXT) {
// Letter grades, scales and text grades are left aligned.
$textgrade = false;
$textgrades = [GRADE_DISPLAY_TYPE_LETTER,
GRADE_DISPLAY_TYPE_REAL_LETTER,
GRADE_DISPLAY_TYPE_LETTER_REAL,
GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE,
GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER];
if (in_array($gradedisplaytype, $textgrades)) {
$textgrade = true;
}

if ($textgrade || ($item->gradetype == GRADE_TYPE_TEXT)) {
$itemcell->attributes['class'] .= ' grade_type_text';
} else if ($item->scaleid && !empty($scalesarray[$item->scaleid])) {
if ($gradedisplaytype == GRADE_DISPLAY_TYPE_PERCENTAGE) {
$itemcell->attributes['class'] .= ' grade_type_value';
} else {
$itemcell->attributes['class'] .= ' grade_type_scale';
}
} else {
$itemcell->attributes['class'] .= ' grade_type_value';
}

if ($item->needsupdate) {
Expand Down
27 changes: 19 additions & 8 deletions grade/report/grader/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
border: 1px solid #ccc;
border-top-width: 0;
border-left-width: 0;
padding: 10px;
padding: 0.5rem 1rem;
vertical-align: top;
height: 100%;
}
Expand All @@ -48,16 +48,15 @@
.path-grade-report-grader .grade_icons,
.path-grade-report-grader .category_grade_icons {
white-space: nowrap;
margin-top: 10px;
margin-right: 10px;
margin-top: 0.5rem;
}

.path-grade-report-grader .grade_type_value .grade_icons {
margin-left: auto;
}

.path-grade-report-grader .grade_icons .icon {
margin-right: 20px;
margin-right: 1rem;
}

.path-grade-report-grader .grade_icons .icon:last-child {
Expand Down Expand Up @@ -91,8 +90,13 @@
}

.path-grade-report-grader .heading .gradeitemheader {
text-indent: -24px;
padding-left: 22px;
text-indent: -1.5rem;
padding-left: 1.5rem;
padding-top: 6px;
}

.path-grade-report-grader .dropdown-item {
text-align: left;
}

.path-grade-report-grader .heading .gradeitemheader .itemicon {
Expand Down Expand Up @@ -160,7 +164,8 @@
}

.path-grade-report-grader .gradeparent td.grade_type_value,
.path-grade-report-grader .gradeparent td.grade_type_value input {
.path-grade-report-grader .gradeparent td.grade_type_value input,
.path-grade-report-grader .gradeparent td.grade_type_value div {
text-align: right;
margin-left: auto;
}
Expand All @@ -169,6 +174,11 @@
display: inline-block;
}

.path-grade-report-grader .header,
.path-grade-report-grader td.userfield div {
padding-top: 6px;
}

.path-grade-report-grader .gradeparent tr:nth-child(n) td.ajaxoverridden:nth-child(n) {
/* Made very specific to override the default stripped style of the table. */
background-color: #ffe3a0;
Expand Down Expand Up @@ -204,7 +214,8 @@

.path-grade-report-grader .action-menu {
display: inline-block;
padding-left: 10px;
margin-right: -0.5rem;
padding-left: 0.5rem;
}

.path-grade-report-grader .heading .action-menu {
Expand Down
2 changes: 1 addition & 1 deletion grade/report/grader/templates/categorycell.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}}
<div class="d-flex flex-column h-100">
<div class="d-flex">
<div>
<div class="header">
{{{courseheader}}}
</div>
<div>
Expand Down
2 changes: 1 addition & 1 deletion grade/templates/cellmenu.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"columncollapse": "<a class='dropdown-item' data-hider='hide' aria-label='Collapse' role='menuitem' href='#'>Collapse</a>"
}
}}
<div class="action-menu mb-1 moodle-actionmenu grader" data-collapse="menu">
<div class="action-menu moodle-actionmenu grader" data-collapse="menu">
<div class="dropdown">
<button class="btn btn-link btn-icon icon-size-3 cellmenubtn"
type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
Expand Down
2 changes: 2 additions & 0 deletions grade/templates/grades/grader/text.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@
"text": "<span class='gradevalue dimmed_text '>Mostly separate knowing</span>"
}
}}
<div class="header">
{{{gradepassicon}}}
<span class="{{extraclasses}}">{{{text}}}</span>
</div>

0 comments on commit ba81947

Please sign in to comment.