Add personal ranking mode to order slides and show image placement only with an image
CI / Deploy / PHP 8.4 (push) Failing after 1m28s
CI / Deploy / PHP 8.5 (push) Failing after 1m31s
CI / Deploy / test (push) Failing after 2s
CI / Deploy / deploy (push) Skipped

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:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-17 09:15:49 +01:00
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);
}
}