Skip to content

Commit

Permalink
Version 5.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bihor committed Apr 17, 2024
1 parent dfc97ba commit fe2eb0d
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 24 deletions.
37 changes: 29 additions & 8 deletions Classes/Controller/QuizController.php
Expand Up @@ -1507,15 +1507,21 @@ public function showAction(Quiz $quiz = null): ResponseInterface
// in diesem Fall brauchen wir das letzte und nächste Tag
$lastItem = null;
$lastTag = '';
foreach ($quizPaginator->getPaginatedItems() as $itemQuestion) {
if ($lastItem) {
$lastItem->setNextTag($itemQuestion->getTag()->getName());
}
if (($lastTag)) {
$itemQuestion->setPrevTag($lastTag);
if ($data['final']) {
// next und prev werden hier gesetzt: getSortedSelections()
} else {
foreach ($quizPaginator->getPaginatedItems() as $itemQuestion) {
if ($itemQuestion->getTag()) {
if ($lastItem) {
$lastItem->setNextTag($itemQuestion->getTag()->getName());
}
if (($lastTag)) {
$itemQuestion->setPrevTag($lastTag);
}
$lastTag = $itemQuestion->getTag()->getName();
$lastItem = $itemQuestion;
}
}
$lastTag = $itemQuestion->getTag()->getName();
$lastItem = $itemQuestion;
}
}

Expand Down Expand Up @@ -1867,6 +1873,21 @@ public function resultAction(Quiz $quiz = null): ResponseInterface
$userPid = $pid;
}
}
if ($this->settings['groupByTag']) {
// in diesem Fall brauchen wir das letzte und nächste Tag
$lastItem = null;
$lastTag = '';
foreach ($quiz->getQuestions() as $itemQuestion) {
if ($lastItem) {
$lastItem->setNextTag($itemQuestion->getTag()->getName());
}
if (($lastTag)) {
$itemQuestion->setPrevTag($lastTag);
}
$lastTag = $itemQuestion->getTag()->getName();
$lastItem = $itemQuestion;
}
}
$this->view->assign('quiz', $quiz);
$this->view->assign('participants', $this->participantRepository->findFromPidAndQuiz($userPid, $quiz->getUid(), $this->settings['resultLimit']));
$this->view->assign('debug', $debug);
Expand Down
24 changes: 21 additions & 3 deletions Classes/Domain/Model/Participant.php
Expand Up @@ -706,22 +706,40 @@ public function getSelectionsByTag($tag)

/**
* Returns the sorted selections
*
* @return array sortedSelections
*/
public function getSortedSelections()
public function getSortedSelections(): array
{
$sortedSelections = [];
$i = 0;
$hasTags = false;
foreach ($this->selections as $selection) {
$sorting = $selection->getSorting();
if ($sorting == 0) {
$sorting = $i;
}
if ($selection->getQuestion()->getTag()) {
$hasTags = true;
}
$sortedSelections[$sorting] = $selection;
$i++;
}
ksort($sortedSelections);
if ($hasTags) {
// prev und next Tag immer setzen, wenn Tags vorhanden sind
$lastItem = null;
$lastTag = '';
foreach ($sortedSelections as $selection) {
$itemQuestion = $selection->getQuestion();
if ($lastItem) {
$lastItem->setNextTag($itemQuestion->getTag()->getName());
}
if (($lastTag)) {
$itemQuestion->setPrevTag($lastTag);
}
$lastTag = $itemQuestion->getTag()->getName();
$lastItem = $itemQuestion;
}
}
return $sortedSelections;
}

Expand Down
11 changes: 7 additions & 4 deletions Documentation/ChangeLog/Index.rst
Expand Up @@ -200,12 +200,12 @@ ChangeLog

Bugfix for: prevent PHP and JavaScript errors from missing settings.

4.3.0:
4.3:
Setting redirectToResultPageAtFinal added: redirect to the result page when the final page is reached?

Setting pointsMode added: 0 points if not all answers are correct now possible.

5.0.0:
5.0:
Refactoring with the rector-tool.

settings.debug=2 is new. If 2 instead of 1, the debug output will be written into a log file.
Expand All @@ -219,5 +219,8 @@ ChangeLog

Bugfix: Matrix-Display.

5.1.0:
More layout possibilities: group a normal quiz/poll by tags; show answers inline (span instead of div).
5.1:
More layout possibilities: group a normal quiz/poll by tags; show answers inline (span instead of div).

5.1.1:
Bugfix for group by tags.
4 changes: 4 additions & 0 deletions Documentation/Configuration/PageTSconfig/Index.rst
Expand Up @@ -54,6 +54,10 @@ Here an example for a template (extract) with 2 layouts:
</f:else>
</f:if>

Note: by default, the template will load JavaScript from cdn.jsdelivr.net, if you use templateLayout 1.
Then the results will be displayed as a chart. Apexcharts will be used then. Here you find more informations about Apexcharts:
https://apexcharts.com/

- Furthermore you can use TSconfig to rename or hide quiz-fields in the BE. Here two examples:

::
Expand Down
9 changes: 6 additions & 3 deletions README.md
@@ -1,6 +1,6 @@
# fp_masterquiz

