ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
assKprimChoiceGUI Class Reference
+ Inheritance diagram for assKprimChoiceGUI:
+ Collaboration diagram for assKprimChoiceGUI:

Public Member Functions

 __construct ($qId=-1)
 removeImage ()
 downkprim_answers ()
 upkprim_answers ()
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 getSpecificFeedbackOutput ($active_id, $pass)
 getTestOutput ($active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE, $showInlineFeedback=FALSE)
 getPreview ($show_question_only=FALSE, $showInlineFeedback=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)
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment.
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment.
 getAggregatedAnswersView ($relevant_answers)
 Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface.
 renderAggregateView ($aggregate)
 aggregateAnswers ($rawSolutionData, $answers)
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor
executeCommand ()
 execute command
 getCommand ($cmd)
 getType ()
 needed for page editor compliance
 setTaxonomyIds ($taxonomyIds)
 getTaxonomyIds ()
 setTargetGui ($linkTargetGui)
 setTargetGuiClass ($targetGuiClass)
 getTargetGuiClass ()
 setQuestionHeaderBlockBuilder ($questionHeaderBlockBuilder)
 setQuestionActionCmd ($questionActionCmd)
 getQuestionActionCmd ()
_getQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui note: please do not use $this inside this method to allow static calls.
 _getGUIClassNameForId ($a_q_id)
 _getClassNameForQType ($q_type)
createQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation.
 getQuestionTemplate ()
 get question template
 getILIASPage ($html="")
 Returns the ILIAS Page around a question.
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="")
 output question page
 cancel ()
 cancel action
 originalSyncForm ($return_to="", $return_to_feedback= '')
 sync ()
 cancelSync ()
 saveEdit ()
 save question
 save ()
 save question
 saveReturn ()
 save question
 apply ()
 apply changes
 getContextPath ($cont_obj, $a_endnode_id, $a_startnode_id=1)
 get context path in content object tree
 setSequenceNumber ($nr)
 getSequenceNumber ()
 setQuestionCount ($a_question_count)
 getQuestionCount ()
 getErrorMessage ()
 setErrorMessage ($errormessage)
 addErrorMessage ($errormessage)
 outAdditionalOutput ()
 getQuestionType ()
 Returns the question type string.
 getAsValueAttribute ($a_value)
 Returns a HTML value attribute.
 addNewIdListener (&$a_object, $a_method, $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved.
 callNewIdListeners ($a_new_id)
 Call the new id listeners.
 addQuestionFormCommandButtons ($form)
 Add the command buttons of a question properties form.
 addBasicQuestionFormProperties ($form)
 Add basic question form properties: assessment: title, author, description, question, working time.
 getSelfAssessmentTags ()
 Get tags allowed in question tags in self assessment mode.
 getAnswerFeedbackOutput ($active_id, $pass)
 Returns the answer generic feedback depending on the results of the question.
 getGenericFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question.
 getGenericFeedbackOutputForCorrectSolution ()
 getGenericFeedbackOutputForIncorrectSolution ()
 outQuestionType ()
 showSuggestedSolution ()
 suggestedsolution ()
 Allows to add suggested solutions for questions.
 outSolutionExplorer ()
 saveSuggestedSolution ()
 cancelExplorer ()
 outPageSelector ()
 outChapterSelector ()
 outGlossarySelector ()
 linkChilds ()
 addPG ()
 addST ()
 addGIT ()
 isSaveCommand ()
 setQuestionTabs ()
 addTab_SuggestedSolution (ilTabsGUI $tabs, $classname)
 getEditQuestionTabCommands ()
 isAutosaveable ()
 outQuestionForTest ($formaction, $active_id, $pass=NULL, $is_question_postponed=FALSE, $user_post_solutions=FALSE, $show_specific_inline_feedback=FALSE)
 setPreviewSession ($previewSession)
 getPreviewSession ()
 showHints ()

Data Fields

 $object
- Data Fields inherited from assQuestionGUI
const FORM_MODE_EDIT = 'edit'
const FORM_MODE_ADJUST = 'adjust'
const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded'
const FORM_ENCODING_MULTIPART = 'multipart/form-data'
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 $object
 $tpl
 $lng
 $error
 $errormessage
 $sequence_no
 sequence number in test
 $question_count
 question count in test

Protected Member Functions

 getAdditionalEditQuestionCommands ()
 editQuestion (ilPropertyFormGUI $form=null)
 uploadImage ()
 writePostData ($upload=false)
 getParticipantsAnswerKeySequence ()
- Protected Member Functions inherited from assQuestionGUI
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object.
 saveTaxonomyAssignments ()
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 getBasicEditQuestionTabCommands ()
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI
 addTab_QuestionPreview (ilTabsGUI $tabsGUI)
 writeQuestionGenericPostData ()
 getFormEncodingType ()
 addBackTab (ilTabsGUI $ilTabs)
 buildBasicEditFormObject ()

Private Member Functions

 buildEditForm ()
 handleAnswerTextsSubmit ($answers)
 populateSpecificFeedbackInline ($user_solution, $answer_id, $template)

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

Detailed Description

Definition at line 16 of file class.assKprimChoiceGUI.php.

Constructor & Destructor Documentation

assKprimChoiceGUI::__construct (   $qId = -1)
Parameters
$qId

Definition at line 26 of file class.assKprimChoiceGUI.php.

References assQuestionGUI\__construct().

{
require_once 'Modules/TestQuestionPool/classes/class.assKprimChoice.php';
$this->object = new assKprimChoice();
if ($qId > 0)
{
$this->object->loadFromDb($qId);
}
}

+ Here is the call graph for this function:

Member Function Documentation

assKprimChoiceGUI::aggregateAnswers (   $rawSolutionData,
  $answers 
)

Definition at line 865 of file class.assKprimChoiceGUI.php.

Referenced by getAggregatedAnswersView().

{
$aggregate = array();
foreach( $answers as $answer )
{
$answerAgg = array(
'answertext' => $answer->getAnswerText(), 'count_true' => 0, 'count_false' => 0
);
foreach( $rawSolutionData as $solutionRecord )
{
if( $solutionRecord['value1'] == $answer->getPosition() )
{
if( $solutionRecord['value2'] )
{
$answerAgg['count_true']++;
}
else
{
$answerAgg['count_false']++;
}
}
}
$aggregate[] = $answerAgg;
}
return $aggregate;
}

+ Here is the caller graph for this function:

assKprimChoiceGUI::buildEditForm ( )
private
assKprimChoiceGUI::downkprim_answers ( )

Definition at line 77 of file class.assKprimChoiceGUI.php.

References $_POST, and editQuestion().

{
if( isset($_POST['cmd'][__FUNCTION__]) && count($_POST['cmd'][__FUNCTION__]) )
{
$this->object->moveAnswerDown( key($_POST['cmd'][__FUNCTION__]) );
$this->object->saveToDb();
}
$this->editQuestion();
}

+ Here is the call graph for this function:

assKprimChoiceGUI::editQuestion ( ilPropertyFormGUI  $form = null)
protected

Definition at line 44 of file class.assKprimChoiceGUI.php.

References buildEditForm(), and assQuestionGUI\getQuestionTemplate().

Referenced by downkprim_answers(), removeImage(), upkprim_answers(), uploadImage(), and writePostData().

{
if( $form === null )
{
$form = $this->buildEditForm();
}
$this->tpl->addCss('Modules/Test/templates/default/ta.css');
$this->tpl->setVariable("QUESTION_DATA", $this->ctrl->getHTML($form));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assKprimChoiceGUI::getAdditionalEditQuestionCommands ( )
protected

Reimplemented from assQuestionGUI.

Definition at line 39 of file class.assKprimChoiceGUI.php.

{
return array('uploadImage', 'removeImage');
}
assKprimChoiceGUI::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 807 of file class.assKprimChoiceGUI.php.

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

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

References aggregateAnswers(), and renderAggregateView().

{
return $this->renderAggregateView(
$this->aggregateAnswers( $relevant_answers, $this->object->getAnswers() ) )->get();
return '<pre>'.print_r($relevant_answers, 1).'</pre>';
}

+ Here is the call graph for this function:

assKprimChoiceGUI::getParticipantsAnswerKeySequence ( )
protected

Definition at line 726 of file class.assKprimChoiceGUI.php.

References $_GET, and $_SESSION.

Referenced by getPreview(), getSolutionOutput(), and getTestOutput().

{
if( !$this->object->isShuffleAnswersEnabled() )
{
return array_keys($this->object->getAnswers());
}
if (strcmp($_GET["activecommand"], "directfeedback") == 0)
{
if (is_array($_SESSION["choicekeys"])) $this->choiceKeys = $_SESSION["choicekeys"];
}
if (!is_array($this->choiceKeys))
{
$this->choiceKeys = array_keys($this->object->getAnswers());
if ($this->object->getShuffle())
{
$this->choiceKeys = $this->object->pcArrayShuffle($this->choiceKeys);
}
}
$_SESSION["choicekeys"] = $this->choiceKeys;
return $this->choiceKeys;
}

+ Here is the caller graph for this function:

assKprimChoiceGUI::getPreview (   $show_question_only = FALSE,
  $showInlineFeedback = false 
)
Parameters
bool$show_question_only
bool$showInlineFeedback

Reimplemented from assQuestionGUI.

Definition at line 464 of file class.assKprimChoiceGUI.php.

References assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), getParticipantsAnswerKeySequence(), assQuestionGUI\getPreviewSession(), populateSpecificFeedbackInline(), and ilUtil\prepareFormOutput().

{
$user_solution = is_object($this->getPreviewSession()) ? (array)$this->getPreviewSession()->getParticipantsSolution() : array();
// shuffle output
// generate the question output
include_once "./Services/UICore/classes/class.ilTemplate.php";
$template = new ilTemplate("tpl.il_as_qpl_mc_kprim_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
foreach ($keys as $answer_id)
{
$answer = $this->object->getAnswer($answer_id);
if (strlen($answer->getImageFile()))
{
if ($this->object->getThumbSize())
{
$template->setCurrentBlock("preview");
$template->setVariable("URL_PREVIEW", $answer->getImageWebPath());
$template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
$template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.svg'));
$template->setVariable("ANSWER_IMAGE_URL", $answer->getThumbWebPath());
list($width, $height, $type, $attr) = getimagesize($answer->getImageFsPath());
$alt = $answer->getImageFile();
if (strlen($answer->getAnswertext()))
{
$alt = $answer->getAnswertext();
}
$alt = preg_replace("/<[^>]*?>/", "", $alt);
$template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
$template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock("answer_image");
$template->setVariable("ANSWER_IMAGE_URL", $answer->getImageWebPath());
list($width, $height, $type, $attr) = getimagesize($answer->getImageFsPath());
$alt = $answer->getImageFile();
if (strlen($answer->getAnswertext()))
{
$alt = $answer->getAnswertext();
}
$alt = preg_replace("/<[^>]*?>/", "", $alt);
$template->setVariable("ATTR", $attr);
$template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
$template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
$template->parseCurrentBlock();
}
}
if( $showInlineFeedback )
{
$this->populateSpecificFeedbackInline($user_solution, $answer_id, $template);
}
$template->setCurrentBlock("answer_row");
$template->setVariable("ANSWER_ID", $answer_id);
$template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
$template->setVariable('VALUE_TRUE', 1);
$template->setVariable('VALUE_FALSE', 0);
if( isset($user_solution[$answer->getPosition()]) )
{
$tplVar = $user_solution[$answer->getPosition()] ? 'CHECKED_ANSWER_TRUE' : 'CHECKED_ANSWER_FALSE';
$template->setVariable($tplVar, " checked=\"checked\"");
}
$template->parseCurrentBlock();
}
$questiontext = $this->object->getQuestion();
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
$template->setVariable("INSTRUCTIONTEXT", $this->object->getInstructionTextTranslation(
$this->lng, $this->object->getOptionLabel()
));
$template->setVariable("OPTION_LABEL_TRUE", $this->object->getTrueOptionLabelTranslation(
$this->lng, $this->object->getOptionLabel()
));
$template->setVariable("OPTION_LABEL_FALSE", $this->object->getFalseOptionLabelTranslation(
$this->lng, $this->object->getOptionLabel()
));
$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:

assKprimChoiceGUI::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 
)
Parameters
$active_id
null$pass
bool$graphicalOutput
bool$result_output
bool$show_question_only
bool$show_feedback
bool$show_correct_solution
bool$show_manual_scoring
bool$show_question_text

Reimplemented from assQuestionGUI.

Definition at line 569 of file class.assKprimChoiceGUI.php.

References $pass, assQuestionGUI\getGenericFeedbackOutput(), ilUtil\getHtmlPath(), assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), getParticipantsAnswerKeySequence(), populateSpecificFeedbackInline(), and ilUtil\prepareFormOutput().

{
// shuffle output
// 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))
{
$solutions =& $this->object->getSolutionValues($active_id, $pass);
foreach ($solutions as $idx => $solution_value)
{
$user_solution[$solution_value['value1']] = $solution_value['value2'];
}
}
else
{
// take the correct solution instead of the user solution
foreach ($this->object->getAnswers() as $answer)
{
$user_solution[$answer->getPosition()] = $answer->getCorrectness();
}
}
// generate the question output
$template = new ilTemplate("tpl.il_as_qpl_mc_kprim_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool");
foreach ($keys as $answer_id)
{
$answer = $this->object->getAnswer($answer_id);
if (($active_id > 0) && (!$show_correct_solution))
{
if ($graphicalOutput)
{
// output of ok/not ok icons for user entered solutions
if( $user_solution[$answer->getPosition()] == $answer->getCorrectness() )
{
$template->setCurrentBlock("icon_ok");
$template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg"));
$template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock("icon_ok");
$template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.svg"));
$template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
$template->parseCurrentBlock();
}
}
}
if (strlen($answer->getImageFile()))
{
$template->setCurrentBlock("answer_image");
if ($this->object->getThumbSize())
{
$template->setVariable("ANSWER_IMAGE_URL", $answer->getThumbWebPath());
}
else
{
$template->setVariable("ANSWER_IMAGE_URL", $answer->getImageWebPath());
}
$template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($answer->getImageFile()));
$template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($answer->getImageFile()));
$template->parseCurrentBlock();
}
if ($show_feedback)
{
$this->populateSpecificFeedbackInline($user_solution, $answer_id, $template);
}
$template->setCurrentBlock("answer_row");
$template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
if( isset($user_solution[$answer->getPosition()]) )
{
if( $user_solution[$answer->getPosition()] )
{
$template->setVariable("SOLUTION_IMAGE_TRUE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_checked.png")));
$template->setVariable("SOLUTION_ALT_TRUE", $this->lng->txt("checked"));
$template->setVariable("SOLUTION_IMAGE_FALSE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png")));
$template->setVariable("SOLUTION_ALT_FALSE", $this->lng->txt("unchecked"));
}
else
{
$template->setVariable("SOLUTION_IMAGE_TRUE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png")));
$template->setVariable("SOLUTION_ALT_TRUE", $this->lng->txt("unchecked"));
$template->setVariable("SOLUTION_IMAGE_FALSE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_checked.png")));
$template->setVariable("SOLUTION_ALT_FALSE", $this->lng->txt("checked"));
}
}
else
{
$template->setVariable("SOLUTION_IMAGE_TRUE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png")));
$template->setVariable("SOLUTION_ALT_TRUE", $this->lng->txt("unchecked"));
$template->setVariable("SOLUTION_IMAGE_FALSE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png")));
$template->setVariable("SOLUTION_ALT_FALSE", $this->lng->txt("unchecked"));
}
$template->parseCurrentBlock();
}
if ($show_question_text==true)
{
$questiontext = $this->object->getQuestion();
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
$template->setVariable("INSTRUCTIONTEXT", $this->object->getInstructionTextTranslation(
$this->lng, $this->object->getOptionLabel()
));
}
$template->setVariable("OPTION_LABEL_TRUE", $this->object->getTrueOptionLabelTranslation(
$this->lng, $this->object->getOptionLabel()
));
$template->setVariable("OPTION_LABEL_FALSE", $this->object->getFalseOptionLabelTranslation(
$this->lng, $this->object->getOptionLabel()
));
$questionoutput = $template->get();
$feedback = ($show_feedback) ? $this->getGenericFeedbackOutput($active_id, $pass) : "";
$solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html",TRUE, TRUE, "Modules/TestQuestionPool");
if( strlen($feedback) )
{
$solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $feedback , true ));
}
$solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
$solutionoutput = $solutiontemplate->get();
if (!$show_question_only)
{
// get page object output
$solutionoutput = $this->getILIASPage($solutionoutput);
}
return $solutionoutput;
}

