Skip to content

Commit

Permalink
Issue #78: Show in upcomming quizzes graph inprogress quizzes that ar…
Browse files Browse the repository at this point in the history
…e upcomming quizzes with override
  • Loading branch information
guillogo authored and Matt Porritt committed Mar 13, 2021
1 parent 0fcefa4 commit d7575b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 6 additions & 6 deletions classes/output/all_participants_inprogress.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ public function get_all_participants_inprogress_chart(int $now, int $hoursahead
$upcommingquizzes = $quizzes['upcomming'];
$finishedquizzes = $quizzes['finished'];

foreach ($upcommingquizzes as $key=>$upcommingquiz) {
foreach ($upcommingquiz as $keyupcomming=>$upcomming) {
$inprogressquizzes[$keyupcomming] = $upcomming;
foreach ($upcommingquizzes as $timestamp => $upcommingquiz) {
foreach ($upcommingquiz as $timestampupcomming => $upcomming) {
$inprogressquizzes[$timestampupcomming] = $upcomming;
}
}

foreach ($finishedquizzes as $key=>$finishedquiz) {
foreach ($finishedquiz as $keyfinished=>$finished) {
$inprogressquizzes[$keyfinished] = $finished;
foreach ($finishedquizzes as $timestamp => $finishedquiz) {
foreach ($finishedquiz as $timestampfinished => $finished) {
$inprogressquizzes[$timestampfinished] = $finished;
}
}

Expand Down
10 changes: 9 additions & 1 deletion classes/output/upcomming_quizzes.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,17 @@ public function get_upcomming_quizzes_chart(int $now): array {
$participantcount += $quiz->participants;
}

// Check if inprogress quizzes are upcomming quizzes with overrides.
foreach ($quizzes['inprogress'] as $inprogress) {
if ($inprogress->timestampopen >= $timestamp && $inprogress->timestampopen < $timestamp + HOURSECS) {
$quizcount++;
$participantcount += $inprogress->participants;
}
}

$quizseriesdata[] = $quizcount;
$participantseriesdata[] = $participantcount;
$labels[] = userdate($timestamp, get_string('inprogressdatetime', 'local_assessfreq'));
$labels[] = userdate($timestamp + HOURSECS, get_string('inprogressdatetime', 'local_assessfreq'));
}

// Create chart object.
Expand Down

0 comments on commit d7575b2

Please sign in to comment.