19declare(strict_types=1);
23use Psr\Http\Message\ServerRequestInterface;
28 private string $import_temp_directory =
CLIENT_DATA_DIR . DIRECTORY_SEPARATOR .
'temp';
46 $subdir = basename($file_to_import,
'.zip');
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(
63 $importdir . DIRECTORY_SEPARATOR . basename($importdir) .
'.xml',
64 $importdir . DIRECTORY_SEPARATOR . preg_replace(
'/test|tst|qpl/',
'qti', basename($importdir)) .
'.xml'
70 return $importdir . DIRECTORY_SEPARATOR
71 . str_replace(
'tst',
'results', $subdir) .
'.xml';
76 return $this->import_temp_directory;
81 $subdir = basename($file_to_import,
'.zip');
82 return $this->import_temp_directory . DIRECTORY_SEPARATOR . $subdir;
89 ServerRequestInterface $request
95 )->withRequest($request)->getData();
96 if (isset(
$data[
'selected_questions'])) {
97 return $data[
'selected_questions'];
106 ?
string $path_to_uploaded_file_in_temp_dir =
null
116 $founditems = &$qtiParser->getFoundItems();
117 if ($path_to_uploaded_file_in_temp_dir !==
null && $founditems === []) {
119 $this->deleteUploadedImportFile($path_to_uploaded_file_in_temp_dir);
120 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'qpl_import_no_items'),
true);
126 foreach ($founditems as $item) {
127 if ($item[
'type'] !==
'') {
134 if ($complete == 0) {
136 $this->deleteUploadedImportFile($path_to_uploaded_file_in_temp_dir);
137 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'qpl_import_non_ilias_files'),
true);
143 foreach ($founditems as $item) {
144 $options[$item[
'ident']] =
"{$item['title']} ({$this->getLabelForQuestionType($item['type'])})";
145 $values[] = $item[
'ident'];
147 $select_questions = $this->ui_factory->input()->field()->multiSelect(
148 $this->
lng->txt(
'questions'),
150 )->withValue($values);
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'));
160 if ($this->
lng->exists($type)) {
161 return $this->
lng->txt($type);
169 if (array_key_exists($type, $this->old_export_question_types)) {
170 return $this->
lng->txt($this->old_export_question_types[$type]);
177 foreach ($this->component_factory->getActivePluginsInSlot(
'qst') as $pl) {
178 if ($pl->getQuestionType() === $type) {
179 return $pl->getQuestionTypeTranslation();
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
const QT_MULTIPLE_CHOICE_MR
const QT_MULTIPLE_CHOICE_SR
startParsing()
stores xml data in array
buildImportDirectoriesFromContainerImport(string $importdir)
trait TestQuestionsImportTrait
buildImportQuestionsSelectionForm(string $form_cmd, string $importdir, string $qtifile, ?string $path_to_uploaded_file_in_temp_dir=null)
getLabelForQuestionType(string $type)
buildImportDirectoryFromImportFile(string $file_to_import)
buildImportDirectoriesFromImportFile(string $file_to_import)
getLabelForPluginQuestionTypes(string $type)
array $old_export_question_types
buildResultsFilePath(string $importdir, string $subdir)
retrieveSelectedQuestionsFromImportQuestionsSelectionForm(string $form_cmd, string $importdir, string $qtifile, ServerRequestInterface $request)