+ Here is the call graph for this function:

assKprimChoiceGUI::getSpecificFeedbackOutput (   $active_id,
  $pass 
)
Parameters
integer$active_id
integer$pass
Returns
string

Reimplemented from assQuestionGUI.

Definition at line 333 of file class.assKprimChoiceGUI.php.

{
return ''; // question type supports inline answer specific feedback
}
assKprimChoiceGUI::getTestOutput (   $active_id,
  $pass = NULL,
  $is_postponed = FALSE,
  $use_post_solutions = FALSE,
  $showInlineFeedback = FALSE 
)
Parameters
integer$active_id
integer | null$pass
bool$is_postponed
bool$use_post_solutions
bool$show_feedback
Returns
string

Definition at line 347 of file class.assKprimChoiceGUI.php.

References $pass, ilObjTest\_getPass(), ilObjTest\_getUsePreviousAnswers(), ilUtil\getImagePath(), getParticipantsAnswerKeySequence(), assQuestionGUI\outQuestionPage(), populateSpecificFeedbackInline(), and ilUtil\prepareFormOutput().

{
// shuffle output
// get the solution of the user for the active pass or from the last pass if allowed
$user_solution = array();
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);
}
$solutions =& $this->object->getSolutionValues($active_id, $pass);
foreach ($solutions as $idx => $solution_value)
{
$user_solution[$solution_value["value1"]] = $solution_value["value2"];
}
}
// generate the question output
include_once "./Services/UICore/classes/class.ilTemplate.php";
$template = new ilTemplate("tpl.il_as_qpl_mc_kprim_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
foreach ($keys as $answer_id)
{
$answer = $this->object->getAnswer($answer_id);
if (strlen($answer->getImageFile()))
{
if ($this->object->getThumbSize())
{
$template->setCurrentBlock("preview");
$template->setVariable("URL_PREVIEW", $answer->getImageWebPath());
$template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview'));
$template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.svg'));
$template->setVariable("ANSWER_IMAGE_URL", $answer->getThumbWebPath());
list($width, $height, $type, $attr) = getimagesize($answer->getImageFsPath());
$alt = $answer->getImageFile();
if (strlen($answer->getAnswertext()))
{
$alt = $answer->getAnswertext();
}
$alt = preg_replace("/<[^>]*?>/", "", $alt);
$template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
$template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock("answer_image");
$template->setVariable("ANSWER_IMAGE_URL", $answer->getImageWebPath());
list($width, $height, $type, $attr) = getimagesize($answer->getImageFsPath());
$alt = $answer->getImageFile();
if (strlen($answer->getAnswertext()))
{
$alt = $answer->getAnswertext();
}
$alt = preg_replace("/<[^>]*?>/", "", $alt);
$template->setVariable("ATTR", $attr);
$template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt));
$template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt));
$template->parseCurrentBlock();
}
}
if( $showInlineFeedback )
{
$this->populateSpecificFeedbackInline($user_solution, $answer_id, $template);
}
$template->setCurrentBlock("answer_row");
$template->setVariable("ANSWER_ID", $answer_id);
$template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
$template->setVariable('VALUE_TRUE', 1);
$template->setVariable('VALUE_FALSE', 0);
if( isset($user_solution[$answer->getPosition()]) )
{
$tplVar = $user_solution[$answer->getPosition()] ? 'CHECKED_ANSWER_TRUE' : 'CHECKED_ANSWER_FALSE';
$template->setVariable($tplVar, " checked=\"checked\"");
}
$template->parseCurrentBlock();
}
$questiontext = $this->object->getQuestion();
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
$template->setVariable("INSTRUCTIONTEXT", $this->object->getInstructionTextTranslation(
$this->lng, $this->object->getOptionLabel()
));
$template->setVariable("OPTION_LABEL_TRUE", $this->object->getTrueOptionLabelTranslation(
$this->lng, $this->object->getOptionLabel()
));
$template->setVariable("OPTION_LABEL_FALSE", $this->object->getFalseOptionLabelTranslation(
$this->lng, $this->object->getOptionLabel()
));
$questionoutput = $template->get();
$pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
return $pageoutput;
}

