19 declare(strict_types=1);
44 $this->main_tpl = $DIC->ui()->mainTemplate();
46 $local_dic = QuestionPoolDIC::dic();
47 $this->questionrepository = $local_dic[
'question.general_properties.repository'];
52 $cmd = $this->
ctrl->getCmd(self::CMD_SHOW_FORM);
53 $nextClass = $this->
ctrl->getNextClass($this);
56 case 'ilasshintpagegui':
64 $forwarder->forward();
68 $this->
tabs->setTabActive(
'tst_question_hints_tab');
80 $form->setValuesByPost();
81 } elseif ($this->request_data_collector->isset(
'hint_id') && (
int) $this->request_data_collector->raw(
'hint_id')) {
84 if (!$questionHint->load((
int) $this->request_data_collector->raw(
'hint_id'))) {
85 $this->main_tpl->setOnScreenMessage(
87 'invalid hint id given: ' . $this->request_data_collector->string(
'hint_id'),
98 $this->main_tpl->setContent($form->getHTML());
104 if ($this->request_data_collector->isset(
'hint_id')) {
105 $questionHint->load((
int) $this->request_data_collector->int(
'hint_id'));
107 $hintJustCreated =
false;
110 $questionHint->setQuestionId($this->question_obj->getId());
112 $questionHint->setIndex(
116 $hintJustCreated =
true;
120 if ($form->checkInput()) {
121 $questionHint->setText($form->getInput(
'hint_text'));
122 $questionHint->setPoints($form->getInput(
'hint_points'));
124 $questionHint->save();
125 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tst_question_hints_form_saved_msg'),
true);
127 if (!$this->question_obj->isAdditionalContentEditingModePageObject()) {
128 $this->question_obj->updateTimestamp();
131 if ($this->question_gui->needsSyncQuery()) {
132 $this->
ctrl->redirectByClass(
133 ilAssQuestionHintsGUI::class,
138 if ($hintJustCreated && $this->question_obj->isAdditionalContentEditingModePageObject()) {
139 $this->
ctrl->setParameterByClass(ilAssHintPageGUI::class,
'hint_id', $questionHint->getId());
140 $this->
ctrl->redirectByClass(ilAssHintPageGUI::class,
'edit');
146 $this->main_tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_question_hints_form_invalid_msg'));
153 $this->
ctrl->redirectByClass(ilAssQuestionHintsGUI::class);
159 $form->setTableWidth(
'100%');
161 if (!$this->question_obj->isAdditionalContentEditingModePageObject()) {
164 $areaInp =
new ilTextAreaInputGUI($this->
lng->txt(
'tst_question_hints_form_label_hint_text'),
'hint_text');
166 $areaInp->setRows(10);
167 $areaInp->setCols(80);
169 if (!$this->question_obj->getPreventRteUsage()) {
170 $areaInp->setUseRte(
true);
175 $areaInp->setRTESupport($this->question_obj->getId(),
'qpl',
'assessment');
177 $form->addItem($areaInp);
182 $numInp =
new ilNumberInputGUI($this->
lng->txt(
'tst_question_hints_form_label_hint_points'),
'hint_points');
183 $numInp->allowDecimals(
true);
184 $numInp->setRequired(
true);
187 $form->addItem($numInp);
192 $form->setTitle(sprintf(
193 $this->
lng->txt(
'tst_question_hints_form_header_edit'),
194 $questionHint->getIndex(),
195 $this->question_obj->getTitleForHTMLOutput()
199 $form->addItem($hiddenInp);
201 if (!$this->question_obj->isAdditionalContentEditingModePageObject()) {
202 $areaInp->setValue($questionHint->getText());
205 $numInp->setValue((
string) $questionHint->getPoints());
207 $hiddenInp->setValue((
string) $questionHint->getId());
210 $form->setTitle(sprintf(
211 $this->
lng->txt(
'tst_question_hints_form_header_create'),
212 $this->question_obj->getTitleForHTMLOutput()
216 if ($this->question_obj->isAdditionalContentEditingModePageObject()) {
217 if ($questionHint instanceof ilAssQuestionHint) {
218 $saveCmdLabel = $this->
lng->txt(
'tst_question_hints_form_cmd_save_points');
220 $saveCmdLabel = $this->
lng->txt(
'tst_question_hints_form_cmd_save_points_and_edit_page');
223 $saveCmdLabel = $this->
lng->txt(
'tst_question_hints_form_cmd_save');
226 $form->setFormAction($this->
ctrl->getFormAction($this));
228 $form->addCommandButton(self::CMD_SAVE_FORM, $saveCmdLabel);
229 $form->addCommandButton(self::CMD_CANCEL_FORM, $this->
lng->txt(
'cancel'));
GeneralQuestionPropertiesRepository $questionrepository
const PRESENTATION_MODE_AUTHOR
presentation mode for authoring
const CMD_SHOW_LIST
command constants
__construct(assQuestionGUI $questionGUI)
static getNextIndexByQuestionId($questionId)
determines the next index to be used for a new hint that is to be added to the list of existing hints...
buildForm(ilAssQuestionHint $questionHint=null)
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
ilGlobalTemplateInterface $main_tpl
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.
showFormCmd(ilPropertyFormGUI $form=null)