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
@@ -23,6 +23,7 @@ class SlidesTable extends Table
|
||||
{
|
||||
public const MAX_OPTIONS = 20;
|
||||
public const MAX_QUIZ_OPTIONS = 10;
|
||||
public const MAX_ORDER_OPTIONS = 10;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $config The configuration for the Table.
|
||||
@@ -233,6 +234,32 @@ class SlidesTable extends Table
|
||||
return ['labels' => $labels, 'correct' => $correct];
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the item rows of an ordering slide (`order_options[]`, in the correct order).
|
||||
* Empty rows are skipped; a repeated label is reported, because it would make the order ambiguous.
|
||||
*
|
||||
* @param array<mixed> $rows Raw form rows (labels)
|
||||
* @return array{labels: list<string>, duplicate: bool}
|
||||
*/
|
||||
public static function parseOrderOptions(array $rows): array
|
||||
{
|
||||
$labels = [];
|
||||
$duplicate = false;
|
||||
foreach ($rows as $row) {
|
||||
$label = is_scalar($row) ? mb_substr(trim((string)$row), 0, 255) : '';
|
||||
if ($label === '' || count($labels) >= self::MAX_ORDER_OPTIONS) {
|
||||
continue;
|
||||
}
|
||||
if (in_array($label, $labels, true)) {
|
||||
$duplicate = true;
|
||||
continue;
|
||||
}
|
||||
$labels[] = $label;
|
||||
}
|
||||
|
||||
return ['labels' => $labels, 'duplicate' => $duplicate];
|
||||
}
|
||||
|
||||
/**
|
||||
* Persists the end of a timed quiz once its deadline has passed. Safe to
|
||||
* call repeatedly (no-op unless the slide is still flagged open).
|
||||
|
||||
Reference in new issue
Block a user