ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
assOrderingQuestionGUI Class Reference

Ordering question GUI representation. More...

+ Inheritance diagram for assOrderingQuestionGUI:
+ Collaboration diagram for assOrderingQuestionGUI:

Public Member Functions

 __construct ($id=-1)
 assOrderingQuestionGUI constructor
 getCommand ($cmd)
 changeToPictures ()
 changeToText ()
 addanswers ()
 removeimageanswers ()
 removeanswers ()
 upanswers ()
 downanswers ()
 uploadanswers ()
 writePostData ($always=false, $clear_answers=false)
 Evaluates a posted edit form and writes the form data in the question object.
 editQuestion ($checkonly=FALSE)
 Creates an output of the edit form for the question.
 outQuestionForTest ($formaction, $active_id, $pass=NULL, $is_postponed=FALSE, $user_post_solution=FALSE)
 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.
 getPreview ($show_question_only=FALSE)
 getTestOutput ($active_id, $pass=NULL, $is_postponed=FALSE, $user_post_solution=FALSE)
 saveFeedback ()
 Saves the feedback for the question.
 setQuestionTabs ()
 Sets the ILIAS tabs for this question type.
 getSpecificFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question.
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor
executeCommand ()
 execute command
 getType ()
 needed for page editor compliance
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object.
 assessment ()
 output assessment
_getQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui note: please do not use $this inside this method to allow static calls.
 _getGUIClassNameForId ($a_q_id)
 _getClassNameForQType ($q_type)
createQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation.
 getQuestionTemplate ()
 get question template
 getILIASPage ($html="")
 Returns the ILIAS Page around a question.
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="")
 output question page
 cancel ()
 cancel action
 originalSyncForm ($return_to="")
 sync ()
 cancelSync ()
 saveEdit ()
 save question
 save ()
 save question
 saveReturn ()
 save question
 apply ()
 apply changes
 getContextPath ($cont_obj, $a_endnode_id, $a_startnode_id=1)
 get context path in content object tree
 setSequenceNumber ($nr)
 getSequenceNumber ()
 setQuestionCount ($a_question_count)
 getQuestionCount ()
 getErrorMessage ()
 setErrorMessage ($errormessage)
 addErrorMessage ($errormessage)
 outAdditionalOutput ()
 getQuestionType ()
 Returns the question type string.
 getAsValueAttribute ($a_value)
 Returns a HTML value attribute.
 addNewIdListener (&$a_object, $a_method, $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved.
 callNewIdListeners ($a_new_id)
 Call the new id listeners.
 setSelfAssessmentEditingMode ($a_selfassessmenteditingmode)
 Set Self-Assessment Editing Mode.
 getSelfAssessmentEditingMode ()
 Get Self-Assessment Editing Mode.
 setPreventRteUsage ($a_val)
 Set prevent rte usage.
 getPreventRteUsage ()
 Get prevent rte usage.
 setDefaultNrOfTries ($a_defaultnroftries)
 Set Default Nr of Tries.
 getDefaultNrOfTries ()
 Get Default Nr of Tries.
 addQuestionFormCommandButtons ($form)
 Add the command buttons of a question properties form.
 addBasicQuestionFormProperties ($form)
 Add basic question form properties: assessment: title, author, description, question, working time.
 getSelfAssessmentTags ()
 Get tags allowed in question tags in self assessment mode.
 getAnswerFeedbackOutput ($active_id, $pass)
 Returns the answer generic feedback depending on the results of the question.
 getGenericFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question.
 feedback ($checkonly=false)
 Creates the output of the feedback page for the question.
 outQuestionType ()
 suggestedsolution ()
 Allows to add suggested solutions for questions.
 outSolutionExplorer ()
 saveSuggestedSolution ()
 cancelExplorer ()
 outPageSelector ()
 outChapterSelector ()
 outGlossarySelector ()
 linkChilds ()
 addPG ()
 addST ()
 addGIT ()
 isSaveCommand ()
 isAutosaveable ()
 showHints ()

Private Member Functions

 getAnswerImageFileUploadWizardFormProperty ()
 isUploadAnswersCommand ()

Private Attributes

 $uploadAlert = null

Additional Inherited Members

- Data Fields inherited from assQuestionGUI
 $object
 $tpl
 $lng
 $error
 $errormessage
 $sequence_no
 sequence number in test
 $question_count
 question count in test
 $prevent_rte_usage = false
 do not use rte for editing
- Protected Member Functions inherited from assQuestionGUI
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI

Detailed Description

Ordering question GUI representation.

The assOrderingQuestionGUI class encapsulates the GUI representation for ordering questions.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 38 of file class.assOrderingQuestionGUI.php.

Constructor & Destructor Documentation

assOrderingQuestionGUI::__construct (   $id = -1)

assOrderingQuestionGUI constructor

The constructor takes possible arguments an creates an instance of the assOrderingQuestionGUI object.

Parameters
integer$idThe database id of a ordering question object public

Definition at line 50 of file class.assOrderingQuestionGUI.php.

References assQuestionGUI\__construct().

{
include_once "./Modules/TestQuestionPool/classes/class.assOrderingQuestion.php";
$this->object = new assOrderingQuestion();
if ($id >= 0)
{
$this->object->loadFromDb($id);
}
}

+ Here is the call graph for this function:

Member Function Documentation

assOrderingQuestionGUI::addanswers ( )

Definition at line 78 of file class.assOrderingQuestionGUI.php.

References $_POST, editQuestion(), and assQuestionGUI\writePostData().

{
$this->writePostData(true);
$position = key($_POST["cmd"]["addanswers"]);
$this->object->addAnswer("", $position+1);
$this->editQuestion();
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::changeToPictures ( )

Definition at line 66 of file class.assOrderingQuestionGUI.php.

References editQuestion(), and assQuestionGUI\writePostData().

{
$this->writePostData(true, true);
$this->editQuestion();
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::changeToText ( )

Definition at line 72 of file class.assOrderingQuestionGUI.php.

References editQuestion(), and assQuestionGUI\writePostData().

{
$this->writePostData(true, true);
$this->editQuestion();
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::downanswers ( )

Definition at line 111 of file class.assOrderingQuestionGUI.php.

References $_POST, editQuestion(), and assQuestionGUI\writePostData().

{
$this->writePostData(true);
$position = key($_POST["cmd"]["downanswers"]);
$this->object->moveAnswerDown($position);
$this->editQuestion();
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::editQuestion (   $checkonly = FALSE)

Creates an output of the edit form for the question.

public

Definition at line 256 of file class.assOrderingQuestionGUI.php.

References $_POST, $errors, assQuestionGUI\addBasicQuestionFormProperties(), assQuestionGUI\addQuestionFormCommandButtons(), ilNumberInputGUI\allowDecimals(), getAnswerImageFileUploadWizardFormProperty(), assQuestionGUI\getQuestionTemplate(), assQuestionGUI\getSelfAssessmentEditingMode(), assQuestionGUI\isSaveCommand(), OQ_PICTURES, OQ_TERMS, assQuestionGUI\outQuestionType(), ilFormPropertyGUI\setRequired(), and ilNumberInputGUI\setValue().

Referenced by addanswers(), changeToPictures(), changeToText(), downanswers(), removeanswers(), removeimageanswers(), upanswers(), uploadanswers(), and writePostData().

{
$save = $this->isSaveCommand();
include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
$orderingtype = (array_key_exists('ordering_type', $_POST)) ? $_POST['ordering_type'] : $this->object->getOrderingType();
if (strcmp($this->ctrl->getCmd(), 'changeToText') == 0) $orderingtype = OQ_TERMS;
if (strcmp($this->ctrl->getCmd(), 'changeToPictures') == 0) $orderingtype = OQ_PICTURES;
$form = new ilPropertyFormGUI();
$form->setFormAction($this->ctrl->getFormAction($this));
$form->setTitle($this->outQuestionType());
$form->setMultipart(($orderingtype == OQ_PICTURES) ? TRUE : FALSE);
$form->setTableWidth("100%");
$form->setId("ordering");
// Edit mode
$hidden = new ilHiddenInputGUI("ordering_type");
$hidden->setValue($orderingtype);
$form->addItem($hidden);
// title, author, description, question, working time (assessment mode)
{
$element_height = new ilNumberInputGUI($this->lng->txt("element_height"), "element_height");
$element_height->setValue($this->object->getElementHeight());
$element_height->setRequired(false);
$element_height->setMaxLength(6);
$element_height->setMinValue(20);
$element_height->setSize(6);
$element_height->setInfo($this->lng->txt("element_height_info"));
$form->addItem($element_height);
}
if ($orderingtype == OQ_PICTURES)
{
$geometry = new ilNumberInputGUI($this->lng->txt("thumb_geometry"), "thumb_geometry");
$geometry->setValue($this->object->getThumbGeometry());
$geometry->setRequired(true);
$geometry->setMaxLength(6);
$geometry->setMinValue(20);
$geometry->setSize(6);
$geometry->setInfo($this->lng->txt("thumb_geometry_info"));
$form->addItem($geometry);
}
if (count($this->object->getAnswers()) == 0)
{
$this->object->addAnswer();
}
// Answers
if ($orderingtype == OQ_PICTURES)
{
$answerImageUpload = $this->getAnswerImageFileUploadWizardFormProperty();
if( $this->uploadAlert !== null )
{
$answerImageUpload->setAlert($this->uploadAlert);
}
$form->addItem($answerImageUpload);
}
else
{
$answers = new ilTextWizardInputGUI($this->lng->txt("answers"), "answers");
$answers->setRequired(TRUE);
$answers->setInfo($this->lng->txt('ordering_answer_sequence_info'));
$answers->setAllowMove(TRUE);
$answervalues = array();
foreach ($this->object->getAnswers() as $index => $answervalue)
{
$answervalues[$index] = $answervalue->getAnswertext();
}
ksort($answervalues);
$answers->setValues($answervalues);
$form->addItem($answers);
}
// points
$points = new ilNumberInputGUI($this->lng->txt("points"), "points");
$points->allowDecimals(true);
$points->setValue($this->object->getPoints());
$points->setRequired(TRUE);
$points->setSize(3);
$points->setMinValue(0);
$points->setMinvalueShouldBeGreater(true);
$form->addItem($points);
if (true || !$this->getSelfAssessmentEditingMode())
{
if ($orderingtype == OQ_PICTURES)
{
$form->addCommandButton("changeToText", $this->lng->txt("order_terms"));
}
else
{
$form->addCommandButton("changeToPictures", $this->lng->txt("order_pictures"));
}
}
$errors = false;
if ($save)
{
$form->setValuesByPost();
$errors = !$form->checkInput();
$form->setValuesByPost(); // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
if ($errors) $checkonly = false;
}
if (!$checkonly) $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
return $errors;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assOrderingQuestionGUI::getAnswerImageFileUploadWizardFormProperty ( )
private
Returns

Definition at line 122 of file class.assOrderingQuestionGUI.php.

References ilFormPropertyGUI\setRequired().

Referenced by editQuestion(), and uploadanswers().

{
include_once "./Modules/TestQuestionPool/classes/class.ilImageWizardInputGUI.php";
$answers = new ilImageWizardInputGUI($this->lng->txt("answers"), "answers");
$answers->setRequired(TRUE);
$answers->setQuestionObject($this->object);
$answers->setInfo($this->lng->txt('ordering_answer_sequence_info'));
$answers->setAllowMove(TRUE);
$answervalues = array();
foreach ($this->object->getAnswers() as $index => $answervalue)
{
$answervalues[$index] = $answervalue->getAnswertext();
}
$answers->setValues($answervalues);
return $answers;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assOrderingQuestionGUI::getCommand (   $cmd)

Reimplemented from assQuestionGUI.

Definition at line 61 of file class.assOrderingQuestionGUI.php.

References $cmd.

{
return $cmd;
}
assOrderingQuestionGUI::getPreview (   $show_question_only = FALSE)

Definition at line 527 of file class.assOrderingQuestionGUI.php.

References $_GET, $ilUser, assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), ilUtil\getStyleSheetLocation(), OQ_PICTURES, and OUTPUT_JAVASCRIPT.

{
global $ilUser;
// shuffle output
$keys = array_keys($this->object->answers);
shuffle($keys);
// generate the question output
include_once "./Services/UICore/classes/class.ilTemplate.php";
$template = new ilTemplate("tpl.il_as_qpl_ordering_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
$jsswitch = "";
if (strcmp($this->ctrl->getCmd(), 'preview') == 0)
{
if (array_key_exists('js', $_GET))
{
$ilUser->writePref('tst_javascript', $_GET['js']);
}
$jstemplate = new ilTemplate("tpl.il_as_qpl_javascript_switch.html", TRUE, TRUE, "Modules/TestQuestionPool");
if ($ilUser->getPref("tst_javascript") == 1)
{
$jstemplate->setVariable("JAVASCRIPT_IMAGE", ilUtil::getImagePath("javascript_disable.png"));
$jstemplate->setVariable("JAVASCRIPT_IMAGE_ALT", $this->lng->txt("disable_javascript"));
$jstemplate->setVariable("JAVASCRIPT_IMAGE_TITLE", $this->lng->txt("disable_javascript"));
$this->ctrl->setParameterByClass($this->ctrl->getCmdClass(), "js", "0");
$jstemplate->setVariable("JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
}
else
{
$jstemplate->setVariable("JAVASCRIPT_IMAGE", ilUtil::getImagePath("javascript.png"));
$jstemplate->setVariable("JAVASCRIPT_IMAGE_ALT", $this->lng->txt("enable_javascript"));
$jstemplate->setVariable("JAVASCRIPT_IMAGE_TITLE", $this->lng->txt("enable_javascript"));
$this->ctrl->setParameterByClass($this->ctrl->getCmdClass(), "js", "1");
$jstemplate->setVariable("JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
}
$jsswitch = $jstemplate->get();
if ($ilUser->getPref('tst_javascript')) $this->object->setOutputType(OUTPUT_JAVASCRIPT);
}
if ($this->object->getOutputType() == OUTPUT_JAVASCRIPT)
{
// BEGIN: add javascript code for javascript enabled ordering questions
$this->tpl->addBlockFile("CONTENT_BLOCK", "head_content", "tpl.il_as_qpl_ordering_output_javascript.html", "Modules/TestQuestionPool");
$this->tpl->setCurrentBlock("head_content");
$this->tpl->setVariable("JS_LOCATION", "./Modules/TestQuestionPool/js/toolman/");
$this->tpl->parseCurrentBlock();
// END: add javascript code for javascript enabled ordering questions
// BEGIN: add additional stylesheet for javascript enabled ordering questions
$this->tpl->setCurrentBlock("AdditionalStyle");
$this->tpl->setVariable("LOCATION_ADDITIONAL_STYLESHEET", ilUtil::getStyleSheetLocation("output", "test_javascript.css", "Modules/TestQuestionPool"));
$this->tpl->parseCurrentBlock();
// END: add additional stylesheet for javascript enabled ordering questions
}
if ($this->object->getOutputType() != OUTPUT_JAVASCRIPT)
{
foreach ($keys as $idx)
{
$answer = $this->object->answers[$idx];
if ($this->object->getOrderingType() == OQ_PICTURES)
{
$template->setCurrentBlock("ordering_row_standard_pictures");
$template->setVariable("PICTURE_HREF", $this->object->getImagePathWeb() . $answer->getAnswertext());
$thumbweb = $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getAnswertext();
$thumb = $this->object->getImagePath() . $this->object->getThumbPrefix() . $answer->getAnswertext();
if (!@file_exists($thumb)) $this->object->rebuildThumbnails();
$template->setVariable("THUMB_HREF", $thumbweb);
$template->setVariable("THUMB_ALT", $this->lng->txt("thumbnail"));
$template->setVariable("THUMB_TITLE", $this->lng->txt("enlarge"));
$template->setVariable("ANSWER_ID", $answer->getRandomID());
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock("ordering_row_standard_text");
$template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
$template->setVariable("ANSWER_ID", $answer->getRandomID());
$template->parseCurrentBlock();
}
$template->setCurrentBlock("ordering_row_standard");
$template->setVariable("ANSWER_ID", $answer->getRandomID());
$template->parseCurrentBlock();
}
}
else
{
foreach ($keys as $idx)
{
$answer = $this->object->answers[$idx];
if ($this->object->getOrderingType() == OQ_PICTURES)
{
$template->setCurrentBlock("ordering_row_javascript_pictures");
$template->setVariable("PICTURE_HREF", $this->object->getImagePathWeb() . $answer->getAnswertext());
$thumbweb = $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getAnswertext();
$thumb = $this->object->getImagePath() . $this->object->getThumbPrefix() . $answer->getAnswertext();
if (!@file_exists($thumb)) $this->object->rebuildThumbnails();
$template->setVariable("THUMB_HREF", $thumbweb);
$template->setVariable("THUMB_ALT", $this->lng->txt("thumbnail"));
$template->setVariable("THUMB_TITLE", $this->lng->txt("thumbnail"));
$template->setVariable("ENLARGE_HREF", ilUtil::getImagePath("enlarge.png", FALSE));
$template->setVariable("ENLARGE_ALT", $this->lng->txt("enlarge"));
$template->setVariable("ENLARGE_TITLE", $this->lng->txt("enlarge"));
$template->setVariable("ANSWER_ID", $answer->getRandomID());
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock("ordering_row_javascript_text");
$template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
$template->setVariable("ANSWER_ID", $answer->getRandomID());
$template->parseCurrentBlock();
}
}
$template->setCurrentBlock("ordering_with_javascript");
if ($this->object->getOrderingType() == OQ_PICTURES)
{
$template->setVariable("RESET_POSITIONS", $this->lng->txt("reset_pictures"));
}
else
{
$template->setVariable("RESET_POSITIONS", $this->lng->txt("reset_definitions"));
}
$template->parseCurrentBlock();
}
$questiontext = $this->object->getQuestion();
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
$questionoutput = $jsswitch . $template->get();
if (!$show_question_only)
{
// get page object output
$questionoutput = $this->getILIASPage($questionoutput);
}
return $questionoutput;
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::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.

Parameters
integer$active_idThe active user id
integer$passThe test pass
boolean$graphicalOutputShow visual feedback for right/wrong answers
boolean$result_outputShow the reached points for parts of the question
boolean$show_question_onlyShow the question without the ILIAS content around
boolean$show_feedbackShow the question feedback
boolean$show_correct_solutionShow the correct solution instead of the user solution
boolean$show_manual_scoringShow specific information for the manual scoring output
Returns
The solution output of the question as HTML code

Reimplemented from assQuestionGUI.

Definition at line 390 of file class.assOrderingQuestionGUI.php.

References $ok, $pass, assQuestionGUI\getAnswerFeedbackOutput(), ilUtil\getImagePath(), and OQ_PICTURES.

{
// shuffle output
$keys = array_keys($this->object->answers);
// generate the question output
include_once "./Services/UICore/classes/class.ilTemplate.php";
$template = new ilTemplate("tpl.il_as_qpl_ordering_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool");
$solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html",TRUE, TRUE, "Modules/TestQuestionPool");
// get the solution of the user for the active pass or from the last pass if allowed
$solutions = array();
if (($active_id > 0) && (!$show_correct_solution))
{
$solutions =& $this->object->getSolutionValues($active_id, $pass);
}
else
{
foreach ($this->object->answers as $index => $answer)
{
array_push($solutions, array("value1" => $index, "value2" => $index+1));
}
}
foreach ($keys as $idx)
{
$answer = $this->object->answers[$idx];
if (($active_id > 0) && (!$show_correct_solution))
{
if ($graphicalOutput)
{
$sol = array();
foreach ($solutions as $solution)
{
$sol[$solution["value1"]] = $solution["value2"];
}
asort($sol);
$sol = array_keys($sol);
$ans = array();
foreach ($this->object->answers as $k => $a)
{
$ans[$k] = $k;
}
asort($ans);
$ans = array_keys($ans);
$ok = FALSE;
foreach ($ans as $arr_idx => $ans_idx)
{
if ($ans_idx == $idx)
{
if ($ans_idx == $sol[$arr_idx])
{
$ok = TRUE;
}
}
}
// output of ok/not ok icons for user entered solutions
if ($ok)
{
$template->setCurrentBlock("icon_ok");
$template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.png"));
$template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock("icon_ok");
$template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.png"));
$template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
$template->parseCurrentBlock();
}
}
}
if ($this->object->getOrderingType() == OQ_PICTURES)
{
$template->setCurrentBlock("ordering_row_standard_pictures");
$thumbweb = $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getAnswertext();
$thumb = $this->object->getImagePath() . $this->object->getThumbPrefix() . $answer->getAnswertext();
if (!@file_exists($thumb)) $this->object->rebuildThumbnails();
$template->setVariable("THUMB_HREF", $thumbweb);
list($width, $height, $type, $attr) = getimagesize($thumb);
$template->setVariable("ATTR", $attr);
$template->setVariable("THUMB_ALT", $this->lng->txt("thumbnail"));
$template->setVariable("THUMB_TITLE", $this->lng->txt("enlarge"));
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock("ordering_row_standard_text");
$template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
$template->parseCurrentBlock();
}
$template->setCurrentBlock("ordering_row_standard");
if ($result_output)
{
$answer = $this->object->answers[$idx];
$points = $answer->getPoints();
$resulttext = ($points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")";
$template->setVariable("RESULT_OUTPUT", sprintf($resulttext, $points));
}
foreach ($solutions as $solution)
{
if (strcmp($solution["value1"], $idx) == 0)
{
$template->setVariable("ANSWER_ORDER", $solution["value2"]);
}
}
$template->parseCurrentBlock();
}
$questiontext = $this->object->getQuestion();
if ($show_question_text==true)
{
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
}
$questionoutput = $template->get();
$feedback = ($show_feedback) ? $this->getAnswerFeedbackOutput($active_id, $pass) : "";
if (strlen($feedback)) $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
$solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
$solutionoutput = $solutiontemplate->get();
if (!$show_question_only)
{
// get page object output
$solutionoutput = '<div class="ilc_question_Standard">'.$solutionoutput."</div>";
}
return $solutionoutput;
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::getSpecificFeedbackOutput (   $active_id,
  $pass 
)

Returns the answer specific feedback for the question.

This method should be overwritten by the actual question.

Todo:
Mark this method abstract!
Parameters
integer$active_idActive ID of the user
integer$passActive pass
Returns
string HTML Code with the answer specific feedback public

Reimplemented from assQuestionGUI.

Definition at line 985 of file class.assOrderingQuestionGUI.php.

{
$output = "";
return $this->object->prepareTextareaOutput($output, TRUE);
}
assOrderingQuestionGUI::getTestOutput (   $active_id,
  $pass = NULL,
  $is_postponed = FALSE,
  $user_post_solution = FALSE 
)

Definition at line 664 of file class.assOrderingQuestionGUI.php.

References $_SESSION, $pass, ilObjTest\_getPass(), ilObjTest\_getUsePreviousAnswers(), ilUtil\getImagePath(), ilUtil\getStyleSheetLocation(), OQ_PICTURES, OUTPUT_JAVASCRIPT, and assQuestionGUI\outQuestionPage().

Referenced by outQuestionForTest().

{
// shuffle output
$keys = array();
if (is_array($user_post_solution))
{
$keys = $_SESSION["ordering_keys"];
}
else
{
$keys = array_keys($this->object->answers);
shuffle($keys);
}
$_SESSION["ordering_keys"] = $keys;
// generate the question output
include_once "./Services/UICore/classes/class.ilTemplate.php";
$template = new ilTemplate("tpl.il_as_qpl_ordering_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
if ($this->object->getOutputType() == OUTPUT_JAVASCRIPT)
{
// BEGIN: add javascript code for javascript enabled ordering questions
$this->tpl->addBlockFile("CONTENT_BLOCK", "head_content", "tpl.il_as_qpl_ordering_output_javascript.html", "Modules/TestQuestionPool");
$this->tpl->setCurrentBlock("head_content");
$this->tpl->setVariable("JS_LOCATION", "./Modules/TestQuestionPool/js/toolman/");
$this->tpl->parseCurrentBlock();
// END: add javascript code for javascript enabled ordering questions
// BEGIN: add additional stylesheet for javascript enabled ordering questions
$this->tpl->setCurrentBlock("AdditionalStyle");
$this->tpl->setVariable("LOCATION_ADDITIONAL_STYLESHEET", ilUtil::getStyleSheetLocation("output", "test_javascript.css", "Modules/TestQuestionPool"));
$this->tpl->parseCurrentBlock();
// END: add additional stylesheet for javascript enabled ordering questions
// BEGIN: onsubmit form action for javascript enabled ordering questions
$this->tpl->setVariable("ON_SUBMIT", "return saveOrder('orderlist');");
// END: onsubmit form action for javascript enabled ordering questions
}
// get the solution of the user for the active pass or from the last pass if allowed
if ($active_id)
{
$solutions = NULL;
include_once "./Modules/Test/classes/class.ilObjTest.php";
if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
{
if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
}
if (is_array($user_post_solution))
{
$solutions = array();
foreach ($user_post_solution as $key => $value)
{
if (preg_match("/order_(\d+)/", $key, $matches))
{
foreach ($this->object->getAnswers() as $answeridx => $answer)
{
if ($answer->getRandomID() == $matches[1])
{
array_push($solutions, array("value1" => $answeridx, "value2" => $value));
}
}
}
}
}
else
{
$solutions =& $this->object->getSolutionValues($active_id, $pass);
}
if ($this->object->getOutputType() == OUTPUT_JAVASCRIPT)
{
$solution_script .= "";
$jssolutions = array();
foreach ($solutions as $idx => $solution_value)
{
if ((strcmp($solution_value["value2"], "") != 0) && (strcmp($solution_value["value1"], "") != 0))
{
$jssolutions[$solution_value["value2"]] = $solution_value["value1"];
}
}
if (count($jssolutions))
{
ksort($jssolutions);
$js = "";
foreach ($jssolutions as $key => $value)
{
if (is_object($this->object->getAnswer($value)))
{
$js .= "initialorder.push('id_" . $this->object->getAnswer($value)->getRandomID() . "');";
}
}
$js .= "restoreInitialOrder();";
}
if (strlen($js))
{
$template->setCurrentBlock("javascript_restore_order");
$template->setVariable("RESTORE_ORDER", $js);
$template->parseCurrentBlock();
}
}
}
if ($this->object->getOutputType() != OUTPUT_JAVASCRIPT)
{
foreach ($keys as $idx)
{
$answer = $this->object->answers[$idx];
if ($this->object->getOrderingType() == OQ_PICTURES)
{
$template->setCurrentBlock("ordering_row_standard_pictures");
$template->setVariable("PICTURE_HREF", $this->object->getImagePathWeb() . $answer->getAnswertext());
$thumbweb = $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getAnswertext();
$thumb = $this->object->getImagePath() . $this->object->getThumbPrefix() . $answer->getAnswertext();
if (!@file_exists($thumb)) $this->object->rebuildThumbnails();
$template->setVariable("THUMB_HREF", $thumbweb);
$template->setVariable("THUMB_ALT", $this->lng->txt("thumbnail"));
$template->setVariable("THUMB_TITLE", $this->lng->txt("enlarge"));
$template->setVariable("ANSWER_ID", $answer->getRandomID());
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock("ordering_row_standard_text");
$template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
$template->setVariable("ANSWER_ID", $answer->getRandomID());
$template->parseCurrentBlock();
}
$template->setCurrentBlock("ordering_row_standard");
$template->setVariable("ANSWER_ID", $answer->getRandomID());
if (is_array($solutions))
{
foreach ($solutions as $solution)
{
if (($solution["value1"] == $idx) && (strlen($solution["value2"])))
{
$template->setVariable("ANSWER_ORDER", " value=\"" . $solution["value2"] . "\"");
}
}
}
$template->parseCurrentBlock();
}
}
else
{
foreach ($keys as $idx)
{
$answer = $this->object->answers[$idx];
if ($this->object->getOrderingType() == OQ_PICTURES)
{
$template->setCurrentBlock("ordering_row_javascript_pictures");
$template->setVariable("PICTURE_HREF", $this->object->getImagePathWeb() . $answer->getAnswertext());
$thumbweb = $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getAnswertext();
$thumb = $this->object->getImagePath() . $this->object->getThumbPrefix() . $answer->getAnswertext();
if (!@file_exists($thumb)) $this->object->rebuildThumbnails();
$template->setVariable("THUMB_HREF", $thumbweb);
$template->setVariable("THUMB_ALT", $this->lng->txt("thumbnail"));
$template->setVariable("THUMB_TITLE", $this->lng->txt("thumbnail"));
$template->setVariable("ENLARGE_HREF", ilUtil::getImagePath("enlarge.png", FALSE));
$template->setVariable("ENLARGE_ALT", $this->lng->txt("enlarge"));
$template->setVariable("ENLARGE_TITLE", $this->lng->txt("enlarge"));
$template->setVariable("ANSWER_ID", $answer->getRandomID());
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock("ordering_row_javascript_text");
$template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
$template->setVariable("ANSWER_ID", $answer->getRandomID());
$template->parseCurrentBlock();
}
}
$template->setCurrentBlock("ordering_with_javascript");
if ($this->object->getOrderingType() == OQ_PICTURES)
{
$template->setVariable("RESET_POSITIONS", $this->lng->txt("reset_pictures"));
}
else
{
$template->setVariable("RESET_POSITIONS", $this->lng->txt("reset_definitions"));
}
$template->parseCurrentBlock();
}
$questiontext = $this->object->getQuestion();
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
$questionoutput = $template->get();
$pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
return $pageoutput;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assOrderingQuestionGUI::isUploadAnswersCommand ( )
private

Definition at line 151 of file class.assOrderingQuestionGUI.php.

{
return $this->ctrl->getCmd() == 'uploadanswers';
}
assOrderingQuestionGUI::outQuestionForTest (   $formaction,
  $active_id,
  $pass = NULL,
  $is_postponed = FALSE,
  $user_post_solution = FALSE 
)

Definition at line 370 of file class.assOrderingQuestionGUI.php.

References $pass, and getTestOutput().

{
$test_output = $this->getTestOutput($active_id, $pass, $is_postponed, $user_post_solution);
$this->tpl->setVariable("QUESTION_OUTPUT", $test_output);
$this->tpl->setVariable("FORMACTION", $formaction);
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::removeanswers ( )

Definition at line 95 of file class.assOrderingQuestionGUI.php.

References $_POST, editQuestion(), and assQuestionGUI\writePostData().

{
$this->writePostData(true);
$position = key($_POST["cmd"]["removeanswers"]);
$this->object->deleteAnswer($position);
$this->editQuestion();
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::removeimageanswers ( )

Definition at line 86 of file class.assOrderingQuestionGUI.php.

References $_POST, $filename, editQuestion(), and assQuestionGUI\writePostData().

{
$this->writePostData(true);
$position = key($_POST['cmd']['removeimageanswers']);
$filename = $_POST['answers']['imagename'][$position];
$this->object->removeAnswerImage($position);
$this->editQuestion();
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::saveFeedback ( )

Saves the feedback for the question.

public

Reimplemented from assQuestionGUI.

Definition at line 859 of file class.assOrderingQuestionGUI.php.

References $_POST, $errors, and assQuestionGUI\feedback().

{
include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
$errors = $this->feedback(true);
$this->object->saveFeedbackGeneric(0, $_POST["feedback_incomplete"]);
$this->object->saveFeedbackGeneric(1, $_POST["feedback_complete"]);
$this->object->cleanupMediaObjectUsage();
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::setQuestionTabs ( )

Sets the ILIAS tabs for this question type.

public

Todo:
: MOVE THIS STEPS TO COMMON QUESTION CLASS assQuestionGUI

Reimplemented from assQuestionGUI.

Definition at line 876 of file class.assOrderingQuestionGUI.php.

References $_GET, $_POST, $ref_id, assQuestionGUI\addTab_QuestionHints(), and ilTestExpressPage\getReturnToPageLink().

{
global $rbacsystem, $ilTabs;
$this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$q_type = $this->object->getQuestionType();
if (strlen($q_type))
{
$classname = $q_type . "GUI";
$this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
$this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
}
if ($_GET["q_id"])
{
if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
{
// edit page
$ilTabs->addTarget("edit_page",
$this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "edit"),
array("edit", "insert", "exec_pg"),
"", "", $force_active);
}
// edit page
$ilTabs->addTarget("preview",
$this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "preview"),
array("preview"),
"ilPageObjectGUI", "", $force_active);
}
$force_active = false;
if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
{
$url = "";
if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
$commands = $_POST["cmd"];
if (is_array($commands))
{
foreach ($commands as $key => $value)
{
if (preg_match("/^delete_.*/", $key, $matches))
{
$force_active = true;
}
}
}
// edit question properties
$ilTabs->addTarget("edit_question",
$url,
array("editQuestion", "save", "saveEdit", "addanswers", "removeanswers", "changeToPictures", "uploadanswers", "changeToText", "upanswers", "downanswers", "originalSyncForm"),
$classname, "", $force_active);
}
if ($_GET["q_id"])
{
$ilTabs->addTarget("feedback",
$this->ctrl->getLinkTargetByClass($classname, "feedback"),
array("feedback", "saveFeedback"),
$classname, "");
}
// add tab for question hint within common class assQuestionGUI
$this->addTab_QuestionHints($ilTabs);
if ($_GET["q_id"])
{
$ilTabs->addTarget("solution_hint",
$this->ctrl->getLinkTargetByClass($classname, "suggestedsolution"),
array("suggestedsolution", "saveSuggestedSolution", "outSolutionExplorer", "cancel",
"addSuggestedSolution","cancelExplorer", "linkChilds", "removeSuggestedSolution"
),
$classname,
""
);
}
// Assessment of questions sub menu entry
if ($_GET["q_id"])
{
$ilTabs->addTarget("statistics",
$this->ctrl->getLinkTargetByClass($classname, "assessment"),
array("assessment"),
$classname, "");
}
if (($_GET["calling_test"] > 0) || ($_GET["test_ref_id"] > 0))
{
$ref_id = $_GET["calling_test"];
if (strlen($ref_id) == 0) $ref_id = $_GET["test_ref_id"];
global $___test_express_mode;
if (!$_GET['test_express_mode'] && !$___test_express_mode) {
$ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
}
else {
$ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), $link);
}
}
else
{
$ilTabs->setBackTarget($this->lng->txt("qpl"), $this->ctrl->getLinkTargetByClass("ilobjquestionpoolgui", "questions"));
}
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::upanswers ( )

Definition at line 103 of file class.assOrderingQuestionGUI.php.

References $_POST, editQuestion(), and assQuestionGUI\writePostData().

{
$this->writePostData(true);
$position = key($_POST["cmd"]["upanswers"]);
$this->object->moveAnswerUp($position);
$this->editQuestion();
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::uploadanswers ( )

Definition at line 139 of file class.assOrderingQuestionGUI.php.

References editQuestion(), getAnswerImageFileUploadWizardFormProperty(), and assQuestionGUI\writePostData().

{
if( !$inp->checkInput() )
{
$this->uploadAlert = $inp->getAlert();
}
$this->writePostData(true);
$this->editQuestion();
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::writePostData (   $always = false,
  $clear_answers = false 
)

Evaluates a posted edit form and writes the form data in the question object.

Returns
integer A positive value, if one of the required fields wasn't set, else 0 private

Definition at line 162 of file class.assOrderingQuestionGUI.php.

References $_POST, $filename, editQuestion(), assQuestionGUI\getSelfAssessmentEditingMode(), and OQ_TERMS.

{
$hasErrors = (!$always) ? $this->editQuestion(true) : false;
if (!$hasErrors)
{
$this->object->setTitle($_POST["title"]);
$this->object->setAuthor($_POST["author"]);
$this->object->setComment($_POST["comment"]);
include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
$questiontext = $_POST["question"];
$this->object->setQuestion($questiontext);
$this->object->setThumbGeometry($_POST["thumb_geometry"]);
$this->object->setElementHeight($_POST["element_height"]);
{
$this->object->setNrOfTries($_POST['nr_of_tries']);
}
// adding estimated working time
$this->object->setEstimatedWorkingTime(
$_POST["Estimated"]["hh"],
$_POST["Estimated"]["mm"],
$_POST["Estimated"]["ss"]
);
$ordering_type = $_POST["ordering_type"];
$this->object->setOrderingType($ordering_type);
// Delete all existing answers and create new answers from the form data
$this->object->flushAnswers();
$saved = false;
// add answers
if ($_POST['ordering_type'] == OQ_TERMS)
{
$answers = $_POST["answers"];
if (is_array($answers))
{
foreach ($answers as $index => $answer)
{
if($clear_answers)
{
$answer = "";
}
$this->object->addAnswer($answer);
}
}
}
else
{
foreach (array_keys($_POST['answers']['count']) as $index)
{
if($clear_answers)
{
$this->object->addAnswer("");
continue;
}
$picturefile = $_POST['answers']['imagename'][$index];
$file_org_name = $_FILES['answers']['name']['image'][$index];
$file_temp_name = $_FILES['answers']['tmp_name']['image'][$index];
// new file
if (strlen($file_temp_name))
{
// check suffix
$suffix = strtolower(array_pop(explode(".", $file_org_name)));
if(in_array($suffix, array("jpg", "jpeg", "png", "gif")))
{
// upload image
$filename = $this->object->createNewImageFileName($file_org_name);
$filename = $this->object->getEncryptedFilename($filename);
if ($this->object->setImageFile($file_temp_name, $filename, $picturefile))
{
$picturefile = $filename;
}
}
}
$this->object->addAnswer($picturefile);
}
}
$this->object->setPoints($_POST["points"]);
return 0;
}
else
{
return 1;
}
}

+ Here is the call graph for this function:

Field Documentation

assOrderingQuestionGUI::$uploadAlert = null
private

Definition at line 40 of file class.assOrderingQuestionGUI.php.


The documentation for this class was generated from the following file: