Skip to content

Commit

Permalink
Version 5.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bihor committed Nov 21, 2024
1 parent c9bbf5c commit 5375ae4
Show file tree
Hide file tree
Showing 37 changed files with 97 additions and 439 deletions.
24 changes: 9 additions & 15 deletions Classes/Controller/ParticipantController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ public function listAction(int $currentPage = 1): ResponseInterface
$participantPaginator = new ArrayPaginator($participantArray, $currentPage, $this->settings['pagebrowser']['itemsPerPage']);
$participantPagination = new SimplePagination($participantPaginator);

$this->view->assign('pid', $pid);
$this->view->assign('qid', $qid);
$this->view->assign('participants', $participants);
$this->view->assign('paginator', $participantPaginator);
$this->view->assign('pagination', $participantPagination);
$this->view->assign('pages', range(1, $participantPagination->getLastPageNumber()));
$this->moduleTemplate->assign('pid', $pid);
$this->moduleTemplate->assign('qid', $qid);
$this->moduleTemplate->assign('participants', $participants);
$this->moduleTemplate->assign('paginator', $participantPaginator);
$this->moduleTemplate->assign('pagination', $participantPagination);
$this->moduleTemplate->assign('pages', range(1, $participantPagination->getLastPageNumber()));
$this->addDocHeaderDropDown('list');
return $this->defaultRendering();
return $this->moduleTemplate->renderResponse('Participant/List');
}

/**
Expand All @@ -110,9 +110,9 @@ public function detailAction(Participant $participant): ResponseInterface
}
}

$this->view->assign('participant', $participant);
$this->moduleTemplate->assign('participant', $participant);
$this->addDocHeaderDropDown('list');
return $this->defaultRendering();
return $this->moduleTemplate->renderResponse('Participant/Detail');
}

/**
Expand All @@ -137,12 +137,6 @@ protected function getLanguageService(): LanguageService
return $GLOBALS['LANG'];
}

protected function defaultRendering(): ResponseInterface
{
$this->moduleTemplate->setContent($this->view->render());
return $this->htmlResponse($this->moduleTemplate->renderContent());
}

protected function addDocHeaderDropDown(string $currentAction): void
{
$languageService = $this->getLanguageService();
Expand Down
14 changes: 4 additions & 10 deletions Classes/Controller/QuestionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ public function moveAction(Quiz $quiz, Question $question = NULL): ResponseInter
}

$questions = $this->questionRepository->findOtherThan($pid, $quiz->getUid());
$this->view->assign('question', $question);
$this->view->assign('questions', $questions);
$this->view->assign('quiz', $quiz);
$this->moduleTemplate->assign('question', $question);
$this->moduleTemplate->assign('questions', $questions);
$this->moduleTemplate->assign('quiz', $quiz);
$this->addDocHeaderDropDown('index');
return $this->defaultRendering();
return $this->moduleTemplate->renderResponse('Question/Move');
}

/*
Expand All @@ -83,12 +83,6 @@ protected function getLanguageService(): LanguageService
return $GLOBALS['LANG'];
}

protected function defaultRendering(): ResponseInterface
{
$this->moduleTemplate->setContent($this->view->render());
return $this->htmlResponse($this->moduleTemplate->renderContent());
}

protected function addDocHeaderDropDown(string $currentAction): void
{
$languageService = $this->getLanguageService();
Expand Down
58 changes: 26 additions & 32 deletions Classes/Controller/QuizController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

namespace Fixpunkt\FpMasterquiz\Controller;

use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\CMS\Core\Mail\MailMessage;
use Symfony\Component\Mime\Address;
use Fixpunkt\FpMasterquiz\Domain\Repository\QuizRepository;
use Fixpunkt\FpMasterquiz\Domain\Repository\AnswerRepository;
use Fixpunkt\FpMasterquiz\Domain\Repository\ParticipantRepository;
Expand All @@ -25,10 +22,13 @@
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Pagination\ArrayPaginator;
use Psr\Http\Message\ResponseInterface;
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\Mail\MailMessage;
use Symfony\Component\Mime\Address;
use Psr\Http\Message\ResponseInterface;
use Psr\Log\LoggerInterface;

/***
Expand Down Expand Up @@ -1229,7 +1229,7 @@ protected function evaluateInputTextAnswerResult(int $i_quid,
}

// for security reasons check the input from the frontend
$answerText = filter_var($answerText, FILTER_SANITIZE_STRING);
$answerText = htmlspecialchars($answerText); //filter_var($answerText, FILTER_SANITIZE_STRING);

// store the answer of the participant in the selected dataset
$c_selected->setEntered($answerText);
Expand All @@ -1239,7 +1239,7 @@ protected function evaluateInputTextAnswerResult(int $i_quid,
$c_selected->addAnswer($answer);

if ($i_question->getQmode() == 3) {
// sum the the points of the current answer to the max. possible point until the current question
// sum the points of the current answer to the max. possible point until the current question
$maximum1 += $answer->getPoints();

// if the answer is right
Expand Down Expand Up @@ -1294,7 +1294,7 @@ public function getFeUser(int $userid): array
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('fe_users');
$queryBuilder = $connection->createQueryBuilder();
$statement = $queryBuilder->select('*')->from('fe_users')->where(
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($userid, \PDO::PARAM_INT))
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($userid, \TYPO3\CMS\Core\Database\Connection::PARAM_INT))
)->setMaxResults(1)->executeQuery();
while ($row = $statement->fetch()) {
return $row;
Expand Down Expand Up @@ -2123,11 +2123,11 @@ public function indexAction(): ResponseInterface
$otherLangs[] = $this->quizRepository->findFormUidAndPidOtherLanguages($quiz->getUid());
}

$this->view->assign('pid', $pid);
$this->view->assign('quizzes', $quizzes);
$this->view->assign('otherQuizzes', $otherLangs);
$this->moduleTemplate->assign('pid', $pid);
$this->moduleTemplate->assign('quizzes', $quizzes);
$this->moduleTemplate->assign('otherQuizzes', $otherLangs);
$this->addDocHeaderDropDown('index');
return $this->defaultRendering();
return $this->moduleTemplate->renderResponse('Quiz/Index');
}

/**
Expand Down Expand Up @@ -2162,30 +2162,30 @@ public function detailAction(Quiz $quiz): ResponseInterface
$lostArray[$question->getUid()] = $question->getTitle();
}

$this->view->assign('quiz', $quiz);
$this->view->assign('lostArray', $lostArray);
$this->view->assign('lost', count($lostArray));
$this->view->assign('updated', $updated);
$this->moduleTemplate->assign('quiz', $quiz);
$this->moduleTemplate->assign('lostArray', $lostArray);
$this->moduleTemplate->assign('lost', count($lostArray));
$this->moduleTemplate->assign('updated', $updated);
if ($this->request->hasArgument('prop')) {
$this->view->assign('prop', $this->request->getArgument('prop'));
$this->moduleTemplate->assign('prop', $this->request->getArgument('prop'));
} else {
$this->view->assign('prop', 0);
$this->moduleTemplate->assign('prop', 0);
}

if ($this->request->hasArgument('user')) {
$this->view->assign('user', $this->request->getArgument('user'));
$this->moduleTemplate->assign('user', $this->request->getArgument('user'));
} else {
$this->view->assign('user', 0);
$this->moduleTemplate->assign('user', 0);
}

if ($this->request->hasArgument('chart')) {
$this->view->assign('chart', $this->request->getArgument('chart'));
$this->moduleTemplate->assign('chart', $this->request->getArgument('chart'));
} else {
$this->view->assign('chart', 0);
$this->moduleTemplate->assign('chart', 0);
}

$this->addDocHeaderDropDown('index');
return $this->defaultRendering();
return $this->moduleTemplate->renderResponse('Quiz/Detail');
}

/**
Expand All @@ -2197,11 +2197,11 @@ public function chartsAction(Quiz $quiz): ResponseInterface
$pid = $be ? $this->id : (int)$GLOBALS['TSFE']->id;

$debug = $this->setAllUserAnswers($quiz, $pid, $be);
$this->view->assign('debug', $debug);
$this->view->assign('pid', $pid);
$this->view->assign('quiz', $quiz);
$this->moduleTemplate->assign('debug', $debug);
$this->moduleTemplate->assign('pid', $pid);
$this->moduleTemplate->assign('quiz', $quiz);
$this->addDocHeaderDropDown('index');
return $this->defaultRendering();
return $this->moduleTemplate->renderResponse('Quiz/Charts');
}

/**
Expand Down Expand Up @@ -2268,12 +2268,6 @@ protected function getLanguageService(): LanguageService
return $GLOBALS['LANG'];
}

protected function defaultRendering(): ResponseInterface
{
$this->moduleTemplate->setContent($this->view->render());
return $this->htmlResponse($this->moduleTemplate->renderContent());
}

protected function addDocHeaderDropDown(string $currentAction): void
{
$languageService = $this->getLanguageService();
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()
->select('username')
->from('fe_users')
->where(
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($this->user, \PDO::PARAM_INT))
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter(intval($this->user), \TYPO3\CMS\Core\Database\Connection::PARAM_INT))
)
->setMaxResults(1)
->executeQuery();
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 @@ -689,7 +689,7 @@ public function getSortedCategoriesArray() {
$queryBuilder->expr()->eq('mm.uid_local', $queryBuilder->quoteIdentifier('sys_category.uid'))
)
->where(
$queryBuilder->expr()->eq('mm.uid_foreign', $queryBuilder->createNamedParameter($this->uid, \PDO::PARAM_INT)),
$queryBuilder->expr()->eq('mm.uid_foreign', $queryBuilder->createNamedParameter(intval($this->uid), \TYPO3\CMS\Core\Database\Connection::PARAM_INT)),
$queryBuilder->expr()->eq('mm.tablenames', $queryBuilder->createNamedParameter('tx_fpmasterquiz_domain_model_question'))
)
->orderBy('sys_category.sorting')
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Repository/QuestionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function moveToQuiz($questionID, $quizID)
$queryBuilder
->update($table)
->where(
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($questionID, \PDO::PARAM_INT))
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter(intval($questionID), \TYPO3\CMS\Core\Database\Connection::PARAM_INT))
)
->set('quiz', intval($quizID))
->executeStatement();
Expand Down
23 changes: 4 additions & 19 deletions Classes/Domain/Repository/QuizRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use TYPO3\CMS\Extbase\Persistence\Repository;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
Expand Down Expand Up @@ -53,32 +54,16 @@ public function initializeObject()
*/
public function getMyLocalizedUid(int $defaultQuizUid, int $sys_language_uid)
{
/*
$query = $this->createQuery();
//$query->getQuerySettings()->setReturnRawQueryResult(TRUE); // funktioniert leider nicht
$query->matching(
$query->logicalAnd(
$query->equals('l10n_parent', $defaultQuizUid),
$query->equals('sys_language_uid', $sys_language_uid)
)
);
$result = $query->execute()->getFirst();
if ($result) {
return $result->getUid();
} else {
return 0;
}
*/
$uid = 0;
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_fpmasterquiz_domain_model_quiz');
$statement = $queryBuilder
->select('uid')
->from('tx_fpmasterquiz_domain_model_quiz')
->where(
$queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($defaultQuizUid, \PDO::PARAM_INT))
$queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($defaultQuizUid, Connection::PARAM_INT))
)
->andWhere(
$queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($sys_language_uid, \PDO::PARAM_INT))
$queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($sys_language_uid, Connection::PARAM_INT))
)
->setMaxResults(1)
->executeQuery();
Expand Down Expand Up @@ -117,7 +102,7 @@ public function findFormUidAndPidOtherLanguages(int $uid)
->select('*')
->from('tx_fpmasterquiz_domain_model_quiz')
->where(
$queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT))
$queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($uid, Connection::PARAM_INT))
)
->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 @@ -127,8 +127,8 @@ public function deleteByParticipantAndQuestion($participantId, $questionId)
->from($table)
->where(
$queryBuilder->expr()->and(
$queryBuilder->expr()->eq('participant', $queryBuilder->createNamedParameter($participantId, \PDO::PARAM_INT)),
$queryBuilder->expr()->eq('question', $queryBuilder->createNamedParameter($questionId, \PDO::PARAM_INT))
$queryBuilder->expr()->eq('participant', $queryBuilder->createNamedParameter(intval($participantId), \TYPO3\CMS\Core\Database\Connection::PARAM_INT)),
$queryBuilder->expr()->eq('question', $queryBuilder->createNamedParameter(intval($questionId), \TYPO3\CMS\Core\Database\Connection::PARAM_INT))
)
)
->executeQuery()
Expand Down
2 changes: 1 addition & 1 deletion Classes/Task/CsvExportAdditionalFieldProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function validateAdditionalFields(array &$submittedData, SchedulerModuleC
->count('uid')
->from('pages')
->where(
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter((int)$submittedData['fpmasterquiz']['page'], \PDO::PARAM_INT))
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter((int)$submittedData['fpmasterquiz']['page'], \TYPO3\CMS\Core\Database\Connection::PARAM_INT))
)
->executeQuery()
->fetchOne();
Expand Down
4 changes: 2 additions & 2 deletions Classes/Task/CsvExportTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function execute() {
$queryBuilder->expr()->eq('mm.uid_foreign', $queryBuilder->quoteIdentifier('tx_fpmasterquiz_domain_model_answer.uid'))
)
->where(
$queryBuilder->expr()->eq('tx_fpmasterquiz_domain_model_answer.pid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT))
$queryBuilder->expr()->eq('tx_fpmasterquiz_domain_model_answer.pid', $queryBuilder->createNamedParameter($uid, \TYPO3\CMS\Core\Database\Connection::PARAM_INT))
)
->orderBy('mm.sorting', 'ASC')
->executeQuery();
Expand Down Expand Up @@ -252,7 +252,7 @@ public function execute() {
$queryBuilder->expr()->eq('question.uid', $queryBuilder->quoteIdentifier('tx_fpmasterquiz_domain_model_selected.question'))
)
->where(
$queryBuilder->expr()->eq('tx_fpmasterquiz_domain_model_selected.pid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT))
$queryBuilder->expr()->eq('tx_fpmasterquiz_domain_model_selected.pid', $queryBuilder->createNamedParameter($uid, \TYPO3\CMS\Core\Database\Connection::PARAM_INT))
)
->orderBy('part.uid', 'DESC')
->addOrderBy('suid', 'ASC')
Expand Down
2 changes: 1 addition & 1 deletion Classes/Task/DeleteParticipantAdditionalFieldProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function validateAdditionalFields(array &$submittedData, SchedulerModuleC
->count('uid')
->from('pages')
->where(
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter((int)$submittedData['fp_masterquiz']['page'], \PDO::PARAM_INT))
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter((int)$submittedData['fp_masterquiz']['page'], \TYPO3\CMS\Core\Database\Connection::PARAM_INT))
)
->executeQuery()
->fetchOne();
Expand Down
Loading

0 comments on commit 5375ae4

Please sign in to comment.