Skip to content

Commit

Permalink
MDL-75173 core_completion: Inconsistent status check.
Browse files Browse the repository at this point in the history
There is inconsistent status check for course completion block and
completion details page. Completion block was taking to account
pending statuses for completion criteria while completion details
page was ignoring those.
  • Loading branch information
ilyatregubov committed Oct 14, 2022
1 parent d6fa50d commit 90b1e2c
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions blocks/completionstatus/details.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,36 @@
);
$ccompletion = new completion_completion($params);

if ($coursecomplete) {
// Save row data.
$rows = array();

// Flag to set if current completion data is inconsistent with what is stored in the database.
$pendingupdate = false;

// Load criteria to display.
$completions = $info->get_completions($user->id);

// Loop through course criteria.
foreach ($completions as $completion) {
$criteria = $completion->get_criteria();

if (!$pendingupdate && $criteria->is_pending($completion)) {
$pendingupdate = true;
}

$row = array();
$row['type'] = $criteria->criteriatype;
$row['title'] = $criteria->get_title();
$row['status'] = $completion->get_status();
$row['complete'] = $completion->is_complete();
$row['timecompleted'] = $completion->timecompleted;
$row['details'] = $criteria->get_details($completion);
$rows[] = $row;
}

if ($pendingupdate) {
echo html_writer::tag('i', get_string('pending', 'completion'));
} else if ($coursecomplete) {
echo get_string('complete');
} else if (!$criteriacomplete && !$ccompletion->timestarted) {
echo html_writer::tag('i', get_string('notyetstarted', 'completion'));
Expand All @@ -121,9 +150,6 @@
echo html_writer::end_tag('td');
echo html_writer::end_tag('tr');

// Load criteria to display.
$completions = $info->get_completions($user->id);

// Check if this course has any criteria.
if (empty($completions)) {
echo html_writer::start_tag('tr');
Expand Down Expand Up @@ -166,23 +192,6 @@
echo html_writer::tag('th', get_string('completiondate', 'report_completion'), array('class' => 'c5 header', 'scope' => 'col'));
echo html_writer::end_tag('tr');

// Save row data.
$rows = array();

// Loop through course criteria.
foreach ($completions as $completion) {
$criteria = $completion->get_criteria();

$row = array();
$row['type'] = $criteria->criteriatype;
$row['title'] = $criteria->get_title();
$row['status'] = $completion->get_status();
$row['complete'] = $completion->is_complete();
$row['timecompleted'] = $completion->timecompleted;
$row['details'] = $criteria->get_details($completion);
$rows[] = $row;
}

// Print table.
$last_type = '';
$agg_type = false;
Expand Down

0 comments on commit 90b1e2c

Please sign in to comment.