Feature/edit scale comment #42
No files matched your search
@@ -60,7 +60,7 @@ src/
|
|||||||
AdminController Dashboard, Settings, Present, State-JSON, Control, QR, PDF-Export, Token rotieren, Zurücksetzen, Löschen
|
AdminController Dashboard, Settings, Present, State-JSON, Control, QR, PDF-Export, Token rotieren, Zurücksetzen, Löschen
|
||||||
SlidesController Folien-CRUD, Antworten offener Fragen bzw. Skala-Auswertung (`answers`), Sortieren (Drag & Drop/Pfeiltasten via `reorder`, JSON; erfordert JS), Antworten zurücksetzen,
|
SlidesController Folien-CRUD, Antworten offener Fragen bzw. Skala-Auswertung (`answers`), Sortieren (Drag & Drop/Pfeiltasten via `reorder`, JSON; erfordert JS), Antworten zurücksetzen,
|
||||||
YouTube-Link prüfen (`youtubeCheck`, JSON)
|
YouTube-Link prüfen (`youtubeCheck`, JSON)
|
||||||
ParticipateController /p/{code}: Ansicht, State-JSON, Abstimmen, eigenen Skala-Kommentar bearbeiten; anonymes Cookie plenario_pid
|
ParticipateController /p/{code}: Ansicht, State-JSON, Abstimmen, eigene Antwort/Kommentar bearbeiten; anonymes Cookie plenario_pid
|
||||||
EmbedController /e/{key}/{id}: eine Folie zum Einbetten (z. B. Canva), activate/heartbeat/pause/control
|
EmbedController /e/{key}/{id}: eine Folie zum Einbetten (z. B. Canva), activate/heartbeat/pause/control
|
||||||
ErrorController Fehlerseiten (Templates unter templates/Error, Layout `error`)
|
ErrorController Fehlerseiten (Templates unter templates/Error, Layout `error`)
|
||||||
Mailer/ PollMailer (adminLink, recovery; `sendSafely()` loggt Transportfehler statt zu werfen), Transport/FileTransport (lokal)
|
Mailer/ PollMailer (adminLink, recovery; `sendSafely()` loggt Transportfehler statt zu werfen), Transport/FileTransport (lokal)
|
||||||
@@ -219,9 +219,10 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures
|
|||||||
vor/zurück/Pause, Laufbalken bis zum Wechsel (`Comments.progress()`, setzt nach dem Neu-Rendern per negativem
|
vor/zurück/Pause, Laufbalken bis zum Wechsel (`Comments.progress()`, setzt nach dem Neu-Rendern per negativem
|
||||||
`animation-delay` fort, bei Pause unsichtbar), Zustand übersteht das Neu-Rendern beim Polling). Bei internem Feedback erscheinen sie erst,
|
`animation-delay` fort, bei Pause unsichtbar), Zustand übersteht das Neu-Rendern beim Polling). Bei internem Feedback erscheinen sie erst,
|
||||||
wenn der Presenter die Ergebnisse einblendet.
|
wenn der Presenter die Ergebnisse einblendet.
|
||||||
Teilnehmende können ihren eigenen Kommentar ändern, ergänzen oder leeren, solange die Abstimmung offen ist
|
- **Antwort nachträglich bearbeiten** (gegen Tippfehler, `VoteService::hasEditableText()`): Antwort einer offenen Frage
|
||||||
(`participate:comment` → `VoteService::editComment()`, gleiche Vorbedingungen wie `submit()`, in der Folien-Sperre);
|
(darf nicht leer werden) bzw. Kommentar einer Skala (ändern, ergänzen, leeren; die Bewertung bleibt unveränderlich),
|
||||||
die Bewertung selbst bleibt unveränderlich.
|
nur solange die Abstimmung offen ist. `participate:edit` → `VoteService::editText()`, gleiche Vorbedingungen wie
|
||||||
|
`submit()`, in der Folien-Sperre, legt nie eine neue Antwort an.
|
||||||
|
|
||||||
- **PDF-Export** (`/admin/{token}/export.pdf`, `admin:export`, `ReportService` + `PdfView`, Dompdf): Ergebnisse aller
|
- **PDF-Export** (`/admin/{token}/export.pdf`, `admin:export`, `ReportService` + `PdfView`, Dompdf): Ergebnisse aller
|
||||||
interaktiven Folien (Inhaltsfolien/YouTube fehlen). Standard ist die Fassung **ohne interne Inhalte**: private Folien
|
interaktiven Folien (Inhaltsfolien/YouTube fehlen). Standard ist die Fassung **ohne interne Inhalte**: private Folien
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ return function (RouteBuilder $routes): void {
|
|||||||
->setPatterns(['code' => '[A-Za-z0-9-]{4,16}'])
|
->setPatterns(['code' => '[A-Za-z0-9-]{4,16}'])
|
||||||
->setPass(['code'])
|
->setPass(['code'])
|
||||||
->setMethods(['POST']);
|
->setMethods(['POST']);
|
||||||
$builder->connect('/p/{code}/comment', 'Participate::comment', ['_name' => 'participate:comment'])
|
$builder->connect('/p/{code}/edit', 'Participate::edit', ['_name' => 'participate:edit'])
|
||||||
->setPatterns(['code' => '[A-Za-z0-9-]{4,16}'])
|
->setPatterns(['code' => '[A-Za-z0-9-]{4,16}'])
|
||||||
->setPass(['code'])
|
->setPass(['code'])
|
||||||
->setMethods(['POST']);
|
->setMethods(['POST']);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Model\Entity\Poll;
|
use App\Model\Entity\Poll;
|
||||||
|
use App\Model\Entity\Slide;
|
||||||
use App\Model\Table\PollsTable;
|
use App\Model\Table\PollsTable;
|
||||||
use App\Service\PollStateService;
|
use App\Service\PollStateService;
|
||||||
use App\Service\VoteException;
|
use App\Service\VoteException;
|
||||||
@@ -86,11 +87,11 @@ class ParticipateController extends AppController
|
|||||||
$slide = $poll->is_active ? $stateService->currentSlide($poll) : null;
|
$slide = $poll->is_active ? $stateService->currentSlide($poll) : null;
|
||||||
$participantHash = $this->participantHash($poll);
|
$participantHash = $this->participantHash($poll);
|
||||||
$state = $stateService->forParticipant($poll, $participantHash, $slide);
|
$state = $stateService->forParticipant($poll, $participantHash, $slide);
|
||||||
$ownComment = $slide?->hasComments() && $state['hasResponded']
|
$ownText = $slide !== null && VoteService::hasEditableText($slide) && $state['hasResponded']
|
||||||
? (new VoteService())->ownComment($slide, $participantHash)
|
? (new VoteService())->ownText($slide, $participantHash)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
$this->set(compact('poll', 'slide', 'state', 'participantHash', 'ownComment'));
|
$this->set(compact('poll', 'slide', 'state', 'participantHash', 'ownText'));
|
||||||
$this->setPollInterval();
|
$this->setPollInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,12 +158,13 @@ class ParticipateController extends AppController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces the own comment on a scale slide while voting is open (e.g. to fix a typo).
|
* Replaces the own answer text (open question) or comment (scale) while voting is open,
|
||||||
|
* e.g. to fix a typo. See VoteService::editText().
|
||||||
*
|
*
|
||||||
* @param string $code Join code
|
* @param string $code Join code
|
||||||
* @return \Cake\Http\Response|null
|
* @return \Cake\Http\Response|null
|
||||||
*/
|
*/
|
||||||
public function comment(string $code): ?Response
|
public function edit(string $code): ?Response
|
||||||
{
|
{
|
||||||
$this->request->allowMethod(['post']);
|
$this->request->allowMethod(['post']);
|
||||||
$poll = $this->loadPoll($code);
|
$poll = $this->loadPoll($code);
|
||||||
@@ -176,11 +178,13 @@ class ParticipateController extends AppController
|
|||||||
throw new VoteException(__('Diese Frage ist nicht mehr aktiv.'));
|
throw new VoteException(__('Diese Frage ist nicht mehr aktiv.'));
|
||||||
}
|
}
|
||||||
$data = (array)$this->request->getData();
|
$data = (array)$this->request->getData();
|
||||||
(new VoteService())->editComment($poll, $slide, $this->participantHash($poll), $data);
|
(new VoteService())->editText($poll, $slide, $this->participantHash($poll), $data);
|
||||||
$comment = $data['comment'] ?? '';
|
$comment = $data['comment'] ?? '';
|
||||||
$this->Flash->success(!is_scalar($comment) || trim((string)$comment) === ''
|
$this->Flash->success(match (true) {
|
||||||
? __('Dein Kommentar wurde entfernt.')
|
$slide->type === Slide::TYPE_OPEN => __('Deine Antwort wurde geändert.'),
|
||||||
: __('Dein Kommentar wurde gespeichert.'));
|
!is_scalar($comment) || trim((string)$comment) === '' => __('Dein Kommentar wurde entfernt.'),
|
||||||
|
default => __('Dein Kommentar wurde gespeichert.'),
|
||||||
|
});
|
||||||
} catch (VoteException $e) {
|
} catch (VoteException $e) {
|
||||||
$this->Flash->error($e->getMessage());
|
$this->Flash->error($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-15
@@ -36,8 +36,8 @@ use Cake\Utility\Security;
|
|||||||
* `remove` withdraws one own upvote of the question.
|
* `remove` withdraws one own upvote of the question.
|
||||||
* - ordering: `order` = all option ids, each exactly once, in the participant's order.
|
* - ordering: `order` = all option ids, each exactly once, in the participant's order.
|
||||||
* Stored as one row with the ids comma separated in `text_value` (see parseOrder()).
|
* Stored as one row with the ids comma separated in `text_value` (see parseOrder()).
|
||||||
* - scale with comment field: the own comment can be changed while voting is open
|
* - open question and scale with comment field: the own answer text or comment can be changed
|
||||||
* (editComment()), the rating cannot.
|
* while voting is open (editText()), a scale rating cannot.
|
||||||
*/
|
*/
|
||||||
class VoteService
|
class VoteService
|
||||||
{
|
{
|
||||||
@@ -127,45 +127,59 @@ class VoteService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scale with comment field: replaces the participant's own comment (e.g. to fix a typo)
|
* Whether the participant may change the text of their answer afterwards (e.g. to fix a typo):
|
||||||
* as long as voting on the slide is open. The rating itself stays unchanged; an empty
|
* the answer of an open question and the comment of a scale with comment field.
|
||||||
* comment removes it. Same preconditions as submit().
|
*
|
||||||
|
* @param \App\Model\Entity\Slide $slide Slide
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function hasEditableText(Slide $slide): bool
|
||||||
|
{
|
||||||
|
return $slide->type === Slide::TYPE_OPEN || ($slide->type === Slide::TYPE_SCALE && $slide->hasComments());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the text of the participant's own answer as long as voting on the slide is open
|
||||||
|
* (see hasEditableText()). Open question: `text`, must not be empty. Scale: `comment`, the
|
||||||
|
* rating itself stays unchanged and an empty comment removes it. Same preconditions as submit().
|
||||||
*
|
*
|
||||||
* @param \App\Model\Entity\Poll $poll Poll
|
* @param \App\Model\Entity\Poll $poll Poll
|
||||||
* @param \App\Model\Entity\Slide $slide Slide
|
* @param \App\Model\Entity\Slide $slide Slide
|
||||||
* @param string $participantHash Participant hash
|
* @param string $participantHash Participant hash
|
||||||
* @param array<string, mixed> $data Request data (`comment`)
|
* @param array<string, mixed> $data Request data (`text` or `comment`)
|
||||||
* @return void
|
* @return void
|
||||||
* @throws \App\Service\VoteException
|
* @throws \App\Service\VoteException
|
||||||
*/
|
*/
|
||||||
public function editComment(Poll $poll, Slide $slide, string $participantHash, array $data): void
|
public function editText(Poll $poll, Slide $slide, string $participantHash, array $data): void
|
||||||
{
|
{
|
||||||
$this->assertOpen($poll, $slide);
|
$this->assertOpen($poll, $slide);
|
||||||
if (!$slide->hasComments()) {
|
if (!self::hasEditableText($slide)) {
|
||||||
throw new VoteException(__('Bei dieser Frage gibt es keine Kommentare.'));
|
throw new VoteException(__('Diese Antwort kann nicht mehr geändert werden.'));
|
||||||
}
|
}
|
||||||
$comment = self::comment($data);
|
$text = $slide->type === Slide::TYPE_OPEN ? $this->openRows($data)[0]['text_value'] : self::comment($data);
|
||||||
$this->Responses->getConnection()->transactional(function () use ($slide, $participantHash, $comment): void {
|
$this->Responses->getConnection()->transactional(function () use ($slide, $participantHash, $text): void {
|
||||||
$this->lockSlide($slide);
|
$this->lockSlide($slide);
|
||||||
$row = $this->Responses->find()
|
$row = $this->Responses->find()
|
||||||
->where(['slide_id' => $slide->id, 'participant_hash' => $participantHash])
|
->where(['slide_id' => $slide->id, 'participant_hash' => $participantHash])
|
||||||
->first();
|
->first();
|
||||||
if ($row === null) {
|
if ($row === null) {
|
||||||
throw new VoteException(__('Bitte gib zuerst deine Bewertung ab.'));
|
throw new VoteException($slide->type === Slide::TYPE_OPEN
|
||||||
|
? __('Du hast hier noch nicht geantwortet.')
|
||||||
|
: __('Bitte gib zuerst deine Bewertung ab.'));
|
||||||
}
|
}
|
||||||
$row->text_value = $comment;
|
$row->text_value = $text;
|
||||||
$this->Responses->saveOrFail($row);
|
$this->Responses->saveOrFail($row);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The participant's own comment on a scale slide (null: none or not answered yet).
|
* Text of the participant's own answer: open answer or scale comment (null: none or not answered yet).
|
||||||
*
|
*
|
||||||
* @param \App\Model\Entity\Slide $slide Slide
|
* @param \App\Model\Entity\Slide $slide Slide
|
||||||
* @param string $participantHash Participant hash
|
* @param string $participantHash Participant hash
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public function ownComment(Slide $slide, string $participantHash): ?string
|
public function ownText(Slide $slide, string $participantHash): ?string
|
||||||
{
|
{
|
||||||
$row = $this->Responses->find()
|
$row = $this->Responses->find()
|
||||||
->select(['text_value'])
|
->select(['text_value'])
|
||||||
|
|||||||
@@ -8,9 +8,11 @@
|
|||||||
* @var \App\Model\Entity\Slide|null $slide
|
* @var \App\Model\Entity\Slide|null $slide
|
||||||
* @var array<string, mixed> $state
|
* @var array<string, mixed> $state
|
||||||
* @var string $participantHash Seed for the shuffled items of ordering slides
|
* @var string $participantHash Seed for the shuffled items of ordering slides
|
||||||
* @var string|null $ownComment Own comment on a scale slide (editable while voting is open)
|
* @var string|null $ownText Own open answer or scale comment (editable while voting is open)
|
||||||
* @var int $pollIntervalMs
|
* @var int $pollIntervalMs
|
||||||
*/
|
*/
|
||||||
|
use App\Service\VoteService;
|
||||||
|
|
||||||
$this->assign('title', $poll->title);
|
$this->assign('title', $poll->title);
|
||||||
$this->assign('bodyClass', 'participant');
|
$this->assign('bodyClass', 'participant');
|
||||||
$voteUrl = ['_name' => 'participate:vote', 'code' => $poll->join_code];
|
$voteUrl = ['_name' => 'participate:vote', 'code' => $poll->join_code];
|
||||||
@@ -218,20 +220,28 @@ $countdown = function (?int $remaining): string {
|
|||||||
<?= $this->Form->end() ?>
|
<?= $this->Form->end() ?>
|
||||||
<?php elseif ($state['hasResponded']) : ?>
|
<?php elseif ($state['hasResponded']) : ?>
|
||||||
<p class="done">✓ <?= __('Deine Antwort ist angekommen.') ?></p>
|
<p class="done">✓ <?= __('Deine Antwort ist angekommen.') ?></p>
|
||||||
<?php if ($slide->type === 'scale' && $slide->hasComments() && $slide->isVotingOpen()) : ?>
|
<?php if (VoteService::hasEditableText($slide) && $slide->isVotingOpen()) :
|
||||||
<?php if ($ownComment !== null) : ?>
|
$isOpen = $slide->type === 'open'; ?>
|
||||||
<p class="own-comment__label"><?= __('Dein Kommentar:') ?></p>
|
<?php if ($ownText !== null) : ?>
|
||||||
<blockquote class="own-comment"><?= nl2br(h($ownComment)) ?></blockquote>
|
<p class="own-comment__label"><?= $isOpen ? __('Deine Antwort:') : __('Dein Kommentar:') ?></p>
|
||||||
|
<blockquote class="own-comment"><?= nl2br(h($ownText)) ?></blockquote>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<details class="own-comment__edit">
|
<details class="own-comment__edit">
|
||||||
<summary><?= $ownComment !== null ? __('Kommentar bearbeiten') : __('Kommentar hinzufügen') ?></summary>
|
<summary><?= match (true) {
|
||||||
<?= $this->Form->create(null, ['url' => ['_name' => 'participate:comment', 'code' => $poll->join_code], 'class' => 'vote-form']) ?>
|
$isOpen => __('Antwort bearbeiten'),
|
||||||
|
$ownText !== null => __('Kommentar bearbeiten'),
|
||||||
|
default => __('Kommentar hinzufügen'),
|
||||||
|
} ?></summary>
|
||||||
|
<?= $this->Form->create(null, ['url' => ['_name' => 'participate:edit', 'code' => $poll->join_code], 'class' => 'vote-form']) ?>
|
||||||
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
|
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
|
||||||
<label class="scale-comment" for="scale-comment"><?= __('Kommentar') ?></label>
|
<label class="scale-comment" for="edit-text"><?= $isOpen ? __('Antwort') : __('Kommentar') ?></label>
|
||||||
<textarea id="scale-comment" name="comment" rows="3" maxlength="500"
|
<textarea id="edit-text" name="<?= $isOpen ? 'text' : 'comment' ?>" rows="3" maxlength="500"
|
||||||
aria-describedby="comment-edit-hint"><?= h((string)$ownComment) ?></textarea>
|
<?= $isOpen ? 'required' : '' ?>
|
||||||
<p class="hint" id="comment-edit-hint"><?= __('Möglich, solange die Abstimmung läuft. Ein leeres Feld entfernt deinen Kommentar, deine Bewertung bleibt.') ?></p>
|
aria-describedby="edit-text-hint"><?= h((string)$ownText) ?></textarea>
|
||||||
<?= $this->Form->button(__('Kommentar speichern'), ['class' => 'button button--primary button--block']) ?>
|
<p class="hint" id="edit-text-hint"><?= $isOpen
|
||||||
|
? __('Möglich, solange die Abstimmung läuft.')
|
||||||
|
: __('Möglich, solange die Abstimmung läuft. Ein leeres Feld entfernt deinen Kommentar, deine Bewertung bleibt.') ?></p>
|
||||||
|
<?= $this->Form->button($isOpen ? __('Antwort speichern') : __('Kommentar speichern'), ['class' => 'button button--primary button--block']) ?>
|
||||||
<?= $this->Form->end() ?>
|
<?= $this->Form->end() ?>
|
||||||
</details>
|
</details>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
@@ -180,4 +180,62 @@ class ParticipateControllerTest extends TestCase
|
|||||||
$this->assertArrayHasKey('state', $body);
|
$this->assertArrayHasKey('state', $body);
|
||||||
$this->assertSame(2, TableRegistry::getTableLocator()->get('Responses')->find()->where(['slide_id' => $slide->id])->count());
|
$this->assertSame(2, TableRegistry::getTableLocator()->get('Responses')->find()->where(['slide_id' => $slide->id])->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testOpenAnswerCanBeEditedWhileVotingIsOpen(): void
|
||||||
|
{
|
||||||
|
[$poll] = $this->createPoll();
|
||||||
|
$slide = $this->createSlide($poll, Slide::TYPE_OPEN);
|
||||||
|
$this->goLive($poll, $slide);
|
||||||
|
$responses = TableRegistry::getTableLocator()->get('Responses');
|
||||||
|
|
||||||
|
$this->cookie('plenario_pid', self::PID);
|
||||||
|
$this->post("/p/{$poll->join_code}/vote", ['slide_id' => $slide->id, 'text' => 'Tipfehler']);
|
||||||
|
$this->cookie('plenario_pid', self::PID);
|
||||||
|
$this->get('/p/' . $poll->join_code);
|
||||||
|
$this->assertResponseContains('Antwort bearbeiten');
|
||||||
|
$this->assertResponseContains('Tipfehler');
|
||||||
|
|
||||||
|
$this->cookie('plenario_pid', self::PID);
|
||||||
|
$this->post("/p/{$poll->join_code}/edit", ['slide_id' => $slide->id, 'text' => ' Tippfehler ']);
|
||||||
|
$this->assertRedirect(['_name' => 'participate', 'code' => $poll->join_code]);
|
||||||
|
$this->assertFlashMessage('Deine Antwort wurde geändert.');
|
||||||
|
$this->assertSame(1, $responses->find()->count());
|
||||||
|
$this->assertSame('Tippfehler', $responses->find()->firstOrFail()->text_value);
|
||||||
|
|
||||||
|
// An open answer cannot be emptied.
|
||||||
|
$this->cookie('plenario_pid', self::PID);
|
||||||
|
$this->post("/p/{$poll->join_code}/edit", ['slide_id' => $slide->id, 'text' => ' ']);
|
||||||
|
$this->assertFlashMessage('Bitte gib eine Antwort ein.');
|
||||||
|
$this->assertSame('Tippfehler', $responses->find()->firstOrFail()->text_value);
|
||||||
|
|
||||||
|
// Without an own answer there is nothing to edit (and nothing is created).
|
||||||
|
$this->cookie('plenario_pid', str_repeat('f', 32));
|
||||||
|
$this->post("/p/{$poll->join_code}/edit", ['slide_id' => $slide->id, 'text' => 'Neu']);
|
||||||
|
$this->assertFlashMessage('Du hast hier noch nicht geantwortet.');
|
||||||
|
$this->assertSame(1, $responses->find()->count());
|
||||||
|
|
||||||
|
// Closed: no form, no change.
|
||||||
|
TableRegistry::getTableLocator()->get('Slides')->updateAll(['is_voting_open' => false], ['id' => $slide->id]);
|
||||||
|
$this->cookie('plenario_pid', self::PID);
|
||||||
|
$this->get('/p/' . $poll->join_code);
|
||||||
|
$this->assertResponseNotContains('Antwort bearbeiten');
|
||||||
|
$this->cookie('plenario_pid', self::PID);
|
||||||
|
$this->post("/p/{$poll->join_code}/edit", ['slide_id' => $slide->id, 'text' => 'Zu spät']);
|
||||||
|
$this->assertFlashMessage('Die Abstimmung zu dieser Frage ist geschlossen.');
|
||||||
|
$this->assertSame('Tippfehler', $responses->find()->firstOrFail()->text_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testChoiceAnswersCannotBeEdited(): void
|
||||||
|
{
|
||||||
|
[$poll] = $this->createPoll();
|
||||||
|
$slide = $this->createSlide($poll, Slide::TYPE_CHOICE);
|
||||||
|
$this->goLive($poll, $slide);
|
||||||
|
|
||||||
|
$this->cookie('plenario_pid', self::PID);
|
||||||
|
$this->post("/p/{$poll->join_code}/vote", ['slide_id' => $slide->id, 'option_id' => $slide->slide_options[0]->id]);
|
||||||
|
$this->cookie('plenario_pid', self::PID);
|
||||||
|
$this->post("/p/{$poll->join_code}/edit", ['slide_id' => $slide->id, 'text' => 'Hack']);
|
||||||
|
$this->assertFlashMessage('Diese Antwort kann nicht mehr geändert werden.');
|
||||||
|
$this->assertFalse(TableRegistry::getTableLocator()->get('Responses')->exists(['text_value' => 'Hack']));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -267,7 +267,7 @@ class ScaleCommentsTest extends TestCase
|
|||||||
$this->assertResponseContains('Kommentar bearbeiten');
|
$this->assertResponseContains('Kommentar bearbeiten');
|
||||||
$this->assertResponseContains('Sehr <gut>');
|
$this->assertResponseContains('Sehr <gut>');
|
||||||
|
|
||||||
$this->post('/p/' . $poll->join_code . '/comment', ['slide_id' => $slide->id, 'comment' => ' Sehr gut! ', 'value' => '1']);
|
$this->post('/p/' . $poll->join_code . '/edit', ['slide_id' => $slide->id, 'comment' => ' Sehr gut! ', 'value' => '1']);
|
||||||
$this->assertRedirect('/p/' . $poll->join_code);
|
$this->assertRedirect('/p/' . $poll->join_code);
|
||||||
$this->assertFlashMessage('Dein Kommentar wurde gespeichert.');
|
$this->assertFlashMessage('Dein Kommentar wurde gespeichert.');
|
||||||
|
|
||||||
@@ -279,8 +279,8 @@ class ScaleCommentsTest extends TestCase
|
|||||||
$this->assertSame(4, $rows->first()->numeric_value, 'the rating stays unchanged');
|
$this->assertSame(4, $rows->first()->numeric_value, 'the rating stays unchanged');
|
||||||
|
|
||||||
// Repeating the request is harmless, an empty comment removes it.
|
// Repeating the request is harmless, an empty comment removes it.
|
||||||
$this->post('/p/' . $poll->join_code . '/comment', ['slide_id' => $slide->id, 'comment' => ' Sehr gut! ']);
|
$this->post('/p/' . $poll->join_code . '/edit', ['slide_id' => $slide->id, 'comment' => ' Sehr gut! ']);
|
||||||
$this->post('/p/' . $poll->join_code . '/comment', ['slide_id' => $slide->id, 'comment' => '']);
|
$this->post('/p/' . $poll->join_code . '/edit', ['slide_id' => $slide->id, 'comment' => '']);
|
||||||
$this->assertFlashMessage('Dein Kommentar wurde entfernt.');
|
$this->assertFlashMessage('Dein Kommentar wurde entfernt.');
|
||||||
$this->assertNull($this->slidesTable()->Responses->get($rows->first()->id)->text_value);
|
$this->assertNull($this->slidesTable()->Responses->get($rows->first()->id)->text_value);
|
||||||
}
|
}
|
||||||
@@ -293,7 +293,7 @@ class ScaleCommentsTest extends TestCase
|
|||||||
$this->get('/p/' . $poll->join_code);
|
$this->get('/p/' . $poll->join_code);
|
||||||
$this->assertResponseContains('Kommentar hinzufügen');
|
$this->assertResponseContains('Kommentar hinzufügen');
|
||||||
|
|
||||||
$this->post('/p/' . $poll->join_code . '/comment', ['slide_id' => $slide->id, 'comment' => 'Nachgereicht']);
|
$this->post('/p/' . $poll->join_code . '/edit', ['slide_id' => $slide->id, 'comment' => 'Nachgereicht']);
|
||||||
$row = $this->slidesTable()->Responses->find()
|
$row = $this->slidesTable()->Responses->find()
|
||||||
->where(['slide_id' => $slide->id, 'participant_hash' => $this->hash('b', $poll)])
|
->where(['slide_id' => $slide->id, 'participant_hash' => $this->hash('b', $poll)])
|
||||||
->firstOrFail();
|
->firstOrFail();
|
||||||
@@ -309,7 +309,7 @@ class ScaleCommentsTest extends TestCase
|
|||||||
$this->get('/p/' . $poll->join_code);
|
$this->get('/p/' . $poll->join_code);
|
||||||
$this->assertResponseNotContains('Kommentar bearbeiten');
|
$this->assertResponseNotContains('Kommentar bearbeiten');
|
||||||
|
|
||||||
$this->post('/p/' . $poll->join_code . '/comment', ['slide_id' => $slide->id, 'comment' => 'Zu spät']);
|
$this->post('/p/' . $poll->join_code . '/edit', ['slide_id' => $slide->id, 'comment' => 'Zu spät']);
|
||||||
$this->assertFlashMessage('Die Abstimmung zu dieser Frage ist geschlossen.');
|
$this->assertFlashMessage('Die Abstimmung zu dieser Frage ist geschlossen.');
|
||||||
$this->assertSame('Sehr <gut>', $this->slidesTable()->Responses->find()
|
$this->assertSame('Sehr <gut>', $this->slidesTable()->Responses->find()
|
||||||
->where(['slide_id' => $slide->id, 'participant_hash' => $this->hash('a', $poll)])
|
->where(['slide_id' => $slide->id, 'participant_hash' => $this->hash('a', $poll)])
|
||||||
@@ -322,7 +322,7 @@ class ScaleCommentsTest extends TestCase
|
|||||||
$votes = new VoteService();
|
$votes = new VoteService();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$votes->editComment($poll, $slide, $this->hash('z', $poll), ['comment' => 'Ohne Bewertung']);
|
$votes->editText($poll, $slide, $this->hash('z', $poll), ['comment' => 'Ohne Bewertung']);
|
||||||
$this->fail('Expected VoteException');
|
$this->fail('Expected VoteException');
|
||||||
} catch (VoteException $e) {
|
} catch (VoteException $e) {
|
||||||
$this->assertSame('Bitte gib zuerst deine Bewertung ab.', $e->getMessage());
|
$this->assertSame('Bitte gib zuerst deine Bewertung ab.', $e->getMessage());
|
||||||
@@ -333,6 +333,6 @@ class ScaleCommentsTest extends TestCase
|
|||||||
$poll = $this->goLive($poll, $plain);
|
$poll = $this->goLive($poll, $plain);
|
||||||
$votes->submit($poll, $plain, $this->hash('a', $poll), ['value' => 3]);
|
$votes->submit($poll, $plain, $this->hash('a', $poll), ['value' => 3]);
|
||||||
$this->expectException(VoteException::class);
|
$this->expectException(VoteException::class);
|
||||||
$votes->editComment($poll, $plain, $this->hash('a', $poll), ['comment' => 'Eingeschmuggelt']);
|
$votes->editText($poll, $plain, $this->hash('a', $poll), ['comment' => 'Eingeschmuggelt']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user