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