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

Matching question GUI representation. More...

+ Inheritance diagram for assMatchingQuestionGUI:
+ Collaboration diagram for assMatchingQuestionGUI:

Public Member Functions

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

Protected Member Functions

 sortDefinitionsBySolution ($solution)
- Protected Member Functions inherited from assQuestionGUI
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI

Private Member Functions

 isValidTermAndDefinitionAmount (ilPropertyFormGUI $form)
 isCorrectMatching ($pair, $definition, $term)

Additional Inherited Members

- Data Fields inherited from assQuestionGUI
 $object
 $tpl
 $lng
 $error
 $errormessage
 $sequence_no
 sequence number in test
 $question_count
 question count in test
 $prevent_rte_usage = false
 do not use rte for editing

Detailed Description

Matching question GUI representation.

The assMatchingQuestionGUI class encapsulates the GUI representation for matching questions.

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

Definition at line 19 of file class.assMatchingQuestionGUI.php.

Constructor & Destructor Documentation

assMatchingQuestionGUI::__construct (   $id = -1)

assMatchingQuestionGUI constructor

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

Parameters
integer$idThe database id of a image map question object public

Definition at line 29 of file class.assMatchingQuestionGUI.php.

References assQuestionGUI\__construct(), and assQuestionGUI\setErrorMessage().

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

+ Here is the call graph for this function:

Member Function Documentation

assMatchingQuestionGUI::adddefinitions ( )

Definition at line 210 of file class.assMatchingQuestionGUI.php.

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

{
$this->writePostData();
$position = key($_POST["cmd"]["adddefinitions"]);
$this->object->insertDefinition($position+1);
$this->editQuestion();
}

+ Here is the call graph for this function:

assMatchingQuestionGUI::addpairs ( )

Definition at line 226 of file class.assMatchingQuestionGUI.php.

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

{
$this->writePostData();
$position = key($_POST["cmd"]["addpairs"]);
$this->object->insertMatchingPair($position+1);
$this->editQuestion();
}

+ Here is the call graph for this function:

assMatchingQuestionGUI::addterms ( )

Definition at line 194 of file class.assMatchingQuestionGUI.php.

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

{
$this->writePostData();
$position = key($_POST["cmd"]["addterms"]);
$this->object->insertTerm($position+1);
$this->editQuestion();
}

+ Here is the call graph for this function:

assMatchingQuestionGUI::checkInput ( )

check input fields

Definition at line 1219 of file class.assMatchingQuestionGUI.php.

References $_POST.

{
if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
{
return false;
}
return true;
}
assMatchingQuestionGUI::editQuestion (   $checkonly = FALSE)

Creates an output of the edit form for the question.

public

Definition at line 247 of file class.assMatchingQuestionGUI.php.

References $errors, assQuestionGUI\addBasicQuestionFormProperties(), assQuestionGUI\addQuestionFormCommandButtons(), assQuestionGUI\getQuestionTemplate(), assQuestionGUI\getSelfAssessmentEditingMode(), assQuestionGUI\isSaveCommand(), isValidTermAndDefinitionAmount(), assQuestionGUI\outQuestionType(), ilUtil\sendFailure(), ilMatchingWizardInputGUI\setHideImages(), ilSelectInputGUI\setOptions(), ilFormPropertyGUI\setRequired(), and ilNumberInputGUI\setValue().

Referenced by adddefinitions(), addpairs(), addterms(), removedefinitions(), removeimagedefinitions(), removeimageterms(), removepairs(), removeterms(), uploaddefinitions(), uploadterms(), and writePostData().

{
$save = $this->isSaveCommand();
include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
$form->setFormAction($this->ctrl->getFormAction($this));
$form->setTitle($this->outQuestionType());
$form->setMultipart(true);
$form->setTableWidth("100%");
$form->setId("matching");
// Edit mode
$hidden = new ilHiddenInputGUI("matching_type");
$hidden->setValue($matchingtype);
$form->addItem($hidden);
// title, author, description, question, working time (assessment mode)
{
// shuffle
$shuffle = new ilSelectInputGUI($this->lng->txt("shuffle_answers"), "shuffle");
$shuffle_options = array(
0 => $this->lng->txt("no"),
1 => $this->lng->txt("matching_shuffle_terms_definitions"),
2 => $this->lng->txt("matching_shuffle_terms"),
3 => $this->lng->txt("matching_shuffle_definitions")
);
$shuffle->setOptions($shuffle_options);
$shuffle->setValue($this->object->getShuffle() != null ? $this->object->getShuffle() : 1);
$shuffle->setRequired(FALSE);
$form->addItem($shuffle);
$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);
$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);
}
// Definitions
include_once "./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
$definitions = new ilMatchingWizardInputGUI($this->lng->txt("definitions"), "definitions");
if ($this->getSelfAssessmentEditingMode()) $definitions->setHideImages(true);
$definitions->setRequired(true);
$definitions->setQuestionObject($this->object);
$definitions->setTextName($this->lng->txt('definition_text'));
$definitions->setImageName($this->lng->txt('definition_image'));
include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
if (!count($this->object->getDefinitions())) $this->object->addDefinition(new assAnswerMatchingDefinition());
$definitionvalues = $this->object->getDefinitions();
$definitions->setValues($definitionvalues);
$definitions->checkInput();
$form->addItem($definitions);
// Terms
include_once "./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
$terms = new ilMatchingWizardInputGUI($this->lng->txt("terms"), "terms");
if ($this->getSelfAssessmentEditingMode()) $terms->setHideImages(true);
$terms->setRequired(true);
$terms->setQuestionObject($this->object);
$terms->setTextName($this->lng->txt('term_text'));
$terms->setImageName($this->lng->txt('term_image'));
include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
if (!count($this->object->getTerms())) $this->object->addTerm(new assAnswerMatchingTerm());
$termvalues = $this->object->getTerms();
$terms->setValues($termvalues);
$terms->checkInput();
$form->addItem($terms);
// Matching Pairs
include_once "./Modules/TestQuestionPool/classes/class.ilMatchingPairWizardInputGUI.php";
$pairs = new ilMatchingPairWizardInputGUI($this->lng->txt('matching_pairs'), 'pairs');
$pairs->setRequired(true);
$pairs->setTerms($this->object->getTerms());
$pairs->setDefinitions($this->object->getDefinitions());
include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
if (count($this->object->getMatchingPairs()) == 0)
{
$this->object->addMatchingPair(new assAnswerMatchingPair($termvalues[0], $definitionvalues[0], 0));
}
$pairs->setPairs($this->object->getMatchingPairs());
$form->addItem($pairs);
$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) && !$this->isValidTermAndDefinitionAmount($form)
{
$errors = true;
$terms->setAlert($this->lng->txt("msg_number_of_terms_too_low"));
ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
}
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:

