Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ceb6a6c6ef | ||
|
|
3eabeebf6b | ||
|
|
83e70dd02f |
@@ -14,6 +14,7 @@ Szkielet komponentu Joomla 6 do gromadzenia pytań testowych.
|
|||||||
- frontendowy widok testu na podstawie wybranego zestawu pytań,
|
- frontendowy widok testu na podstawie wybranego zestawu pytań,
|
||||||
- dwuetapowe rozpoczęcie testu z loginem użytkownika i możliwością przedłużenia czasu,
|
- dwuetapowe rozpoczęcie testu z loginem użytkownika i możliwością przedłużenia czasu,
|
||||||
- zegar odliczający czas testu i automatyczne zakończenie po jego upływie,
|
- zegar odliczający czas testu i automatyczne zakończenie po jego upływie,
|
||||||
|
- zapisywanie wyników testów i zaznaczonych odpowiedzi w bazie danych,
|
||||||
- pozycję menu „Arkusz egzaminacyjny” z opcjonalnym symbolem arkusza,
|
- pozycję menu „Arkusz egzaminacyjny” z opcjonalnym symbolem arkusza,
|
||||||
- listę wyboru dostępnych symboli arkuszy na stronie klienckiej,
|
- listę wyboru dostępnych symboli arkuszy na stronie klienckiej,
|
||||||
- możliwość rozwiązania arkusza i wyświetlenia wyniku oraz odpowiedzi poprawnych i zaznaczonych,
|
- możliwość rozwiązania arkusza i wyświetlenia wyniku oraz odpowiedzi poprawnych i zaznaczonych,
|
||||||
@@ -27,6 +28,6 @@ Szkielet komponentu Joomla 6 do gromadzenia pytań testowych.
|
|||||||
|
|
||||||
## Instalacja
|
## Instalacja
|
||||||
|
|
||||||
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.16.1).
|
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.17.0).
|
||||||
|
|
||||||
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
|
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
|
||||||
|
|||||||
@@ -73,3 +73,19 @@ CREATE TABLE IF NOT EXISTS `#__testquestions_set_questions` (
|
|||||||
PRIMARY KEY (`set_id`, `question_id`),
|
PRIMARY KEY (`set_id`, `question_id`),
|
||||||
KEY `idx_question_id` (`question_id`)
|
KEY `idx_question_id` (`question_id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `#__testquestions_results` (
|
||||||
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`set_id` int unsigned NOT NULL,
|
||||||
|
`participant_name` varchar(255) NOT NULL DEFAULT '',
|
||||||
|
`extra_time` smallint unsigned NOT NULL DEFAULT 0,
|
||||||
|
`correct_count` smallint unsigned NOT NULL DEFAULT 0,
|
||||||
|
`total_count` smallint unsigned NOT NULL DEFAULT 0,
|
||||||
|
`percentage` decimal(5,2) NOT NULL DEFAULT 0.00,
|
||||||
|
`answers` longtext NULL,
|
||||||
|
`created` datetime NOT NULL,
|
||||||
|
`created_by` int unsigned NOT NULL DEFAULT 0,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_set_id` (`set_id`),
|
||||||
|
KEY `idx_created` (`created`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
DROP TABLE IF EXISTS `#__testquestions_set_questions`;
|
DROP TABLE IF EXISTS `#__testquestions_set_questions`;
|
||||||
DROP TABLE IF EXISTS `#__testquestions_sets`;
|
DROP TABLE IF EXISTS `#__testquestions_sets`;
|
||||||
DROP TABLE IF EXISTS `#__testquestions_subjects`;
|
DROP TABLE IF EXISTS `#__testquestions_subjects`;
|
||||||
|
DROP TABLE IF EXISTS `#__testquestions_results`;
|
||||||
DROP TABLE IF EXISTS `#__testquestions_questions`;
|
DROP TABLE IF EXISTS `#__testquestions_questions`;
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
-- No database changes required for version 1.16.2.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
-- No database changes required for version 1.16.3.
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS `#__testquestions_results` (
|
||||||
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`set_id` int unsigned NOT NULL,
|
||||||
|
`participant_name` varchar(255) NOT NULL DEFAULT '',
|
||||||
|
`extra_time` smallint unsigned NOT NULL DEFAULT 0,
|
||||||
|
`correct_count` smallint unsigned NOT NULL DEFAULT 0,
|
||||||
|
`total_count` smallint unsigned NOT NULL DEFAULT 0,
|
||||||
|
`percentage` decimal(5,2) NOT NULL DEFAULT 0.00,
|
||||||
|
`answers` longtext NULL,
|
||||||
|
`created` datetime NOT NULL,
|
||||||
|
`created_by` int unsigned NOT NULL DEFAULT 0,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_set_id` (`set_id`),
|
||||||
|
KEY `idx_created` (`created`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<creationDate>2026-10-14</creationDate>
|
<creationDate>2026-10-14</creationDate>
|
||||||
<author>Komponent</author>
|
<author>Komponent</author>
|
||||||
<license>GNU General Public License version 2 or later</license>
|
<license>GNU General Public License version 2 or later</license>
|
||||||
<version>1.16.1</version>
|
<version>1.17.0</version>
|
||||||
<description>COM_TESTQUESTIONS_DESCRIPTION</description>
|
<description>COM_TESTQUESTIONS_DESCRIPTION</description>
|
||||||
<element>com_testquestions</element>
|
<element>com_testquestions</element>
|
||||||
<namespace path="src">Komponent\Component\Testquestions</namespace>
|
<namespace path="src">Komponent\Component\Testquestions</namespace>
|
||||||
|
|||||||
@@ -20,15 +20,14 @@
|
|||||||
|
|
||||||
.com-testquestions #test-timer-container {
|
.com-testquestions #test-timer-container {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
left: 1rem;
|
left: 2rem;
|
||||||
bottom: 1rem;
|
bottom: 2rem;
|
||||||
z-index: 1050;
|
z-index: 1050;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 4px;
|
padding: 0;
|
||||||
background: #fff;
|
background: transparent;
|
||||||
border: 1px solid #dfe3e7;
|
border: 0;
|
||||||
border-radius: .25rem;
|
box-shadow: none;
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.com-testquestions .timer-text {
|
.com-testquestions .timer-text {
|
||||||
|
|||||||
@@ -70,4 +70,29 @@ class SetModel extends BaseDatabaseModel
|
|||||||
->order('sub.title ASC, s.title ASC')
|
->order('sub.title ASC, s.title ASC')
|
||||||
)->loadObjectList();
|
)->loadObjectList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function saveResult(string $participantName, int $extraTime, array $result): bool
|
||||||
|
{
|
||||||
|
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||||
|
$setId = $this->getSetId();
|
||||||
|
$user = Factory::getApplication()->getIdentity();
|
||||||
|
|
||||||
|
if ($setId < 1 || trim($participantName) === '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = (object) [
|
||||||
|
'set_id' => $setId,
|
||||||
|
'participant_name' => trim($participantName),
|
||||||
|
'extra_time' => max(0, $extraTime),
|
||||||
|
'correct_count' => (int) ($result['correct'] ?? 0),
|
||||||
|
'total_count' => (int) ($result['total'] ?? 0),
|
||||||
|
'percentage' => (float) ($result['percentage'] ?? 0),
|
||||||
|
'answers' => json_encode($result['items'] ?? [], JSON_UNESCAPED_UNICODE),
|
||||||
|
'created' => Factory::getDate()->toSql(),
|
||||||
|
'created_by' => $user ? (int) $user->id : 0,
|
||||||
|
];
|
||||||
|
|
||||||
|
return (bool) $db->insertObject('#__testquestions_results', $row);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,14 @@ class HtmlView extends BaseHtmlView
|
|||||||
&& $input->post->getInt('set_id', 0) > 0;
|
&& $input->post->getInt('set_id', 0) > 0;
|
||||||
$this->results = $this->buildResults($this->items);
|
$this->results = $this->buildResults($this->items);
|
||||||
|
|
||||||
|
if ($this->results) {
|
||||||
|
$this->getModel()->saveResult(
|
||||||
|
$input->post->getString('participant_name', ''),
|
||||||
|
$input->post->getInt('extra_time', 0),
|
||||||
|
$this->results
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return parent::display($tpl);
|
return parent::display($tpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,8 +127,10 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
const update = function () {
|
const update = function () {
|
||||||
const minutes = Math.floor(remaining / 60);
|
const minutes = Math.floor(remaining / 60);
|
||||||
const seconds = remaining % 60;
|
const seconds = remaining % 60;
|
||||||
|
const ratio = remaining / total;
|
||||||
text.textContent = String(minutes).padStart(2, '0') + ':' + String(seconds).padStart(2, '0');
|
text.textContent = String(minutes).padStart(2, '0') + ':' + String(seconds).padStart(2, '0');
|
||||||
ring.style.strokeDashoffset = circumference * (1 - remaining / total);
|
ring.style.strokeDashoffset = circumference * (1 - remaining / total);
|
||||||
|
ring.style.stroke = ratio <= 0.1 ? '#dc3545' : (ratio <= 0.2 ? '#fd7e14' : '#4a86cf');
|
||||||
|
|
||||||
if (remaining <= 0 && !submitted) {
|
if (remaining <= 0 && !submitted) {
|
||||||
submitted = true;
|
submitted = true;
|
||||||
|
|||||||
+6
-7
@@ -156,15 +156,14 @@ div.odpup
|
|||||||
|
|
||||||
.com-testquestions #test-timer-container {
|
.com-testquestions #test-timer-container {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
left: 1rem;
|
left: 2rem;
|
||||||
bottom: 1rem;
|
bottom: 2rem;
|
||||||
z-index: 1050;
|
z-index: 1050;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 4px;
|
padding: 0;
|
||||||
background: #fff;
|
background: transparent;
|
||||||
border: 1px solid #dfe3e7;
|
border: 0;
|
||||||
border-radius: .25rem;
|
box-shadow: none;
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.com-testquestions .question-number {
|
.com-testquestions .question-number {
|
||||||
|
|||||||
Reference in New Issue
Block a user