Make Q&A upvote budget a share of the questions
CI / Deploy / test (push) Successful in 58s
CI / Deploy / deploy (push) Skipped

The fixed number of votes per person does not fit varying question
counts. The budget is now `upvote_share` percent of the questions
(rounded up, at least one), so it grows with the number of questions.
A migration converts existing Q&A slides (no voting stays off, others
get 25 %).

On the stage the voting step no longer lists the questions but points
participants to their devices.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-11 23:53:32 +01:00
1 parent 3762b880cb
commit 575fb8649d
14 files changed
+171 -76

No files matched your search

@@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
use Migrations\BaseMigration;
/**
* Q&A slides: the fixed number of upvotes per person (`max_upvotes`) becomes a share of the
* questions (`upvote_share`, percent). "No upvotes" stays off, every other value becomes the default 25 %.
*/
class ConvertQaUpvotesToShare extends BaseMigration
{
/**
* @return void
*/
public function up(): void
{
$rows = $this->fetchAll("SELECT id, settings FROM slides WHERE type = 'qa'");
foreach ($rows as $row) {
$settings = json_decode((string)$row['settings'], true);
if (!is_array($settings) || !array_key_exists('max_upvotes', $settings)) {
continue;
}
$settings['upvote_share'] = (int)$settings['max_upvotes'] === 0 ? 0 : 25;
unset($settings['max_upvotes']);
$this->getAdapter()->execute(
'UPDATE slides SET settings = ? WHERE id = ?',
[json_encode($settings, JSON_UNESCAPED_UNICODE), $row['id']],
);
}
}
/**
* @return void
*/
public function down(): void
{
}
}