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
@@ -88,6 +88,67 @@ class AdminControllerTest extends TestCase
|
||||
$this->assertSame(1, $slide->position);
|
||||
}
|
||||
|
||||
public function testAddQuizSlide(): void
|
||||
{
|
||||
[, $token] = $this->createPoll();
|
||||
$data = [
|
||||
'type' => 'quiz',
|
||||
'question' => 'Hauptstadt von Frankreich?',
|
||||
'settings' => ['time_limit' => '20'],
|
||||
'is_voting_open' => '1',
|
||||
'quiz_options' => [
|
||||
['label' => 'Lyon', 'correct' => '0'],
|
||||
['label' => 'Paris', 'correct' => '1'],
|
||||
['label' => ''],
|
||||
],
|
||||
];
|
||||
|
||||
$this->get("/admin/$token/slides/add?type=quiz");
|
||||
$this->assertResponseOk();
|
||||
$this->assertResponseContains('name="quiz_options[0][label]"');
|
||||
$this->assertResponseNotContains('name="is_voting_open"');
|
||||
|
||||
$this->post("/admin/$token/slides/add?type=quiz", ['quiz_options' => [['label' => 'A'], ['label' => 'B']]] + $data);
|
||||
$this->assertResponseOk();
|
||||
$this->assertResponseContains('Bitte markiere mindestens eine Antwort als richtig.');
|
||||
|
||||
$this->post("/admin/$token/slides/add?type=quiz", $data);
|
||||
$this->assertRedirect(['_name' => 'admin', 'token' => $token]);
|
||||
$slide = $this->slidesTable()->find()->contain(['SlideOptions'])->firstOrFail();
|
||||
$this->assertSame(['Lyon', 'Paris'], array_map(fn($o) => $o->label, $slide->slide_options));
|
||||
$this->assertSame([false, true], array_map(fn($o) => $o->is_correct, $slide->slide_options));
|
||||
$this->assertSame(['time_limit' => 20], $slide->settings);
|
||||
$this->assertFalse($slide->is_voting_open, 'quiz starts closed until the presenter starts it');
|
||||
}
|
||||
|
||||
public function testPresenterStartsAndEndsQuiz(): void
|
||||
{
|
||||
[$poll, $token] = $this->createPoll();
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_QUIZ, ['is_voting_open' => false], ['Richtig', 'Falsch']);
|
||||
$this->goLive($poll, $slide);
|
||||
$control = function (string $action) use ($token): array {
|
||||
$this->configRequest(['headers' => ['Accept' => 'application/json']]);
|
||||
$this->post("/admin/$token/control", ['action' => $action]);
|
||||
$this->assertResponseOk();
|
||||
|
||||
return json_decode((string)$this->_response->getBody(), true);
|
||||
};
|
||||
|
||||
$state = $control('toggle');
|
||||
$this->assertSame('running', $state['results']['phase']);
|
||||
$this->assertGreaterThan(25, $state['results']['remaining']);
|
||||
$this->assertStringNotContainsString('correct', (string)$this->_response->getBody());
|
||||
$this->assertNotNull($this->slidesTable()->get($slide->id)->voting_ends_at);
|
||||
|
||||
$state = $control('toggle');
|
||||
$this->assertSame('finished', $state['results']['phase']);
|
||||
$this->assertTrue($state['results']['options'][0]['correct']);
|
||||
|
||||
$this->post("/admin/$token/slides/{$slide->id}/reset");
|
||||
$slide = $this->slidesTable()->get($slide->id);
|
||||
$this->assertSame(Slide::QUIZ_READY, $slide->quizPhase());
|
||||
}
|
||||
|
||||
public function testEditKeepsVotesOfUnchangedOptions(): void
|
||||
{
|
||||
[$poll, $token] = $this->createPoll();
|
||||
|
||||
Reference in new issue
Block a user