Add prepared questions to Q&A slides
The slide form takes questions entered beforehand (e.g. received by mail), one per line, while collecting. They are stored as regular questions with a reserved participant hash, synced idempotently, and not counted as participants. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
76d8bb3170
commit
4b5f9d92a1
7 files changed
+248
-4
No files matched your search
@@ -48,11 +48,13 @@ class SlidesController extends AdminAppController
|
||||
$optionsText = $type === Slide::TYPE_CHOICE ? "\n" : '';
|
||||
$quizOptions = [];
|
||||
$orderOptions = [];
|
||||
$preparedText = '';
|
||||
|
||||
if ($this->request->is('post')) {
|
||||
$optionsText = (string)$this->request->getData('options_text', '');
|
||||
$quizOptions = $this->postedQuizOptions();
|
||||
$orderOptions = $this->postedOrderOptions();
|
||||
$preparedText = (string)$this->request->getData('prepared_text', '');
|
||||
if ($this->saveSlide($slide, $optionsText)) {
|
||||
$this->Flash->success(__('Folie angelegt.'));
|
||||
|
||||
@@ -60,7 +62,7 @@ class SlidesController extends AdminAppController
|
||||
}
|
||||
}
|
||||
|
||||
$this->set(compact('slide', 'optionsText', 'quizOptions', 'orderOptions'));
|
||||
$this->set(compact('slide', 'optionsText', 'quizOptions', 'orderOptions', 'preparedText'));
|
||||
$this->render('form');
|
||||
|
||||
return null;
|
||||
@@ -76,11 +78,13 @@ class SlidesController extends AdminAppController
|
||||
$optionsText = implode("\n", array_map(fn($o) => $o->label, $slide->slide_options ?? []));
|
||||
$quizOptions = array_map(fn($o) => ['label' => $o->label, 'correct' => $o->is_correct], $slide->slide_options ?? []);
|
||||
$orderOptions = array_map(fn($o) => $o->label, $slide->slide_options ?? []);
|
||||
$preparedText = $slide->isQa() ? implode("\n", (new QaService())->preparedQuestions($slide)) : '';
|
||||
|
||||
if ($this->request->is(['post', 'put', 'patch'])) {
|
||||
$optionsText = (string)$this->request->getData('options_text', '');
|
||||
$quizOptions = $this->postedQuizOptions();
|
||||
$orderOptions = $this->postedOrderOptions();
|
||||
$preparedText = (string)$this->request->getData('prepared_text', $preparedText);
|
||||
if ($this->saveSlide($slide, $optionsText)) {
|
||||
$this->Flash->success(__('Folie gespeichert.'));
|
||||
|
||||
@@ -89,7 +93,7 @@ class SlidesController extends AdminAppController
|
||||
}
|
||||
|
||||
$hasResponses = $this->Slides->Responses->exists(['slide_id' => $slide->id]);
|
||||
$this->set(compact('slide', 'optionsText', 'quizOptions', 'orderOptions', 'hasResponses'));
|
||||
$this->set(compact('slide', 'optionsText', 'quizOptions', 'orderOptions', 'preparedText', 'hasResponses'));
|
||||
$this->render('form');
|
||||
|
||||
return null;
|
||||
@@ -334,6 +338,11 @@ class SlidesController extends AdminAppController
|
||||
if ($slide->type === Slide::TYPE_CHOICE || $slide->isQuiz() || $slide->isOrder()) {
|
||||
$this->Slides->syncOptions($slide, $labels, $correct);
|
||||
}
|
||||
// Without the field (stage no longer "collect") the prepared questions stay untouched.
|
||||
$prepared = $this->request->getData('prepared_text');
|
||||
if ($slide->isQa() && is_string($prepared)) {
|
||||
(new QaService())->syncPrepared($slide, QaService::parsePrepared($prepared));
|
||||
}
|
||||
if ($slide->isQa() && $slide->qaStage() === Slide::QA_VOTE && !$slide->hasQaUpvotes()) {
|
||||
// Upvotes were switched off while voting: continue with the discussion.
|
||||
(new QaService())->setStage($slide, Slide::QA_DISCUSS);
|
||||
|
||||
Reference in new issue
Block a user