Add ordering slide type
CI / Deploy / test (push) Successful in 50s
CI / Deploy / deploy (push) Skipped

Participants bring shuffled items into the correct order and submit it
once. The admin enters the items in the correct order and can reorder
them by drag & drop or arrow keys. Closing the voting reveals the
solution: how many got it completely right and how often each item was
placed correctly; participants see whether their order was right.

The drag & drop mechanics of the slide list are extracted into a
reusable makeSortable() helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-07 16:47:37 +01:00
1 parent 4eed568a64
commit 918e077734
17 files changed
+922 -95

No files matched your search

+34 -3
View File
@@ -22,7 +22,8 @@ use Cake\ORM\Locator\LocatorAwareTrait;
* Quiz slides reveal results (and the participant's own correctness) only
* once the quiz is finished – then always, independent of
* `show_results_to_participants`. Timed quizzes are closed lazily here
* when their deadline has passed.
* when their deadline has passed. Ordering slides work the same way: solution,
* counts and the participant's correctness (`order`) only once voting is closed.
*
* Q&A slides have their own participant view (`qa`, see qaState()), never `results`.
* Private open questions (anonymous feedback) never show results to participants.
@@ -153,6 +154,7 @@ class PollStateService
$words = $slide?->type === Slide::TYPE_WORDCLOUD ? $this->wordState($slide, $participantHash) : null;
$quiz = $slide?->isQuiz() ? $this->quizState($slide, $participantHash) : null;
$qa = $slide?->isQa() ? $this->qaState($slide, $participantHash) : null;
$order = $slide?->isOrder() ? $this->orderState($slide, $participantHash) : null;
$hasResponded = match (true) {
$words !== null => $words['mine'] !== [] || $words['down'] !== [],
$qa !== null => $qa['mine'] !== [] || $qa['upvoted'] !== [],
@@ -164,8 +166,8 @@ class PollStateService
&& $slide->isInteractive()
&& $qa === null
&& !$slide->isPrivate()
&& ($quiz !== null
? $quiz['phase'] === Slide::QUIZ_FINISHED
&& ($quiz !== null || $order !== null
? ($quiz['phase'] ?? null) === Slide::QUIZ_FINISHED || ($order['revealed'] ?? false)
: ($poll->show_results_to_participants && ($hasResponded || !$isVotingOpen))
|| ($words !== null && $words['allowUpvotes'] && $isVotingOpen));
@@ -189,6 +191,35 @@ class PollStateService
'words' => $words,
'quiz' => $quiz,
'qa' => $qa,
'order' => $order,
];
}
/**
* Ordering progress of one participant. Own answer and correctness only once
* revealed (voting closed); before that the state must not hint at the solution.
*
* @param \App\Model\Entity\Slide $slide Ordering slide incl. slide_options
* @param string $participantHash Participant hash
* @return array{revealed: bool, answer: list<int>|null, isCorrect: bool|null}
*/
public function orderState(Slide $slide, string $participantHash): array
{
$revealed = $slide->isOrderRevealed();
$answer = null;
if ($revealed) {
$response = $this->Responses->find()
->select(['text_value'])
->where(['slide_id' => $slide->id, 'participant_hash' => $participantHash])
->first();
$answer = $response === null ? null : VoteService::parseOrder($response->text_value);
}
$correct = array_map(fn($option) => $option->id, array_values($slide->slide_options ?? []));
return [
'revealed' => $revealed,
'answer' => $answer,
'isCorrect' => $answer === null ? null : $answer === $correct,
];
}