Offer reset when slides were touched, not only when answers exist
The dashboard and per-slide reset buttons only checked for responses, so a started quiz without votes, a closed slide or a running presentation could not be reset. Check Slide::isFresh() and Poll::isStarted() as well. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0eb054ed29
commit
9c6a19f0de
6 files changed
+81
-10
No files matched your search
@@ -61,7 +61,12 @@ class AdminController extends AdminAppController
|
||||
|
||||
$hasPrepared = $this->Responses->hasPrepared($this->poll->id);
|
||||
|
||||
$this->set(compact('slides', 'responseCounts', 'hasPrepared', 'typeLabels', 'typeDescriptions', 'joinUrl', 'embedKey'));
|
||||
// Answers are not the only thing a reset undoes: a started quiz, closed slides or a running presentation too.
|
||||
$canReset = $responseCounts !== []
|
||||
|| $this->poll->isStarted()
|
||||
|| array_filter($slides, fn(Slide $slide) => !$slide->isFresh()) !== [];
|
||||
|
||||
$this->set(compact('slides', 'responseCounts', 'canReset', 'hasPrepared', 'typeLabels', 'typeDescriptions', 'joinUrl', 'embedKey'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -140,6 +140,14 @@ class Poll extends Entity
|
||||
$this->embed_seen_at = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool Live or paused, i.e. not in the state notStarted() sets
|
||||
*/
|
||||
public function isStarted(): bool
|
||||
{
|
||||
return $this->current_slide_id !== null || $this->paused_slide_id !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool Paused after a slide had been live (not: not started yet)
|
||||
*/
|
||||
|
||||
@@ -450,6 +450,21 @@ class Slide extends Entity
|
||||
$this->focus_response_id = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the slide is in the state startFresh() sets (nothing started, closed or discussed yet).
|
||||
* A reset has nothing to do for such a slide unless it has answers.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isFresh(): bool
|
||||
{
|
||||
return $this->is_voting_open === !$this->isQuiz()
|
||||
&& $this->voting_started_at === null
|
||||
&& $this->voting_ends_at === null
|
||||
&& $this->stage === ($this->isQa() ? self::QA_COLLECT : null)
|
||||
&& $this->focus_response_id === null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens or closes voting. Opening a quiz that is not running (re)starts its
|
||||
* voting window and timer; opening a running quiz changes nothing.
|
||||
|
||||
Reference in new issue
Block a user