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';
8 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
37 include_once
"./Modules/TestQuestionPool/classes/class.assErrorText.php";
41 $this->
object->loadFromDb($id);
50 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
52 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
64 if (is_array(
$_POST[
'errordata'][
'key'])) {
65 $this->
object->flushErrorData();
66 foreach (
$_POST[
'errordata'][
'key'] as $idx => $val) {
67 $this->
object->addErrorData(
69 $_POST[
'errordata'][
'value'][$idx],
70 $_POST[
'errordata'][
'points'][$idx]
78 $questiontext =
$_POST[
"question"];
79 $this->
object->setQuestion($questiontext);
80 $this->
object->setErrorText(
$_POST[
"errortext"]);
81 $points_wrong = str_replace(
",",
".",
$_POST[
"points_wrong"]);
82 if (strlen($points_wrong) == 0) {
85 $this->
object->setPointsWrong($points_wrong);
87 if (!$this->object->getSelfAssessmentEditingMode()) {
88 $this->
object->setTextSize(
$_POST[
"textsize"]);
102 $tabs = $DIC[
'ilTabs'];
103 $tabs->setTabActive(
'edit_question');
107 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
109 $this->editForm = $form;
111 $form->setFormAction($this->ctrl->getFormAction($this));
113 $form->setMultipart(
false);
114 $form->setTableWidth(
"100%");
115 $form->setId(
"orderinghorizontal");
121 if (count($this->object->getErrorData()) || $checkonly) {
127 $form->addCommandButton(
"analyze", $this->lng->txt(
'analyze_errortext'));
133 $form->setValuesByPost();
134 $errors = !$form->checkInput();
135 $form->setValuesByPost();
142 $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
154 $header->setTitle($this->lng->txt(
"errors_section"));
157 include_once
"./Modules/TestQuestionPool/classes/class.ilErrorTextWizardInputGUI.php";
159 $errordata->
setKeyName($this->lng->txt(
'text_wrong'));
160 $errordata->setValueName($this->lng->txt(
'text_correct'));
161 $errordata->setValues($this->object->getErrorData());
165 $points_wrong =
new ilNumberInputGUI($this->lng->txt(
"points_wrong"),
"points_wrong");
167 $points_wrong->setMaxValue(0);
168 $points_wrong->setMaxvalueShouldBeLess(
true);
169 $points_wrong->setValue($this->object->getPointsWrong());
170 $points_wrong->setInfo($this->lng->txt(
"points_wrong_info"));
171 $points_wrong->setSize(6);
172 $points_wrong->setRequired(
true);
185 $errortext->
setValue($this->object->getErrorText());
186 $errortext->setRequired(
true);
187 $errortext->setInfo($this->lng->txt(
"errortext_info"));
188 $errortext->setRows(10);
189 $errortext->setCols(80);
192 if (!$this->object->getSelfAssessmentEditingMode()) {
195 $textsize->
setValue(strlen($this->object->getTextSize()) ? $this->object->getTextSize() : 100.0);
196 $textsize->setInfo($this->lng->txt(
"textsize_errortext_info"));
197 $textsize->setSize(6);
198 $textsize->setSuffix(
"%");
199 $textsize->setMinValue(10);
200 $textsize->setRequired(
true);
211 $this->
object->setErrorData($this->object->getErrorsFromText(
$_POST[
'errortext']));
246 $graphicalOutput =
false,
247 $result_output =
false,
248 $show_question_only =
true,
249 $show_feedback =
false,
250 $show_correct_solution =
false,
251 $show_manual_scoring =
false,
252 $show_question_text =
true 255 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
257 $selections = array();
258 if (($active_id > 0) && (!$show_correct_solution)) {
261 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
263 if (is_array($solutions)) {
264 foreach ($solutions as $solution) {
265 array_push($selections, (
int) $solution[
'value1']);
267 $errortext_value = join(
",", $selections);
270 $selections = $this->
object->getBestSelection();
271 $reached_points = $this->
object->getPoints();
274 if ($result_output) {
275 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
276 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
279 if ($this->object->getTextSize() >= 10) {
280 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
283 if ($show_question_text ==
true) {
284 $template->setVariable(
"QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
287 $errortext = $this->
object->createErrorTextOutput($selections, $graphicalOutput, $show_correct_solution,
false);
289 $template->setVariable(
"ERRORTEXT", $errortext);
290 $questionoutput = $template->get();
292 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
295 if ($show_feedback) {
298 $feedback .= strlen($fb) ? $fb :
'';
302 $feedback .= strlen($fb) ? $fb :
'';
304 if (strlen($feedback)) {
310 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
311 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
314 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
316 $solutionoutput = $solutiontemplate->get();
317 if (!$show_question_only) {
321 return $solutionoutput;
324 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
328 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output.html",
true,
true,
"Modules/TestQuestionPool");
329 if ($this->object->getTextSize() >= 10) {
330 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
332 $template->setVariable(
"QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
333 $errortext = $this->
object->createErrorTextOutput($selections);
334 $template->setVariable(
"ERRORTEXT", $errortext);
335 $template->setVariable(
"ERRORTEXT_ID",
"qst_" . $this->object->getId());
336 $questionoutput = $template->get();
337 if (!$show_question_only) {
341 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/errortext.js");
342 return $questionoutput;
350 $is_postponed =
false,
351 $use_post_solutions =
false,
352 $show_feedback =
false 355 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output.html",
true,
true,
"Modules/TestQuestionPool");
359 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 360 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 362 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 364 $solutions = $this->
object->getTestOutputSolutions($active_id,
$pass);
367 $errortext_value =
"";
368 $selections = array();
369 if (is_array($solutions)) {
370 foreach ($solutions as $solution) {
371 array_push($selections, $solution[
'value1']);
373 $errortext_value = join(
",", $selections);
375 if ($this->object->getTextSize() >= 10) {
376 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
378 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
379 $errortext = $this->
object->createErrorTextOutput($selections);
381 $template->setVariable(
"ERRORTEXT", $errortext);
382 $template->setVariable(
"ERRORTEXT_ID",
"qst_" . $this->object->getId());
383 $template->setVariable(
"ERRORTEXT_VALUE", $errortext_value);
385 $questionoutput = $template->get();
386 if (!$show_question_only) {
390 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/errortext.js");
391 $questionoutput = $template->get();
392 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
398 $selection = $this->
object->getBestSelection(
false);
400 if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
404 $feedback =
'<table class="test_specific_feedback"><tbody>';
407 foreach (preg_split(
"/[\n\r]+/", $this->object->errortext) as $line) {
408 $elements = array_merge($elements, preg_split(
"/\s+/", $line));
411 $matchedIndexes = array();
414 foreach ($selection as
$index => $answer) {
416 foreach ($answer as $answerPartIndex) {
417 $element[] = $elements[$answerPartIndex];
420 $element = implode(
' ', $element);
421 $element = str_replace(array(
'((',
'))',
'#'), array(
'',
'',
''), $element);
427 $feedback .=
'<td class="text-nowrap">' . $ordinal .
'. ' . $element .
':</td>';
429 foreach ($this->object->getErrorData() as $idx => $ans) {
430 if (isset($matchedIndexes[$idx])) {
434 if (preg_match(
'/' . preg_quote($ans->text_wrong,
'/') .
'/', $element)) {
435 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
436 $this->object->getId(),
441 $feedback .=
'<td>' . $fb .
'</td>';
443 $matchedIndexes[$idx] = $idx;
449 $feedback .=
'</tr>';
452 $feedback .=
'</tbody></table>';
454 return $this->
object->prepareTextareaOutput($feedback,
true);
495 $errortext = $this->
object->getErrorText();
498 foreach ($relevant_answers as $answer_chosen) {
499 $passdata[$answer_chosen[
'active_fi'] .
'-' . $answer_chosen[
'pass']][$answer_chosen[
'value2']][] = $answer_chosen[
'value1'];
503 foreach ($passdata as $key =>
$pass) {
504 $passdata[$key] = $this->
object->createErrorTextOutput(
$pass);
505 $html .= $passdata[$key] .
'<hr /><br />';
513 $answersByActiveAndPass = array();
515 foreach ($relevantAnswers as $row) {
516 $key = $row[
'active_fi'] .
':' . $row[
'pass'];
518 if (!isset($answersByActiveAndPass[$key])) {
519 $answersByActiveAndPass[$key] = array();
522 if (!isset($answersByActiveAndPass[$key][$row[
'value2']])) {
523 $answersByActiveAndPass[$key][$row[
'value2']] = array();
526 $answersByActiveAndPass[$key][$row[
'value2']][] = $row[
'value1'];
531 foreach ($answersByActiveAndPass as $ans) {
532 $errorText = $this->
object->createErrorTextOutput($ans);
533 $errorMd5 = md5($errorText);
535 if (!isset($answers[$errorMd5])) {
536 $answers[$errorMd5] = array(
537 'answer' => $errorText,
'frequency' => 0
541 $answers[$errorMd5][
'frequency']++;
544 return array_values($answers);
550 include_once
"./Modules/TestQuestionPool/classes/forms/class.ilAssErrorTextCorrectionsInputGUI.php";
552 $errordata->
setKeyName($this->lng->txt(
'text_wrong'));
553 $errordata->setValueName($this->lng->txt(
'text_correct'));
554 $errordata->setValues($this->object->getErrorData());
558 $points_wrong =
new ilNumberInputGUI($this->lng->txt(
"points_wrong"),
"points_wrong");
560 $points_wrong->setMaxValue(0);
561 $points_wrong->setMaxvalueShouldBeLess(
true);
562 $points_wrong->setValue($this->object->getPointsWrong());
563 $points_wrong->setInfo($this->lng->txt(
"points_wrong_info"));
564 $points_wrong->setSize(6);
565 $points_wrong->setRequired(
true);
576 $this->
object->flushErrorData();
577 foreach ($form->
getItemByPostVar(
'errordata')->getValues() as $idx => $errAnswer) {
578 $this->
object->addErrorData(
579 $errAnswer->text_wrong,
580 $errAnswer->text_correct,
585 $this->
object->setPointsWrong((
float) $form->
getInput(
'points_wrong'));
isTestPresentationContext()
hasCorrectSolution($activeId, $passIndex)
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
getAnswersFrequency($relevantAnswers, $questionIndex)
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
setValue($a_value)
Set Value.
supportsIntermediateSolutionOutput()
Question type specific support of intermediate solution output The function getSolutionOutput respect...
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
writePostData($always=false)
{}
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
__construct($id=-1)
assErrorTextGUI constructor
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
populateTaxonomyFormSection(ilPropertyFormGUI $form)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
getSpecificFeedbackOutput($userSolution)
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
getTestOutput( $active_id, $pass, $is_postponed=false, $use_post_solutions=false, $show_feedback=false)
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
setKeyName($a_name)
Set key name.
writeQuestionGenericPostData()
getILIASPage($html="")
Returns the ILIAS Page around a question.
Class for error text questions.
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
getPreview($show_question_only=false, $showInlineFeedback=false)
const CSS_CLASS_FEEDBACK_WRONG
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
The assErrorTextGUI class encapsulates the GUI representation for error text questions.
Basic GUI class for assessment questions.
setErrorMessage($errormessage)
analyze()
Parse the error text.
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.
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
saveTaxonomyAssignments()
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
This class represents a key value pair wizard property in a property form.
Interface ilGuiAnswerScoringAdjustable.
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
Interface ilGuiQuestionScoringAdjustable.
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.