ILIAS  Release_4_4_x_branch Revision 61816
 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
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object.
 writeAnswerSpecificPostData ($always=true)
 Extracts the answer specific values from $_POST and applies them to the data object.
 writeQuestionSpecificPostData ($always=true)
 Extracts the question specific values from $_POST and applies them to the data object.
 uploadterms ()
 removeimageterms ()
 uploaddefinitions ()
 removeimagedefinitions ()
 addterms ()
 removeterms ()
 adddefinitions ()
 removedefinitions ()
 addpairs ()
 removepairs ()
 editQuestion ($checkonly=FALSE)
 populateAnswerSpecificFormPart (\ilPropertyFormGUI $form)
 populateQuestionSpecificFormPart (\ilPropertyFormGUI $form)
 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
 setQuestionTabs ()
 Sets the ILIAS tabs for this question type.
 getSpecificFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question.
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment.
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment.
 resetFormValuesForSuppressedPostvars ($form)
 getAggregatedAnswersView ($relevant_answers)
 Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface.
 aggregateAnswerVariants ($relevant_answers_chosen, $terms, $definitions)
 renderVariantsView ($aggregate)
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor
executeCommand ()
 execute command
 getCommand ($cmd)
 getType ()
 needed for page editor compliance
 setTaxonomyIds ($taxonomyIds)
 getTaxonomyIds ()
 setTargetGui (ilTestPlayerAbstractGUI $linkTargetGui)
 setTargetGuiClass ($targetGuiClass)
 getTargetGuiClass ()
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object.
 assessment ()
 output assessment
_getQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui note: please do not use $this inside this method to allow static calls.
 _getGUIClassNameForId ($a_q_id)
 _getClassNameForQType ($q_type)
createQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation.
 getQuestionTemplate ()
 get question template
 getILIASPage ($html="")
 Returns the ILIAS Page around a question.
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="")
 output question page
 cancel ()
 cancel action
 originalSyncForm ($return_to="", $return_to_feedback= '')
 sync ()
 cancelSync ()
 saveEdit ()
 save question
 save ()
 save question
 saveReturn ()
 save question
 apply ()
 apply changes
 getContextPath ($cont_obj, $a_endnode_id, $a_startnode_id=1)
 get context path in content object tree
 setSequenceNumber ($nr)
 getSequenceNumber ()
 setQuestionCount ($a_question_count)
 getQuestionCount ()
 getErrorMessage ()
 setErrorMessage ($errormessage)
 addErrorMessage ($errormessage)
 outAdditionalOutput ()
 getQuestionType ()
 Returns the question type string.
 getAsValueAttribute ($a_value)
 Returns a HTML value attribute.
 addNewIdListener (&$a_object, $a_method, $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved.
 callNewIdListeners ($a_new_id)
 Call the new id listeners.
 addQuestionFormCommandButtons ($form)
 Add the command buttons of a question properties form.
 addBasicQuestionFormProperties ($form)
 Add basic question form properties: assessment: title, author, description, question, working time.
 getSelfAssessmentTags ()
 Get tags allowed in question tags in self assessment mode.
 getAnswerFeedbackOutput ($active_id, $pass)
 Returns the answer generic feedback depending on the results of the question.
 getGenericFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question.
 outQuestionType ()
 showSuggestedSolution ()
 suggestedsolution ()
 Allows to add suggested solutions for questions.
 outSolutionExplorer ()
 saveSuggestedSolution ()
 cancelExplorer ()
 outPageSelector ()
 outChapterSelector ()
 outGlossarySelector ()
 linkChilds ()
 addPG ()
 addST ()
 addGIT ()
 isSaveCommand ()
 isAutosaveable ()
 showHints ()
- Public Member Functions inherited from ilGuiQuestionScoringAdjustable
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui.
- Public Member Functions inherited from ilGuiAnswerScoringAdjustable
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui.

Protected Member Functions

 sortDefinitionsBySolution ($solution)
- Protected Member Functions inherited from assQuestionGUI
 saveTaxonomyAssignments ()
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI
 writeQuestionGenericPostData ()

Private Member Functions

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

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
- Data Fields inherited from assQuestionGUI
const FORM_MODE_EDIT = 'edit'
const FORM_MODE_ADJUST = 'adjust'
 $object
 $tpl
 $lng
 $error
 $errormessage
 $sequence_no
 sequence number in test
 $question_count
 question count in test

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
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
Id:
class.assMatchingQuestionGUI.php 60700 2015-09-15 09:01:13Z gitmgr

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

Definition at line 34 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 198 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 214 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 182 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::aggregateAnswerVariants (   $relevant_answers_chosen,
  $terms,
  $definitions 
)

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

Referenced by getAggregatedAnswersView().

{
$variants = array();
$passdata = array();
foreach ($relevant_answers_chosen as $relevant_answer)
{
$pass_ident = $relevant_answer['active_fi'].$relevant_answer['pass'];
$answer = $passdata[$pass_ident];
if (strlen($answer))
{
$answer_elements = explode(',', $answer);
} else {
$answer_elements = array();
}
$answer_elements[] = $relevant_answer['value1'].'.'.$relevant_answer['value2'];
$passdata[$pass_ident] = implode(',',$answer_elements);
}
foreach($passdata as $passident => $behaviour)
{
$variants[$behaviour]++;
}
arsort($variants);
return $variants;
}

+ Here is the caller graph for this function:

assMatchingQuestionGUI::checkInput ( )

check input fields

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

References $_POST.

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

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

References $errors, assQuestionGUI\addBasicQuestionFormProperties(), assQuestionGUI\addQuestionFormCommandButtons(), assQuestionGUI\getQuestionTemplate(), assQuestionGUI\isSaveCommand(), isValidTermAndDefinitionAmount(), assQuestionGUI\outQuestionType(), populateAnswerSpecificFormPart(), populateQuestionSpecificFormPart(), assQuestionGUI\populateTaxonomyFormSection(), and ilUtil\sendFailure().

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");
// title, author, description, question, working time (assessment mode)
$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) && !$this->object->getSelfAssessmentEditingMode() )
{
$errors = true;
$terms = $form->getItemByPostVar('terms');
$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::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 1346 of file class.assMatchingQuestionGUI.php.

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

{
return array('shuffle', 'element_height', 'thumb_geometry');
}
assMatchingQuestionGUI::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 1393 of file class.assMatchingQuestionGUI.php.

References $pass, assQuestionGUI\$tpl, aggregateAnswerVariants(), and renderVariantsView().

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

+ Here is the call graph for this function:

assMatchingQuestionGUI::getPreview (   $show_question_only = FALSE)

Definition at line 731 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;
}
foreach ($definitions as $key => $definition)
{
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') . ' ' . ($key+1) . ': ' . $this->object->prepareTextareaOutput($definition->text, TRUE) : $this->lng->txt('definition') . ' ' . ($key+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();
foreach ($terms as $key => $term)
{
$template->setCurrentBlock('option');
$template->setVariable("VALUE_OPTION", $term->identifier);
$template->setVariable("TEXT_OPTION", (strlen($term->text)) ? $this->lng->txt('term') . ' ' . ($key +1) . ': ' . ilUtil::prepareFormOutput($term->text) : $this->lng->txt('term') . ' ' . ($key+1));
$template->parseCurrentBlock();
}
$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();
}
foreach ($terms as $key => $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') . ' ' . ($key+1) . ': ' . $this->object->prepareTextareaOutput($term->text, TRUE) : $this->lng->txt('term') . ' ' . ($key+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');
}
$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 577 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 407 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 1319 of file class.assMatchingQuestionGUI.php.

Referenced by getSolutionOutput().

{
$feedback = '<table><tbody>';
foreach ($this->object->getMatchingPairs() as $idx => $ans)
{
$fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
$this->object->getId(), $idx
);
$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 .= $fb . '</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 1053 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));
foreach ($definitions as $key => $definition)
{
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') . ' ' . ($key+1) . ': ' . ilUtil::prepareFormOutput($definition->text) : $this->lng->txt('definition') . ' ' . ($key+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();
foreach ($terms as $key => $term)
{
$template->setCurrentBlock('option');
$template->setVariable("VALUE_OPTION", $term->identifier);
$template->setVariable("TEXT_OPTION", (strlen($term->text)) ? $this->lng->txt('term') . ' ' . ($key+1) . ': ' . ilUtil::prepareFormOutput($term->text) : $this->lng->txt('term') . ' ' . ($key +1));
foreach ($solutions as $solution)
{
if ($solution["value1"] == $term->identifier && $solution["value2"] == $definition->identifier)
{
$template->setVariable("SELECTED_OPTION", " selected=\"selected\"");
}
}
$template->parseCurrentBlock();
}
$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();
}
foreach ($terms as $key=>$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') . ' ' . ($key+1) . ': ' . ilUtil::prepareFormOutput($term->text) : $this->lng->txt('term') . ' ' . ($key+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');
}
$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 883 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 1498 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 275 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 387 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::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

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

