Merge pull request 'Make the comment rotation interval configurable' (#23) from feature/comment-interval into main
Reviewed-on: #23
This commit was merged in pull request #23.
This commit is contained in:
commit
ec0b13cae8
7 files changed
+66
-5
No files matched your search
@@ -181,7 +181,8 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures
|
||||
- **Skala-Kommentare** (Setting `comments`, `Slide::hasComments()`): optionales Feld `comment`, gespeichert als `text_value`
|
||||
in derselben Zeile wie `numeric_value` (ohne Setting wird es ignoriert). Öffentliche Skalen liefern im Presenter-/Embed-State
|
||||
`results.comments` (Teilnehmende bekommen immer `[]`, `PollStateService::participantResults()`)
|
||||
(älteste zuerst, je `id`, `text`, `value` – `value` nur mit Setting `comment_ratings`, sonst `null`); `Comments` in `plenario.js` blättert sie automatisch durch („Kommentar X von N“,
|
||||
(älteste zuerst, je `id`, `text`, `value` – `value` nur mit Setting `comment_ratings`, sonst `null`); `Comments` in `plenario.js` blättert sie automatisch durch (Sekunden pro Kommentar = Setting `comment_interval`, Auswahl
|
||||
`Slide::COMMENT_INTERVALS`, Standard 8, im State als `results.commentInterval`; „Kommentar X von N“,
|
||||
vor/zurück/Pause, Zustand übersteht das Neu-Rendern beim Polling). Bei internem Feedback erscheinen sie erst,
|
||||
wenn der Presenter die Ergebnisse einblendet.
|
||||
|
||||
|
||||
@@ -55,6 +55,13 @@ class Slide extends Entity
|
||||
*/
|
||||
public const QUIZ_TIME_LIMITS = [0, 10, 15, 20, 30, 45, 60, 90, 120, 180, 300];
|
||||
|
||||
/**
|
||||
* Selectable seconds per comment when the comments of a scale rotate in the presentation.
|
||||
*
|
||||
* @var list<int>
|
||||
*/
|
||||
public const COMMENT_INTERVALS = [3, 5, 8, 10, 15, 20, 30, 45, 60];
|
||||
|
||||
/**
|
||||
* Q&A stages, see qaStage(): participants submit questions, then upvote
|
||||
* them, then the presenter discusses them one by one (most upvoted first).
|
||||
@@ -87,9 +94,10 @@ class Slide extends Entity
|
||||
// private: internal feedback, ratings only visible in the admin area (never on the stage)
|
||||
// comments: optional comment field, comments rotate in the presentation (unless private)
|
||||
// comment_ratings: show the rating next to each comment in the presentation
|
||||
// comment_interval: seconds per comment while they rotate (one of COMMENT_INTERVALS)
|
||||
self::TYPE_SCALE => [
|
||||
'scale_min' => 1, 'scale_max' => 5, 'min_label' => '', 'max_label' => '', 'private' => false,
|
||||
'comments' => false, 'comment_ratings' => false,
|
||||
'comments' => false, 'comment_ratings' => false, 'comment_interval' => 8,
|
||||
],
|
||||
self::TYPE_CONTENT => [],
|
||||
// time_limit in seconds, 0 = no limit (presenter ends the quiz)
|
||||
|
||||
@@ -159,6 +159,10 @@ class SlidesTable extends Table
|
||||
$settings['private'] = filter_var($input['private'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
$settings['comments'] = filter_var($input['comments'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
$settings['comment_ratings'] = filter_var($input['comment_ratings'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
$interval = (int)($input['comment_interval'] ?? $settings['comment_interval']);
|
||||
if (in_array($interval, Slide::COMMENT_INTERVALS, true)) {
|
||||
$settings['comment_interval'] = $interval;
|
||||
}
|
||||
break;
|
||||
case Slide::TYPE_QUIZ:
|
||||
$limit = (int)($input['time_limit'] ?? $settings['time_limit']);
|
||||
|
||||
@@ -22,6 +22,7 @@ use Cake\ORM\Locator\LocatorAwareTrait;
|
||||
* 'comments' => [['id', 'text', 'value' (int|null)]] oldest first (only with the comment field, else [];
|
||||
* 'value' is null unless the setting comment_ratings is on;
|
||||
* presentation only, emptied for participants in PollStateService);
|
||||
* 'commentInterval' => int seconds per comment while they rotate;
|
||||
* open/scale with 'private' (anonymous/internal feedback): contents are included for the
|
||||
* presenter/embed, which start with the results hidden and may show them on demand;
|
||||
* participants never get results of these slides, the public PDF strips them (withoutContents())
|
||||
@@ -322,7 +323,11 @@ class ResultsService
|
||||
];
|
||||
}
|
||||
|
||||
return $this->scaleResults($slide) + ['private' => $slide->isPrivate(), 'comments' => $comments];
|
||||
return $this->scaleResults($slide) + [
|
||||
'private' => $slide->isPrivate(),
|
||||
'comments' => $comments,
|
||||
'commentInterval' => (int)$slide->setting('comment_interval'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -172,6 +172,15 @@ $optionsError = $slide->getError('options_text');
|
||||
'checked' => (bool)$settings['comments'],
|
||||
]) ?>
|
||||
<p class="hint"><?= __('Die Kommentare laufen in der Präsentation nacheinander durch (nicht bei den Teilnehmenden). Bei internem Feedback erst, wenn du die Ergebnisse einblendest.') ?></p>
|
||||
<?= $this->Form->control('settings.comment_interval', [
|
||||
'type' => 'select',
|
||||
'options' => array_combine(
|
||||
\App\Model\Entity\Slide::COMMENT_INTERVALS,
|
||||
array_map(fn(int $s) => __n('{0} Sekunde', '{0} Sekunden', $s, $s), \App\Model\Entity\Slide::COMMENT_INTERVALS),
|
||||
),
|
||||
'label' => __('Nächster Kommentar nach'),
|
||||
'value' => $settings['comment_interval'],
|
||||
]) ?>
|
||||
<?= $this->Form->control('settings.comment_ratings', [
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Bewertung beim Kommentar in der Präsentation anzeigen'),
|
||||
|
||||
@@ -154,6 +154,29 @@ class ScaleCommentsTest extends TestCase
|
||||
$this->assertSame([4, 3], array_column($this->presenterResults($token)['comments'], 'value'));
|
||||
}
|
||||
|
||||
public function testCommentIntervalIsConfigurable(): void
|
||||
{
|
||||
$this->assertSame(8, SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, [])['comment_interval']);
|
||||
$this->assertSame(15, SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, ['comment_interval' => '15'])['comment_interval']);
|
||||
$this->assertSame(8, SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, ['comment_interval' => '7'])['comment_interval']);
|
||||
$this->assertSame(8, SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, ['comment_interval' => '-1'])['comment_interval']);
|
||||
|
||||
[, $token] = $this->scaleWithComments(['comment_interval' => 20]);
|
||||
$this->assertSame(20, $this->presenterResults($token)['commentInterval']);
|
||||
|
||||
$this->get("/admin/$token");
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testFormShowsCommentInterval(): void
|
||||
{
|
||||
[, $token] = $this->createPoll();
|
||||
$this->get("/admin/$token/slides/add?type=scale");
|
||||
|
||||
$this->assertResponseContains('name="settings[comment_interval]"');
|
||||
$this->assertResponseContains('15 Sekunden');
|
||||
}
|
||||
|
||||
public function testParticipantsNeverSeeComments(): void
|
||||
{
|
||||
[$poll] = $this->scaleWithComments();
|
||||
|
||||
+13
-2
@@ -304,7 +304,11 @@
|
||||
items: [],
|
||||
node: null,
|
||||
|
||||
render: function (items) {
|
||||
/**
|
||||
* @param {Array} items comments, oldest first
|
||||
* @param {number} [seconds] time per comment (slide setting), default 8
|
||||
*/
|
||||
render: function (items, seconds) {
|
||||
// A different first comment means a different slide (or a reset): start over.
|
||||
var key = String(items[0].id);
|
||||
if (key !== Comments.key) {
|
||||
@@ -312,6 +316,13 @@
|
||||
Comments.index = 0;
|
||||
Comments.paused = false;
|
||||
}
|
||||
var intervalMs = seconds > 0 ? seconds * 1000 : 8000;
|
||||
if (intervalMs !== Comments.intervalMs) {
|
||||
// Setting changed (or another slide): apply it right away.
|
||||
Comments.intervalMs = intervalMs;
|
||||
clearInterval(Comments.timer);
|
||||
Comments.timer = null;
|
||||
}
|
||||
Comments.items = items;
|
||||
Comments.index = Math.min(Comments.index, items.length - 1);
|
||||
|
||||
@@ -518,7 +529,7 @@
|
||||
]),
|
||||
gauge
|
||||
]);
|
||||
var comments = results.comments && results.comments.length ? Comments.render(results.comments) : null;
|
||||
var comments = results.comments && results.comments.length ? Comments.render(results.comments, results.commentInterval) : null;
|
||||
return el('div', { class: 'scale-results' }, [average, columns, labels, comments]);
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user