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
@@ -39,6 +39,7 @@ class Slide extends Entity
|
||||
public const TYPE_QUIZ = 'quiz';
|
||||
public const TYPE_YOUTUBE = 'youtube';
|
||||
public const TYPE_QA = 'qa';
|
||||
public const TYPE_ORDER = 'order';
|
||||
|
||||
/**
|
||||
* Quiz phases, see quizPhase().
|
||||
@@ -91,6 +92,8 @@ class Slide extends Entity
|
||||
self::TYPE_YOUTUBE => ['url' => '', 'video_id' => '', 'start' => 0, 'autoplay' => false],
|
||||
// upvotes per participant in the voting stage (1..QA_MAX_UPVOTES)
|
||||
self::TYPE_QA => ['max_upvotes' => 3],
|
||||
// The correct order is the order of the slide_options (position), revealed when voting closes.
|
||||
self::TYPE_ORDER => [],
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -115,6 +118,7 @@ class Slide extends Entity
|
||||
self::TYPE_OPEN => __('Offene Frage'),
|
||||
self::TYPE_SCALE => __('Skala'),
|
||||
self::TYPE_QUIZ => __('Quiz'),
|
||||
self::TYPE_ORDER => __('Reihenfolge'),
|
||||
self::TYPE_QA => __('Fragen & Antworten'),
|
||||
self::TYPE_CONTENT => __('Inhaltsfolie'),
|
||||
self::TYPE_YOUTUBE => __('YouTube-Video'),
|
||||
@@ -132,6 +136,7 @@ class Slide extends Entity
|
||||
self::TYPE_OPEN => __('Freitext-Antworten, live als Liste.'),
|
||||
self::TYPE_SCALE => __('Bewertung auf einer Skala, z. B. 1 bis 5.'),
|
||||
self::TYPE_QUIZ => __('Frage mit richtiger Antwort und Zeitlimit, aufgelöst wird erst am Ende.'),
|
||||
self::TYPE_ORDER => __('Einträge in die richtige Reihenfolge bringen, aufgelöst wird beim Schließen der Abstimmung.'),
|
||||
self::TYPE_QA => __('Teilnehmende reichen Fragen ein und wählen per Upvote, welche zuerst beantwortet werden.'),
|
||||
self::TYPE_CONTENT => __('Nur Text anzeigen, ohne Abstimmung.'),
|
||||
self::TYPE_YOUTUBE => __('Video in der Präsentation abspielen, Teilnehmende bekommen den Link zum Teilen.'),
|
||||
@@ -233,6 +238,48 @@ class Slide extends Entity
|
||||
return $this->type === self::TYPE_QA;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isOrder(): bool
|
||||
{
|
||||
return $this->type === self::TYPE_ORDER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ordering slide whose solution may be shown: voting is closed. While voting
|
||||
* is open, neither the correct order nor any counts may leave the server.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isOrderRevealed(): bool
|
||||
{
|
||||
return $this->isOrder() && !$this->isVotingOpen();
|
||||
}
|
||||
|
||||
/**
|
||||
* Options of an ordering slide in a stable pseudo-random order (same seed =
|
||||
* same order, e.g. per participant across reloads). With two or more options
|
||||
* the result never equals the correct order.
|
||||
*
|
||||
* @param string $seed Seed, e.g. participant hash or "slide:{id}"
|
||||
* @return list<\App\Model\Entity\SlideOption>
|
||||
*/
|
||||
public function shuffledOptions(string $seed): array
|
||||
{
|
||||
$options = array_values($this->slide_options ?? []);
|
||||
$correct = array_map(fn($option) => $option->id, $options);
|
||||
usort($options, fn($a, $b) => strcmp(
|
||||
hash('sha256', $seed . '|' . $a->id),
|
||||
hash('sha256', $seed . '|' . $b->id),
|
||||
));
|
||||
if (count($options) > 1 && array_map(fn($option) => $option->id, $options) === $correct) {
|
||||
$options[] = array_shift($options);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stage of a Q&A slide (one of the QA_* constants), see QaService.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user