4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
5 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
6 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
33 parent::__construct();
34 include_once
"./Modules/TestQuestionPool/classes/class.assOrderingHorizontal.php";
39 $this->
object->loadFromDb($id);
57 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
60 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
79 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
81 $form->setFormAction($this->ctrl->getFormAction($this));
83 $form->setMultipart(FALSE);
84 $form->setTableWidth(
"100%");
85 $form->setId(
"orderinghorizontal");
99 $form->setValuesByPost();
100 $errors = !$form->checkInput();
101 $form->setValuesByPost();
102 if (
$errors) $checkonly =
false;
105 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
125 $graphicalOutput = FALSE,
126 $result_output = FALSE,
127 $show_question_only = TRUE,
128 $show_feedback = FALSE,
129 $show_correct_solution = FALSE,
130 $show_manual_scoring = FALSE,
131 $show_question_text = TRUE
135 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
138 if (($active_id > 0) && (!$show_correct_solution))
140 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
141 if (strlen($solutions[0][
"value1"]))
143 $elements = split(
"{::}", $solutions[0][
"value1"]);
144 foreach ($elements as $id => $element)
146 $template->setCurrentBlock(
"element");
147 $template->setVariable(
"ELEMENT_ID",
"sol_e_" . $this->object->getId() .
"_$id");
149 $template->parseCurrentBlock();
152 $solutionvalue = str_replace(
"{::}",
" ", $solutions[0][
"value1"]);
156 $elements = $this->
object->getOrderingElements();
157 foreach ($elements as $id => $element)
159 $template->setCurrentBlock(
"element");
160 $template->setVariable(
"ELEMENT_ID",
"sol_e_" . $this->object->getId() .
"_$id");
162 $template->parseCurrentBlock();
164 $solutionvalue = join($this->object->getOrderingElements(),
" ");
167 if (($active_id > 0) && (!$show_correct_solution))
169 if($this->object->getStep() === NULL)
171 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
175 $reached_points = $this->
object->calculateReachedPoints($active_id,
$pass);
177 if ($graphicalOutput)
180 if ($reached_points == $this->object->getMaximumPoints())
182 $template->setCurrentBlock(
"icon_ok");
184 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
185 $template->parseCurrentBlock();
189 $template->setCurrentBlock(
"icon_ok");
190 if ($reached_points > 0)
193 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
198 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
200 $template->parseCurrentBlock();
206 $reached_points = $this->
object->getPoints();
211 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
212 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
214 if($show_question_text==
true)
216 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
219 if ($this->object->textsize >= 10) $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->textsize .
"%;\"");
221 $questionoutput = $template->get();
222 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
223 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
230 $feedback .= strlen($fb) ? $fb :
'';
233 $feedback .= strlen($fb) ? $fb :
'';
235 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
236 $solutionoutput = $solutiontemplate->get();
237 if (!$show_question_only)
242 return $solutionoutput;
245 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
250 $elements = $this->
object->splitAndTrimOrderElementText($elements, $this->object->getAnswerSeparator());
254 $elements = $this->
object->getRandomOrderingElements();
257 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_preview.html",TRUE, TRUE,
"Modules/TestQuestionPool");
258 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->textsize >= 10) $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->textsize .
"%;\"");
269 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
270 $questionoutput = $template->get();
271 if (!$show_question_only)
276 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
277 return $questionoutput;
280 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
283 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
284 $elements = $this->
object->getRandomOrderingElements();
289 include_once
"./Modules/Test/classes/class.ilObjTest.php";
294 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
295 if (count($solutions) == 1)
297 $elements = split(
"{::}", $solutions[0][
"value1"]);
300 if (count($solutions) == 0)
302 $_SESSION[
'qst_ordering_horizontal_elements'] = $elements;
306 unset(
$_SESSION[
'qst_ordering_horizontal_elements']);
308 foreach ($elements as $id => $element)
310 $template->setCurrentBlock(
"element");
311 $template->setVariable(
"ELEMENT_ID",
"e_" . $this->object->getId() .
"_$id");
314 $template->parseCurrentBlock();
316 $template->setVariable(
"QUESTION_ID", $this->object->getId());
317 if ($this->object->textsize >= 10) $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->textsize .
"%;\"");
318 $template->setVariable(
"VALUE_ORDERRESULT",
' value="' . join($elements,
'{::}') .
'"');
319 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
320 $questionoutput = $template->get();
321 if (!$show_question_only)
326 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
327 $questionoutput = $template->get();
328 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
339 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
340 $errors = $this->feedback(
true);
341 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
342 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
343 $this->
object->cleanupMediaObjectUsage();
344 parent::saveFeedback();
356 global $rbacsystem, $ilTabs;
358 $ilTabs->clearTargets();
360 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
361 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
362 $q_type = $this->
object->getQuestionType();
366 $classname = $q_type .
"GUI";
367 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
368 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
373 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
376 $ilTabs->addTarget(
"edit_page",
377 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
378 array(
"edit",
"insert",
"exec_pg"),
379 "",
"", $force_active);
385 $force_active =
false;
386 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
389 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
390 $commands =
$_POST[
"cmd"];
391 if (is_array($commands))
393 foreach ($commands as $key => $value)
395 if (preg_match(
"/^suggestrange_.*/", $key, $matches))
397 $force_active =
true;
402 $ilTabs->addTarget(
"edit_question",
404 array(
"editQuestion",
"save",
"saveEdit",
"originalSyncForm"),
405 $classname,
"", $force_active);
420 $ilTabs->addTarget(
"statistics",
421 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
431 if(strpos($this->object->getOrderText(),
'::'))
433 $answers = explode(
'::', $this->object->getOrderText());
435 $answers = explode(
' ', $this->object->getOrderText());
438 if( !$this->object->feedbackOBJ->specificAnswerFeedbackExists(array_values($answers)) )
443 $output =
'<table class="test_specific_feedback"><tbody>';
445 foreach($answers as $idx => $answer)
447 $feedback = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
448 $this->object->getId(), $idx
451 $output .=
"<tr><td>{$answer}</td><td>{$feedback}</td></tr>";
454 $output .=
'</tbody></table>';
456 return $this->
object->prepareTextareaOutput($output, TRUE);
461 $this->
object->setTextSize(
$_POST[
"textsize"] );
462 $this->
object->setOrderText(
$_POST[
"ordertext"] );
463 $this->
object->setPoints(
$_POST[
"points"] );
484 $ordertext->
setValue( $this->object->prepareTextareaOutput( $this->object->getOrderText() ) );
485 $ordertext->setRequired( TRUE );
486 $ordertext->setInfo( sprintf( $this->lng->txt(
"ordertext_info" ), $this->
object->separator ) );
487 $ordertext->setRows( 10 );
488 $ordertext->setCols( 80 );
491 $textsize =
new ilNumberInputGUI($this->lng->txt(
"textsize" ),
"textsize");
492 $textsize->
setValue( $this->object->getTextSize() );
493 $textsize->setInfo( $this->lng->txt(
"textsize_info" ) );
494 $textsize->setSize( 6 );
495 $textsize->setMinValue( 10 );
496 $textsize->setRequired( FALSE );
504 if ($this->object->getPoints() == null)
506 $points->setValue(
"1" );
510 $points->setValue( $this->object->getPoints() );
512 $points->setRequired( TRUE );
513 $points->setSize( 3 );
514 $points->setMinValue( 0.0 );
515 $points->setMinvalueShouldBeGreater(
true );
530 $this->
aggregateAnswers( $relevant_answers, $this->object->getOrderText() ) )->get();
535 $aggregate = array();
536 foreach($relevant_answers_chosen as $answer)
538 $answer = str_replace($this->object->getAnswerSeparator(),
' - ', $answer);
539 if (in_array($answer[
'value1'], $aggregate))
541 $aggregate[$answer[
'value1']] = $aggregate[$answer[
'value1']]+1;
545 $aggregate[$answer[
'value1']] = 1;
559 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
561 foreach ($aggregate as $key => $line_data)
563 $tpl->setCurrentBlock(
'aggregaterow' );
564 $tpl->setVariable(
'COUNT', $line_data );
565 $tpl->setVariable(
'OPTION', $key );
566 $tpl->parseCurrentBlock();
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
Class for horizontal ordering questions.
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
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.
saveFeedback()
Saves the feedback for a single choice question.
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
setValue($a_value)
Set Value.
The assOrderingHorizontalGUI class encapsulates the GUI representation for horizontal ordering questi...
getQuestionTemplate()
get question template
renderAggregateView($aggregate)
getTestOutput($active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
writeQuestionGenericPostData()
getILIASPage($html="")
Returns the ILIAS Page around a question.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
aggregateAnswers($relevant_answers_chosen, $answer_defined_on_question)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
getSpecificFeedbackOutput($active_id, $pass)
Basic GUI class for assessment questions.
setErrorMessage($errormessage)
_getUsePreviousAnswers($active_id, $user_active_user_setting=false)
Returns if the previous results should be hidden for a learner.
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
saveTaxonomyAssignments()
__construct($id=-1)
assOrderingHorizontalGUI constructor
setQuestionTabs()
Sets the ILIAS tabs for this question type.
This class represents a text area property in a property form.
addBackTab(ilTabsGUI $ilTabs)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
Interface ilGuiQuestionScoringAdjustable.
getPreview($show_question_only=FALSE, $showInlineFeedback=false)
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
writePostData($always=false)
Evaluates a posted edit form and writes the form data in the question object.