References ilPropertyFormGUI\addItem(), ilMatchingWizardInputGUI\setHideImages(), and ilFormPropertyGUI\setRequired().

Referenced by editQuestion().

{
// Definitions
include_once "./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
$definitions = new ilMatchingWizardInputGUI($this->lng->txt( "definitions" ), "definitions");
if ($this->object->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->object->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 );
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assMatchingQuestionGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

References ilPropertyFormGUI\addItem(), ilSelectInputGUI\setOptions(), and ilNumberInputGUI\setValue().

Referenced by editQuestion().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assMatchingQuestionGUI::removedefinitions ( )

Definition at line 206 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 ( )

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

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

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

+ Here is the call graph for this function:

assMatchingQuestionGUI::removeimageterms ( )

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

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

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

+ Here is the call graph for this function:

assMatchingQuestionGUI::removepairs ( )

Definition at line 222 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 190 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::renderVariantsView (   $aggregate)

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

References $options, and assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

{
$tpl = new ilTemplate( 'tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool" );
$tpl->setVariable( 'OPTION_HEADER', $this->lng->txt( 'answer_variant' ) );
$tpl->setVariable( 'COUNT_HEADER', $this->lng->txt( 'count' ) );
$tpl->setVariable( 'AGGREGATION_HEADER', $this->lng->txt( 'aggregated_answers_variants' ) );
foreach ($aggregate as $options => $count)
{
$tpl->setCurrentBlock( 'aggregaterow' );
$optionstext = array();
foreach (explode( ',', $options ) as $option)
{
$pair = explode('.',$option);
if($pair[0] == -1 || $pair[1] == -1)
{
continue;
}
$term = $this->object->getTermWithIdentifier($pair[0]);
$term_rep = $term->text;
if($term->picture)
{
$term_rep .= '&nbsp;<img src="'
. $this->object->getImagePathWeb()
. $this->object->getThumbPrefix()
. $term->picture
. '" />';
}
$definition = $this->object->getDefinitionWithIdentifier($pair[1]);
$definition_rep = $definition->text;
if($definition->picture)
{
$definition_rep .= '&nbsp;<img src="'
. $this->object->getImagePathWeb()
. $this->object->getThumbPrefix()
. $definition->picture
. '" />';
}
$optionstext[] = $definition_rep. '&nbsp;-&gt;&nbsp;'. $term_rep;
}
$tpl->setVariable( 'OPTION', implode( '<br />', $optionstext ) );
$tpl->setVariable( 'COUNT', $count );
$tpl->parseCurrentBlock();
}
return $tpl;
}

+ Here is the caller graph for this function:

assMatchingQuestionGUI::resetFormValuesForSuppressedPostvars (   $form)

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

References $_POST.

{
$element = $form->getItemByPostvar('thumb_geometry');
$_POST['thumb_geometry'] = $this->object->getThumbGeometry();
$element->setValue( $this->object->getThumbGeometry() );
}
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 1225 of file class.assMatchingQuestionGUI.php.

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

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

+ Here is the call graph for this function:

assMatchingQuestionGUI::sortDefinitionsBySolution (   $solution)
protected

Definition at line 872 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 ( )

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

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

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

+ Here is the call graph for this function:

assMatchingQuestionGUI::uploadterms ( )

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

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

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

+ Here is the call graph for this function:

assMatchingQuestionGUI::writeAnswerSpecificPostData (   $always = true)

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

References $_POST, and $filename.

Referenced by writePostData().

{
// Delete all existing answers and create new answers from the form data
$this->object->flushMatchingPairs();
$this->object->flushTerms();
$this->object->flushDefinitions();
// add terms
require_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
require_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'] ))
{
require_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
);
}
}
}

+ Here is the caller graph for this function:

assMatchingQuestionGUI::writePostData (   $always = false)

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

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

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

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

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

+ Here is the call graph for this function:

assMatchingQuestionGUI::writeQuestionSpecificPostData (   $always = true)

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

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

Implements ilGuiQuestionScoringAdjustable.

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

References $_POST.

Referenced by writePostData().

{
if (!$this->object->getSelfAssessmentEditingMode())
{
$this->object->setShuffle( $_POST["shuffle"] );
}
else
{
$this->object->setShuffle( 1 );
}
$this->object->setThumbGeometry( $_POST["thumb_geometry"] );
$this->object->setElementHeight( $_POST["element_height"] );
}

+ Here is the caller graph for this function:


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