ILIAS  Release_5_0_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
 setClearAnswersOnWritingPostDataEnabled ($clearAnswersOnWritingPostDataEnabled)
 isClearAnswersOnWritingPostDataEnabled ()
 changeToPictures ()
 changeToText ()
 orderNestedTerms ()
 orderNestedPictures ()
 addanswers ()
 removeimageanswers ()
 removeanswers ()
 upanswers ()
 downanswers ()
 uploadanswers ()
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from $_POST and applies them to the data object.
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 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)
 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.
 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, $showInlineFeedback=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.
 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 ($linkTargetGui)
 setTargetGuiClass ($targetGuiClass)
 getTargetGuiClass ()
 setQuestionHeaderBlockBuilder ($questionHeaderBlockBuilder)
 setQuestionActionCmd ($questionActionCmd)
 getQuestionActionCmd ()
_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.
 getGenericFeedbackOutputForCorrectSolution ()
 getGenericFeedbackOutputForIncorrectSolution ()
 outQuestionType ()
 showSuggestedSolution ()
 suggestedsolution ()
 Allows to add suggested solutions for questions.
 outSolutionExplorer ()
 saveSuggestedSolution ()
 cancelExplorer ()
 outPageSelector ()
 outChapterSelector ()
 outGlossarySelector ()
 linkChilds ()
 addPG ()
 addST ()
 addGIT ()
 isSaveCommand ()
 addTab_SuggestedSolution (ilTabsGUI $tabs, $classname)
 getEditQuestionTabCommands ()
 isAutosaveable ()
 outQuestionForTest ($formaction, $active_id, $pass=NULL, $is_question_postponed=FALSE, $user_post_solutions=FALSE, $show_specific_inline_feedback=FALSE)
 setPreviewSession ($previewSession)
 getPreviewSession ()
 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'
const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded'
const FORM_ENCODING_MULTIPART = 'multipart/form-data'
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 $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
 $clearAnswersOnWritingPostDataEnabled

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
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object.
 saveTaxonomyAssignments ()
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 getBasicEditQuestionTabCommands ()
 getAdditionalEditQuestionCommands ()
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI
 addTab_QuestionPreview (ilTabsGUI $tabsGUI)
 writeQuestionGenericPostData ()
 getFormEncodingType ()
 addBackTab (ilTabsGUI $ilTabs)
 buildBasicEditFormObject ()

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 57267 2015-01-20 16:53:50Z bheyser

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 43 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);
$this->clearAnswersOnWritingPostDataEnabled = false;
}

+ Here is the call graph for this function:

Member Function Documentation

assOrderingQuestionGUI::addanswers ( )

Definition at line 124 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 1402 of file class.assOrderingQuestionGUI.php.

Referenced by getAggregatedAnswersView().

{
$passdata = array(); // Regroup answers into units of passes.
foreach($relevant_answers_chosen as $answer_chosen)
{
$passdata[$answer_chosen['active_fi'].'-'. $answer_chosen['pass']][$answer_chosen['value2']] = $answer_chosen['value1'];
}
$variants = array(); // Determine unique variants.
foreach($passdata as $key => $data)
{
$hash = md5(implode('-', $data));
$value_set = false;
foreach ($variants as $vkey => $variant)
{
if ($variant['hash'] == $hash)
{
$variant['count']++;
$value_set = true;
}
}
if (!$value_set)
{
$variants[$key]['hash'] = $hash;
$variants[$key]['count'] = 1;
}
}
$aggregate = array(); // Render aggregate from variant.
foreach ($variants as $key => $variant_entry)
{
$variant = $passdata[$key];
foreach($variant as $variant_key => $variant_line)
{
$i = 0;
$aggregated_info_for_answer['count'] = $variant_entry['count'];
foreach ($answers_defined_on_question as $answer)
{
$i++;
$aggregated_info_for_answer[$i . ' - ' . $answer->getAnswerText()]
= $passdata[$key][$i];
}
}
$aggregate[] = $aggregated_info_for_answer;
}
return $aggregate;
}

+ Here is the caller graph for this function:

assOrderingQuestionGUI::changeToPictures ( )

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

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

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

+ Here is the call graph for this function:

assOrderingQuestionGUI::changeToText ( )

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

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

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

+ Here is the call graph for this function:

assOrderingQuestionGUI::downanswers ( )

Definition at line 157 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 451 of file class.assOrderingQuestionGUI.php.

References $errors, assQuestionGUI\addBasicQuestionFormProperties(), assQuestionGUI\addQuestionFormCommandButtons(), assQuestionGUI\getQuestionTemplate(), assQuestionGUI\isSaveCommand(), OQ_PICTURES, assQuestionGUI\outQuestionType(), populateAnswerSpecificFormPart(), populateCommandButtons(), populateQuestionSpecificFormPart(), and assQuestionGUI\populateTaxonomyFormSection().

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 1369 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 1383 of file class.assOrderingQuestionGUI.php.

