Skip to content

Commit

Permalink
Additional bugfixing:
Browse files Browse the repository at this point in the history
* Download data not respecting month selected (also added ordering of data for visibility ease)
* Fixed year filter display not respecting "courselevelyearfilter"
* Corrected issues with cutoff time calculations
* Updated activity dashboard for assign module not outputting submission status
* Updated CSS to change selected menu items to blue background on select instead of on losing focus
  • Loading branch information
SimonThornett committed Oct 3, 2024
1 parent fc7f76b commit c72a833
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 12 deletions.
11 changes: 8 additions & 3 deletions classes/frequency.php
Original file line number Diff line number Diff line change
Expand Up @@ -1258,13 +1258,13 @@ public function get_frequency_array(int $year = 0, int $month = 0, string $metri
* @param array $modules The modules to get.
* @return array $data The data for the download file.
*/
public function get_download_data(int $year, string $metric, array $modules): array {
public function get_download_data(int $year, int $month, string $metric, array $modules): array {
global $DB, $PAGE;

$data = [];
$events = [];
$from = mktime(0, 0, 0, 1, 1, $year);
$to = mktime(23, 59, 59, 12, 31, $year);
$from = mktime(0, 0, 0, $month, 1, $year);
$to = strtotime("+1 year", $from) - 1;

if ($metric == 'assess') {
if ($PAGE->course->id == SITEID) {
Expand Down Expand Up @@ -1294,6 +1294,11 @@ public function get_download_data(int $year, string $metric, array $modules): ar
}
}

// Soert the data by timeend.
usort($events, function($a, $b) {
return strcmp($a->timeend, $b->timeend);
});

// Format the data ready for download.
foreach ($events as $event) {
$row = [];
Expand Down
2 changes: 1 addition & 1 deletion report/heatmap/classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function render_report($preferenceyear, $preferencemodules, $preferenceme
],
'downloadmetric' => $preferencemetric,
'sesskey' => sesskey(),
'iscourse' => $this->page->course->id !== SITEID,
'yearfilter' => get_config('assessfreqreport_heatmap', 'courselevelyearfilter'),
'courseid' => $this->page->course->id,
'months' => $months,
'scales' => html_writer::table($scalestable),
Expand Down
4 changes: 3 additions & 1 deletion report/heatmap/download.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@
}

$frequency = new frequency();
$data = $frequency->get_download_data($year, $metric, $modules);
$orderedmonths = get_months_ordered();
$month = array_key_first($orderedmonths);
$data = $frequency->get_download_data($year, $month, $metric, $modules);

$rawfilename = $year . '_' . $metric . '_' . implode('_', $modules);
$filename = clean_filename($rawfilename);
Expand Down
4 changes: 2 additions & 2 deletions report/heatmap/templates/filters.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
<div class="container-fluid">
<div class="row justify-content-between">
<div class="col-9">
{{^iscourse}}
{{#yearfilter}}
{{> assessfreqreport_heatmap/filter-year}}
{{/iscourse}}
{{/yearfilter}}
{{> assessfreqreport_heatmap/filter-type}}
{{> assessfreqreport_heatmap/filter-metric}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion report/summary_graphs/classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function render_report($data) {
'assessfreqreport_summary_graphs/summary-graphs',
[
'charts' => $charts,
'iscourse' => $this->page->course->id !== SITEID,
'yearfilter' => get_config('assessfreqreport_summary_graphs', 'courselevelyearfilter'),
'filters' => [
'years' => get_years(get_user_preferences('assessfreqreport_summary_graphs_year_preference', date('Y'))),
],
Expand Down
4 changes: 2 additions & 2 deletions report/summary_graphs/templates/filters.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
}}

<div class="filters">
{{^iscourse}}
{{#yearfilter}}
<p>{{#str}}report:usage_guidlines, assessfreqreport_summary_graphs {{/str}}</p>
{{> assessfreqreport_summary_graphs/filter-year}}
{{/iscourse}}
{{/yearfilter}}
</div>
27 changes: 26 additions & 1 deletion source/assign/classes/output/user_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ public function other_cols($column, $row) : string {
* @return string html used to display the field.
*/
public function col_timeopen(stdClass $row) : string {
if (!$row->timeopen) {
return '-';
}

$datetime = userdate($row->timeopen, get_string('studentattempt:trenddatetime', 'assessfreqsource_assign'));

if ($row->timeopen != $this->timeopen) {
Expand All @@ -173,6 +177,10 @@ public function col_timeopen(stdClass $row) : string {
* @return string html used to display the field.
*/
public function col_timeclose(stdClass $row) : string {
if (!$row->timeclose) {
return '-';
}

$datetime = userdate($row->timeclose, get_string('studentattempt:trenddatetime', 'assessfreqsource_assign'));

if ($row->timeclose != $this->timeclose) {
Expand All @@ -192,7 +200,11 @@ public function col_timeclose(stdClass $row) : string {
* @return string html used to display the field.
*/
public function col_cutoffdate(stdClass $row) : string {
$cutoffdate = format_time($row->cutoffdate);
if (!$row->cutoffdate) {
return '-';
}

$cutoffdate = format_time($row->cutoffdate ? $row->cutoffdate - time() : 0);

if ($row->cutoffdate != $this->cutoffdate) {
$content = html_writer::span($cutoffdate, 'local-assessfreq-override-status');
Expand Down Expand Up @@ -229,6 +241,19 @@ public function col_actions(stdClass $row) : string {
return $manage;
}

/**
* Get the status for the assignment column.
*
* @param stdClass $row
* @return string html used to display the field.
*/
public function col_status(stdClass $row) : string {
if (!$row->status || $row->status == 'new') {
return '';
}

return get_string('submissionstatus_' . $row->status, 'assign');
}

/**
* Query the database for results to display in the table.
Expand Down
13 changes: 12 additions & 1 deletion source/quiz/classes/output/user_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ public function other_cols($column, $row) : string {
* @return string html used to display the field.
*/
public function col_timeopen(stdClass $row) : string {
if (!$row->timeopen) {
return '-';
}

$datetime = userdate($row->timeopen, get_string('studentattempt:trenddatetime', 'assessfreqsource_quiz'));

if ($row->timeopen != $this->timeopen) {
Expand All @@ -171,6 +175,9 @@ public function col_timeopen(stdClass $row) : string {
* @return string html used to display the field.
*/
public function col_timeclose(stdClass $row) : string {
if (!$row->timeclose) {
return '-';
}
$datetime = userdate($row->timeclose, get_string('studentattempt:trenddatetime', 'assessfreqsource_quiz'));

if ($row->timeclose != $this->timeclose) {
Expand All @@ -190,7 +197,11 @@ public function col_timeclose(stdClass $row) : string {
* @return string html used to display the field.
*/
public function col_timelimit(stdClass $row) : string {
$timelimit = format_time($row->timelimit);
if (!$row->timeclose) {
return '-';
}

$timelimit = format_time($row->timeclose ? $row->timeclose - time() : 0);

if ($row->timelimit != $this->timelimit) {
$content = html_writer::span($timelimit, 'local-assessfreq-override-status');
Expand Down
8 changes: 8 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,11 @@ body #local-assessfreq-index {
.modal-dialog.local-assessfreq-modal-large .modal-body .chartjs-render-monitor {
min-height: calc(100vh - 250px);
}

#local-assessfreq-index .dropdown-menu .dropdown-item:active,
#local-assessfreq-index .dropdown-menu .dropdown-item:focus,
#local-assessfreq-index .dropdown-menu .dropdown-item:focus-within {
outline: 0 !important;
background-color: #0176be !important;
color: #fff !important;
}

0 comments on commit c72a833

Please sign in to comment.