Add personal ranking mode to order slides and show image placement only with an image
Order slides get a "ranking" setting without a correct solution: the stage shows the live average ranking, participants only get a confirmation. The image placement question in the slide form is only shown for an existing image or a chosen file. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
85627b364d
commit
0aac113f30
15 files changed
+239
-15
No files matched your search
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
namespace App\Test\TestCase\Controller;
|
||||
|
||||
use App\Model\Entity\Slide;
|
||||
use App\Service\PollStateService;
|
||||
use App\Service\ResultsService;
|
||||
use App\Test\TestCase\PlenarioTestTrait;
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
@@ -90,4 +92,46 @@ class OrderSlideTest extends TestCase
|
||||
$this->assertStringContainsString('1 von 1', $html);
|
||||
$this->assertStringContainsString('komplett richtig sortiert', $html);
|
||||
}
|
||||
|
||||
public function testRankingHasNoSolutionAndShowsAverageOrder(): void
|
||||
{
|
||||
[$poll, $token] = $this->createPoll();
|
||||
$this->post("/admin/$token/slides/add?type=order", [
|
||||
'type' => 'order', 'question' => 'Was ist dir wichtig?', 'is_voting_open' => '1',
|
||||
'settings' => ['ranking' => '1'], 'order_options' => ['Eins', 'Zwei', 'Drei'],
|
||||
]);
|
||||
$slide = $this->slidesTable()->find()->where(['poll_id' => $poll->id])->contain(['SlideOptions'])->firstOrFail();
|
||||
$this->assertTrue($slide->isRanking());
|
||||
$this->goLive($poll, $slide);
|
||||
[$a, $b, $c] = array_map(fn($o) => $o->id, $slide->slide_options);
|
||||
|
||||
// Two people rank Drei first; the stored order of the entries has no meaning.
|
||||
foreach (['c' => [$c, $a, $b], 'd' => [$c, $b, $a]] as $pid => $order) {
|
||||
$this->cookie('plenario_pid', str_repeat($pid, 32));
|
||||
$this->post('/p/' . $poll->join_code . '/vote', ['slide_id' => $slide->id, 'order' => $order]);
|
||||
}
|
||||
|
||||
// Participant: confirmation only, no results, no verdict - even after closing.
|
||||
$this->get('/p/' . $poll->join_code);
|
||||
$this->assertResponseContains('Deine Reihenfolge ist angekommen.');
|
||||
$this->assertResponseNotContains('Auflösung gibt es');
|
||||
$this->post("/admin/$token/control", ['action' => 'toggle']);
|
||||
$this->get('/p/' . $poll->join_code);
|
||||
$this->assertResponseNotContains('deine Reihenfolge stimmt');
|
||||
$this->assertResponseNotContains('Leider');
|
||||
$state = (new PollStateService())->forParticipant($this->pollsTable()->get($poll->id), str_repeat('c', 32));
|
||||
$this->assertNull($state['results']);
|
||||
$this->assertFalse($state['order']['revealed']);
|
||||
|
||||
// Presenter/export: items by average position, Drei first.
|
||||
$results = (new ResultsService())->forSlide($this->slidesTable()->get($slide->id, contain: ['SlideOptions']));
|
||||
$this->assertTrue($results['ranking']);
|
||||
// Eins and Zwei tie at 2.5 and keep the order of the entries.
|
||||
$this->assertSame(['Drei', 'Eins', 'Zwei'], array_column($results['items'], 'label'));
|
||||
$this->assertSame(1.0, (float)$results['items'][0]['average']);
|
||||
$this->assertSame(100.0, (float)$results['items'][0]['score']);
|
||||
|
||||
$html = $this->exportHtml($token);
|
||||
$this->assertStringContainsString('persönliche Rangfolgen', $html);
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,21 @@ class SlideImageTest extends TestCase
|
||||
$this->assertSame([$slide->image], $this->storedImages($poll->id));
|
||||
}
|
||||
|
||||
public function testPlacementIsOnlyOfferedWithAnImage(): void
|
||||
{
|
||||
[$poll, $token, $slide] = $this->slideWithImage();
|
||||
$empty = $this->createSlide($poll, Slide::TYPE_CONTENT, ['question' => 'Ohne Bild']);
|
||||
|
||||
// The placement fieldset is always rendered (usable without JavaScript); the script shows it only
|
||||
// for an existing image or a chosen file, marked by data-has-image.
|
||||
$this->get("/admin/$token/slides/{$slide->id}/edit");
|
||||
$this->assertResponseContains('data-image-layout');
|
||||
$this->assertResponseContains('data-has-image');
|
||||
$this->get("/admin/$token/slides/{$empty->id}/edit");
|
||||
$this->assertResponseContains('data-image-layout');
|
||||
$this->assertResponseNotContains('data-has-image');
|
||||
}
|
||||
|
||||
public function testLayoutDefaultsByType(): void
|
||||
{
|
||||
[$poll, , $content] = $this->slideWithImage();
|
||||
|
||||
@@ -129,7 +129,7 @@ class OrderTest extends TestCase
|
||||
$state = $this->participantState($poll, 'p1');
|
||||
$this->assertTrue($state['hasResponded']);
|
||||
$this->assertNull($state['results']);
|
||||
$this->assertSame(['revealed' => false, 'answer' => null, 'isCorrect' => null], $state['order']);
|
||||
$this->assertSame(['ranking' => false, 'revealed' => false, 'answer' => null, 'isCorrect' => null], $state['order']);
|
||||
}
|
||||
|
||||
public function testClosingRevealsResultsToEveryone(): void
|
||||
|
||||
Reference in new issue
Block a user