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>
39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?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
|
|
{
|
|
}
|
|
}
|