Skip to content

Commit

Permalink
MDL-77447 gradereport_singleview: Add grade status icons
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyatregubov committed Jul 20, 2023
1 parent 62588d8 commit 565dbaa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 29 deletions.
25 changes: 11 additions & 14 deletions grade/report/singleview/classes/local/screen/grade.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,24 +215,21 @@ public function format_line($item): array {

$grade = $this->fetch_grade_or_default($this->item, $item->id);

$lockicon = '';
$gradestatus = '';
$context = [
'hidden' => $grade->is_hidden(),
'locked' => $grade->is_locked(),
];

$lockedgrade = $lockedgradeitem = 0;
if (!empty($grade->locked)) {
$lockedgrade = 1;
}
if (!empty($grade->grade_item->locked)) {
$lockedgradeitem = 1;
}
// Check both grade and grade item.
if ( $lockedgrade || $lockedgradeitem ) {
$lockicon = $OUTPUT->pix_icon('t/locked', 'grade is locked') . ' ';
if (in_array(true, $context)) {
$context['classes'] = 'gradestatus';
$gradestatus = $OUTPUT->render_from_template('core_grades/status_icons', $context);
}

if (has_capability('moodle/site:viewfullnames', \context_course::instance($this->courseid))) {
$fullname = $lockicon . fullname($item, true);
$fullname = fullname($item, true);
} else {
$fullname = $lockicon . fullname($item);
$fullname = fullname($item);
}

$item->imagealt = $fullname;
Expand All @@ -245,7 +242,7 @@ public function format_line($item): array {
$line = [
html_writer::link($url, $userpic . $fullname),
$this->get_user_action_menu($item),
$formatteddefinition['finalgrade'],
$formatteddefinition['finalgrade'] . $gradestatus,
$this->item_range(),
$formatteddefinition['feedback'],
$formatteddefinition['override'],
Expand Down
24 changes: 11 additions & 13 deletions grade/report/singleview/classes/local/screen/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,16 @@ public function format_line($item): array {
global $OUTPUT;

$grade = $this->fetch_grade_or_default($item, $this->item->id);
$lockicon = '';
$gradestatus = '';

$lockeditem = $lockeditemgrade = 0;
if (!empty($grade->locked)) {
$lockeditem = 1;
}
if (!empty($grade->grade_item->locked)) {
$lockeditemgrade = 1;
}
// Check both grade and grade item.
if ($lockeditem || $lockeditemgrade) {
$lockicon = $OUTPUT->pix_icon('t/locked', 'grade is locked', 'moodle', ['class' => 'ml-3']);
$context = [
'hidden' => $grade->is_hidden(),
'locked' => $grade->is_locked(),
];

if (in_array(true, $context)) {
$context['classes'] = 'gradestatus';
$gradestatus = $OUTPUT->render_from_template('core_grades/status_icons', $context);
}

// Create a fake gradetreeitem so we can call get_element_header().
Expand Down Expand Up @@ -210,10 +208,10 @@ public function format_line($item): array {
}

$line = [
html_writer::div($itemicon . $itemcontent . $lockicon, "{$type} d-flex align-items-center"),
html_writer::div($itemicon . $itemcontent, "{$type} d-flex align-items-center"),
$this->get_item_action_menu($item),
$this->category($item),
$formatteddefinition['finalgrade'],
$formatteddefinition['finalgrade'] . $gradestatus,
new range($item),
$formatteddefinition['feedback'],
$formatteddefinition['override'],
Expand Down
2 changes: 0 additions & 2 deletions grade/report/singleview/classes/report/singleview.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
namespace gradereport_singleview\report;

use context_course;
use grade_helper;
use grade_report;
use html_writer;
use moodle_url;
use renderer_base;
use stdClass;
Expand Down

0 comments on commit 565dbaa

Please sign in to comment.