+ Here is the call graph for this function:

assKprimChoiceGUI::handleAnswerTextsSubmit (   $answers)
private

Definition at line 313 of file class.assKprimChoiceGUI.php.

References assKprimChoice\ANSWER_TYPE_MULTI_LINE, and ilUtil\secureString().

Referenced by writeAnswerSpecificPostData().

{
if( $this->object->getAnswerType() == assKprimChoice::ANSWER_TYPE_MULTI_LINE )
{
return $answers;
}
foreach($answers as $key => $answer)
{
$answer->setAnswerText(ilUtil::secureString($answer->getAnswerText()));
}
return $answers;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assKprimChoiceGUI::populateAnswerSpecificFormPart ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form
Returns
ilPropertyFormGUI

Implements ilGuiAnswerScoringAdjustable.

Definition at line 276 of file class.assKprimChoiceGUI.php.

References ilPropertyFormGUI\addItem(), and ilFormPropertyGUI\setInfo().

Referenced by buildEditForm().

{
require_once 'Modules/TestQuestionPool/classes/class.ilKprimChoiceWizardInputGUI.php';
$kprimAnswers = new ilKprimChoiceWizardInputGUI($this->lng->txt('answers'), 'kprim_answers');
$kprimAnswers->setInfo($this->lng->txt('kprim_answers_info'));
$kprimAnswers->setSize(64);
$kprimAnswers->setMaxLength(1000);
$kprimAnswers->setRequired(true);
$kprimAnswers->setAllowMove(true);
$kprimAnswers->setQuestionObject($this->object);
if( !$this->object->getSelfAssessmentEditingMode() )
{
$kprimAnswers->setSingleline($this->object->isSingleLineAnswerType($this->object->getAnswerType()));
}
else
{
$kprimAnswers->setSingleline(false);
}
$kprimAnswers->setValues($this->object->getAnswers());
$form->addItem($kprimAnswers);
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assKprimChoiceGUI::populateQuestionSpecificFormPart ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form
Returns
ilPropertyFormGUI

Implements ilGuiQuestionScoringAdjustable.

Definition at line 157 of file class.assKprimChoiceGUI.php.

References ilPropertyFormGUI\addItem(), ilCheckboxInputGUI\setChecked(), ilFormPropertyGUI\setInfo(), ilSelectInputGUI\setOptions(), ilFormPropertyGUI\setRequired(), ilNumberInputGUI\setSuffix(), and ilTextInputGUI\setValue().

Referenced by buildEditForm().

{
// shuffle answers
$shuffleAnswers = new ilCheckboxInputGUI($this->lng->txt( "shuffle_answers" ), "shuffle_answers_enabled");
$shuffleAnswers->setChecked( $this->object->isShuffleAnswersEnabled() );
$form->addItem($shuffleAnswers);
if( !$this->object->getSelfAssessmentEditingMode() )
{
// answer mode (single-/multi-line)
$answerType = new ilSelectInputGUI($this->lng->txt('answer_types'), 'answer_type');
$answerType->setOptions($this->object->getAnswerTypeSelectOptions($this->lng));
$answerType->setValue( $this->object->getAnswerType() );
$form->addItem($answerType);
}
if( !$this->object->getSelfAssessmentEditingMode() && $this->object->isSingleLineAnswerType($this->object->getAnswerType()) )
{
// thumb size
$thumbSize = new ilNumberInputGUI($this->lng->txt('thumb_size'), 'thumb_size');
$thumbSize->setSuffix($this->lng->txt("thumb_size_unit_pixel"));
$thumbSize->setInfo( $this->lng->txt('thumb_size_info') );
$thumbSize->setDecimals(false);
$thumbSize->setMinValue(20);
$thumbSize->setSize(6);
$thumbSize->setValue( $this->object->getThumbSize() );
$form->addItem($thumbSize);
}
// option label
$optionLabel = new ilRadioGroupInputGUI($this->lng->txt('option_label'), 'option_label');
$optionLabel->setInfo($this->lng->txt('option_label_info'));
$optionLabel->setRequired(true);
$optionLabel->setValue($this->object->getOptionLabel());
foreach($this->object->getValidOptionLabelsTranslated($this->lng) as $labelValue => $labelText)
{
$option = new ilRadioOption($labelText, $labelValue);
$optionLabel->addOption($option);
if( $this->object->isCustomOptionLabel($labelValue) )
{
$customLabelTrue = new ilTextInputGUI(
$this->lng->txt('option_label_custom_true'), 'option_label_custom_true'
);
$customLabelTrue->setValue($this->object->getCustomTrueOptionLabel());
$option->addSubItem($customLabelTrue);
$customLabelFalse = new ilTextInputGUI(
$this->lng->txt('option_label_custom_false'), 'option_label_custom_false'
);
$customLabelFalse->setValue($this->object->getCustomFalseOptionLabel());
$option->addSubItem($customLabelFalse);
}
}
$form->addItem($optionLabel);
// points
$points = new ilNumberInputGUI($this->lng->txt('points'), 'points');
$points->setRequired(true);
$points->setSize(3);
$points->allowDecimals(true);
$points->setMinValue(0);
$points->setMinvalueShouldBeGreater(true);
$points->setValue($this->object->getPoints());
$form->addItem($points);
// score partial solution
$scorePartialSolution = new ilCheckboxInputGUI($this->lng->txt('score_partsol_enabled'), 'score_partsol_enabled');
$scorePartialSolution->setInfo($this->lng->txt('score_partsol_enabled_info'));
$scorePartialSolution->setChecked( $this->object->isScorePartialSolutionEnabled() );
$form->addItem($scorePartialSolution);
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assKprimChoiceGUI::populateSpecificFeedbackInline (   $user_solution,
  $answer_id,
  $template 
)
private

Definition at line 749 of file class.assKprimChoiceGUI.php.

References ilAssConfigurableMultiOptionQuestionFeedback\FEEDBACK_SETTING_ALL, ilAssConfigurableMultiOptionQuestionFeedback\FEEDBACK_SETTING_CHECKED, and ilAssConfigurableMultiOptionQuestionFeedback\FEEDBACK_SETTING_CORRECT.

Referenced by getPreview(), getSolutionOutput(), and getTestOutput().

{
require_once 'Modules/TestQuestionPool/classes/feedback/class.ilAssConfigurableMultiOptionQuestionFeedback.php';
if($this->object->getSpecificFeedbackSetting() == ilAssConfigurableMultiOptionQuestionFeedback::FEEDBACK_SETTING_CHECKED)
{
foreach($user_solution as $mc_solution)
{
if(strcmp($mc_solution, $answer_id) == 0)
{
$fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), $answer_id);
if(strlen($fb))
{
$template->setCurrentBlock("feedback");
$template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
$template->parseCurrentBlock();
}
}
}
}
if($this->object->getSpecificFeedbackSetting() == ilAssConfigurableMultiOptionQuestionFeedback::FEEDBACK_SETTING_ALL)
{
$fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), $answer_id);
if(strlen($fb))
{
$template->setCurrentBlock("feedback");
$template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
$template->parseCurrentBlock();
}
}
if($this->object->getSpecificFeedbackSetting() == ilAssConfigurableMultiOptionQuestionFeedback::FEEDBACK_SETTING_CORRECT)
{
$answer = $this->object->getAnswer($answer_id);
if($answer->getCorrectness())
{
$fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), $answer_id);
if(strlen($fb))
{
$template->setCurrentBlock("feedback");
$template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true));
$template->parseCurrentBlock();
}
}
}
}

