ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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 62 of file TestQuestionsImportTrait.php.

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

◆ buildImportDirectoriesFromImportFile()

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

Definition at line 47 of file TestQuestionsImportTrait.php.

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

◆ buildImportDirectoryFromImportFile()

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

Definition at line 82 of file TestQuestionsImportTrait.php.

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

◆ 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 105 of file TestQuestionsImportTrait.php.

110 : ?StandardForm {
111 $qtiParser = new \ilQTIParser(
112 $importdir,
113 $qtifile,
115 0,
116 []
117 );
118 $qtiParser->startParsing();
119 $founditems = &$qtiParser->getFoundItems();
120 if ($path_to_uploaded_file_in_temp_dir !== null && $founditems === []) {
121 \ilFileUtils::delDir($importdir);
122 $this->deleteUploadedImportFile($path_to_uploaded_file_in_temp_dir);
123 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('qpl_import_no_items'), true);
124 return null;
125 }
126
127 $complete = 0;
128 $incomplete = 0;
129 foreach ($founditems as $item) {
130 if ($item['type'] !== '') {
131 $complete++;
132 } else {
133 $incomplete++;
134 }
135 }
136
137 if ($complete == 0) {
138 \ilFileUtils::delDir($importdir);
139 $this->deleteUploadedImportFile($path_to_uploaded_file_in_temp_dir);
140 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('qpl_import_non_ilias_files'), true);
141 return null;
142 }
143
144 $options = [];
145 $values = [];
146 foreach ($founditems as $item) {
147 $options[$item['ident']] = "{$item['title']} ({$this->getLabelForQuestionType($item['type'])})";
148 $values[] = $item['ident'];
149 }
150 $select_questions = $this->ui_factory->input()->field()->multiSelect(
151 $this->lng->txt('questions'),
153 )->withValue($values);
154
155 return $this->ui_factory->input()->container()->form()->standard(
156 $this->ctrl->getFormActionByClass(self::class, $form_cmd),
157 ['selected_questions' => $select_questions]
158 )->withSubmitLabel($this->lng->txt('import'));
159 }
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().

+ Here is the call graph for this function:

◆ buildResultsFilePath()

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

Definition at line 71 of file TestQuestionsImportTrait.php.

71 : string
72 {
73 return $importdir . DIRECTORY_SEPARATOR
74 . str_replace('tst', 'results', $subdir) . '.xml';
75 }

◆ getImportTempDirectory()

ILIAS\TestQuestionPool\Import\getImportTempDirectory ( )
private

Definition at line 77 of file TestQuestionsImportTrait.php.

77 : string
78 {
79 return $this->import_temp_directory;
80 }

◆ getLabelForPluginQuestionTypes()

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

Definition at line 178 of file TestQuestionsImportTrait.php.

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

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 161 of file TestQuestionsImportTrait.php.

161 : string
162 {
163 if ($this->lng->exists($type)) {
164 return $this->lng->txt($type);
165 }
166
172 if (array_key_exists($type, $this->old_export_question_types)) {
173 return $this->lng->txt($this->old_export_question_types[$type]);
174 }
175 return $this->getLabelForPluginQuestionTypes($type);
176 }

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 88 of file TestQuestionsImportTrait.php.

93 : array {
95 $form_cmd,
96 $importdir,
97 $qtifile
98 )->withRequest($request)->getData();
99 if (isset($data['selected_questions'])) {
100 return $data['selected_questions'];
101 }
102 return [];
103 }
$request
@ilCtrl_Calls ilObjLearningSequenceContentGUI: ilObjLearningSequenceConditionsGUI
Definition: ltiauth.php:39
buildImportQuestionsSelectionForm(string $form_cmd, string $importdir, string $qtifile, ?string $path_to_uploaded_file_in_temp_dir=null)
$data
Definition: storeScorm.php:45

References $data.

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 33 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
Deprecated:
12: Use ILIAS\Test\ExportImport\TestImporter instead

Definition at line 29 of file TestQuestionsImportTrait.php.