MDL-80768 output: stricter progress bar component percentage type.

Avoid mixing float/string types, where the decimal separator could
vary according to current locale.
This commit is contained in:
Paul Holden
2024-01-30 23:28:40 +00:00
parent 6080ef9fe7
commit 40ae05718c
2 changed files with 7 additions and 2 deletions
+1 -1
View File
@@ -5241,7 +5241,7 @@ class progress_bar implements renderable, templatable {
$this->percent = $percent;
$this->lastupdate = microtime(true);
echo $OUTPUT->render_progress_bar_update($this->html_id, sprintf("%.1f", $this->percent), $msg, $estimatemsg);
echo $OUTPUT->render_progress_bar_update($this->html_id, $this->percent, $msg, $estimatemsg);
flush();
}
+6 -1
View File
@@ -5140,7 +5140,12 @@ EOD;
* @return string ascii fragment
*/
public function render_progress_bar_update(string $id, float $percent, string $msg, string $estimate) : string {
return html_writer::script(js_writer::function_call('updateProgressBar', [$id, $percent, $msg, $estimate]));
return html_writer::script(js_writer::function_call('updateProgressBar', [
$id,
round($percent, 1),
$msg,
$estimate,
]));
}
/**