ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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  global $ilDB;
35  $this->ilDB = $ilDB;
36  }
37 
41  public function getAnswerType()
42  {
43  return $this->answerType;
44  }
45 
49  public function setAnswerType($answerType)
50  {
51  $this->answerType = $answerType;
52  }
53 
57  public function getCorrectAnswers()
58  {
60  }
61 
62 
63  public function setCorrectAnswers($correct_answers)
64  {
65  $this->correct_answers = $correct_answers;
66  }
67 
68  private function buildFolderName()
69  {
70  return ilUtil::getDataDir() . '/assessment/longMenuQuestion/' . $this->getId() . '/' ;
71  }
72 
73  public function getAnswerTableName()
74  {
75  return "qpl_a_lome";
76  }
77 
78  private function buildFileName($gap_id)
79  {
80  try
81  {
82  $this->assertDirExists();
83  return $this->buildFolderName() . $gap_id . '.txt';
84  }
85  catch (ilException $e) {
86 
87  }
88  }
89 
90  function setLongMenuTextValue($long_menu_text = "")
91  {
92  $this->long_menu_text = $long_menu_text;
93  }
94 
96  {
97  return $this->long_menu_text;
98  }
99 
100  public function setAnswers($answers)
101  {
102  $this->answers = $answers;
103  }
104 
105  public function getAnswers()
106  {
107  return $this->answers;
108  }
109 
113  public function getJsonStructure()
114  {
115  return $this->json_structure;
116  }
117 
121  public function setJsonStructure($json_structure)
122  {
123  $this->json_structure = $json_structure;
124  }
125 
127  {
128  $this->specificFeedbackSetting = $specificFeedbackSetting;
129  }
130 
131  public function getSpecificFeedbackSetting()
132  {
134  }
135 
136  public function setMinAutoComplete($minAutoComplete)
137  {
138  $this->minAutoComplete = $minAutoComplete;
139  }
140 
141  public function getMinAutoComplete()
142  {
143  return $this->minAutoComplete ? $this->minAutoComplete : self::MIN_LENGTH_AUTOCOMPLETE;
144  }
145 
146  public function isComplete()
147  {
148  if (strlen($this->title)
149  && $this->author
150  && $this->question
151  && sizeof($this->answers) > 0
152  && sizeof($this->correct_answers) > 0
153  && $this->getPoints() > 0
154  )
155  {
156  return true;
157  }
158  return false;
159  }
160 
161  public function saveToDb($original_id = "")
162  {
166  parent::saveToDb($original_id);
167  }
168 
169  public function checkQuestionCustomPart()
170  {
171  $hidden_text_files = $this->getAnswers();
172  $correct_answers = $this->getCorrectAnswers();
173  $points = array();
174  if( sizeof($correct_answers) == 0 || sizeof($hidden_text_files) == 0 )
175  {
176  return false;
177  }
178  if(sizeof($correct_answers) != sizeof($hidden_text_files))
179  {
180  return false;
181  }
182  foreach($correct_answers as $key => $correct_answers_row)
183  {
184  if($this->correctAnswerDoesNotExistInAnswerOptions($correct_answers_row, $hidden_text_files[$key]))
185  {
186  return false;
187  }
188  if( !is_array($correct_answers_row[0]) || sizeof($correct_answers_row[0]) == 0)
189  {
190  return false;
191  }
192  if($correct_answers_row[1] > 0)
193  {
194  array_push($points, $correct_answers_row[1]);
195  }
196  }
197  if(sizeof($correct_answers) != sizeof($points))
198  {
199  return false;
200  }
201 
202  foreach($points as $row)
203  {
204  if($row <= 0)
205  {
206  return false;
207  }
208  }
209  return true;
210  }
211 
212  private function correctAnswerDoesNotExistInAnswerOptions($answers, $answer_options)
213  {
214  foreach($answers[0] as $key => $answer)
215  {
216  if(!in_array($answer, $answer_options))
217  {
218  return true;
219  }
220  }
221  return false;
222  }
223 
224 
231  function getMaximumPoints()
232  {
233  $sum = 0;
234  $points = $this->getCorrectAnswers();
235  if($points)
236  {
237  foreach($points as $add)
238  {
239  $sum += $add[1];
240  }
241  }
242  return $sum;
243  }
244 
246  {
247  // save additional data
248  $this->ilDB->manipulateF( "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
249  array( "integer" ),
250  array( $this->getId() )
251  );
252  $this->ilDB->manipulateF( "INSERT INTO " . $this->getAdditionalTableName(
253  ) . " (question_fi, long_menu_text, feedback_setting, min_auto_complete) VALUES (%s, %s, %s, %s)",
254  array( "integer", "text", "integer", "integer"),
255  array(
256  $this->getId(),
257  $this->getLongMenuTextValue(),
258  (int)$this->getSpecificFeedbackSetting(),
259  (int)$this->getMinAutoComplete()
260  )
261  );
262  $this->createFileFromArray();
263  }
264 
265  public function saveAnswerSpecificDataToDb()
266  {
267  $this->clearAnswerSpecificDataFromDb($this->getId());
268  $type_array = $this->getAnswerType();
269  $points = 0;
270  foreach($this->getCorrectAnswers() as $gap_number => $gap)
271  {
272  foreach($gap[0] as $position => $answer)
273  {
274  if($type_array == null)
275  {
276  $type = $gap[2];
277  }
278  else
279  {
280  $type = $type_array[$gap_number];
281  }
282  $this->db->replace(
283  $this->getAnswerTableName(),
284  array(
285  'question_fi' => array('integer', (int)$this->getId()),
286  'gap_number' => array('integer', (int)$gap_number),
287  'position' => array('integer', (int)$position)
288  ),
289  array(
290  'answer_text' => array('text', $answer),
291  'points' => array('float', $gap[1]),
292  'type' => array('integer', (int) $type)
293  )
294  );
295  }
296  $points += $gap[1];
297  }
298  $this->setPoints($points);
299  }
300 
301  private function createFileFromArray()
302  {
303  $array = $this->getAnswers();
304  $this->clearFolder();
305  foreach($array as $gap => $values)
306  {
307  $file_content = '';
308  if(is_array($values))
309  {
310  foreach($values as $key => $value)
311  {
312  $file_content .= $value . "\n";
313  }
314  $file_content = rtrim($file_content, "\n");
315  $file = fopen($this->buildFileName($gap), "w");
316  fwrite($file, $file_content);
317  fclose($file);
318  }
319  }
320  }
321 
322  private function createArrayFromFile()
323  {
324  $files = glob( $this->buildFolderName() . '*.txt' );
325 
326  if($files === false)
327  {
328  $files = array();
329  }
330 
331  $answers = array();
332 
333  foreach( $files as $file)
334  {
335  $gap = str_replace('.txt', '', basename($file));
336  $answers[(int) $gap] = explode("\n", file_get_contents($file));
337  }
338  $this->setAnswers($answers);
339  return $answers;
340  }
341 
342  private function clearFolder($let_folder_exists = true)
343  {
344  ilUtil::delDir($this->buildFolderName(), $let_folder_exists);
345  }
346 
347  private function assertDirExists()
348  {
349  $folder_name = $this->buildFolderName();
350  if(!ilUtil::makeDirParents($folder_name))
351  {
352  throw new ilException('Cannot create export directory');
353  }
354 
355  if(
356  !is_dir($folder_name) ||
357  !is_readable($folder_name) ||
358  !is_writable($folder_name)
359  )
360  {
361  throw new ilException('Cannot create export directory');
362  }
363  }
364 
365  public function loadFromDb($question_id)
366  {
367  $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",
368  array("integer"),
369  array($question_id)
370  );
371  if ($result->numRows() == 1)
372  {
373  $data = $this->ilDB->fetchAssoc($result);
374  $this->setId($question_id);
375  $this->setObjId($data["obj_fi"]);
376  $this->setNrOfTries($data['nr_of_tries']);
377  $this->setTitle($data["title"]);
378  $this->setComment($data["description"]);
379  $this->setOriginalId($data["original_id"]);
380  $this->setAuthor($data["author"]);
381  $this->setPoints($data["points"]);
382  $this->setOwner($data["owner"]);
383  include_once("./Services/RTE/classes/class.ilRTE.php");
384  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data['question_text'], 1));
385  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
386  $this->setLongMenuTextValue(ilRTE::_replaceMediaObjectImageSrc($data['long_menu_text'], 1));
387  $this->loadCorrectAnswerData($question_id);
388  $this->setMinAutoComplete($data["min_auto_complete"]);
389  if( isset($data['feedback_setting']) )
390  {
391  $this->setSpecificFeedbackSetting((int)$data['feedback_setting']);
392  }
393  try
394  {
395  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
396  }
398  {
399  }
400  }
401 
402  $this->loadCorrectAnswerData($question_id);
403  $this->createArrayFromFile();
404  parent::loadFromDb($question_id);
405  }
406 
407  private function loadCorrectAnswerData($question_id)
408  {
409  $res = $this->db->queryF(
410  "SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY gap_number, position ASC",
411  array('integer'), array($question_id)
412  );
413 
414  $correct_answers = array();
415  while($data = $this->ilDB->fetchAssoc($res))
416  {
417  $correct_answers[$data['gap_number']][0][$data['position']] = rtrim($data['answer_text']);
418  $correct_answers[$data['gap_number']][1] = $data['points'];
419  $correct_answers[$data['gap_number']][2] = $data['type'];
420  }
421  $this->setJsonStructure(json_encode($correct_answers));
422  $this->setCorrectAnswers($correct_answers);
423 
424  }
425 
426  public function getCorrectAnswersForQuestionSolution($question_id)
427  {
428  $correct_answers = array();
429  $res = $this->db->queryF(
430  'SELECT gap_number, answer_text FROM ' . $this->getAnswerTableName() .' WHERE question_fi = %s',
431  array('integer'), array($question_id)
432  );
433  while($data = $this->ilDB->fetchAssoc($res))
434  {
435  if(array_key_exists($data['gap_number'], $correct_answers))
436  {
437  $correct_answers[$data['gap_number']] .= ' ' . $this->lng->txt("or") . ' ';
438  $correct_answers[$data['gap_number']] .= rtrim($data['answer_text']);
439  }
440  else
441  {
442  $correct_answers[$data['gap_number']] .= rtrim($data['answer_text']);
443  }
444  }
445  return $correct_answers;
446  }
447 
448  private function getCorrectAnswersForGap($question_id, $gap_id)
449  {
450  $correct_answers = array();
451  $res = $this->db->queryF(
452  'SELECT answer_text FROM ' . $this->getAnswerTableName() .' WHERE question_fi = %s AND gap_number = %s',
453  array('integer', 'integer'), array($question_id, $gap_id)
454  );
455  while($data = $this->ilDB->fetchAssoc($res))
456  {
457  $correct_answers[] = rtrim($data['answer_text']);
458  }
459  return $correct_answers;
460  }
461 
462  private function getPointsForGap($question_id, $gap_id)
463  {
464  $points = 0;
465  $res = $this->db->queryF(
466  'SELECT points FROM ' . $this->getAnswerTableName() .' WHERE question_fi = %s AND gap_number = %s GROUP BY gap_number, points',
467  array('integer', 'integer'), array($question_id, $gap_id)
468  );
469  while($data = $this->ilDB->fetchAssoc($res))
470  {
471  $points = $data['points'];
472  }
473  return $points;
474  }
475 
476 
477  function getAnswersObject()
478  {
479  return json_encode($this->createArrayFromFile());
480  }
481 
483  {
484  $this->loadCorrectAnswerData($this->getId());
485  return $this->getJsonStructure();
486  }
487 
488  function duplicate($for_test = true, $title = "", $author = "", $owner = "", $testObjId = null)
489  {
490 
491  if ($this->id <= 0)
492  {
493  // The question has not been saved. It cannot be duplicated
494  return;
495  }
496 
497  // duplicate the question in database
498  $this_id = $this->getId();
499  $thisObjId = $this->getObjId();
500 
501  $clone = $this;
502  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
504  $clone->id = -1;
505 
506  if( (int)$testObjId > 0 )
507  {
508  $clone->setObjId($testObjId);
509  }
510 
511  if ($title)
512  {
513  $clone->setTitle($title);
514  }
515 
516  if ($author)
517  {
518  $clone->setAuthor($author);
519  }
520  if ($owner)
521  {
522  $clone->setOwner($owner);
523  }
524 
525  if ($for_test)
526  {
527  $clone->saveToDb($original_id);
528  }
529  else
530  {
531  $clone->saveToDb();
532  }
533 
534  $clone->copyPageOfQuestion($this_id);
535  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
536  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
537 
538  return $clone->id;
539  }
540 
541  function copyObject($target_questionpool_id, $title = "")
542  {
543  if ($this->id <= 0)
544  {
545  // The question has not been saved. It cannot be duplicated
546  return;
547  }
548  // duplicate the question in database
549  $clone = $this;
550  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
552  $clone->id = -1;
553  $source_questionpool_id = $this->getObjId();
554  $clone->setObjId($target_questionpool_id);
555  if ($title)
556  {
557  $clone->setTitle($title);
558  }
559  $clone->saveToDb();
560 
561  $clone->copyPageOfQuestion($original_id);
562  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
563 
564  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
565 
566  return $clone->id;
567  }
568 
569  public function createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle = "")
570  {
571  if ($this->id <= 0)
572  {
573  // The question has not been saved. It cannot be duplicated
574  return;
575  }
576 
577  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
578 
579  $sourceQuestionId = $this->id;
580  $sourceParentId = $this->getObjId();
581 
582  // duplicate the question in database
583  $clone = $this;
584  $clone->id = -1;
585 
586  $clone->setObjId($targetParentId);
587 
588  if ($targetQuestionTitle)
589  {
590  $clone->setTitle($targetQuestionTitle);
591  }
592 
593  $clone->saveToDb();
594  $clone->copyPageOfQuestion($sourceQuestionId);
595  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
596 
597  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
598 
599  return $clone->id;
600  }
601 
602 
614  public function calculateReachedPoints($active_id, $pass = NULL, $authorizedSolution = true, $returndetails = FALSE)
615  {
616  if( $returndetails )
617  {
618  throw new ilTestException('return details not implemented for '.__METHOD__);
619  }
620 
621  $found_values = array();
622  if (is_null($pass))
623  {
624  $pass = $this->getSolutionMaxPass($active_id);
625  }
626  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
627  while ($data = $this->ilDB->fetchAssoc($result))
628  {
629  $found_values[(int)$data['value1']] = $data['value2'];
630  }
631 
632  $points = $this->calculateReachedPointsForSolution($found_values, $active_id);
633 
634  return $points;
635  }
636 
637  protected function calculateReachedPointsForSolution($found_values, $active_id = 0)
638  {
639  $points = 0;
640  foreach($found_values as $key => $answer)
641  {
642  if($answer != '')
643  {
644  $correct_answers = $this->getCorrectAnswersForGap($this->id, $key);
645  if(in_array($answer, $correct_answers))
646  {
647  $points += $this->getPointsForGap($this->id, $key);
648  }
649  }
650  }
651  return $points;
652  }
653 
662  public function saveWorkingData($active_id, $pass = NULL, $authorized = true)
663  {
664  if (is_null($pass))
665  {
666  include_once "./Modules/Test/classes/class.ilObjTest.php";
667  $pass = ilObjTest::_getPass($active_id);
668  }
669  $this->getProcessLocker()->requestUserSolutionUpdateLock();
670 
671  $entered_values = 0;
672  $this->removeCurrentSolution($active_id, $pass, $authorized);
673 
674  foreach($this->getSolutionSubmit() as $val1 => $val2)
675  {
676  $value = ilUtil::stripSlashes($val2, FALSE);
677  if (strlen($value))
678  {
679  $this->saveCurrentSolution($active_id,$pass, $val1, $value, $authorized);
680  $entered_values++;
681  }
682  }
683  $this->getProcessLocker()->releaseUserSolutionUpdateLock();
684 
685  if ($entered_values)
686  {
687  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
689  {
690  $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
691  }
692  }
693  else
694  {
695  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
697  {
698  $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
699  }
700  }
701  return true;
702  }
703 
704  public function getSolutionSubmit()
705  {
706  $solutionSubmit = array();
707  $answer = ilUtil::stripSlashesRecursive($_POST['answer']);
708 
709  foreach($answer as $key => $value)
710  {
711  $solutionSubmit[$key] = $value;
712  }
713 
714  return $solutionSubmit;
715  }
716 
717  protected function savePreviewData(ilAssQuestionPreviewSession $previewSession)
718  {
719  if( array_key_exists('answer',$_POST) )
720  {
721  $previewSession->setParticipantsSolution($_POST['answer']);
722  }
723  else
724  {
725  $previewSession->setParticipantsSolution(null);
726  }
727  }
728 
736  protected function reworkWorkingData($active_id, $pass, $obligationsAnswered)
737  {
738  // nothing to rework!
739  }
740 
746  public function getQuestionType()
747  {
748  return "assLongMenu";
749  }
750 
756  public function getAdditionalTableName()
757  {
758  return 'qpl_qst_lome';
759  }
760 
766  {
767  return parent::getRTETextWithMediaObjects() . $this->getLongMenuTextValue();
768  }
781  public function setExportDetailsXLS(&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
782  {
783  include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
784  $solution = $this->getSolutionValues($active_id, $pass);
785  $worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
786  $worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
787  $i = 1;
788  foreach ($this->getCorrectAnswers() as $gap_index => $gap)
789  {
790  $worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($this->lng->txt('assLongMenu') . " $i"), $format_bold);
791  foreach ($solution as $solutionvalue)
792  {
793  if ($gap_index == $solutionvalue["value1"])
794  {
795  switch ($gap[2])
796  {
797  case self::ANSWER_TYPE_SELECT_VAL:
798  $value = $solutionvalue["value2"];
799  if($value == -1)
800  {
801  $value = '';
802  }
803  $worksheet->writeString($startrow + $i, 1, $value);
804  break;
805  case self::ANSWER_TYPE_TEXT_VAL:
806  $worksheet->writeString($startrow + $i, 1, $solutionvalue["value2"]);
807  break;
808  }
809  }
810  }
811  $i++;
812  }
813  return $startrow + $i + 1;
814  }
815 
824  public function getUserQuestionResult($active_id, $pass)
825  {
826  $result = new ilUserQuestionResult($this, $active_id, $pass);
827 
828  $points = $this->calculateReachedPoints($active_id, $pass);
829  $max_points = $this->getMaximumPoints();
830 
831  $result->setReachedPercentage(($points/$max_points) * 100);
832 
833  return $result;
834  }
835 
844  public function getAvailableAnswerOptions($index = null)
845  {
846  return $this->createArrayFromFile();
847  }
848 
849  public function isShuffleAnswersEnabled()
850  {
851  return false;
852  }
853 
854  public function clearAnswerSpecificDataFromDb($question_id)
855  {
856  $this->ilDB->manipulateF( 'DELETE FROM ' . $this->getAnswerTableName() .' WHERE question_fi = %s',
857  array( 'integer' ),
858  array( $question_id )
859  );
860  }
861 
862  public function delete($original_id)
863  {
864  parent::delete($original_id);
865  $this->clearFolder(false);
866  }
867 
872  {
873  $this->setLongMenuTextValue( $migrator->migrateToLmContent($this->getLongMenuTextValue()) );
874  }
875 
879  public function toJSON()
880  {
881  include_once("./Services/RTE/classes/class.ilRTE.php");
882  $result = array();
883  $result['id'] = (int) $this->getId();
884  $result['type'] = (string) $this->getQuestionType();
885  $result['title'] = (string) $this->getTitle();
886  $replaced_quesiton_text = $this->getLongMenuTextValue();
887  $result['question'] = $this->formatSAQuestion($this->getQuestion());
888  $result['lmtext'] = $this->formatSAQuestion($replaced_quesiton_text);
889  $result['nr_of_tries'] = (int) $this->getNrOfTries();
890  $result['shuffle'] = (bool) $this->getShuffle();
891  $result['feedback'] = array(
892  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
893  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
894  );
895 
896  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
897  $result['answers'] = $this->getAnswers();
898  $result['correct_answers'] = $this->getCorrectAnswers();
899  $result['mobs'] = $mobs;
900  return json_encode($result);
901  }
902 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
correctAnswerDoesNotExistInAnswerOptions($answers, $answer_options)
getId()
Gets the id of the assQuestion object.
lmMigrateQuestionTypeSpecificContent(ilAssSelfAssessmentMigrator $migrator)
setAnswers($answers)
print $file
static _getOriginalId($question_id)
Returns the original id of a question.
formatSAQuestion($a_q)
Format self assessment question.
getCorrectAnswersForQuestionSolution($question_id)
Base class for ILIAS Exception handling.
$_POST['username']
Definition: cron.php:12
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...
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
_convert_text($a_text, $a_target="has been removed")
getAdditionalTableName()
Returns the name of the additional question data table in the database.
savePreviewData(ilAssQuestionPreviewSession $previewSession)
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. ...
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true)
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)
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
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
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.
$data
setLongMenuTextValue($long_menu_text="")
$mobs
Class ilUserQuestionResult.
removeCurrentSolution($active_id, $pass, $authorized=true, $ignoredSolutionIds=array())
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 ...
_getLogLanguage()
retrieve the log language for assessment logging
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
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:28
setExportDetailsXLS(&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
Creates an Excel worksheet for the detailed cumulated results of this question.
static getDataDir()
get data directory (outside webspace)
clearAnswerSpecificDataFromDb($question_id)
setQuestion($question="")
Sets the question string of the question object.
Interface ilObjQuestionScoringAdjustable.
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.
logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
getTitle()
Gets the title string of the assQuestion object.
reworkWorkingData($active_id, $pass, $obligationsAnswered)
Reworks the allready saved working data if neccessary.
__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.
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.