ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\TestQuestionPool\Import Namespace Reference

Functions

array 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.

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

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  }
+ Here is the caller graph for this function:

◆ buildImportDirectoriesFromImportFile()

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

Definition at line 44 of file TestQuestionsImportTrait.php.

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

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  }
+ 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.

Referenced by ilObjTest\fromXML().

79  : string
80  {
81  $subdir = basename($file_to_import, '.zip');
82  return $this->import_temp_directory . DIRECTORY_SEPARATOR . $subdir;
83  }
+ 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.

References ILIAS\Repository\ctrl(), ilFileUtils\delDir(), ilQTIParser\IL_MO_VERIFY_QTI, ILIAS\Repository\lng(), null, and ILIAS\UI\Implementation\Component\Input\withValue().

Referenced by ilObjTestGUI\importFile(), ilObjQuestionPoolGUI\importFile(), ilObjQuestionPoolGUI\importQuestionsFile(), and ILIAS\TestQuestionPool\Import\retrieveSelectedQuestionsFromImportQuestionsSelectionForm().

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61
+ 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.

Referenced by ilObjTestGUI\importFile(), and ilTestImporter\importXmlRepresentation().

68  : string
69  {
70  return $importdir . DIRECTORY_SEPARATOR
71  . str_replace('tst', 'results', $subdir) . '.xml';
72  }
+ Here is the caller graph for this function:

◆ getImportTempDirectory()

ILIAS\TestQuestionPool\Import\getImportTempDirectory ( )
private

Definition at line 74 of file TestQuestionsImportTrait.php.

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

74  : string
75  {
76  return $this->import_temp_directory;
77  }
+ Here is the caller graph for this function:

◆ getLabelForPluginQuestionTypes()

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

Definition at line 175 of file TestQuestionsImportTrait.php.

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

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  }
+ 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.

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

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  }
+ 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.

References $data, and ILIAS\TestQuestionPool\Import\buildImportQuestionsSelectionForm().

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

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)
+ Here is the call graph for this function:
+ 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
const QT_ORDERING

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