ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  return true;
25  }
26 
27  return false;
28  }
29 
36  {
37  return $this->isQuestionSetConfigured();
38  }
39 
43  public function removeQuestionSetRelatedData()
44  {
45  $res = $this->db->queryF(
46  "SELECT question_fi FROM tst_test_question WHERE test_fi = %s",
47  array('integer'),
48  array($this->testOBJ->getTestId())
49  );
50 
51  while ($row = $this->db->fetchAssoc($res)) {
52  $this->testOBJ->removeQuestion($row["question_fi"]);
53  }
54 
55  $this->db->manipulateF(
56  "DELETE FROM tst_test_question WHERE test_fi = %s",
57  array('integer'),
58  array($this->testOBJ->getTestId())
59  );
60 
61  $this->testOBJ->questions = array();
62 
63  $this->testOBJ->saveCompleteStatus($this);
64  }
65 
67  {
68  // nothing to do
69  }
70 
76  public function cloneQuestionSetRelatedData(ilObjTest $cloneTestOBJ)
77  {
78  global $ilLog;
79 
80  require_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
81  require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
82 
84 
85  foreach ($this->testOBJ->questions as $key => $question_id) {
86  $question = assQuestion::_instanciateQuestion($question_id);
87  $cloneTestOBJ->questions[$key] = $question->duplicate(true, null, null, null, $cloneTestOBJ->getId());
88 
89  $original_id = assQuestion::_getOriginalId($question_id);
90 
91  $question = assQuestion::_instanciateQuestion($cloneTestOBJ->questions[$key]);
92  $question->saveToDb($original_id);
93 
94  // Save the mapping of old question id <-> new question id
95  // This will be used in class.ilObjCourse::cloneDependencies to copy learning objectives
96  $originalKey = $this->testOBJ->getRefId() . '_question_' . $question_id;
97  $mappedKey = $cloneTestOBJ->getRefId() . '_question_' . $cloneTestOBJ->questions[$key];
98  $cwo->appendMapping($originalKey, $mappedKey);
99  $ilLog->write(__METHOD__ . ": Added question id mapping $originalKey <-> $mappedKey");
100  }
101  }
102 
106  public function loadFromDb()
107  {
108  // TODO: Implement loadFromDb() method.
109  }
110 
114  public function saveToDb()
115  {
116  // TODO: Implement saveToDb() method.
117  }
118 
119  public function reindexQuestionOrdering()
120  {
121  $query = "
122  SELECT question_fi FROM tst_test_question
123  WHERE test_fi = %s
124  ORDER BY sequence ASC
125  ";
126 
127  $res = $this->db->queryF(
128  $query,
129  array('integer'),
130  array($this->testOBJ->getTestId())
131  );
132 
133  $sequenceIndex = 0;
134 
135  while ($row = $this->db->fetchAssoc($res)) {
136  $sequenceIndex++; // start with 1
137 
138  $this->db->update(
139  'tst_test_question',
140  array('sequence' => array('integer', $sequenceIndex)),
141  array('question_fi' => array('integer', $row['question_fi']))
142  );
143  }
144  }
145 
151  public function cloneToDbForTestId($testId)
152  {
153  // TODO: Implement saveToDbByTestId() method.
154  }
155 
159  public function deleteFromDb()
160  {
161  // TODO: Implement deleteFromDb() method.
162  }
163 
165  {
166  return false;
167  }
168 }
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.
foreach($_POST as $key=> $value) $res
getId()
get object id public
$query
loadFromDb()
loads the question set config for current test from the database
Create styles array
The data for the language used.
removeQuestionSetRelatedData()
removes all question set config related data
deleteFromDb()
deletes the question set config for current test from the database
cloneQuestionSetRelatedData(ilObjTest $cloneTestOBJ)
removes all question set config related data for cloned/copied test
getRefId()
get reference id public
cloneToDbForTestId($testId)
saves the question set config for test with given id to the database
$key
Definition: croninfo.php:18