49 $this->
object->loadFromDb(
$id);
63 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
74 bool $checkonly =
false,
75 ?
bool $is_save_cmd =
null
80 $this->editForm = $form;
82 $form->setFormAction($this->
ctrl->getFormAction($this));
84 $form->setMultipart(
false);
85 $form->setTableWidth(
"100%");
86 $form->setId(
"orderinghorizontal");
99 $form->setValuesByPost();
100 $errors = !$form->checkInput();
101 $form->setValuesByPost();
116 bool $graphical_output =
false,
117 bool $result_output =
false,
118 bool $show_question_only =
true,
119 bool $show_feedback =
false,
120 bool $show_correct_solution =
false,
121 bool $show_manual_scoring =
false,
122 bool $show_question_text =
true,
123 bool $show_inline_feedback =
true
125 $user_solutions = [];
126 if (($active_id > 0) && (!$show_correct_solution)) {
127 $user_solutions = $this->
object->getSolutionValues($active_id, $pass);
130 return $this->renderSolutionOutput(
138 $show_correct_solution,
139 $show_manual_scoring,
142 $show_inline_feedback,
147 mixed $user_solutions,
150 bool $graphical_output =
false,
151 bool $result_output =
false,
152 bool $show_question_only =
true,
153 bool $show_feedback =
false,
154 bool $show_correct_solution =
false,
155 bool $show_manual_scoring =
false,
156 bool $show_question_text =
true,
157 bool $show_autosave_title =
false,
158 bool $show_inline_feedback =
false,
160 $template = new
ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output_solution.html",
true,
true,
"components/ILIAS/TestQuestionPool");
163 if (count($user_solutions) && strlen($user_solutions[0][
"value1"])) {
164 $elements = explode(
"{::}", $user_solutions[0][
"value1"]);
167 if (!count($elements)) {
168 $elements = $show_correct_solution ? $this->
object->getOrderingElements() : $this->
object->getRandomOrderingElements();
171 foreach ($elements as
$id => $element) {
172 $template->setCurrentBlock(
"element");
173 $template->setVariable(
"ELEMENT_ID",
"sol_e_" . $this->
object->getId() .
"_$id");
174 $template->setVariable(
180 $template->parseCurrentBlock();
183 if (($active_id > 0) && (!$show_correct_solution)) {
184 if ($this->
object->getStep() ===
null) {
185 $reached_points = $this->
object->getReachedPoints($active_id, $pass);
187 $reached_points = $this->
object->calculateReachedPoints($active_id, $pass);
189 if ($graphical_output) {
190 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
191 if ($reached_points == $this->
object->getMaximumPoints()) {
192 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
193 } elseif ($reached_points > 0) {
194 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_MOSTLY_OK);
196 $template->setCurrentBlock(
"icon_ok");
197 $template->setVariable(
"ICON_OK", $correctness_icon);
198 $template->parseCurrentBlock();
201 $reached_points = $this->
object->getPoints();
204 if ($result_output) {
205 $resulttext = ($reached_points == 1) ?
"(%s " . $this->
lng->txt(
"point") .
")" :
"(%s " . $this->
lng->txt(
"points") .
")";
206 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
208 if ($show_question_text ==
true) {
209 $template->setVariable(
"QUESTIONTEXT", $this->renderLatex($this->
object->getQuestionForHTMLOutput()));
212 if ($this->
object->getTextSize() >= 10) {
213 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->
object->getTextSize() .
"%;\"");
216 $questionoutput = $template->get();
217 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"components/ILIAS/TestQuestionPool");
218 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
222 if ($show_feedback) {
223 if (!$this->isTestPresentationContext()) {
224 $fb = $this->getGenericFeedbackOutput((
int) $active_id, $pass);
225 $feedback .= strlen($fb) ? $fb :
'';
228 if (strlen($feedback)) {
230 $this->hasCorrectSolution($active_id, $pass) ?
234 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
237 $solutionoutput = $solutiontemplate->get();
238 if (!$show_question_only) {
240 $solutionoutput = $this->getILIASPage($solutionoutput);
242 return $solutionoutput;
247 bool $show_question_only =
false,
248 bool $show_inline_feedback =
false
250 $template = new
ilTemplate(
'tpl.il_as_qpl_orderinghorizontal_output.html',
true,
true,
'components/ILIAS/TestQuestionPool');
251 $this->initializePlayerJS();
253 if ($this->getPreviewSession() !==
null
254 && $this->getPreviewSession()->getParticipantsSolution() !==
null) {
255 $elements = $this->
object->splitAndTrimOrderElementText(
256 (
string) $this->getPreviewSession()->getParticipantsSolution(),
257 $this->
object->getAnswerSeparator()
260 $elements = $this->
object->getRandomOrderingElements();
263 foreach ($elements as
$id => $element) {
264 $template->setCurrentBlock(
'element');
265 $template->setVariable(
'ELEMENT_ID',
"e_{$this->object->getId()}_{$id}");
267 $template->parseCurrentBlock();
269 $template->setVariable(
'QUESTION_ID', $this->
object->getId());
270 $template->setVariable(
'VALUE_ORDERRESULT',
' value="' . join(
'{::}', $elements) .
'"');
271 if ($this->
object->getTextSize() >= 10) {
272 $template->setVariable(
'STYLE',
' style="font-size: ' . $this->
object->getTextSize() .
'%;"');
274 $template->setVariable(
'QUESTIONTEXT', $this->renderLatex(
275 $this->
object->getQuestionForHTMLOutput()
277 if ($show_question_only) {
278 return $template->get();
280 return $this->getILIASPage($template->get());
286 bool $is_question_postponed =
false,
287 array|
bool $user_post_solutions =
false,
288 bool $show_specific_inline_feedback =
false
290 $template = new
ilTemplate(
'tpl.il_as_qpl_orderinghorizontal_output.html',
true,
true,
'components/ILIAS/TestQuestionPool');
291 $this->initializePlayerJS();
293 $elements = $this->
object->getRandomOrderingElements();
295 $solutions = $this->
object->getTestOutputSolutions($active_id, $pass);
296 if (count($solutions) == 1) {
297 $elements = explode(
'{::}', $solutions[0][
'value1']);
300 if (!is_array($solutions) || count($solutions) == 0) {
305 foreach ($elements as
$id => $element) {
306 $template->setCurrentBlock(
'element');
307 $template->setVariable(
'ELEMENT_ID',
"e_{$this->object->getId()}_{$id}");
309 $template->parseCurrentBlock();
311 $template->setVariable(
'QUESTION_ID', $this->
object->getId());
312 if ($this->
object->getTextSize() >= 10) {
313 $template->setVariable(
'STYLE',
' style="font-size: ' . $this->
object->getTextSize() .
'%;"');
315 $template->setVariable(
'VALUE_ORDERRESULT',
' value="' . join(
'{::}', $elements) .
'"');
316 $template->setVariable(
'QUESTIONTEXT', $this->renderLatex($this->
object->getQuestionForHTMLOutput()));
317 return $this->outQuestionPage(
"", $is_question_postponed, $active_id, $template->get());
327 $this->
object->setTextSize($this->request_data_collector->float(
'textsize'));
328 $this->
object->setOrderText($this->request_data_collector->raw(
'ordertext'));
329 $this->
object->setPoints($this->request_data_collector->float(
'points'));
350 $ordertext->setValue((
string) self::prepareTextareaOutput($this->
object->getOrderText(),
false,
true));
351 $ordertext->setRequired(
true);
352 $ordertext->setInfo(sprintf($this->
lng->txt(
"ordertext_info"), $this->object->getSeparator()));
353 $ordertext->setRows(10);
354 $ordertext->setCols(80);
358 $textsize->setValue($this->
object->getTextSize());
359 $textsize->setInfo($this->
lng->txt(
"textsize_info"));
360 $textsize->setSize(6);
361 $textsize->setMinValue(10);
362 $textsize->setRequired(
false);
367 $points->allowDecimals(
true);
370 if ($this->
object->getPoints() ==
null) {
371 $points->setValue(
"1");
373 $points->setValue($this->
object->getPoints());
375 $points->setRequired(
true);
377 $points->setMinValue(0.0);
378 $points->setMinvalueShouldBeGreater(
true);
387 foreach ($relevantAnswers as $ans) {
388 $md5 = md5($ans[
'value1']);
390 if (!isset($answers[$md5])) {
391 $answer = str_replace(
392 $this->
object->getAnswerSeparator(),
393 ' - ',
403 $answers[$md5][
'frequency']++;
414 $points->allowDecimals(
true);
415 $points->setValue($this->
object->getPoints());
416 $points->setRequired(
true);
418 $points->setMinValue(0.0);
419 $points->setMinvalueShouldBeGreater(
true);
425 $this->
object->setPoints((
float) str_replace(
',',
'.', $form->
getInput(
'points')));
430 $this->tpl->addJavascript(
'assets/js/orderinghorizontal.js');
431 $this->tpl->addOnLoadCode(
432 "il.test.orderinghorizontal.init(document.querySelector('#horizontal_{$this->object->getId()}'));"
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getSolutionOutput(int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
writePostData(bool $always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...
renderSolutionOutput(mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
getTestOutput(int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
getPreview(bool $show_question_only=false, bool $show_inline_feedback=false)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from the request and applies them to the data object.
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
getAnswersFrequency($relevantAnswers, $questionIndex)
__construct($id=-1)
assOrderingHorizontalGUI constructor
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
getSpecificFeedbackOutput(array $userSolution)
Returns the answer specific feedback for the question.
Class for horizontal ordering questions.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
writeQuestionGenericPostData()
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
renderEditForm(ilPropertyFormGUI $form)
saveTaxonomyAssignments()
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
setErrorMessage(string $errormessage)
const CSS_CLASS_FEEDBACK_WRONG
const CSS_CLASS_FEEDBACK_CORRECT
static clear(string $a_var)
static set(string $a_var, $a_val)
Set a value.
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc