19 declare(strict_types=1);
44 protected int $question_title_output_mode,
45 protected bool $autosave_enabled,
46 protected int $autosave_interval,
47 protected bool $shuffle_questions,
48 protected bool $question_hints_enabled,
49 protected bool $instant_feedback_points_enabled,
50 protected bool $instant_feedback_generic_enabled,
51 protected bool $instant_feedback_specific_enabled,
52 protected bool $instant_feedback_solution_enabled,
53 protected bool $force_instant_feedback_on_next_question,
54 protected bool $lock_answer_on_instant_feedback,
55 protected bool $lock_answer_on_next_question
68 ?array $environment =
null 70 $inputs[
'title_output'] = $f->radio($lng->
txt(
'tst_title_output'))
71 ->withOption(
'0', $lng->
txt(
'tst_title_output_full'))
72 ->withOption(
'1', $lng->
txt(
'tst_title_output_hide_points'))
73 ->withOption(
'3', $lng->
txt(
'tst_title_output_only_points'))
74 ->withOption(
'2', $lng->
txt(
'tst_title_output_no_title'))
81 $inputs[
'shuffle_questions'] = $f->checkbox(
82 $lng->
txt(
'tst_shuffle_questions'),
83 $lng->
txt(
'tst_shuffle_questions_description')
86 $inputs[
'offer_hints'] = $f->checkbox(
87 $lng->
txt(
'tst_setting_offer_hints_label'),
88 $lng->
txt(
'tst_setting_offer_hints_info')
91 if ($environment[
'participant_data_exists']) {
92 $inputs[
'shuffle_questions'] =
$inputs[
'shuffle_questions']->withDisabled(
true);
93 $inputs[
'offer_hints'] =
$inputs[
'offer_hints']->withDisabled(
true);
99 $section = $f->section(
$inputs, $lng->
txt(
'tst_presentation_properties'))
110 $trafo = $refinery->custom()->transformation(
111 static function (?array $vs): array {
114 'autosave_enabled' =>
false,
115 'autosave_interval' => self::DEFAULT_AUTOSAVE_INTERVAL
120 'autosave_enabled' =>
true,
121 'autosave_interval' => $vs[
'autosave_interval'] * 1000
125 $sub_inputs_autosave[
'autosave_interval'] = $f->numeric($lng->
txt(
'autosave_ival'), $lng->
txt(
'seconds'))
127 ->withAdditionalTransformation($refinery->int()->isGreaterThan(0))
134 $autosave_input = $f->optionalGroup(
135 $sub_inputs_autosave,
136 $lng->
txt(
'autosave'),
137 $lng->
txt(
'autosave_info')
139 ->withAdditionalTransformation($trafo);
142 return $autosave_input;
145 return $autosave_input->withValue([
'autosave_interval' => $this->
getAutosaveInterval() / 1000]);
154 $constraint = $refinery->custom()->constraint(
155 fn(?array $vs) => $vs ===
null 156 || $vs[
'enabled_feedback_types'][
'instant_feedback_specific'] ===
null 157 && $vs[
'enabled_feedback_types'][
'instant_feedback_generic'] ===
null 158 && $vs[
'enabled_feedback_types'][
'instant_feedback_points'] ===
null 159 && $vs[
'enabled_feedback_types'][
'instant_feedback_solution'] ===
null 160 && $vs[
'feedback_trigger'] ===
null 162 $vs[
'enabled_feedback_types'][
'instant_feedback_specific'] ===
true 163 || $vs[
'enabled_feedback_types'][
'instant_feedback_generic'] ===
true 164 || $vs[
'enabled_feedback_types'][
'instant_feedback_points'] ===
true 165 || $vs[
'enabled_feedback_types'][
'instant_feedback_solution'] ===
true 167 && $vs[
'feedback_trigger'] !==
'',
168 $lng->
txt(
'select_at_least_one_feedback_type_and_trigger')
170 $trafo = $refinery->custom()->transformation(
171 static function (?array $vs): array {
174 'enabled_feedback_types' => [
175 'instant_feedback_specific' =>
false,
176 'instant_feedback_generic' =>
false,
177 'instant_feedback_points' =>
false,
178 'instant_feedback_solution' => false
180 'feedback_on_next_question' => false
184 $vs[
'feedback_on_next_question'] = $vs[
'feedback_trigger'] ===
'1';
189 $instant_feedback = $f->optionalGroup(
191 $lng->
txt(
'tst_instant_feedback'),
192 $lng->
txt(
'tst_instant_feedback_desc')
194 ->withAdditionalTransformation($constraint)
195 ->withAdditionalTransformation($trafo);
198 $instant_feedback = $instant_feedback->withValue(
200 'enabled_feedback_types' => [
211 if (!$environment[
'participant_data_exists']) {
212 return $instant_feedback;
215 return $instant_feedback->withDisabled(
true);
222 $feedback_options = [
223 'instant_feedback_points' => $f->checkbox(
224 $lng->
txt(
'tst_instant_feedback_results'),
225 $lng->
txt(
'tst_instant_feedback_results_desc')
227 'instant_feedback_generic' => $f->checkbox(
228 $lng->
txt(
'tst_instant_feedback_answer_generic'),
229 $lng->
txt(
'tst_instant_feedback_answer_generic_desc')
231 'instant_feedback_specific' => $f->checkbox(
232 $lng->
txt(
'tst_instant_feedback_answer_specific'),
233 $lng->
txt(
'tst_instant_feedback_answer_specific_desc')
235 'instant_feedback_solution' => $f->checkbox(
236 $lng->
txt(
'tst_instant_feedback_solution'),
237 $lng->
txt(
'tst_instant_feedback_solution_desc')
241 $sub_inputs_feedback[
'enabled_feedback_types'] = $f->group(
243 $lng->
txt(
'tst_instant_feedback_contents')
246 $sub_inputs_feedback[
'feedback_trigger'] = $f->radio(
247 $lng->
txt(
'tst_instant_feedback_trigger')
250 $lng->
txt(
'tst_instant_feedback_trigger_manual'),
251 $lng->
txt(
'tst_instant_feedback_trigger_manual_desc')
254 $lng->
txt(
'tst_instant_feedback_trigger_forced'),
255 $lng->
txt(
'tst_instant_feedback_trigger_forced_desc')
256 )->withRequired(
true);
258 return $sub_inputs_feedback;
267 $lock_answers = $f->radio(
268 $lng->
txt(
'tst_answer_fixation_handling')
270 self::ANSWER_FIXATION_NONE,
271 $lng->
txt(
'tst_answer_fixation_none'),
272 $lng->
txt(
'tst_answer_fixation_none_desc')
274 self::ANSWER_FIXATION_ON_INSTANT_FEEDBACK,
275 $lng->
txt(
'tst_answer_fixation_on_instant_feedback'),
276 $lng->
txt(
'tst_answer_fixation_on_instant_feedback_desc')
278 self::ANSWER_FIXATION_ON_FOLLOWUP_QUESTION,
279 $lng->
txt(
'tst_answer_fixation_on_followup_question'),
280 $lng->
txt(
'tst_answer_fixation_on_followup_question_desc')
282 self::ANSWER_FIXATION_ON_IFB_OR_FUQST,
283 $lng->
txt(
'tst_answer_fixation_on_instantfb_or_followupqst'),
284 $lng->
txt(
'tst_answer_fixation_on_instantfb_or_followupqst_desc')
289 if (!$environment[
'participant_data_exists']) {
290 return $lock_answers;
293 return $lock_answers->withDisabled(
true);
298 return $refinery->custom()->transformation(
299 static function (?
string $v): array {
300 if ($v ===
null || $v === self::ANSWER_FIXATION_NONE) {
302 'lock_answer_on_instant_feedback' =>
false,
303 'lock_answer_on_next_question' => false
307 if ($v === self::ANSWER_FIXATION_ON_INSTANT_FEEDBACK) {
309 'lock_answer_on_instant_feedback' =>
true,
310 'lock_answer_on_next_question' => false
313 if ($v === self::ANSWER_FIXATION_ON_FOLLOWUP_QUESTION) {
315 'lock_answer_on_instant_feedback' =>
false,
316 'lock_answer_on_next_question' => true
321 'lock_answer_on_instant_feedback' =>
true,
322 'lock_answer_on_next_question' => true
332 return $refinery->custom()->constraint(
333 function ($vs):
bool {
334 if ($vs[
'shuffle_questions'] ===
true 335 && $vs[
'lock_answers'][
'lock_answer_on_next_question']) {
340 $lng->
txt(
'tst_settings_conflict_shuffle_and_lock'),
403 : $additional_info->
getTagForLangVar(
'tst_instant_feedback_trigger_manual');
406 $lock_answers = $additional_info->
getTagForLangVar(
'tst_answer_fixation_none');
409 $lock_answers = $additional_info->
getTagForLangVar(
'tst_answer_fixation_on_instantfb_or_followupqst');
411 $lock_answers = $additional_info->
getTagForLangVar(
'tst_answer_fixation_on_instant_feedback');
413 $lock_answers = $additional_info->
getTagForLangVar(
'tst_answer_fixation_on_followup_question');
422 return $this->question_title_output_mode;
427 $clone = clone $this;
428 $clone->question_title_output_mode = $question_title_output_mode;
434 return $this->autosave_enabled;
439 $clone = clone $this;
440 $clone->autosave_enabled = $autosave_enabled;
446 return $this->autosave_interval;
451 $clone = clone $this;
452 $clone->autosave_interval = $autosave_interval;
458 return $this->shuffle_questions;
463 $clone = clone $this;
464 $clone->shuffle_questions = $shuffle_questions;
470 return $this->question_hints_enabled;
475 $clone = clone $this;
476 $clone->question_hints_enabled = $question_hints_enabled;
482 return $this->instant_feedback_points_enabled;
487 $clone = clone $this;
488 $clone->instant_feedback_points_enabled = $instant_feedback_points_enabled;
494 return $this->instant_feedback_generic_enabled;
499 $clone = clone $this;
500 $clone->instant_feedback_generic_enabled = $instant_feedback_generic_enabled;
506 return $this->instant_feedback_specific_enabled;
511 $clone = clone $this;
512 $clone->instant_feedback_specific_enabled = $instant_feedback_specific_enabled;
518 return $this->instant_feedback_solution_enabled;
523 $clone = clone $this;
524 $clone->instant_feedback_solution_enabled = $instant_feedback_solution_enabled;
538 return $this->force_instant_feedback_on_next_question;
543 $clone = clone $this;
544 $clone->force_instant_feedback_on_next_question = $force_instant_feedback_on_next_question;
550 return $this->lock_answer_on_instant_feedback;
555 $clone = clone $this;
556 $clone->lock_answer_on_instant_feedback = $lock_answer_on_instant_feedback;
562 return $this->lock_answer_on_next_question;
567 $clone = clone $this;
568 $clone->lock_answer_on_next_question = $lock_answer_on_next_question;
576 return self::ANSWER_FIXATION_ON_IFB_OR_FUQST;
580 return self::ANSWER_FIXATION_ON_INSTANT_FEEDBACK;
584 return self::ANSWER_FIXATION_ON_FOLLOWUP_QUESTION;
587 return self::ANSWER_FIXATION_NONE;
getInstantFeedbackSpecificEnabled()
getForceInstantFeedbackOnNextQuestion()
getLockAnswerOnNextQuestionEnabled()
withShuffleQuestions(bool $shuffle_questions)
getLockAnswerOnInstantFeedbackEnabled()
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
withLockAnswerOnInstantFeedbackEnabled(bool $lock_answer_on_instant_feedback)
getInputInstantFeedback(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, array $environment)
const ANSWER_FIXATION_ON_FOLLOWUP_QUESTION
withQuestionHintsEnabled(bool $question_hints_enabled)
getTransformationLockAnswers(Refinery $refinery)
A constraint encodes some resrtictions on values.
getInstantFeedbackGenericEnabled()
toForm(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
toLog(AdditionalInformationGenerator $additional_info)
withInstantFeedbackGenericEnabled(bool $instant_feedback_generic_enabled)
withInstantFeedbackSpecificEnabled(bool $instant_feedback_specific_enabled)
const DEFAULT_AUTOSAVE_INTERVAL
getInputAutosave(\ilLanguage $lng, FieldFactory $f, Refinery $refinery)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getSubInputInstantFeedback(\ilLanguage $lng, FieldFactory $f)
getAnswerFixationSettingsAsFormValue()
getQuestionTitleOutputMode()
const ANSWER_FIXATION_ON_INSTANT_FEEDBACK
isAnyInstantFeedbackOptionEnabled()
getInstantFeedbackPointsEnabled()
withQuestionTitleOutputMode(int $question_title_output_mode)
withLockAnswerOnNextQuestionEnabled(bool $lock_answer_on_next_question)
getInstantFeedbackSolutionEnabled()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
withAutosaveEnabled(bool $autosave_enabled)
const ANSWER_FIXATION_ON_IFB_OR_FUQST
__construct(Container $dic, ilPlugin $plugin)
getShuffleAndLockAnswersConstraint(\ilLanguage $lng, Refinery $refinery)
const ANSWER_FIXATION_NONE
__construct(int $test_id, protected int $question_title_output_mode, protected bool $autosave_enabled, protected int $autosave_interval, protected bool $shuffle_questions, protected bool $question_hints_enabled, protected bool $instant_feedback_points_enabled, protected bool $instant_feedback_generic_enabled, protected bool $instant_feedback_specific_enabled, protected bool $instant_feedback_solution_enabled, protected bool $force_instant_feedback_on_next_question, protected bool $lock_answer_on_instant_feedback, protected bool $lock_answer_on_next_question)
withForceInstantFeedbackOnNextQuestion(bool $force_instant_feedback_on_next_question)
getInputLockAnswers(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, array $environment)
getQuestionHintsEnabled()
withAutosaveInterval(int $autosave_interval)
withInstantFeedbackSolutionEnabled(bool $instant_feedback_solution_enabled)
withInstantFeedbackPointsEnabled(bool $instant_feedback_points_enabled)