From f9090dff7c6d25a0e6e8ac7d4940e415b40c0694 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Fri, 18 Mar 2016 16:13:29 +0800 Subject: [PATCH] MDL-53539 tool_lp: Fix percentage displays for template statistics --- .../external/template_statistics_exporter.php | 28 +++++++++++++++---- .../lp/templates/template_statistics.mustache | 8 +++--- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/admin/tool/lp/classes/external/template_statistics_exporter.php b/admin/tool/lp/classes/external/template_statistics_exporter.php index 43774941835..8b005ff86e0 100644 --- a/admin/tool/lp/classes/external/template_statistics_exporter.php +++ b/admin/tool/lp/classes/external/template_statistics_exporter.php @@ -63,15 +63,24 @@ class template_statistics_exporter extends exporter { 'linkedcompetencypercentage' => array( 'type' => PARAM_FLOAT ), + 'linkedcompetencypercentageformatted' => array( + 'type' => PARAM_RAW + ), 'linkedcompetencycount' => array( 'type' => PARAM_INT ), 'completedplanpercentage' => array( 'type' => PARAM_FLOAT ), + 'completedplanpercentageformatted' => array( + 'type' => PARAM_RAW + ), 'proficientusercompetencyplanpercentage' => array( 'type' => PARAM_FLOAT ), + 'proficientusercompetencyplanpercentageformatted' => array( + 'type' => PARAM_RAW + ), 'leastproficient' => array( 'type' => competency_exporter::read_properties_definition(), 'multiple' => true @@ -89,19 +98,23 @@ class template_statistics_exporter extends exporter { $linkedcompetencycount = 0; } $linkedcompetencypercentage = 0; + $linkedcompetencypercentageformatted = ''; if ($this->data->competencycount > 0) { - $linkedcompetencypercentage = format_float( - ((float) $linkedcompetencycount / (float) $this->data->competencycount) * 100.0); + $linkedcompetencypercentage = ((float) $linkedcompetencycount / (float) $this->data->competencycount) * 100.0; + $linkedcompetencypercentageformatted = format_float($linkedcompetencypercentage); } $completedplanpercentage = 0; + $completedplanpercentageformatted = ''; if ($this->data->plancount > 0) { - $completedplanpercentage = format_float( - ((float) $this->data->completedplancount / (float) $this->data->plancount) * 100.0); + $completedplanpercentage = ((float) $this->data->completedplancount / (float) $this->data->plancount) * 100.0; + $completedplanpercentageformatted = format_float($completedplanpercentage); } $proficientusercompetencyplanpercentage = 0; + $proficientusercompetencyplanpercentageformatted = ''; if ($this->data->usercompetencyplancount > 0) { - $proficientusercompetencyplanpercentage = format_float( - ((float) $this->data->proficientusercompetencyplancount / (float) $this->data->usercompetencyplancount) * 100.0); + $proficientusercompetencyplanpercentage = ((float) $this->data->proficientusercompetencyplancount / + (float) $this->data->usercompetencyplancount) * 100.0; + $proficientusercompetencyplanpercentageformatted = format_float($proficientusercompetencyplanpercentage); } $competencies = array(); $contextcache = array(); @@ -116,8 +129,11 @@ class template_statistics_exporter extends exporter { return array( 'linkedcompetencycount' => $linkedcompetencycount, 'linkedcompetencypercentage' => $linkedcompetencypercentage, + 'linkedcompetencypercentageformatted' => $linkedcompetencypercentageformatted, 'completedplanpercentage' => $completedplanpercentage, + 'completedplanpercentageformatted' => $completedplanpercentageformatted, 'proficientusercompetencyplanpercentage' => $proficientusercompetencyplanpercentage, + 'proficientusercompetencyplanpercentageformatted' => $proficientusercompetencyplanpercentageformatted, 'leastproficient' => $competencies, 'leastproficientcount' => count($competencies) ); diff --git a/admin/tool/lp/templates/template_statistics.mustache b/admin/tool/lp/templates/template_statistics.mustache index edef1c4f1a7..b8acd95919d 100644 --- a/admin/tool/lp/templates/template_statistics.mustache +++ b/admin/tool/lp/templates/template_statistics.mustache @@ -52,7 +52,7 @@
- {{linkedcompetencypercentage}} % + {{linkedcompetencypercentageformatted}} %
@@ -63,7 +63,7 @@
- {{completedplanpercentage}} % + {{completedplanpercentageformatted}} %
@@ -71,11 +71,11 @@ {{#usercompetencyplancount}}
- {{#str}}averageproficiencyrate, tool_lp, {{proficientusercompetencyplanpercentage}} {{/str}} + {{#str}}averageproficiencyrate, tool_lp, {{proficientusercompetencyplanpercentageformatted}} {{/str}}
- {{proficientusercompetencyplanpercentage}} % + {{proficientusercompetencyplanpercentageformatted}} %