Add quiz slide type
Quiz slides have predefined answers with one or more marked as correct. The presenter starts the quiz, which then runs until its optional time limit expires or the presenter ends it. Counts and correct answers are only revealed once the quiz is finished; participants then see whether their answer was right. - migration: slide_options.is_correct, slides.voting_started_at/voting_ends_at - Slide::isVotingOpen() includes the quiz deadline, expired quizzes are closed lazily when the state is read - presenter countdown, quiz tiles and reveal with correct-answer summary - CSV export marks quiz answers as right/wrong Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
04cbc5bcd3
commit
fd8da4c16c
18 files changed
+999
-43
No files matched your search
@@ -13,6 +13,17 @@ $this->assign('title', $poll->title);
|
||||
$this->assign('bodyClass', 'participant');
|
||||
$voteUrl = ['_name' => 'participate:vote', 'code' => $poll->join_code];
|
||||
$words = $state['words'] ?? null;
|
||||
$quiz = $state['quiz'] ?? null;
|
||||
$countdown = function (?int $remaining): string {
|
||||
if ($remaining === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return '<p class="countdown" role="timer" data-countdown data-remaining="' . $remaining . '">'
|
||||
. '<span class="countdown__label">' . h(__('Noch')) . '</span> '
|
||||
. '<strong class="countdown__value" data-countdown-value>' . sprintf('%d:%02d', intdiv($remaining, 60), $remaining % 60) . '</strong>'
|
||||
. '</p>';
|
||||
};
|
||||
?>
|
||||
<div class="participant-view"
|
||||
data-participant
|
||||
@@ -51,7 +62,39 @@ $words = $state['words'] ?? null;
|
||||
<p class="muted"><?= nl2br(h($slide->description)) ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($words !== null && $slide->is_voting_open) : ?>
|
||||
<?php if ($quiz !== null) : ?>
|
||||
<?php if ($quiz['phase'] === 'ready') : ?>
|
||||
<div class="waiting center">
|
||||
<div class="pulse" aria-hidden="true"></div>
|
||||
<p class="muted"><?= __('Das Quiz startet gleich. Die Antworten erscheinen, sobald es losgeht.') ?></p>
|
||||
</div>
|
||||
<?php elseif ($quiz['phase'] === 'running' && $state['hasResponded']) : ?>
|
||||
<?= $countdown($quiz['remaining']) ?>
|
||||
<p class="done">✓ <?= __('Deine Antwort ist angekommen.') ?></p>
|
||||
<p class="muted"><?= __('Die Auflösung gibt es, sobald das Quiz beendet ist.') ?></p>
|
||||
<?php elseif ($quiz['phase'] === 'running') : ?>
|
||||
<?= $countdown($quiz['remaining']) ?>
|
||||
<?= $this->Form->create(null, ['url' => $voteUrl, 'class' => 'vote-form', 'data-quiz-form' => true]) ?>
|
||||
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
|
||||
<fieldset class="choices choices--quiz">
|
||||
<legend class="sr-only"><?= __('Antworten') ?></legend>
|
||||
<?php foreach ($slide->slide_options as $index => $option) : ?>
|
||||
<label class="choice choice--quiz choice--c<?= $index % 6 ?>">
|
||||
<input type="radio" name="option_id" value="<?= (int)$option->id ?>" required>
|
||||
<span><?= h($option->label) ?></span>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</fieldset>
|
||||
<?= $this->Form->button(__('Antwort abgeben'), ['class' => 'button button--primary button--block']) ?>
|
||||
<?= $this->Form->end() ?>
|
||||
<?php elseif ($quiz['isCorrect'] === true) : ?>
|
||||
<p class="verdict verdict--correct">✓ <?= __('Richtig!') ?></p>
|
||||
<?php elseif ($quiz['isCorrect'] === false) : ?>
|
||||
<p class="verdict verdict--wrong">✗ <?= __('Leider falsch.') ?></p>
|
||||
<?php else : ?>
|
||||
<p class="muted"><?= __('Das Quiz ist beendet – du hast keine Antwort abgegeben.') ?></p>
|
||||
<?php endif; ?>
|
||||
<?php elseif ($words !== null && $slide->is_voting_open) : ?>
|
||||
<?= $this->Form->create(null, ['url' => $voteUrl, 'class' => 'vote-form word-form', 'data-word-form' => true]) ?>
|
||||
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
|
||||
<p class="hint"><?= __('Du kannst beliebig viele Begriffe abgeben.') ?></p>
|
||||
@@ -113,7 +156,11 @@ $words = $state['words'] ?? null;
|
||||
</section>
|
||||
|
||||
<section class="card results-card" data-results-card <?= $state['results'] ? '' : 'hidden' ?>>
|
||||
<h2><?= $words !== null ? __('Wortwolke') : __('Ergebnisse') ?></h2>
|
||||
<h2><?= match (true) {
|
||||
$words !== null => __('Wortwolke'),
|
||||
$quiz !== null => __('Auflösung'),
|
||||
default => __('Ergebnisse'),
|
||||
} ?></h2>
|
||||
<?php if ($words !== null && $words['allowUpvotes'] && $slide->is_voting_open) : ?>
|
||||
<p class="hint" data-upvote-hint><?= $words['allowDownvotes']
|
||||
? __('Tippe auf einen Begriff, um ihn zu unterstützen, oder auf „−“, um ihn abzulehnen.')
|
||||
|
||||
Reference in new issue
Block a user