diff --git a/export.php b/export.php index 0a5765c..ead107a 100644 --- a/export.php +++ b/export.php @@ -160,9 +160,9 @@ if ($formdata = $mform->get_data()) { $usersummary = $reportdata->summary->get_taken_sessions_summary_for($user->id); $data->table[$i][] = $usersummary->numtakensessions; - $data->table[$i][] = attendance_format_float($usersummary->takensessionspoints) . ' / ' . - attendance_format_float($usersummary->takensessionsmaxpoints); - $data->table[$i][] = attendance_format_float($usersummary->takensessionspercentage * 100, false); + $data->table[$i][] = format_float($usersummary->takensessionspoints, 1, true, true) . ' / ' . + format_float($usersummary->takensessionsmaxpoints, 1, true, true); + $data->table[$i][] = format_float($usersummary->takensessionspercentage * 100); $i++; } diff --git a/locallib.php b/locallib.php index 1d30ecb..22a5c1e 100644 --- a/locallib.php +++ b/locallib.php @@ -239,14 +239,3 @@ function attendance_update_users_grade($attendance, $userids=array()) { return grade_update('mod/attendance', $course->id, 'mod', 'attendance', $attendance->id, 0, $grades); } - -/** - * Given a float, prints it nicely. - * - * @param float $float The float to print - * @param bool $stripzeros If true, removes final zeros after decimal point - * @return string locale float - */ -function attendance_format_float($float, $stripzeros=true) { - return format_float($float, 1, true, $stripzeros); -} diff --git a/renderer.php b/renderer.php index 25868b3..e8c7b36 100644 --- a/renderer.php +++ b/renderer.php @@ -802,8 +802,8 @@ class mod_attendance_renderer extends plugin_renderer_base { if (isset($sess->statusid)) { $status = $userdata->statuses[$sess->statusid]; $row->cells[] = $status->description; - $row->cells[] = attendance_format_float($status->grade) . ' / ' . - attendance_format_float($statussetmaxpoints[$status->setnumber]); + $row->cells[] = format_float($status->grade, 1, true, true) . ' / ' . + format_float($statussetmaxpoints[$status->setnumber], 1, true, true); $row->cells[] = $sess->remarks; } else if ($sess->sessdate < $userdata->user->enrolmentstart) { $cell = new html_table_cell(get_string('enrolmentstart', 'attendance', @@ -825,7 +825,7 @@ class mod_attendance_renderer extends plugin_renderer_base { $row->cells[] = $cell; } else { // Student cannot mark their own attendace. $row->cells[] = '?'; - $row->cells[] = '? / ' . attendance_format_float($statussetmaxpoints[$sess->statusset]); + $row->cells[] = '? / ' . format_float($statussetmaxpoints[$sess->statusset], 1, true, true); $row->cells[] = ''; } } @@ -951,19 +951,19 @@ class mod_attendance_renderer extends plugin_renderer_base { $usersummary = $reportdata->summary->get_taken_sessions_summary_for($user->id); } $row->cells[] = $usersummary->numtakensessions; - $row->cells[] = attendance_format_float($usersummary->takensessionspoints) . ' / ' . - attendance_format_float($usersummary->takensessionsmaxpoints); - $row->cells[] = attendance_format_float($usersummary->takensessionspercentage * 100, false) . '%'; + $row->cells[] = format_float($usersummary->takensessionspoints, 1, true, true) . ' / ' . + format_float($usersummary->takensessionsmaxpoints, 1, true, true); + $row->cells[] = format_float($usersummary->takensessionspercentage * 100) . '%'; if ($reportdata->pageparams->view == ATT_VIEW_SUMMARY) { $row->cells[] = $usersummary->numallsessions; - $row->cells[] = attendance_format_float($usersummary->takensessionspoints) . ' / ' . - attendance_format_float($usersummary->allsessionsmaxpoints); - $row->cells[] = attendance_format_float($usersummary->allsessionspercentage * 100, false) . '%'; + $row->cells[] = format_float($usersummary->takensessionspoints, 1, true, true) . ' / ' . + format_float($usersummary->allsessionsmaxpoints, 1, true, true); + $row->cells[] = format_float($usersummary->allsessionspercentage * 100) . '%'; - $row->cells[] = attendance_format_float($usersummary->maxpossiblepoints) . ' / ' . - attendance_format_float($usersummary->allsessionsmaxpoints); - $row->cells[] = attendance_format_float($usersummary->maxpossiblepercentage * 100, false) . '%'; + $row->cells[] = format_float($usersummary->maxpossiblepoints, 1, true, true) . ' / ' . + format_float($usersummary->allsessionsmaxpoints, 1, true, true); + $row->cells[] = format_float($usersummary->maxpossiblepercentage * 100) . '%'; } if ($bulkmessagecapability) { // Create the checkbox for bulk messaging. diff --git a/renderhelpers.php b/renderhelpers.php index 10f95de..bf07176 100644 --- a/renderhelpers.php +++ b/renderhelpers.php @@ -49,8 +49,8 @@ class user_sessions_cells_generator { if (array_key_exists($sess->id, $this->reportdata->sessionslog[$this->user->id])) { $statusid = $this->reportdata->sessionslog[$this->user->id][$sess->id]->statusid; if (array_key_exists($statusid, $this->reportdata->statuses)) { - $points = attendance_format_float($this->reportdata->statuses[$statusid]->grade); - $maxpoints = attendance_format_float($sess->maxpoints); + $points = format_float($this->reportdata->statuses[$statusid]->grade, 1, true, true); + $maxpoints = format_float($sess->maxpoints, 1, true, true); $this->construct_existing_status_cell($this->reportdata->statuses[$statusid]->acronym . " ({$points}/{$maxpoints})"); } else { @@ -243,44 +243,47 @@ function construct_user_data_stat($usersummary, $view) { $row = new html_table_row(); $row->attributes['class'] = 'normal'; $row->cells[] = get_string('pointssessionscompleted', 'attendance') . ':'; - $row->cells[] = attendance_format_float($usersummary->takensessionspoints) . ' / ' . attendance_format_float($usersummary->takensessionsmaxpoints); + $row->cells[] = format_float($usersummary->takensessionspoints, 1, true, true) . ' / ' . + format_float($usersummary->takensessionsmaxpoints, 1, true, true); $stattable->data[] = $row; $row = new html_table_row(); $row->attributes['class'] = 'normal'; $row->cells[] = get_string('percentagesessionscompleted', 'attendance') . ':'; - $row->cells[] = attendance_format_float($usersummary->takensessionspercentage * 100, false) . '%'; + $row->cells[] = format_float($usersummary->takensessionspercentage * 100) . '%'; $stattable->data[] = $row; if ($view == ATT_VIEW_ALL) { $row = new html_table_row(); $row->attributes['class'] = 'highlight'; $row->cells[] = get_string('sessionstotal', 'attendance') . ':'; - $row->cells[] = attendance_format_float($usersummary->numallsessions); + $row->cells[] = $usersummary->numallsessions; $stattable->data[] = $row; $row = new html_table_row(); $row->attributes['class'] = 'highlight'; $row->cells[] = get_string('pointsallsessions', 'attendance') . ':'; - $row->cells[] = attendance_format_float($usersummary->takensessionspoints) . ' / ' . attendance_format_float($usersummary->allsessionsmaxpoints); + $row->cells[] = format_float($usersummary->takensessionspoints, 1, true, true) . ' / ' . + format_float($usersummary->allsessionsmaxpoints, 1, true, true); $stattable->data[] = $row; $row = new html_table_row(); $row->attributes['class'] = 'highlight'; $row->cells[] = get_string('percentageallsessions', 'attendance') . ':'; - $row->cells[] = attendance_format_float($usersummary->allsessionspercentage * 100, false) . '%'; + $row->cells[] = format_float($usersummary->allsessionspercentage * 100) . '%'; $stattable->data[] = $row; $row = new html_table_row(); $row->attributes['class'] = 'normal'; $row->cells[] = get_string('maxpossiblepoints', 'attendance') . ':'; - $row->cells[] = attendance_format_float($usersummary->maxpossiblepoints) . ' / ' . attendance_format_float($usersummary->allsessionsmaxpoints); + $row->cells[] = format_float($usersummary->maxpossiblepoints, 1, true, true) . ' / ' . + format_float($usersummary->allsessionsmaxpoints, 1, true, true); $stattable->data[] = $row; $row = new html_table_row(); $row->attributes['class'] = 'normal'; $row->cells[] = get_string('maxpossiblepercentage', 'attendance') . ':'; - $row->cells[] = attendance_format_float($usersummary->maxpossiblepercentage * 100, false) . '%'; + $row->cells[] = format_float($usersummary->maxpossiblepercentage * 100) . '%'; $stattable->data[] = $row; }