Skip to content

Commit

Permalink
Version 6.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bihor committed Nov 28, 2024
1 parent c8ccb3c commit 4fb5b71
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 69 deletions.
29 changes: 18 additions & 11 deletions Classes/Controller/QuizController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\CMS\Core\View\ViewFactoryData;
use TYPO3\CMS\Core\View\ViewFactoryInterface;
use TYPO3\CMS\Core\Mail\MailMessage;
use Symfony\Component\Mime\Address;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -96,7 +97,8 @@ class QuizController extends ActionController
*/
protected $persistenceManager;

public function __construct(protected readonly ModuleTemplateFactory $moduleTemplateFactory, private readonly LoggerInterface $logger)
public function __construct(
protected readonly ModuleTemplateFactory $moduleTemplateFactory, private readonly LoggerInterface $logger, private ViewFactoryInterface $viewFactory)
{
}

Expand Down Expand Up @@ -1069,6 +1071,7 @@ public function doAll(Quiz $quiz, array $userData, int $pages, array $randomNumb
'homepage' => $this->participant->getHomepage(),
'participant' => $this->participant,
'finalContent' => $finalContent,
'qtype' => $quiz->getQtype(),
'settings' => $this->settings
];
if ($this->settings['email']['sendToAdmin'] && ($this->settings['email']['adminEmail'] || $specialRecievers !== [])) {
Expand Down Expand Up @@ -2244,16 +2247,20 @@ protected function sendTemplateEmail(array $recipient, array $sender, $subject,
$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK
);
$requestLanguage = $this->request->getAttribute('language');
$requestLocale = $requestLanguage->getLocale();
$variables['language_code'] = $requestLocale->getLanguageCode();

$viewFactoryData = new ViewFactoryData(
templateRootPaths: $extbaseFrameworkConfiguration['view']['templateRootPaths'],
partialRootPaths: $extbaseFrameworkConfiguration['view']['partialRootPaths'],
layoutRootPaths: $extbaseFrameworkConfiguration['view']['layoutRootPaths'],
request: $this->request,
);
$view = $this->viewFactory->create($viewFactoryData);
$view->assignMultiple($variables);
$emailBodyHtml = $view->render('Email/' . $templateName . '.html');

$emailViewHtml = GeneralUtility::makeInstance(StandaloneView::class);
$emailViewHtml->setTemplateRootPaths($extbaseFrameworkConfiguration['view']['templateRootPaths']);
$emailViewHtml->setLayoutRootPaths($extbaseFrameworkConfiguration['view']['layoutRootPaths']);
$emailViewHtml->setPartialRootPaths($extbaseFrameworkConfiguration['view']['partialRootPaths']);
$emailViewHtml->setTemplate('Email/' . $templateName . '.html');
$emailViewHtml->setFormat('html');
$emailViewHtml->assignMultiple($variables);

$emailBodyHtml = $emailViewHtml->render();
if ($this->withDebug()) {
echo "###" . $emailBodyHtml . '###';
return true;
Expand Down
7 changes: 6 additions & 1 deletion Documentation/ChangeLog/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,9 @@ ChangeLog
6.0.0:
First version for TYPO3 13, but emails are not working with TYPO3 13!

Upgrade Wizards for old file references and Switchable-Controller-Action-Plugins removed!
Upgrade Wizards for old file references and Switchable-Controller-Action-Plugins removed!

6.1.0:
Support for TYPO3 12 dropped!

The emails are now localized too.
48 changes: 9 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# fp_masterquiz

version 6.0.0
version 6.1.0

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 All @@ -20,43 +20,13 @@ Available languages: english and german/deutsch.

You find the documentation at typo3.org: https://docs.typo3.org/p/fixpunkt/fp-masterquiz/master/en-us/

Changes in version 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.
- settings.user.checkFEuser allows now values greater than 1.
- Bugfix for pointsMode 4.

Changes in version 5.0.3:
- Bugfix: prevent multiple ajax calls.
- Bugfix: Matrix-Display.

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.4:
- More support for group by tags.
- More support for matrix-questions.

Changes in version 5.1.6:
- Bugfix: backend preview.
- Remove of deprecated methods and sql-fields.

Changes in 5.1.7:
- Bugfix: sorting-error of selected-table.

Changes in 5.1.8:
- Bugfix: translations in Ajax-mode.

Changes in 5.1.9:
- Bugfix: points calculation for modes 3 and 4.

Changes in 5.1.11:
- Bugfix: allow backend-module for users.

Changes in 5.2.0:
- Refactoring with the rector-project.
- Preparations for TYPO3 13. Attention: the path to the backend templates is now defined in Configuration/page.tsconfig.

Changes in 6.0.0:
- First version for TYPO3 13, but emails are not working with TYPO3 13!
- Upgrade Wizards for old file references and Switchable-Controller-Action-Plugins removed!
- Upgrade Wizards for old file references and Switchable-Controller-Action-Plugins removed!

Changes in 6.1.0:
- Support for TYPO3 12 dropped!
- The emails are now localized too.

You find the whole changelog here:
https://raw.githubusercontent.com/bihor/fp_masterquiz/refs/heads/master/Documentation/ChangeLog/Index.rst
25 changes: 25 additions & 0 deletions Resources/Private/Language/de.locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,31 @@
<source>Clicked by you</source>
<target>Von dir angeklickt</target>
</trans-unit>
<trans-unit id="qtype.0" resname="qtype.0">
<target>Quiz</target>
</trans-unit>
<trans-unit id="qtype.1" resname="qtype.1">
<target>Umfrage</target>
</trans-unit>
<trans-unit id="qtype.2" resname="qtype.2">
<target>Psychotest</target>
</trans-unit>
<trans-unit id="email.hello" resname="email.hello">
<source>Hello</source>
<target>Hallo</target>
</trans-unit>
<trans-unit id="email.intro_user1" resname="email.intro_user1">
<target>hier ist dein</target>
</trans-unit>
<trans-unit id="email.intro1" resname="email.intro1">
<target>es gibt ein neues</target>
</trans-unit>
<trans-unit id="email.intro2" resname="email.intro2">
<target>-Ergebnis:</target>
</trans-unit>
<trans-unit id="email.points" resname="email.points">
<target>Erhaltene Punkte:</target>
</trans-unit>
</body>
</file>
</xliff>
24 changes: 24 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,30 @@
<trans-unit id="text.categoryCount" resname="text.categoryCount">
<source>Clicked by you</source>
</trans-unit>
<trans-unit id="qtype.0" resname="qtype.0">
<source>Quiz</source>
</trans-unit>
<trans-unit id="qtype.1" resname="qtype.1">
<source>Poll</source>
</trans-unit>
<trans-unit id="qtype.2" resname="qtype.2">
<source>Test</source>
</trans-unit>
<trans-unit id="email.hello" resname="email.hello">
<source>Hello</source>
</trans-unit>
<trans-unit id="email.intro_user1" resname="email.intro_user1">
<source>here is your</source>
</trans-unit>
<trans-unit id="email.intro1" resname="email.intro1">
<source>there is a new</source>
</trans-unit>
<trans-unit id="email.intro2" resname="email.intro2">
<source>-result:</source>
</trans-unit>
<trans-unit id="email.points" resname="email.points">
<source>Total points:</source>
</trans-unit>
</body>
</file>
</xliff>
17 changes: 13 additions & 4 deletions Resources/Private/Templates/Email/ToAdmin.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@
<html>
<head>
<meta charset="UTF-8">
<title>Quiz-Result</title>
<title>fp_masterquiz</title>
</head>
<body>
<h3>Hello Admin,</h3>
<p>a new quiz-result is here from:</p>
<h3><f:translate key="email.hello" extensionName="FpMasterquiz" languageKey="{language_code}" /> Admin,</h3>
<p><f:translate key="email.intro1" extensionName="FpMasterquiz" languageKey="{language_code}" />
<f:switch expression="{qtype}">
<f:case value="1"><f:translate key="qtype.1" extensionName="FpMasterquiz" languageKey="{language_code}" /></f:case>
<f:case value="2"><f:translate key="qtype.2" extensionName="FpMasterquiz" languageKey="{language_code}" /></f:case>
<f:defaultCase><f:translate key="qtype.0" extensionName="FpMasterquiz" languageKey="{language_code}" /></f:defaultCase>
</f:switch><f:translate key="email.intro2" extensionName="FpMasterquiz" languageKey="{language_code}" /></p>
<p>Name: {name}</p>
<p>E-Mail: <a href="mailto:{email}">{email}</a></p>
<p>Homepage: <a href="{homepage}">{homepage}</a></p>

<f:if condition="{settings.showPoints}"><f:if condition="{participant.maximum2} > 0">
<p>Total points: {participant.points}/{participant.maximum2} (<f:format.number decimals="2" decimalSeparator="," thousandsSeparator=".">{participant.percent2}</f:format.number>%).</p>
<p>
<f:translate key="email.points" extensionName="FpMasterquiz" languageKey="{language_code}" />
{participant.points}/{participant.maximum2}
(<f:format.number decimals="2" decimalSeparator="," thousandsSeparator=".">{participant.percent2}</f:format.number>%).
</p>
<br/>
</f:if></f:if>
<f:format.raw>{finalContent}</f:format.raw>
Expand Down
13 changes: 10 additions & 3 deletions Resources/Private/Templates/Email/ToUser.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
<title>Quiz-Result</title>
</head>
<body>
<h3>Hello {name},</h3>
<p>here is your quiz-result:</p>
<h3><f:translate key="email.hello" extensionName="FpMasterquiz" languageKey="{language_code}" /> {name},</h3>
<p><f:translate key="email.intro_user1" extensionName="FpMasterquiz" languageKey="{language_code}" />
<f:switch expression="{qtype}">
<f:case value="1"><f:translate key="qtype.1" extensionName="FpMasterquiz" languageKey="{language_code}" /></f:case>
<f:case value="2"><f:translate key="qtype.2" extensionName="FpMasterquiz" languageKey="{language_code}" /></f:case>
<f:defaultCase><f:translate key="qtype.0" extensionName="FpMasterquiz" languageKey="{language_code}" /></f:defaultCase>
</f:switch><f:translate key="email.intro2" extensionName="FpMasterquiz" languageKey="{language_code}" /></p>

<f:if condition="{settings.showPoints}"><f:if condition="{participant.maximum2} > 0">
<p>Your total points: {participant.points}/{participant.maximum2} (<f:format.number decimals="2" decimalSeparator="," thousandsSeparator=".">{participant.percent2}</f:format.number>%).</p>
<p><f:translate key="email.points" extensionName="FpMasterquiz" languageKey="{language_code}" />
{participant.points}/{participant.maximum2}
(<f:format.number decimals="2" decimalSeparator="," thousandsSeparator=".">{participant.percent2}</f:format.number>%).</p>
<br/>
</f:if></f:if>
<f:format.raw>{finalContent}</f:format.raw>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
],
"require" : {
"typo3/cms-core" : "~12.4.0 || ~13.4.0"
"typo3/cms-core" : "~13.4.0"
},
"suggest": {
"typo3/cms-dashboard": "Use widgets in dashboard"
Expand Down
4 changes: 2 additions & 2 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
'category' => 'plugin',
'author' => 'Kurt Gusbeth',
'state' => 'stable',
'version' => '6.0.0',
'version' => '6.1.0',
'constraints' => [
'depends' => [
'typo3' => '12.4.0-13.4.99',
'typo3' => '13.4.0-13.4.99',
],
'conflicts' => [],
'suggests' => [],
Expand Down
8 changes: 0 additions & 8 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;

defined('TYPO3') || die();
Expand Down Expand Up @@ -81,12 +79,6 @@ function()
]
);

// wizards
if ((new Typo3Version())->getMajorVersion() < 13) {
// @extensionScannerIgnoreLine
ExtensionManagementUtility::addPageTSConfig('@import \'EXT:fp_masterquiz/Configuration/TSconfig/ContentElementWizard.tsconfig\'');
}

// register statistics tables for garbage collection
// see https://docs.typo3.org/c/typo3/cms-scheduler/main/en-us/Installation/BaseTasks/Index.html#table-garbage-collection-task-example
if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('scheduler')) {
Expand Down

0 comments on commit 4fb5b71

Please sign in to comment.