ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.assLongMenu.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
5require_once './Modules/Test/classes/inc.AssessmentConstants.php';
6require_once './Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
7require_once './Modules/TestQuestionPool/interfaces/interface.iQuestionCondition.php';
8require_once './Modules/TestQuestionPool/classes/class.ilUserQuestionResult.php';
9
10
12{
13 private $answerType;
16 private $ilDB;
19
22 const GAP_PLACEHOLDER = 'Longmenu';
24 const MAX_INPUT_FIELDS = 500;
25
27 private $correct_answers = [];
28
30 private $answers = [];
31
32 public function __construct(
33 $title = "",
34 $comment = "",
35 $author = "",
36 $owner = -1,
37 $question = ""
38 ) {
39 require_once 'Modules/TestQuestionPool/classes/feedback/class.ilAssConfigurableMultiOptionQuestionFeedback.php';
41 $this->minAutoComplete = self::MIN_LENGTH_AUTOCOMPLETE;
42 parent::__construct($title, $comment, $author, $owner, $question);
43 $this->ilDB = $GLOBALS['DIC']['ilDB'];
44 }
45
49 public function getAnswerType()
50 {
51 return $this->answerType;
52 }
53
57 public function setAnswerType($answerType)
58 {
59 $this->answerType = $answerType;
60 }
61
65 public function getCorrectAnswers()
66 {
68 }
69
70
72 {
73 $this->correct_answers = $correct_answers;
74 }
75
76 private function buildFolderName()
77 {
78 return ilUtil::getDataDir() . '/assessment/longMenuQuestion/' . $this->getId() . '/' ;
79 }
80
81 public function getAnswerTableName()
82 {
83 return "qpl_a_lome";
84 }
85
86 private function buildFileName($gap_id)
87 {
88 try {
89 $this->assertDirExists();
90 return $this->buildFolderName() . $gap_id . '.txt';
91 } catch (ilException $e) {
92 }
93 }
94
96 {
97 $this->long_menu_text = $long_menu_text;
98 }
99
100 public function getLongMenuTextValue()
101 {
103 }
104
105 public function setAnswers($answers)
106 {
107 $this->answers = $answers;
108 }
109
110 public function getAnswers()
111 {
112 return $this->answers;
113 }
114
118 public function getJsonStructure()
119 {
121 }
122
127 {
128 $this->json_structure = $json_structure;
129 }
130
132 {
133 $this->specificFeedbackSetting = $specificFeedbackSetting;
134 }
135
137 {
139 }
140
142 {
143 $this->minAutoComplete = $minAutoComplete;
144 }
145
146 public function getMinAutoComplete()
147 {
148 return $this->minAutoComplete ? $this->minAutoComplete : self::MIN_LENGTH_AUTOCOMPLETE;
149 }
150
151 public function isComplete()
152 {
153 if (strlen($this->title)
154 && $this->author
155 && $this->question
156 && sizeof($this->answers) > 0
157 && sizeof($this->correct_answers) > 0
158 && $this->getPoints() > 0
159 ) {
160 return true;
161 }
162 return false;
163 }
164
165 public function saveToDb($original_id = "")
166 {
170 parent::saveToDb($original_id);
171 }
172
173 public function checkQuestionCustomPart()
174 {
175 $hidden_text_files = $this->getAnswers();
177 $points = array();
178 if (sizeof($correct_answers) == 0 || sizeof($hidden_text_files) == 0) {
179 return false;
180 }
181 if (sizeof($correct_answers) != sizeof($hidden_text_files)) {
182 return false;
183 }
184 foreach ($correct_answers as $key => $correct_answers_row) {
185 if ($this->correctAnswerDoesNotExistInAnswerOptions($correct_answers_row, $hidden_text_files[$key])) {
186 return false;
187 }
188 if (!is_array($correct_answers_row[0]) || sizeof($correct_answers_row[0]) == 0) {
189 return false;
190 }
191 if ($correct_answers_row[1] > 0) {
192 array_push($points, $correct_answers_row[1]);
193 }
194 }
195 if (sizeof($correct_answers) != sizeof($points)) {
196 return false;
197 }
198
199 foreach ($points as $row) {
200 if ($row <= 0) {
201 return false;
202 }
203 }
204 return true;
205 }
206
207 private function correctAnswerDoesNotExistInAnswerOptions($answers, $answer_options)
208 {
209 foreach ($answers[0] as $key => $answer) {
210 if (!in_array($answer, $answer_options)) {
211 return true;
212 }
213 }
214 return false;
215 }
216
217
224 public function getMaximumPoints()
225 {
226 $sum = 0;
227 $points = $this->getCorrectAnswers();
228 if ($points) {
229 foreach ($points as $add) {
230 $sum += $add[1];
231 }
232 }
233 return $sum;
234 }
235
237 {
238 // save additional data
239 $this->ilDB->manipulateF(
240 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
241 array( "integer" ),
242 array( $this->getId() )
243 );
244 $this->ilDB->manipulateF(
245 "INSERT INTO " . $this->getAdditionalTableName(
246 ) . " (question_fi, long_menu_text, feedback_setting, min_auto_complete) VALUES (%s, %s, %s, %s)",
247 array( "integer", "text", "integer", "integer"),
248 array(
249 $this->getId(),
250 $this->getLongMenuTextValue(),
251 (int) $this->getSpecificFeedbackSetting(),
252 (int) $this->getMinAutoComplete()
253 )
254 );
255 $this->createFileFromArray();
256 }
257
259 {
260 $this->clearAnswerSpecificDataFromDb($this->getId());
261 $type_array = $this->getAnswerType();
262 $points = 0;
263 foreach ($this->getCorrectAnswers() as $gap_number => $gap) {
264 foreach ($gap[0] as $position => $answer) {
265 if ($type_array == null) {
266 $type = $gap[2];
267 } else {
268 $type = $type_array[$gap_number];
269 }
270 $this->db->replace(
271 $this->getAnswerTableName(),
272 array(
273 'question_fi' => array('integer', (int) $this->getId()),
274 'gap_number' => array('integer', (int) $gap_number),
275 'position' => array('integer', (int) $position)
276 ),
277 array(
278 'answer_text' => array('text', $answer),
279 'points' => array('float', $gap[1]),
280 'type' => array('integer', (int) $type)
281 )
282 );
283 }
284 $points += $gap[1];
285 }
286 $this->setPoints($points);
287 }
288
289 private function createFileFromArray()
290 {
291 $array = $this->getAnswers();
292 $this->clearFolder();
293 foreach ($array as $gap => $values) {
294 $file_content = '';
295 if (is_array($values)) {
296 foreach ($values as $key => $value) {
297 $file_content .= $value . "\n";
298 }
299 $file_content = rtrim($file_content, "\n");
300 $file = fopen($this->buildFileName($gap), "w");
301 fwrite($file, $file_content);
302 fclose($file);
303 }
304 }
305 }
306
307 private function createArrayFromFile()
308 {
309 $files = glob($this->buildFolderName() . '*.txt');
310
311 if ($files === false) {
312 $files = array();
313 }
314
315 $answers = array();
316
317 foreach ($files as $file) {
318 $gap = str_replace('.txt', '', basename($file));
319 $answers[(int) $gap] = explode("\n", file_get_contents($file));
320 }
321 $this->setAnswers($answers);
322 return $answers;
323 }
324
325 private function clearFolder($let_folder_exists = true)
326 {
327 ilUtil::delDir($this->buildFolderName(), $let_folder_exists);
328 }
329
330 private function assertDirExists()
331 {
332 $folder_name = $this->buildFolderName();
333 if (!ilUtil::makeDirParents($folder_name)) {
334 throw new ilException('Cannot create export directory');
335 }
336
337 if (
338 !is_dir($folder_name) ||
339 !is_readable($folder_name) ||
340 !is_writable($folder_name)
341 ) {
342 throw new ilException('Cannot create export directory');
343 }
344 }
345
346 public function loadFromDb($question_id)
347 {
348 $result = $this->ilDB->queryF(
349 "SELECT qpl_questions.*, " . $this->getAdditionalTableName() . ".* FROM qpl_questions LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = qpl_questions.question_id WHERE qpl_questions.question_id = %s",
350 array("integer"),
351 array($question_id)
352 );
353 if ($result->numRows() == 1) {
354 $data = $this->ilDB->fetchAssoc($result);
355 $this->setId($question_id);
356 $this->setObjId($data["obj_fi"]);
357 $this->setNrOfTries($data['nr_of_tries']);
358 $this->setTitle($data["title"]);
359 $this->setComment($data["description"]);
360 $this->setOriginalId($data["original_id"]);
361 $this->setAuthor($data["author"]);
362 $this->setPoints($data["points"]);
363 $this->setOwner($data["owner"]);
364 include_once("./Services/RTE/classes/class.ilRTE.php");
365 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data['question_text'], 1));
366 $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
368 $this->loadCorrectAnswerData($question_id);
369 $this->setMinAutoComplete($data["min_auto_complete"]);
370 if (isset($data['feedback_setting'])) {
371 $this->setSpecificFeedbackSetting((int) $data['feedback_setting']);
372 }
373 try {
374 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
375 } catch (ilTestQuestionPoolException $e) {
376 }
377 }
378
379 $this->loadCorrectAnswerData($question_id);
380 $this->createArrayFromFile();
381 parent::loadFromDb($question_id);
382 }
383
384 private function loadCorrectAnswerData($question_id)
385 {
386 $res = $this->db->queryF(
387 "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY gap_number, position ASC",
388 array('integer'),
389 array($question_id)
390 );
391
392 $correct_answers = array();
393 while ($data = $this->ilDB->fetchAssoc($res)) {
394 $correct_answers[$data['gap_number']][0][$data['position']] = rtrim($data['answer_text']);
395 $correct_answers[$data['gap_number']][1] = $data['points'];
396 $correct_answers[$data['gap_number']][2] = $data['type'];
397 }
398 $this->setJsonStructure(json_encode($correct_answers));
400 }
401
402 public function getCorrectAnswersForQuestionSolution($question_id)
403 {
404 $correct_answers = array();
405 $res = $this->db->queryF(
406 'SELECT gap_number, answer_text FROM ' . $this->getAnswerTableName() . ' WHERE question_fi = %s',
407 array('integer'),
408 array($question_id)
409 );
410 while ($data = $this->ilDB->fetchAssoc($res)) {
411 if (array_key_exists($data['gap_number'], $correct_answers)) {
412 $correct_answers[$data['gap_number']] .= ' ' . $this->lng->txt("or") . ' ';
413 $correct_answers[$data['gap_number']] .= rtrim($data['answer_text']);
414 } else {
415 $correct_answers[$data['gap_number']] .= rtrim($data['answer_text']);
416 }
417 }
418 return $correct_answers;
419 }
420
421 private function getCorrectAnswersForGap($question_id, $gap_id)
422 {
423 $correct_answers = array();
424 $res = $this->db->queryF(
425 'SELECT answer_text FROM ' . $this->getAnswerTableName() . ' WHERE question_fi = %s AND gap_number = %s',
426 array('integer', 'integer'),
427 array($question_id, $gap_id)
428 );
429 while ($data = $this->ilDB->fetchAssoc($res)) {
430 $correct_answers[] = rtrim($data['answer_text']);
431 }
432 return $correct_answers;
433 }
434
435 private function getPointsForGap($question_id, $gap_id)
436 {
437 $points = 0;
438 $res = $this->db->queryF(
439 'SELECT points FROM ' . $this->getAnswerTableName() . ' WHERE question_fi = %s AND gap_number = %s GROUP BY gap_number, points',
440 array('integer', 'integer'),
441 array($question_id, $gap_id)
442 );
443 while ($data = $this->ilDB->fetchAssoc($res)) {
444 $points = $data['points'];
445 }
446 return $points;
447 }
448
449
450 public function getAnswersObject()
451 {
452 return json_encode($this->createArrayFromFile());
453 }
454
455 public function getCorrectAnswersAsJson()
456 {
457 $this->loadCorrectAnswerData($this->getId());
458 return $this->getJsonStructure();
459 }
460
461 public function duplicate($for_test = true, $title = "", $author = "", $owner = "", $testObjId = null)
462 {
463 if ($this->id <= 0) {
464 // The question has not been saved. It cannot be duplicated
465 return;
466 }
467
468 // duplicate the question in database
469 $this_id = $this->getId();
470 $thisObjId = $this->getObjId();
471
472 $clone = $this;
473 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
475 $clone->id = -1;
476
477 if ((int) $testObjId > 0) {
478 $clone->setObjId($testObjId);
479 }
480
481 if ($title) {
482 $clone->setTitle($title);
483 }
484
485 if ($author) {
486 $clone->setAuthor($author);
487 }
488 if ($owner) {
489 $clone->setOwner($owner);
490 }
491
492 if ($for_test) {
493 $clone->saveToDb($original_id);
494 } else {
495 $clone->saveToDb();
496 }
497
498 $clone->copyPageOfQuestion($this_id);
499 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
500 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
501
502 return $clone->id;
503 }
504
505 public function copyObject($target_questionpool_id, $title = "")
506 {
507 if ($this->id <= 0) {
508 // The question has not been saved. It cannot be duplicated
509 return;
510 }
511 // duplicate the question in database
512 $clone = $this;
513 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
515 $clone->id = -1;
516 $source_questionpool_id = $this->getObjId();
517 $clone->setObjId($target_questionpool_id);
518 if ($title) {
519 $clone->setTitle($title);
520 }
521 $clone->saveToDb();
522
523 $clone->copyPageOfQuestion($original_id);
524 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
525
526 $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
527
528 return $clone->id;
529 }
530
531 public function createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle = "")
532 {
533 if ($this->id <= 0) {
534 // The question has not been saved. It cannot be duplicated
535 return;
536 }
537
538 include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
539
540 $sourceQuestionId = $this->id;
541 $sourceParentId = $this->getObjId();
542
543 // duplicate the question in database
544 $clone = $this;
545 $clone->id = -1;
546
547 $clone->setObjId($targetParentId);
548
549 if ($targetQuestionTitle) {
550 $clone->setTitle($targetQuestionTitle);
551 }
552
553 $clone->saveToDb();
554 $clone->copyPageOfQuestion($sourceQuestionId);
555 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
556
557 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
558
559 return $clone->id;
560 }
561
562
574 public function calculateReachedPoints($active_id, $pass = null, $authorizedSolution = true, $returndetails = false)
575 {
576 if ($returndetails) {
577 throw new ilTestException('return details not implemented for ' . __METHOD__);
578 }
579
580 $found_values = array();
581 if (is_null($pass)) {
582 $pass = $this->getSolutionMaxPass($active_id);
583 }
584 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
585 while ($data = $this->ilDB->fetchAssoc($result)) {
586 $found_values[(int) $data['value1']] = $data['value2'];
587 }
588
589 $points = $this->calculateReachedPointsForSolution($found_values, $active_id);
590
591 return $points;
592 }
593
594 protected function calculateReachedPointsForSolution($found_values, $active_id = 0)
595 {
596 $points = 0;
597 foreach ($found_values as $key => $answer) {
598 if ($answer != '') {
599 $correct_answers = $this->getCorrectAnswersForGap($this->id, $key);
600 if (in_array($answer, $correct_answers)) {
601 $points += $this->getPointsForGap($this->id, $key);
602 }
603 }
604 }
605 return $points;
606 }
607
616 public function saveWorkingData($active_id, $pass = null, $authorized = true)
617 {
618 if (is_null($pass)) {
619 include_once "./Modules/Test/classes/class.ilObjTest.php";
620 $pass = ilObjTest::_getPass($active_id);
621 }
622
623 $entered_values = 0;
624
625 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $active_id, $pass, $authorized) {
626 $this->removeCurrentSolution($active_id, $pass, $authorized);
627
628 foreach ($this->getSolutionSubmit() as $val1 => $val2) {
629 $value = ilUtil::stripSlashes($val2, false);
630 if (strlen($value)) {
631 $this->saveCurrentSolution($active_id, $pass, $val1, $value, $authorized);
632 $entered_values++;
633 }
634 }
635 });
636
637 if ($entered_values) {
638 include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
640 assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
641 }
642 } else {
643 include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
645 assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
646 }
647 }
648 return true;
649 }
650
651 // fau: testNav - overridden function lookupForExistingSolutions (specific for long menu question: ignore unselected values)
658 public function lookupForExistingSolutions($activeId, $pass)
659 {
660 global $ilDB;
661
662 $return = array(
663 'authorized' => false,
664 'intermediate' => false
665 );
666
667 $query = "
668 SELECT authorized, COUNT(*) cnt
669 FROM tst_solutions
670 WHERE active_fi = " . $ilDB->quote($activeId, 'integer') . "
671 AND question_fi = " . $ilDB->quote($this->getId(), 'integer') . "
672 AND pass = " . $ilDB->quote($pass, 'integer') . "
673 AND value2 <> '-1'
674 ";
675
676 if ($this->getStep() !== null) {
677 $query .= " AND step = " . $ilDB->quote((int) $this->getStep(), 'integer') . " ";
678 }
679
680 $query .= "
681 GROUP BY authorized
682 ";
683
684 $result = $ilDB->query($query);
685
686 while ($row = $ilDB->fetchAssoc($result)) {
687 if ($row['authorized']) {
688 $return['authorized'] = $row['cnt'] > 0;
689 } else {
690 $return['intermediate'] = $row['cnt'] > 0;
691 }
692 }
693 return $return;
694 }
695 // fau.
696
697
698 public function getSolutionSubmit()
699 {
700 $solutionSubmit = array();
701 $answer = ilUtil::stripSlashesRecursive($_POST['answer']);
702
703 foreach ($answer as $key => $value) {
704 $solutionSubmit[$key] = $value;
705 }
706
707 return $solutionSubmit;
708 }
709
710 protected function savePreviewData(ilAssQuestionPreviewSession $previewSession)
711 {
712 if (array_key_exists('answer', $_POST)) {
713 $previewSession->setParticipantsSolution($_POST['answer']);
714 } else {
715 $previewSession->setParticipantsSolution(null);
716 }
717 }
718
722 protected function reworkWorkingData($active_id, $pass, $obligationsAnswered, $authorized)
723 {
724 // nothing to rework!
725 }
726
732 public function getQuestionType()
733 {
734 return "assLongMenu";
735 }
736
742 public function getAdditionalTableName()
743 {
744 return 'qpl_qst_lome';
745 }
746
752 {
753 return parent::getRTETextWithMediaObjects() . $this->getLongMenuTextValue();
754 }
755
759 public function setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
760 {
761 parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
762
763 $solution = $this->getSolutionValues($active_id, $pass);
764
765 $i = 1;
766 foreach ($this->getCorrectAnswers() as $gap_index => $gap) {
767 $worksheet->setCell($startrow + $i, 0, $this->lng->txt('assLongMenu') . " $i");
768 $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
769 foreach ($solution as $solutionvalue) {
770 if ($gap_index == $solutionvalue["value1"]) {
771 switch ($gap[2]) {
773 $value = $solutionvalue["value2"];
774 if ($value == -1) {
775 $value = '';
776 }
777 $worksheet->setCell($startrow + $i, 1, $value);
778 break;
780 $worksheet->setCell($startrow + $i, 1, $solutionvalue["value2"]);
781 break;
782 }
783 }
784 }
785 $i++;
786 }
787
788 return $startrow + $i + 1;
789 }
790
799 public function getUserQuestionResult($active_id, $pass)
800 {
801 $result = new ilUserQuestionResult($this, $active_id, $pass);
802
803 $points = $this->calculateReachedPoints($active_id, $pass);
804 $max_points = $this->getMaximumPoints();
805
806 $result->setReachedPercentage(($points/$max_points) * 100);
807
808 return $result;
809 }
810
819 public function getAvailableAnswerOptions($index = null)
820 {
821 return $this->createArrayFromFile();
822 }
823
824 public function isShuffleAnswersEnabled()
825 {
826 return false;
827 }
828
829 public function clearAnswerSpecificDataFromDb($question_id)
830 {
831 $this->ilDB->manipulateF(
832 'DELETE FROM ' . $this->getAnswerTableName() . ' WHERE question_fi = %s',
833 array( 'integer' ),
834 array( $question_id )
835 );
836 }
837
838 public function delete($original_id)
839 {
840 parent::delete($original_id);
841 $this->clearFolder(false);
842 }
843
848 {
849 $this->setLongMenuTextValue($migrator->migrateToLmContent($this->getLongMenuTextValue()));
850 }
851
855 public function toJSON()
856 {
857 include_once("./Services/RTE/classes/class.ilRTE.php");
858 $result = array();
859 $result['id'] = (int) $this->getId();
860 $result['type'] = (string) $this->getQuestionType();
861 $result['title'] = (string) $this->getTitle();
862 $replaced_quesiton_text = $this->getLongMenuTextValue();
863 $result['question'] = $this->formatSAQuestion($this->getQuestion());
864 $result['lmtext'] = $this->formatSAQuestion($replaced_quesiton_text);
865 $result['nr_of_tries'] = (int) $this->getNrOfTries();
866 $result['shuffle'] = (bool) $this->getShuffle();
867 $result['feedback'] = array(
868 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
869 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
870 );
871
872 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
873 $result['answers'] = $this->getAnswers();
874 $result['correct_answers'] = $this->getCorrectAnswers();
875 $result['mobs'] = $mobs;
876 return json_encode($result);
877 }
878}
$worksheet
$result
$files
Definition: add-vimline.php:18
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
lmMigrateQuestionTypeSpecificContent(ilAssSelfAssessmentMigrator $migrator)
loadCorrectAnswerData($question_id)
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
const MIN_LENGTH_AUTOCOMPLETE
copyObject($target_questionpool_id, $title="")
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
getUserQuestionResult($active_id, $pass)
Get the user solution for a question by active_id and the test pass.
calculateReachedPointsForSolution($found_values, $active_id=0)
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
saveWorkingData($active_id, $pass=null, $authorized=true)
Saves the learners input of the question to the database.
getCorrectAnswersForGap($question_id, $gap_id)
setLongMenuTextValue($long_menu_text="")
isComplete()
Returns true, if a question is complete for use.
const ANSWER_TYPE_TEXT_VAL
buildFileName($gap_id)
setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
{Creates an Excel worksheet for the detailed cumulated results of this question.object}
getQuestionType()
Returns the question type of the question.
const ANSWER_TYPE_SELECT_VAL
toJSON()
Returns a JSON representation of the question.
getPointsForGap($question_id, $gap_id)
clearFolder($let_folder_exists=true)
loadFromDb($question_id)
Loads the question from the database.
setMinAutoComplete($minAutoComplete)
clearAnswerSpecificDataFromDb($question_id)
saveToDb($original_id="")
Saves the question to the database.
setAnswerType($answerType)
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assQuestion constructor
setSpecificFeedbackSetting($specificFeedbackSetting)
setCorrectAnswers($correct_answers)
getAnswerTableName()
Returns the name of the answer table in the database.
lookupForExistingSolutions($activeId, $pass)
Lookup if an authorized or intermediate solution exists.
correctAnswerDoesNotExistInAnswerOptions($answers, $answer_options)
reworkWorkingData($active_id, $pass, $obligationsAnswered, $authorized)
{Reworks the allready saved working data if neccessary.}
getCorrectAnswersForQuestionSolution($question_id)
savePreviewData(ilAssQuestionPreviewSession $previewSession)
setJsonStructure($json_structure)
setAnswers($answers)
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Abstract basic class which is to be extended by the concrete assessment question type classes.
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass.
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.
static _getOriginalId($question_id)
Returns the original id of a question.
formatSAQuestion($a_q)
Format self assessment question.
setId($id=-1)
Sets the id of the assQuestion object.
setOriginalId($original_id)
setObjId($obj_id=0)
Set the object id of the container object.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
saveQuestionDataToDb($original_id="")
getId()
Gets the id of the assQuestion object.
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
getObjId()
Get the object id of the container object.
setTitle($title="")
Sets the title string of the assQuestion object.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second.
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
removeCurrentSolution($active_id, $pass, $authorized=true)
setAuthor($author="")
Sets the authors name of the assQuestion object.
getPoints()
Returns the maximum available points for the question.
getShuffle()
Gets the shuffle flag.
getTitle()
Gets the title string of the assQuestion object.
setPoints($a_points)
Sets the maximum available points for the question.
setComment($comment="")
Sets the comment string of the assQuestion object.
setNrOfTries($a_nr_of_tries)
getQuestion()
Gets the question string of the question object.
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
setQuestion($question="")
Sets the question string of the question object.
Database Wrapper.
Definition: class.ilDB.php:30
queryF($a_query, $a_types, $a_values)
Formatted query (for SELECTS).
manipulateF($a_query, $a_types, $a_values)
Formatted manupulate (for DELETE, UPDATE, INSERT).
fetchAssoc($a_set)
Fetch row as associative array from result set.
Base class for ILIAS Exception handling.
static _getLogLanguage()
retrieve the log language for assessment logging
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
Base Exception for all Exceptions relating to Modules/Test.
Class ilUserQuestionResult.
static getDataDir()
get data directory (outside webspace)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static makeDirParents($a_dir)
Create a new directory and all parent directories.
$key
Definition: croninfo.php:18
$i
Definition: disco.tpl.php:19
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Interface ilObjQuestionScoringAdjustable.
$index
Definition: metadata.php:60
$query
$type
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
foreach($_POST as $key=> $value) $res
$mobs