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);
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 149 $solutions =
array();
150 if (($active_id > 0) && (!$show_correct_solution)) {
151 $solutions =&$this->
object->getSolutionValues($active_id,
$pass);
154 foreach ($this->
object->answers as $answer) {
155 if ($answer->getPoints() > 0) {
156 if (!is_array($rank[$answer->getPoints()])) {
157 $rank[$answer->getPoints()] =
array();
159 array_push($rank[$answer->getPoints()], $answer->getAnswertext());
162 krsort($rank, SORT_NUMERIC);
163 foreach ($rank as
$index => $bestsolutions) {
164 array_push($solutions,
array(
"value1" => join(
",", $bestsolutions),
"points" =>
$index));
169 include_once
"./Services/UICore/classes/class.ilTemplate.php";
170 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
171 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
172 $available_answers =&$this->
object->getAvailableAnswers();
173 for (
$i = 0;
$i < $this->
object->getCorrectAnswers();
$i++) {
174 if ((!$test_id) && (strcmp($solutions[
$i][
"value1"],
"") == 0)) {
176 if (($active_id > 0) && (!$show_correct_solution)) {
177 if ($graphicalOutput) {
179 $index = $this->
object->isAnswerCorrect($available_answers, $solutions[$i][
"value1"]);
182 unset($available_answers[
$index]);
188 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
193 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
198 $template->setCurrentBlock(
"textsubset_row");
199 $template->setVariable(
"SOLUTION", $solutions[$i][
"value1"]);
201 if ($result_output) {
202 $points = $solutions[
$i][
"points"];
203 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
204 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
209 $questiontext = $this->
object->getQuestion();
210 if ($show_question_text==
true) {
211 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext,
true));
215 if (strlen($feedback)) {
221 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
222 $solutiontemplate->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput($feedback,
true));
224 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
226 $solutionoutput = $solutiontemplate->get();
227 if (!$show_question_only) {
231 return $solutionoutput;
234 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
238 include_once
"./Services/UICore/classes/class.ilTemplate.php";
239 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html",
true,
true,
"Modules/TestQuestionPool");
240 $width = $this->
object->getMaxTextboxWidth();
241 for (
$i = 0;
$i < $this->
object->getCorrectAnswers();
$i++) {
242 $template->setCurrentBlock(
"textsubset_row");
243 foreach ($solutions as $idx => $solution_value) {
245 $template->setVariable(
"TEXTFIELD_VALUE",
" value=\"" . $solution_value .
"\"");
249 $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d",
$i+1));
250 $template->setVariable(
"TEXTFIELD_SIZE", $width);
253 $questiontext = $this->
object->getQuestion();
254 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext,
true));
256 if (!$show_question_only) {
260 return $questionoutput;
263 public function getTestOutput($active_id,
$pass = null, $is_postponed =
false, $use_post_solutions =
false, $inlineFeedback =
false)
270 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 271 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 273 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 276 $solutions = $this->
object->getUserSolutionPreferingIntermediate($active_id,
$pass);
280 include_once
"./Services/UICore/classes/class.ilTemplate.php";
281 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html",
true,
true,
"Modules/TestQuestionPool");
282 $width = $this->
object->getMaxTextboxWidth();
283 for (
$i = 0;
$i < $this->
object->getCorrectAnswers();
$i++) {
284 $template->setCurrentBlock(
"textsubset_row");
285 foreach ($solutions as $idx => $solution_value) {
291 $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d",
$i+1));
292 $template->setVariable(
"TEXTFIELD_SIZE", $width);
295 $questiontext = $this->
object->getQuestion();
296 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext,
true));
298 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
311 global $rbacsystem, $ilTabs;
313 $ilTabs->clearTargets();
315 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
316 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
317 $q_type = $this->
object->getQuestionType();
319 if (strlen($q_type)) {
320 $classname = $q_type .
"GUI";
321 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
322 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
326 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
330 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
331 array(
"edit",
"insert",
"exec_pg"),
341 $force_active =
false;
342 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
345 $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
351 array(
"editQuestion",
"save",
"saveEdit",
"addanswers",
"removeanswers",
"originalSyncForm"),
371 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
384 return $this->
object->prepareTextareaOutput(
$output,
true);
389 $this->
object->setCorrectAnswers(
$_POST[
"correctanswers"]);
390 $this->
object->setTextRating(
$_POST[
"text_rating"]);
396 $this->
object->flushAnswers();
397 foreach (
$_POST[
'answers'][
'answer'] as
$index => $answer) {
398 $answertext = $answer;
399 $this->
object->addAnswer($answertext,
$_POST[
'answers'][
'points'][
$index], $index);
406 $correctanswers =
new ilNumberInputGUI($this->lng->txt(
"nr_of_correct_answers"),
"correctanswers");
408 $correctanswers->setDecimals(0);
409 $correctanswers->setSize(3);
410 $correctanswers->setValue($this->
object->getCorrectAnswers());
411 $correctanswers->setRequired(
true);
412 $form->
addItem($correctanswers);
415 $points =
new ilNumberInputGUI($this->lng->txt(
"maximum_points"),
"points");
417 $points->setMinvalueShouldBeGreater(
true);
419 $points->setDisabled(
true);
420 $points->allowDecimals(
true);
421 $points->setValue($this->
object->getMaximumPoints());
422 $points->setRequired(
false);
426 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"text_rating");
427 $text_options =
array(
428 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
429 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive")
431 if (!$this->
object->getSelfAssessmentEditingMode()) {
432 $text_options[
"l1"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1");
433 $text_options[
"l2"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2");
434 $text_options[
"l3"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3");
435 $text_options[
"l4"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4");
436 $text_options[
"l5"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5");
439 $textrating->setValue($this->
object->getTextRating());
447 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
450 $choices->setQuestionObject($this->
object);
451 $choices->setSingleline(
true);
452 $choices->setAllowMove(
false);
453 $choices->setMinValue(0.0);
454 if ($this->
object->getAnswerCount() == 0) {
455 $this->
object->addAnswer(
"", 0, 0);
457 $choices->setValues($this->
object->getAnswers());
508 $aggregate =
array();
510 foreach ($relevant_answers_chosen as $relevant_answer) {
511 if (array_key_exists($relevant_answer[
'value1'], $aggregate)) {
512 $aggregate[$relevant_answer[
'value1']]++;
514 $aggregate[$relevant_answer[
'value1']] = 1;
527 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
529 foreach ($aggregate as
$key => $value) {
530 $tpl->setCurrentBlock(
'aggregaterow');
532 $tpl->setVariable(
'COUNT', $value);
533 $tpl->parseCurrentBlock();
isTestPresentationContext()
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...
getSpecificFeedbackOutput($active_id, $pass)
if(!array_key_exists('StateId', $_REQUEST)) $id
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()
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.
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.
getTestOutput($active_id, $pass=null, $is_postponed=false, $use_post_solutions=false, $inlineFeedback=false)
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.
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.