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());
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 134 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
137 if (($active_id > 0) && (!$show_correct_solution)) {
138 $solutions =&$this->
object->getSolutionValues($active_id,
$pass);
139 if (strlen($solutions[0][
"value1"])) {
140 $elements = explode(
"{::}", $solutions[0][
"value1"]);
143 if (!count($elements)) {
144 $elements = $this->
object->getRandomOrderingElements();
147 foreach ($elements as
$id => $element) {
149 $template->setVariable(
"ELEMENT_ID",
"sol_e_" . $this->
object->getId() .
"_$id");
156 $elements = $this->
object->getOrderingElements();
157 foreach ($elements as
$id => $element) {
159 $template->setVariable(
"ELEMENT_ID",
"sol_e_" . $this->
object->getId() .
"_$id");
166 if (($active_id > 0) && (!$show_correct_solution)) {
167 if ($this->
object->getStep() === null) {
168 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
170 $reached_points = $this->
object->calculateReachedPoints($active_id,
$pass);
172 if ($graphicalOutput) {
174 if ($reached_points == $this->
object->getMaximumPoints()) {
177 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
181 if ($reached_points > 0) {
183 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
186 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
192 $reached_points = $this->
object->getPoints();
195 if ($result_output) {
196 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
197 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
199 if ($show_question_text==
true) {
200 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($this->object->getQuestion(),
true));
203 if ($this->
object->textsize >= 10) {
204 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->
object->textsize .
"%;\"");
208 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
209 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
213 if ($show_feedback) {
216 $feedback .= strlen($fb) ? $fb :
'';
220 $feedback .= strlen($fb) ? $fb :
'';
222 if (strlen($feedback)) {
228 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
229 $solutiontemplate->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput($feedback,
true));
231 $solutionoutput = $solutiontemplate->get();
232 if (!$show_question_only) {
236 return $solutionoutput;
239 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
243 $elements = $this->
object->splitAndTrimOrderElementText($elements, $this->
object->getAnswerSeparator());
245 $elements = $this->
object->getRandomOrderingElements();
248 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_preview.html",
true,
true,
"Modules/TestQuestionPool");
249 foreach ($elements as
$id => $element) {
251 $template->setVariable(
"ELEMENT_ID",
"e_" . $this->
object->getId() .
"_$id");
257 $template->setVariable(
"VALUE_ORDERRESULT",
' value="' . join($elements,
'{::}') .
'"');
258 if ($this->
object->textsize >= 10) {
259 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->
object->textsize .
"%;\"");
261 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($this->object->getQuestion(),
true));
263 if (!$show_question_only) {
267 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
268 return $questionoutput;
272 public function getTestOutput($active_id,
$pass, $is_postponed =
false, $use_post_solutions =
false, $show_feedback =
false)
276 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output.html",
true,
true,
"Modules/TestQuestionPool");
277 $elements = $this->
object->getRandomOrderingElements();
282 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 283 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 285 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 287 $solutions = $this->
object->getTestOutputSolutions($active_id,
$pass);
289 if (count($solutions) == 1) {
290 $elements = explode(
"{::}", $solutions[0][
"value1"]);
293 if (count($solutions) == 0) {
294 $_SESSION[
'qst_ordering_horizontal_elements'] = $elements;
296 unset(
$_SESSION[
'qst_ordering_horizontal_elements']);
298 foreach ($elements as
$id => $element) {
300 $template->setVariable(
"ELEMENT_ID",
"e_" . $this->
object->getId() .
"_$id");
306 if ($this->
object->textsize >= 10) {
307 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->
object->textsize .
"%;\"");
309 $template->setVariable(
"VALUE_ORDERRESULT",
' value="' . join($elements,
'{::}') .
'"');
310 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($this->object->getQuestion(),
true));
312 if (!$show_question_only) {
316 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
318 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
329 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
330 $errors = $this->feedback(
true);
331 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
332 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
333 $this->
object->cleanupMediaObjectUsage();
334 parent::saveFeedback();
346 global $rbacsystem, $ilTabs;
348 $ilTabs->clearTargets();
350 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
351 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
352 $q_type = $this->
object->getQuestionType();
354 if (strlen($q_type)) {
355 $classname = $q_type .
"GUI";
356 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
357 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
361 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
365 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
366 array(
"edit",
"insert",
"exec_pg"),
376 $force_active =
false;
377 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
380 $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
382 $commands =
$_POST[
"cmd"];
383 if (is_array($commands)) {
384 foreach ($commands as
$key => $value) {
385 if (preg_match(
"/^suggestrange_.*/",
$key, $matches)) {
386 $force_active =
true;
394 array(
"editQuestion",
"save",
"saveEdit",
"originalSyncForm"),
414 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
426 if (strpos($this->
object->getOrderText(),
'::')) {
427 $answers = explode(
'::', $this->
object->getOrderText());
429 $answers = explode(
' ', $this->
object->getOrderText());
432 if (!$this->
object->feedbackOBJ->specificAnswerFeedbackExists(array_values($answers))) {
436 $output =
'<table class="test_specific_feedback"><tbody>';
438 foreach ($answers as $idx => $answer) {
439 $feedback = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
444 $output .=
"<tr><td>{$answer}</td><td>{$feedback}</td></tr>";
449 return $this->
object->prepareTextareaOutput(
$output,
true);
454 $this->
object->setTextSize(
$_POST[
"textsize"]);
455 $this->
object->setOrderText(
$_POST[
"ordertext"]);
456 $this->
object->setPoints(
$_POST[
"points"]);
477 $ordertext->
setValue($this->
object->prepareTextareaOutput($this->object->getOrderText()));
478 $ordertext->setRequired(
true);
479 $ordertext->setInfo(sprintf($this->lng->txt(
"ordertext_info"), $this->
object->separator));
480 $ordertext->setRows(10);
481 $ordertext->setCols(80);
486 $textsize->setInfo($this->lng->txt(
"textsize_info"));
487 $textsize->setSize(6);
488 $textsize->setMinValue(10);
489 $textsize->setRequired(
false);
497 if ($this->
object->getPoints() == null) {
498 $points->setValue(
"1");
500 $points->setValue($this->
object->getPoints());
502 $points->setRequired(
true);
504 $points->setMinValue(0.0);
505 $points->setMinvalueShouldBeGreater(
true);
526 $aggregate =
array();
527 foreach ($relevant_answers_chosen as $answer) {
528 $answer = str_replace($this->
object->getAnswerSeparator(),
' - ', $answer);
529 if (in_array($answer[
'value1'], $aggregate)) {
530 $aggregate[$answer[
'value1']] = $aggregate[$answer[
'value1']]+1;
532 $aggregate[$answer[
'value1']] = 1;
546 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
548 foreach ($aggregate as
$key => $line_data) {
549 $tpl->setCurrentBlock(
'aggregaterow');
550 $tpl->setVariable(
'COUNT', $line_data);
552 $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
saveFeedback()
Saves the feedback for a single choice question.
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)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
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
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)
getPreview($show_question_only=false, $showInlineFeedback=false)
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.
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)
{}