ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilTestExportRandomQuestionSet Class Reference
+ Inheritance diagram for ilTestExportRandomQuestionSet:
+ Collaboration diagram for ilTestExportRandomQuestionSet:

Public Member Functions

 __construct (\ilObjTest $test_obj, private ilLanguage $lng, private ilLogger $logger, private ilTree $tree, private ilComponentRepository $component_repository, protected \ILIAS\TestQuestionPool\QuestionInfoService $questioninfo, string $mode="xml")
 
- Public Member Functions inherited from ilTestExport
 __construct (public ilObjTest $test_obj, public string $mode="xml")
 
 isResultExportingEnabledForTestExport ()
 
 setResultExportingEnabledForTestExport (bool $resultExprtingEnabledForTestExport)
 
 getForcedAccessFilteredParticipantList ()
 
 setForcedAccessFilteredParticipantList (ilTestParticipantList $forcedAccessFilteredParticipantList)
 
 getAccessFilteredParticipantList ()
 
 getExtension ()
 
 getInstId ()
 
 buildExportFile ()
 
 buildExportResultFile ()
 
 buildExportFileXML ()
 
 exportXHTMLMediaObjects ($a_export_dir)
 

Protected Member Functions

 initXmlExport ()
 
 populateQuestionSetConfigXml (ilXmlWriter $xml_writer)
 
 populateCommonSettings (ilXmlWriter $xml_writer)
 
 populateQuestionStages (ilXmlWriter $xml_writer)
 
 populateSelectionDefinitions (ilXmlWriter $xml_writer)
 
 getQuestionsQtiXml ()
 
 getQuestionIds ()
 
 getLoadedStagingPoolQuestionList (int $pool_id)
 
- Protected Member Functions inherited from ilTestExport
 initXmlExport ()
 
 getQuestionIds ()
 
 populateQuestionSetConfigXml (ilXmlWriter $xmlWriter)
 
 getQtiXml ()
 
 getQuestionsQtiXml ()
 
 getQuestionQtiXml ($questionId)
 
 populateQuestionSkillAssignmentsXml (ilXmlWriter $a_xml_writer, ilAssQuestionSkillAssignmentList $assignmentList, array $questions)
 
 populateSkillLevelThresholdsXml (ilXmlWriter $a_xml_writer, ilAssQuestionSkillAssignmentList $assignmentList)
 
 buildQuestionSkillAssignmentList ()
 

Protected Attributes

ilTestRandomQuestionSetSourcePoolDefinitionList $src_pool_def_list
 
 $staging_pool_question_list_by_pool_id
 
- Protected Attributes inherited from ilTestExport
bool $resultExportingEnabledForTestExport = false
 
ilTestParticipantList $forcedAccessFilteredParticipantList = null
 
ilBenchmark $bench
 
ilErrorHandling $err
 
ilDBInterface $db
 
ILIAS $ilias
 
string $inst_id
 

Detailed Description

Definition at line 27 of file class.ilTestExportRandomQuestionSet.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestExportRandomQuestionSet::__construct ( \ilObjTest  $test_obj,
private ilLanguage  $lng,
private ilLogger  $logger,
private ilTree  $tree,
private ilComponentRepository  $component_repository,
protected \ILIAS\TestQuestionPool\QuestionInfoService  $questioninfo,
string  $mode = "xml" 
)

Definition at line 36 of file class.ilTestExportRandomQuestionSet.php.

References ILIAS\MetaData\Repository\Validation\Data\__construct().

45  {
46  parent::__construct($test_obj, $mode);
47  }
__construct(VocabulariesInterface $vocabularies)
+ Here is the call graph for this function:

Member Function Documentation

◆ getLoadedStagingPoolQuestionList()

ilTestExportRandomQuestionSet::getLoadedStagingPoolQuestionList ( int  $pool_id)
protected

Definition at line 177 of file class.ilTestExportRandomQuestionSet.php.

Referenced by getQuestionIds(), getQuestionsQtiXml(), and populateQuestionStages().

178  {
179  if (!isset($this->staging_pool_question_list_by_pool_id[$pool_id])) {
180  $question_list = new ilTestRandomQuestionSetStagingPoolQuestionList($this->db, $this->component_repository);
181  $question_list->setTestId($this->test_obj->getTestId());
182  $question_list->setPoolId($pool_id);
183  $question_list->loadQuestions();
184 
185  $this->staging_pool_question_list_by_pool_id[$pool_id] = $question_list;
186  }
187 
188  return $this->staging_pool_question_list_by_pool_id[$pool_id];
189  }
+ Here is the caller graph for this function:

◆ getQuestionIds()

ilTestExportRandomQuestionSet::getQuestionIds ( )
protected
Returns
array

Definition at line 162 of file class.ilTestExportRandomQuestionSet.php.

References getLoadedStagingPoolQuestionList().

Referenced by initXmlExport().

162  : array
163  {
164  $question_ids = [];
165 
166  foreach ($this->src_pool_def_list->getInvolvedSourcePoolIds() as $pool_id) {
167  $question_list = $this->getLoadedStagingPoolQuestionList($pool_id);
168 
169  foreach ($question_list as $question_id) {
170  $question_ids[] = $question_id;
171  }
172  }
173 
174  return $question_ids;
175  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionsQtiXml()

ilTestExportRandomQuestionSet::getQuestionsQtiXml ( )
protected

Definition at line 144 of file class.ilTestExportRandomQuestionSet.php.

References getLoadedStagingPoolQuestionList(), and ilTestExport\getQuestionQtiXml().

144  : string
145  {
146  $question_qti_xml = '';
147 
148  foreach ($this->src_pool_def_list->getInvolvedSourcePoolIds() as $pool_id) {
149  $question_list = $this->getLoadedStagingPoolQuestionList($pool_id);
150 
151  foreach ($question_list as $question_id) {
152  $question_qti_xml .= $this->getQuestionQtiXml($question_id);
153  }
154  }
155 
156  return $question_qti_xml;
157  }
getQuestionQtiXml($questionId)
+ Here is the call graph for this function:

◆ initXmlExport()

ilTestExportRandomQuestionSet::initXmlExport ( )
protected

Definition at line 49 of file class.ilTestExportRandomQuestionSet.php.

References getQuestionIds().

49  : void
50  {
51  $src_pool_def_factory = new ilTestRandomQuestionSetSourcePoolDefinitionFactory(
52  $this->db,
53  $this->test_obj
54  );
55 
56  $this->src_pool_def_list = new ilTestRandomQuestionSetSourcePoolDefinitionList(
57  $this->db,
58  $this->test_obj,
59  $src_pool_def_factory
60  );
61 
62  $this->src_pool_def_list->loadDefinitions();
63 
64  $this->test_obj->questions = $this->getQuestionIds();
65  $this->staging_pool_question_list_by_pool_id = [];
66  }
+ Here is the call graph for this function:

◆ populateCommonSettings()

ilTestExportRandomQuestionSet::populateCommonSettings ( ilXmlWriter  $xml_writer)
protected

Definition at line 77 of file class.ilTestExportRandomQuestionSet.php.

References ILIAS\Repository\lng(), ILIAS\Repository\logger(), and ilXmlWriter\xmlElement().

Referenced by populateQuestionSetConfigXml().

78  {
79  $question_set_config = new ilTestRandomQuestionSetConfig(
80  $this->tree,
81  $this->db,
82  $this->lng,
83  $this->logger,
84  $this->component_repository,
85  $this->test_obj,
86  $this->questioninfo
87  );
88  $question_set_config->loadFromDb();
89 
90  $xml_writer->xmlElement('RandomQuestionSetSettings', [
91  'amountMode' => $question_set_config->getQuestionAmountConfigurationMode(),
92  'questAmount' => $question_set_config->getQuestionAmountPerTest(),
93  'homogeneous' => $question_set_config->arePoolsWithHomogeneousScoredQuestionsRequired(),
94  'synctimestamp' => $question_set_config->getLastQuestionSyncTimestamp()
95  ]);
96  }
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateQuestionSetConfigXml()

ilTestExportRandomQuestionSet::populateQuestionSetConfigXml ( ilXmlWriter  $xml_writer)
protected

Definition at line 68 of file class.ilTestExportRandomQuestionSet.php.

References populateCommonSettings(), populateQuestionStages(), populateSelectionDefinitions(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

68  : void
69  {
70  $xml_writer->xmlStartTag('RandomQuestionSetConfig');
71  $this->populateCommonSettings($xml_writer);
72  $this->populateQuestionStages($xml_writer);
73  $this->populateSelectionDefinitions($xml_writer);
74  $xml_writer->xmlEndTag('RandomQuestionSetConfig');
75  }
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
+ Here is the call graph for this function:

◆ populateQuestionStages()

ilTestExportRandomQuestionSet::populateQuestionStages ( ilXmlWriter  $xml_writer)
protected

Definition at line 98 of file class.ilTestExportRandomQuestionSet.php.

References getLoadedStagingPoolQuestionList(), ilXmlWriter\xmlData(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by populateQuestionSetConfigXml().

99  {
100  $xml_writer->xmlStartTag('RandomQuestionStage');
101 
102  foreach ($this->src_pool_def_list->getInvolvedSourcePoolIds() as $pool_id) {
103  $question_list = $this->getLoadedStagingPoolQuestionList($pool_id);
104 
105  $xml_writer->xmlStartTag('RandomQuestionStagingPool', ['poolId' => $pool_id]);
106  $xml_writer->xmlData(implode(',', $question_list->getQuestions()));
107  $xml_writer->xmlEndTag('RandomQuestionStagingPool');
108  }
109 
110  $xml_writer->xmlEndTag('RandomQuestionStage');
111  }
xmlData(string $data, bool $encode=true, bool $escape=true)
Writes data.
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateSelectionDefinitions()

ilTestExportRandomQuestionSet::populateSelectionDefinitions ( ilXmlWriter  $xml_writer)
protected

Definition at line 113 of file class.ilTestExportRandomQuestionSet.php.

References ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by populateQuestionSetConfigXml().

114  {
115  $xml_writer->xmlStartTag('RandomQuestionSelectionDefinitions');
116 
117  foreach ($this->src_pool_def_list as $definition) {
118  $attributes = [
119  'id' => $definition->getId(),
120  'ref_id' => $definition->getPoolRefId(),
121  'poolId' => $definition->getPoolId(),
122  'questAmount' => $definition->getQuestionAmount() ?? '',
123  'poolQuestCount' => $definition->getPoolQuestionCount(),
124  'position' => $definition->getSequencePosition(),
125  'typeFilter' => implode(',', $definition->getTypeFilterAsTypeTags()),
126  ];
127 
128 
129  // #21330
130  $mappedTaxFilter = $definition->getMappedTaxonomyFilter();
131  if (is_array($mappedTaxFilter) && count($mappedTaxFilter) > 0) {
132  $attributes['taxFilter'] = serialize($mappedTaxFilter);
133  }
134 
135  $xml_writer->xmlStartTag('RandomQuestionSelectionDefinition', $attributes);
136  $xml_writer->xmlElement('RandomQuestionSourcePoolTitle', null, $definition->getPoolTitle());
137  $xml_writer->xmlElement('RandomQuestionSourcePoolPath', null, $definition->getPoolPath());
138  $xml_writer->xmlEndTag('RandomQuestionSelectionDefinition');
139  }
140 
141  $xml_writer->xmlEndTag('RandomQuestionSelectionDefinitions');
142  }
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $src_pool_def_list

ilTestRandomQuestionSetSourcePoolDefinitionList ilTestExportRandomQuestionSet::$src_pool_def_list
protected

Definition at line 29 of file class.ilTestExportRandomQuestionSet.php.

◆ $staging_pool_question_list_by_pool_id

ilTestExportRandomQuestionSet::$staging_pool_question_list_by_pool_id
protected

Definition at line 34 of file class.ilTestExportRandomQuestionSet.php.


The documentation for this class was generated from the following file: