ILIAS  Release_4_4_x_branch Revision 61816
 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
 changeToPictures ()
 changeToText ()
 orderNestedTerms ()
 orderNestedPictures ()
 addanswers ()
 removeimageanswers ()
 removeanswers ()
 upanswers ()
 downanswers ()
 uploadanswers ()
 writeQuestionSpecificPostData ($always=true)
 Extracts the question specific values from $_POST and applies them to the data object.
 writeAnswerSpecificPostData ($clear_answers=false)
 Extracts the answer specific values from $_POST and applies them to the data object.
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui.
 populateQuestionSpecificFormPart (\ilPropertyFormGUI $form)
 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)
 setQuestionTabs ()
 Sets the ILIAS tabs for this question type.
 getSpecificFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question.
 setLeveledOrdering ($new_hierarchy)
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment.
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment.
 resetFormValuesForSuppressedPostvars ($form)
 getAggregatedAnswersView ($relevant_answers)
 Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface.
 aggregateAnswers ($relevant_answers_chosen, $answers_defined_on_question)
 renderAggregateView ($aggregate)
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor
executeCommand ()
 execute command
 getCommand ($cmd)
 getType ()
 needed for page editor compliance
 setTaxonomyIds ($taxonomyIds)
 getTaxonomyIds ()
 setTargetGui (ilTestPlayerAbstractGUI $linkTargetGui)
 setTargetGuiClass ($targetGuiClass)
 getTargetGuiClass ()
 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="", $return_to_feedback= '')
 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.
 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.
 outQuestionType ()
 showSuggestedSolution ()
 suggestedsolution ()
 Allows to add suggested solutions for questions.
 outSolutionExplorer ()
 saveSuggestedSolution ()
 cancelExplorer ()
 outPageSelector ()
 outChapterSelector ()
 outGlossarySelector ()
 linkChilds ()
 addPG ()
 addST ()
 addGIT ()
 isSaveCommand ()
 isAutosaveable ()
 showHints ()
- Public Member Functions inherited from ilGuiQuestionScoringAdjustable
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui.

Data Fields

 $old_ordering_depth = array()
 $leveled_ordering = array()
- Data Fields inherited from assQuestionGUI
const FORM_MODE_EDIT = 'edit'
const FORM_MODE_ADJUST = 'adjust'
 $object
 $tpl
 $lng
 $error
 $errormessage
 $sequence_no
 sequence number in test
 $question_count
 question count in test

Private Member Functions

 getAnswerImageFileUploadWizardFormProperty ()
 isUploadAnswersCommand ()
 populateCommandButtons (ilPropertyFormGUI $form)
 getRandomIdToAnswerMap ()
 getDepthRecursive ($child, $ordering_depth)
 getOldLeveledOrdering ()

Private Attributes

 $uploadAlert = null

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static getCommandsFromClassConstants ($guiClassName, $cmdConstantNameBegin= 'CMD_')
 extracts values of all constants of given class with given prefix as array can be used to get all possible commands in case of these commands are defined as constants
- Protected Member Functions inherited from assQuestionGUI
 saveTaxonomyAssignments ()
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI
 writeQuestionGenericPostData ()

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
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
Id:
class.assOrderingQuestionGUI.php 56134 2014-12-09 13:22:18Z mbecker

Definition at line 22 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
Returns
assOrderingQuestionGUI

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

References assQuestionGUI\__construct(), and OUTPUT_JAVASCRIPT.

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

+ Here is the call graph for this function:

Member Function Documentation

assOrderingQuestionGUI::addanswers ( )

Definition at line 113 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::aggregateAnswers (   $relevant_answers_chosen,
  $answers_defined_on_question 
)

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

References OQ_PICTURES, and OQ_TERMS.

Referenced by getAggregatedAnswersView().

