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";
40 $this->
object->loadFromDb($id);
54 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
57 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
76 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
78 $this->editForm = $form;
80 $form->setFormAction($this->ctrl->getFormAction($this));
82 $form->setMultipart(FALSE);
83 $form->setTableWidth(
"100%");
84 $form->setId(
"orderinghorizontal");
98 $form->setValuesByPost();
100 $form->setValuesByPost();
101 if (
$errors) $checkonly =
false;
104 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
124 $graphicalOutput = FALSE,
125 $result_output = FALSE,
126 $show_question_only = TRUE,
127 $show_feedback = FALSE,
128 $show_correct_solution = FALSE,
129 $show_manual_scoring = FALSE,
130 $show_question_text = TRUE
134 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
137 if (($active_id > 0) && (!$show_correct_solution))
139 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
140 if (strlen($solutions[0][
"value1"]))
142 $elements = explode(
"{::}", $solutions[0][
"value1"]);
145 if( !count($elements) )
147 $elements = $this->
object->getRandomOrderingElements();
150 foreach ($elements as $id => $element)
152 $template->setCurrentBlock(
"element");
153 $template->setVariable(
"ELEMENT_ID",
"sol_e_" . $this->
object->getId() .
"_$id");
155 $template->parseCurrentBlock();
162 $elements = $this->
object->getOrderingElements();
163 foreach ($elements as $id => $element)
165 $template->setCurrentBlock(
"element");
166 $template->setVariable(
"ELEMENT_ID",
"sol_e_" . $this->
object->getId() .
"_$id");
168 $template->parseCurrentBlock();
173 if (($active_id > 0) && (!$show_correct_solution))
175 if($this->
object->getStep() === NULL)
177 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
181 $reached_points = $this->
object->calculateReachedPoints($active_id,
$pass);
183 if ($graphicalOutput)
186 if ($reached_points == $this->
object->getMaximumPoints())
188 $template->setCurrentBlock(
"icon_ok");
190 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
191 $template->parseCurrentBlock();
195 $template->setCurrentBlock(
"icon_ok");
196 if ($reached_points > 0)
199 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
204 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
206 $template->parseCurrentBlock();
212 $reached_points = $this->
object->getPoints();
217 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
218 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
220 if($show_question_text==
true)
222 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
225 if ($this->
object->textsize >= 10) $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->
object->textsize .
"%;\"");
227 $questionoutput = $template->get();
228 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
229 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
238 $feedback .= strlen($fb) ? $fb :
'';
242 $feedback .= strlen($fb) ? $fb :
'';
244 if (strlen($feedback))
250 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
251 $solutiontemplate->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput( $feedback,
true ));
253 $solutionoutput = $solutiontemplate->get();
254 if (!$show_question_only)
259 return $solutionoutput;
262 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
267 $elements = $this->
object->splitAndTrimOrderElementText($elements, $this->
object->getAnswerSeparator());
271 $elements = $this->
object->getRandomOrderingElements();
274 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_preview.html",TRUE, TRUE,
"Modules/TestQuestionPool");
275 foreach ($elements as $id => $element)
277 $template->setCurrentBlock(
"element");
278 $template->setVariable(
"ELEMENT_ID",
"e_" . $this->
object->getId() .
"_$id");
281 $template->parseCurrentBlock();
283 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
284 $template->setVariable(
"VALUE_ORDERRESULT",
' value="' . join($elements,
'{::}') .
'"');
285 if ($this->
object->textsize >= 10) $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->
object->textsize .
"%;\"");
286 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
287 $questionoutput = $template->get();
288 if (!$show_question_only)
293 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
294 return $questionoutput;
298 function getTestOutput($active_id,
$pass, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
302 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
303 $elements = $this->
object->getRandomOrderingElements();
309 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 310 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 312 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 314 $solutions = $this->
object->getTestOutputSolutions($active_id,
$pass);
316 if (count($solutions) == 1)
318 $elements = explode(
"{::}", $solutions[0][
"value1"]);
321 if (count($solutions) == 0)
323 $_SESSION[
'qst_ordering_horizontal_elements'] = $elements;
327 unset(
$_SESSION[
'qst_ordering_horizontal_elements']);
329 foreach ($elements as $id => $element)
331 $template->setCurrentBlock(
"element");
332 $template->setVariable(
"ELEMENT_ID",
"e_" . $this->
object->getId() .
"_$id");
335 $template->parseCurrentBlock();
337 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
338 if ($this->
object->textsize >= 10) $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->
object->textsize .
"%;\"");
339 $template->setVariable(
"VALUE_ORDERRESULT",
' value="' . join($elements,
'{::}') .
'"');
340 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
341 $questionoutput = $template->get();
342 if (!$show_question_only)
347 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
348 $questionoutput = $template->get();
349 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
360 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
361 $errors = $this->feedback(
true);
362 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
363 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
364 $this->
object->cleanupMediaObjectUsage();
365 parent::saveFeedback();
377 global $rbacsystem, $ilTabs;
379 $ilTabs->clearTargets();
381 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
382 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
383 $q_type = $this->
object->getQuestionType();
387 $classname = $q_type .
"GUI";
388 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
389 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
394 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
397 $ilTabs->addTarget(
"edit_page",
398 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
399 array(
"edit",
"insert",
"exec_pg"),
400 "",
"", $force_active);
406 $force_active =
false;
407 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
410 if ($classname)
$url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
411 $commands =
$_POST[
"cmd"];
412 if (is_array($commands))
414 foreach ($commands as $key => $value)
416 if (preg_match(
"/^suggestrange_.*/", $key, $matches))
418 $force_active =
true;
423 $ilTabs->addTarget(
"edit_question",
425 array(
"editQuestion",
"save",
"saveEdit",
"originalSyncForm"),
426 $classname,
"", $force_active);
441 $ilTabs->addTarget(
"statistics",
442 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
452 if(strpos($this->
object->getOrderText(),
'::'))
454 $answers = explode(
'::', $this->
object->getOrderText());
456 $answers = explode(
' ', $this->
object->getOrderText());
459 if( !$this->
object->feedbackOBJ->specificAnswerFeedbackExists(array_values($answers)) )
464 $output =
'<table class="test_specific_feedback"><tbody>';
466 foreach($answers as $idx => $answer)
468 $feedback = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
469 $this->
object->getId(), $idx
472 $output .=
"<tr><td>{$answer}</td><td>{$feedback}</td></tr>";
477 return $this->
object->prepareTextareaOutput(
$output, TRUE);
482 $this->
object->setTextSize(
$_POST[
"textsize"] );
483 $this->
object->setOrderText(
$_POST[
"ordertext"] );
484 $this->
object->setPoints(
$_POST[
"points"] );
505 $ordertext->
setValue( $this->
object->prepareTextareaOutput( $this->object->getOrderText() ) );
506 $ordertext->setRequired( TRUE );
507 $ordertext->setInfo( sprintf( $this->lng->txt(
"ordertext_info" ), $this->
object->separator ) );
508 $ordertext->setRows( 10 );
509 $ordertext->setCols( 80 );
512 $textsize =
new ilNumberInputGUI($this->lng->txt(
"textsize" ),
"textsize");
514 $textsize->setInfo( $this->lng->txt(
"textsize_info" ) );
515 $textsize->setSize( 6 );
516 $textsize->setMinValue( 10 );
517 $textsize->setRequired( FALSE );
525 if ($this->
object->getPoints() == null)
527 $points->setValue(
"1" );
531 $points->setValue( $this->
object->getPoints() );
533 $points->setRequired( TRUE );
534 $points->setSize( 3 );
535 $points->setMinValue( 0.0 );
536 $points->setMinvalueShouldBeGreater(
true );
556 $aggregate =
array();
557 foreach($relevant_answers_chosen as $answer)
559 $answer = str_replace($this->
object->getAnswerSeparator(),
' - ', $answer);
560 if (in_array($answer[
'value1'], $aggregate))
562 $aggregate[$answer[
'value1']] = $aggregate[$answer[
'value1']]+1;
566 $aggregate[$answer[
'value1']] = 1;
580 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
582 foreach ($aggregate as $key => $line_data)
584 $tpl->setCurrentBlock(
'aggregaterow' );
585 $tpl->setVariable(
'COUNT', $line_data );
586 $tpl->setVariable(
'OPTION', $key );
587 $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.
setValue($a_value)
Set Value.
The assOrderingHorizontalGUI class encapsulates the GUI representation for horizontal ordering questi...
Add rich text string
The name of the decorator.
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
renderAggregateView($aggregate)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
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.
Create styles array
The data for the language used.
saveTaxonomyAssignments()
__construct($id=-1)
assOrderingHorizontalGUI constructor
setQuestionTabs()
Sets the ILIAS tabs for this question type.
Create new PHPExcel object
obj_idprivate
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)
{}