4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
5 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
6 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiAnswerScoringAdjustable.php';
7 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
34 parent::__construct();
35 require_once
'./Modules/TestQuestionPool/classes/class.assTextSubset.php';
39 $this->
object->loadFromDb($id);
52 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
55 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
73 require_once
'./Services/Form/classes/class.ilPropertyFormGUI.php';
75 $form->setFormAction($this->ctrl->getFormAction($this));
77 $form->setMultipart(FALSE);
78 $form->setTableWidth(
"100%");
79 $form->setId(
"asstextsubset");
90 $form->setValuesByPost();
91 $points = $form->getItemByPostVar(
'points');
92 $points->setValue($this->object->getMaximumPoints());
94 $form->setValuesByPost();
95 if (
$errors) $checkonly =
false;
98 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
108 $position = key(
$_POST[
'cmd'][
'addanswers']);
109 $this->
object->addAnswer(
"", 0, $position+1);
119 $position = key(
$_POST[
'cmd'][
'removeanswers']);
120 $this->
object->deleteAnswer($position);
140 $graphicalOutput = FALSE,
141 $result_output = FALSE,
142 $show_question_only = TRUE,
143 $show_feedback = FALSE,
144 $show_correct_solution = FALSE,
145 $show_manual_scoring = FALSE,
146 $show_question_text = TRUE
150 $solutions = array();
151 if (($active_id > 0) && (!$show_correct_solution))
153 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
158 foreach ($this->object->answers as $answer)
160 if ($answer->getPoints() > 0)
162 if (!is_array($rank[$answer->getPoints()]))
164 $rank[$answer->getPoints()] = array();
166 array_push($rank[$answer->getPoints()], $answer->getAnswertext());
169 krsort($rank, SORT_NUMERIC);
170 foreach ($rank as $index => $bestsolutions)
172 array_push($solutions, array(
"value1" => join(
",", $bestsolutions),
"points" => $index));
177 include_once
"./Services/UICore/classes/class.ilTemplate.php";
178 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
179 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
180 $available_answers =& $this->
object->getAvailableAnswers();
181 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
183 if ((!$test_id) && (strcmp($solutions[$i][
"value1"],
"") == 0))
188 if (($active_id > 0) && (!$show_correct_solution))
190 if ($graphicalOutput)
193 $index = $this->
object->isAnswerCorrect($available_answers, $solutions[$i][
"value1"]);
195 if ($index !== FALSE)
197 unset($available_answers[$index]);
202 $template->setCurrentBlock(
"icon_ok");
204 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
205 $template->parseCurrentBlock();
209 $template->setCurrentBlock(
"icon_ok");
211 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
212 $template->parseCurrentBlock();
216 $template->setCurrentBlock(
"textsubset_row");
217 $template->setVariable(
"SOLUTION", $solutions[$i][
"value1"]);
218 $template->setVariable(
"COUNTER", $i+1);
221 $points = $solutions[$i][
"points"];
222 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
223 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
225 $template->parseCurrentBlock();
228 $questiontext = $this->
object->getQuestion();
229 if ($show_question_text==
true)
231 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
233 $questionoutput = $template->get();
235 if (strlen($feedback))
241 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
242 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
244 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
246 $solutionoutput = $solutiontemplate->get();
247 if (!$show_question_only)
252 return $solutionoutput;
255 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
259 include_once
"./Services/UICore/classes/class.ilTemplate.php";
260 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
261 $width = $this->
object->getMaxTextboxWidth();
262 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
264 $template->setCurrentBlock(
"textsubset_row");
265 foreach ($solutions as $idx => $solution_value)
269 $template->setVariable(
"TEXTFIELD_VALUE",
" value=\"" . $solution_value.
"\"");
272 $template->setVariable(
"COUNTER", $i+1);
273 $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d", $i+1));
274 $template->setVariable(
"TEXTFIELD_SIZE", $width);
275 $template->parseCurrentBlock();
277 $questiontext = $this->
object->getQuestion();
278 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
279 $questionoutput = $template->get();
280 if (!$show_question_only)
285 return $questionoutput;
288 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $inlineFeedback =
false)
296 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 297 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 299 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 302 $solutions = $this->
object->getUserSolutionPreferingIntermediate($active_id,
$pass);
306 include_once
"./Services/UICore/classes/class.ilTemplate.php";
307 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
308 $width = $this->
object->getMaxTextboxWidth();
309 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
311 $template->setCurrentBlock(
"textsubset_row");
312 foreach ($solutions as $idx => $solution_value)
319 $template->setVariable(
"COUNTER", $i+1);
320 $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d", $i+1));
321 $template->setVariable(
"TEXTFIELD_SIZE", $width);
322 $template->parseCurrentBlock();
324 $questiontext = $this->
object->getQuestion();
325 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
326 $questionoutput = $template->get();
327 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
340 global $rbacsystem, $ilTabs;
342 $ilTabs->clearTargets();
344 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
345 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
346 $q_type = $this->
object->getQuestionType();
350 $classname = $q_type .
"GUI";
351 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
352 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
357 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
360 $ilTabs->addTarget(
"edit_page",
361 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
362 array(
"edit",
"insert",
"exec_pg"),
363 "",
"", $force_active);
369 $force_active =
false;
370 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
373 if ($classname)
$url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
375 $ilTabs->addTarget(
"edit_question",
377 array(
"editQuestion",
"save",
"saveEdit",
"addanswers",
"removeanswers",
"originalSyncForm"),
378 $classname,
"", $force_active);
393 $ilTabs->addTarget(
"statistics",
394 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
405 return $this->
object->prepareTextareaOutput($output, TRUE);
410 $this->
object->setCorrectAnswers(
$_POST[
"correctanswers"] );
411 $this->
object->setTextRating(
$_POST[
"text_rating"] );
417 $this->
object->flushAnswers();
418 foreach (
$_POST[
'answers'][
'answer'] as $index => $answer)
420 $answertext = $answer;
421 $this->
object->addAnswer( $answertext,
$_POST[
'answers'][
'points'][$index], $index );
428 $correctanswers =
new ilNumberInputGUI($this->lng->txt(
"nr_of_correct_answers" ),
"correctanswers");
430 $correctanswers->setDecimals( 0 );
431 $correctanswers->setSize( 3 );
432 $correctanswers->setValue( $this->object->getCorrectAnswers() );
433 $correctanswers->setRequired(
true );
434 $form->
addItem( $correctanswers );
437 $points =
new ilNumberInputGUI($this->lng->txt(
"maximum_points" ),
"points");
439 $points->setMinvalueShouldBeGreater(
true);
440 $points->setSize( 6 );
441 $points->setDisabled(
true );
442 $points->allowDecimals(
true);
443 $points->setValue( $this->object->getMaximumPoints() );
444 $points->setRequired(
false );
448 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating" ),
"text_rating");
449 $text_options = array(
450 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive" ),
451 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive" )
453 if (!$this->object->getSelfAssessmentEditingMode())
455 $text_options[
"l1"] = sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"1" );
456 $text_options[
"l2"] = sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"2" );
457 $text_options[
"l3"] = sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"3" );
458 $text_options[
"l4"] = sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"4" );
459 $text_options[
"l5"] = sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"5" );
462 $textrating->setValue( $this->object->getTextRating() );
470 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
473 $choices->setQuestionObject( $this->
object );
474 $choices->setSingleline(
true );
475 $choices->setAllowMove(
false );
476 $choices->setMinValue(0.0);
477 if ($this->object->getAnswerCount() == 0)
478 $this->object->addAnswer(
"", 0, 0 );
479 $choices->setValues( $this->object->getAnswers() );
529 $aggregate = array();
531 foreach ($relevant_answers_chosen as $relevant_answer)
533 if ( array_key_exists($relevant_answer[
'value1'], $aggregate) )
535 $aggregate[$relevant_answer[
'value1']]++;
539 $aggregate[$relevant_answer[
'value1']] = 1;
552 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
554 foreach ($aggregate as $key => $value)
556 $tpl->setCurrentBlock(
'aggregaterow' );
557 $tpl->setVariable(
'OPTION', $key );
558 $tpl->setVariable(
'COUNT', $value );
559 $tpl->parseCurrentBlock();
isTestPresentationContext()
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
writePostData()
Evaluates a posted edit form and writes the form data in the question object.
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
getPreview($show_question_only=FALSE, $showInlineFeedback=false)
getTestOutput($active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE, $inlineFeedback=false)
getSpecificFeedbackOutput($active_id, $pass)
Class for TextSubset questions.
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
removeanswers()
Remove an answer.
writeQuestionGenericPostData()
getILIASPage($html="")
Returns the ILIAS Page around a question.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
renderAggregateView($aggregate)
special template class to simplify handling of ITX/PEAR
writePostData($always=false)
Evaluates a posted edit form and writes the form data in the question object.
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
const CSS_CLASS_FEEDBACK_WRONG
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.
Basic GUI class for assessment questions.
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
getAnswerFeedbackOutput($active_id, $pass)
Returns the answer generic feedback depending on the results of the question.
saveTaxonomyAssignments()
Multiple choice question GUI representation.
addBackTab(ilTabsGUI $ilTabs)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
Interface ilGuiAnswerScoringAdjustable.
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
Interface ilGuiQuestionScoringAdjustable.
__construct($id=-1)
assTextSubsetGUI constructor
setQuestionTabs()
Sets the ILIAS tabs for this question type.
aggregateAnswers($relevant_answers_chosen)
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
addanswers()
Add a new answer.
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.