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';
35 parent::__construct();
36 require_once
'./Modules/TestQuestionPool/classes/class.assTextSubset.php';
40 $this->
object->loadFromDb($id);
49 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
52 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
70 require_once
'./Services/Form/classes/class.ilPropertyFormGUI.php';
72 $this->editForm = $form;
74 $form->setFormAction($this->ctrl->getFormAction($this));
76 $form->setMultipart(FALSE);
77 $form->setTableWidth(
"100%");
78 $form->setId(
"asstextsubset");
89 $form->setValuesByPost();
90 $points = $form->getItemByPostVar(
'points');
91 $points->setValue($this->
object->getMaximumPoints());
93 $form->setValuesByPost();
94 if (
$errors) $checkonly =
false;
97 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
107 $position = key(
$_POST[
'cmd'][
'addanswers']);
108 $this->
object->addAnswer(
"", 0, $position+1);
118 $position = key(
$_POST[
'cmd'][
'removeanswers']);
119 $this->
object->deleteAnswer($position);
139 $graphicalOutput = FALSE,
140 $result_output = FALSE,
141 $show_question_only = TRUE,
142 $show_feedback = FALSE,
143 $show_correct_solution = FALSE,
144 $show_manual_scoring = FALSE,
145 $show_question_text = TRUE
149 $solutions =
array();
150 if (($active_id > 0) && (!$show_correct_solution))
152 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
157 foreach ($this->
object->answers as $answer)
159 if ($answer->getPoints() > 0)
161 if (!is_array($rank[$answer->getPoints()]))
163 $rank[$answer->getPoints()] =
array();
165 array_push($rank[$answer->getPoints()], $answer->getAnswertext());
168 krsort($rank, SORT_NUMERIC);
169 foreach ($rank as $index => $bestsolutions)
171 array_push($solutions,
array(
"value1" => join(
",", $bestsolutions),
"points" => $index));
176 include_once
"./Services/UICore/classes/class.ilTemplate.php";
177 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
178 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
179 $available_answers =& $this->
object->getAvailableAnswers();
180 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
182 if ((!$test_id) && (strcmp($solutions[$i][
"value1"],
"") == 0))
187 if (($active_id > 0) && (!$show_correct_solution))
189 if ($graphicalOutput)
192 $index = $this->
object->isAnswerCorrect($available_answers, $solutions[$i][
"value1"]);
194 if ($index !== FALSE)
196 unset($available_answers[$index]);
201 $template->setCurrentBlock(
"icon_ok");
203 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
204 $template->parseCurrentBlock();
208 $template->setCurrentBlock(
"icon_ok");
210 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
211 $template->parseCurrentBlock();
215 $template->setCurrentBlock(
"textsubset_row");
216 $template->setVariable(
"SOLUTION", $solutions[$i][
"value1"]);
217 $template->setVariable(
"COUNTER", $i+1);
220 $points = $solutions[$i][
"points"];
221 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
222 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
224 $template->parseCurrentBlock();
227 $questiontext = $this->
object->getQuestion();
228 if ($show_question_text==
true)
230 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext, TRUE));
232 $questionoutput = $template->get();
234 if (strlen($feedback))
240 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
241 $solutiontemplate->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput( $feedback,
true ));
243 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
245 $solutionoutput = $solutiontemplate->get();
246 if (!$show_question_only)
251 return $solutionoutput;
254 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
258 include_once
"./Services/UICore/classes/class.ilTemplate.php";
259 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
260 $width = $this->
object->getMaxTextboxWidth();
261 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
263 $template->setCurrentBlock(
"textsubset_row");
264 foreach ($solutions as $idx => $solution_value)
268 $template->setVariable(
"TEXTFIELD_VALUE",
" value=\"" . $solution_value.
"\"");
271 $template->setVariable(
"COUNTER", $i+1);
272 $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d", $i+1));
273 $template->setVariable(
"TEXTFIELD_SIZE", $width);
274 $template->parseCurrentBlock();
276 $questiontext = $this->
object->getQuestion();
277 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext, TRUE));
278 $questionoutput = $template->get();
279 if (!$show_question_only)
284 return $questionoutput;
287 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $inlineFeedback =
false)
295 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 296 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 298 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 301 $solutions = $this->
object->getUserSolutionPreferingIntermediate($active_id,
$pass);
305 include_once
"./Services/UICore/classes/class.ilTemplate.php";
306 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
307 $width = $this->
object->getMaxTextboxWidth();
308 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
310 $template->setCurrentBlock(
"textsubset_row");
311 foreach ($solutions as $idx => $solution_value)
318 $template->setVariable(
"COUNTER", $i+1);
319 $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d", $i+1));
320 $template->setVariable(
"TEXTFIELD_SIZE", $width);
321 $template->parseCurrentBlock();
323 $questiontext = $this->
object->getQuestion();
324 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext, TRUE));
325 $questionoutput = $template->get();
326 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
339 global $rbacsystem, $ilTabs;
341 $ilTabs->clearTargets();
343 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
344 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
345 $q_type = $this->
object->getQuestionType();
349 $classname = $q_type .
"GUI";
350 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
351 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
356 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
359 $ilTabs->addTarget(
"edit_page",
360 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
361 array(
"edit",
"insert",
"exec_pg"),
362 "",
"", $force_active);
368 $force_active =
false;
369 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
372 if ($classname)
$url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
374 $ilTabs->addTarget(
"edit_question",
376 array(
"editQuestion",
"save",
"saveEdit",
"addanswers",
"removeanswers",
"originalSyncForm"),
377 $classname,
"", $force_active);
392 $ilTabs->addTarget(
"statistics",
393 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
404 return $this->
object->prepareTextareaOutput(
$output, TRUE);
409 $this->
object->setCorrectAnswers(
$_POST[
"correctanswers"] );
410 $this->
object->setTextRating(
$_POST[
"text_rating"] );
416 $this->
object->flushAnswers();
417 foreach (
$_POST[
'answers'][
'answer'] as $index => $answer)
419 $answertext = $answer;
420 $this->
object->addAnswer( $answertext,
$_POST[
'answers'][
'points'][$index], $index );
427 $correctanswers =
new ilNumberInputGUI($this->lng->txt(
"nr_of_correct_answers" ),
"correctanswers");
429 $correctanswers->setDecimals( 0 );
430 $correctanswers->setSize( 3 );
431 $correctanswers->setValue( $this->
object->getCorrectAnswers() );
432 $correctanswers->setRequired(
true );
433 $form->
addItem( $correctanswers );
436 $points =
new ilNumberInputGUI($this->lng->txt(
"maximum_points" ),
"points");
438 $points->setMinvalueShouldBeGreater(
true);
439 $points->setSize( 6 );
440 $points->setDisabled(
true );
441 $points->allowDecimals(
true);
442 $points->setValue( $this->
object->getMaximumPoints() );
443 $points->setRequired(
false );
447 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating" ),
"text_rating");
448 $text_options =
array(
449 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive" ),
450 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive" )
452 if (!$this->
object->getSelfAssessmentEditingMode())
454 $text_options[
"l1"] = sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"1" );
455 $text_options[
"l2"] = sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"2" );
456 $text_options[
"l3"] = sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"3" );
457 $text_options[
"l4"] = sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"4" );
458 $text_options[
"l5"] = sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"5" );
461 $textrating->setValue( $this->
object->getTextRating() );
469 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
472 $choices->setQuestionObject( $this->
object );
473 $choices->setSingleline(
true );
474 $choices->setAllowMove(
false );
475 $choices->setMinValue(0.0);
476 if ($this->
object->getAnswerCount() == 0)
477 $this->
object->addAnswer(
"", 0, 0 );
478 $choices->setValues( $this->
object->getAnswers() );
528 $aggregate =
array();
530 foreach ($relevant_answers_chosen as $relevant_answer)
532 if ( array_key_exists($relevant_answer[
'value1'], $aggregate) )
534 $aggregate[$relevant_answer[
'value1']]++;
538 $aggregate[$relevant_answer[
'value1']] = 1;
551 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
553 foreach ($aggregate as $key => $value)
555 $tpl->setCurrentBlock(
'aggregaterow' );
556 $tpl->setVariable(
'OPTION', $key );
557 $tpl->setVariable(
'COUNT', $value );
558 $tpl->parseCurrentBlock();
isTestPresentationContext()
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
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.
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
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)
{}
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.
Create styles array
The data for the language used.
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
getAnswerFeedbackOutput($active_id, $pass)
Returns the answer generic feedback depending on the results of the question.
saveTaxonomyAssignments()
Create new PHPExcel object
obj_idprivate
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.