Let scale slides hide the average or the distribution on stage
The average is now the headline of a scale result and the distribution a compact detail below it. Two new settings (show_average, show_distribution) hide either part in the presentation; evaluation and PDF stay complete. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
239599e6a3
commit
bf16ac0d3b
8 files changed
+183
-15
No files matched your search
@@ -232,6 +232,10 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures
|
|||||||
Teilnehmende wählen Sterne (Radios in DOM-Reihenfolge 1..n, Füllung per CSS `:has()`), der State enthält `results.stars`;
|
Teilnehmende wählen Sterne (Radios in DOM-Reihenfolge 1..n, Füllung per CSS `:has()`), der State enthält `results.stars`;
|
||||||
`Results.stars` in `plenario.js` zeigt den Durchschnitt als teilweise gefüllte Sterne und die Verteilung als Balken 5 → 1.
|
`Results.stars` in `plenario.js` zeigt den Durchschnitt als teilweise gefüllte Sterne und die Verteilung als Balken 5 → 1.
|
||||||
Text-Ausgabe (Auswertung, PDF) über `Slide::ratingText()` (`★★★★☆`), barrierearm über `element/rating`.
|
Text-Ausgabe (Auswertung, PDF) über `Slide::ratingText()` (`★★★★☆`), barrierearm über `element/rating`.
|
||||||
|
- **Skala-Teile in der Präsentation** (Settings `show_average` / `show_distribution`, Standard an): blenden Durchschnitt
|
||||||
|
bzw. Verteilung nur auf der Bühne (Presenter/Embed) aus; das JSON bleibt vollständig und trägt `results.showAverage` /
|
||||||
|
`showDistribution`, `Results.scaleLayout()` in `plenario.js` ordnet die Teile an (ohne Durchschnitt bleibt die Anzahl
|
||||||
|
sichtbar, ohne Verteilung wandern die Beschriftungen zum Durchschnitt). Auswertung und PDF zeigen immer alles.
|
||||||
- **Antwort nachträglich bearbeiten** (gegen Tippfehler, `VoteService::hasEditableText()`): Antwort einer offenen Frage
|
- **Antwort nachträglich bearbeiten** (gegen Tippfehler, `VoteService::hasEditableText()`): Antwort einer offenen Frage
|
||||||
(darf nicht leer werden) bzw. Kommentar einer Skala (ändern, ergänzen, leeren; die Bewertung bleibt unveränderlich),
|
(darf nicht leer werden) bzw. Kommentar einer Skala (ändern, ergänzen, leeren; die Bewertung bleibt unveränderlich),
|
||||||
nur solange die Abstimmung offen ist. `participate:edit` → `VoteService::editText()`, gleiche Vorbedingungen wie
|
nur solange die Abstimmung offen ist. `participate:edit` → `VoteService::editText()`, gleiche Vorbedingungen wie
|
||||||
|
|||||||
@@ -95,10 +95,13 @@ class Slide extends Entity
|
|||||||
// comment_ratings: show the rating next to each comment in the presentation
|
// comment_ratings: show the rating next to each comment in the presentation
|
||||||
// (time per comment depends on its length, see Comments.delay() in plenario.js)
|
// (time per comment depends on its length, see Comments.delay() in plenario.js)
|
||||||
// style: numbers or stars (SCALE_*), stars always start at scale_min = 1
|
// style: numbers or stars (SCALE_*), stars always start at scale_min = 1
|
||||||
|
// show_average / show_distribution: parts of the result shown in the presentation (presenter/embed);
|
||||||
|
// the evaluation in the admin area and the PDF export always contain both
|
||||||
self::TYPE_SCALE => [
|
self::TYPE_SCALE => [
|
||||||
'style' => self::SCALE_NUMBERS,
|
'style' => self::SCALE_NUMBERS,
|
||||||
'scale_min' => 1, 'scale_max' => 5, 'min_label' => '', 'max_label' => '', 'private' => false,
|
'scale_min' => 1, 'scale_max' => 5, 'min_label' => '', 'max_label' => '', 'private' => false,
|
||||||
'comments' => false, 'comment_ratings' => false,
|
'comments' => false, 'comment_ratings' => false,
|
||||||
|
'show_average' => true, 'show_distribution' => true,
|
||||||
],
|
],
|
||||||
self::TYPE_CONTENT => [],
|
self::TYPE_CONTENT => [],
|
||||||
// time_limit in seconds, 0 = no limit (presenter ends the quiz)
|
// time_limit in seconds, 0 = no limit (presenter ends the quiz)
|
||||||
|
|||||||
@@ -162,6 +162,8 @@ class SlidesTable extends Table
|
|||||||
$settings['private'] = filter_var($input['private'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
$settings['private'] = filter_var($input['private'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||||
$settings['comments'] = filter_var($input['comments'] ?? 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);
|
$settings['comment_ratings'] = filter_var($input['comment_ratings'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||||
|
$settings['show_average'] = filter_var($input['show_average'] ?? true, FILTER_VALIDATE_BOOLEAN);
|
||||||
|
$settings['show_distribution'] = filter_var($input['show_distribution'] ?? true, FILTER_VALIDATE_BOOLEAN);
|
||||||
break;
|
break;
|
||||||
case Slide::TYPE_QUIZ:
|
case Slide::TYPE_QUIZ:
|
||||||
$limit = (int)($input['time_limit'] ?? $settings['time_limit']);
|
$limit = (int)($input['time_limit'] ?? $settings['time_limit']);
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ use Cake\ORM\Locator\LocatorAwareTrait;
|
|||||||
* 'min', 'max', 'minLabel', 'maxLabel', 'private' (bool), 'stars' (bool: star rating, min = 1);
|
* 'min', 'max', 'minLabel', 'maxLabel', 'private' (bool), 'stars' (bool: star rating, min = 1);
|
||||||
* 'comments' => [['id', 'text', 'value' (int|null)]] oldest first (only with the comment field, else [];
|
* 'comments' => [['id', 'text', 'value' (int|null)]] oldest first (only with the comment field, else [];
|
||||||
* 'value' is null unless the setting comment_ratings is on;
|
* 'value' is null unless the setting comment_ratings is on;
|
||||||
|
* 'showAverage', 'showDistribution' (bool): parts shown in the presentation (settings
|
||||||
|
* show_average/show_distribution, the data is always complete);
|
||||||
* presentation only: participants never get results of scale slides, see PollStateService);
|
* presentation only: participants never get results of scale slides, see PollStateService);
|
||||||
* open/scale with 'private' (anonymous/internal feedback): contents are included for the
|
* 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;
|
* presenter/embed, which start with the results hidden and may show them on demand;
|
||||||
@@ -335,6 +337,8 @@ class ResultsService
|
|||||||
return $this->scaleResults($slide) + [
|
return $this->scaleResults($slide) + [
|
||||||
'private' => $slide->isPrivate(),
|
'private' => $slide->isPrivate(),
|
||||||
'comments' => $comments,
|
'comments' => $comments,
|
||||||
|
'showAverage' => (bool)$slide->setting('show_average'),
|
||||||
|
'showDistribution' => (bool)$slide->setting('show_distribution'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,6 +180,20 @@ $optionsError = $slide->getError('options_text');
|
|||||||
'placeholder' => __('z. B. sehr'), 'value' => $settings['max_label'],
|
'placeholder' => __('z. B. sehr'), 'value' => $settings['max_label'],
|
||||||
]) ?>
|
]) ?>
|
||||||
</div>
|
</div>
|
||||||
|
<fieldset class="scale-parts">
|
||||||
|
<legend><?= __('In der Präsentation zeigen') ?></legend>
|
||||||
|
<?= $this->Form->control('settings.show_average', [
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'label' => __('Durchschnitt'),
|
||||||
|
'checked' => (bool)$settings['show_average'],
|
||||||
|
]) ?>
|
||||||
|
<?= $this->Form->control('settings.show_distribution', [
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'label' => __('Verteilung der Stimmen'),
|
||||||
|
'checked' => (bool)$settings['show_distribution'],
|
||||||
|
]) ?>
|
||||||
|
<p class="hint"><?= __('Ohne beides zeigt die Präsentation nur die Anzahl der Bewertungen (und ggf. die Kommentare). Die Auswertung in der Verwaltung und der PDF-Export enthalten immer alles.') ?></p>
|
||||||
|
</fieldset>
|
||||||
<?= $this->Form->control('settings.comments', [
|
<?= $this->Form->control('settings.comments', [
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
'label' => __('Kommentarfeld anzeigen (Teilnehmende können ihre Bewertung optional begründen)'),
|
'label' => __('Kommentarfeld anzeigen (Teilnehmende können ihre Bewertung optional begründen)'),
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Test\TestCase\Controller;
|
||||||
|
|
||||||
|
use App\Model\Entity\Slide;
|
||||||
|
use App\Model\Table\SlidesTable;
|
||||||
|
use App\Service\VoteService;
|
||||||
|
use App\Test\TestCase\PlenarioTestTrait;
|
||||||
|
use Cake\TestSuite\IntegrationTestTrait;
|
||||||
|
use Cake\TestSuite\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scale slides can hide the average and/or the distribution in the presentation.
|
||||||
|
*/
|
||||||
|
class ScalePartsTest extends TestCase
|
||||||
|
{
|
||||||
|
use IntegrationTestTrait;
|
||||||
|
use PlenarioTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
protected array $fixtures = ['app.Polls', 'app.Slides', 'app.SlideOptions', 'app.Responses'];
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->enableCsrfToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $settings Extra settings
|
||||||
|
* @return array<string, mixed> Presenter results
|
||||||
|
*/
|
||||||
|
protected function presenterResults(array $settings): array
|
||||||
|
{
|
||||||
|
[$poll, $token] = $this->createPoll();
|
||||||
|
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => $settings + ['scale_min' => 1, 'scale_max' => 5]]);
|
||||||
|
$poll = $this->goLive($poll, $slide);
|
||||||
|
(new VoteService())->submit($poll, $slide, VoteService::participantHash(str_repeat('a', 32), $poll->id), ['value' => 4]);
|
||||||
|
|
||||||
|
$this->get("/admin/$token/state");
|
||||||
|
|
||||||
|
return json_decode((string)$this->_response->getBody(), true)['results'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testBothPartsAreShownByDefault(): void
|
||||||
|
{
|
||||||
|
$settings = SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, []);
|
||||||
|
$this->assertTrue($settings['show_average']);
|
||||||
|
$this->assertTrue($settings['show_distribution']);
|
||||||
|
|
||||||
|
$results = $this->presenterResults([]);
|
||||||
|
$this->assertTrue($results['showAverage']);
|
||||||
|
$this->assertTrue($results['showDistribution']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPartsCanBeHidden(): void
|
||||||
|
{
|
||||||
|
$settings = SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, ['show_average' => '0', 'show_distribution' => '0']);
|
||||||
|
$this->assertFalse($settings['show_average']);
|
||||||
|
$this->assertFalse($settings['show_distribution']);
|
||||||
|
|
||||||
|
$results = $this->presenterResults(['show_average' => false, 'show_distribution' => false]);
|
||||||
|
$this->assertFalse($results['showAverage']);
|
||||||
|
$this->assertFalse($results['showDistribution']);
|
||||||
|
// The data stays complete (evaluation, PDF), only the presentation hides it.
|
||||||
|
$this->assertEqualsWithDelta(4.0, $results['average'], 0.001);
|
||||||
|
$this->assertSame(1, $results['participants']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFormSavesParts(): void
|
||||||
|
{
|
||||||
|
[$poll, $token] = $this->createPoll();
|
||||||
|
$this->get("/admin/$token/slides/add?type=scale");
|
||||||
|
$this->assertResponseContains('name="settings[show_average]"');
|
||||||
|
$this->assertResponseContains('name="settings[show_distribution]"');
|
||||||
|
|
||||||
|
$this->post("/admin/$token/slides/add?type=scale", [
|
||||||
|
'type' => 'scale',
|
||||||
|
'question' => 'Wie fandest du den Abend?',
|
||||||
|
'settings' => ['scale_min' => '1', 'scale_max' => '5', 'show_average' => '1', 'show_distribution' => '0'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$slide = $this->slidesTable()->find()->where(['poll_id' => $poll->id])->firstOrFail();
|
||||||
|
$this->assertTrue($slide->setting('show_average'));
|
||||||
|
$this->assertFalse($slide->setting('show_distribution'));
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
-10
@@ -309,6 +309,8 @@ textarea { resize: vertical; }
|
|||||||
.export-choice legend, .scale-style legend { font-weight: 600; margin-bottom: 4px; }
|
.export-choice legend, .scale-style legend { font-weight: 600; margin-bottom: 4px; }
|
||||||
.export-choice label, .scale-style label { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 2px solid var(--border); border-radius: 8px; cursor: pointer; }
|
.export-choice label, .scale-style label { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 2px solid var(--border); border-radius: 8px; cursor: pointer; }
|
||||||
.export-choice label:has(input:checked), .scale-style label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
|
.export-choice label:has(input:checked), .scale-style label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
|
||||||
|
.scale-parts { border: 0; padding: 0; margin: 0 0 12px; }
|
||||||
|
.scale-parts legend { font-weight: 600; margin-bottom: 4px; }
|
||||||
.export-choice input, .scale-style input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--primary); }
|
.export-choice input, .scale-style input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--primary); }
|
||||||
.export-choice strong { display: block; }
|
.export-choice strong { display: block; }
|
||||||
.export-choice .hint { display: block; margin: 2px 0 0; }
|
.export-choice .hint { display: block; margin: 2px 0 0; }
|
||||||
@@ -458,6 +460,11 @@ textarea { resize: vertical; }
|
|||||||
.star-meter__fill { position: absolute; top: 0; left: 0; overflow: hidden; color: var(--star); transition: width .6s ease; }
|
.star-meter__fill { position: absolute; top: 0; left: 0; overflow: hidden; color: var(--star); transition: width .6s ease; }
|
||||||
.bar--star .bar__fill { background: var(--star); }
|
.bar--star .bar__fill { background: var(--star); }
|
||||||
.stars-legend { margin: 10px 0 0; font-size: .85rem; color: var(--muted); }
|
.stars-legend { margin: 10px 0 0; font-size: .85rem; color: var(--muted); }
|
||||||
|
.average .stars-legend { flex-basis: 100%; margin: 0; }
|
||||||
|
/* parts hidden per slide (show_average/show_distribution): only the number of ratings remains */
|
||||||
|
.scale-count { margin: 0 0 10px; font-size: .85rem; font-weight: 700; color: var(--muted); }
|
||||||
|
.scale-total { display: flex; flex-direction: column; align-items: center; gap: .2em; padding: 16px 20px; background: var(--surface-2); border-radius: 14px; color: var(--muted); }
|
||||||
|
.scale-total strong { font-size: 3em; font-weight: 800; line-height: 1; color: var(--c1); font-variant-numeric: tabular-nums; }
|
||||||
|
|
||||||
.cloud { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .2em .6em; line-height: 1.15; padding: 8px; }
|
.cloud { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .2em .6em; line-height: 1.15; padding: 8px; }
|
||||||
.cloud__word { font-weight: 800; color: var(--c0); transition: font-size .6s ease; }
|
.cloud__word { font-weight: 800; color: var(--c0); transition: font-size .6s ease; }
|
||||||
@@ -651,16 +658,24 @@ body.present {
|
|||||||
.stage--content .stage__description { color: var(--text); font-size: clamp(1.3rem, 2.6vw, 2.2rem); }
|
.stage--content .stage__description { color: var(--text); font-size: clamp(1.3rem, 2.6vw, 2.2rem); }
|
||||||
.stage__results { font-size: clamp(1rem, 1.8vw, 1.5rem); margin-top: 2vh; }
|
.stage__results { font-size: clamp(1rem, 1.8vw, 1.5rem); margin-top: 2vh; }
|
||||||
.stage .bar__track { height: 1.1em; }
|
.stage .bar__track { height: 1.1em; }
|
||||||
.stage .columns { height: 22vh; }
|
/* scale on stage: the average is the headline, the distribution a compact detail below */
|
||||||
.stage .average { padding: 1vh 2vw; gap: 1vh 3vw; margin-bottom: 1.5vh; background: rgba(var(--tint), .06); }
|
.stage .columns { height: 13vh; gap: .6vw; font-size: .75em; }
|
||||||
.stage .average__value strong { font-size: clamp(2.6rem, 5vw, 4.5rem); }
|
.stage .average { padding: 2vh 2.5vw; gap: 1.5vh 4vw; margin-bottom: 1.5vh; background: rgba(var(--tint), .06); }
|
||||||
.stage .average__of { font-size: clamp(1.2rem, 2vw, 1.8rem); }
|
.stage .average__value strong { font-size: clamp(3.4rem, 7.5vw, 7rem); }
|
||||||
.stage .average__label, .stage .average__count, .stage .average__ends { font-size: clamp(.85rem, 1.2vw, 1.1rem); }
|
.stage .average__of { font-size: clamp(1.4rem, 2.8vw, 2.6rem); }
|
||||||
.stage .average__track { height: .7em; box-shadow: none; background: linear-gradient(90deg, var(--surface-2), var(--c1)); }
|
.stage .average__label, .stage .average__count, .stage .average__ends { font-size: clamp(.95rem, 1.5vw, 1.4rem); }
|
||||||
.stage .average__ends { margin-top: 4px; }
|
.stage .average__track { height: 1em; box-shadow: none; background: linear-gradient(90deg, var(--surface-2), var(--c1)); }
|
||||||
.stage .star-meter { font-size: clamp(2.4rem, 5.5vw, 5rem); }
|
.stage .average__ends { margin-top: 6px; }
|
||||||
.stage .bars--stars { gap: 1.2vh; }
|
.stage .star-meter { font-size: clamp(3rem, 7.5vw, 7rem); }
|
||||||
.stage .stars-legend { font-size: clamp(.85rem, 1.2vw, 1.1rem); }
|
.stage .bars--stars { gap: .8vh; font-size: .75em; }
|
||||||
|
.stage .bars--stars .bar__track { height: .8em; }
|
||||||
|
.stage .stars-legend, .stage .scale-count, .stage .scale__labels { font-size: clamp(.85rem, 1.2vw, 1.1rem); }
|
||||||
|
.stage .scale-total { padding: 3vh 2.5vw; background: rgba(var(--tint), .06); }
|
||||||
|
.stage .scale-total strong { font-size: clamp(3.4rem, 7.5vw, 7rem); }
|
||||||
|
/* average without distribution: room for an even bigger figure */
|
||||||
|
.stage .scale-results--average .average { padding: 4vh 3vw; }
|
||||||
|
.stage .scale-results--average .average__value strong { font-size: clamp(4.5rem, 10vw, 9rem); }
|
||||||
|
.stage .scale-results--average .star-meter { font-size: clamp(4rem, 10vw, 9rem); }
|
||||||
.stage .cloud { font-size: clamp(1.4rem, 2.6vw, 2.6rem); }
|
.stage .cloud { font-size: clamp(1.4rem, 2.6vw, 2.6rem); }
|
||||||
.stage .answers { columns: 340px; }
|
.stage .answers { columns: 340px; }
|
||||||
.stage .quiz-timer { font-size: clamp(3rem, 7vw, 6rem); }
|
.stage .quiz-timer { font-size: clamp(3rem, 7vw, 6rem); }
|
||||||
|
|||||||
+41
-5
@@ -542,7 +542,10 @@
|
|||||||
var max = Math.max.apply(null, results.buckets.map(function (b) { return b.count; }).concat([1]));
|
var max = Math.max.apply(null, results.buckets.map(function (b) { return b.count; }).concat([1]));
|
||||||
var total = results.buckets.reduce(function (sum, b) { return sum + b.count; }, 0);
|
var total = results.buckets.reduce(function (sum, b) { return sum + b.count; }, 0);
|
||||||
var hasAverage = results.average !== null;
|
var hasAverage = results.average !== null;
|
||||||
var nearest = hasAverage ? Math.round(results.average) : null;
|
var showAverage = results.showAverage !== false;
|
||||||
|
var showDistribution = results.showDistribution !== false;
|
||||||
|
// Highlight the column of the average only where the average is shown.
|
||||||
|
var nearest = hasAverage && showAverage ? Math.round(results.average) : null;
|
||||||
var columns = el('div', { class: 'columns' }, results.buckets.map(function (bucket) {
|
var columns = el('div', { class: 'columns' }, results.buckets.map(function (bucket) {
|
||||||
return el('div', { class: 'column' + (bucket.value === nearest ? ' column--avg' : '') }, [
|
return el('div', { class: 'column' + (bucket.value === nearest ? ' column--avg' : '') }, [
|
||||||
el('div', { class: 'column__count', text: String(bucket.count) }),
|
el('div', { class: 'column__count', text: String(bucket.count) }),
|
||||||
@@ -569,9 +572,10 @@
|
|||||||
el('div', { class: 'average__track' }, [
|
el('div', { class: 'average__track' }, [
|
||||||
hasAverage ? el('div', { class: 'average__marker', style: 'left:' + position + '%' }) : null
|
hasAverage ? el('div', { class: 'average__marker', style: 'left:' + position + '%' }) : null
|
||||||
]),
|
]),
|
||||||
|
// Without the distribution the labels of both ends move here.
|
||||||
el('div', { class: 'average__ends' }, [
|
el('div', { class: 'average__ends' }, [
|
||||||
el('span', { text: String(results.min) }),
|
el('span', { text: results.min + (!showDistribution && results.minLabel ? ' · ' + results.minLabel : '') }),
|
||||||
el('span', { text: String(results.max) })
|
el('span', { text: (!showDistribution && results.maxLabel ? results.maxLabel + ' · ' : '') + results.max })
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
var average = el('div', { class: 'average' }, [
|
var average = el('div', { class: 'average' }, [
|
||||||
@@ -586,7 +590,29 @@
|
|||||||
gauge
|
gauge
|
||||||
]);
|
]);
|
||||||
var comments = results.comments && results.comments.length ? Comments.render(results.comments, String) : null;
|
var comments = results.comments && results.comments.length ? Comments.render(results.comments, String) : null;
|
||||||
return el('div', { class: 'scale-results' }, [average, columns, labels, comments]);
|
return Results.scaleLayout(total, showAverage ? average : null, showDistribution ? [columns, labels] : null, comments);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Arranges the parts of a scale result according to showAverage/showDistribution:
|
||||||
|
* without the average the number of ratings stays visible above the distribution,
|
||||||
|
* without both it is the only figure (besides the comments).
|
||||||
|
*/
|
||||||
|
scaleLayout: function (total, average, distribution, comments) {
|
||||||
|
var countText = total === 1 ? 'Bewertung' : 'Bewertungen';
|
||||||
|
var parts = [];
|
||||||
|
if (average) {
|
||||||
|
parts.push(average);
|
||||||
|
} else if (distribution) {
|
||||||
|
parts.push(el('p', { class: 'scale-count', text: total + ' ' + countText }));
|
||||||
|
} else {
|
||||||
|
parts.push(el('div', { class: 'scale-total' }, [
|
||||||
|
el('strong', { text: String(total) }),
|
||||||
|
el('span', { text: countText })
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
var modifier = average && !distribution ? ' scale-results--average' : '';
|
||||||
|
return el('div', { class: 'scale-results' + modifier }, parts.concat(distribution || [], [comments]));
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -644,7 +670,17 @@
|
|||||||
+ ' (' + value + ' von ' + results.max + ')';
|
+ ' (' + value + ' von ' + results.max + ')';
|
||||||
})
|
})
|
||||||
: null;
|
: null;
|
||||||
return el('div', { class: 'scale-results' }, [average, bars, labels, comments]);
|
var showDistribution = results.showDistribution !== false;
|
||||||
|
if (!showDistribution && labels) {
|
||||||
|
// Without the distribution the legend stays with the average.
|
||||||
|
average.appendChild(labels);
|
||||||
|
}
|
||||||
|
return Results.scaleLayout(
|
||||||
|
total,
|
||||||
|
results.showAverage !== false ? average : null,
|
||||||
|
showDistribution ? [bars, labels] : null,
|
||||||
|
comments
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user