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';
34 parent::__construct();
35 include_once
"./Modules/TestQuestionPool/classes/class.assOrderingHorizontal.php";
39 $this->
object->loadFromDb(
$id);
53 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
55 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
74 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
76 $this->editForm =
$form;
78 $form->setFormAction($this->ctrl->getFormAction($this));
80 $form->setMultipart(
false);
81 $form->setTableWidth(
"100%");
82 $form->setId(
"orderinghorizontal");
95 $form->setValuesByPost();
97 $form->setValuesByPost();
104 $this->tpl->setVariable(
"QUESTION_DATA",
$form->getHTML());
135 $graphicalOutput =
false,
136 $result_output =
false,
137 $show_question_only =
true,
138 $show_feedback =
false,
139 $show_correct_solution =
false,
140 $show_manual_scoring =
false,
141 $show_question_text =
true 144 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
147 if (($active_id > 0) && (!$show_correct_solution)) {
150 if (strlen($solutions[0][
"value1"])) {
151 $elements = explode(
"{::}", $solutions[0][
"value1"]);
154 if (!count($elements)) {
155 $elements = $this->
object->getRandomOrderingElements();
158 foreach ($elements as
$id => $element) {
160 $template->setVariable(
"ELEMENT_ID",
"sol_e_" . $this->object->getId() .
"_$id");
167 $elements = $this->
object->getOrderingElements();
168 foreach ($elements as
$id => $element) {
170 $template->setVariable(
"ELEMENT_ID",
"sol_e_" . $this->object->getId() .
"_$id");
177 if (($active_id > 0) && (!$show_correct_solution)) {
178 if ($this->object->getStep() === null) {
179 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
181 $reached_points = $this->
object->calculateReachedPoints($active_id,
$pass);
183 if ($graphicalOutput) {
185 if ($reached_points == $this->object->getMaximumPoints()) {
188 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
192 if ($reached_points > 0) {
194 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
197 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
203 $reached_points = $this->
object->getPoints();
206 if ($result_output) {
207 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
208 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
210 if ($show_question_text ==
true) {
211 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
214 if ($this->object->textsize >= 10) {
215 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->textsize .
"%;\"");
219 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
220 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
224 if ($show_feedback) {
227 $feedback .= strlen($fb) ? $fb :
'';
231 $feedback .= strlen($fb) ? $fb :
'';
233 if (strlen($feedback)) {
239 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
240 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
242 $solutionoutput = $solutiontemplate->get();
243 if (!$show_question_only) {
247 return $solutionoutput;
250 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
254 $elements = $this->
object->splitAndTrimOrderElementText($elements, $this->object->getAnswerSeparator());
256 $elements = $this->
object->getRandomOrderingElements();
259 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_preview.html",
true,
true,
"Modules/TestQuestionPool");
260 foreach ($elements as
$id => $element) {
262 $template->setVariable(
"ELEMENT_ID",
"e_" . $this->object->getId() .
"_$id");
267 $template->setVariable(
"QUESTION_ID", $this->object->getId());
268 $template->setVariable(
"VALUE_ORDERRESULT",
' value="' . join(
'{::}', $elements) .
'"');
269 if ($this->object->textsize >= 10) {
270 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->textsize .
"%;\"");
272 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
274 if (!$show_question_only) {
279 if ($DIC[
'ilBrowser']->isMobile() || $DIC[
'ilBrowser']->isIpad()) {
280 $this->tpl->addJavaScript(
'./libs/bower/bower_components/jqueryui-touch-punch/jquery.ui.touch-punch.min.js');
282 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
283 return $questionoutput;
287 public function getTestOutput($active_id,
$pass, $is_postponed =
false, $use_post_solutions =
false, $show_feedback =
false)
291 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output.html",
true,
true,
"Modules/TestQuestionPool");
292 $elements = $this->
object->getRandomOrderingElements();
297 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 298 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 300 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 302 $solutions = $this->
object->getTestOutputSolutions($active_id,
$pass);
304 if (is_array($solutions) && count($solutions) == 1) {
305 $elements = explode(
"{::}", $solutions[0][
"value1"]);
308 if (!is_array($solutions) || count($solutions) == 0) {
309 $_SESSION[
'qst_ordering_horizontal_elements'] = $elements;
311 unset(
$_SESSION[
'qst_ordering_horizontal_elements']);
313 foreach ($elements as
$id => $element) {
315 $template->setVariable(
"ELEMENT_ID",
"e_" . $this->object->getId() .
"_$id");
320 $template->setVariable(
"QUESTION_ID", $this->object->getId());
321 if ($this->object->textsize >= 10) {
322 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->textsize .
"%;\"");
324 $template->setVariable(
"VALUE_ORDERRESULT",
' value="' . join(
'{::}', $elements) .
'"');
325 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
327 if (!$show_question_only) {
332 if ($DIC[
'ilBrowser']->isMobile() || $DIC[
'ilBrowser']->isIpad()) {
333 $this->tpl->addJavaScript(
'./libs/bower/bower_components/jqueryui-touch-punch/jquery.ui.touch-punch.min.js');
335 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
337 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
348 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
349 $errors = $this->feedback(
true);
350 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
351 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
352 $this->
object->cleanupMediaObjectUsage();
353 parent::saveFeedback();
366 $rbacsystem = $DIC[
'rbacsystem'];
367 $ilTabs = $DIC[
'ilTabs'];
369 $ilTabs->clearTargets();
371 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
372 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
373 $q_type = $this->
object->getQuestionType();
375 if (strlen($q_type)) {
376 $classname = $q_type .
"GUI";
377 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
378 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
382 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
386 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
387 array(
"edit",
"insert",
"exec_pg"),
397 $force_active =
false;
398 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
401 $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
403 $commands =
$_POST[
"cmd"];
404 if (is_array($commands)) {
405 foreach ($commands as
$key => $value) {
406 if (preg_match(
"/^suggestrange_.*/",
$key, $matches)) {
407 $force_active =
true;
415 array(
"editQuestion",
"save",
"saveEdit",
"originalSyncForm"),
435 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
447 if (strpos($this->object->getOrderText(),
'::')) {
448 $answers = explode(
'::', $this->object->getOrderText());
450 $answers = explode(
' ', $this->object->getOrderText());
453 if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
457 $output =
'<table class="test_specific_feedback"><tbody>';
459 foreach ($answers as $idx => $answer) {
460 $feedback = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
461 $this->object->getId(),
466 $output .=
"<tr><td>{$answer}</td><td>{$feedback}</td></tr>";
471 return $this->
object->prepareTextareaOutput(
$output,
true);
476 $this->
object->setTextSize(
$_POST[
"textsize"]);
477 $this->
object->setOrderText(
$_POST[
"ordertext"]);
478 $this->
object->setPoints(
$_POST[
"points"]);
499 $ordertext->
setValue($this->object->prepareTextareaOutput($this->object->getOrderText()));
500 $ordertext->setRequired(
true);
501 $ordertext->setInfo(sprintf($this->lng->txt(
"ordertext_info"), $this->
object->separator));
502 $ordertext->setRows(10);
503 $ordertext->setCols(80);
507 $textsize->
setValue($this->object->getTextSize());
508 $textsize->setInfo($this->lng->txt(
"textsize_info"));
509 $textsize->setSize(6);
510 $textsize->setMinValue(10);
511 $textsize->setRequired(
false);
519 if ($this->object->getPoints() == null) {
520 $points->setValue(
"1");
522 $points->setValue($this->object->getPoints());
524 $points->setRequired(
true);
526 $points->setMinValue(0.0);
527 $points->setMinvalueShouldBeGreater(
true);
548 $aggregate = array();
549 foreach ($relevant_answers_chosen as $answer) {
550 $answer = str_replace($this->object->getAnswerSeparator(),
' - ', $answer);
551 if (in_array($answer[
'value1'], $aggregate)) {
552 $aggregate[$answer[
'value1']] = $aggregate[$answer[
'value1']] + 1;
554 $aggregate[$answer[
'value1']] = 1;
568 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
570 foreach ($aggregate as
$key => $line_data) {
571 $tpl->setCurrentBlock(
'aggregaterow');
572 $tpl->setVariable(
'COUNT', $line_data);
574 $tpl->parseCurrentBlock();
583 foreach ($relevantAnswers as $ans) {
584 $md5 = md5($ans[
'value1']);
586 if (!isset($answers[$md5])) {
587 $answer = str_replace(
588 $this->object->getAnswerSeparator(),
589 ' - ',
593 $answers[$md5] = array(
594 'answer' => $answer,
'frequency' => 0
598 $answers[$md5][
'frequency']++;
610 $points->setValue($this->object->getPoints());
611 $points->setRequired(
true);
613 $points->setMinValue(0.0);
614 $points->setMinvalueShouldBeGreater(
true);
623 $this->
object->setPoints((
float) $form->
getInput(
'points'));
isTestPresentationContext()
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
hasCorrectSolution($activeId, $passIndex)
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
saveFeedback()
Saves the feedback for a single choice question.
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
supportsIntermediateSolutionOutput()
Question type specific support of intermediate solution output The function getSolutionOutput respect...
if(!array_key_exists('StateId', $_REQUEST)) $id
setValue($a_value)
Set Value.
The assOrderingHorizontalGUI class encapsulates the GUI representation for horizontal ordering questi...
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
renderAggregateView($aggregate)
getSpecificFeedbackOutput($userSolution)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
writeQuestionGenericPostData()
if(isset($_POST['submit'])) $form
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...
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.
aggregateAnswers($relevant_answers_chosen, $answer_defined_on_question)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
const CSS_CLASS_FEEDBACK_WRONG
Basic GUI class for assessment questions.
setErrorMessage($errormessage)
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
saveTaxonomyAssignments()
__construct($id=-1)
assOrderingHorizontalGUI constructor
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
setQuestionTabs()
Sets the ILIAS tabs for this question type.
This class represents a text area property in a property form.
addBackTab(ilTabsGUI $ilTabs)
getPreview($show_question_only=false, $showInlineFeedback=false)
getAnswersFrequency($relevantAnswers, $questionIndex)
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.
getTestOutput($active_id, $pass, $is_postponed=false, $use_post_solutions=false, $show_feedback=false)
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
writePostData($always=false)
{}