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"]);
146 if( !count($elements) )
148 $elements = $this->
object->getRandomOrderingElements();
151 foreach ($elements as $id => $element)
153 $template->setCurrentBlock(
"element");
154 $template->setVariable(
"ELEMENT_ID",
"sol_e_" . $this->object->getId() .
"_$id");
156 $template->parseCurrentBlock();
163 $elements = $this->
object->getOrderingElements();
164 foreach ($elements as $id => $element)
166 $template->setCurrentBlock(
"element");
167 $template->setVariable(
"ELEMENT_ID",
"sol_e_" . $this->object->getId() .
"_$id");
169 $template->parseCurrentBlock();
174 if (($active_id > 0) && (!$show_correct_solution))
176 if($this->object->getStep() === NULL)
178 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
182 $reached_points = $this->
object->calculateReachedPoints($active_id,
$pass);
184 if ($graphicalOutput)
187 if ($reached_points == $this->object->getMaximumPoints())
189 $template->setCurrentBlock(
"icon_ok");
191 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
192 $template->parseCurrentBlock();
196 $template->setCurrentBlock(
"icon_ok");
197 if ($reached_points > 0)
200 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
205 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
207 $template->parseCurrentBlock();
213 $reached_points = $this->
object->getPoints();
218 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
219 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
221 if($show_question_text==
true)
223 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
226 if ($this->object->textsize >= 10) $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->textsize .
"%;\"");
228 $questionoutput = $template->get();
229 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
230 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
239 $feedback .= strlen($fb) ? $fb :
'';
243 $feedback .= strlen($fb) ? $fb :
'';
245 if (strlen($feedback))
251 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
252 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
254 $solutionoutput = $solutiontemplate->get();
255 if (!$show_question_only)
260 return $solutionoutput;
263 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
268 $elements = $this->
object->splitAndTrimOrderElementText($elements, $this->object->getAnswerSeparator());
272 $elements = $this->
object->getRandomOrderingElements();
275 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_preview.html",TRUE, TRUE,
"Modules/TestQuestionPool");
276 foreach ($elements as $id => $element)
278 $template->setCurrentBlock(
"element");
279 $template->setVariable(
"ELEMENT_ID",
"e_" . $this->object->getId() .
"_$id");
282 $template->parseCurrentBlock();
284 $template->setVariable(
"QUESTION_ID", $this->object->getId());
285 $template->setVariable(
"VALUE_ORDERRESULT",
' value="' . join($elements,
'{::}') .
'"');
286 if ($this->object->textsize >= 10) $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->textsize .
"%;\"");
287 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
288 $questionoutput = $template->get();
289 if (!$show_question_only)
294 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
295 return $questionoutput;
299 function getTestOutput($active_id,
$pass, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
303 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
304 $elements = $this->
object->getRandomOrderingElements();
310 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 311 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 313 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 317 if (count($solutions) == 1)
319 $elements = split(
"{::}", $solutions[0][
"value1"]);
322 if (count($solutions) == 0)
324 $_SESSION[
'qst_ordering_horizontal_elements'] = $elements;
328 unset(
$_SESSION[
'qst_ordering_horizontal_elements']);
330 foreach ($elements as $id => $element)
332 $template->setCurrentBlock(
"element");
333 $template->setVariable(
"ELEMENT_ID",
"e_" . $this->object->getId() .
"_$id");
336 $template->parseCurrentBlock();
338 $template->setVariable(
"QUESTION_ID", $this->object->getId());
339 if ($this->object->textsize >= 10) $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->textsize .
"%;\"");
340 $template->setVariable(
"VALUE_ORDERRESULT",
' value="' . join($elements,
'{::}') .
'"');
341 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
342 $questionoutput = $template->get();
343 if (!$show_question_only)
348 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
349 $questionoutput = $template->get();
350 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
361 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
362 $errors = $this->feedback(
true);
363 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
364 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
365 $this->
object->cleanupMediaObjectUsage();
366 parent::saveFeedback();
378 global $rbacsystem, $ilTabs;
380 $ilTabs->clearTargets();
382 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
383 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
384 $q_type = $this->
object->getQuestionType();
388 $classname = $q_type .
"GUI";
389 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
390 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
395 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
398 $ilTabs->addTarget(
"edit_page",
399 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
400 array(
"edit",
"insert",
"exec_pg"),
401 "",
"", $force_active);
407 $force_active =
false;
408 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
411 if ($classname)
$url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
412 $commands =
$_POST[
"cmd"];
413 if (is_array($commands))
415 foreach ($commands as $key => $value)
417 if (preg_match(
"/^suggestrange_.*/", $key, $matches))
419 $force_active =
true;
424 $ilTabs->addTarget(
"edit_question",
426 array(
"editQuestion",
"save",
"saveEdit",
"originalSyncForm"),
427 $classname,
"", $force_active);
442 $ilTabs->addTarget(
"statistics",
443 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
453 if(strpos($this->object->getOrderText(),
'::'))
455 $answers = explode(
'::', $this->object->getOrderText());
457 $answers = explode(
' ', $this->object->getOrderText());
460 if( !$this->object->feedbackOBJ->specificAnswerFeedbackExists(array_values($answers)) )
465 $output =
'<table class="test_specific_feedback"><tbody>';
467 foreach($answers as $idx => $answer)
469 $feedback = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
470 $this->object->getId(), $idx
473 $output .=
"<tr><td>{$answer}</td><td>{$feedback}</td></tr>";
476 $output .=
'</tbody></table>';
478 return $this->
object->prepareTextareaOutput($output, TRUE);
483 $this->
object->setTextSize(
$_POST[
"textsize"] );
484 $this->
object->setOrderText(
$_POST[
"ordertext"] );
485 $this->
object->setPoints(
$_POST[
"points"] );
506 $ordertext->
setValue( $this->object->prepareTextareaOutput( $this->object->getOrderText() ) );
507 $ordertext->setRequired( TRUE );
508 $ordertext->setInfo( sprintf( $this->lng->txt(
"ordertext_info" ), $this->
object->separator ) );
509 $ordertext->setRows( 10 );
510 $ordertext->setCols( 80 );
513 $textsize =
new ilNumberInputGUI($this->lng->txt(
"textsize" ),
"textsize");
514 $textsize->
setValue( $this->object->getTextSize() );
515 $textsize->setInfo( $this->lng->txt(
"textsize_info" ) );
516 $textsize->setSize( 6 );
517 $textsize->setMinValue( 10 );
518 $textsize->setRequired( FALSE );
526 if ($this->object->getPoints() == null)
528 $points->setValue(
"1" );
532 $points->setValue( $this->object->getPoints() );
534 $points->setRequired( TRUE );
535 $points->setSize( 3 );
536 $points->setMinValue( 0.0 );
537 $points->setMinvalueShouldBeGreater(
true );
552 $this->
aggregateAnswers( $relevant_answers, $this->object->getOrderText() ) )->get();
557 $aggregate = array();
558 foreach($relevant_answers_chosen as $answer)
560 $answer = str_replace($this->object->getAnswerSeparator(),
' - ', $answer);
561 if (in_array($answer[
'value1'], $aggregate))
563 $aggregate[$answer[
'value1']] = $aggregate[$answer[
'value1']]+1;
567 $aggregate[$answer[
'value1']] = 1;
581 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
583 foreach ($aggregate as $key => $line_data)
585 $tpl->setCurrentBlock(
'aggregaterow' );
586 $tpl->setVariable(
'COUNT', $line_data );
587 $tpl->setVariable(
'OPTION', $key );
588 $tpl->parseCurrentBlock();
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
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.
getTestOutputSolutions($activeId, $pass)
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)
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
getTestOutput($active_id, $pass, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
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
const CSS_CLASS_FEEDBACK_WRONG
getSpecificFeedbackOutput($active_id, $pass)
Basic GUI class for assessment questions.
setErrorMessage($errormessage)
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.