assMatchingQuestionGUI::feedback (   $checkonly = false)

Creates the output of the feedback page for a single choice question.

public

Reimplemented from assQuestionGUI.

Definition at line 1358 of file class.assMatchingQuestionGUI.php.

References $_GET, $errors, ilObjAdvancedEditing\_getUsedHTMLTags(), assQuestionGUI\getPreventRteUsage(), assQuestionGUI\getSelfAssessmentEditingMode(), and ilTextAreaInputGUI\setValue().

Referenced by saveFeedback().

{
$save = (strcmp($this->ctrl->getCmd(), "saveFeedback") == 0) ? TRUE : FALSE;
include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
$form->setFormAction($this->ctrl->getFormAction($this));
$form->setTitle($this->lng->txt('feedback_answers'));
$form->setTableWidth("98%");
$form->setId("feedback");
$complete = new ilTextAreaInputGUI($this->lng->txt("feedback_complete_solution"), "feedback_complete");
$complete->setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)));
$complete->setRequired(false);
$complete->setRows(10);
$complete->setCols(80);
if (!$this->getPreventRteUsage())
{
$complete->setUseRte(true);
}
include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
$complete->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
$complete->addPlugin("latex");
$complete->addButton("latex");
$complete->addButton("pastelatex");
$complete->setRTESupport($this->object->getId(), "qpl", "assessment", null, false, '3.4.7');
$form->addItem($complete);
$incomplete = new ilTextAreaInputGUI($this->lng->txt("feedback_incomplete_solution"), "feedback_incomplete");
$incomplete->setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)));
$incomplete->setRequired(false);
$incomplete->setRows(10);
$incomplete->setCols(80);
if (!$this->getPreventRteUsage())
{
$incomplete->setUseRte(true);
}
include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
$incomplete->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
$incomplete->addPlugin("latex");
$incomplete->addButton("latex");
$incomplete->addButton("pastelatex");
$incomplete->setRTESupport($this->object->getId(), "qpl", "assessment", null, false, '3.4.7');
$form->addItem($incomplete);
{
foreach ($this->object->getMatchingPairs() as $index => $answer)
{
$caption = $ordinal = $index+1;
$caption .= '. <br />"' . $answer->term->text . '" =&gt; ';
$caption .= '"' . $answer->definition->text . '"';
$caption .= '</i>';
$answerobj = new ilTextAreaInputGUI($this->object->prepareTextareaOutput($caption, true), "feedback_answer_$index");
$answerobj->setValue($this->object->prepareTextareaOutput($this->object->getFeedbackSingleAnswer($index)));
$answerobj->setRequired(false);
$answerobj->setRows(10);
$answerobj->setCols(80);
$answerobj->setUseRte(true);
include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
$answerobj->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
$answerobj->addPlugin("latex");
$answerobj->addButton("latex");
$answerobj->addButton("pastelatex");
$answerobj->setRTESupport($this->object->getId(), "qpl", "assessment", null, false, '3.4.7');
$form->addItem($answerobj);
}
}
global $ilAccess;
if ($ilAccess->checkAccess("write", "", $_GET['ref_id']) || $this->getSelfAssessmentEditingMode())
{
$form->addCommandButton("saveFeedback", $this->lng->txt("save"));
}
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 (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
return $errors;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assMatchingQuestionGUI::getCommand (   $cmd)

Reimplemented from assQuestionGUI.

Definition at line 41 of file class.assMatchingQuestionGUI.php.

References $cmd.

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

Definition at line 730 of file class.assMatchingQuestionGUI.php.

References $_GET, $ilUser, assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), getPreviewJS(), OUTPUT_JAVASCRIPT, and ilUtil\prepareFormOutput().

