ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\TestQuestionPool\Import Namespace Reference

Functions

 buildImportDirectoriesFromImportFile (string $file_to_import)
 
 buildImportDirectoriesFromContainerImport (string $importdir)
 
 buildResultsFilePath (string $importdir, string $subdir)
 
 getImportTempDirectory ()
 
 buildImportDirectoryFromImportFile (string $file_to_import)
 
 retrieveSelectedQuestionsFromImportQuestionsSelectionForm (string $form_cmd, string $importdir, string $qtifile, ServerRequestInterface $request)
 
 buildImportQuestionsSelectionForm (string $form_cmd, string $importdir, string $qtifile, ?string $path_to_uploaded_file_in_temp_dir=null)
 
 getLabelForQuestionType (string $type)
 
 getLabelForPluginQuestionTypes (string $type)
 

Variables

trait TestQuestionsImportTrait
 
array $old_export_question_types
 

Function Documentation

◆ buildImportDirectoriesFromContainerImport()

ILIAS\TestQuestionPool\Import\buildImportDirectoriesFromContainerImport ( string  $importdir)
private

Definition at line 59 of file TestQuestionsImportTrait.php.

59 : array
60 {
61 return [
62 $importdir,
63 $importdir . DIRECTORY_SEPARATOR . basename($importdir) . '.xml',
64 $importdir . DIRECTORY_SEPARATOR . preg_replace('/test|tst|qpl/', 'qti', basename($importdir)) . '.xml'
65 ];
66 }

Referenced by ilTestImporter\importXmlRepresentation(), and ilTestQuestionPoolImporter\importXmlRepresentation().

+ Here is the caller graph for this function:

◆ buildImportDirectoriesFromImportFile()

ILIAS\TestQuestionPool\Import\buildImportDirectoriesFromImportFile ( string  $file_to_import)
private

Definition at line 44 of file TestQuestionsImportTrait.php.

44 : array
45 {
46 $subdir = basename($file_to_import, '.zip');
47 return [
48 $subdir,
49 $this->import_temp_directory . DIRECTORY_SEPARATOR . $subdir,
50 $this->import_temp_directory . DIRECTORY_SEPARATOR . $subdir . DIRECTORY_SEPARATOR . $subdir . '.xml',
51 $this->import_temp_directory . DIRECTORY_SEPARATOR . $subdir . DIRECTORY_SEPARATOR . str_replace(
52 ['qpl', 'tst'],
53 'qti',
54 $subdir
55 ) . '.xml'
56 ];
57 }

Referenced by ilObjTestGUI\importFile(), ilObjQuestionPoolGUI\importFile(), ilObjQuestionPoolGUI\importQuestionsFile(), ilObjQuestionPoolGUI\importVerifiedFileObject(), and ilObjQuestionPoolGUI\importVerifiedQuestionsFileObject().

+ Here is the caller graph for this function:

◆ buildImportDirectoryFromImportFile()

ILIAS\TestQuestionPool\Import\buildImportDirectoryFromImportFile ( string  $file_to_import)
private

Definition at line 79 of file TestQuestionsImportTrait.php.

79 : string
80 {
81 $subdir = basename($file_to_import, '.zip');
82 return $this->import_temp_directory . DIRECTORY_SEPARATOR . $subdir;
83 }

Referenced by ilObjTest\fromXML().

+ Here is the caller graph for this function:

◆ buildImportQuestionsSelectionForm()

ILIAS\TestQuestionPool\Import\buildImportQuestionsSelectionForm ( string  $form_cmd,
string  $importdir,
string  $qtifile,
?string  $path_to_uploaded_file_in_temp_dir = null 
)
private

Definition at line 102 of file TestQuestionsImportTrait.php.

107 : ?StandardForm {
108 $qtiParser = new \ilQTIParser(
109 $importdir,
110 $qtifile,
112 0,
113 []
114 );
115 $qtiParser->startParsing();
116 $founditems = &$qtiParser->getFoundItems();
117 if ($path_to_uploaded_file_in_temp_dir !== null && $founditems === []) {
118 \ilFileUtils::delDir($importdir);
119 $this->deleteUploadedImportFile($path_to_uploaded_file_in_temp_dir);
120 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('qpl_import_no_items'), true);
121 return null;
122 }
123
124 $complete = 0;
125 $incomplete = 0;
126 foreach ($founditems as $item) {
127 if ($item['type'] !== '') {
128 $complete++;
129 } else {
130 $incomplete++;
131 }
132 }
133
134 if ($complete == 0) {
135 \ilFileUtils::delDir($importdir);
136 $this->deleteUploadedImportFile($path_to_uploaded_file_in_temp_dir);
137 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('qpl_import_non_ilias_files'), true);
138 return null;
139 }
140
141 $options = [];
142 $values = [];
143 foreach ($founditems as $item) {
144 $options[$item['ident']] = "{$item['title']} ({$this->getLabelForQuestionType($item['type'])})";
145 $values[] = $item['ident'];
146 }
147 $select_questions = $this->ui_factory->input()->field()->multiSelect(
148 $this->lng->txt('questions'),
149 $options
150 )->withValue($values);
151
152 return $this->ui_factory->input()->container()->form()->standard(
153 $this->ctrl->getFormActionByClass(self::class, $form_cmd),
154 ['selected_questions' => $select_questions]
155 )->withSubmitLabel($this->lng->txt('import'));
156 }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References ilFileUtils\delDir(), and ILIAS\Repository\lng().

