Skip to content

Commit

Permalink
Version 4.0.0 beta 10
Browse files Browse the repository at this point in the history
  • Loading branch information
bihor committed Jun 30, 2023
1 parent 29ec14c commit 204d482
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 109 deletions.
107 changes: 58 additions & 49 deletions Classes/Controller/QuizController.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ public function doAll(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz, array $use
$finalImageuid = 0; // image for the final page
$finalContent = ''; // special content for the final page
$finalCategoryArray = []; // Auswertung der angeklickten Kategorien
$redirectTo = ''; // redirect to uri (after evaluation)
$emailAnswers = []; // special admin email to answer relations
$specialRecievers = []; // special admin email recievers
$debug = $userData['debug']; // debug output
Expand Down Expand Up @@ -845,11 +846,9 @@ public function doAll(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz, array $use
// Punkte-Match
if ($evaluation->getPage() > 0) {
// Weiterleitung zu dieser Seite
$this->redirectToURI(
$this->uriBuilder->reset()
$redirectTo = $this->uriBuilder->reset()
->setTargetPageUid($evaluation->getPage())
->build()
);
->build();
} else if ($evaluation->getCe() > 0) {
// Content-Element ausgeben
$ttContentConfig = [
Expand Down Expand Up @@ -1015,6 +1014,7 @@ public function doAll(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz, array $use
'useJoker' => $useJoker,
'mandatoryNotAnswered' => $mandatoryNotAnswered,
'session' => $session,
'redirectTo' => $redirectTo,
'debug' => $debug
];
}
Expand Down Expand Up @@ -1419,26 +1419,29 @@ public function showAction(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz = null
return $this->htmlResponse();
}
if ($this->checkForClosure()) {
$this->redirectToURI(
$this->uriBuilder->reset()
->setTargetPageUid($this->settings['closurePageUid'])
->uriFor(
'closure',
[
'participant' => $this->participant,
'session' => $this->participant->getSession()
],
'Quiz',
null,
'closure'
)
->build()
);
$uri = $this->uriBuilder->reset()
->setTargetPageUid($this->settings['closurePageUid'])
->uriFor(
'closure',
[
'participant' => $this->participant,
'session' => $this->participant->getSession()
],
'Quiz',
null,
'closure'
);
return $this->responseFactory->createResponse(307)
->withHeader('Location', $uri);
}
// participant wird zuerst hier definiert ...
$userData = $this->findParticipant($quiz->getUid(), $quiz->getPid());
/// ... und dann hier in der DB abgespeichert
$data = $this->doAll($quiz, $userData, 0, []);
if ($data['redirectTo']) {
return $this->responseFactory->createResponse(307)
->withHeader('Location', $data['redirectTo']);
}
$page = $data['page'];
$pages = $data['pages'];
$languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language');
Expand Down Expand Up @@ -1515,21 +1518,20 @@ public function showByTagAction(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz =
return $this->htmlResponse();
}
if ($this->checkForClosure()) {
$this->redirectToURI(
$this->uriBuilder->reset()
->setTargetPageUid($this->settings['closurePageUid'])
->uriFor(
'closure',
[
'participant' => $this->participant,
'session' => $this->participant->getSession()
],
'Quiz',
null,
'closure'
)
->build()
);
$uri = $this->uriBuilder->reset()
->setTargetPageUid($this->settings['closurePageUid'])
->uriFor(
'closure',
[
'participant' => $this->participant,
'session' => $this->participant->getSession()
],
'Quiz',
null,
'closure'
);
return $this->responseFactory->createResponse(307)
->withHeader('Location', $uri);
}
$userData = $this->findParticipant($quiz->getUid(), $quiz->getPid());
$page = $this->request->hasArgument('currentPage') ? intval($this->request->getArgument('currentPage')) : 1;
Expand All @@ -1541,6 +1543,10 @@ public function showByTagAction(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz =
}
$pages = $tagArray['pages'];
$data = $this->doAll($quiz, $userData, $pages, $tagArray['randomNumbers']);
if ($data['redirectTo']) {
return $this->responseFactory->createResponse(307)
->withHeader('Location', $data['redirectTo']);
}
$lastPage = $data['lastPage'];
if ($this->settings['allowEdit']) {
$lastPage = $page;
Expand Down Expand Up @@ -1636,21 +1642,20 @@ public function showAjaxAction(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz):
return $this->htmlResponse();
}
if ($this->checkForClosure()) {
$this->redirectToURI(
$this->uriBuilder->reset()
->setTargetPageUid($this->settings['closurePageUid'])
->uriFor(
'closure',
[
'participant' => $this->participant,
'session' => $this->participant->getSession()
],
'Quiz',
null,
'closure'
)
->build()
);
$uri = $this->uriBuilder->reset()
->setTargetPageUid($this->settings['closurePageUid'])
->uriFor(
'closure',
[
'participant' => $this->participant,
'session' => $this->participant->getSession()
],
'Quiz',
null,
'closure'
);
return $this->responseFactory->createResponse(307)
->withHeader('Location', $uri);
}
// siehe: https://www.sebkln.de/tutorials/erstellung-einer-typo3-extension-mit-ajax-aufruf/
// $quizUid = $this->request->hasArgument('quiz') ? intval($this->request->getArgument('quiz')) : 0;
Expand All @@ -1659,6 +1664,10 @@ public function showAjaxAction(\Fixpunkt\FpMasterquiz\Domain\Model\Quiz $quiz):
$this->settings['user']['useCookie'] = 0;
$userData = $this->findParticipant($quiz->getUid(), $quiz->getPid());
$data = $this->doAll($quiz, $userData, 0, []);
if ($data['redirectTo']) {
return $this->responseFactory->createResponse(307)
->withHeader('Location', $data['redirectTo']);
}
$page = $data['page'];
$pages = $data['pages'];
$from = 1 + (($page - 1) * intval($this->settings['pagebrowser']['itemsPerPage']));
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public function getUsername()
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($this->user, \PDO::PARAM_INT))
)
->setMaxResults(1)
->execute();
->executeQuery();
while ($row = $statement->fetch()) {
return $row['username'];
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Question.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,6 @@ public function getSortedCategoriesArray() {
$queryBuilder->expr()->eq('mm.tablenames', $queryBuilder->createNamedParameter('tx_fpmasterquiz_domain_model_question'))
)
->orderBy('sys_category.sorting')
->execute();
->executeQuery();
}
}
2 changes: 1 addition & 1 deletion Classes/Domain/Repository/QuestionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function moveToQuiz($questionID, $quizID)
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($questionID, \PDO::PARAM_INT))
)
->set('quiz', intval($quizID))
->execute();
->executeStatement();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Classes/Domain/Repository/QuizRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function getMyLocalizedUid(int $defaultQuizUid, int $sys_language_uid)
$queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($sys_language_uid, \PDO::PARAM_INT))
)
->setMaxResults(1)
->execute();
->executeQuery();
while ($row = $statement->fetch()) {
$uid = $row['uid'];
}
Expand Down Expand Up @@ -117,8 +117,8 @@ public function findFormUidAndPidOtherLanguages(int $uid)
->where(
$queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT))
)
->execute();
return $statement->fetchAll();
->executeQuery();
return $statement->fetchAllAssociative();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Repository/SelectedRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ public function deleteByParticipantAndQuestion($participantId, $questionId)
$queryBuilder->expr()->eq('question', $queryBuilder->createNamedParameter($questionId, \PDO::PARAM_INT))
)
)
->execute()
->fetchAll();
->executeQuery()
->fetchAllAssociative();
foreach ($rows as $row) {
GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table)
->delete(
Expand Down
5 changes: 2 additions & 3 deletions Configuration/TCA/tx_fpmasterquiz_domain_model_answer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'iconfile' => 'EXT:fp_masterquiz/Resources/Public/Icons/tx_fpmasterquiz_domain_model_answer.gif'
],
'types' => [
'1' => ['showitem' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, title, points, --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime'],
'1' => ['showitem' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, title, points, --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime, --div--;LLL:EXT:fp_masterquiz/Resources/Private/Language/locallang_db.xlf:tabs.categories, categories'],
],
'columns' => [
'sys_language_uid' => [
Expand Down Expand Up @@ -146,5 +146,4 @@
],
],
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('tx_fpmasterquiz_domain_model_answer', 'categories');
];
5 changes: 2 additions & 3 deletions Configuration/TCA/tx_fpmasterquiz_domain_model_evaluation.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
'iconfile' => 'EXT:fp_masterquiz/Resources/Public/Icons/tx_fpmasterquiz_domain_model_evaluation.gif'
],
'types' => [
'1' => ['showitem' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, evaluate, minimum, maximum, image, bodytext, ce, page, --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime'],
'1' => ['showitem' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, evaluate, minimum, maximum, image, bodytext, ce, page, --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime, --div--;LLL:EXT:fp_masterquiz/Resources/Private/Language/locallang_db.xlf:tabs.categories, categories'],
],
'columns' => [
'sys_language_uid' => [
Expand Down Expand Up @@ -210,5 +210,4 @@
],
],
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('tx_fpmasterquiz_domain_model_evaluation', 'categories');
];
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'iconfile' => 'EXT:fp_masterquiz/Resources/Public/Icons/tx_fpmasterquiz_domain_model_participant.gif'
],
'types' => [
'1' => ['showitem' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, name, email, homepage, user, ip, session, sessionstart, randompages, points, maximum1, maximum2, page, completed, quiz, selections'],
'1' => ['showitem' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, name, email, homepage, user, ip, session, sessionstart, randompages, points, maximum1, maximum2, page, completed, quiz, selections, --div--;LLL:EXT:fp_masterquiz/Resources/Private/Language/locallang_db.xlf:tabs.categories, categories'],
],
'columns' => [
'sys_language_uid' => [
Expand Down Expand Up @@ -254,5 +254,4 @@
],
],
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('tx_fpmasterquiz_domain_model_participant', 'categories');
];
5 changes: 2 additions & 3 deletions Configuration/TCA/tx_fpmasterquiz_domain_model_question.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'iconfile' => 'EXT:fp_masterquiz/Resources/Public/Icons/tx_fpmasterquiz_domain_model_question.gif'
],
'types' => [
'1' => ['showitem' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, title, qmode, image, bodytext, explanation, tag, optional, answers, --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime'],
'1' => ['showitem' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, title, qmode, image, bodytext, explanation, tag, optional, answers, --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime, --div--;LLL:EXT:fp_masterquiz/Resources/Private/Language/locallang_db.xlf:tabs.categories, categories'],
],
'columns' => [
'sys_language_uid' => [
Expand Down Expand Up @@ -254,5 +254,4 @@
],
],
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('tx_fpmasterquiz_domain_model_question', 'categories');
];
6 changes: 3 additions & 3 deletions Configuration/TCA/tx_fpmasterquiz_domain_model_quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
'sys_language_uid, l10n_parent, l10n_diffsource, hidden, name, path_segment, about, timeperiod, media, qtype,
--div--;LLL:EXT:fp_masterquiz/Resources/Private/Language/locallang_db.xlf:tabs.questions, questions,
--div--;LLL:EXT:fp_masterquiz/Resources/Private/Language/locallang_db.xlf:tabs.evaluations, evaluations,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime, closed'],
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime, closed,
--div--;LLL:EXT:fp_masterquiz/Resources/Private/Language/locallang_db.xlf:tabs.categories, categories'],
],
'columns' => [
'sys_language_uid' => [
Expand Down Expand Up @@ -249,5 +250,4 @@
],
],
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('tx_fpmasterquiz_domain_model_quiz', 'categories');
];
6 changes: 3 additions & 3 deletions Configuration/TCA/tx_fpmasterquiz_domain_model_selected.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
'iconfile' => 'EXT:fp_masterquiz/Resources/Public/Icons/tx_fpmasterquiz_domain_model_selected.gif'
],
'types' => [
'1' => ['showitem' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, points, entered, question, answers'],
'1' => ['showitem' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, points, entered, question, answers,
--div--;LLL:EXT:fp_masterquiz/Resources/Private/Language/locallang_db.xlf:tabs.categories, categories'],
],
'columns' => [
'sys_language_uid' => [
Expand Down Expand Up @@ -142,5 +143,4 @@
],
],
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('tx_fpmasterquiz_domain_model_selected', 'categories');
];
4 changes: 4 additions & 0 deletions Resources/Private/Language/de.locallang_db.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
<source>Evaluations</source>
<target>Auswertungen</target>
</trans-unit>
<trans-unit id="tabs.categories" resname="tabs.categories">
<source>Categories</source>
<target>Kategorien</target>
</trans-unit>
<trans-unit id="tx_fpmasterquiz_domain_model_quiz" resname="tx_fpmasterquiz_domain_model_quiz">
<source>Quiz</source>
<target>Quiz/Test</target>
Expand Down
3 changes: 3 additions & 0 deletions Resources/Private/Language/locallang_db.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<trans-unit id="tabs.evaluations" resname="tabs.evaluations">
<source>Evaluations</source>
</trans-unit>
<trans-unit id="tabs.categories" resname="tabs.categories">
<source>Categories</source>
</trans-unit>
<trans-unit id="tx_fpmasterquiz_domain_model_quiz" resname="tx_fpmasterquiz_domain_model_quiz">
<source>Quiz</source>
</trans-unit>
Expand Down
Loading

0 comments on commit 204d482

Please sign in to comment.