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

Cloze test question GUI representation. More...

+ Inheritance diagram for assClozeTestGUI:
+ Collaboration diagram for assClozeTestGUI:

Public Member Functions

 __construct ($id=-1)
 assClozeTestGUI constructor
 getCommand ($cmd)
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object.
 editQuestion ($checkonly=FALSE)
 Creates an output of the edit form for the question.
 createGaps ()
 Create gaps from cloze text.
 removegap ()
 Remove a gap answer.
 addgap ()
 Add a gap answer.
 outQuestionForTest ($formaction, $active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE)
 Creates an output of the question for a test.
 getPreview ($show_question_only=FALSE)
 Creates a preview output of the question.
 getSolutionOutput ($active_id, $pass=NULL, $graphicalOutput=FALSE, $result_output=FALSE, $show_question_only=TRUE, $show_feedback=FALSE, $show_correct_solution=FALSE, $show_manual_scoring=FALSE, $show_question_text=TRUE)
 Get the question solution output.
 getAnswerFeedbackOutput ($active_id, $pass)
 Returns the answer generic feedback depending on the results of the question.
 getTestOutput ($active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
 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.
 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 ()

Private Attributes

 $gapIndex
 A temporary variable to store gap indexes of ilCtrl commands in the getCommand method.

Additional Inherited Members

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

Detailed Description

Cloze test question GUI representation.

The assClozeTestGUI class encapsulates the GUI representation for cloze test 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 37 of file class.assClozeTestGUI.php.

Constructor & Destructor Documentation

assClozeTestGUI::__construct (   $id = -1)

assClozeTestGUI constructor

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

Definition at line 49 of file class.assClozeTestGUI.php.

References assQuestionGUI\__construct().

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

+ Here is the call graph for this function:

Member Function Documentation

assClozeTestGUI::addgap ( )

Add a gap answer.

Definition at line 377 of file class.assClozeTestGUI.php.

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

{
$this->writePostData(true);
$this->object->addGapAnswer($this->gapIndex, key($_POST['cmd']['addgap_' . $this->gapIndex])+1, "");
$this->editQuestion();
}

+ Here is the call graph for this function:

assClozeTestGUI::createGaps ( )

Create gaps from cloze text.

Definition at line 357 of file class.assClozeTestGUI.php.

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

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

+ Here is the call graph for this function:

assClozeTestGUI::editQuestion (   $checkonly = FALSE)

Creates an output of the edit form for the question.

public

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

References $errors, assQuestionGUI\addBasicQuestionFormProperties(), assQuestionGUI\addQuestionFormCommandButtons(), ilNumberInputGUI\allowDecimals(), CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, assQuestionGUI\getQuestionTemplate(), assQuestionGUI\getSelfAssessmentEditingMode(), assQuestionGUI\isSaveCommand(), assQuestionGUI\outQuestionType(), ilUtil\prepareFormOutput(), ilTextInputGUI\setInlineStyle(), ilSelectInputGUI\setOptions(), ilFormPropertyGUI\setRequired(), ilCheckboxInputGUI\setValue(), and ilNumberInputGUI\setValue().

Referenced by addgap(), createGaps(), removegap(), and writePostData().

{
$save = $this->isSaveCommand();
# if ($_REQUEST['prev_qid']) {
# $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
# }
include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
$form->setFormAction($this->ctrl->getFormAction($this));
$form->setTitle($this->outQuestionType());
$form->setMultipart(FALSE);
$form->setTableWidth("100%");
$form->setId("assclozetest");
// title, author, description, question, working time (assessment mode)
$q_item = $form->getItemByPostVar("question");
$q_item->setInfo($this->lng->txt("close_text_hint"));
$q_item->setTitle($this->lng->txt("cloze_text"));
// text rating
{
$textrating = new ilSelectInputGUI($this->lng->txt("text_rating"), "textgap_rating");
$text_options = array(
"ci" => $this->lng->txt("cloze_textgap_case_insensitive"),
"cs" => $this->lng->txt("cloze_textgap_case_sensitive"),
"l1" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1"),
"l2" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2"),
"l3" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3"),
"l4" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4"),
"l5" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5")
);
$textrating->setOptions($text_options);
$textrating->setValue($this->object->getTextgapRating());
$form->addItem($textrating);
// text field length
$fixedTextLength = new ilNumberInputGUI($this->lng->txt("cloze_fixed_textlength"), "fixedTextLength");
$fixedTextLength->setValue(ilUtil::prepareFormOutput($this->object->getFixedTextLength()));
$fixedTextLength->setMinValue(0);
$fixedTextLength->setSize(3);
$fixedTextLength->setMaxLength(6);
$fixedTextLength->setInfo($this->lng->txt('cloze_fixed_textlength_description'));
$fixedTextLength->setRequired(false);
$form->addItem($fixedTextLength);
// identical scoring
$identical_scoring = new ilCheckboxInputGUI($this->lng->txt("identical_scoring"), "identical_scoring");
$identical_scoring->setValue(1);
$identical_scoring->setChecked($this->object->getIdenticalScoring());
$identical_scoring->setInfo($this->lng->txt('identical_scoring_desc'));
$identical_scoring->setRequired(FALSE);
$form->addItem($identical_scoring);
}
for ($i = 0; $i < $this->object->getGapCount(); $i++)
{
$gap = $this->object->getGap($i);
$header = new ilFormSectionHeaderGUI();
$header->setTitle($this->lng->txt("gap") . " " . ($i+1));
$form->addItem($header);
$gapcounter = new ilHiddenInputGUI("gap[$i]");
$gapcounter->setValue($i);
$form->addItem($gapcounter);
$gaptype = new ilSelectInputGUI($this->lng->txt('type'), "clozetype_$i");
$options = array(
0 => $this->lng->txt("text_gap"),
1 => $this->lng->txt("select_gap"),
2 => $this->lng->txt("numeric_gap")
);
$gaptype->setOptions($options);
$gaptype->setValue($gap->getType());
$form->addItem($gaptype);
if ($gap->getType() == CLOZE_TEXT)
{
// Choices
include_once "./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
$values = new ilAnswerWizardInputGUI($this->lng->txt("values"), "gap_" . $i . "");
$values->setRequired(true);
$values->setQuestionObject($this->object);
$values->setSingleline(true);
$values->setAllowMove(false);
if (count($gap->getItemsRaw()) == 0) $gap->addItem(new assAnswerCloze("", 0, 0));
$values->setValues($gap->getItemsRaw());
$form->addItem($values);
if( $this->object->getFixedTextLength() > 0 )
{
$values->setSize($this->object->getFixedTextLength());
$values->setMaxLength($this->object->getFixedTextLength());
}
}
else if ($gap->getType() == CLOZE_SELECT)
{
include_once "./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
$values = new ilAnswerWizardInputGUI($this->lng->txt("values"), "gap_" . $i . "");
$values->setRequired(true);
$values->setQuestionObject($this->object);
$values->setSingleline(true);
$values->setAllowMove(false);
if (count($gap->getItemsRaw()) == 0) $gap->addItem(new assAnswerCloze("", 0, 0));
$values->setValues($gap->getItemsRaw());
$form->addItem($values);
// shuffle
$shuffle = new ilCheckboxInputGUI($this->lng->txt("shuffle_answers"), "shuffle_" . $i . "");
$shuffle->setValue(1);
$shuffle->setChecked($gap->getShuffle());
$shuffle->setRequired(FALSE);
$form->addItem($shuffle);
}
else if ($gap->getType() == CLOZE_NUMERIC)
{
if (count($gap->getItemsRaw()) == 0) $gap->addItem(new assAnswerCloze("", 0, 0));
foreach ($gap->getItemsRaw() as $item)
{
// #8944: the js-based ouput in self-assessment cannot support formulas
{
$value = new ilFormulaInputGUI($this->lng->txt('value'), "gap_" . $i . "_numeric");
$value->setInlineStyle('text-align: right;');
$lowerbound = new ilFormulaInputGUI($this->lng->txt('range_lower_limit'), "gap_" . $i . "_numeric_lower");
$lowerbound->setInlineStyle('text-align: right;');
$upperbound = new ilFormulaInputGUI($this->lng->txt('range_upper_limit'), "gap_" . $i . "_numeric_upper");
$upperbound->setInlineStyle('text-align: right;');
}
else
{
$value = new ilNumberInputGUI($this->lng->txt('value'), "gap_" . $i . "_numeric");
$value->allowDecimals(true);
$lowerbound = new ilNumberInputGUI($this->lng->txt('range_lower_limit'), "gap_" . $i . "_numeric_lower");
$lowerbound->allowDecimals(true);
$upperbound = new ilNumberInputGUI($this->lng->txt('range_upper_limit'), "gap_" . $i . "_numeric_upper");
$upperbound->allowDecimals(true);
}
$value->setSize(10);
$value->setValue(ilUtil::prepareFormOutput($item->getAnswertext()));
$value->setRequired(true);
$form->addItem($value);
$lowerbound->setSize(10);
$lowerbound->setRequired(true);
$lowerbound->setValue(ilUtil::prepareFormOutput($item->getLowerBound()));
$form->addItem($lowerbound);
$upperbound->setSize(10);
$upperbound->setRequired(true);
$upperbound->setValue(ilUtil::prepareFormOutput($item->getUpperBound()));
$form->addItem($upperbound);
if( $this->object->getFixedTextLength() > 0 )
{
$value->setSize($this->object->getFixedTextLength());
$value->setMaxLength($this->object->getFixedTextLength());
$lowerbound->setSize($this->object->getFixedTextLength());
$lowerbound->setMaxLength($this->object->getFixedTextLength());
$upperbound->setSize($this->object->getFixedTextLength());
$upperbound->setMaxLength($this->object->getFixedTextLength());
}
$points = new ilNumberInputGUI($this->lng->txt('points'), "gap_" . $i . "_numeric_points");
$points->allowDecimals(true);
$points->setSize(3);
$points->setRequired(true);
$points->setValue(ilUtil::prepareFormOutput($item->getPoints()));
$form->addItem($points);
}
}
}
$form->addCommandButton('createGaps', $this->lng->txt('create_gaps'));
$errors = false;
if ($save)
{
$form->setValuesByPost();
$errors = !$form->checkInput();
$form->setValuesByPost(); // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
if ($errors) $checkonly = false;
}
if (!$checkonly) $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
return $errors;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assClozeTestGUI::feedback (   $checkonly = false)

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

public

Reimplemented from assQuestionGUI.

Definition at line 920 of file class.assClozeTestGUI.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("100%");
$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->gaps as $index => $answer)
{
$caption = 'Gap '.$ordinal = $index+1 .':<i> ';
foreach ($answer->items as $item)
{
$caption .= '"' . $item->answertext.'" / ';
}
$caption = substr($caption, 0, strlen($caption)-3);
$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:

assClozeTestGUI::getAnswerFeedbackOutput (   $active_id,
  $pass 
)

Returns the answer generic feedback depending on the results of the question.

Deprecated:
Use getGenericFeedbackOutput instead.
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 666 of file class.assClozeTestGUI.php.

References $pass, $test, and ilObjTest\getManualFeedback().

{
include_once "./Modules/Test/classes/class.ilObjTest.php";
$manual_feedback = ilObjTest::getManualFeedback($active_id, $this->object->getId(), $pass);
if (strlen($manual_feedback))
{
return $manual_feedback;
}
$correct_feedback = $this->object->getFeedbackGeneric(1);
$incorrect_feedback = $this->object->getFeedbackGeneric(0);
if (strlen($correct_feedback.$incorrect_feedback))
{
$reached_points = $this->object->calculateReachedPoints($active_id, $pass);
$max_points = $this->object->getMaximumPoints();
if ($reached_points == $max_points)
{
$output .= $correct_feedback;
}
else
{
$output .= $incorrect_feedback;
}
}
$test = new ilObjTest($this->object->active_id);
return $this->object->prepareTextareaOutput($output, TRUE);
}

+ Here is the call graph for this function:

assClozeTestGUI::getCommand (   $cmd)

Reimplemented from assQuestionGUI.

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

References $cmd.

{
if (preg_match("/^(removegap|addgap)_(\d+)$/", $cmd, $matches))
{
$cmd = $matches[1];
$this->gapIndex = $matches[2];
}
return $cmd;
}
assClozeTestGUI::getPreview (   $show_question_only = FALSE)

Creates a preview output of the question.

Creates a preview output of the question

Returns
string HTML code which contains the preview output of the question public

Definition at line 411 of file class.assClozeTestGUI.php.

References CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, assQuestionGUI\getILIASPage(), and ilUtil\prepareFormOutput().

{
// generate the question output
include_once "./Services/UICore/classes/class.ilTemplate.php";
$template = new ilTemplate("tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
$output = $this->object->getClozeText();
foreach ($this->object->getGaps() as $gap_index => $gap)
{
switch ($gap->getType())
{
case CLOZE_TEXT:
$gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE, "Modules/TestQuestionPool");
$gaptemplate->setVariable("TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->object->getFixedTextLength() : $gap->getMaxWidth());
$gaptemplate->setVariable("GAP_COUNTER", $gap_index);
$output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
break;
$gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE, "Modules/TestQuestionPool");
foreach ($gap->getItems() as $item)
{
$gaptemplate->setCurrentBlock("select_gap_option");
$gaptemplate->setVariable("SELECT_GAP_VALUE", $item->getOrder());
$gaptemplate->setVariable("SELECT_GAP_TEXT", ilUtil::prepareFormOutput($item->getAnswerText()));
$gaptemplate->parseCurrentBlock();
}
$gaptemplate->setVariable("PLEASE_SELECT", $this->lng->txt("please_select"));
$gaptemplate->setVariable("GAP_COUNTER", $gap_index);
$output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
break;
$gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE, "Modules/TestQuestionPool");
$gaptemplate->setVariable("TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->object->getFixedTextLength() : $gap->getMaxWidth());
$gaptemplate->setVariable("GAP_COUNTER", $gap_index);
$output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
break;
}
}
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($output, TRUE));
$questionoutput = $template->get();
if (!$show_question_only)
{
// get page object output
$questionoutput = $this->getILIASPage($questionoutput);
}
return $questionoutput;
}

+ Here is the call graph for this function:

assClozeTestGUI::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 471 of file class.assClozeTestGUI.php.

References $pass, CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, assQuestionGUI\getGenericFeedbackOutput(), ilUtil\getImagePath(), getSpecificFeedbackOutput(), and ilUtil\prepareFormOutput().

{
// get the solution of the user for the active pass or from the last pass if allowed
$user_solution = array();
if (($active_id > 0) && (!$show_correct_solution))
{
// get the solutions of a user
$user_solution =& $this->object->getSolutionValues($active_id, $pass);
if (!is_array($user_solution))
{
$user_solution = array();
}
} else {
foreach ($this->object->gaps as $index => $gap)
{
$user_solution = array();
}
}
include_once "./Services/UICore/classes/class.ilTemplate.php";
$template = new ilTemplate("tpl.il_as_qpl_cloze_question_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool");
$output = $this->object->getClozeText();
foreach ($this->object->getGaps() as $gap_index => $gap)
{
$gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_output_solution_gap.html", TRUE, TRUE, "Modules/TestQuestionPool");
$found = array();
foreach ($user_solution as $solutionarray)
{
if ($solutionarray["value1"] == $gap_index) $found = $solutionarray;
}
if ($active_id)
{
if ($graphicalOutput)
{
// output of ok/not ok icons for user entered solutions
$details = $this->object->calculateReachedPoints($active_id, $pass, TRUE);
$check = $details[$gap_index];
if ($check["best"])
{
$gaptemplate->setCurrentBlock("icon_ok");
$gaptemplate->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.png"));
$gaptemplate->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
$gaptemplate->parseCurrentBlock();
}
else
{
$gaptemplate->setCurrentBlock("icon_not_ok");
if ($check["positive"])
{
$gaptemplate->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_mostly_ok.png"));
$gaptemplate->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_not_correct_but_positive"));
}
else
{
$gaptemplate->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.png"));
$gaptemplate->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
}
$gaptemplate->parseCurrentBlock();
}
}
}
if ($result_output)
{
$points = $this->object->getMaximumGapPoints($gap_index);
$resulttext = ($points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")";
$gaptemplate->setCurrentBlock("result_output");
$gaptemplate->setVariable("RESULT_OUTPUT", sprintf($resulttext, $points));
$gaptemplate->parseCurrentBlock();
}
switch ($gap->getType())
{
case CLOZE_TEXT:
$solutiontext = "";
if (($active_id > 0) && (!$show_correct_solution))
{
if ((count($found) == 0) || (strlen(trim($found["value2"])) == 0))
{
for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
{
$solutiontext .= "&nbsp;";
}
}
else
{
$solutiontext = ilUtil::prepareFormOutput($found["value2"]);
}
}
else
{
$solutiontext = ilUtil::prepareFormOutput($gap->getBestSolutionOutput());
}
$gaptemplate->setVariable("SOLUTION", $solutiontext);
$output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
break;
$solutiontext = "";
if (($active_id > 0) && (!$show_correct_solution))
{
if ((count($found) == 0) || (strlen(trim($found["value2"])) == 0))
{
for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
{
$solutiontext .= "&nbsp;";
}
}
else
{
$item = $gap->getItem($found["value2"]);
if (is_object($item))
{
$solutiontext = ilUtil::prepareFormOutput($item->getAnswertext());
}
else
{
for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
{
$solutiontext .= "&nbsp;";
}
}
}
}
else
{
$solutiontext = ilUtil::prepareFormOutput($gap->getBestSolutionOutput());
}
$gaptemplate->setVariable("SOLUTION", $solutiontext);
$output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
break;
$solutiontext = "";
if (($active_id > 0) && (!$show_correct_solution))
{
if ((count($found) == 0) || (strlen(trim($found["value2"])) == 0))
{
for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
{
$solutiontext .= "&nbsp;";
}
}
else
{
$solutiontext = ilUtil::prepareFormOutput($found["value2"]);
}
}
else
{
$solutiontext = ilUtil::prepareFormOutput($gap->getBestSolutionOutput());
}
$gaptemplate->setVariable("SOLUTION", $solutiontext);
$output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
break;
}
}
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($output, TRUE));
// generate the question output
$solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html",TRUE, TRUE, "Modules/TestQuestionPool");
$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:

assClozeTestGUI::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 1007 of file class.assClozeTestGUI.php.

Referenced by getSolutionOutput().

{
$feedback = '<table><tbody>';
foreach ($this->object->gaps as $index => $answer)
{
$caption = $ordinal = $index+1 .':<i> ';
foreach ($answer->items as $item)
{
$caption .= '"' . $item->answertext.'" / ';
}
$caption = substr($caption, 0, strlen($caption)-3);
$caption .= '</i>';
$feedback .= '<tr><td>';
$feedback .= $caption .'</td><td>';
$feedback .= $this->object->getFeedbackSingleAnswer($index) . '</td> </tr>';
}
$feedback .= '</tbody></table>';
return $this->object->prepareTextareaOutput($feedback, TRUE);
}

+ Here is the caller graph for this function:

assClozeTestGUI::getTestOutput (   $active_id,
  $pass = NULL,
  $is_postponed = FALSE,
  $use_post_solutions = FALSE,
  $show_feedback = FALSE 
)

Definition at line 693 of file class.assClozeTestGUI.php.

References $pass, ilObjTest\_getPass(), ilObjTest\_getUsePreviousAnswers(), CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, assQuestionGUI\outQuestionPage(), and ilUtil\prepareFormOutput().

Referenced by outQuestionForTest().

{
// get the solution of the user for the active pass or from the last pass if allowed
$user_solution = array();
if ($active_id)
{
include_once "./Modules/Test/classes/class.ilObjTest.php";
if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
{
if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
}
$user_solution =& $this->object->getSolutionValues($active_id, $pass);
if (!is_array($user_solution))
{
$user_solution = array();
}
}
// generate the question output
include_once "./Services/UICore/classes/class.ilTemplate.php";
$template = new ilTemplate("tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
$output = $this->object->getClozeText();
foreach ($this->object->getGaps() as $gap_index => $gap)
{
switch ($gap->getType())
{
case CLOZE_TEXT:
$gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE, "Modules/TestQuestionPool");
$gaptemplate->setVariable("TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->object->getFixedTextLength() : $gap->getMaxWidth());
$gaptemplate->setVariable("GAP_COUNTER", $gap_index);
foreach ($user_solution as $solution)
{
if (strcmp($solution["value1"], $gap_index) == 0)
{
$gaptemplate->setVariable("VALUE_GAP", " value=\"" . ilUtil::prepareFormOutput($solution["value2"]) . "\"");
}
}
$output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
break;
$gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE, "Modules/TestQuestionPool");
foreach ($gap->getItems() as $item)
{
$gaptemplate->setCurrentBlock("select_gap_option");
$gaptemplate->setVariable("SELECT_GAP_VALUE", $item->getOrder());
$gaptemplate->setVariable("SELECT_GAP_TEXT", ilUtil::prepareFormOutput($item->getAnswerText()));
foreach ($user_solution as $solution)
{
if (strcmp($solution["value1"], $gap_index) == 0)
{
if (strcmp($solution["value2"], $item->getOrder()) == 0)
{
$gaptemplate->setVariable("SELECT_GAP_SELECTED", " selected=\"selected\"");
}
}
}
$gaptemplate->parseCurrentBlock();
}
$gaptemplate->setVariable("PLEASE_SELECT", $this->lng->txt("please_select"));
$gaptemplate->setVariable("GAP_COUNTER", $gap_index);
$output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
break;
$gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE, "Modules/TestQuestionPool");
$gaptemplate->setVariable("TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->object->getFixedTextLength() : $gap->getMaxWidth());
$gaptemplate->setVariable("GAP_COUNTER", $gap_index);
foreach ($user_solution as $solution)
{
if (strcmp($solution["value1"], $gap_index) == 0)
{
$gaptemplate->setVariable("VALUE_GAP", " value=\"" . ilUtil::prepareFormOutput($solution["value2"]) . "\"");
}
}
$output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
break;
}
}
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($output, 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:

assClozeTestGUI::outQuestionForTest (   $formaction,
  $active_id,
  $pass = NULL,
  $is_postponed = FALSE,
  $use_post_solutions = FALSE 
)

Creates an output of the question for a test.

Creates an output of the question for a test

Parameters
string$formactionThe form action for the test output
integer$active_idThe active id of the current user from the tst_active database table
integer$passThe test pass of the current user
boolean$is_postponedThe information if the question is a postponed question or not
boolean$use_post_solutionsFills the question output with answers from the previous post if TRUE, otherwise with the user results from the database public

Definition at line 396 of file class.assClozeTestGUI.php.

References $pass, and getTestOutput().

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

+ Here is the call graph for this function:

assClozeTestGUI::removegap ( )

Remove a gap answer.

Definition at line 367 of file class.assClozeTestGUI.php.

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

{
$this->writePostData(true);
$this->object->deleteAnswerText($this->gapIndex, key($_POST['cmd']['removegap_' . $this->gapIndex]));
$this->editQuestion();
}

+ Here is the call graph for this function:

assClozeTestGUI::saveFeedback ( )

Saves the feedback for a single choice question.

public

Reimplemented from assQuestionGUI.

Definition at line 782 of file class.assClozeTestGUI.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->gaps as $index => $answer)
{
$this->object->saveFeedbackSingleAnswer($index, $_POST["feedback_answer_$index"]);
}
$this->object->cleanupMediaObjectUsage();
}

+ Here is the call graph for this function:

assClozeTestGUI::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 803 of file class.assClozeTestGUI.php.

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

{
global $rbacsystem, $ilTabs;
$this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$q_type = $this->object->getQuestionType();
if (strlen($q_type))
{
$classname = $q_type . "GUI";
$this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
$this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
# $this->ctrl->setParameterByClass(strtolower($classname), 'prev_qid', $_REQUEST['prev_qid']);
}
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;
$commands = $_POST["cmd"];
if (is_array($commands))
{
foreach ($commands as $key => $value)
{
if (preg_match("/^removegap_.*/", $key, $matches) ||
preg_match("/^addgap_.*/", $key, $matches)
)
{
$force_active = true;
}
}
}
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", "originalSyncForm", "save", "createGaps", "saveEdit"),
$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:

assClozeTestGUI::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 76 of file class.assClozeTestGUI.php.

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

{
$hasErrors = (!$always) ? $this->editQuestion(true) : false;
if (!$hasErrors)
{
$this->object->flushGaps();
$this->object->setTitle($_POST["title"]);
$this->object->setAuthor($_POST["author"]);
$this->object->setComment($_POST["comment"]);
$this->object->setTextgapRating($_POST["textgap_rating"]);
$this->object->setIdenticalScoring($_POST["identical_scoring"]);
{
$this->object->setNrOfTries($_POST['nr_of_tries']);
}
$this->object->setFixedTextLength($_POST["fixedTextLength"]);
include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
$cloze_text = $_POST["question"];
$this->object->setClozeText($cloze_text);
$this->object->setEstimatedWorkingTime(
$_POST["Estimated"]["hh"],
$_POST["Estimated"]["mm"],
$_POST["Estimated"]["ss"]
);
if (is_array($_POST['gap']))
{
if (strcmp($this->ctrl->getCmd(), 'createGaps') != 0) $this->object->clearGapAnswers();
foreach ($_POST['gap'] as $idx => $hidden)
{
$clozetype = $_POST['clozetype_' . $idx];
$this->object->setGapType($idx, $clozetype);
if (array_key_exists('shuffle_' . $idx, $_POST))
{
$this->object->setGapShuffle($idx, $_POST['shuffle_' . $idx]);
}
if (strcmp($this->ctrl->getCmd(), 'createGaps') != 0)
{
if (is_array($_POST['gap_' . $idx]['answer']))
{
foreach ($_POST['gap_' . $idx]['answer'] as $order => $value)
{
$this->object->addGapAnswer($idx, $order, $value);
}
}
}
if (array_key_exists('gap_' . $idx . '_numeric', $_POST))
{
if (strcmp($this->ctrl->getCmd(), 'createGaps') != 0) $this->object->addGapAnswer($idx, 0, str_replace(",", ".", $_POST['gap_' . $idx . '_numeric']));
$this->object->setGapAnswerLowerBound($idx, 0, str_replace(",", ".", $_POST['gap_' . $idx . '_numeric_lower']));
$this->object->setGapAnswerUpperBound($idx, 0, str_replace(",", ".", $_POST['gap_' . $idx . '_numeric_upper']));
$this->object->setGapAnswerPoints($idx, 0, $_POST['gap_' . $idx . '_numeric_points']);
}
if (is_array($_POST['gap_' . $idx]['points']))
{
foreach ($_POST['gap_' . $idx]['points'] as $order => $value)
{
$this->object->setGapAnswerPoints($idx, $order, $value);
}
}
}
if (strcmp($this->ctrl->getCmd(), 'createGaps') != 0) $this->object->updateClozeTextFromGaps();
}
return 0;
}
else
{
return 1;
}
}

+ Here is the call graph for this function:

Field Documentation

assClozeTestGUI::$gapIndex
private

A temporary variable to store gap indexes of ilCtrl commands in the getCommand method.

Definition at line 42 of file class.assClozeTestGUI.php.


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