4 require_once
'Services/Xml/classes/class.ilSaxParser.php';
58 xml_set_object($xmlParser, $this);
59 xml_set_element_handler($xmlParser,
'handlerBeginTag',
'handlerEndTag');
60 xml_set_character_data_handler($xmlParser,
'handlerCharacterData');
66 case 'RandomQuestionSetConfig':
67 $this->inRandomQuestionSetConfig =
true;
70 case 'RandomQuestionSetSettings':
71 if ($this->inRandomQuestionSetConfig) {
72 $this->inRandomQuestionSetSettings =
true;
74 $this->attr = $tagAttributes;
78 case 'RandomQuestionStage':
79 if ($this->inRandomQuestionSetConfig) {
80 $this->inRandomQuestionStage =
true;
84 case 'RandomQuestionStagingPool':
85 if ($this->inRandomQuestionStage) {
87 $this->attr = $tagAttributes;
91 case 'RandomQuestionSelectionDefinitions':
92 if ($this->inRandomQuestionSetConfig) {
93 $this->inRandomQuestionSelectionDefinitions =
true;
97 case 'RandomQuestionSelectionDefinition':
98 if ($this->inRandomQuestionSelectionDefinitions) {
100 $this->attr = $tagAttributes;
104 case 'RandomQuestionSourcePoolTitle':
105 case 'RandomQuestionSourcePoolPath':
116 case 'RandomQuestionSetConfig':
117 $this->inRandomQuestionSetConfig =
false;
120 case 'RandomQuestionSetSettings':
121 if ($this->inRandomQuestionSetConfig) {
127 case 'RandomQuestionStage':
128 if ($this->inRandomQuestionSetConfig) {
129 $this->inRandomQuestionStage =
false;
133 case 'RandomQuestionStagingPool':
134 if ($this->inRandomQuestionSetConfig && $this->inRandomQuestionStage) {
141 case 'RandomQuestionSelectionDefinitions':
142 if ($this->inRandomQuestionSetConfig) {
143 $this->inRandomQuestionSelectionDefinitions =
false;
147 case 'RandomQuestionSelectionDefinition':
148 if ($this->inRandomQuestionSetConfig && $this->inRandomQuestionSelectionDefinitions) {
150 $this->sourcePoolDefinition->saveToDb();
156 $this->sourcePoolDefinition->getId()
159 $this->sourcePoolDefinition = null;
164 case 'RandomQuestionSourcePoolTitle':
166 $this->sourcePoolDefinition->setPoolTitle($this->cdata);
171 case 'RandomQuestionSourcePoolPath':
172 if ($this->sourcePoolDefinition instanceof ilTestRandomQuestionSetSourcePoolDefinition) {
173 $this->sourcePoolDefinition->setPoolPath($this->cdata);
182 if ($charData !=
"\n") {
184 $charData = preg_replace(
"/\t+/",
" ", $charData);
186 $this->cdata .= $charData;
193 $tree = $DIC[
'tree'];
194 $ilDB = $DIC[
'ilDB'];
195 $ilPluginAdmin = $DIC[
'ilPluginAdmin'];
197 require_once
'Modules/Test/classes/class.ilTestRandomQuestionSetConfig.php';
200 if (!$questionSetConfig->isValidQuestionAmountConfigurationMode($attr[
'amountMode'])) {
201 require_once
'Modules/Test/exceptions/class.ilTestException.php';
203 'invalid random test question set config amount mode given: "' . $attr[
'amountMode'] .
'"' 207 $questionSetConfig->setQuestionAmountConfigurationMode($attr[
'amountMode']);
208 $questionSetConfig->setQuestionAmountPerTest((
int) $attr[
'questAmount']);
209 $questionSetConfig->setPoolsWithHomogeneousScoredQuestionsRequired((
bool) $attr[
'homogeneous']);
210 $questionSetConfig->setLastQuestionSyncTimestamp((
int) $attr[
'synctimestamp']);
212 $questionSetConfig->saveToDb();
218 $ilDB = $DIC[
'ilDB'];
220 $oldPoolId = $attr[
'poolId'];
221 $newPoolId =
$ilDB->nextId(
'object_data');
230 $oldQuestionIds = explode(
',', $cdata);
232 require_once
'Modules/Test/classes/class.ilTestRandomQuestionSetStagingPoolQuestion.php';
234 foreach ($oldQuestionIds as $oldQuestionId) {
242 $stagingQuestion->setTestId($this->testOBJ->getTestId());
243 $stagingQuestion->setPoolId($newPoolId);
244 $stagingQuestion->setQuestionId($newQuestionId);
246 $stagingQuestion->saveQuestionStaging();
253 $ilDB = $DIC[
'ilDB'];
255 require_once
'Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinition.php';
262 $source_pool_id = (int) $attr[
'poolId'];
268 $sourcePoolDefinition->
setPoolId($effective_pool_id);
270 $derive_from_obj_id =
true;
272 if (isset($attr[
'ref_id']) && is_numeric($attr[
'ref_id'])) {
273 if ($source_pool_id === $effective_pool_id) {
274 $derive_from_obj_id =
false;
275 $sourcePoolDefinition->
setPoolRefId((
int) $attr[
'ref_id']);
279 if ($derive_from_obj_id) {
281 $ref_id = current($ref_ids);
282 $sourcePoolDefinition->
setPoolRefId($ref_id ? (
int) $ref_id : null);
290 if (isset($attr[
'tax']) && isset($attr[
'taxNode'])) {
291 $mappedTaxFilter = array(
292 (
int) $attr[
'tax'] => array(
293 (
int) $attr[
'taxNode']
297 } elseif (isset($attr[
'taxFilter']) && strlen($attr[
'taxFilter']) > 0) {
298 $mappedTaxFilter = unserialize($attr[
'taxFilter']);
setPoolRefId(?int $poolRefId)
setQuestionAmount($questionAmount)
setImportMapping($importMapping)
importRandomQuestionSetSettings($attr)
static _getAllReferences($a_id)
get all reference ids of object
Base Exception for all Exceptions relating to Modules/Test.
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
setMappedTaxonomyFilter($filter=array())
set the original taxonomy filter condition
setPoolQuestionCount($poolQuestionCount)
getRandomQuestionSourcePoolDefinitionInstance()
handlerBeginTag($xmlParser, $tagName, $tagAttributes)
importRandomQuestionStagingPool($attr, $cdata)
setSequencePosition($sequencePosition)
importRandomQuestionSourcePoolDefinition(ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition, $attr)
handlerEndTag($xmlParser, $tagName)
handlerCharacterData($xmlParser, $charData)