Referenced by ilObjTestGUI\importFile(), ilObjQuestionPoolGUI\importFile(), and ilObjQuestionPoolGUI\importQuestionsFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildResultsFilePath()

ILIAS\TestQuestionPool\Import\buildResultsFilePath ( string  $importdir,
string  $subdir 
)
private

Definition at line 68 of file TestQuestionsImportTrait.php.

68 : string
69 {
70 return $importdir . DIRECTORY_SEPARATOR
71 . str_replace('tst', 'results', $subdir) . '.xml';
72 }

Referenced by ilObjTestGUI\importFile().

+ Here is the caller graph for this function:

◆ getImportTempDirectory()

ILIAS\TestQuestionPool\Import\getImportTempDirectory ( )
private

Definition at line 74 of file TestQuestionsImportTrait.php.

74 : string
75 {
76 return $this->import_temp_directory;
77 }

Referenced by ilObjTestGUI\importFile(), ilObjQuestionPoolGUI\importFile(), and ilObjQuestionPoolGUI\importQuestionsFile().

+ Here is the caller graph for this function:

◆ getLabelForPluginQuestionTypes()

ILIAS\TestQuestionPool\Import\getLabelForPluginQuestionTypes ( string  $type)
private

Definition at line 175 of file TestQuestionsImportTrait.php.

175 : string
176 {
177 foreach ($this->component_factory->getActivePluginsInSlot('qst') as $pl) {
178 if ($pl->getQuestionType() === $type) {
179 return $pl->getQuestionTypeTranslation();
180 }
181 }
182 return $type;
183 }

Referenced by ILIAS\TestQuestionPool\Import\getLabelForQuestionType().

+ Here is the caller graph for this function:

◆ getLabelForQuestionType()

ILIAS\TestQuestionPool\Import\getLabelForQuestionType ( string  $type)
private
Todo:
Remove with ILIAS 12: This is here for backward compatibility. As we support the import of a previous version this should go with ILIAS 11, but being generous: ILIAS 12 it is.

Definition at line 158 of file TestQuestionsImportTrait.php.

158 : string
159 {
160 if ($this->lng->exists($type)) {
161 return $this->lng->txt($type);
162 }
163
169 if (array_key_exists($type, $this->old_export_question_types)) {
170 return $this->lng->txt($this->old_export_question_types[$type]);
171 }
172 return $this->getLabelForPluginQuestionTypes($type);
173 }

References ILIAS\TestQuestionPool\Import\getLabelForPluginQuestionTypes(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ retrieveSelectedQuestionsFromImportQuestionsSelectionForm()

ILIAS\TestQuestionPool\Import\retrieveSelectedQuestionsFromImportQuestionsSelectionForm ( string  $form_cmd,
string  $importdir,
string  $qtifile,
ServerRequestInterface  $request 
)
private

Definition at line 85 of file TestQuestionsImportTrait.php.

90 : array {
92 $form_cmd,
93 $importdir,
94 $qtifile
95 )->withRequest($request)->getData();
96 if (isset($data['selected_questions'])) {
97 return $data['selected_questions'];
98 }
99 return [];
100 }
buildImportQuestionsSelectionForm(string $form_cmd, string $importdir, string $qtifile, ?string $path_to_uploaded_file_in_temp_dir=null)

References $data.

Referenced by ilObjQuestionPoolGUI\importVerifiedFileObject(), and ilObjQuestionPoolGUI\importVerifiedQuestionsFileObject().

+ Here is the caller graph for this function:

Variable Documentation

◆ $old_export_question_types

array ILIAS::TestQuestionPool::Import\$old_export_question_types
private
Initial value:
= [
'ORDERING QUESTION' => \ilQTIItem::QT_ORDERING,
'KPRIM CHOICE QUESTION' => \ilQTIItem::QT_KPRIM_CHOICE,
'LONG MENU QUESTION' => \ilQTIItem::QT_LONG_MENU,
'SINGLE CHOICE QUESTION' => \ilQTIItem::QT_MULTIPLE_CHOICE_SR,
'MULTIPLE CHOICE QUESTION' => \ilQTIItem::QT_MULTIPLE_CHOICE_MR,
'MATCHING QUESTION' => \ilQTIItem::QT_MATCHING,
'CLOZE QUESTION' => \ilQTIItem::QT_CLOZE,
'IMAGE MAP QUESTION' => \ilQTIItem::QT_IMAGEMAP,
'TEXT QUESTION' => \ilQTIItem::QT_TEXT,
'NUMERIC QUESTION' => \ilQTIItem::QT_NUMERIC,
'TEXTSUBSET QUESTION' => \ilQTIItem::QT_TEXTSUBSET
]
const QT_MULTIPLE_CHOICE_MR
const QT_MULTIPLE_CHOICE_SR
const QT_LONG_MENU
const QT_KPRIM_CHOICE
const QT_NUMERIC
const QT_MATCHING
const QT_ORDERING
const QT_IMAGEMAP
const QT_TEXTSUBSET

Definition at line 30 of file TestQuestionsImportTrait.php.

◆ TestQuestionsImportTrait

trait ILIAS::TestQuestionPool::Import\TestQuestionsImportTrait
Initial value:
{
private string $import_temp_directory = CLIENT_DATA_DIR . DIRECTORY_SEPARATOR . 'temp'
const CLIENT_DATA_DIR
Definition: constants.php:46

Definition at line 26 of file TestQuestionsImportTrait.php.