ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilTestFixedQuestionSetConfig.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/Test/classes/class.ilTestQuestionSetConfig.php';
5 
15 {
21  public function isQuestionSetConfigured()
22  {
23  if( count($this->testOBJ->questions) )
24  {
25  return true;
26  }
27 
28  return false;
29  }
30 
37  {
38  return $this->isQuestionSetConfigured();
39  }
40 
44  public function removeQuestionSetRelatedData()
45  {
46  $this->testOBJ->removeAllTestEditings();
47 
48  $res = $this->db->queryF(
49  "SELECT question_fi FROM tst_test_question WHERE test_fi = %s",
50  array('integer'), array($this->testOBJ->getTestId())
51  );
52 
53  while( $row = $this->db->fetchAssoc($res) )
54  {
55  $this->testOBJ->removeQuestion($row["question_fi"]);
56  }
57 
58  $this->db->manipulateF(
59  "DELETE FROM tst_test_question WHERE test_fi = %s",
60  array('integer'), array($this->testOBJ->getTestId())
61  );
62 
63  $this->testOBJ->questions = array();
64 
65  $this->testOBJ->saveCompleteStatus($this);
66  }
67 
73  public function cloneQuestionSetRelatedData($cloneTestOBJ)
74  {
75  global $ilLog;
76 
77  require_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
78  require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
79 
80  $cwo = ilCopyWizardOptions::_getInstance($cloneTestOBJ->getId());
81 
82  foreach( $this->testOBJ->questions as $key => $question_id )
83  {
84  $question = assQuestion::_instanciateQuestion($question_id);
85  $cloneTestOBJ->questions[$key] = $question->duplicate(true, null, null, null, $cloneTestOBJ->getId());
86 
87  $original_id = assQuestion::_getOriginalId($question_id);
88 
89  $question = assQuestion::_instanciateQuestion($cloneTestOBJ->questions[$key]);
90  $question->saveToDb($original_id);
91 
92  // Save the mapping of old question id <-> new question id
93  // This will be used in class.ilObjCourse::cloneDependencies to copy learning objectives
94  $originalKey = $this->testOBJ->getRefId().'_'.$question_id;
95  $mappedKey = $cloneTestOBJ->getRefId().'_'.$cloneTestOBJ->questions[$key];
96  $cwo->appendMapping($originalKey, $mappedKey);
97  $ilLog->write(__METHOD__.": Added mapping $originalKey <-> $mappedKey");
98  }
99  }
100 
104  public function loadFromDb()
105  {
106  // TODO: Implement loadFromDb() method.
107  }
108 
112  public function saveToDb()
113  {
114  // TODO: Implement saveToDb() method.
115  }
116 
122  public function cloneToDbForTestId($testId)
123  {
124  // TODO: Implement saveToDbByTestId() method.
125  }
126 
130  public function deleteFromDb()
131  {
132  // TODO: Implement deleteFromDb() method.
133  }
134 }
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _getOriginalId($question_id)
Returns the original id of a question.
isQuestionSetConfigured()
returns the fact wether a useable question set config exists or not
doesQuestionSetRelatedDataExist()
returns the fact wether a useable question set config exists or not
saveToDb()
saves the question set config for current test to the database
static _getInstance($a_copy_id)
Get instance of copy wizard options.
cloneQuestionSetRelatedData($cloneTestOBJ)
removes all question set config related data for cloned/copied test
loadFromDb()
loads the question set config for current test from the database
removeQuestionSetRelatedData()
removes all question set config related data
deleteFromDb()
deletes the question set config for current test from the database
cloneToDbForTestId($testId)
saves the question set config for test with given id to the database