Show scale results as average next to a donut chart
Average and distribution now sit side by side: a big average figure with its gauge or stars, and the distribution as a donut (CSS conic-gradient, shades of one colour, legend with percent and count). A single dropdown setting scale_view (both, average only, chart only) replaces the two checkboxes; a single part is centred. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bf16ac0d3b
commit
b3c80ab79f
8 files changed
+185
-192
No files matched your search
@@ -11,7 +11,7 @@ use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
|
||||
/**
|
||||
* Scale slides can hide the average and/or the distribution in the presentation.
|
||||
* Scale slides show average and distribution in the presentation, or only one of them (setting scale_view).
|
||||
*/
|
||||
class ScalePartsTest extends TestCase
|
||||
{
|
||||
@@ -47,44 +47,39 @@ class ScalePartsTest extends TestCase
|
||||
|
||||
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']);
|
||||
$this->assertSame(Slide::SCALE_VIEW_BOTH, SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, [])['scale_view']);
|
||||
$this->assertSame(Slide::SCALE_VIEW_BOTH, $this->presenterResults([])['view']);
|
||||
}
|
||||
|
||||
public function testPartsCanBeHidden(): void
|
||||
public function testUnknownViewFallsBackToBoth(): void
|
||||
{
|
||||
$settings = SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, ['show_average' => '0', 'show_distribution' => '0']);
|
||||
$this->assertFalse($settings['show_average']);
|
||||
$this->assertFalse($settings['show_distribution']);
|
||||
$settings = SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, ['scale_view' => 'nothing']);
|
||||
$this->assertSame(Slide::SCALE_VIEW_BOTH, $settings['scale_view']);
|
||||
}
|
||||
|
||||
$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.
|
||||
public function testOnlyOnePartKeepsTheDataComplete(): void
|
||||
{
|
||||
$results = $this->presenterResults(['scale_view' => Slide::SCALE_VIEW_CHART]);
|
||||
|
||||
$this->assertSame(Slide::SCALE_VIEW_CHART, $results['view']);
|
||||
// The data stays complete (evaluation, PDF), only the presentation hides a part.
|
||||
$this->assertEqualsWithDelta(4.0, $results['average'], 0.001);
|
||||
$this->assertSame(1, $results['participants']);
|
||||
}
|
||||
|
||||
public function testFormSavesParts(): void
|
||||
public function testFormSavesView(): 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->assertResponseContains('name="settings[scale_view]"');
|
||||
|
||||
$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'],
|
||||
'settings' => ['scale_min' => '1', 'scale_max' => '5', 'scale_view' => Slide::SCALE_VIEW_AVERAGE],
|
||||
]);
|
||||
|
||||
$slide = $this->slidesTable()->find()->where(['poll_id' => $poll->id])->firstOrFail();
|
||||
$this->assertTrue($slide->setting('show_average'));
|
||||
$this->assertFalse($slide->setting('show_distribution'));
|
||||
$this->assertSame(Slide::SCALE_VIEW_AVERAGE, $slide->setting('scale_view'));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user