apmuthu / LimeSurvey

The official LimeSurvey repository
http://www.limesurvey.org
0 stars 0 forks source link

{PERC} shows {TOTAL} #19

Open apmuthu opened 7 years ago

apmuthu commented 7 years ago

When setting Assessment Rules, the use of {PERC} just shows the total correct answers.

apmuthu commented 1 year ago

Make the following changes to application/helpers/frontend_helper.php:

--- application/helpers/frontend_helper.php Fri Aug 12 10:20:31 2016
+++ application/helpers/frontend_helper.php Thu Jul 27 19:56:11 2023
@@ -1796,7 +1796,7 @@
                             </th>
                             </tr>
                             <tr>
-                            <td>".str_replace(array("{PERC}", "{TOTAL}"), array($val, $total), $assessed['message'])."
+                            <td>".str_replace(array("{PERC}", "{TOTAL}"), array(round(100*$val/$assessed['max'],2), $total), $assessed['message'])."
                             </td>
                             </tr>
                             </table><br />\n";
@@ -1819,7 +1819,7 @@
                     </th>
                     </tr>
                     <tr>
-                    <td>".str_replace(array("{PERC}", "{TOTAL}"), array($val, $total), stripslashes($assessed['message']))."
+                    <td>".str_replace(array("{PERC}", "{TOTAL}"), array(round(100*$val/$assessed['max'],2), $total), stripslashes($assessed['message']))."
                     </td>
                     </tr>
                     </table>\n";

LS205_PERC_mod_frontend_helper.php.zip