+ Here is the caller graph for this function:

assKprimChoiceGUI::removeImage ( )

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

References $_POST, and editQuestion().

{
$position = key($_POST['cmd']['removeImage']);
$this->object->removeAnswerImage($position);
$this->object->saveToDb();
$this->editQuestion();
}

+ Here is the call graph for this function:

assKprimChoiceGUI::renderAggregateView (   $aggregate)

Definition at line 842 of file class.assKprimChoiceGUI.php.

References assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

{
$trueOptionLabel = $this->object->getTrueOptionLabelTranslation($this->lng, $this->object->getOptionLabel());
$falseOptionLabel = $this->object->getFalseOptionLabelTranslation($this->lng, $this->object->getOptionLabel());
$tpl = new ilTemplate('tpl.il_as_aggregated_kprim_answers_table.html', true, true, "Modules/TestQuestionPool");
foreach( $aggregate as $lineData )
{
$tpl->setCurrentBlock('aggregaterow');
$tpl->setVariable('OPTION', $lineData['answertext']);
$tpl->setVariable('COUNT_TRUE', $lineData['count_true']);
$tpl->setVariable('COUNT_FALSE', $lineData['count_false']);
$tpl->parseCurrentBlock();
}
$tpl->setVariable('OPTION_HEAD', $this->lng->txt('answers'));
$tpl->setVariable('COUNT_TRUE_HEAD', $trueOptionLabel);
$tpl->setVariable('COUNT_FALSE_HEAD', $falseOptionLabel);
return $tpl;
}

+ Here is the caller graph for this function:

assKprimChoiceGUI::upkprim_answers ( )

Definition at line 88 of file class.assKprimChoiceGUI.php.

References $_POST, and editQuestion().

{
if( isset($_POST['cmd'][__FUNCTION__]) && count($_POST['cmd'][__FUNCTION__]) )
{
$this->object->moveAnswerUp( key($_POST['cmd'][__FUNCTION__]) );
$this->object->saveToDb();
}
$this->editQuestion();
}

+ Here is the call graph for this function:

assKprimChoiceGUI::uploadImage ( )
protected

Definition at line 57 of file class.assKprimChoiceGUI.php.

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

{
$result = $this->writePostData(true);
if( $result == 0 )
{
$this->object->saveToDb();
$this->editQuestion();
}
}

+ Here is the call graph for this function:

assKprimChoiceGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form

Implements ilGuiAnswerScoringAdjustable.

Definition at line 303 of file class.assKprimChoiceGUI.php.

References ilPropertyFormGUI\getItemByPostVar(), and handleAnswerTextsSubmit().

Referenced by writePostData().

{
$answers = $form->getItemByPostVar('kprim_answers')->getValues();
$answers = $this->handleAnswerTextsSubmit($answers);
$files = $form->getItemByPostVar('kprim_answers')->getFiles();
$this->object->handleFileUploads($answers, $files);
$this->object->setAnswers($answers);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assKprimChoiceGUI::writePostData (   $upload = false)
protected

Definition at line 99 of file class.assKprimChoiceGUI.php.

References $_POST, buildEditForm(), editQuestion(), assQuestionGUI\saveTaxonomyAssignments(), ilUtil\sendFailure(), writeAnswerSpecificPostData(), assQuestionGUI\writeQuestionGenericPostData(), and writeQuestionSpecificPostData().

{
$form = $this->buildEditForm();
$form->setValuesByPost();
if( $upload )
{
$answersInput = $form->getItemByPostVar('kprim_answers');
$answersInput->setIgnoreMissingUploadsEnabled(true);
if( !$answersInput->checkUploads($_POST[$answersInput->getPostVar()]) )
{
ilUtil::sendFailure($this->lng->txt("form_input_not_valid"));
$this->editQuestion($form);
return 1;
}
$answersInput->collectValidFiles();
}
elseif( !$form->checkInput() )
{
$this->editQuestion($form);
return 1;
}
return 0;
}

+ Here is the call graph for this function:

assKprimChoiceGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form

Implements ilGuiQuestionScoringAdjustable.

Definition at line 235 of file class.assKprimChoiceGUI.php.

References assKprimChoice\ANSWER_TYPE_MULTI_LINE, and ilPropertyFormGUI\getItemByPostVar().

Referenced by writePostData().

{
$oldAnswerType = $this->object->getAnswerType();
$this->object->setShuffleAnswersEnabled($form->getItemByPostVar('shuffle_answers_enabled')->getChecked());
if( !$this->object->getSelfAssessmentEditingMode() )
{
$this->object->setAnswerType($form->getItemByPostVar('answer_type')->getValue());
}
else
{
$this->object->setAnswerType(assKprimChoice::ANSWER_TYPE_MULTI_LINE);
}
if( !$this->object->getSelfAssessmentEditingMode() && $this->object->isSingleLineAnswerType($oldAnswerType) )
{
$this->object->setThumbSize($form->getItemByPostVar('thumb_size')->getValue());
}
$this->object->setOptionLabel($form->getItemByPostVar('option_label')->getValue());
if( $this->object->isCustomOptionLabel($this->object->getOptionLabel()) )
{
$this->object->setCustomTrueOptionLabel( strip_tags(
$form->getItemByPostVar('option_label_custom_true')->getValue()
));
$this->object->setCustomFalseOptionLabel( strip_tags(
$form->getItemByPostVar('option_label_custom_false')->getValue()
));
}
$this->object->setPoints($form->getItemByPostVar('points')->getValue());
$this->object->setScorePartialSolutionEnabled($form->getItemByPostVar('score_partsol_enabled')->getChecked());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

assKprimChoiceGUI::$object

Definition at line 21 of file class.assKprimChoiceGUI.php.


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