From 5721370ea16218a1578838780cb510842ed579f7 Mon Sep 17 00:00:00 2001 From: Wojtek Date: Thu, 15 Oct 2026 21:15:00 +0200 Subject: [PATCH] Include correction points in final score --- README.md | 2 +- .../com_testquestions/sql/updates/mysql/1.22.0.sql | 1 + .../components/com_testquestions/src/Model/ResultModel.php | 6 +++--- .../components/com_testquestions/tmpl/result/default.php | 2 ++ com_testquestions.xml | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 administrator/components/com_testquestions/sql/updates/mysql/1.22.0.sql diff --git a/README.md b/README.md index dd6f8c5..ffbfcc6 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,6 @@ Szkielet komponentu Joomla 6 do gromadzenia pytań testowych. ## Instalacja -W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.21.0). +W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.22.0). Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**. diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.22.0.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.22.0.sql new file mode 100644 index 0000000..5131c21 --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.22.0.sql @@ -0,0 +1 @@ +-- Corrected points are calculated as automatic points plus manually awarded correction points. diff --git a/administrator/components/com_testquestions/src/Model/ResultModel.php b/administrator/components/com_testquestions/src/Model/ResultModel.php index f3bd044..45c5622 100644 --- a/administrator/components/com_testquestions/src/Model/ResultModel.php +++ b/administrator/components/com_testquestions/src/Model/ResultModel.php @@ -57,16 +57,16 @@ class ResultModel extends BaseDatabaseModel } unset($answer); - $pointsAfter = 0; + $correctionPoints = 0; foreach ($item->answers as $answer) { - $pointsAfter += (int) ($answer['awarded_points'] ?? 0); + $correctionPoints += (int) ($answer['awarded_points'] ?? 0); } $db = Factory::getContainer()->get('DatabaseDriver'); $row = (object) [ 'id' => $id, 'answers' => json_encode($item->answers, JSON_UNESCAPED_UNICODE), - 'points_after' => $pointsAfter, + 'points_after' => (int) $item->points_before + $correctionPoints, ]; return (bool) $db->updateObject('#__testquestions_results', $row, 'id'); diff --git a/administrator/components/com_testquestions/tmpl/result/default.php b/administrator/components/com_testquestions/tmpl/result/default.php index 269ffe5..999a577 100644 --- a/administrator/components/com_testquestions/tmpl/result/default.php +++ b/administrator/components/com_testquestions/tmpl/result/default.php @@ -11,6 +11,8 @@
escape(($this->item->subject_title ? $this->item->subject_title . ' — ' : '') . $this->item->set_title); ?>
item->correct_count; ?> / item->total_count; ?> (item->percentage, ENT_QUOTES, 'UTF-8'); ?>%)
+
+
item->points_before; ?> / item->points_after; ?>
item->execution_time / 60); ?>:item->execution_time % 60), 2, '0', STR_PAD_LEFT); ?>
diff --git a/com_testquestions.xml b/com_testquestions.xml index 7ad7d3a..2dbae89 100644 --- a/com_testquestions.xml +++ b/com_testquestions.xml @@ -4,7 +4,7 @@ 2026-10-14 Komponent GNU General Public License version 2 or later - 1.21.0 + 1.22.0 COM_TESTQUESTIONS_DESCRIPTION com_testquestions Komponent\Component\Testquestions