{
return array();
}
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 1396 of file class.assOrderingQuestionGUI.php.

References aggregateAnswers(), and renderAggregateView().

{
return $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 168 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 1312 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 1347 of file class.assOrderingQuestionGUI.php.

References $ilDB, $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,
  $showInlineFeedback = false 
)

Reimplemented from assQuestionGUI.

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

References $ilUser, assQuestionGUI\$tpl, assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), assQuestionGUI\getPreviewSession(), getRandomIdToAnswerMap(), ilUtil\getStyleSheetLocation(), OQ_NESTED_PICTURES, OQ_NESTED_TERMS, OQ_PICTURES, OUTPUT_JAVASCRIPT, and ilNestedOrderingGUI\setOrderingType().

{
global $tpl;
$this->object->setOutputType(OUTPUT_JAVASCRIPT);
$tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_javascript.css", "Modules/TestQuestionPool"));
include_once "./Services/UICore/classes/class.ilTemplate.php";
$template = new ilTemplate("tpl.il_as_qpl_ordering_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
if( is_object($this->getPreviewSession()) && count((array)$this->getPreviewSession()->getParticipantsSolution()) )
{
if ($this->object->getOrderingType() == OQ_NESTED_TERMS || $this->object->getOrderingType() == OQ_NESTED_PICTURES)
{
$answerMap = $this->getRandomIdToAnswerMap();
$answerArray = array();
$shuffleAnswers = false;
foreach((array)$this->getPreviewSession()->getParticipantsSolution() as $val1 => $val2)
{
list($randomId, $depth) = explode(':', $val2);
$answ = new ASS_AnswerOrdering(
$answerMap[$randomId]->getAnswertext(), $randomId, $depth
);
$answerArray[] = $answ;
$jssolutions[$val2] = $val1;
}
}
else
{
foreach((array)$this->getPreviewSession()->getParticipantsSolution() as $val1 => $val2)
{
$jssolutions[$val2] = $val1;
}
}
}
else
{
$answerArray = $this->object->answers;
$shuffleAnswers = true;
}
global $ilUser;
// shuffle output
$keys = array_keys($this->object->answers);
if($shuffleAnswers)
{
shuffle($keys);
}
if ($this->object->getOrderingType() == OQ_NESTED_TERMS || $this->object->getOrderingType() == OQ_NESTED_PICTURES)
{
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($answerArray, $shuffleAnswers);
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 = $template->get();
if (!$show_question_only)
{
// get page object output
$questionoutput = $this->getILIASPage($questionoutput);
}
return $questionoutput;
}
else
{
$this->tpl->addJavascript("./Modules/TestQuestionPool/templates/default/ordering.js");
$template->setCurrentBlock('form_submit_register');
$template->touchBlock('form_submit_register');
$template->parseCurrentBlock();
if(count($jssolutions))
{
ksort($jssolutions);
$initial_order = array();
foreach($jssolutions as $key => $value)
{
if(is_object($this->object->getAnswer($value)))
{
$initial_order[] = 'id_' . $this->object->getAnswer($value)->getRandomID();
}
}
$template->setVariable('INITIAL_ORDER', json_encode($initial_order));
}
else
{
$template->setVariable('INITIAL_ORDER', json_encode(array()));
}
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.svg", 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();
}
}
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"));
}
$questiontext = $this->object->getQuestion();
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
$template->setVariable("QUESTION_ID", $this->object->getId());
$questionoutput = $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 977 of file class.assOrderingQuestionGUI.php.

Referenced by getPreview(), and 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 535 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);
}
}
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.svg"));
$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.svg"));
$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);
}
}
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 1289 of file class.assOrderingQuestionGUI.php.

Referenced by getSolutionOutput().