version 5.1.0
version 5.1.1

TYPO3 extension to create a quiz, poll or test. The participant result will be saved in the DB too and can be deleted automatically via Scheduler.

Expand Down Expand Up @@ -51,5 +51,8 @@ Changes in version 5.0.3:
- Bugfix: prevent multiple ajax calls.
- Bugfix: Matrix-Display.

Changes in version 5.1.0:
- More layout possibilities: group a normal quiz/poll by tags; show answers inline (span instead of div).
Changes in version 5.1:
- More layout possibilities: group a normal quiz/poll by tags; show answers inline (span instead of div).

Changes in version 5.1.1:
- Bugfix for group by tags.
16 changes: 14 additions & 2 deletions Resources/Private/Partials/Question/PropertiesSent.html
@@ -1,7 +1,13 @@
<html xmlns:f="https://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:variable name="enablePoints">{selection.maximumPoints}</f:variable>
<f:variable name="maxPoints">{f:if(condition: '{settings.pointsMode} == 4', then: '1', else: '{selection.maximumPoints}')}</f:variable>
<div class="card"><div class="card-body">
<f:if condition="{settings.groupByTag}"><f:then>
<f:if condition="{selection.question.tag.name} != {selection.question.prevTag}">
<div class="card"><div class="card-header">{selection.question.tag.name}</div><div class="card-body">
</f:if>
</f:then><f:else>
<div class="card"><div class="card-body">
</f:else></f:if>
<f:if condition="({settings.showPageNo} == 1) && ({settings.ajax} == 1) && ({pages} != 1) && ({final} == 0)">
<p class="quiz-progress">{f:translate(key: "text.page")} <span>{page}</span> {f:translate(key: "text.of")} {pages} ({pagePercent}%)</p>
</f:if>
Expand Down Expand Up @@ -147,6 +153,12 @@
<p>{f:translate(key: "text.explanation", default: 'Explanation: ')}</p>
<f:format.html>{selection.question.explanation}</f:format.html>
</f:if>
</div></div>
<f:if condition="{settings.groupByTag}"><f:then>
<f:if condition="{selection.question.tag.name} != {selection.question.nextTag}">
</div></div>
</f:if>
</f:then><f:else>
</div></div>
</f:else></f:if>
<br />
</html>
17 changes: 15 additions & 2 deletions Resources/Private/Templates/Quiz/Result.html
Expand Up @@ -21,6 +21,7 @@
<f:for each="{quiz.questions}" as="question" iteration="pageiterator">
<f:if condition="{settings.templateLayout} == 2">
<f:then>
<f:comment>Detailed results</f:comment>
<div>{settings.template.wrapQuestionTitle1 -> f:format.raw()}{question.title}{settings.template.wrapQuestionTitle2 -> f:format.raw()}</div>
<div>{settings.template.wrapQuestionDesc1 -> f:format.raw()}<f:format.html>{question.bodytext}</f:format.html>{settings.template.wrapQuestionDesc2 -> f:format.raw()}</div>
<table class="table quiz-table">
Expand Down Expand Up @@ -66,7 +67,13 @@
</table>
</f:then>
<f:else>
<div class="card"><div class="card-body">
<f:if condition="{settings.groupByTag}"><f:then>
<f:if condition="{question.tag.name} != {question.prevTag}">
<div class="card"><div class="card-header">{question.tag.name}</div><div class="card-body">
</f:if>
</f:then><f:else>
<div class="card"><div class="card-body">
</f:else></f:if>
{settings.template.wrapQuestionTitle1 -> f:format.raw()}{question.title}{settings.template.wrapQuestionTitle2 -> f:format.raw()}
<div class="row">
<div class="{f:if(condition: '{question.image.uid}', then: settings.template.colText, else: settings.template.col12)}">
Expand Down Expand Up @@ -103,7 +110,13 @@
<p>{f:translate(key: "text.explanation", default: 'Explanation: ')}</p>
<f:format.html>{question.explanation}</f:format.html>
</f:if>
</div></div>
<f:if condition="{settings.groupByTag}"><f:then>
<f:if condition="{question.tag.name} != {question.nextTag}">
</div></div>
</f:if>
</f:then><f:else>
</div></div>
</f:else></f:if>
</f:else>
</f:if>
<br/>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
@@ -1,7 +1,7 @@
{
"name" : "fixpunkt/fp-masterquiz",
"type" : "typo3-cms-extension",
"description" : "A modern extension that offers quiz, polls and tests. The result can be displayed as a chart. Supports 7 question modes.",
"description" : "A modern extension that offers quiz, polls and tests. The result can be displayed as a chart.",
"authors" : [{
"name" : "Kurt Gusbeth",
"role" : "Developer"
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Expand Up @@ -16,7 +16,7 @@
'category' => 'plugin',
'author' => 'Kurt Gusbeth',
'state' => 'stable',
'version' => '5.1.0',
'version' => '5.1.1',
'constraints' => [
'depends' => [
'typo3' => '12.4.0-12.4.99',
Expand Down

0 comments on commit fe2eb0d

Please sign in to comment.