ILIAS  Release_4_1_x_branch Revision 61804
 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)
 Get the question solution output.
 getTestOutput ($active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE)
 saveFeedback ()
 Saves the feedback for a single choice question.
 setQuestionTabs ()
 Sets the ILIAS tabs for this question type.
- 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
 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.
 getAnswerFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback depending on the results of the question.
 feedback ($checkonly=false)
 Creates the output of the feedback page for the question.
 outQuestionType ()
 suggestedsolution ()
 Allows to add suggested solutions for questions.
 outSolutionExplorer ()
 saveSuggestedSolution ()
 cancelExplorer ()
 outPageSelector ()
 outChapterSelector ()
 outGlossarySelector ()
 linkChilds ()
 addPG ()
 addST ()
 addGIT ()

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

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
Version
Id:
class.assClozeTestGUI.php 33584 2012-03-07 12:48:19Z mbecker

Definition at line 36 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 48 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 337 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 317 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 152 of file class.assClozeTestGUI.php.

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

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

{
$save = ((strcmp($this->ctrl->getCmd(), "save") == 0) || (strcmp($this->ctrl->getCmd(), "saveEdit") == 0)) ? TRUE : FALSE;
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);
}
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)
{
$value = new ilFormulaInputGUI($this->lng->txt('value'), "gap_" . $i . "_numeric");
$value->setSize(10);
$value->setValue(ilUtil::prepareFormOutput($item->getAnswertext()));
$value->setRequired(true);
$value->setInlineStyle('text-align: right;');
$form->addItem($value);
$lowerbound = new ilFormulaInputGUI($this->lng->txt('range_lower_limit'), "gap_" . $i . "_numeric_lower");
$lowerbound->setSize(10);
$lowerbound->setRequired(true);
$lowerbound->setValue(ilUtil::prepareFormOutput($item->getLowerBound()));
$lowerbound->setInlineStyle('text-align: right;');
$form->addItem($lowerbound);
$upperbound = new ilFormulaInputGUI($this->lng->txt('range_upper_limit'), "gap_" . $i . "_numeric_upper");
$upperbound->setSize(10);
$upperbound->setRequired(true);
$upperbound->setValue(ilUtil::prepareFormOutput($item->getUpperBound()));
$upperbound->setInlineStyle('text-align: right;');
$form->addItem($upperbound);
$points = new ilNumberInputGUI($this->lng->txt('points'), "gap_" . $i . "_numeric_points");
$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::getCommand (   $cmd)

Reimplemented from assQuestionGUI.

Definition at line 59 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 371 of file class.assClozeTestGUI.php.

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

{
// generate the question output
include_once "./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 
)

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

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

References $pass, CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, assQuestionGUI\getAnswerFeedbackOutput(), assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), 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)
{
// get the solutions of a user
$user_solution =& $this->object->getSolutionValues($active_id, $pass);
if (!is_array($user_solution))
{
$user_solution = array();
}
}
include_once "./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.gif"));
$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.gif"));
$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.gif"));
$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 = ($show_feedback) ? $this->getAnswerFeedbackOutput($active_id, $pass) : "";
if (strlen($feedback)) $solutiontemplate->setVariable("FEEDBACK", $feedback);
$solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
$solutionoutput = $solutiontemplate->get();
if (!$show_question_only)
{
// get page object output
$solutionoutput = $this->getILIASPage($solutionoutput);
}
return $solutionoutput;
}

+ Here is the call graph for this function:

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

Definition at line 607 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 "./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 356 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 327 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 695 of file class.assClozeTestGUI.php.

References $_POST, $errors, and assQuestionGUI\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"]);
$this->object->cleanupMediaObjectUsage();
}

+ Here is the call graph for this function:

assClozeTestGUI::setQuestionTabs ( )

Sets the ILIAS tabs for this question type.

public

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

References $_GET, $_POST, and $ref_id.

{
global $rbacsystem, $ilTabs;
$this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$q_type = $this->object->getQuestionType();
if (strlen($q_type))
{
$classname = $q_type . "GUI";
$this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
$this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
}
if ($_GET["q_id"])
{
if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
{
// edit page
$ilTabs->addTarget("edit_content",
$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_properties",
$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, "");
}
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"];
$ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
}
else
{
$ilTabs->setBackTarget($this->lng->txt("qpl"), $this->ctrl->getLinkTargetByClass("ilobjquestionpoolgui", "questions"));
}
}
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 75 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 41 of file class.assClozeTestGUI.php.


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