{
$passdata = array(); // Regroup answers into one line per pass.
foreach($relevant_answers_chosen as $answer_chosen)
{
$pass_ident = $answer_chosen['active_fi'].'-'. $answer_chosen['pass'];
$answers = $passdata[$pass_ident];
if(!strlen($answers))
{
$answers = array();
}
else
{
$answers = explode(',',$answers);
}
if($this->object->getOrderingType() == OQ_TERMS || $this->object->getOrderingType() == OQ_PICTURES)
{
$answers[$answer_chosen['value2']] = $answer_chosen['value1'];
} else {
$parts = explode(':',$answer_chosen['value2']);
$item = $parts[0];
$depth = $parts[1];
$answers[$answer_chosen['value1']] = implode('|', array($depth,$item));
}
$passdata[$pass_ident] = implode(',', $answers);
}
$variants = array();
foreach($passdata as $line_data)
{
if(isset($variants[$line_data]))
{
$variants[$line_data]++;
}
else
{
$variants[$line_data] = 1;
}
}
return $variants;
}

+ Here is the caller graph for this function:

assOrderingQuestionGUI::changeToPictures ( )

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

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

{
if($this->object->getOrderingType() != OQ_NESTED_PICTURES && $this->object->getOrderingType() != OQ_PICTURES)
{
$clearAnswers = true;
}
else
{
$clearAnswers = false;
}
$this->object->setOrderingType(OQ_PICTURES);
$this->writePostData(true, $clearAnswers);
$this->object->saveToDb();
$this->editQuestion();
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::changeToText ( )

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

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

{
if($this->object->getOrderingType() != OQ_NESTED_TERMS && $this->object->getOrderingType() != OQ_TERMS)
{
$clearAnswers = true;
}
else
{
$clearAnswers = false;
}
$this->object->setOrderingType(OQ_TERMS);
$this->writePostData(true, $clearAnswers);
$this->object->saveToDb();
$this->editQuestion();
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::downanswers ( )

Definition at line 146 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.

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

References $errors, assQuestionGUI\addBasicQuestionFormProperties(), assQuestionGUI\addQuestionFormCommandButtons(), ilPropertyFormGUI\checkInput(), ilPropertyFormGUI\getHTML(), assQuestionGUI\getQuestionTemplate(), assQuestionGUI\isSaveCommand(), OQ_PICTURES, assQuestionGUI\outQuestionType(), populateAnswerSpecificFormPart(), populateCommandButtons(), populateQuestionSpecificFormPart(), assQuestionGUI\populateTaxonomyFormSection(), ilFormGUI\setFormAction(), ilFormGUI\setId(), ilFormGUI\setMultipart(), ilPropertyFormGUI\setTableWidth(), ilPropertyFormGUI\setTitle(), and ilPropertyFormGUI\setValuesByPost().

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

{
$save = $this->isSaveCommand();
$orderingtype = $this->object->getOrderingType();
require_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
$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");
// title, author, description, question, working time (assessment mode)
if (true || !$this->object->getSelfAssessmentEditingMode())
{
$this->populateCommandButtons($form);
}
$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::getAfterParticipationSuppressionAnswerPostVars ( )

Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment.

The form elements will be shown disabled, so the users see the usual form but can only edit the settings, which make sense in the given context.

E.g. array('cloze_type', 'image_filename')

Returns
string[]

Implements ilGuiAnswerScoringAdjustable.

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

{
return array();
}
assOrderingQuestionGUI::getAfterParticipationSuppressionQuestionPostVars ( )

Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment.

The form elements will be shown disabled, so the users see the usual form but can only edit the settings, which make sense in the given context.

E.g. array('cloze_type', 'image_filename')

Returns
string[]

Implements ilGuiQuestionScoringAdjustable.

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

{
return array('element_height', 'thumb_geometry','answers');
}
assOrderingQuestionGUI::getAggregatedAnswersView (   $relevant_answers)

Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface.

Parameters
array$relevant_answers
Returns
string

Implements ilGuiQuestionScoringAdjustable.

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

References $pass, assQuestionGUI\$tpl, aggregateAnswers(), and renderAggregateView().

{
$passes = array();
foreach($relevant_answers as $pass)
{
$passes[$pass['active_fi'].'-'.$pass['pass']] = '-';
}
$passcount = count($passes);
foreach($relevant_answers as $pass)
{
$actives[$pass['active_fi']] = $pass['active_fi'];
}
$usercount = count($actives);
$tpl = new ilTemplate('tpl.il_as_aggregated_answers_header.html', true, true, "Modules/TestQuestionPool");
$tpl->setVariable('HEADERTEXT', $this->lng->txt('overview'));
$tpl->setVariable('NUMBER_OF_USERS_INFO', $this->lng->txt('number_of_users'));
$tpl->setVariable('NUMBER_OF_USERS', $usercount);
$tpl->setVariable('NUMBER_OF_PASSES_INFO', $this->lng->txt('number_of_passes'));
$tpl->setVariable('NUMBER_OF_PASSES', $passcount);
return $tpl->get() . $this->renderAggregateView(
$this->aggregateAnswers( $relevant_answers, $this->object->getAnswers() ) )->get();
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::getAnswerImageFileUploadWizardFormProperty ( )
private
Returns

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

References ilFormPropertyGUI\setRequired().

Referenced by populateAnswerSpecificFormPart(), 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::getDepthRecursive (   $child,
  $ordering_depth 
)
private

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

Referenced by setLeveledOrdering().

{
if(is_array($child->children))
{
foreach($child->children as $grand_child)
{
$ordering_depth++;
$this->leveled_ordering[] = $ordering_depth;
$this->getDepthRecursive($grand_child, $ordering_depth);
}
}
else
{
$ordering_depth++;
$this->leveled_ordering[] = $ordering_depth;
}
}

+ Here is the caller graph for this function:

assOrderingQuestionGUI::getOldLeveledOrdering ( )
private

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

References $old_ordering_depth, $res, and $row.

Referenced by writeAnswerSpecificPostData().

{
global $ilDB;
$res = $ilDB->queryF('SELECT depth FROM qpl_a_ordering WHERE question_fi = %s ORDER BY solution_order ASC',
array('integer'), array($this->object->getId()));
while($row = $ilDB->fetchAssoc($res))
{
$this->old_ordering_depth[] = $row['depth'];
}
}

+ Here is the caller graph for this function:

assOrderingQuestionGUI::getPreview (   $show_question_only = FALSE)

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

References $_GET, $ilUser, assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), ilUtil\getStyleSheetLocation(), iljQueryUtil\initjQuery(), iljQueryUtil\initjQueryUI(), OQ_NESTED_PICTURES, OQ_NESTED_TERMS, 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");
if ($this->object->getOrderingType() == OQ_NESTED_TERMS
||$this->object->getOrderingType() == OQ_NESTED_PICTURES)
{
$this->object->setOutputType(OUTPUT_JAVASCRIPT);
// 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 = "";
include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
include_once 'Modules/TestQuestionPool/classes/class.ilNestedOrderingGUI.php';
$answers = new ilNestedOrderingGUI($this->lng->txt("answers"), "answers");
$answers->setOrderingType($this->object->getOrderingType());
$answers->setObjAnswersArray($this->object->answers);
if($this->object->getOrderingType() == OQ_NESTED_PICTURES)
{
$answers->setImagePath($this->object->getImagePath());
$answers->setImagePathWeb($this->object->getImagePathWeb());
$answers->setThumbPrefix($this->object->getThumbPrefix());
}
$template->setCurrentBlock('nested_ordering_output');
$template->setVariable('NESTED_ORDERING',$answers->getHtml());
$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;
}
else
{
$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->touchBlock('head_content');
require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
// 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::getRandomIdToAnswerMap ( )
private

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

Referenced by getTestOutput().

{
$randomIdToAnswerMap = array();
foreach($this->object->answers as $answer)
{
$randomIdToAnswerMap[$answer->getRandomId()] = $answer;
}
return $randomIdToAnswerMap;
}

+ Here is the caller 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
bool$show_question_text
Returns
string The solution output of the question as HTML code

Reimplemented from assQuestionGUI.

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

References $ok, $pass, assQuestionGUI\getAnswerFeedbackOutput(), assQuestionGUI\getGenericFeedbackOutput(), assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), getSpecificFeedbackOutput(), OQ_NESTED_PICTURES, OQ_NESTED_TERMS, and OQ_PICTURES.

{
if($this->object->getOrderingType() == OQ_NESTED_TERMS
|| $this->object->getOrderingType() == OQ_NESTED_PICTURES)
{
$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_nested_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);
$user_order = array();
foreach ($solutions as $solution)
{
if(strchr( $solution['value2'],':') == true)
{
$current_solution = explode(':', $solution['value2']);
$user_order[$solution["value1"]]['index'] = $solution["value1"];
$user_order[$solution["value1"]]['random_id'] = $current_solution[0];
$user_order[$solution["value1"]]['depth'] = $current_solution[1];
// needed for graphical output
$answer_text = $this->object->lookupAnswerTextByRandomId($current_solution[0]);
$user_order[$solution["value1"]]['answertext'] = $answer_text;
}
}
foreach ($this->object->answers as $k => $a)
{
$ok = FALSE;
if ($k == $user_order[$k]['index']
&& $a->getOrderingDepth() == $user_order[$k]['depth']
&& $a->getAnswerText() == $user_order[$k]['answertext'])
{
$ok = TRUE;
}
$user_order[$k]['ok'] = $ok;
}
$solution_output = $user_order;
}
else
{
foreach ($this->object->answers as $index => $answer)
{
$expected_solution[$index]['index'] = $index;
$expected_solution[$index]['random_id'] = $answer->getRandomId();
$expected_solution[$index]['depth'] = $answer->getOrderingDepth();
if($this->object->getOrderingType() == OQ_NESTED_PICTURES)
{
$expected_solution[$index]['answertext'] = $answer->getAnswertext();
}
else
{
$expected_solution[$index]['answertext'] = $answer->getAnswertext();
}
}
$solution_output = $expected_solution;
}
include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
include_once 'Modules/TestQuestionPool/classes/class.ilNestedOrderingGUI.php';
$answers_gui = new ilNestedOrderingGUI($this->lng->txt("answers"), "answers", $graphicalOutput);
$no_js_for_cmds = array('outParticipantsPassDetails', 'outCorrectSolution', 'showManScoringParticipantScreen');
//PERFORM_JAVASCRIPT
if(in_array($this->ctrl->getCmd(), $no_js_for_cmds))
{
$answers_gui->setPerformJavascript(false);
}
else
{
$answers_gui->setPerformJavascript(true);
}
$answers_gui->setOrderingType($this->object->getOrderingType());
if($this->object->getOrderingType() == OQ_NESTED_PICTURES)
{
$answers_gui->setImagePath($this->object->getImagePath());
$answers_gui->setImagePathWeb($this->object->getImagePathWeb());
$answers_gui->setThumbPrefix($this->object->getThumbPrefix());
}
$solution_html = $answers_gui->getSolutionHTML($solution_output);
$template->setVariable('SOLUTION_OUTPUT', $solution_html);
$questiontext = $this->object->getQuestion();
if ($show_question_text==true)
{
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
}
$questionoutput = $template->get();
$feedback = '';
if($show_feedback)
{
$fb = $this->getGenericFeedbackOutput($active_id, $pass);
$feedback .= strlen($fb) ? $fb : '';
$fb = $this->getSpecificFeedbackOutput($active_id, $pass);
$feedback .= strlen($fb) ? $fb : '';
}
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 = $this->getILIASPage($solutionoutput);
}
return $solutionoutput;
}
else
{
$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)
{
if (!$show_correct_solution)
{
foreach($solutions as $index => $item)
{
if($item['value2'] == $idx+1)
{
$answer = $this->object->answers[$item['value1']];
}
}
}
else
{
$answer = $this->object->answers[$idx];
}
if (!$answer)
{
continue;
}
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 = $this->getILIASPage($solutionoutput);
$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 1418 of file class.assOrderingQuestionGUI.php.

Referenced by getSolutionOutput().

{
$output = '<table class="ilTstSpecificFeedbackTable"><tbody>';
foreach($this->object->getAnswers() as $idx => $answer)
{
$feedback = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
$this->object->getId(), $idx
);
$output .= "<tr><td><b><i>{$answer->getAnswerText()}</i></b></td><td>{$feedback}</td></tr>";
}
$output .= '</tbody></table>';
return $this->object->prepareTextareaOutput($output, TRUE);
}

+ Here is the caller graph for this function:

assOrderingQuestionGUI::getTestOutput (   $active_id,
  $pass = NULL,
  $is_postponed = FALSE,
  $user_post_solution = FALSE 
)

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

References $_POST, $_SESSION, $pass, ilObjTest\_getPass(), ilObjTest\_getUsePreviousAnswers(), ilUtil\getImagePath(), getRandomIdToAnswerMap(), ilUtil\getStyleSheetLocation(), iljQueryUtil\initjQuery(), iljQueryUtil\initjQueryUI(), OQ_NESTED_PICTURES, OQ_NESTED_TERMS, 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->getOrderingType() == OQ_NESTED_TERMS
|| $this->object->getOrderingType() == OQ_NESTED_PICTURES)
{
$this->object->setOutputType(OUTPUT_JAVASCRIPT);
include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
include_once 'Modules/TestQuestionPool/classes/class.ilNestedOrderingGUI.php';
$answerGUI = new ilNestedOrderingGUI($this->lng->txt("answers"), "answers");
$answerGUI->setInstanceId('participant');
$answerGUI->setOrderingType($this->object->getOrderingType());
$answerMap = $this->getRandomIdToAnswerMap();
$answerArray = array();
$shuffleAnswers = false;
if( is_array($user_post_solution) && isset($user_post_solution['answers_ordering__participant']) )
{
$answers_ordering = $_POST['answers_ordering__participant'];
$user_solution_hierarchy = json_decode($answers_ordering);
$with_random_id = true;
$this->object->setLeveledOrdering($user_solution_hierarchy, $with_random_id);
foreach($this->object->leveled_ordering as $randomId => $depth)
{
$answ = new ASS_AnswerOrdering(
$answerMap[$randomId]->getAnswertext(), $randomId, $depth
);
$answerArray[] = $answ;
}
}
else
{
include_once "./Modules/Test/classes/class.ilObjTest.php";
if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
{
if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
}
$solutions =& $this->object->getSolutionValues($active_id, $pass);
if( count($solutions) )
{
foreach($solutions as $solution)
{
list($randomId, $depth) = explode(':', $solution['value2']);
$answ = new ASS_AnswerOrdering(
$answerMap[$randomId]->getAnswertext(), $randomId, $depth
);
$answerArray[] = $answ;
}
}
else
{
$answerArray = $this->object->answers;
$shuffleAnswers = true;
}
}
$answerGUI->setObjAnswersArray($answerArray, $shuffleAnswers);
if($this->object->getOrderingType() == OQ_NESTED_PICTURES)
{
$answerGUI->setImagePath($this->object->getImagePath());
$answerGUI->setImagePathWeb($this->object->getImagePathWeb());
$answerGUI->setThumbPrefix($this->object->getThumbPrefix());
}
$template->setCurrentBlock('nested_ordering_output');
$template->setVariable('NESTED_ORDERING',$answerGUI->getHtml($shuffleAnswers));
$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;
}
else
{
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->touchBlock("head_content");
require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
// 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 435 of file class.assOrderingQuestionGUI.php.

{
return $this->ctrl->getCmd() == 'uploadanswers';
}
assOrderingQuestionGUI::orderNestedPictures ( )

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

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

{
$this->object->setOrderingType(OQ_NESTED_PICTURES);
$this->writePostData(true);
$this->object->saveToDb();
$this->editQuestion();
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::orderNestedTerms ( )

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

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

{
if($this->object->getOrderingType() != OQ_NESTED_TERMS && $this->object->getOrderingType() != OQ_TERMS)
{
$clearAnswers = true;
}
else
{
$clearAnswers = false;
}
$this->object->setOrderingType(OQ_NESTED_TERMS);
$this->writePostData(true, $clearAnswers);
$this->object->saveToDb();
$this->editQuestion();
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::outQuestionForTest (   $formaction,
  $active_id,
  $pass = NULL,
  $is_postponed = FALSE,
  $user_post_solution = FALSE 
)

Definition at line 535 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::populateAnswerSpecificFormPart ( ilPropertyFormGUI  $form)

Adds the answer specific form parts to a question property form gui.

Parameters
ilPropertyFormGUI$form
Returns
ilPropertyFormGUI

Implements ilGuiAnswerScoringAdjustable.

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

References ilPropertyFormGUI\addItem(), getAnswerImageFileUploadWizardFormProperty(), OQ_NESTED_PICTURES, OQ_NESTED_TERMS, OQ_PICTURES, and ilNestedOrderingGUI\setOrderingType().

Referenced by editQuestion().

{
$orderingtype = $this->object->getOrderingType();
if (count($this->object->getAnswers()) == 0)
{
$this->object->addAnswer();
}
$header = new ilFormSectionHeaderGUI();
$header->setTitle($this->lng->txt('oq_header_ordering_elements'));
$form->addItem($header);
if ($orderingtype == OQ_PICTURES)
{
$answerImageUpload = $this->getAnswerImageFileUploadWizardFormProperty();
if ($this->uploadAlert !== null)
{
$answerImageUpload->setAlert( $this->uploadAlert );
}
$form->addItem( $answerImageUpload );
}
else if ($orderingtype == OQ_NESTED_TERMS || $orderingtype == OQ_NESTED_PICTURES)
{
require_once 'Modules/TestQuestionPool/classes/class.ilNestedOrderingGUI.php';
$answers = new ilNestedOrderingGUI($this->lng->txt( "answers" ), "answers");
$answers->setOrderingType( $orderingtype );
$answers->setObjAnswersArray( $this->object->getAnswers() );
if ($orderingtype == OQ_NESTED_PICTURES)
{
$answers->setImagePath( $this->object->getImagePath() );
$answers->setImagePathWeb( $this->object->getImagePathWeb() );
$answers->setThumbPrefix( $this->object->getThumbPrefix() );
}
$answers->setInfo( $this->lng->txt( 'ordering_answer_sequence_info' ) );
$form->addItem( $answers );
}
else
{
require_once './Modules/TestQuestionPool/classes/class.ilOrderingTextWizardInputGUI.php';
$answers = new ilOrderingTextWizardInputGUI($this->lng->txt( "answers" ), "answers");
$answervalues = array();
foreach ($this->object->getAnswers() as $index => $answervalue)
{
$answervalues[$index] = $answervalue->getAnswertext();
}
ksort( $answervalues );
$answers->setValues( $answervalues );
$answers->setAllowMove( TRUE );
$answers->setRequired( TRUE );
$answers->setInfo( $this->lng->txt( 'ordering_answer_sequence_info' ) );
$form->addItem( $answers );
}
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assOrderingQuestionGUI::populateCommandButtons ( ilPropertyFormGUI  $form)
private

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

References ilPropertyFormGUI\addCommandButton(), OQ_NESTED_PICTURES, OQ_NESTED_TERMS, OQ_PICTURES, and OQ_TERMS.

Referenced by editQuestion().

{
switch( $this->object->getOrderingType() )
{
case OQ_TERMS:
$form->addCommandButton("changeToPictures", $this->lng->txt("oq_btn_use_order_pictures"));
$form->addCommandButton("orderNestedTerms", $this->lng->txt("oq_btn_nest_terms"));
break;
$form->addCommandButton("changeToText", $this->lng->txt("oq_btn_use_order_terms"));
$form->addCommandButton("orderNestedPictures", $this->lng->txt("oq_btn_nest_pictures"));
break;
$form->addCommandButton("changeToPictures", $this->lng->txt("oq_btn_use_order_pictures"));
$form->addCommandButton("changeToText", $this->lng->txt("oq_btn_define_terms"));
break;
$form->addCommandButton("changeToText", $this->lng->txt("oq_btn_use_order_terms"));
$form->addCommandButton("changeToPictures", $this->lng->txt("oq_btn_define_pictures"));
break;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assOrderingQuestionGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

References ilPropertyFormGUI\addItem(), ilNumberInputGUI\allowDecimals(), OQ_PICTURES, and ilNumberInputGUI\setValue().

Referenced by editQuestion().

{
$orderingtype = $this->object->getOrderingType();
// Edit mode
//$hidden = new ilHiddenInputGUI("ordering_type");
//$hidden->setValue( $orderingtype );
//$form->addItem( $hidden );
if (!$this->object->getSelfAssessmentEditingMode())
{
$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 );
}
// 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 );
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assOrderingQuestionGUI::removeanswers ( )

Definition at line 130 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 121 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::renderAggregateView (   $aggregate)
Parameters
$aggregate
Returns
ilTemplate

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

References assQuestionGUI\$tpl, OQ_NESTED_PICTURES, OQ_NESTED_TERMS, and OQ_TERMS.

Referenced by getAggregatedAnswersView().

{
$tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
$tpl->setVariable( 'OPTION_HEADER', $this->lng->txt('answer_variant') );
$tpl->setVariable( 'COUNT_HEADER', $this->lng->txt('count') );
$tpl->setVariable( 'AGGREGATION_HEADER', $this->lng->txt('aggregated_answers_header') );
foreach ($aggregate as $answers => $line_data)
{
$tpl->setCurrentBlock( 'aggregaterow' );
$html = '<ul style="list-style: none;">';
$answer_entries = explode(',',$answers);
foreach($answer_entries as $key => $line)
{
$html .= '<li>';
if($this->object->getOrderingType() == OQ_NESTED_TERMS || $this->object->getOrderingType() === OQ_NESTED_PICTURES)
{
$answer_parts = explode( '|', $line );
$line_item = $answer_parts[1];
if(isset($answer_parts[0]))
{
$indent_level = $answer_parts[0];
}
else
{
$indent_level = 0;
}
for($i = 0; $i < $indent_level; $i++)
{
$html .= '&nbsp;<small>&gt;</small>&nbsp;';
}
$answer_objs = $this->object->getAnswers();
foreach($answer_objs as $candidate)
{
if($candidate->getRandomId() == $line_item)
{
$answer_obj = $candidate;
}
}
} else {
$line_item = $line;
$answer_obj = $this->object->getAnswer($line_item);
}
if($this->object->getOrderingType() == OQ_TERMS || $this->object->getOrderingType() == OQ_NESTED_TERMS)
{
$html .= $answer_obj->getAnswertext();
} else {
$html .= '&nbsp;<img src="'
. $this->object->getImagePathWeb()
. $this->object->getThumbPrefix()
. $answer_obj->getAnswertext()
. '" />'; // No, seriously.
}
$html .= '</li>';
}
$html .= '</ul>';
$tpl->setVariable( 'COUNT', $line_data );
$tpl->setVariable( 'OPTION', $html );
$tpl->parseCurrentBlock();
}
return $tpl;
}

+ Here is the caller graph for this function:

assOrderingQuestionGUI::resetFormValuesForSuppressedPostvars (   $form)

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

References $_POST.

{
$element = $form->getItemByPostvar('element_height');
if($element)
{
$_POST['element_height'] = $this->object->getElementHeight();
$element->setValue( $this->object->getElementHeight() );
}
$element = $form->getItemByPostvar('thumb_geometry');
if($element)
{
$_POST['thump_geometry'] = $this->object->getThumbGeometry();
$element->setValue( $this->object->getThumbGeometry() );
$element->setRequired( false );
}
$element = $form->getItemByPostvar('answers');
$element->setRequired(false);
}
assOrderingQuestionGUI::setLeveledOrdering (   $new_hierarchy)

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

References getDepthRecursive().

Referenced by writeAnswerSpecificPostData().

{
foreach($new_hierarchy as $id)
{
$ordering_depth = 0;
$this->leveled_ordering[] = $ordering_depth;
if(is_array($id->children))
{
foreach($id->children as $child)
{
$this->getDepthRecursive($child, $ordering_depth);
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller 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 1314 of file class.assOrderingQuestionGUI.php.

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

{
global $rbacsystem, $ilTabs;
$this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "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("ilAssQuestionPageGUI", "edit"),
array("edit", "insert", "exec_pg"),
"", "", $force_active);
}
// edit page
$ilTabs->addTarget("preview",
$this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "preview"),
array("preview"),
"ilAssQuestionPageGUI", "", $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("orderNestedTerms","orderNestedPictures","editQuestion", "save", "saveEdit", "addanswers", "removeanswers", "changeToPictures", "uploadanswers", "changeToText", "upanswers", "downanswers", "originalSyncForm"),
$classname, "", $force_active);
}
// add tab for question feedback within common class assQuestionGUI
$this->addTab_QuestionFeedback($ilTabs);
// 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 138 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 174 of file class.assOrderingQuestionGUI.php.

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

{
$this->lng->loadLanguageModule('form');
if( !$inp->checkInput() )
{
$this->uploadAlert = $inp->getAlert();
ilUtil::sendFailure($inp->getAlert());
}
$this->writePostData(true);
$this->editQuestion();
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::writeAnswerSpecificPostData (   $always = false)

Extracts the answer specific values from $_POST and applies them to the data object.

Parameters
bool$alwaysIf true, a check for form validity is omitted.
Returns
void

Implements ilGuiAnswerScoringAdjustable.

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

References $_POST, $filename, $old_ordering_depth, getOldLeveledOrdering(), OQ_NESTED_PICTURES, OQ_NESTED_TERMS, OQ_TERMS, and setLeveledOrdering().

Referenced by writePostData().

{
$ordering_type = $this->object->getOrderingType();
// Delete all existing answers and create new answers from the form data
$this->object->flushAnswers();
$saved = false;
// add answers
if ($ordering_type == OQ_TERMS
|| $ordering_type == OQ_NESTED_TERMS
|| $ordering_type == OQ_NESTED_PICTURES
)
{
$answers = $_POST["answers"];
if (is_array( $answers ))
{
$answers_ordering = $_POST['answers_ordering__default']; // __default is added by js
$new_hierarchy = json_decode( $answers_ordering );
if (!is_array( $new_hierarchy ))
{
$this->leveled_ordering = $this->old_ordering_depth;
}
else
{
$this->setLeveledOrdering( $new_hierarchy );
}
$counter = 0;
if(is_array($answers['imagename']))
{
foreach($answers['imagename'] as $index => $answer)
{
if($clear_answers)
{
$answer = "";
}
$this->object->addAnswer($answer, -1, $this->leveled_ordering[$counter]);
$counter++;
}
}
else
{
foreach($answers as $index => $answer)
{
if($clear_answers)
{
$answer = "";
}
$this->object->addAnswer($answer, -1, $this->leveled_ordering[$counter]);
$counter++;
}
}
}
}
else
{
if (is_array( $_POST['answers']['count'] ))
{
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 );
}
}
else if(is_array($_POST['answers']))
{
foreach($_POST['answers'] as $random_id => $text_value)
{
$this->object->addAnswer( $text_value );
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller 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.

Parameters
bool$always
bool$clear_answers
Returns
integer A positive value, if one of the required fields wasn't set, else 0

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

References editQuestion(), assQuestionGUI\saveTaxonomyAssignments(), writeAnswerSpecificPostData(), assQuestionGUI\writeQuestionGenericPostData(), and writeQuestionSpecificPostData().

{
$hasErrors = (!$always) ? $this->editQuestion(true) : false;
if (!$hasErrors)
{
$this->writeAnswerSpecificPostData( $clear_answers );
return 0;
}
return 1;
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::writeQuestionSpecificPostData (   $always = true)

Extracts the question specific values from $_POST and applies them to the data object.

Parameters
bool$alwaysIf true, a check for form validity is omitted.
Returns
void

Implements ilGuiQuestionScoringAdjustable.

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

References $_POST.

Referenced by writePostData().

{
$this->object->setThumbGeometry( $_POST["thumb_geometry"] );
$this->object->setElementHeight( $_POST["element_height"] );
//$this->object->setOrderingType( $_POST["ordering_type"] );
$this->object->setPoints($_POST["points"]);
}

+ Here is the caller graph for this function:

Field Documentation

assOrderingQuestionGUI::$leveled_ordering = array()

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

assOrderingQuestionGUI::$old_ordering_depth = array()
assOrderingQuestionGUI::$uploadAlert = null
private

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


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