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';
39 $this->
object->loadFromDb(
$id);
48 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
50 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
68 require_once
'./Services/Form/classes/class.ilPropertyFormGUI.php';
70 $this->editForm =
$form;
72 $form->setFormAction($this->ctrl->getFormAction($this));
74 $form->setMultipart(
false);
75 $form->setTableWidth(
"100%");
76 $form->setId(
"asstextsubset");
86 $form->setValuesByPost();
87 $points =
$form->getItemByPostVar(
'points');
88 $points->setValue($this->object->getMaximumPoints());
90 $form->setValuesByPost();
97 $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);
150 $graphicalOutput =
false,
151 $result_output =
false,
152 $show_question_only =
true,
153 $show_feedback =
false,
154 $show_correct_solution =
false,
155 $show_manual_scoring =
false,
156 $show_question_text =
true 159 $solutions = array();
160 if (($active_id > 0) && (!$show_correct_solution)) {
164 foreach ($this->object->answers as $answer) {
165 if ($answer->getPoints() > 0) {
166 if (!is_array($rank[$answer->getPoints()])) {
167 $rank[$answer->getPoints()] = array();
169 array_push($rank[$answer->getPoints()], $answer->getAnswertext());
172 krsort($rank, SORT_NUMERIC);
173 foreach ($rank as
$index => $bestsolutions) {
174 array_push($solutions, array(
"value1" => join(
",", $bestsolutions),
"points" =>
$index));
179 include_once
"./Services/UICore/classes/class.ilTemplate.php";
180 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
181 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
182 $available_answers = &$this->
object->getAvailableAnswers();
183 for (
$i = 0;
$i < $this->
object->getCorrectAnswers();
$i++) {
184 if ((!$test_id) && (strcmp($solutions[
$i][
"value1"],
"") == 0)) {
186 if (($active_id > 0) && (!$show_correct_solution)) {
187 if ($graphicalOutput) {
189 $index = $this->
object->isAnswerCorrect($available_answers, $solutions[$i][
"value1"]);
192 unset($available_answers[
$index]);
198 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
203 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
208 $template->setCurrentBlock(
"textsubset_row");
209 $template->setVariable(
"SOLUTION", $solutions[$i][
"value1"]);
210 $template->setVariable(
"COUNTER", $i + 1);
211 if ($result_output) {
212 $points = $solutions[
$i][
"points"];
213 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
214 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
219 $questiontext = $this->
object->getQuestion();
220 if ($show_question_text ==
true) {
221 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext,
true));
225 if (strlen($feedback)) {
231 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
232 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
234 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
236 $solutionoutput = $solutiontemplate->get();
237 if (!$show_question_only) {
241 return $solutionoutput;
244 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
248 include_once
"./Services/UICore/classes/class.ilTemplate.php";
249 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html",
true,
true,
"Modules/TestQuestionPool");
250 $width = $this->
object->getMaxTextboxWidth();
251 for (
$i = 0;
$i < $this->
object->getCorrectAnswers();
$i++) {
252 $template->setCurrentBlock(
"textsubset_row");
253 foreach ($solutions as $idx => $solution_value) {
255 $template->setVariable(
"TEXTFIELD_VALUE",
" value=\"" . $solution_value .
"\"");
259 $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d",
$i + 1));
260 $template->setVariable(
"TEXTFIELD_SIZE", $width);
263 $questiontext = $this->
object->getQuestion();
264 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext,
true));
266 if (!$show_question_only) {
270 return $questionoutput;
273 public function getTestOutput($active_id,
$pass = null, $is_postponed =
false, $use_post_solutions =
false, $inlineFeedback =
false)
280 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 281 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 283 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 286 $solutions = $this->
object->getUserSolutionPreferingIntermediate($active_id,
$pass);
290 include_once
"./Services/UICore/classes/class.ilTemplate.php";
291 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html",
true,
true,
"Modules/TestQuestionPool");
292 $width = $this->
object->getMaxTextboxWidth();
293 for (
$i = 0;
$i < $this->
object->getCorrectAnswers();
$i++) {
294 $template->setCurrentBlock(
"textsubset_row");
295 foreach ($solutions as $idx => $solution_value) {
301 $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d",
$i + 1));
302 $template->setVariable(
"TEXTFIELD_SIZE", $width);
305 $questiontext = $this->
object->getQuestion();
306 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext,
true));
308 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
322 $rbacsystem = $DIC[
'rbacsystem'];
323 $ilTabs = $DIC[
'ilTabs'];
325 $ilTabs->clearTargets();
327 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
328 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
329 $q_type = $this->
object->getQuestionType();
331 if (strlen($q_type)) {
332 $classname = $q_type .
"GUI";
333 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
334 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
338 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
342 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
343 array(
"edit",
"insert",
"exec_pg"),
353 $force_active =
false;
354 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
357 $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
363 array(
"editQuestion",
"save",
"saveEdit",
"addanswers",
"removeanswers",
"originalSyncForm"),
383 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
396 return $this->
object->prepareTextareaOutput(
$output,
true);
401 $this->
object->setCorrectAnswers(
$_POST[
"correctanswers"]);
402 $this->
object->setTextRating(
$_POST[
"text_rating"]);
408 $this->
object->flushAnswers();
409 foreach (
$_POST[
'answers'][
'answer'] as
$index => $answer) {
410 $answertext = $answer;
411 $this->
object->addAnswer($answertext,
$_POST[
'answers'][
'points'][
$index], $index);
418 $correctanswers =
new ilNumberInputGUI($this->lng->txt(
"nr_of_correct_answers"),
"correctanswers");
420 $correctanswers->setDecimals(0);
421 $correctanswers->setSize(3);
422 $correctanswers->setValue($this->object->getCorrectAnswers());
423 $correctanswers->setRequired(
true);
424 $form->
addItem($correctanswers);
427 $points =
new ilNumberInputGUI($this->lng->txt(
"maximum_points"),
"points");
429 $points->setMinvalueShouldBeGreater(
true);
431 $points->setDisabled(
true);
432 $points->allowDecimals(
true);
433 $points->setValue($this->object->getMaximumPoints());
434 $points->setRequired(
false);
438 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"text_rating");
439 $text_options = array(
440 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
441 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive")
443 if (!$this->object->getSelfAssessmentEditingMode()) {
444 $text_options[
"l1"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1");
445 $text_options[
"l2"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2");
446 $text_options[
"l3"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3");
447 $text_options[
"l4"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4");
448 $text_options[
"l5"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5");
451 $textrating->setValue($this->object->getTextRating());
459 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
462 $choices->setQuestionObject($this->
object);
463 $choices->setSingleline(
true);
464 $choices->setAllowMove(
false);
465 $choices->setMinValue(0.0);
466 if ($this->object->getAnswerCount() == 0) {
467 $this->
object->addAnswer(
"", 0, 0);
469 $choices->setValues($this->object->getAnswers());
520 $aggregate = array();
522 foreach ($relevant_answers_chosen as $relevant_answer) {
523 if (array_key_exists($relevant_answer[
'value1'], $aggregate)) {
524 $aggregate[$relevant_answer[
'value1']]++;
526 $aggregate[$relevant_answer[
'value1']] = 1;
539 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
541 foreach ($aggregate as
$key => $value) {
542 $tpl->setCurrentBlock(
'aggregaterow');
544 $tpl->setVariable(
'COUNT', $value);
545 $tpl->parseCurrentBlock();
554 foreach ($relevantAnswers as $ans) {
555 if (!isset($answers[$ans[
'value1']])) {
556 $answers[$ans[
'value1']] = array(
557 'answer' => $ans[
'value1'],
'frequency' => 0
561 $answers[$ans[
'value1']][
'frequency']++;
570 require_once
'Modules/TestQuestionPool/classes/forms/class.ilAssAnswerCorrectionsInputGUI.php';
573 $choices->setQuestionObject($this->
object);
574 $choices->setValues($this->object->getAnswers());
585 $points = $form->
getInput(
'answers')[
'points'];
587 foreach ($this->object->getAnswers() as
$index => $answer) {
589 $answer->setPoints((
float) $points[$index]);
isTestPresentationContext()
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
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)
Get the question solution output.
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...
if(!array_key_exists('StateId', $_REQUEST)) $id
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
Class for TextSubset questions.
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
removeanswers()
Remove an answer.
getAnswersFrequency($relevantAnswers, $questionIndex)
writeQuestionGenericPostData()
if(isset($_POST['submit'])) $form
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
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.
getTestOutput($active_id, $pass=null, $is_postponed=false, $use_post_solutions=false, $inlineFeedback=false)
saveTaxonomyAssignments()
supportsIntermediateSolutionOutput()
Question type specific support of intermediate solution output The function getSolutionOutput respect...
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
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.
Interface ilGuiAnswerScoringAdjustable.
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.
getSpecificFeedbackOutput($userSolution)