Allow Q&A rounds without upvotes and limit upvotes per question
- max_upvotes = 0 disables upvoting: the voting stage is skipped (collect -> discuss), questions are discussed in submission order - new setting max_upvotes_per_question caps a participant's upvotes on a single question (0 = no limit besides max_upvotes) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3e44ded107
commit
bc86ec2db6
16 files changed
+235
-38
No files matched your search
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
namespace App\Test\TestCase\Controller;
|
||||
|
||||
use App\Model\Entity\Slide;
|
||||
use App\Service\QaService;
|
||||
use App\Service\VoteService;
|
||||
use App\Test\TestCase\PlenarioTestTrait;
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
@@ -79,6 +80,38 @@ class QaSlideTest extends TestCase
|
||||
$this->assertResponseContains('max. 5 Upvotes pro Person');
|
||||
}
|
||||
|
||||
public function testSwitchingOffUpvotesSkipsTheVotingStage(): void
|
||||
{
|
||||
[$poll, $token] = $this->createPoll();
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_QA, ['settings' => ['max_upvotes' => 2]]);
|
||||
$this->goLive($poll, $slide);
|
||||
(new QaService())->setStage($slide, Slide::QA_VOTE);
|
||||
|
||||
$this->get("/admin/$token/slides/{$slide->id}/edit");
|
||||
$this->assertResponseContains('keine – ohne Abstimmung');
|
||||
$this->assertResponseContains('Höchstens pro Frage');
|
||||
|
||||
// Switched off while voting: the round continues with the discussion.
|
||||
$this->post("/admin/$token/slides/{$slide->id}/edit", [
|
||||
'question' => $slide->question,
|
||||
'settings' => ['max_upvotes' => '0', 'max_upvotes_per_question' => '0'],
|
||||
]);
|
||||
$this->assertRedirect();
|
||||
$slide = $this->slidesTable()->get($slide->id);
|
||||
$this->assertSame([0, Slide::QA_DISCUSS, false], [$slide->setting('max_upvotes'), $slide->qaStage(), $slide->is_voting_open]);
|
||||
|
||||
$this->get("/admin/$token");
|
||||
$this->assertResponseContains('ohne Upvotes');
|
||||
|
||||
// Back to collecting, V goes straight to discussing; "vote" is rejected.
|
||||
$state = $this->control($token, ['action' => 'stage', 'stage' => 'collect']);
|
||||
$this->assertSame(['collect', 'discuss'], $state['results']['stages']);
|
||||
$state = $this->control($token, ['action' => 'toggle']);
|
||||
$this->assertSame('discuss', $state['results']['stage']);
|
||||
$this->post("/admin/$token/control", ['action' => 'stage', 'stage' => 'vote']);
|
||||
$this->assertResponseCode(400);
|
||||
}
|
||||
|
||||
public function testFullRoundTrip(): void
|
||||
{
|
||||
[$poll, $token] = $this->createPoll();
|
||||
|
||||
Reference in new issue
Block a user