{
if( !$this->object->feedbackOBJ->specificAnswerFeedbackExists($this->object->getAnswers()) )
{
return '';
}
$output = '<table class="test_specific_feedback"><tbody>';
foreach($this->object->getAnswers() as $idx => $answer)
{
$feedback = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
$this->object->getId(), $idx
);
$output .= "<tr><td>{$answer->getAnswerText()}</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 989 of file class.assOrderingQuestionGUI.php.

References $_POST, $_SESSION, $pass, assQuestionGUI\$tpl, ilObjTest\_getPass(), ilObjTest\_getUsePreviousAnswers(), ilUtil\getImagePath(), getRandomIdToAnswerMap(), ilUtil\getStyleSheetLocation(), OQ_NESTED_PICTURES, OQ_NESTED_TERMS, OQ_PICTURES, OUTPUT_JAVASCRIPT, assQuestionGUI\outQuestionPage(), and ilNestedOrderingGUI\setInstanceId().

{
global $tpl;
$tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_javascript.css", "Modules/TestQuestionPool"));
// 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");
$this->object->setOutputType(OUTPUT_JAVASCRIPT);
// 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;
if ($this->object->getOrderingType() == OQ_NESTED_TERMS
|| $this->object->getOrderingType() == OQ_NESTED_PICTURES)
{
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
{
$this->tpl->addJavascript("./Modules/TestQuestionPool/templates/default/ordering.js");
// BEGIN: onsubmit form action for javascript enabled ordering questions
$this->tpl->setVariable("ON_SUBMIT", "return $('div.ilVerticalOrderingQuestion').ilOrderingQuestion('saveOrder');");
// 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);
}
$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);
$initial_order = array();
foreach($jssolutions as $key => $value)
{
if(is_object($this->object->getAnswer($value)))
{
$initial_order[] = 'id_' . $this->object->getAnswer($value)->getRandomID();
}
}
$template->setVariable('INITIAL_ORDER', json_encode($initial_order));
}
else
{
$template->setVariable('INITIAL_ORDER', json_encode(array()));
}
}
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.svg", 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();
}
}
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"));
}
$questiontext = $this->object->getQuestion();
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
$template->setVariable("QUESTION_ID", $this->object->getId());
$questionoutput = $template->get();
$pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
$this->tpl->addJavascript("./Modules/TestQuestionPool/templates/default/ordering.js");
return $pageoutput;
}
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::isClearAnswersOnWritingPostDataEnabled ( )
Returns
boolean

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

References $clearAnswersOnWritingPostDataEnabled.

Referenced by writeAnswerSpecificPostData().

+ Here is the caller graph for this function:

assOrderingQuestionGUI::isUploadAnswersCommand ( )
private

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

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

Definition at line 115 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 101 of file class.assOrderingQuestionGUI.php.

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

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

+ 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 314 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
{
$answers = new ilTextWizardInputGUI($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 490 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 372 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 141 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 132 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 1457 of file class.assOrderingQuestionGUI.php.

References assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

{
$tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
foreach ($aggregate as $line_data)
{
$tpl->setCurrentBlock( 'aggregaterow' );
$count = array_shift($line_data);
$html = '<ul>';
foreach($line_data as $key => $line)
{
$html .= '<li>'. ++$line .'&nbsp;-&nbsp;' .$key. '</li>';
}
$html .= '</ul>';
$tpl->setVariable( 'COUNT', $count );
$tpl->setVariable( 'OPTION', $html );
$tpl->parseCurrentBlock();
}
return $tpl;
}

+ Here is the caller graph for this function:

assOrderingQuestionGUI::setClearAnswersOnWritingPostDataEnabled (   $clearAnswersOnWritingPostDataEnabled)
Parameters
boolean$clearAnswersOnWritingPostDataEnabled

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

References $clearAnswersOnWritingPostDataEnabled.

Referenced by changeToPictures(), changeToText(), and orderNestedTerms().

{
$this->clearAnswersOnWritingPostDataEnabled = $clearAnswersOnWritingPostDataEnabled;
}

+ Here is the caller graph for this function:

assOrderingQuestionGUI::setLeveledOrdering (   $new_hierarchy)

Definition at line 1330 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 1214 of file class.assOrderingQuestionGUI.php.

References $_GET, $_POST, assQuestionGUI\addBackTab(), assQuestionGUI\addTab_QuestionFeedback(), assQuestionGUI\addTab_QuestionHints(), assQuestionGUI\addTab_QuestionPreview(), and assQuestionGUI\addTab_SuggestedSolution().

{
global $rbacsystem, $ilTabs;
$ilTabs->clearTargets();
$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);
}
$this->addTab_QuestionPreview($ilTabs);
}
$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);
// add tab for question's suggested solution within common class assQuestionGUI
$this->addTab_SuggestedSolution($ilTabs, $classname);
// Assessment of questions sub menu entry
if ($_GET["q_id"])
{
$ilTabs->addTarget("statistics",
$this->ctrl->getLinkTargetByClass($classname, "assessment"),
array("assessment"),
$classname, "");
}
$this->addBackTab($ilTabs);
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::upanswers ( )

Definition at line 149 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 185 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 ( ilPropertyFormGUI  $form)

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 209 of file class.assOrderingQuestionGUI.php.

References $_POST, $filename, $old_ordering_depth, getOldLeveledOrdering(), isClearAnswersOnWritingPostDataEnabled(), 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)
{
{
$answer = "";
}
$this->object->addAnswer($answer, -1, $this->leveled_ordering[$counter]);
$counter++;
}
}
else
{
foreach($answers as $index => $answer)
{
{
$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)
{
{
$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)

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 432 of file class.assOrderingQuestionGUI.php.

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

{
$hasErrors = (!$always) ? $this->editQuestion(true) : false;
if (!$hasErrors)
{
require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
return 0;
}
return 1;
}

+ Here is the call graph for this function:

assOrderingQuestionGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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 201 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::$clearAnswersOnWritingPostDataEnabled
private
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: