bihor / fp_masterquiz

TYPO3 extension to create a quiz, poll or test. The user result will be saved in the DB too and could be displayed as a chart.
GNU General Public License v3.0
5 stars 9 forks source link

Cant solve a question / new participant #44

Closed naturefund-falk closed 1 year ago

naturefund-falk commented 1 year ago

Looks like i missed somewhere an important configuration step. Created a plugin on page, a quiz with 2 questions for now and an evaluation. After submitting the first result i get the following typo3 exception: ` (1/1) #1249479819 TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException

The object of type "Fixpunkt\FpMasterquiz\Domain\Model\Participant" given to update must be persisted already, but is new. ` The participant form value is empty on submit and outputting the template variables for the page with the question shows, that the participant object is mostly empty and has no uid, ie its new (thats what the exception is showing).

I tried with setting useCookie -1 or 7 days, no difference. What i am missing?

bihor commented 1 year ago

I have never seen this error. Does it shows a line number?

naturefund-falk commented 1 year ago

Sorry, missed the email from github. This coud be such a fast response.

Ok, the line number itself is not realy helpful because its in the persistence manager. But i have the stack trace enabled on this development server:

naturefund-falk commented 1 year ago

Looks like i shouldnt have taken the numbers from the stacktrace as they are resolved to former issues.

naturefund-falk commented 1 year ago

My problem seems to come from the quizController->findParticipant function. It creates a NEW participant, but the later called doAll-function expects an already persisted participant ($this->participantRepository->update(...) only updates a persisted object, no NEW objects). This seems to indicate that i miss the step where it creates a persisted participant.

naturefund-falk commented 1 year ago

Ok, i found the problem in our case. Its because we use in our typo3 installation a special persistence manager. The participantRepository is using it, but the invoked persistence manager in doAll is not. So the $participantRepository->add function is adding the new participant to the special persistence manager, while the later call to persistAll can not persist it, because it does not know about this object.

The explicit invocation of the PersistenceManager via objectmanager::get has to be replaced anyway, because in typo3 v12 this will be removed (the objectManager::get function, not the PersistenceManager). Maybe i manage to create a pull request for this.

bihor commented 1 year ago

OK, thanks for your hints. I guess, you can fix it, so I wait for a solution from you.

bihor commented 1 year ago

Thanks for your pull request. I think, this is fixed now in version 3.5.5.