Add internal feedback and comments to scale slides
- Setting "private": distribution and average are only shown in the
admin evaluation page and CSV export, the stage shows just the count.
- Setting "comments": optional comment field for participants; on public
scales the comments rotate on the results ("Kommentar X von N") with
previous/next/pause controls.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a138425ab0
commit
238797ecfd
15 files changed
+665
-23
No files matched your search
@@ -19,7 +19,10 @@ use Cake\ORM\Locator\LocatorAwareTrait;
|
||||
* - open: 'answers' => [['text', 'created']] newest first, 'private' (bool);
|
||||
* private (anonymous feedback): 'answers' is always empty, texts only via answers()
|
||||
* - scale: 'buckets' => [['value', 'count', 'percent']], 'average' => float|null,
|
||||
* 'min', 'max', 'minLabel', 'maxLabel'
|
||||
* 'min', 'max', 'minLabel', 'maxLabel', 'private' (bool);
|
||||
* 'comments' => [['id', 'text', 'value']] oldest first (only with the comment field, else []);
|
||||
* private (internal feedback): 'buckets' and 'comments' are always empty and 'average' null,
|
||||
* ratings and comments only via scaleResults() / comments()
|
||||
* - quiz: 'phase' (ready|running|finished), 'timeLimit' (s, 0 = manual), 'remaining' (s|null),
|
||||
* 'revealed' (bool), 'options' => [['id', 'label']] while not finished;
|
||||
* once finished additionally per option 'count', 'percent', 'correct' (bool)
|
||||
@@ -307,6 +310,65 @@ class ResultsService
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function scale(Slide $slide): array
|
||||
{
|
||||
if (!$slide->isPrivate()) {
|
||||
return $this->scaleResults($slide) + [
|
||||
'private' => false,
|
||||
'comments' => $slide->hasComments() ? $this->comments($slide, self::MAX_ANSWERS) : [],
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'buckets' => [],
|
||||
'average' => null,
|
||||
'min' => (int)$slide->setting('scale_min'),
|
||||
'max' => (int)$slide->setting('scale_max'),
|
||||
'minLabel' => (string)$slide->setting('min_label'),
|
||||
'maxLabel' => (string)$slide->setting('max_label'),
|
||||
'private' => true,
|
||||
'comments' => [],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Comments of a scale with their rating, oldest first – also of private slides,
|
||||
* so the unfiltered call is only for the admin area.
|
||||
*
|
||||
* @param \App\Model\Entity\Slide $slide Scale slide
|
||||
* @param int|null $limit Max. comments (the newest ones), null = all
|
||||
* @return list<array{id: int, text: string, value: int, created: string}>
|
||||
*/
|
||||
public function comments(Slide $slide, ?int $limit = null): array
|
||||
{
|
||||
$query = $this->Responses->find()
|
||||
->select(['id', 'text_value', 'numeric_value', 'created'])
|
||||
->where(['slide_id' => $slide->id, 'text_value IS NOT' => null, 'numeric_value IS NOT' => null])
|
||||
->orderBy(['id' => 'DESC']);
|
||||
if ($limit !== null) {
|
||||
$query->limit($limit);
|
||||
}
|
||||
|
||||
$comments = [];
|
||||
foreach ($query->all() as $row) {
|
||||
$comments[] = [
|
||||
'id' => (int)$row->id,
|
||||
'text' => (string)$row->text_value,
|
||||
'value' => (int)$row->numeric_value,
|
||||
'created' => $row->created->toIso8601String(),
|
||||
];
|
||||
}
|
||||
|
||||
return array_reverse($comments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Distribution and average of a scale – also of private slides,
|
||||
* so only for the admin area (never for the presenter screen or participants).
|
||||
*
|
||||
* @param \App\Model\Entity\Slide $slide Scale slide
|
||||
* @return array{buckets: list<array{value: int, count: int, percent: float|int}>, average: float|null, min: int, max: int, minLabel: string, maxLabel: string}
|
||||
*/
|
||||
public function scaleResults(Slide $slide): array
|
||||
{
|
||||
$min = (int)$slide->setting('scale_min');
|
||||
$max = (int)$slide->setting('scale_max');
|
||||
|
||||
Reference in new issue
Block a user