Hide Q&A upvote counts until voting ends
A live ranking on the stage swayed the vote. During the vote stage the presenter now gets the questions in submission order without counts, only the total of votes cast. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
891e3cb174
commit
759e15390e
5 files changed
+21
-11
No files matched your search
@@ -40,7 +40,8 @@ use Cake\ORM\Locator\LocatorAwareTrait;
|
||||
* - 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);
|
||||
* during 'vote' only [['id', 'text']] in submission order (no counts while voting is open),
|
||||
* 'focusId' (question being discussed|null), 'focusIndex' (0-based position in questions|null).
|
||||
* Presenter only – participants get their own view, see PollStateService::qaState().
|
||||
*/
|
||||
@@ -215,6 +216,12 @@ class ResultsService
|
||||
protected function qa(Slide $slide): array
|
||||
{
|
||||
$questions = (new QaService())->rankedQuestions($slide);
|
||||
$upvotes = array_sum(array_column($questions, 'votes'));
|
||||
if ($slide->qaStage() === Slide::QA_VOTE) {
|
||||
// A live ranking on the stage would sway the vote: submission order, no counts until voting ends.
|
||||
usort($questions, fn($a, $b) => $a['id'] <=> $b['id']);
|
||||
$questions = array_map(fn($q) => ['id' => $q['id'], 'text' => $q['text']], $questions);
|
||||
}
|
||||
$focusIndex = null;
|
||||
foreach ($questions as $index => $question) {
|
||||
if ($question['id'] === $slide->focus_response_id) {
|
||||
@@ -227,7 +234,7 @@ class ResultsService
|
||||
'stages' => $slide->qaStages(),
|
||||
'maxUpvotes' => (int)$slide->setting('max_upvotes'),
|
||||
'maxPerQuestion' => $slide->qaUpvotesPerQuestion(),
|
||||
'upvotes' => array_sum(array_column($questions, 'votes')),
|
||||
'upvotes' => $upvotes,
|
||||
'questions' => $questions,
|
||||
'focusId' => $focusIndex === null ? null : $slide->focus_response_id,
|
||||
'focusIndex' => $focusIndex,
|
||||
|
||||
Reference in new issue
Block a user