{
global $ilUser;
// generate the question output
include_once "./Services/UICore/classes/class.ilTemplate.php";
$template = new ilTemplate("tpl.il_as_qpl_matching_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
$jsswitch = "";
if (strcmp($this->ctrl->getCmd(), 'preview') == 0)
{
if (array_key_exists('js', $_GET))
{
$ilUser->writePref('tst_javascript', $_GET['js']);
}
$jstemplate = new ilTemplate("tpl.il_as_qpl_javascript_switch.html", TRUE, TRUE, "Modules/TestQuestionPool");
if ($ilUser->getPref("tst_javascript") == 1)
{
$jstemplate->setVariable("JAVASCRIPT_IMAGE", ilUtil::getImagePath("javascript_disable.png"));
$jstemplate->setVariable("JAVASCRIPT_IMAGE_ALT", $this->lng->txt("disable_javascript"));
$jstemplate->setVariable("JAVASCRIPT_IMAGE_TITLE", $this->lng->txt("disable_javascript"));
$this->ctrl->setParameterByClass($this->ctrl->getCmdClass(), "js", "0");
$jstemplate->setVariable("JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
}
else
{
$jstemplate->setVariable("JAVASCRIPT_IMAGE", ilUtil::getImagePath("javascript.png"));
$jstemplate->setVariable("JAVASCRIPT_IMAGE_ALT", $this->lng->txt("enable_javascript"));
$jstemplate->setVariable("JAVASCRIPT_IMAGE_TITLE", $this->lng->txt("enable_javascript"));
$this->ctrl->setParameterByClass($this->ctrl->getCmdClass(), "js", "1");
$jstemplate->setVariable("JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
}
$jsswitch = $jstemplate->get();
if ($ilUser->getPref('tst_javascript')) $this->object->setOutputType(OUTPUT_JAVASCRIPT);
}
if ($this->object->getOutputType() == OUTPUT_JAVASCRIPT)
{
return $this->getPreviewJS($show_question_only);
}
// shuffle output
$terms = $this->object->getTerms();
$definitions = $this->object->getDefinitions();
switch ($this->object->getShuffle())
{
case 1:
$terms = $this->object->pcArrayShuffle($terms);
$definitions = $this->object->pcArrayShuffle($definitions);
break;
case 2:
$terms = $this->object->pcArrayShuffle($terms);
break;
case 3:
$definitions = $this->object->pcArrayShuffle($definitions);
break;
}
for ($i = 0; $i < count($definitions); $i++)
{
$definition = $definitions[$i];
if (is_object($definition))
{
if (strlen($definition->picture))
{
$template->setCurrentBlock('definition_image');
$template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $definition->picture);
$template->setVariable('ANSWER_IMAGE_ALT', (strlen($definition->text)) ? ilUtil::prepareFormOutput($definition->text) : ilUtil::prepareFormOutput($definition->picture));
$template->setVariable('ANSWER_IMAGE_TITLE', (strlen($definition->text)) ? ilUtil::prepareFormOutput($definition->text) : ilUtil::prepareFormOutput($definition->picture));
$template->setVariable('URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
$template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
$template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png'));
$template->setVariable("TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt('definition') . ' ' . ($i+1) . ': ' . $this->object->prepareTextareaOutput($definition->text, TRUE) : $this->lng->txt('definition') . ' ' . ($i+1));
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock('definition_text');
$template->setVariable("DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
$template->parseCurrentBlock();
}
}
$template->setCurrentBlock('option');
$template->setVariable("VALUE_OPTION", 0);
$template->setVariable("TEXT_OPTION", ilUtil::prepareFormOutput($this->lng->txt('please_select')));
$template->parseCurrentBlock();
$j = 1;
foreach ($terms as $term)
{
$template->setCurrentBlock('option');
$template->setVariable("VALUE_OPTION", $term->identifier);
$template->setVariable("TEXT_OPTION", (strlen($term->text)) ? $this->lng->txt('term') . ' ' . ($j) . ': ' . ilUtil::prepareFormOutput($term->text) : $this->lng->txt('term') . ' ' . ($j));
$template->parseCurrentBlock();
$j++;
}
$template->setCurrentBlock('row');
$template->setVariable("TEXT_MATCHES", $this->lng->txt("matches"));
if ($this->object->getEstimatedElementHeight() > 0)
{
$template->setVariable("ELEMENT_HEIGHT", " style=\"height: " . $this->object->getEstimatedElementHeight() . "px;\"");
}
$template->setVariable("QUESTION_ID", $this->object->getId());
$template->setVariable("DEFINITION_ID", $definition->identifier);
$template->parseCurrentBlock();
}
$i = 0;
foreach ($terms as $term)
{
if (strlen($term->picture))
{
$template->setCurrentBlock('term_image');
$template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $term->picture);
$template->setVariable('ANSWER_IMAGE_ALT', (strlen($term->text)) ? ilUtil::prepareFormOutput($term->text) : ilUtil::prepareFormOutput($term->picture));
$template->setVariable('ANSWER_IMAGE_TITLE', (strlen($term->text)) ? ilUtil::prepareFormOutput($term->text) : ilUtil::prepareFormOutput($term->picture));
$template->setVariable('URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
$template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
$template->setVariable("TEXT_TERM", (strlen($term->text)) ? $this->lng->txt('term') . ' ' . ($i+1) . ': ' . $this->object->prepareTextareaOutput($term->text, TRUE) : $this->lng->txt('term') . ' ' . ($i+1));
$template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png'));
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock('term_text');
$template->setVariable("TERM", $this->object->prepareTextareaOutput($term->text, TRUE));
$template->parseCurrentBlock();
}
$template->touchBlock('terms');
$i++;
}
$questiontext = $this->object->getQuestion();
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
$template->setVariable("TEXT_TERMS", ilUtil::prepareFormOutput($this->lng->txt('available_terms')));
$template->setVariable('TEXT_SELECTION', ilUtil::prepareFormOutput($this->lng->txt('selection')));
$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:

assMatchingQuestionGUI::getPreviewJS (   $show_question_only = FALSE)

Definition at line 576 of file class.assMatchingQuestionGUI.php.

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

Referenced by getPreview().

{
global $ilUser;
// generate the question output
include_once "./Services/UICore/classes/class.ilTemplate.php";
$template = new ilTemplate("tpl.il_as_qpl_matching_output_js.html", TRUE, TRUE, "Modules/TestQuestionPool");
$jsswitch = "";
if (strcmp($this->ctrl->getCmd(), 'preview') == 0)
{
if (array_key_exists('js', $_GET))
{
$ilUser->writePref('tst_javascript', $_GET['js']);
}
$jstemplate = new ilTemplate("tpl.il_as_qpl_javascript_switch.html", TRUE, TRUE, "Modules/TestQuestionPool");
if ($ilUser->getPref("tst_javascript") == 1)
{
$jstemplate->setVariable("JAVASCRIPT_IMAGE", ilUtil::getImagePath("javascript_disable.png"));
$jstemplate->setVariable("JAVASCRIPT_IMAGE_ALT", $this->lng->txt("disable_javascript"));
$jstemplate->setVariable("JAVASCRIPT_IMAGE_TITLE", $this->lng->txt("disable_javascript"));
$this->ctrl->setParameterByClass($this->ctrl->getCmdClass(), "js", "0");
$jstemplate->setVariable("JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
}
else
{
$jstemplate->setVariable("JAVASCRIPT_IMAGE", ilUtil::getImagePath("javascript.png"));
$jstemplate->setVariable("JAVASCRIPT_IMAGE_ALT", $this->lng->txt("enable_javascript"));
$jstemplate->setVariable("JAVASCRIPT_IMAGE_TITLE", $this->lng->txt("enable_javascript"));
$this->ctrl->setParameterByClass($this->ctrl->getCmdClass(), "js", "1");
$jstemplate->setVariable("JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
}
$jsswitch = $jstemplate->get();
if ($ilUser->getPref('tst_javascript')) $this->object->setOutputType(OUTPUT_JAVASCRIPT);
}
// shuffle output
$terms = $this->object->getTerms();
$definitions = $this->object->getDefinitions();
switch ($this->object->getShuffle())
{
case 1:
$terms = $this->object->pcArrayShuffle($terms);
$definitions = $this->object->pcArrayShuffle($definitions);
break;
case 2:
$terms = $this->object->pcArrayShuffle($terms);
break;
case 3:
$definitions = $this->object->pcArrayShuffle($definitions);
break;
}
include_once "./Services/YUI/classes/class.ilYuiUtil.php";
// create definitions
$counter = 0;
foreach ($definitions as $definition)
{
if (strlen($definition->picture))
{
$template->setCurrentBlock("definition_picture");
$template->setVariable("DEFINITION_ID", $definition->identifier);
$template->setVariable("IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
$thumbweb = $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $definition->picture;
$thumb = $this->object->getImagePath() . $this->object->getThumbPrefix() . $definition->picture;
if (!@file_exists($thumb)) $this->object->rebuildThumbnails();
$template->setVariable("THUMBNAIL_HREF", $thumbweb);
$template->setVariable("THUMB_ALT", $this->lng->txt("image"));
$template->setVariable("THUMB_TITLE", $this->lng->txt("image"));
$template->setVariable("TEXT_DEFINITION", (strlen($definition->text)) ? $this->object->prepareTextareaOutput($definition->text, TRUE) : '');
$template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
$template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png'));
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock("definition_text");
$template->setVariable("DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
$template->parseCurrentBlock();
}
$template->setCurrentBlock("droparea");
$template->setVariable("ID_DROPAREA", $definition->identifier);
$template->setVariable("QUESTION_ID", $this->object->getId());
if ($this->object->getEstimatedElementHeight() > 0)
{
$template->setVariable("ELEMENT_HEIGHT", " style=\"height: " . $this->object->getEstimatedElementHeight() . "px;\"");
}
$template->parseCurrentBlock();
$template->setCurrentBlock("init_dropareas");
$template->setVariable("COUNTER", $counter++);
$template->setVariable("ID_DROPAREA", $definition->identifier);
$template->parseCurrentBlock();
}
// create terms
$counter = 0;
foreach ($terms as $term)
{
if (strlen($term->picture))
{
$template->setCurrentBlock("term_picture");
$template->setVariable("TERM_ID", $term->identifier);
$template->setVariable("IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
$thumbweb = $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $term->picture;
$thumb = $this->object->getImagePath() . $this->object->getThumbPrefix() . $term->picture;
if (!@file_exists($thumb)) $this->object->rebuildThumbnails();
$template->setVariable("THUMBNAIL_HREF", $thumbweb);
$template->setVariable("THUMB_ALT", $this->lng->txt("image"));
$template->setVariable("THUMB_TITLE", $this->lng->txt("image"));
$template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
$template->setVariable("TEXT_TERM", (strlen($term->text)) ? $this->object->prepareTextareaOutput($term->text, TRUE) : '');
$template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png'));
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock("term_text");
$template->setVariable("TERM_TEXT", $this->object->prepareTextareaOutput($term->text, TRUE));
$template->parseCurrentBlock();
}
$template->setCurrentBlock("draggable");
$template->setVariable("ID_DRAGGABLE", $term->identifier);
if ($this->object->getEstimatedElementHeight() > 0)
{
$template->setVariable("ELEMENT_HEIGHT", " style=\"height: " . $this->object->getEstimatedElementHeight() . "px;\"");
}
$template->parseCurrentBlock();
$template->setCurrentBlock("init_draggables");
$template->setVariable("COUNTER", $counter++);
$template->setVariable("ID_DRAGGABLE", $term->identifier);
$template->parseCurrentBlock();
}
$template->setVariable("RESET_BUTTON", $this->lng->txt("reset_terms"));
$this->tpl->setVariable("LOCATION_ADDITIONAL_STYLESHEET", ilUtil::getStyleSheetLocation("output", "test_javascript.css", "Modules/TestQuestionPool"));
$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:

+ Here is the caller graph for this function:

assMatchingQuestionGUI::getSolutionOutput (   $active_id,
  $pass = NULL,
  $graphicalOutput = FALSE,
  $result_output = FALSE,
  $show_question_only = TRUE,
  $show_feedback = FALSE,
  $show_correct_solution = FALSE,
  $show_manual_scoring = FALSE,
  $show_question_text = TRUE 
)

Get the question solution output.

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

Reimplemented from assQuestionGUI.

Definition at line 406 of file class.assMatchingQuestionGUI.php.

References $ok, $pass, assQuestionGUI\getGenericFeedbackOutput(), ilUtil\getImagePath(), getSpecificFeedbackOutput(), isCorrectMatching(), and ilUtil\prepareFormOutput().

{
// generate the question output
include_once "./Services/UICore/classes/class.ilTemplate.php";
$template = new ilTemplate("tpl.il_as_qpl_matching_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool");
$solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html",TRUE, TRUE, "Modules/TestQuestionPool");
$solutions = array();
if (($active_id > 0) && (!$show_correct_solution))
{
include_once "./Modules/Test/classes/class.ilObjTest.php";
$solutions =& $this->object->getSolutionValues($active_id, $pass);
$solution_script .= "";
}
else
{
foreach ($this->object->getMatchingPairs() as $pair)
{
if( $pair->points <= 0 )
{
continue;
}
$solutions[] = array(
"value1" => $pair->term->identifier,
"value2" => $pair->definition->identifier,
'points' => $pair->points
);
}
}
$i = 0;
foreach ($solutions as $solution)
{
$definition = $this->object->getDefinitionWithIdentifier($solution['value2']);
$term = $this->object->getTermWithIdentifier($solution['value1']);
$points = $solution['points'];
if (is_object($definition))
{
if (strlen($definition->picture))
{
$template->setCurrentBlock('definition_image');
$template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $definition->picture);
$template->setVariable('ANSWER_IMAGE_ALT', (strlen($definition->text)) ? ilUtil::prepareFormOutput($definition->text) : ilUtil::prepareFormOutput($definition->picture));
$template->setVariable('ANSWER_IMAGE_TITLE', (strlen($definition->text)) ? ilUtil::prepareFormOutput($definition->text) : ilUtil::prepareFormOutput($definition->picture));
$template->setVariable('URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
$template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
$template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png'));
$template->setVariable("TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt('definition') . ' ' . ($i+1) . ': ' . ilUtil::prepareFormOutput($definition->text) : $this->lng->txt('definition') . ' ' . ($i+1));
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock('definition_text');
$template->setVariable("DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
$template->parseCurrentBlock();
}
}
if (is_object($term))
{
if (strlen($term->picture))
{
$template->setCurrentBlock('term_image');
$template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $term->picture);
$template->setVariable('ANSWER_IMAGE_ALT', (strlen($term->text)) ? ilUtil::prepareFormOutput($term->text) : ilUtil::prepareFormOutput($term->picture));
$template->setVariable('ANSWER_IMAGE_TITLE', (strlen($term->text)) ? ilUtil::prepareFormOutput($term->text) : ilUtil::prepareFormOutput($term->picture));
$template->setVariable('URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
$template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
$template->setVariable("TEXT_TERM", (strlen($term->text)) ? $this->lng->txt('term') . ' ' . ($i+1) . ': ' . ilUtil::prepareFormOutput($term->text) : $this->lng->txt('term') . ' ' . ($i+1));
$template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png'));
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock('term_text');
$template->setVariable("TERM", $this->object->prepareTextareaOutput($term->text, TRUE));
$template->parseCurrentBlock();
}
$i++;
}
if (($active_id > 0) && (!$show_correct_solution))
{
if ($graphicalOutput)
{
// output of ok/not ok icons for user entered solutions
$ok = false;
foreach ($this->object->getMatchingPairs() as $pair)
{
if( $this->isCorrectMatching($pair, $definition, $term) )
{
$ok = true;
}
}
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 ($result_output)
{
$resulttext = ($points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")";
$template->setCurrentBlock("result_output");
$template->setVariable("RESULT_OUTPUT", sprintf($resulttext, $points));
$template->parseCurrentBlock();
}
$template->setCurrentBlock("row");
if ($this->object->getEstimatedElementHeight() > 0)
{
$template->setVariable("ELEMENT_HEIGHT", " style=\"height: " . $this->object->getEstimatedElementHeight() . "px;\"");
}
$template->setVariable("TEXT_MATCHES", $this->lng->txt("matches"));
$template->parseCurrentBlock();
}
$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 = '<div class="ilc_question_Standard">'.$solutionoutput."</div>";
}
return $solutionoutput;
}

+ Here is the call graph for this function:

assMatchingQuestionGUI::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 1442 of file class.assMatchingQuestionGUI.php.

Referenced by getSolutionOutput().

{
$feedback = '<table><tbody>';
foreach ($this->object->getMatchingPairs() as $idx => $ans)
{
$feedback .= '<tr><td><b><i>' . $ans->definition->text . '</i></b></td><td>'. $this->lng->txt("matches") . '&nbsp;';
$feedback .= '</td><td><b><i>' . $ans->term->text . '</i></b></td><td>&nbsp;</td><td>';
$feedback .= $this->object->getFeedbackSingleAnswer($idx) . '</td> </tr>';
}
$feedback .= '</tbody></table>';
return $this->object->prepareTextareaOutput($feedback, TRUE);
}

+ Here is the caller graph for this function:

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

Definition at line 1057 of file class.assMatchingQuestionGUI.php.

References $pass, ilObjTest\_getPass(), ilObjTest\_getUsePreviousAnswers(), ilUtil\getImagePath(), getTestOutputJS(), OUTPUT_JAVASCRIPT, assQuestionGUI\outQuestionPage(), ilUtil\prepareFormOutput(), and sortDefinitionsBySolution().

Referenced by outQuestionForTest().

{
if ($this->object->getOutputType() == OUTPUT_JAVASCRIPT)
{
return $this->getTestOutputJS($active_id, $pass, $is_postponed, $user_post_solution);
}
// generate the question output
include_once "./Services/UICore/classes/class.ilTemplate.php";
$template = new ilTemplate("tpl.il_as_qpl_matching_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
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['matching'][$this->object->getId()] as $definition => $term)
{
array_push($solutions, array("value1" => $term, "value2" => $definition));
}
}
else
{
$solutions =& $this->object->getSolutionValues($active_id, $pass);
}
}
// shuffle output
$terms = $this->object->getTerms();
$definitions = $this->object->getDefinitions();
switch ($this->object->getShuffle())
{
case 1:
$terms = $this->object->pcArrayShuffle($terms);
if (count($solutions))
{
$definitions = $this->sortDefinitionsBySolution($solutions);
}
else
{
$definitions = $this->object->pcArrayShuffle($definitions);
}
break;
case 2:
$terms = $this->object->pcArrayShuffle($terms);
break;
case 3:
if (count($solutions))
{
$definitions = $this->sortDefinitionsBySolution($solutions);
}
else
{
$definitions = $this->object->pcArrayShuffle($definitions);
}
break;
}
$maxcount = max(count($terms), count($definitions));
for ($i = 0; $i < count($definitions); $i++)
{
$definition = $definitions[$i];
if (is_object($definition))
{
if (strlen($definition->picture))
{
$template->setCurrentBlock('definition_image');
$template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $definition->picture);
$template->setVariable('ANSWER_IMAGE_ALT', (strlen($definition->text)) ? ilUtil::prepareFormOutput($definition->text) : ilUtil::prepareFormOutput($definition->picture));
$template->setVariable('ANSWER_IMAGE_TITLE', (strlen($definition->text)) ? ilUtil::prepareFormOutput($definition->text) : ilUtil::prepareFormOutput($definition->picture));
$template->setVariable('URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
$template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
$template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png'));
$template->setVariable("TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt('definition') . ' ' . ($i+1) . ': ' . ilUtil::prepareFormOutput($definition->text) : $this->lng->txt('definition') . ' ' . ($i+1));
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock('definition_text');
$template->setVariable("DEFINITION", $this->object->prepareTextareaOutput($definition->text, true));
$template->parseCurrentBlock();
}
}
$template->setCurrentBlock('option');
$template->setVariable("VALUE_OPTION", 0);
$template->setVariable("TEXT_OPTION", ilUtil::prepareFormOutput($this->lng->txt('please_select')));
$template->parseCurrentBlock();
$j = 1;
foreach ($terms as $term)
{
$template->setCurrentBlock('option');
$template->setVariable("VALUE_OPTION", $term->identifier);
$template->setVariable("TEXT_OPTION", (strlen($term->text)) ? $this->lng->txt('term') . ' ' . ($j) . ': ' . ilUtil::prepareFormOutput($term->text) : $this->lng->txt('term') . ' ' . ($j));
foreach ($solutions as $solution)
{
if ($solution["value1"] == $term->identifier && $solution["value2"] == $definition->identifier)
{
$template->setVariable("SELECTED_OPTION", " selected=\"selected\"");
}
}
$template->parseCurrentBlock();
$j++;
}
$template->setCurrentBlock('row');
$template->setVariable("TEXT_MATCHES", $this->lng->txt("matches"));
if ($this->object->getEstimatedElementHeight() > 0)
{
$template->setVariable("ELEMENT_HEIGHT", " style=\"height: " . $this->object->getEstimatedElementHeight() . "px;\"");
}
$template->setVariable("QUESTION_ID", $this->object->getId());
$template->setVariable("DEFINITION_ID", $definition->identifier);
$template->parseCurrentBlock();
}
$i = 0;
foreach ($terms as $term)
{
if (strlen($term->picture))
{
$template->setCurrentBlock('term_image');
$template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $term->picture);
$template->setVariable('ANSWER_IMAGE_ALT', (strlen($term->text)) ? ilUtil::prepareFormOutput($term->text) : ilUtil::prepareFormOutput($term->picture));
$template->setVariable('ANSWER_IMAGE_TITLE', (strlen($term->text)) ? ilUtil::prepareFormOutput($term->text) : ilUtil::prepareFormOutput($term->picture));
$template->setVariable('URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
$template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
$template->setVariable("TEXT_TERM", (strlen($term->text)) ? $this->lng->txt('term') . ' ' . ($i+1) . ': ' . ilUtil::prepareFormOutput($term->text) : $this->lng->txt('term') . ' ' . ($i+1));
$template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png'));
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock('term_text');
$template->setVariable("TERM", $this->object->prepareTextareaOutput($term->text, true));
$template->parseCurrentBlock();
}
$template->touchBlock('terms');
$i++;
}
$questiontext = $this->object->getQuestion();
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
$template->setVariable("TEXT_TERMS", ilUtil::prepareFormOutput($this->lng->txt('available_terms')));
$template->setVariable('TEXT_SELECTION', ilUtil::prepareFormOutput($this->lng->txt('selection')));
$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:

assMatchingQuestionGUI::getTestOutputJS (   $active_id,
  $pass = NULL,
  $is_postponed = FALSE,
  $user_post_solution = FALSE 
)

Definition at line 887 of file class.assMatchingQuestionGUI.php.

References $pass, ilObjTest\_getPass(), ilObjTest\_getUsePreviousAnswers(), ilUtil\getImagePath(), ilUtil\getStyleSheetLocation(), ilYuiUtil\initDragDrop(), OUTPUT_JAVASCRIPT, assQuestionGUI\outQuestionPage(), ilUtil\prepareFormOutput(), and sortDefinitionsBySolution().

Referenced by getTestOutput().

{
// generate the question output
include_once "./Services/UICore/classes/class.ilTemplate.php";
$template = new ilTemplate("tpl.il_as_qpl_matching_output_js.html", TRUE, TRUE, "Modules/TestQuestionPool");
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['matching'][$this->object->getId()] as $definition => $term)
{
array_push($solutions, array("value1" => $term, "value2" => $definition));
}
}
else
{
$solutions =& $this->object->getSolutionValues($active_id, $pass);
}
foreach ($solutions as $idx => $solution_value)
{
if ($this->object->getOutputType() == OUTPUT_JAVASCRIPT)
{
if (($solution_value["value2"] > -1) && ($solution_value["value1"] > -1))
{
$template->setCurrentBlock("restoreposition");
$template->setVariable("TERM_ID", $solution_value["value1"]);
$template->setVariable("PICTURE_DEFINITION_ID", $solution_value["value2"]);
$template->parseCurrentBlock();
}
}
}
}
// shuffle output
$terms = $this->object->getTerms();
$definitions = $this->object->getDefinitions();
switch ($this->object->getShuffle())
{
case 1:
$terms = $this->object->pcArrayShuffle($terms);
if (count($solutions))
{
$definitions = $this->sortDefinitionsBySolution($solutions);
}
else
{
$definitions = $this->object->pcArrayShuffle($definitions);
}
break;
case 2:
$terms = $this->object->pcArrayShuffle($terms);
break;
case 3:
if (count($solutions))
{
$definitions = $this->sortDefinitionsBySolution($solutions);
}
else
{
$definitions = $this->object->pcArrayShuffle($definitions);
}
break;
}
include_once "./Services/YUI/classes/class.ilYuiUtil.php";
// create definitions
$counter = 0;
foreach ($definitions as $definition)
{
if (strlen($definition->picture))
{
$template->setCurrentBlock("definition_picture");
$template->setVariable("DEFINITION_ID", $definition->identifier);
$template->setVariable("IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
$thumbweb = $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $definition->picture;
$thumb = $this->object->getImagePath() . $this->object->getThumbPrefix() . $definition->picture;
if (!@file_exists($thumb)) $this->object->rebuildThumbnails();
$template->setVariable("THUMBNAIL_HREF", $thumbweb);
$template->setVariable("THUMB_ALT", $this->lng->txt("image"));
$template->setVariable("THUMB_TITLE", $this->lng->txt("image"));
$template->setVariable("TEXT_DEFINITION", (strlen($definition->text)) ? ilUtil::prepareFormOutput($definition->text) : '');
$template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
$template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png'));
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock("definition_text");
$template->setVariable("DEFINITION", $this->object->prepareTextareaOutput($definition->text, true));
$template->parseCurrentBlock();
}
$template->setCurrentBlock("droparea");
$template->setVariable("ID_DROPAREA", $definition->identifier);
$template->setVariable("QUESTION_ID", $this->object->getId());
if ($this->object->getEstimatedElementHeight() > 0)
{
$template->setVariable("ELEMENT_HEIGHT", " style=\"height: " . $this->object->getEstimatedElementHeight() . "px;\"");
}
$template->parseCurrentBlock();
$template->setCurrentBlock("init_dropareas");
$template->setVariable("COUNTER", $counter++);
$template->setVariable("ID_DROPAREA", $definition->identifier);
$template->parseCurrentBlock();
}
// create terms
$counter = 0;
foreach ($terms as $term)
{
if (strlen($term->picture))
{
$template->setCurrentBlock("term_picture");
$template->setVariable("TERM_ID", $term->identifier);
$template->setVariable("IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
$thumbweb = $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $term->picture;
$thumb = $this->object->getImagePath() . $this->object->getThumbPrefix() . $term->picture;
if (!@file_exists($thumb)) $this->object->rebuildThumbnails();
$template->setVariable("THUMBNAIL_HREF", $thumbweb);
$template->setVariable("THUMB_ALT", $this->lng->txt("image"));
$template->setVariable("THUMB_TITLE", $this->lng->txt("image"));
$template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
$template->setVariable("TEXT_TERM", (strlen($term->text)) ? ilUtil::prepareFormOutput($term->text) : '');
$template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png'));
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock("term_text");
$template->setVariable("TERM_TEXT", $this->object->prepareTextareaOutput($term->text, true));
$template->parseCurrentBlock();
}
$template->setCurrentBlock("draggable");
$template->setVariable("ID_DRAGGABLE", $term->identifier);
if ($this->object->getEstimatedElementHeight() > 0)
{
$template->setVariable("ELEMENT_HEIGHT", " style=\"height: " . $this->object->getEstimatedElementHeight() . "px;\"");
}
$template->parseCurrentBlock();
$template->setCurrentBlock("init_draggables");
$template->setVariable("COUNTER", $counter++);
$template->setVariable("ID_DRAGGABLE", $term->identifier);
$template->parseCurrentBlock();
}
$template->setVariable("RESET_BUTTON", $this->lng->txt("reset_terms"));
$this->tpl->setVariable("LOCATION_ADDITIONAL_STYLESHEET", ilUtil::getStyleSheetLocation("output", "test_javascript.css", "Modules/TestQuestionPool"));
$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:

assMatchingQuestionGUI::isCorrectMatching (   $pair,
  $definition,
  $term 
)
private

Definition at line 1457 of file class.assMatchingQuestionGUI.php.

Referenced by getSolutionOutput().

{
if( !($pair->points > 0) )
{
return false;
}
if( !is_object($term) )
{
return false;
}
if( $pair->definition->identifier != $definition->identifier )
{
return false;
}
if( $pair->term->identifier != $term->identifier )
{
return false;
}
return true;
}

+ Here is the caller graph for this function:

assMatchingQuestionGUI::isValidTermAndDefinitionAmount ( ilPropertyFormGUI  $form)
private
Parameters
ilPropertyFormGUI$form
Returns
bool

Definition at line 373 of file class.assMatchingQuestionGUI.php.

References ilPropertyFormGUI\getItemByPostVar().

Referenced by editQuestion().

{
$numTerms = count($form->getItemByPostVar('terms')->getValues());
$numDefinitions = count($form->getItemByPostVar('definitions')->getValues());
if($numTerms >= $numDefinitions)
{
return true;
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 386 of file class.assMatchingQuestionGUI.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:

assMatchingQuestionGUI::removedefinitions ( )

Definition at line 218 of file class.assMatchingQuestionGUI.php.

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

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

+ Here is the call graph for this function:

assMatchingQuestionGUI::removeimagedefinitions ( )

Remove an image.

Definition at line 185 of file class.assMatchingQuestionGUI.php.

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

{
$this->writePostData(true);
$position = key($_POST['cmd']['removeimagedefinitions']);
$filename = $_POST['definitions']['imagename'][$position];
$this->object->removeDefinitionImage($position);
$this->editQuestion();
}

+ Here is the call graph for this function:

assMatchingQuestionGUI::removeimageterms ( )

Remove an image.

Definition at line 163 of file class.assMatchingQuestionGUI.php.

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

{
$this->writePostData(true);
$position = key($_POST['cmd']['removeimageterms']);
$filename = $_POST['terms']['imagename'][$position];
$this->object->removeTermImage($position);
$this->editQuestion();
}

+ Here is the call graph for this function:

assMatchingQuestionGUI::removepairs ( )

Definition at line 234 of file class.assMatchingQuestionGUI.php.

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

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

+ Here is the call graph for this function:

assMatchingQuestionGUI::removeterms ( )

Definition at line 202 of file class.assMatchingQuestionGUI.php.

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

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

+ Here is the call graph for this function:

assMatchingQuestionGUI::saveFeedback ( )

Saves the feedback for a single choice question.

Reimplemented from assQuestionGUI.

Definition at line 1232 of file class.assMatchingQuestionGUI.php.

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

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

+ Here is the call graph for this function:

assMatchingQuestionGUI::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 1253 of file class.assMatchingQuestionGUI.php.

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

{
global $rbacsystem, $ilTabs;
$this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$q_type = $this->object->getQuestionType();
if (strlen($q_type))
{
$classname = $q_type . "GUI";
$this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
$this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
}
if ($_GET["q_id"])
{
if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
{
// edit page
$ilTabs->addTarget("edit_page",
$this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "edit"),
array("edit", "insert", "exec_pg"),
"", "", $force_active);
}
// edit page
$ilTabs->addTarget("preview",
$this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "preview"),
array("preview"),
"ilPageObjectGUI", "", $force_active);
}
$force_active = false;
if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
{
$url = "";
if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
// edit question properties
$ilTabs->addTarget("edit_question",
$url,
array("editQuestion", "save", "saveEdit", "removeimageterms", "uploadterms", "removeimagedefinitions", "uploaddefinitions",
"addpairs", "removepairs", "addterms", "removeterms", "adddefinitions", "removedefinitions", "originalSyncForm"),
$classname, "", $force_active);
}
if ($_GET["q_id"])
{
$ilTabs->addTarget("feedback",
$this->ctrl->getLinkTargetByClass($classname, "feedback"),
array("feedback", "saveFeedback"),
$classname, "");
}
// add tab for question hint within common class assQuestionGUI
$this->addTab_QuestionHints($ilTabs);
if ($_GET["q_id"])
{
$ilTabs->addTarget("solution_hint",
$this->ctrl->getLinkTargetByClass($classname, "suggestedsolution"),
array("suggestedsolution", "saveSuggestedSolution", "outSolutionExplorer", "cancel",
"addSuggestedSolution","cancelExplorer", "linkChilds", "removeSuggestedSolution"
),
$classname,
""
);
}
// Assessment of questions sub menu entry
if ($_GET["q_id"])
{
$ilTabs->addTarget("statistics",
$this->ctrl->getLinkTargetByClass($classname, "assessment"),
array("assessment"),
$classname, "");
}
if (($_GET["calling_test"] > 0) || ($_GET["test_ref_id"] > 0))
{
$ref_id = $_GET["calling_test"];
if (strlen($ref_id) == 0) $ref_id = $_GET["test_ref_id"];
global $___test_express_mode;
if (!$_GET['test_express_mode'] && !$___test_express_mode) {
$ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
}
else {
$ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), $link);
}
}
else
{
$ilTabs->setBackTarget($this->lng->txt("qpl"), $this->ctrl->getLinkTargetByClass("ilobjquestionpoolgui", "questions"));
}
}

+ Here is the call graph for this function:

assMatchingQuestionGUI::sortDefinitionsBySolution (   $solution)
protected

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

Referenced by getTestOutput(), and getTestOutputJS().

{
$neworder = array();
foreach ($solution as $solution_values)
{
$id = $solution_values['value2'];
array_push($neworder, $this->object->getDefinitionWithIdentifier($id));
}
return $neworder;
}

+ Here is the caller graph for this function:

assMatchingQuestionGUI::uploaddefinitions ( )

Upload an image.

Definition at line 175 of file class.assMatchingQuestionGUI.php.

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

{
$this->writePostData(true);
$position = key($_POST['cmd']['uploaddefinitions']);
$this->editQuestion();
}

+ Here is the call graph for this function:

assMatchingQuestionGUI::uploadterms ( )

Upload an image.

Definition at line 153 of file class.assMatchingQuestionGUI.php.

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

{
$this->writePostData(true);
$position = key($_POST['cmd']['uploadterms']);
$this->editQuestion();
}

+ Here is the call graph for this function:

assMatchingQuestionGUI::writePostData (   $always = false)

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

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

Definition at line 52 of file class.assMatchingQuestionGUI.php.

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

{
$hasErrors = (!$always) ? $this->editQuestion(true) : false;
if (!$hasErrors)
{
$this->object->setTitle($_POST["title"]);
$this->object->setAuthor($_POST["author"]);
$this->object->setComment($_POST["comment"]);
include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
$questiontext = $_POST["question"];
$this->object->setQuestion($questiontext);
{
$this->object->setShuffle($_POST["shuffle"]);
}
else
{
$this->object->setShuffle(1);
}
$this->object->setThumbGeometry($_POST["thumb_geometry"]);
$this->object->setElementHeight($_POST["element_height"]);
{
$this->object->setNrOfTries($_POST['nr_of_tries']);
}
// adding estimated working time
$this->object->setEstimatedWorkingTime(
$_POST["Estimated"]["hh"],
$_POST["Estimated"]["mm"],
$_POST["Estimated"]["ss"]
);
// Delete all existing answers and create new answers from the form data
$this->object->flushMatchingPairs();
$this->object->flushTerms();
$this->object->flushDefinitions();
$saved = false;
// add terms
include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
foreach ($_POST['terms']['answer'] as $index => $answer)
{
$filename = $_POST['terms']['imagename'][$index];
if (strlen($_FILES['terms']['name']['image'][$index]))
{
// upload the new file
$name = $_FILES['terms']['name']['image'][$index];
if ($this->object->setImageFile($_FILES['terms']['tmp_name']['image'][$index], $this->object->getEncryptedFilename($name)))
{
$filename = $this->object->getEncryptedFilename($name);
}
else
{
$filename = "";
}
}
$this->object->addTerm(new assAnswerMatchingTerm($answer, $filename, $_POST['terms']['identifier'][$index]));
}
// add definitions
include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
foreach ($_POST['definitions']['answer'] as $index => $answer)
{
$filename = $_POST['definitions']['imagename'][$index];
if (strlen($_FILES['definitions']['name']['image'][$index]))
{
// upload the new file
$name = $_FILES['definitions']['name']['image'][$index];
if ($this->object->setImageFile($_FILES['definitions']['tmp_name']['image'][$index], $this->object->getEncryptedFilename($name)))
{
$filename = $this->object->getEncryptedFilename($name);
}
else
{
$filename = "";
}
}
$this->object->addDefinition(new assAnswerMatchingDefinition($answer, $filename, $_POST['definitions']['identifier'][$index]));
}
// add matching pairs
if (is_array($_POST['pairs']['points']))
{
include_once "./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
foreach ($_POST['pairs']['points'] as $index => $points)
{
$term_id = $_POST['pairs']['term'][$index];
$definition_id = $_POST['pairs']['definition'][$index];
$this->object->addMatchingPair($this->object->getTermWithIdentifier($term_id), $this->object->getDefinitionWithIdentifier($definition_id), $points);
}
}
return 0;
}
else
{
return 1;
}
}

+ Here is the call graph for this function:


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