Add ordering slide type
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:
1 parent
4eed568a64
commit
918e077734
17 files changed
+922
-95
No files matched your search
@@ -305,6 +305,7 @@ class AdminController extends AdminAppController
|
||||
foreach ($responses as $response) {
|
||||
$texts[$response->id] = (string)$response->text_value;
|
||||
$answer = match (true) {
|
||||
$slide->isOrder() => $this->orderAnswer($slide, $labels, (string)$response->text_value),
|
||||
$response->parent_id !== null => __('Upvote: {0}', $texts[$response->parent_id] ?? ''),
|
||||
$response->slide_option_id !== null => $labels[$response->slide_option_id] ?? '',
|
||||
$response->text_value !== null && $response->numeric_value === VoteService::DOWNVOTE
|
||||
@@ -335,6 +336,26 @@ class AdminController extends AdminAppController
|
||||
->withStringBody($csv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ordering answer for the CSV export, e.g. "A → C → B (falsch)".
|
||||
*
|
||||
* @param \App\Model\Entity\Slide $slide Ordering slide incl. slide_options
|
||||
* @param array<int, string> $labels Option labels by id
|
||||
* @param string $text Stored answer (option ids)
|
||||
* @return string
|
||||
*/
|
||||
protected function orderAnswer(Slide $slide, array $labels, string $text): string
|
||||
{
|
||||
$given = VoteService::parseOrder($text);
|
||||
$correct = array_map(fn($option) => $option->id, array_values($slide->slide_options ?? []));
|
||||
|
||||
return __(
|
||||
'{0} ({1})',
|
||||
implode(' → ', array_map(fn(int $id) => $labels[$id] ?? '?', $given)),
|
||||
$given === $correct ? __('richtig') : __('falsch'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents CSV/formula injection in spreadsheet programs.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user