18 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
47 include_once
"./Modules/TestQuestionPool/classes/class.assOrderingHorizontal.php";
51 $this->
object->loadFromDb(
$id);
65 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
67 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
86 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
88 $this->editForm = $form;
90 $form->setFormAction($this->
ctrl->getFormAction($this));
92 $form->setMultipart(
false);
93 $form->setTableWidth(
"100%");
94 $form->setId(
"orderinghorizontal");
107 $form->setValuesByPost();
108 $errors = !$form->checkInput();
109 $form->setValuesByPost();
116 $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
136 $graphicalOutput =
false,
137 $result_output =
false,
138 $show_question_only =
true,
139 $show_feedback =
false,
140 $show_correct_solution =
false,
141 $show_manual_scoring =
false,
142 $show_question_text =
true 145 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
147 if (($active_id > 0) && (!$show_correct_solution)) {
149 $solutions = $this->
object->getSolutionValues($active_id, $pass);
151 if (count($solutions) && strlen($solutions[0][
"value1"])) {
152 $elements = explode(
"{::}", $solutions[0][
"value1"]);
155 if (!count($elements)) {
156 $elements = $this->
object->getRandomOrderingElements();
159 foreach ($elements as
$id => $element) {
160 $template->setCurrentBlock(
"element");
161 $template->setVariable(
"ELEMENT_ID",
"sol_e_" . $this->
object->getId() .
"_$id");
163 $template->parseCurrentBlock();
166 $elements = $this->
object->getOrderingElements();
167 foreach ($elements as
$id => $element) {
168 $template->setCurrentBlock(
"element");
169 $template->setVariable(
"ELEMENT_ID",
"sol_e_" . $this->
object->getId() .
"_$id");
171 $template->parseCurrentBlock();
175 if (($active_id > 0) && (!$show_correct_solution)) {
176 if ($this->
object->getStep() === null) {
177 $reached_points = $this->
object->getReachedPoints($active_id, $pass);
179 $reached_points = $this->
object->calculateReachedPoints($active_id, $pass);
181 if ($graphicalOutput) {
183 if ($reached_points == $this->
object->getMaximumPoints()) {
185 } elseif ($reached_points > 0) {
188 $template->setCurrentBlock(
"icon_ok");
189 $template->setVariable(
"ICON_OK", $correctness_icon);
190 $template->parseCurrentBlock();
193 $reached_points = $this->
object->getPoints();
196 if ($result_output) {
197 $resulttext = ($reached_points == 1) ?
"(%s " . $this->
lng->txt(
"point") .
")" :
"(%s " . $this->
lng->txt(
"points") .
")";
198 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
200 if ($show_question_text ==
true) {
201 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
204 if ($this->
object->getTextSize() >= 10) {
205 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->
object->getTextSize() .
"%;\"");
208 $questionoutput = $template->get();
209 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
210 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
214 if ($show_feedback) {
217 $feedback .= strlen($fb) ? $fb :
'';
220 if (strlen($feedback)) {
226 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
227 $solutiontemplate->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput($feedback,
true));
229 $solutionoutput = $solutiontemplate->get();
230 if (!$show_question_only) {
234 return $solutionoutput;
238 public function getPreview($show_question_only =
false, $showInlineFeedback =
false): string
242 $elements = $this->
object->splitAndTrimOrderElementText($elements, $this->
object->getAnswerSeparator());
244 $elements = $this->
object->getRandomOrderingElements();
247 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_preview.html",
true,
true,
"Modules/TestQuestionPool");
250 $(
'#horizontal_{QUESTION_ID}').ilHorizontalOrderingQuestion({
251 result_value_selector :
'.ilOrderingValue',
252 result_separator :
'{::}' 256 $js = str_replace(
'{QUESTION_ID}', $this->
object->getId(), $js);
257 $this->tpl->addOnLoadCode($js);
259 foreach ($elements as
$id => $element) {
260 $template->setCurrentBlock(
"element");
261 $template->setVariable(
"ELEMENT_ID",
"e_" . $this->
object->getId() .
"_$id");
264 $template->parseCurrentBlock();
266 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
267 $template->setVariable(
"VALUE_ORDERRESULT",
' value="' . join(
'{::}', $elements) .
'"');
268 if ($this->
object->getTextSize() >= 10) {
269 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->
object->getTextSize() .
"%;\"");
271 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
272 $questionoutput = $template->get();
273 if (!$show_question_only) {
278 if ($DIC->http()->agent()->isMobile() || $DIC->http()->agent()->isIpad()) {
279 require_once
'Services/jQuery/classes/class.iljQueryUtil.php';
282 $this->tpl->addJavaScript(
'./node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js');
284 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
285 return $questionoutput;
289 public function getTestOutput($active_id, $pass, $is_postponed =
false, $use_post_solutions =
false, $show_feedback =
false): string
293 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output.html",
true,
true,
"Modules/TestQuestionPool");
295 $().ready(
function() {
296 if (typeof $.fn.ilHorizontalOrderingQuestion !=
'undefined') {
297 $(
'#horizontal_{QUESTION_ID}').ilHorizontalOrderingQuestion({
298 result_value_selector:
'.ilOrderingValue',
299 result_separator:
'{::}' 304 $js = str_replace(
'{QUESTION_ID}', $this->
object->getId(), $js);
305 $this->tpl->addOnLoadCode($js);
308 $elements = $this->
object->getRandomOrderingElements();
311 $solutions = $this->
object->getTestOutputSolutions($active_id, $pass);
313 if (is_array($solutions) && count($solutions) == 1) {
314 $elements = explode(
"{::}", $solutions[0][
"value1"]);
317 if (!is_array($solutions) || count($solutions) == 0) {
322 foreach ($elements as
$id => $element) {
323 $template->setCurrentBlock(
"element");
324 $template->setVariable(
"ELEMENT_ID",
"e_" . $this->
object->getId() .
"_$id");
327 $template->parseCurrentBlock();
329 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
330 if ($this->
object->getTextSize() >= 10) {
331 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->
object->getTextSize() .
"%;\"");
333 $template->setVariable(
"VALUE_ORDERRESULT",
' value="' . join(
'{::}', $elements) .
'"');
334 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
335 $questionoutput = $template->get();
341 if ($DIC->http()->agent()->isMobile() || $DIC->http()->agent()->isIpad()) {
342 require_once
'Services/jQuery/classes/class.iljQueryUtil.php';
345 $this->tpl->addJavaScript(
'./node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js');
347 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
348 $questionoutput = $template->get();
349 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
359 if ($DIC->http()->agent()->isMobile() || $DIC->http()->agent()->isIpad()) {
360 $files[] =
'./node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js';
373 $this->
object->setTextSize($_POST[
"textsize"]);
374 $this->
object->setOrderText($_POST[
"ordertext"]);
375 $this->
object->setPoints((
float) str_replace(
',',
'.', $_POST[
"points"]));
396 $ordertext->
setValue((
string) self::prepareTextareaOutput($this->
object->getOrderText(),
false,
true));
397 $ordertext->setRequired(
true);
398 $ordertext->setInfo(sprintf($this->
lng->txt(
"ordertext_info"), $this->
object->getSeparator()));
399 $ordertext->setRows(10);
400 $ordertext->setCols(80);
405 $textsize->setInfo($this->
lng->txt(
"textsize_info"));
406 $textsize->setSize(6);
407 $textsize->setMinValue(10);
408 $textsize->setRequired(
false);
416 if ($this->
object->getPoints() == null) {
417 $points->setValue(
"1");
419 $points->setValue($this->
object->getPoints());
421 $points->setRequired(
true);
423 $points->setMinValue(0.0);
424 $points->setMinvalueShouldBeGreater(
true);
442 public function aggregateAnswers($relevant_answers_chosen, $answer_defined_on_question): array
444 $aggregate = array();
445 foreach ($relevant_answers_chosen as $answer) {
446 $answer = str_replace($this->
object->getAnswerSeparator(),
' - ', $answer);
447 if (in_array($answer[
'value1'], $aggregate)) {
448 $aggregate[$answer[
'value1']] = $aggregate[$answer[
'value1']] + 1;
450 $aggregate[$answer[
'value1']] = 1;
464 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
466 foreach ($aggregate as
$key => $line_data) {
479 foreach ($relevantAnswers as $ans) {
480 $md5 = md5($ans[
'value1']);
482 if (!isset($answers[$md5])) {
483 $answer = str_replace(
484 $this->
object->getAnswerSeparator(),
485 ' - ',
489 $answers[$md5] = array(
490 'answer' => $answer,
'frequency' => 0
494 $answers[$md5][
'frequency']++;
506 $points->setValue($this->
object->getPoints());
507 $points->setRequired(
true);
509 $points->setMinValue(0.0);
510 $points->setMinvalueShouldBeGreater(
true);
519 $this->
object->setPoints((
float) str_replace(
',',
'.', $form->
getInput(
'points')));
isTestPresentationContext()
hasCorrectSolution($activeId, $passIndex)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
generateCorrectnessIconsForCorrectness(int $correctness)
getAggregatedAnswersView(array $relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
setCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Sets the template to the given block.
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const CSS_CLASS_FEEDBACK_CORRECT
ilGlobalPageTemplate $tpl
renderAggregateView($aggregate)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
setValue(string $a_value)
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
setErrorMessage(string $errormessage)
writeQuestionGenericPostData()
getSolutionOutput( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
Get the question solution output.
static initjQueryUI(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components.txt for included components)
aggregateAnswers($relevant_answers_chosen, $answer_defined_on_question)
const CSS_CLASS_FEEDBACK_WRONG
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
saveTaxonomyAssignments()
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
__construct($id=-1)
assOrderingHorizontalGUI constructor
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
getPresentationJavascripts()
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
getPreview($show_question_only=false, $showInlineFeedback=false)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
getAnswersFrequency($relevantAnswers, $questionIndex)
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
getSpecificFeedbackOutput(array $userSolution)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static clear(string $a_var)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static set(string $a_var, $a_val)
Set a value.
getTestOutput($active_id, $pass, $is_postponed=false, $use_post_solutions=false, $show_feedback=false)
writePostData(bool $always=false)
{}
getGenericFeedbackOutput(int $active_id, ?int $pass)