Merge pull request 'List all slide types on the start page' (#14) from fix/home-slide-types into main
CI / Deploy / test (push) Successful in 50s
CI / Deploy / deploy (push) Successful in 3s

Reviewed-on: #14
This commit was merged in pull request #14.
This commit is contained in:
gnilebein committed 2026-11-07 16:30:26 +01:00
commit 187af50bcf
4 files changed
+41 -7

No files matched your search

+14
View File
@@ -5,6 +5,7 @@ namespace App\Controller;
use App\Captcha\CaptchaFactory;
use App\Mailer\PollMailer;
use App\Model\Entity\Slide;
use App\Model\Table\PollsTable;
use App\Service\ThrottleService;
use Cake\Core\Configure;
@@ -47,6 +48,18 @@ class HomeController extends AppController
$poll = $this->Polls->newEmptyEntity();
$captcha = CaptchaFactory::create('create')->challenge($this->request);
$this->set(compact('poll', 'captcha'));
$this->setSlideTypes();
}
/**
* Slide types for the start page, listed from the model so new types show up automatically.
*
* @return void
*/
protected function setSlideTypes(): void
{
$this->set('typeLabels', Slide::typeLabels());
$this->set('typeDescriptions', Slide::typeDescriptions());
}
/**
@@ -91,6 +104,7 @@ class HomeController extends AppController
// Re-render the start page with errors.
$this->set('poll', $poll);
$this->set('captcha', $captcha->challenge($this->request));
$this->setSlideTypes();
$this->render('index');
return null;
+12 -5
View File
@@ -5,6 +5,8 @@
* @var \App\View\AppView $this
* @var \App\Model\Entity\Poll $poll
* @var array<string, mixed> $captcha
* @var array<string, string> $typeLabels
* @var array<string, string> $typeDescriptions
*/
$this->assign('title', __('Live-Umfragen ohne Login'));
?>
@@ -53,9 +55,14 @@ $this->assign('title', __('Live-Umfragen ohne Login'));
</section>
</div>
<section class="features">
<div><strong><?= __('Multiple Choice') ?></strong><span><?= __('Balkendiagramm in Echtzeit') ?></span></div>
<div><strong><?= __('Wortwolke') ?></strong><span><?= __('Begriffe sammeln und gewichten') ?></span></div>
<div><strong><?= __('Offene Fragen') ?></strong><span><?= __('Freitext-Antworten live') ?></span></div>
<div><strong><?= __('Skala') ?></strong><span><?= __('Bewertungen mit Durchschnitt') ?></span></div>
<section class="features-section" aria-labelledby="features-title">
<h2 id="features-title"><?= __('Folientypen') ?></h2>
<ul class="features">
<?php foreach ($typeLabels as $type => $label) : ?>
<li class="features__item type-card--<?= h($type) ?>">
<strong><?= h($label) ?></strong>
<span><?= h($typeDescriptions[$type] ?? '') ?></span>
</li>
<?php endforeach; ?>
</ul>
</section>
@@ -3,6 +3,7 @@ declare(strict_types=1);
namespace App\Test\TestCase\Controller;
use App\Model\Entity\Slide;
use App\Test\TestCase\PlenarioTestTrait;
use Cake\Cache\Cache;
use Cake\Core\Configure;
@@ -42,6 +43,15 @@ class HomeControllerTest extends TestCase
$this->assertResponseContains('Teilnahme-Code');
}
public function testIndexListsAllSlideTypes(): void
{
$this->get('/');
foreach (Slide::typeLabels() as $type => $label) {
$this->assertResponseContains('type-card--' . $type, $type);
$this->assertResponseContains(h($label), $type);
}
}
public function testCreateWithValidMathCaptchaSendsAdminMail(): void
{
$this->session(['Captcha.math.create' => 7]);
+5 -2
View File
@@ -142,8 +142,11 @@ h3 { font-size: 1.05rem; margin-top: 1.6em; }
.hero { text-align: center; max-width: 760px; margin: 16px auto 40px; }
.hero h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-top: 16px; }
.features div { padding: 16px; border-radius: var(--radius); background: var(--surface-2); }
.features-section { margin-top: 16px; }
.features-section h2 { text-align: center; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
/* border colour per type: .type-card--{type} below */
.features__item { padding: 16px; border-radius: var(--radius); background: var(--surface-2); border-top: 4px solid var(--c0); }
.features strong { display: block; }
.features span { color: var(--muted); font-size: .9rem; }