Allow Q&A rounds without upvotes and limit upvotes per question #37
No files matched your search
@@ -156,6 +156,10 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures
|
|||||||
(gegen Dubletten, eigene markiert), aber noch keine Upvotes.
|
(gegen Dubletten, eigene markiert), aber noch keine Upvotes.
|
||||||
`vote`: Upvotes auf fremde Fragen, Budget = Setting `max_upvotes` pro Person, frei verteilbar (auch mehrere auf eine Frage,
|
`vote`: Upvotes auf fremde Fragen, Budget = Setting `max_upvotes` pro Person, frei verteilbar (auch mehrere auf eine Frage,
|
||||||
je Upvote eine Zeile), `vote=remove` nimmt eine Stimme der Frage zurück; im State `qa.upvoted` = {Frage-id: eigene Stimmen}.
|
je Upvote eine Zeile), `vote=remove` nimmt eine Stimme der Frage zurück; im State `qa.upvoted` = {Frage-id: eigene Stimmen}.
|
||||||
|
Setting `max_upvotes_per_question` begrenzt die eigenen Stimmen je Frage (0 = nur durch `max_upvotes` begrenzt,
|
||||||
|
effektiv `Slide::qaUpvotesPerQuestion()`, State `maxPerQuestion`). `max_upvotes = 0` = ohne Upvotes: es gibt keine Phase `vote`
|
||||||
|
(`Slide::qaStages()` = collect → discuss, im Presenter-JSON `results.stages`), besprochen wird in Eingangsreihenfolge;
|
||||||
|
wird es während `vote` auf 0 gesetzt, springt `SlidesController::saveSlide()` nach `discuss`.
|
||||||
Setting `allow_self_upvote` (Standard aus, für Themen-Priorisierung) erlaubt Stimmen auf eigene Fragen aus demselben Budget
|
Setting `allow_self_upvote` (Standard aus, für Themen-Priorisierung) erlaubt Stimmen auf eigene Fragen aus demselben Budget
|
||||||
(State `qa.allowSelfUpvote`); bewusst aus, weil anonym sonst Selbstvermarktung die Rangfolge bestimmt;
|
(State `qa.allowSelfUpvote`); bewusst aus, weil anonym sonst Selbstvermarktung die Rangfolge bestimmt;
|
||||||
Teilnehmende sehen alle Fragen in Eingangsreihenfolge **ohne** Zählung. `discuss`: Abstimmung zu, Fragen nach Upvotes
|
Teilnehmende sehen alle Fragen in Eingangsreihenfolge **ohne** Zählung. `discuss`: Abstimmung zu, Fragen nach Upvotes
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Controller;
|
|||||||
|
|
||||||
use App\Model\Entity\Slide;
|
use App\Model\Entity\Slide;
|
||||||
use App\Model\Table\SlidesTable;
|
use App\Model\Table\SlidesTable;
|
||||||
|
use App\Service\QaService;
|
||||||
use App\Service\ResetService;
|
use App\Service\ResetService;
|
||||||
use App\Service\ResultsService;
|
use App\Service\ResultsService;
|
||||||
use App\Service\YouTubeService;
|
use App\Service\YouTubeService;
|
||||||
@@ -300,6 +301,10 @@ class SlidesController extends AdminAppController
|
|||||||
if ($slide->type === Slide::TYPE_CHOICE || $slide->isQuiz() || $slide->isOrder()) {
|
if ($slide->type === Slide::TYPE_CHOICE || $slide->isQuiz() || $slide->isOrder()) {
|
||||||
$this->Slides->syncOptions($slide, $labels, $correct);
|
$this->Slides->syncOptions($slide, $labels, $correct);
|
||||||
}
|
}
|
||||||
|
if ($slide->isQa() && $slide->qaStage() === Slide::QA_VOTE && !$slide->hasQaUpvotes()) {
|
||||||
|
// Upvotes were switched off while voting: continue with the discussion.
|
||||||
|
(new QaService())->setStage($slide, Slide::QA_DISCUSS);
|
||||||
|
}
|
||||||
if ($youtube['warning'] !== null) {
|
if ($youtube['warning'] !== null) {
|
||||||
$this->Flash->warning($youtube['warning']);
|
$this->Flash->warning($youtube['warning']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,9 +104,10 @@ class Slide extends Entity
|
|||||||
self::TYPE_QUIZ => ['time_limit' => 30],
|
self::TYPE_QUIZ => ['time_limit' => 30],
|
||||||
// url as entered, video_id parsed from it, start in seconds
|
// url as entered, video_id parsed from it, start in seconds
|
||||||
self::TYPE_YOUTUBE => ['url' => '', 'video_id' => '', 'start' => 0, 'autoplay' => false],
|
self::TYPE_YOUTUBE => ['url' => '', 'video_id' => '', 'start' => 0, 'autoplay' => false],
|
||||||
// upvotes per participant in the voting stage (1..QA_MAX_UPVOTES);
|
// max_upvotes: upvotes per participant in the voting stage (0..QA_MAX_UPVOTES, 0 = no voting stage);
|
||||||
|
// max_upvotes_per_question: own upvotes per question (0 = no limit besides max_upvotes);
|
||||||
// allow_self_upvote: upvotes on own questions (for prioritizing topics, off by default)
|
// allow_self_upvote: upvotes on own questions (for prioritizing topics, off by default)
|
||||||
self::TYPE_QA => ['max_upvotes' => 3, 'allow_self_upvote' => false],
|
self::TYPE_QA => ['max_upvotes' => 3, 'max_upvotes_per_question' => 0, 'allow_self_upvote' => false],
|
||||||
// The correct order is the order of the slide_options (position), revealed when voting closes.
|
// The correct order is the order of the slide_options (position), revealed when voting closes.
|
||||||
self::TYPE_ORDER => [],
|
self::TYPE_ORDER => [],
|
||||||
];
|
];
|
||||||
@@ -316,6 +317,39 @@ class Slide extends Entity
|
|||||||
return in_array($this->stage, self::QA_STAGES, true) ? (string)$this->stage : self::QA_COLLECT;
|
return in_array($this->stage, self::QA_STAGES, true) ? (string)$this->stage : self::QA_COLLECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether a Q&A slide has a voting stage (setting `max_upvotes` > 0).
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasQaUpvotes(): bool
|
||||||
|
{
|
||||||
|
return (int)$this->setting('max_upvotes') > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stages of a Q&A slide in order: without upvotes the voting stage is skipped.
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public function qaStages(): array
|
||||||
|
{
|
||||||
|
return $this->hasQaUpvotes() ? self::QA_STAGES : [self::QA_COLLECT, self::QA_DISCUSS];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upvotes one participant may give a single Q&A question (never more than `max_upvotes`).
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function qaUpvotesPerQuestion(): int
|
||||||
|
{
|
||||||
|
$max = (int)$this->setting('max_upvotes');
|
||||||
|
$perQuestion = (int)$this->setting('max_upvotes_per_question');
|
||||||
|
|
||||||
|
return $perQuestion > 0 ? min($perQuestion, $max) : $max;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether a participant may answer the slide several times (word cloud: one
|
* Whether a participant may answer the slide several times (word cloud: one
|
||||||
* row per word, Q&A: questions and upvotes).
|
* row per word, Q&A: questions and upvotes).
|
||||||
|
|||||||
@@ -172,7 +172,11 @@ class SlidesTable extends Table
|
|||||||
break;
|
break;
|
||||||
case Slide::TYPE_QA:
|
case Slide::TYPE_QA:
|
||||||
$max = (int)($input['max_upvotes'] ?? $settings['max_upvotes']);
|
$max = (int)($input['max_upvotes'] ?? $settings['max_upvotes']);
|
||||||
$settings['max_upvotes'] = max(1, min(Slide::QA_MAX_UPVOTES, $max));
|
// 0 = no upvotes (no voting stage)
|
||||||
|
$settings['max_upvotes'] = max(0, min(Slide::QA_MAX_UPVOTES, $max));
|
||||||
|
$perQuestion = (int)($input['max_upvotes_per_question'] ?? $settings['max_upvotes_per_question']);
|
||||||
|
// 0 = no limit per question
|
||||||
|
$settings['max_upvotes_per_question'] = max(0, min(Slide::QA_MAX_UPVOTES, $perQuestion));
|
||||||
$settings['allow_self_upvote'] = filter_var($input['allow_self_upvote'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
$settings['allow_self_upvote'] = filter_var($input['allow_self_upvote'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||||
break;
|
break;
|
||||||
case Slide::TYPE_YOUTUBE:
|
case Slide::TYPE_YOUTUBE:
|
||||||
|
|||||||
@@ -280,10 +280,11 @@ class PollStateService
|
|||||||
* - discuss: all questions ranked with upvotes, `focusId` = question being discussed
|
* - discuss: all questions ranked with upvotes, `focusId` = question being discussed
|
||||||
* `upvoted` = own upvotes per question id (several per question are allowed),
|
* `upvoted` = own upvotes per question id (several per question are allowed),
|
||||||
* `allowSelfUpvote` = own questions may be upvoted too (setting `allow_self_upvote`).
|
* `allowSelfUpvote` = own questions may be upvoted too (setting `allow_self_upvote`).
|
||||||
|
* `maxUpvotes` = 0: no voting stage; `maxPerQuestion` = own upvotes allowed per question.
|
||||||
*
|
*
|
||||||
* @param \App\Model\Entity\Slide $slide Q&A slide
|
* @param \App\Model\Entity\Slide $slide Q&A slide
|
||||||
* @param string $participantHash Participant hash
|
* @param string $participantHash Participant hash
|
||||||
* @return array{stage: string, maxUpvotes: int, votesLeft: int, allowSelfUpvote: bool, mine: list<int>, upvoted: array<int, int>,
|
* @return array{stage: string, maxUpvotes: int, maxPerQuestion: int, votesLeft: int, allowSelfUpvote: bool, mine: list<int>, upvoted: array<int, int>,
|
||||||
* questions: list<array{id: int, text: string, votes?: int}>, focusId: int|null}
|
* questions: list<array{id: int, text: string, votes?: int}>, focusId: int|null}
|
||||||
*/
|
*/
|
||||||
public function qaState(Slide $slide, string $participantHash): array
|
public function qaState(Slide $slide, string $participantHash): array
|
||||||
@@ -305,6 +306,7 @@ class PollStateService
|
|||||||
return [
|
return [
|
||||||
'stage' => $stage,
|
'stage' => $stage,
|
||||||
'maxUpvotes' => $max,
|
'maxUpvotes' => $max,
|
||||||
|
'maxPerQuestion' => $slide->qaUpvotesPerQuestion(),
|
||||||
'votesLeft' => max(0, $max - count($own['upvotes'])),
|
'votesLeft' => max(0, $max - count($own['upvotes'])),
|
||||||
'allowSelfUpvote' => (bool)$slide->setting('allow_self_upvote'),
|
'allowSelfUpvote' => (bool)$slide->setting('allow_self_upvote'),
|
||||||
'mine' => $own['questions'],
|
'mine' => $own['questions'],
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ use InvalidArgumentException;
|
|||||||
* Stages (Slide::qaStage()):
|
* Stages (Slide::qaStage()):
|
||||||
* - collect: participants submit questions (voting open)
|
* - collect: participants submit questions (voting open)
|
||||||
* - vote: participants upvote questions of others (own ones with `allow_self_upvote`),
|
* - vote: participants upvote questions of others (own ones with `allow_self_upvote`),
|
||||||
* at most `max_upvotes` each (voting open)
|
* at most `max_upvotes` each and `max_upvotes_per_question` per question (voting open).
|
||||||
|
* Skipped with `max_upvotes` = 0 (Slide::qaStages()).
|
||||||
* - discuss: voting closed; the presenter steps through the questions, most upvoted
|
* - discuss: voting closed; the presenter steps through the questions, most upvoted
|
||||||
* first (`slides.focus_response_id` = question on screen)
|
* first (`slides.focus_response_id` = question on screen)
|
||||||
*
|
*
|
||||||
@@ -70,15 +71,15 @@ class QaService
|
|||||||
/**
|
/**
|
||||||
* Switches the stage. Collecting and voting open the slide for input,
|
* Switches the stage. Collecting and voting open the slide for input,
|
||||||
* discussing closes it and puts the top question on screen. Setting the
|
* discussing closes it and puts the top question on screen. Setting the
|
||||||
* current stage again changes nothing.
|
* current stage again changes nothing. Without upvotes there is no voting stage.
|
||||||
*
|
*
|
||||||
* @param \App\Model\Entity\Slide $slide Q&A slide
|
* @param \App\Model\Entity\Slide $slide Q&A slide
|
||||||
* @param string $stage One of Slide::QA_STAGES
|
* @param string $stage One of Slide::qaStages()
|
||||||
* @return \App\Model\Entity\Slide
|
* @return \App\Model\Entity\Slide
|
||||||
*/
|
*/
|
||||||
public function setStage(Slide $slide, string $stage): Slide
|
public function setStage(Slide $slide, string $stage): Slide
|
||||||
{
|
{
|
||||||
if (!$slide->isQa() || !in_array($stage, Slide::QA_STAGES, true)) {
|
if (!$slide->isQa() || !in_array($stage, $slide->qaStages(), true)) {
|
||||||
throw new InvalidArgumentException('Unknown Q&A stage ' . $stage);
|
throw new InvalidArgumentException('Unknown Q&A stage ' . $stage);
|
||||||
}
|
}
|
||||||
if ($slide->qaStage() === $stage && $slide->stage !== null) {
|
if ($slide->qaStage() === $stage && $slide->stage !== null) {
|
||||||
@@ -95,18 +96,19 @@ class QaService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves to the following stage (collect → vote → discuss).
|
* Moves to the following stage (collect → vote → discuss, without upvotes collect → discuss).
|
||||||
*
|
*
|
||||||
* @param \App\Model\Entity\Slide $slide Q&A slide
|
* @param \App\Model\Entity\Slide $slide Q&A slide
|
||||||
* @return bool False when already discussing
|
* @return bool False when already discussing
|
||||||
*/
|
*/
|
||||||
public function advance(Slide $slide): bool
|
public function advance(Slide $slide): bool
|
||||||
{
|
{
|
||||||
$index = (int)array_search($slide->qaStage(), Slide::QA_STAGES, true);
|
$stages = $slide->qaStages();
|
||||||
if (!isset(Slide::QA_STAGES[$index + 1])) {
|
$index = (int)array_search($slide->qaStage(), $stages, true);
|
||||||
|
if (!isset($stages[$index + 1])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->setStage($slide, Slide::QA_STAGES[$index + 1]);
|
$this->setStage($slide, $stages[$index + 1]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ use Cake\ORM\Locator\LocatorAwareTrait;
|
|||||||
* order with 'position' (1-based), 'placed' (participants who put the item at its position),
|
* order with 'position' (1-based), 'placed' (participants who put the item at its position),
|
||||||
* 'percent', plus 'correctCount' (participants with the completely correct order).
|
* 'percent', plus 'correctCount' (participants with the completely correct order).
|
||||||
* Neither the correct order nor counts are part of the result before it is revealed.
|
* Neither the correct order nor counts are part of the result before it is revealed.
|
||||||
* - qa: 'stage' (collect|vote|discuss), 'maxUpvotes', 'upvotes' (total),
|
* - qa: 'stage' (collect|vote|discuss), 'stages' (available stages in order, no 'vote' without upvotes),
|
||||||
|
* 'maxUpvotes' (per participant, 0 = no upvotes), 'maxPerQuestion' (per participant and question),
|
||||||
|
* 'upvotes' (total),
|
||||||
* 'questions' => [['id', 'text', 'votes']] most upvoted first (ties: oldest first),
|
* 'questions' => [['id', 'text', 'votes']] most upvoted first (ties: oldest first),
|
||||||
* 'focusId' (question being discussed|null), 'focusIndex' (0-based position in questions|null).
|
* 'focusId' (question being discussed|null), 'focusIndex' (0-based position in questions|null).
|
||||||
* Presenter only – participants get their own view, see PollStateService::qaState().
|
* Presenter only – participants get their own view, see PollStateService::qaState().
|
||||||
@@ -221,7 +223,9 @@ class ResultsService
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'stage' => $slide->qaStage(),
|
'stage' => $slide->qaStage(),
|
||||||
|
'stages' => $slide->qaStages(),
|
||||||
'maxUpvotes' => (int)$slide->setting('max_upvotes'),
|
'maxUpvotes' => (int)$slide->setting('max_upvotes'),
|
||||||
|
'maxPerQuestion' => $slide->qaUpvotesPerQuestion(),
|
||||||
'upvotes' => array_sum(array_column($questions, 'votes')),
|
'upvotes' => array_sum(array_column($questions, 'votes')),
|
||||||
'questions' => $questions,
|
'questions' => $questions,
|
||||||
'focusId' => $focusIndex === null ? null : $slide->focus_response_id,
|
'focusId' => $focusIndex === null ? null : $slide->focus_response_id,
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class SlideControlService
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$stage = (string)($data['stage'] ?? '');
|
$stage = (string)($data['stage'] ?? '');
|
||||||
if (!in_array($stage, Slide::QA_STAGES, true)) {
|
if (!in_array($stage, $slide->qaStages(), true)) {
|
||||||
throw new BadRequestException('Unknown stage');
|
throw new BadRequestException('Unknown stage');
|
||||||
}
|
}
|
||||||
$qa->setStage($slide, $stage);
|
$qa->setStage($slide, $stage);
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ use Cake\Utility\Security;
|
|||||||
* at most MAX_QA_QUESTIONS per participant, the same question (case-insensitive)
|
* at most MAX_QA_QUESTIONS per participant, the same question (case-insensitive)
|
||||||
* only once per slide. `vote=up|remove` + `question_id` only while voting: upvote
|
* only once per slide. `vote=up|remove` + `question_id` only while voting: upvote
|
||||||
* questions of others (own ones too with setting `allow_self_upvote`), at most
|
* questions of others (own ones too with setting `allow_self_upvote`), at most
|
||||||
* `max_upvotes` in total, freely distributed (several on one question are allowed);
|
* `max_upvotes` in total, freely distributed (several on one question are allowed,
|
||||||
|
* at most `max_upvotes_per_question` if set; `max_upvotes` = 0 means no voting stage);
|
||||||
* `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()).
|
||||||
@@ -297,6 +298,9 @@ class VoteService
|
|||||||
return [['text_value' => $text]];
|
return [['text_value' => $text]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$slide->hasQaUpvotes()) {
|
||||||
|
throw new VoteException(__('Bei dieser Fragerunde wird nicht abgestimmt.'));
|
||||||
|
}
|
||||||
if ($stage !== Slide::QA_VOTE) {
|
if ($stage !== Slide::QA_VOTE) {
|
||||||
throw new VoteException(__('Die Abstimmung über die Fragen hat noch nicht begonnen.'));
|
throw new VoteException(__('Die Abstimmung über die Fragen hat noch nicht begonnen.'));
|
||||||
}
|
}
|
||||||
@@ -324,8 +328,18 @@ class VoteService
|
|||||||
if (!$slide->setting('allow_self_upvote') && in_array($id, $own['questions'], true)) {
|
if (!$slide->setting('allow_self_upvote') && in_array($id, $own['questions'], true)) {
|
||||||
throw new VoteException(__('Deine eigene Frage kannst du nicht unterstützen.'));
|
throw new VoteException(__('Deine eigene Frage kannst du nicht unterstützen.'));
|
||||||
}
|
}
|
||||||
// Several upvotes on the same question are allowed (push important questions).
|
// Several upvotes on the same question are allowed (push important questions),
|
||||||
|
// up to the limit per question.
|
||||||
$max = (int)$slide->setting('max_upvotes');
|
$max = (int)$slide->setting('max_upvotes');
|
||||||
|
$perQuestion = $slide->qaUpvotesPerQuestion();
|
||||||
|
if ($perQuestion < $max && count(array_keys($own['upvotes'], $id, true)) >= $perQuestion) {
|
||||||
|
throw new VoteException(__n(
|
||||||
|
'Du kannst jeder Frage nur eine Stimme geben.',
|
||||||
|
'Du kannst jeder Frage höchstens {0} Stimmen geben.',
|
||||||
|
$perQuestion,
|
||||||
|
$perQuestion,
|
||||||
|
));
|
||||||
|
}
|
||||||
if (count($own['upvotes']) >= $max) {
|
if (count($own['upvotes']) >= $max) {
|
||||||
throw new VoteException(__n(
|
throw new VoteException(__n(
|
||||||
'Du hast deine Stimme schon vergeben. Nimm sie zurück, um eine andere Frage zu unterstützen.',
|
'Du hast deine Stimme schon vergeben. Nimm sie zurück, um eine andere Frage zu unterstützen.',
|
||||||
|
|||||||
@@ -211,14 +211,15 @@ $bar = function (float $percent, bool $ok = false): string {
|
|||||||
<?php if ($r['questions'] === []) : ?>
|
<?php if ($r['questions'] === []) : ?>
|
||||||
<p class="empty"><?= __('Keine Fragen eingereicht.') ?></p>
|
<p class="empty"><?= __('Keine Fragen eingereicht.') ?></p>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
|
<?php $withUpvotes = $r['maxUpvotes'] > 0; ?>
|
||||||
<table>
|
<table>
|
||||||
<thead><tr><th class="num">#</th><th><?= __('Frage') ?></th><th class="num"><?= __('Upvotes') ?></th></tr></thead>
|
<thead><tr><th class="num">#</th><th><?= __('Frage') ?></th><?php if ($withUpvotes) : ?><th class="num"><?= __('Upvotes') ?></th><?php endif; ?></tr></thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($r['questions'] as $i => $question) : ?>
|
<?php foreach ($r['questions'] as $i => $question) : ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="num"><?= $i + 1 ?>.</td>
|
<td class="num"><?= $i + 1 ?>.</td>
|
||||||
<td><?= nl2br(h($question['text'])) ?></td>
|
<td><?= nl2br(h($question['text'])) ?></td>
|
||||||
<td class="num"><?= (int)$question['votes'] ?></td>
|
<?php if ($withUpvotes) : ?><td class="num"><?= (int)$question['votes'] ?></td><?php endif; ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -96,7 +96,11 @@ $hasInternal = array_filter($slides, fn($slide) => $slide->isInteractive() && $s
|
|||||||
'collect' => __('Fragen sammeln'),
|
'collect' => __('Fragen sammeln'),
|
||||||
'vote' => __('Abstimmung läuft'),
|
'vote' => __('Abstimmung läuft'),
|
||||||
'discuss' => __('Fragen werden besprochen'),
|
'discuss' => __('Fragen werden besprochen'),
|
||||||
][$slide->qaStage()]) ?> · <?= __n('max. {0} Upvote pro Person', 'max. {0} Upvotes pro Person', (int)$slide->setting('max_upvotes'), (int)$slide->setting('max_upvotes')) ?><?= $slide->setting('allow_self_upvote') ? ' · ' . __('auch für eigene Fragen') : '' ?></span>
|
][$slide->qaStage()]) ?> · <?php if (!$slide->hasQaUpvotes()) : ?><?= __('ohne Upvotes') ?><?php else :
|
||||||
|
$maxUpvotes = (int)$slide->setting('max_upvotes');
|
||||||
|
$perQuestion = $slide->qaUpvotesPerQuestion(); ?>
|
||||||
|
<?= __n('max. {0} Upvote pro Person', 'max. {0} Upvotes pro Person', $maxUpvotes, $maxUpvotes) ?><?= $perQuestion < $maxUpvotes ? ' · ' . __n('{0} pro Frage', '{0} pro Frage', $perQuestion, $perQuestion) : '' ?><?= $slide->setting('allow_self_upvote') ? ' · ' . __('auch für eigene Fragen') : '' ?>
|
||||||
|
<?php endif; ?></span>
|
||||||
<?php elseif ($slide->isOrder() && !$slide->is_voting_open) : ?>
|
<?php elseif ($slide->isOrder() && !$slide->is_voting_open) : ?>
|
||||||
<span class="muted">· <?= __('Abstimmung geschlossen, aufgelöst') ?></span>
|
<span class="muted">· <?= __('Abstimmung geschlossen, aufgelöst') ?></span>
|
||||||
<?php elseif (!$slide->is_voting_open) : ?><span class="muted">· <?= __('Abstimmung geschlossen') ?></span><?php endif; ?>
|
<?php elseif (!$slide->is_voting_open) : ?><span class="muted">· <?= __('Abstimmung geschlossen') ?></span><?php endif; ?>
|
||||||
|
|||||||
@@ -173,19 +173,28 @@ $countdown = function (?int $remaining): string {
|
|||||||
<label for="qa-question" class="qa-form__label"><?= __('Deine Frage') ?></label>
|
<label for="qa-question" class="qa-form__label"><?= __('Deine Frage') ?></label>
|
||||||
<textarea id="qa-question" name="question" rows="3" maxlength="500" required
|
<textarea id="qa-question" name="question" rows="3" maxlength="500" required
|
||||||
aria-describedby="qa-hint" placeholder="<?= __('Was möchtest du wissen?') ?>"></textarea>
|
aria-describedby="qa-hint" placeholder="<?= __('Was möchtest du wissen?') ?>"></textarea>
|
||||||
<p class="hint" id="qa-hint"><?= __('Anonym. Du kannst mehrere Fragen stellen. Schau unten, ob deine Frage schon gestellt wurde – dann unterstützt du sie einfach beim Abstimmen, das nach der Sammelphase beginnt.') ?></p>
|
<p class="hint" id="qa-hint"><?= $qa['maxUpvotes'] > 0
|
||||||
|
? __('Anonym. Du kannst mehrere Fragen stellen. Schau unten, ob deine Frage schon gestellt wurde – dann unterstützt du sie einfach beim Abstimmen, das nach der Sammelphase beginnt.')
|
||||||
|
: __('Anonym. Du kannst mehrere Fragen stellen. Schau unten, ob deine Frage schon gestellt wurde.') ?></p>
|
||||||
<?= $this->Form->button(__('Frage einreichen'), ['class' => 'button button--primary button--block']) ?>
|
<?= $this->Form->button(__('Frage einreichen'), ['class' => 'button button--primary button--block']) ?>
|
||||||
<?= $this->Form->end() ?>
|
<?= $this->Form->end() ?>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
|
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
|
||||||
<p class="hint"><?= $qa['stage'] === 'vote'
|
<p class="hint"><?php if ($qa['stage'] === 'vote') : ?>
|
||||||
? __n(
|
<?php if ($qa['maxUpvotes'] === 1) : ?>
|
||||||
'Du hast eine Stimme: Gib sie mit „+“ der Frage, die dir am wichtigsten ist. Mit „−“ nimmst du sie zurück.',
|
<?= __('Du hast eine Stimme: Gib sie mit „+“ der Frage, die dir am wichtigsten ist. Mit „−“ nimmst du sie zurück.') ?>
|
||||||
'Du hast {0} Stimmen: Verteile sie mit „+“ auf die Fragen, die dir wichtig sind – gern auch mehrere auf eine Frage. Mit „−“ nimmst du eine zurück.',
|
<?php elseif ($qa['maxPerQuestion'] === 1) : ?>
|
||||||
$qa['maxUpvotes'],
|
<?= __('Du hast {0} Stimmen: Verteile sie mit „+“ auf die Fragen, die dir wichtig sind – jede Frage kann eine Stimme von dir bekommen. Mit „−“ nimmst du sie zurück.', $qa['maxUpvotes']) ?>
|
||||||
$qa['maxUpvotes'],
|
<?php elseif ($qa['maxPerQuestion'] < $qa['maxUpvotes']) : ?>
|
||||||
)
|
<?= __('Du hast {0} Stimmen: Verteile sie mit „+“ auf die Fragen, die dir wichtig sind – höchstens {1} auf eine Frage. Mit „−“ nimmst du eine zurück.', $qa['maxUpvotes'], $qa['maxPerQuestion']) ?>
|
||||||
: __('Die Fragen werden jetzt besprochen – die mit den meisten Stimmen zuerst.') ?></p>
|
<?php else : ?>
|
||||||
|
<?= __('Du hast {0} Stimmen: Verteile sie mit „+“ auf die Fragen, die dir wichtig sind – gern auch mehrere auf eine Frage. Mit „−“ nimmst du eine zurück.', $qa['maxUpvotes']) ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php elseif ($qa['maxUpvotes'] > 0) : ?>
|
||||||
|
<?= __('Die Fragen werden jetzt besprochen – die mit den meisten Stimmen zuerst.') ?>
|
||||||
|
<?php else : ?>
|
||||||
|
<?= __('Die Fragen werden jetzt besprochen – in der Reihenfolge, in der sie eingegangen sind.') ?>
|
||||||
|
<?php endif; ?></p>
|
||||||
<noscript><p class="muted"><?= __('Zum Abstimmen wird JavaScript benötigt.') ?></p></noscript>
|
<noscript><p class="muted"><?= __('Zum Abstimmen wird JavaScript benötigt.') ?></p></noscript>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<p class="qa-message" data-qa-message role="status" aria-live="polite"></p>
|
<p class="qa-message" data-qa-message role="status" aria-live="polite"></p>
|
||||||
|
|||||||
@@ -285,12 +285,20 @@ $optionsError = $slide->getError('options_text');
|
|||||||
?>
|
?>
|
||||||
<?= $this->Form->control('settings.max_upvotes', [
|
<?= $this->Form->control('settings.max_upvotes', [
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'options' => $upvoteOptions,
|
'options' => [0 => __('keine – ohne Abstimmung')] + $upvoteOptions,
|
||||||
'label' => __('Upvotes (Stimmen) pro Person'),
|
'label' => __('Upvotes (Stimmen) pro Person'),
|
||||||
'value' => $settings['max_upvotes'],
|
'value' => $settings['max_upvotes'],
|
||||||
'aria-describedby' => 'qa-upvotes-hint',
|
'aria-describedby' => 'qa-upvotes-hint',
|
||||||
]) ?>
|
]) ?>
|
||||||
<p class="hint" id="qa-upvotes-hint"><?= __('So viele Stimmen hat jede Person beim Abstimmen. Sie lassen sich frei auf Fragen anderer verteilen – mehrere auf eine Frage geben ihr mehr Gewicht.') ?></p>
|
<p class="hint" id="qa-upvotes-hint"><?= __('So viele Stimmen hat jede Person beim Abstimmen. Sie lassen sich auf Fragen anderer verteilen. Mit „keine“ entfällt die Abstimmung: Nach dem Sammeln werden die Fragen in der Reihenfolge besprochen, in der sie eingegangen sind.') ?></p>
|
||||||
|
<?= $this->Form->control('settings.max_upvotes_per_question', [
|
||||||
|
'type' => 'select',
|
||||||
|
'options' => [0 => __('unbegrenzt (bis alle Stimmen vergeben sind)')] + $upvoteOptions,
|
||||||
|
'label' => __('Höchstens pro Frage'),
|
||||||
|
'value' => $settings['max_upvotes_per_question'],
|
||||||
|
'aria-describedby' => 'qa-per-question-hint',
|
||||||
|
]) ?>
|
||||||
|
<p class="hint" id="qa-per-question-hint"><?= __('So viele Stimmen darf eine Person derselben Frage geben. „1 Stimme“ heißt: jede Frage höchstens einmal unterstützen. Mehrere Stimmen auf eine Frage geben ihr mehr Gewicht.') ?></p>
|
||||||
<?= $this->Form->control('settings.allow_self_upvote', [
|
<?= $this->Form->control('settings.allow_self_upvote', [
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
'label' => __('Stimmen für eigene Fragen erlauben'),
|
'label' => __('Stimmen für eigene Fragen erlauben'),
|
||||||
@@ -298,7 +306,7 @@ $optionsError = $slide->getError('options_text');
|
|||||||
'aria-describedby' => 'qa-self-upvote-hint',
|
'aria-describedby' => 'qa-self-upvote-hint',
|
||||||
]) ?>
|
]) ?>
|
||||||
<p class="hint" id="qa-self-upvote-hint"><?= __('Sinnvoll, wenn ihr Themen priorisiert („Was besprechen wir heute?“). Bei normalen Fragerunden lieber aus: Sonst landen oft die Fragen derjenigen vorn, die alle Stimmen sich selbst geben.') ?></p>
|
<p class="hint" id="qa-self-upvote-hint"><?= __('Sinnvoll, wenn ihr Themen priorisiert („Was besprechen wir heute?“). Bei normalen Fragerunden lieber aus: Sonst landen oft die Fragen derjenigen vorn, die alle Stimmen sich selbst geben.') ?></p>
|
||||||
<p class="hint"><?= __('Ablauf in der Präsentation: 1. Fragen sammeln, 2. abstimmen, 3. besprechen – die Frage mit den meisten Upvotes zuerst. Du schaltest die Schritte selbst weiter.') ?></p>
|
<p class="hint"><?= __('Ablauf in der Präsentation: 1. Fragen sammeln, 2. abstimmen, 3. besprechen – die Frage mit den meisten Upvotes zuerst. Ohne Upvotes entfällt Schritt 2. Du schaltest die Schritte selbst weiter.') ?></p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ($slide->isInteractive() && !$slide->isQuiz() && !$slide->isQa()) : ?>
|
<?php if ($slide->isInteractive() && !$slide->isQuiz() && !$slide->isQa()) : ?>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
namespace App\Test\TestCase\Controller;
|
namespace App\Test\TestCase\Controller;
|
||||||
|
|
||||||
use App\Model\Entity\Slide;
|
use App\Model\Entity\Slide;
|
||||||
|
use App\Service\QaService;
|
||||||
use App\Service\VoteService;
|
use App\Service\VoteService;
|
||||||
use App\Test\TestCase\PlenarioTestTrait;
|
use App\Test\TestCase\PlenarioTestTrait;
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
use Cake\TestSuite\IntegrationTestTrait;
|
||||||
@@ -79,6 +80,38 @@ class QaSlideTest extends TestCase
|
|||||||
$this->assertResponseContains('max. 5 Upvotes pro Person');
|
$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
|
public function testFullRoundTrip(): void
|
||||||
{
|
{
|
||||||
[$poll, $token] = $this->createPoll();
|
[$poll, $token] = $this->createPoll();
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use App\Service\VoteException;
|
|||||||
use App\Service\VoteService;
|
use App\Service\VoteService;
|
||||||
use App\Test\TestCase\PlenarioTestTrait;
|
use App\Test\TestCase\PlenarioTestTrait;
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Q&A slides: collect questions, upvote, discuss one by one.
|
* Q&A slides: collect questions, upvote, discuss one by one.
|
||||||
@@ -76,8 +77,73 @@ class QaTest extends TestCase
|
|||||||
$this->assertSame(Slide::QA_COLLECT, $slide->qaStage());
|
$this->assertSame(Slide::QA_COLLECT, $slide->qaStage());
|
||||||
|
|
||||||
$table = $this->slidesTable();
|
$table = $this->slidesTable();
|
||||||
$this->assertSame(1, $table->patchEntity($slide, ['type' => 'qa', 'settings' => ['max_upvotes' => '0']])->setting('max_upvotes'));
|
$this->assertSame(0, $table->patchEntity($slide, ['type' => 'qa', 'settings' => ['max_upvotes' => '0']])->setting('max_upvotes'));
|
||||||
|
$this->assertSame(0, $table->patchEntity($slide, ['type' => 'qa', 'settings' => ['max_upvotes' => '-3']])->setting('max_upvotes'));
|
||||||
$this->assertSame(10, $table->patchEntity($slide, ['type' => 'qa', 'settings' => ['max_upvotes' => '99']])->setting('max_upvotes'));
|
$this->assertSame(10, $table->patchEntity($slide, ['type' => 'qa', 'settings' => ['max_upvotes' => '99']])->setting('max_upvotes'));
|
||||||
|
|
||||||
|
$this->assertSame(0, $slide->setting('max_upvotes_per_question'));
|
||||||
|
$patched = $table->patchEntity($slide, ['type' => 'qa', 'settings' => ['max_upvotes' => '5', 'max_upvotes_per_question' => '2']]);
|
||||||
|
$this->assertSame([2, 2], [$patched->setting('max_upvotes_per_question'), $patched->qaUpvotesPerQuestion()]);
|
||||||
|
$patched = $table->patchEntity($slide, ['type' => 'qa', 'settings' => ['max_upvotes' => '3', 'max_upvotes_per_question' => '99']]);
|
||||||
|
// Never more per question than in total.
|
||||||
|
$this->assertSame([10, 3], [$patched->setting('max_upvotes_per_question'), $patched->qaUpvotesPerQuestion()]);
|
||||||
|
$patched = $table->patchEntity($slide, ['type' => 'qa', 'settings' => ['max_upvotes' => '4', 'max_upvotes_per_question' => '0']]);
|
||||||
|
$this->assertSame(4, $patched->qaUpvotesPerQuestion(), '0 = no limit per question');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWithoutUpvotesThereIsNoVotingStage(): void
|
||||||
|
{
|
||||||
|
[$poll, $slide] = $this->createQa(0);
|
||||||
|
$this->assertFalse($slide->hasQaUpvotes());
|
||||||
|
$this->assertSame([Slide::QA_COLLECT, Slide::QA_DISCUSS], $slide->qaStages());
|
||||||
|
$first = $this->ask($poll, $slide, 'p1', 'Frage A');
|
||||||
|
$this->ask($poll, $slide, 'p2', 'Frage B');
|
||||||
|
$this->assertVoteFails('Bei dieser Fragerunde wird nicht abgestimmt.', fn() => $this->vote($poll, $slide, 'p2', $first));
|
||||||
|
|
||||||
|
$qa = new QaService();
|
||||||
|
try {
|
||||||
|
$qa->setStage($slide, Slide::QA_VOTE);
|
||||||
|
$this->fail('No voting stage expected');
|
||||||
|
} catch (InvalidArgumentException) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// collect → discuss, in submission order.
|
||||||
|
$this->assertTrue($qa->advance($slide));
|
||||||
|
$slide = $this->slidesTable()->get($slide->id);
|
||||||
|
$this->assertSame([Slide::QA_DISCUSS, $first, false], [$slide->qaStage(), $slide->focus_response_id, $slide->is_voting_open]);
|
||||||
|
$this->assertFalse($qa->advance($slide));
|
||||||
|
|
||||||
|
$results = (new ResultsService())->forSlide($slide);
|
||||||
|
$this->assertSame([['collect', 'discuss'], 0], [$results['stages'], $results['maxUpvotes']]);
|
||||||
|
$this->assertSame(['Frage A', 'Frage B'], array_column($results['questions'], 'text'));
|
||||||
|
$this->assertSame(0, (new PollStateService())->forParticipant($poll, 'p1')['qa']['maxUpvotes']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUpvotesPerQuestionAreLimited(): void
|
||||||
|
{
|
||||||
|
[$poll] = $this->createPoll();
|
||||||
|
$slide = $this->createSlide($poll, Slide::TYPE_QA, ['settings' => ['max_upvotes' => 3, 'max_upvotes_per_question' => 1]]);
|
||||||
|
$poll = $this->goLive($poll, $slide);
|
||||||
|
$a = $this->ask($poll, $slide, 'p1', 'Frage A');
|
||||||
|
$b = $this->ask($poll, $slide, 'p1', 'Frage B');
|
||||||
|
$slide = $this->stage($slide, Slide::QA_VOTE);
|
||||||
|
|
||||||
|
$this->vote($poll, $slide, 'p2', $a);
|
||||||
|
$this->assertVoteFails('Du kannst jeder Frage nur eine Stimme geben.', fn() => $this->vote($poll, $slide, 'p2', $a));
|
||||||
|
$this->vote($poll, $slide, 'p2', $b);
|
||||||
|
// Withdrawing frees the question again.
|
||||||
|
$this->vote($poll, $slide, 'p2', $a, 'remove');
|
||||||
|
$this->vote($poll, $slide, 'p2', $a);
|
||||||
|
|
||||||
|
$state = (new PollStateService())->forParticipant($poll, 'p2')['qa'];
|
||||||
|
$this->assertEquals([1, 1, [$a => 1, $b => 1]], [$state['maxPerQuestion'], $state['votesLeft'], $state['upvoted']]);
|
||||||
|
|
||||||
|
$this->slidesTable()->patchEntity($slide, ['type' => 'qa', 'settings' => ['max_upvotes' => 3, 'max_upvotes_per_question' => 2]]);
|
||||||
|
$this->slidesTable()->saveOrFail($slide);
|
||||||
|
$this->vote($poll, $slide, 'p2', $a);
|
||||||
|
$this->vote($poll, $slide, 'p3', $b);
|
||||||
|
$this->vote($poll, $slide, 'p3', $b);
|
||||||
|
$this->assertVoteFails('Du kannst jeder Frage höchstens 2 Stimmen geben.', fn() => $this->vote($poll, $slide, 'p3', $b));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCollectQuestionsSeveralPerParticipantWithoutDuplicates(): void
|
public function testCollectQuestionsSeveralPerParticipantWithoutDuplicates(): void
|
||||||
|
|||||||
+13
-6
@@ -743,9 +743,13 @@
|
|||||||
var onQuestion = options && options.onQuestion;
|
var onQuestion = options && options.onQuestion;
|
||||||
var questions = results.questions;
|
var questions = results.questions;
|
||||||
var maxVotes = Math.max.apply(null, questions.map(function (q) { return q.votes; }).concat([1]));
|
var maxVotes = Math.max.apply(null, questions.map(function (q) { return q.votes; }).concat([1]));
|
||||||
var children = [Qa.steps(results.stage, onStage)];
|
var children = [Qa.steps(results.stage, onStage, results.stages)];
|
||||||
|
var withVotes = results.maxUpvotes > 0;
|
||||||
|
|
||||||
function votes(question) {
|
function votes(question) {
|
||||||
|
if (!withVotes) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return el('span', {
|
return el('span', {
|
||||||
class: 'qa-votes',
|
class: 'qa-votes',
|
||||||
'aria-label': question.votes + (question.votes === 1 ? ' Stimme' : ' Stimmen'),
|
'aria-label': question.votes + (question.votes === 1 ? ' Stimme' : ' Stimmen'),
|
||||||
@@ -763,6 +767,7 @@
|
|||||||
} else if (results.stage === 'vote') {
|
} else if (results.stage === 'vote') {
|
||||||
children.push(el('p', { class: 'qa-summary', text: 'Abstimmen: jede Person hat '
|
children.push(el('p', { class: 'qa-summary', text: 'Abstimmen: jede Person hat '
|
||||||
+ results.maxUpvotes + (results.maxUpvotes === 1 ? ' Stimme' : ' Stimmen')
|
+ results.maxUpvotes + (results.maxUpvotes === 1 ? ' Stimme' : ' Stimmen')
|
||||||
|
+ (results.maxPerQuestion < results.maxUpvotes ? ' (höchstens ' + results.maxPerQuestion + ' pro Frage)' : '')
|
||||||
+ ' · bisher ' + results.upvotes + ' vergeben' }));
|
+ ' · bisher ' + results.upvotes + ' vergeben' }));
|
||||||
children.push(el('ol', { class: 'qa-list' }, questions.map(function (question) {
|
children.push(el('ol', { class: 'qa-list' }, questions.map(function (question) {
|
||||||
return el('li', { class: 'qa-item' }, [
|
return el('li', { class: 'qa-item' }, [
|
||||||
@@ -819,9 +824,9 @@
|
|||||||
var Qa = {
|
var Qa = {
|
||||||
labels: { collect: 'Fragen sammeln', vote: 'Abstimmen', discuss: 'Besprechen' },
|
labels: { collect: 'Fragen sammeln', vote: 'Abstimmen', discuss: 'Besprechen' },
|
||||||
|
|
||||||
/** Stepper of the three stages; clickable for the presenter (onStage). */
|
/** Stepper of the stages (without upvotes there is no voting stage); clickable for the presenter (onStage). */
|
||||||
steps: function (stage, onStage) {
|
steps: function (stage, onStage, stages) {
|
||||||
return el('ol', { class: 'qa-steps', 'aria-label': 'Ablauf' }, ['collect', 'vote', 'discuss'].map(function (key, i) {
|
return el('ol', { class: 'qa-steps', 'aria-label': 'Ablauf' }, (stages || ['collect', 'vote', 'discuss']).map(function (key, i) {
|
||||||
var current = key === stage;
|
var current = key === stage;
|
||||||
var label = (i + 1) + ' ' + Qa.labels[key];
|
var label = (i + 1) + ' ' + Qa.labels[key];
|
||||||
var item = onStage
|
var item = onStage
|
||||||
@@ -1430,7 +1435,7 @@
|
|||||||
'aria-label': given === 0 ? 'keine Stimme von dir' : given + (given === 1 ? ' Stimme' : ' Stimmen') + ' von dir',
|
'aria-label': given === 0 ? 'keine Stimme von dir' : given + (given === 1 ? ' Stimme' : ' Stimmen') + ' von dir',
|
||||||
text: '▲ ' + given
|
text: '▲ ' + given
|
||||||
}),
|
}),
|
||||||
button('up', '+', 'Stimme geben', qa.votesLeft === 0)
|
button('up', '+', 'Stimme geben', qa.votesLeft === 0 || given >= qa.maxPerQuestion)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
return el('li', { class: 'qa-item' + (mine ? ' is-mine' : '') + (given > 0 ? ' is-upvoted' : '') }, [
|
return el('li', { class: 'qa-item' + (mine ? ' is-mine' : '') + (given > 0 ? ' is-upvoted' : '') }, [
|
||||||
@@ -1463,7 +1468,9 @@
|
|||||||
}
|
}
|
||||||
return el('li', attrs, [
|
return el('li', attrs, [
|
||||||
el('span', { class: 'qa-item__text', text: (i < index ? '✓ ' : '') + question.text + (mine ? ' (deine Frage)' : '') }),
|
el('span', { class: 'qa-item__text', text: (i < index ? '✓ ' : '') + question.text + (mine ? ' (deine Frage)' : '') }),
|
||||||
el('span', { class: 'qa-votes', 'aria-label': question.votes + (question.votes === 1 ? ' Stimme' : ' Stimmen'), text: '▲ ' + question.votes })
|
qa.maxUpvotes > 0
|
||||||
|
? el('span', { class: 'qa-votes', 'aria-label': question.votes + (question.votes === 1 ? ' Stimme' : ' Stimmen'), text: '▲ ' + question.votes })
|
||||||
|
: null
|
||||||
]);
|
]);
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user