ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
4require_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
45 {
46 $res = $this->db->queryF(
47 "SELECT question_fi FROM tst_test_question WHERE test_fi = %s",
48 array('integer'), array($this->testOBJ->getTestId())
49 );
50
51 while( $row = $this->db->fetchAssoc($res) )
52 {
53 $this->testOBJ->removeQuestion($row["question_fi"]);
54 }
55
56 $this->db->manipulateF(
57 "DELETE FROM tst_test_question WHERE test_fi = %s",
58 array('integer'), 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 {
87 $question = assQuestion::_instanciateQuestion($question_id);
88 $cloneTestOBJ->questions[$key] = $question->duplicate(true, null, null, null, $cloneTestOBJ->getId());
89
90 $original_id = assQuestion::_getOriginalId($question_id);
91
92 $question = assQuestion::_instanciateQuestion($cloneTestOBJ->questions[$key]);
93 $question->saveToDb($original_id);
94
95 // Save the mapping of old question id <-> new question id
96 // This will be used in class.ilObjCourse::cloneDependencies to copy learning objectives
97 $originalKey = $this->testOBJ->getRefId().'_question_'.$question_id;
98 $mappedKey = $cloneTestOBJ->getRefId().'_question_'.$cloneTestOBJ->questions[$key];
99 $cwo->appendMapping($originalKey, $mappedKey);
100 $ilLog->write(__METHOD__.": Added question id mapping $originalKey <-> $mappedKey");
101 }
102 }
103
107 public function loadFromDb()
108 {
109 // TODO: Implement loadFromDb() method.
110 }
111
115 public function saveToDb()
116 {
117 // TODO: Implement saveToDb() method.
118 }
119
120 public function reindexQuestionOrdering()
121 {
122 $query = "
123 SELECT question_fi FROM tst_test_question
124 WHERE test_fi = %s
125 ORDER BY sequence ASC
126 ";
127
128 $res = $this->db->queryF(
129 $query, array('integer'), array($this->testOBJ->getTestId())
130 );
131
132 $sequenceIndex = 0;
133
134 while($row = $this->db->fetchAssoc($res))
135 {
136 $sequenceIndex++; // start with 1
137
138 $this->db->update('tst_test_question',
139 array('sequence' => array('integer', $sequenceIndex)),
140 array('question_fi' => array('integer', $row['question_fi']))
141 );
142 }
143 }
144
150 public function cloneToDbForTestId($testId)
151 {
152 // TODO: Implement saveToDbByTestId() method.
153 }
154
158 public function deleteFromDb()
159 {
160 // TODO: Implement deleteFromDb() method.
161 }
162
164 {
165 return false;
166 }
167}
static _getOriginalId($question_id)
Returns the original id of a question.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
getRefId()
get reference id @access public
getId()
get object id @access public
loadFromDb()
loads 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
removeQuestionSetRelatedData()
removes all question set config related data
isQuestionSetConfigured()
returns the fact wether a useable question set config exists or not
saveToDb()
saves the question set config for current test to the database
cloneQuestionSetRelatedData(ilObjTest $cloneTestOBJ)
removes all question set config related data for cloned/copied test
doesQuestionSetRelatedDataExist()
returns the fact wether a useable question set config exists or not
deleteFromDb()
deletes the question set config for current test from the database
resetQuestionSetRelatedTestSettings()
resets all test settings that depends on a non changed question set config