ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjQuestionPoolGUI.php
Go to the documentation of this file.
1 <?php
2 
19 require_once './Modules/Test/classes/inc.AssessmentConstants.php';
20 
30 
55 {
59  private \ILIAS\Filesystem\Util\Archive\LegacyArchives $archives;
60  protected Service $taxonomy;
61  public ?ilObject $object;
63  protected ilDBInterface $db;
64  protected RBACServices $rbac;
66  protected ilHelpGUI $help;
76 
77  public function __construct()
78  {
80  global $DIC;
81  $this->type = 'qpl';
82 
83  $this->db = $DIC['ilDB'];
84  $this->rbac = $DIC->rbac();
85  $this->log = $DIC['ilLog'];
86  $this->help = $DIC['ilHelp'];
87  $this->global_screen = $DIC['global_screen'];
88  $this->component_factory = $DIC['component.factory'];
89  $this->component_repository = $DIC['component.repository'];
90  $this->navigation_history = $DIC['ilNavigationHistory'];
91  $this->ui_service = $DIC->uiService();
92  $this->questioninfo = $DIC->testQuestionPool()->questionInfo();
93  $this->qplrequest = $DIC->testQuestionPool()->internal()->request();
94  $this->taxonomy = $DIC->taxonomy();
95  $this->http = $DIC->http();
96  $this->http_request = $this->http->request();
97  $this->data_factory = new DataFactory();
98  $this->archives = $DIC->legacyArchives();
99  parent::__construct('', $this->qplrequest->raw('ref_id'), true, false);
100 
101  $this->ctrl->saveParameter($this, [
102  'ref_id',
103  'test_ref_id',
104  'calling_test',
105  'test_express_mode',
106  'q_id',
107  'tax_node',
108  'consumer_context'
109  ]);
110  $this->ctrl->saveParameterByClass('ilAssQuestionPageGUI', 'consumer_context');
111  $this->ctrl->saveParameterByClass('ilobjquestionpoolgui', 'consumer_context');
112 
113  $this->lng->loadLanguageModule('assessment');
114 
115  $here_uri = $this->data_factory->uri($this->request->getUri()->__toString());
116  $url_builder = new URLBuilder($here_uri);
117  $query_params_namespace = ['qpool', 'table'];
118  list($url_builder, $action_parameter_token, $row_id_token) = $url_builder->acquireParameters(
119  $query_params_namespace,
120  "action", //this is the actions's parameter name
121  "qids" //this is the parameter name to be used for row-ids
122  );
123  $this->url_builder = $url_builder;
124  $this->action_parameter_token = $action_parameter_token;
125  $this->row_id_token = $row_id_token;
126 
127  $this->notes_service->gui()->initJavascript();
128  }
129 
130  protected function getQueryParamString(string $param): ?string
131  {
132  if (!$this->request_wrapper->has($param)) {
133  return null;
134  }
135  $trafo = $this->refinery->byTrying([
136  $this->refinery->kindlyTo()->null(),
137  $this->refinery->kindlyTo()->string()
138  ]);
139  return $this->request_wrapper->retrieve($param, $trafo);
140  }
141 
142  protected function getQueryParamInt(string $param): ?int
143  {
144  if (!$this->request_wrapper->has($param)) {
145  return null;
146  }
147  $trafo = $this->refinery->byTrying([
148  $this->refinery->kindlyTo()->null(),
149  $this->refinery->kindlyTo()->int()
150  ]);
151  return $this->request_wrapper->retrieve($param, $trafo);
152  }
153 
154  public function executeCommand(): void
155  {
156  $ilUser = $this->user;
157  $ilAccess = $this->access;
158  $ilNavigationHistory = $this->navigation_history;
159  $tpl = $this->tpl;
160  $ilCtrl = $this->ctrl;
162  $ilTabs = $this->tabs_gui;
163  $lng = $this->lng;
164  $ilDB = $this->db;
165  $component_repository = $this->component_repository;
167  $randomGroup = $this->refinery->random();
168 
169  $writeAccess = $ilAccess->checkAccess('write', '', $this->qplrequest->getRefId());
170 
171  if ((!$ilAccess->checkAccess('read', '', $this->qplrequest->getRefId()))
172  && (!$ilAccess->checkAccess('visible', '', $this->qplrequest->getRefId()))) {
173  $ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
174  }
175 
176  if (!$this->getCreationMode() &&
177  $ilAccess->checkAccess('read', '', $this->qplrequest->getRefId())) {
178  if ('qpl' === $this->object->getType()) {
179  $ilNavigationHistory->addItem(
180  $this->qplrequest->getRefId(),
181  ilLink::_getLink($this->qplrequest->getRefId(), "qpl"),
182  'qpl',
183  );
184  }
185  }
186 
187  $cmd = $this->ctrl->getCmd('questions');
188  $next_class = $this->ctrl->getNextClass($this);
189  $q_id = $this->getQueryParamInt('q_id');
190 
191  if (in_array($next_class, ['', 'ilobjquestionpoolgui']) && $cmd == 'questions') {
192  $q_id = -1;
193  }
194 
195  $this->prepareOutput();
196 
197  $this->tpl->addCss(ilUtil::getStyleSheetLocation('output', 'test_print.css', 'Modules/Test'), 'print');
198 
199  $q_type = '';
200  if (!(in_array($next_class, ['', 'ilobjquestionpoolgui']) && $cmd == 'questions') && $q_id < 1) {
201  $q_type = $this->qplrequest->raw('sel_question_types');
202  }
203  if ($cmd !== 'createQuestion' && $cmd !== 'createQuestionForTest'
204  && $next_class != 'ilassquestionpagegui') {
205  if (($this->qplrequest->raw('test_ref_id') != '') || ($this->qplrequest->raw('calling_test'))) {
206  $ref_id = $this->qplrequest->raw('test_ref_id');
207  if (!$ref_id) {
208  $ref_id = $this->qplrequest->raw('calling_test');
209  }
210  }
211  }
212  switch ($next_class) {
213  case 'ilcommonactiondispatchergui':
215  $this->ctrl->forwardCommand($gui);
216  break;
217 
218  case 'ilobjectmetadatagui':
219  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
220  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
221  }
222  $md_gui = new ilObjectMetaDataGUI($this->object);
223  $this->ctrl->forwardCommand($md_gui);
224  break;
225 
226  case 'ilassquestionpreviewgui':
227  if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) {
228  $this->redirectAfterMissingWrite();
229  }
230 
231  $this->ctrl->saveParameter($this, 'q_id');
232  $gui = new ilAssQuestionPreviewGUI(
233  $this->ctrl,
234  $this->rbac_system,
235  $this->tabs_gui,
236  $this->tpl,
237  $this->lng,
238  $ilDB,
239  $ilUser,
240  $randomGroup,
241  $this->global_screen,
242  $this->http,
243  $this->refinery
244  );
245 
246  $gui->initQuestion((int) $this->qplrequest->raw('q_id'), $this->object->getId());
247  $gui->initPreviewSettings($this->object->getRefId());
248  $gui->initPreviewSession($ilUser->getId(), $this->fetchAuthoringQuestionIdParamater());
249  $gui->initHintTracking();
250 
251  $ilHelp = $this->help;
252  $ilHelp->setScreenIdComponent('qpl');
253 
254  $this->ctrl->forwardCommand($gui);
255  break;
256 
257  case 'ilassquestionpagegui':
258  if ($cmd == 'finishEditing') {
259  $this->ctrl->redirectByClass('ilassquestionpreviewgui', 'show');
260  break;
261  }
262  if ($cmd === 'edit' && !$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
263  $this->redirectAfterMissingWrite();
264  }
265  $this->tpl->setCurrentBlock('ContentStyle');
266  $this->tpl->setVariable('LOCATION_CONTENT_STYLESHEET', ilObjStyleSheet::getContentStylePath(0));
267  $this->tpl->parseCurrentBlock();
268 
269  $this->tpl->setCurrentBlock('SyntaxStyle');
270  $this->tpl->setVariable('LOCATION_SYNTAX_STYLESHEET', ilObjStyleSheet::getSyntaxStylePath());
271  $this->tpl->parseCurrentBlock();
273  $q_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
274  $q_gui->setQuestionTabs();
275  $q_gui->outAdditionalOutput();
276  $q_gui->object->setObjId($this->object->getId());
277 
278  $q_gui->setTargetGuiClass(null);
279  $q_gui->setQuestionActionCmd('');
280 
281  if ($this->object->getType() == 'qpl') {
282  $q_gui->addHeaderAction();
283  }
284 
285  $question = $q_gui->object;
286 
287  if ($this->questioninfo->isInActiveTest($question->getObjId())) {
288  $this->tpl->setOnScreenMessage(
289  'failure',
290  $this->lng->txt('question_is_part_of_running_test'),
291  true
292  );
293  $this->ctrl->redirectByClass('ilAssQuestionPreviewGUI', ilAssQuestionPreviewGUI::CMD_SHOW);
294  }
295 
296  $this->ctrl->saveParameter($this, 'q_id');
297  $this->lng->loadLanguageModule('content');
298  $this->ctrl->setReturnByClass('ilAssQuestionPageGUI', 'view');
299  $this->ctrl->setReturn($this, 'questions');
300  $page_gui = new ilAssQuestionPageGUI($this->qplrequest->getQuestionId());
301  $page_gui->obj->addUpdateListener(
302  $question,
303  'updateTimestamp'
304  );
305  $page_gui->setEditPreview(true);
306  $page_gui->setEnabledTabs(false);
307  if (strlen(
308  $this->ctrl->getCmd()
309  ) == 0 && !isset($_POST['editImagemapForward_x'])) { // workaround for page edit imagemaps, keep in mind
310  $this->ctrl->setCmdClass(get_class($page_gui));
311  $this->ctrl->setCmd('preview');
312  }
313  $page_gui->setQuestionHTML([$q_gui->object->getId() => $q_gui->getPreview(true)]);
314  $page_gui->setTemplateTargetVar('ADM_CONTENT');
315  $page_gui->setOutputMode('edit');
316  $page_gui->setHeader($question->getTitleForHTMLOutput());
317  $page_gui->setPresentationTitle($question->getTitleForHTMLOutput());
318  $ret = $this->ctrl->forwardCommand($page_gui);
319  if ($ret != '') {
320  $tpl->setContent($ret);
321  }
322  break;
323 
324  case 'ilpermissiongui':
325  $perm_gui = new ilPermissionGUI($this);
326  $this->ctrl->forwardCommand($perm_gui);
327  break;
328 
329  case 'ilobjectcopygui':
330  $cp = new ilObjectCopyGUI($this);
331  $cp->setType('qpl');
332  $this->ctrl->forwardCommand($cp);
333  break;
334 
335  case 'ilquestionpoolexportgui':
336  $exp_gui = new ilQuestionPoolExportGUI($this);
337  $exp_gui->addFormat('xml', $this->lng->txt('qpl_export_xml'));
338  $exp_gui->addFormat('xlsx', $this->lng->txt('qpl_export_excel'), $this, 'createExportExcel');
339  $ret = $this->ctrl->forwardCommand($exp_gui);
340  break;
341 
342  case 'ilinfoscreengui':
343  $this->infoScreenForward();
344  break;
345 
346  case 'ilassquestionhintsgui':
347  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
348  $this->redirectAfterMissingWrite();
349  }
350 
351  $this->ctrl->setReturn($this, 'questions');
352  $questionGUI = assQuestionGUI::_getQuestionGUI(
353  $q_type ?? '',
355  );
356  $questionGUI->object->setObjId($this->object->getId());
357  $questionGUI->setQuestionTabs();
358 
359  if ($this->questioninfo->isInActiveTest($questionGUI->object->getObjId())) {
360  $this->tpl->setOnScreenMessage(
361  'failure',
362  $this->lng->txt('question_is_part_of_running_test'),
363  true
364  );
365  $this->ctrl->redirectByClass('ilAssQuestionPreviewGUI', ilAssQuestionPreviewGUI::CMD_SHOW);
366  }
367 
368  $ilHelp = $this->help;
369  $ilHelp->setScreenIdComponent('qpl');
370 
371  if ($this->object->getType() == 'qpl' && $writeAccess) {
372  $questionGUI->addHeaderAction();
373  }
374  $gui = new ilAssQuestionHintsGUI($questionGUI);
375 
376  $gui->setEditingEnabled(
377  $this->access->checkAccess('write', '', $this->object->getRefId())
378  );
379 
380  $ilCtrl->forwardCommand($gui);
381 
382  break;
383 
384  case 'illocalunitconfigurationgui':
385  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
386  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
387  }
388  $questionGUI = assQuestionGUI::_getQuestionGUI($q_type, $this->fetchAuthoringQuestionIdParamater());
389  $questionGUI->object->setObjId($this->object->getId());
390  $questionGUI->setQuestionTabs();
391 
392  $this->ctrl->setReturn($this, 'questions');
393  $gui = new ilLocalUnitConfigurationGUI(
394  new ilUnitConfigurationRepository($this->qplrequest->getQuestionId())
395  );
396  $ilCtrl->forwardCommand($gui);
397  break;
398 
399  case 'ilassquestionfeedbackeditinggui':
400  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
401  $this->redirectAfterMissingWrite();
402  }
403 
404  $this->ctrl->setReturn($this, 'questions');
405  $questionGUI = assQuestionGUI::_getQuestionGUI($q_type, $this->fetchAuthoringQuestionIdParamater());
406  $questionGUI->object->setObjId($this->object->getId());
407  $questionGUI->setQuestionTabs();
408 
409  if ($this->questioninfo->isInActiveTest($questionGUI->object->getObjId())) {
410  $this->tpl->setOnScreenMessage(
411  'failure',
412  $this->lng->txt('question_is_part_of_running_test'),
413  true
414  );
415  $this->ctrl->redirectByClass('ilAssQuestionPreviewGUI', ilAssQuestionPreviewGUI::CMD_SHOW);
416  }
417 
418  $ilHelp = $this->help;
419  $ilHelp->setScreenIdComponent('qpl');
420 
421  if ($this->object->getType() == 'qpl' && $writeAccess) {
422  $questionGUI->addHeaderAction();
423  }
424  $gui = new ilAssQuestionFeedbackEditingGUI($questionGUI, $ilCtrl, $ilAccess, $tpl, $ilTabs, $lng);
425  $ilCtrl->forwardCommand($gui);
426 
427  break;
428 
429  case 'ilobjquestionpoolsettingsgeneralgui':
431  $ilCtrl,
432  $ilAccess,
433  $lng,
434  $tpl,
435  $ilTabs,
436  $this,
437  $this->refinery,
438  $this->ui_factory,
439  $this->ui_renderer,
440  $this->http_request,
441  );
442  $this->ctrl->forwardCommand($gui);
443  break;
444 
445  case strtolower(ilTaxonomySettingsGUI::class):
446  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
447  $this->redirectAfterMissingWrite();
448  }
449 
451  $obj = $this->object;
453  $this->object,
454  $ilDB,
455  $this->refinery,
456  $component_repository,
457  $ilCtrl,
458  $ilTabs,
459  $lng,
460  $this->taxonomy
461  );
462 
463  $forwarder->forward();
464 
465  break;
466 
467  case 'ilquestionpoolskilladministrationgui':
468  $obj = $this->object;
470  $ilias,
471  $ilCtrl,
472  $this->refinery,
473  $ilAccess,
474  $ilTabs,
475  $tpl,
476  $lng,
477  $ilDB,
478  $component_repository,
479  $obj,
480  $this->ref_id
481  );
482 
483  $this->ctrl->forwardCommand($gui);
484 
485  break;
486 
487 
488  case 'ilobjquestionpoolgui':
489  case '':
490 
491  //table actions.
492  if ($action = $this->getQueryParamString($this->action_parameter_token)) {
493  $ids = $this->request_wrapper->retrieve(
494  $this->row_id_token->getName(),
495  $this->refinery->custom()->transformation(fn($v) => $v)
496  );
497 
498  if (is_null($ids)) {
499  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_questions_selected'), true);
500  $this->ctrl->redirect($this, 'questions');
501  }
502  if ($ids[0] === 'ALL_OBJECTS') {
503  $ids = $this->object->getAllQuestionIds();
504  }
505  if (!is_array($ids)) {
506  $ids = explode(',', $ids);
507  }
508  $ids = array_map('intval', $ids);
509 
510  $class = strtolower(assQuestionGUI::_getGUIClassNameForId(current($ids)));
511  $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", current($ids));
512  $this->ctrl->setParameterByClass("ilAssQuestionPreviewGUI", "q_id", current($ids));
513  $this->ctrl->setParameterByClass('ilAssQuestionFeedbackEditingGUI', 'q_id', current($ids));
514  $this->ctrl->setParameterByClass('ilAssQuestionHintsGUI', 'q_id', current($ids));
515  $this->ctrl->setParameterByClass($class, "q_id", current($ids));
516 
517  switch ($action) {
518  case 'preview':
519  $url = $this->ctrl->getLinkTargetByClass('ilAssQuestionPreviewGUI', ilAssQuestionPreviewGUI::CMD_SHOW);
520  $this->ctrl->redirectToURL($url);
521  break;
522  case 'statistics':
523  $url = $this->ctrl->getLinkTargetByClass('ilAssQuestionPreviewGUI', ilAssQuestionPreviewGUI::CMD_STATISTICS);
524  $this->ctrl->redirectToURL($url);
525  break;
526  case 'edit_question':
527  $url = $this->ctrl->getLinkTargetByClass($class, 'editQuestion');
528  $this->ctrl->redirectToURL($url);
529  break;
530  case 'edit_page':
531  $url = $this->ctrl->getLinkTargetByClass('ilAssQuestionPageGUI', 'edit');
532  $this->ctrl->redirectToURL($url);
533  break;
534  case 'feedback':
535  $url = $this->ctrl->getLinkTargetByClass('ilAssQuestionFeedbackEditingGUI', ilAssQuestionFeedbackEditingGUI::CMD_SHOW);
536  $this->ctrl->redirectToURL($url);
537  break;
538  case 'hints':
539  $url = $this->ctrl->getLinkTargetByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
540  $this->ctrl->redirectToURL($url);
541  break;
542  case 'move':
543  $ret = $this->moveQuestions($ids);
544  $this->ctrl->redirect($this, 'questions');
545  break;
546  case 'copy':
547  $this->copyQuestions($ids);
548  $this->ctrl->redirect($this, 'questions');
549  break;
550  case 'delete':
551  $this->confirmDeleteQuestions($ids);
552  break;
553  case 'export':
554  $this->exportQuestions($ids);
555  $this->ctrl->redirect($this, 'questions');
556  break;
557  case 'comments':
560  $this->object->getRefId(),
561  'quest',
562  $this->object->getId(),
563  'quest',
564  current($ids)
565  );
566  echo ''
567  . '<script>'
568  . ' event = new Event("click");'
570  . '</script>'
571  ;
572  exit();
573 
574  default:
575  throw new \Exception("'$action'" . " not implemented");
576  }
577  break;
578  }
579 
580 
581  if ($cmd == 'questions') {
582  $this->ctrl->setParameter($this, 'q_id', '');
583  }
584  $cmd .= 'Object';
585  $ret = $this->$cmd();
586  break;
587 
588  default:
589  if (in_array($cmd, ['editQuestion', 'save', 'suggestedsolution']) && !$ilAccess->checkAccess(
590  'write',
591  '',
592  $this->object->getRefId()
593  )) {
594  $this->redirectAfterMissingWrite();
595  }
596 
597  if ($cmd === 'assessment' &&
598  $this->object->getType() === 'tst' &&
599  !$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
600  $this->redirectAfterMissingWrite();
601  }
602 
603  $this->ctrl->setReturn($this, 'questions');
604 
605  $questionGUI = assQuestionGUI::_getQuestionGUI($q_type, $this->fetchAuthoringQuestionIdParamater());
606  $questionGUI->setEditContext(assQuestionGUI::EDIT_CONTEXT_AUTHORING);
607  $questionGUI->object->setObjId($this->object->getId());
608 
609  if (in_array(
610  $cmd,
611  ['editQuestion', 'save', 'suggestedsolution']
612  ) && $this->questioninfo->isInActiveTest($questionGUI->object->getObjId())
613  ) {
614  $this->tpl->setOnScreenMessage(
615  'failure',
616  $this->lng->txt('question_is_part_of_running_test'),
617  true
618  );
619  $this->ctrl->redirectByClass('ilAssQuestionPreviewGUI', ilAssQuestionPreviewGUI::CMD_SHOW);
620  }
621 
622  if ($this->object->getType() == 'qpl') {
623  $questionGUI->setTaxonomyIds($this->object->getTaxonomyIds());
624 
625  if ($writeAccess) {
626  $questionGUI->addHeaderAction();
627  }
628  }
629  $questionGUI->setQuestionTabs();
630 
631  $ilHelp = $this->help;
632  $ilHelp->setScreenIdComponent('qpl');
633  $ret = $this->ctrl->forwardCommand($questionGUI);
634  break;
635  }
636 
637  if (!(strtolower($this->qplrequest->raw('baseClass')) == 'iladministrationgui'
638  || strtolower($this->qplrequest->raw('baseClass')) == 'ilrepositorygui')
639  && $this->getCreationMode() != true) {
640  $this->tpl->printToStdout();
641  }
642  }
643 
644  protected function redirectAfterMissingWrite()
645  {
646  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_permission'), true);
647  $target_class = get_class($this->object) . 'GUI';
648  $this->ctrl->setParameterByClass($target_class, 'ref_id', $this->ref_id);
649  $this->ctrl->redirectByClass($target_class);
650  }
651 
656  protected function exportObject(): void
657  {
658  $this->ctrl->redirectByClass('ilQuestionPoolExportGUI');
659  }
660 
661  public function downloadFileObject(): void
662  {
663  $file = explode('_', $this->qplrequest->raw('file_id'));
664  $fileObj = new ilObjFile($file[count($file) - 1], false);
665  $fileObj->sendFile();
666  exit;
667  }
668 
672  public function fullscreenObject(): void
673  {
674  $page_gui = new ilAssQuestionPageGUI($this->qplrequest->raw('pg_id'));
675  $page_gui->showMediaFullscreen();
676  }
677 
681  public function download_paragraphObject(): void
682  {
683  $pg_obj = new ilAssQuestionPage($this->qplrequest->raw('pg_id'));
684  $pg_obj->sendParagraph($this->qplrequest->raw('par_id'), $this->qplrequest->raw('downloadtitle'));
685  exit;
686  }
687 
691  public function uploadQplObject($questions_only = false)
692  {
693  $this->ctrl->setParameter($this, 'new_type', $this->qplrequest->raw('new_type'));
694  if (!isset($_FILES['xmldoc']) || !isset($_FILES['xmldoc']['error']) || $_FILES['xmldoc']['error'] > UPLOAD_ERR_OK) {
695  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('error_upload'), true);
696  if (!$questions_only) {
697  $this->ctrl->redirect($this, 'create');
698  }
699  return false;
700  }
701 
702  $basedir = $this->createImportDirectory();
703 
704  $xml_file = '';
705  $qti_file = '';
706  $subdir = '';
707 
708  $file = pathinfo($_FILES['xmldoc']['name']);
709  $full_path = $basedir . '/' . $_FILES['xmldoc']['name'];
710 
711  if (strpos($file['filename'], 'qpl') === false
712  && strpos($file['filename'], 'qti') === false) {
713  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('import_file_not_valid'), true);
714  $cmd = $this->ctrl->getCmd() === 'upload' ? 'importQuestions' : 'create';
715  $this->ctrl->redirect($this, $cmd);
716  return;
717  }
718 
719  $this->log->write(__METHOD__ . ': full path ' . $full_path);
720  try {
721  ilFileUtils::moveUploadedFile($_FILES['xmldoc']['tmp_name'], $_FILES['xmldoc']['name'], $full_path);
722  } catch (Error $e) {
723  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('import_file_not_valid'), true);
724  $cmd = $this->ctrl->getCmd() === 'upload' ? 'importQuestions' : 'create';
725  $this->ctrl->redirect($this, $cmd);
726  return;
727  }
728  $this->log->write(__METHOD__ . ': full path ' . $full_path);
729  if (strcmp($_FILES['xmldoc']['type'], 'text/xml') == 0) {
730  $qti_file = $full_path;
732  } else {
733  $this->archives->unzip($full_path);
734 
735  $subdir = basename($file['basename'], '.' . $file['extension']);
737  $xml_file = ilObjQuestionPool::_getImportDirectory() . '/' . $subdir . '/' . $subdir . '.xml';
738  $qti_file = ilObjQuestionPool::_getImportDirectory() . '/' . $subdir . '/' . str_replace(
739  'qpl',
740  'qti',
741  $subdir
742  ) . '.xml';
743  }
744  if (!file_exists($qti_file)) {
745  ilFileUtils::delDir($basedir);
746  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('cannot_find_xml'), true);
747  $cmd = $this->ctrl->getCmd() === 'upload' ? 'importQuestions' : 'create';
748  $this->ctrl->redirect($this, $cmd);
749  return false;
750  }
751  $qtiParser = new ilQTIParser($qti_file, ilQTIParser::IL_MO_VERIFY_QTI, 0, '');
752  $qtiParser->startParsing();
753  $founditems = &$qtiParser->getFoundItems();
754  if (count($founditems) == 0) {
755  ilFileUtils::delDir($basedir);
756 
757  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('qpl_import_no_items'), true);
758  if (!$questions_only) {
759  $this->ctrl->redirect($this, 'create');
760  }
761  return false;
762  }
763 
764  $complete = 0;
765  $incomplete = 0;
766  foreach ($founditems as $item) {
767  if (strlen($item['type'])) {
768  $complete++;
769  } else {
770  $incomplete++;
771  }
772  }
773 
774  if ($complete == 0) {
775  ilFileUtils::delDir($basedir);
776 
777  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('qpl_import_non_ilias_files'), true);
778  if (!$questions_only) {
779  $this->ctrl->redirect($this, 'create');
780  }
781  return false;
782  }
783 
784  ilSession::set('qpl_import_xml_file', $xml_file);
785  ilSession::set('qpl_import_qti_file', $qti_file);
786  ilSession::set('qpl_import_subdir', $subdir);
787 
788  $this->tpl->addBlockFile(
789  'ADM_CONTENT',
790  'adm_content',
791  'tpl.qpl_import_verification.html',
792  'Modules/TestQuestionPool'
793  );
794  $table = new ilQuestionPoolImportVerificationTableGUI($this, 'uploadQpl');
795  $rows = [];
796 
797  foreach ($founditems as $item) {
798  $row = [
799  'title' => $item['title'],
800  'ident' => $item['ident'],
801  ];
802  switch ($item['type']) {
804  $type = $this->lng->txt('assClozeTest');
805  break;
807  $type = $this->lng->txt('assImagemapQuestion');
808  break;
810  $type = $this->lng->txt('assMatchingQuestion');
811  break;
813  $type = $this->lng->txt('assMultipleChoice');
814  break;
816  $type = $this->lng->txt('assKprimChoice');
817  break;
819  $type = $this->lng->txt('assLongMenu');
820  break;
822  $type = $this->lng->txt('assSingleChoice');
823  break;
825  $type = $this->lng->txt('assOrderingQuestion');
826  break;
828  $type = $this->lng->txt('assTextQuestion');
829  break;
831  $type = $this->lng->txt('assNumeric');
832  break;
834  $type = $this->lng->txt('assTextSubset');
835  break;
836  default:
837  $type = $this->lng->txt($item['type']);
838  break;
839  }
840 
841  if (strcmp($type, '-' . $item['type'] . '-') == 0) {
842  $component_factory = $this->component_factory;
843  $component_repository = $this->component_repository;
844  foreach ($component_factory->getActivePluginsInSlot('qst') as $pl) {
845  if (strcmp($pl->getQuestionType(), $item['type']) == 0) {
846  $type = $pl->getQuestionTypeTranslation();
847  }
848  }
849  }
850 
851  $row['type'] = $type;
852 
853  $rows[] = $row;
854  }
855  $table->setData($rows);
856 
857  if (is_file($xml_file)
858  && !$questions_only) {
859  $this->tpl->setCurrentBlock("import_qpl");
860  try {
861  $fh = fopen($xml_file, 'r');
862  $xml = fread($fh, filesize($xml_file));
863  fclose($fh);
864  } catch (Exception $e) {
865  return false;
866  }
867  if (preg_match('/<ContentObject.*?MetaData.*?General.*?Title[^>]*?>([^<]*?)</', $xml, $matches)) {
868  $this->tpl->setVariable('VALUE_NEW_QUESTIONPOOL', $matches[1]);
869  }
870 
871  $this->tpl->setVariable("TEXT_CREATE_NEW_QUESTIONPOOL", $this->lng->txt("qpl_import_create_new_qpl"));
872  $this->tpl->parseCurrentBlock();
873  }
874 
875  $this->tpl->setCurrentBlock('adm_content');
876  $this->tpl->setVariable('FOUND_QUESTIONS_INTRODUCTION', $this->lng->txt('qpl_import_verify_found_questions'));
877  if ($questions_only) {
878  $this->tpl->setVariable('VERIFICATION_HEADING', $this->lng->txt('import_questions_into_qpl'));
879  $this->tpl->setVariable('FORMACTION', $this->ctrl->getFormAction($this));
880  } else {
881  $this->tpl->setVariable('VERIFICATION_HEADING', $this->lng->txt('import_qpl'));
882 
883  $this->ctrl->setParameter($this, 'new_type', $this->type);
884  $this->tpl->setVariable('FORMACTION', $this->ctrl->getFormAction($this));
885  }
886 
887  $value_questions_only = 0;
888  if ($questions_only) {
889  $value_questions_only = 1;
890  }
891  $this->tpl->setVariable('VALUE_QUESTIONS_ONLY', $value_questions_only);
892  $this->tpl->setVariable('VERIFICATION_TABLE', $table->getHtml());
893  $this->tpl->setVariable('VERIFICATION_FORM_NAME', $table->getFormName());
894 
895  $this->tpl->parseCurrentBlock();
896 
897  return true;
898  }
899 
900  private function createImportDirectory(): string
901  {
902  $qpl_data_dir = ilFileUtils::getDataDir() . '/qpl_data';
903  ilFileUtils::makeDir($qpl_data_dir);
904 
905  if (!is_writable($qpl_data_dir)) {
906  $this->error->raiseError(
907  'Questionpool Data Directory (' . $qpl_data_dir
908  . ') not writeable.',
909  $this->error->FATAL
910  );
911  }
912 
913  $qpl_dir = $qpl_data_dir . '/qpl_import';
914  ilFileUtils::makeDir($qpl_dir);
915  if (!@is_dir($qpl_dir)) {
916  $this->error->raiseError('Creation of Questionpool Directory failed.', $this->error->FATAL);
917  }
918  return $qpl_dir;
919  }
920 
921  public function importVerifiedFileObject(): void
922  {
923 
924  if ($this->creation_mode
925  && !$this->checkPermissionBool('create', '', $this->qplrequest->string('new_type'))
926  || !$this->creation_mode
927  && !$this->checkPermissionBool('read', '', $this->object->getType())) {
928  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
929  $this->ctrl->redirect($this, 'create');
930  return;
931  }
932  $title = '';
933  $description = null;
934  if ($this->qplrequest->int('questions_only') === 1) {
935  $newObj = $this->object;
936  $title = $this->object->getTitle();
937  $description = $this->object->getDescription();
938  } else {
939  $newObj = new ilObjQuestionPool(0, true);
940  $newObj->setType($this->qplrequest->raw('new_type'));
941  $newObj->setTitle('dummy');
942  $newObj->setDescription('questionpool import');
943  $newObj->create(true);
944  $newObj->createReference();
945  $newObj->putInTree($this->qplrequest->getRefId());
946  $newObj->setPermissions($this->qplrequest->getRefId());
947 
948  $title = $this->qplrequest->raw('qpl_new');
949  }
950 
951  if (is_string(ilSession::get("qpl_import_dir")) && is_string(ilSession::get("qpl_import_subdir")) && is_file(
952  ilSession::get("qpl_import_dir") . '/' . ilSession::get("qpl_import_subdir") . "/manifest.xml"
953  )) {
954  ilSession::set("qpl_import_idents", $this->qplrequest->raw("ident"));
955 
956  $fileName = ilSession::get('qpl_import_subdir') . '.zip';
957  $fullPath = ilSession::get('qpl_import_dir') . '/' . $fileName;
958  $imp = new ilImport($this->qplrequest->getRefId());
959  $map = $imp->getMapping();
960  $map->addMapping('Modules/TestQuestionPool', 'qpl', 'new_id', $newObj->getId());
961  $imp->importObject($newObj, $fullPath, $fileName, 'qpl', 'Modules/TestQuestionPool', true);
962  } else {
963  $qtiParser = new ilQTIParser(
964  ilSession::get('qpl_import_qti_file'),
966  $newObj->getId(),
967  $this->qplrequest->raw('ident')
968  );
969  $qtiParser->startParsing();
970  // import page data
971  if (strlen(ilSession::get('qpl_import_xml_file'))) {
972  $contParser = new ilQuestionPageParser(
973  $newObj,
974  ilSession::get('qpl_import_xml_file'),
975  ilSession::get('qpl_import_subdir')
976  );
977  $contParser->setQuestionMapping($qtiParser->getImportMapping());
978  $contParser->startParsing();
979  // #20494
980  $newObj->fromXML(ilSession::get('qpl_import_xml_file'));
981  }
982 
983  if ($title !== '') {
984  $newObj->setTitle($title);
985  }
986 
987  if ($description !== null) {
988  $newObj->setDescription($description);
989  }
990 
991  $newObj->update();
992  $newObj->saveToDb();
993  }
995 
996  if ($_POST['questions_only'] == 1) {
997  $this->ctrl->redirect($this, 'questions');
998  } else {
999  $this->tpl->setOnScreenMessage('success', $this->lng->txt('object_imported'), true);
1001  'ilias.php?ref_id=' . $newObj->getRefId() .
1002  '&baseClass=ilObjQuestionPoolGUI'
1003  );
1004  }
1005  }
1006 
1007  public function cancelImportObject(): void
1008  {
1009  if ($_POST['questions_only'] == 1) {
1010  $this->ctrl->redirect($this, 'questions');
1011  } else {
1012  $this->ctrl->redirect($this, 'cancel');
1013  }
1014  }
1015 
1019  public function uploadObject(): void
1020  {
1021  $upload_valid = true;
1022  $form = $this->getImportQuestionsForm();
1023  if ($form->checkInput()) {
1024  if (!$this->uploadQplObject(true)) {
1025  $form->setValuesByPost();
1026  $this->importQuestionsObject($form);
1027  }
1028  } else {
1029  $form->setValuesByPost();
1030  $this->importQuestionsObject($form);
1031  }
1032  }
1033 
1037  public function importQuestionsObject(ilPropertyFormGUI $form = null): void
1038  {
1039  if (!$form instanceof ilPropertyFormGUI) {
1040  $form = $this->getImportQuestionsForm();
1041  }
1042 
1043  $this->tpl->setContent($form->getHtml());
1044  }
1045 
1047  {
1048  $form = new ilPropertyFormGUI();
1049  $form->setTitle($this->lng->txt('import_question'));
1050  $form->setFormAction($this->ctrl->getFormAction($this, 'upload'));
1051 
1052  $file = new ilFileInputGUI($this->lng->txt('select_file'), 'xmldoc');
1053  $file->setRequired(true);
1054  $form->addItem($file);
1055 
1056  $form->addCommandButton('upload', $this->lng->txt('upload'));
1057  $form->addCommandButton('questions', $this->lng->txt('cancel'));
1058 
1059  return $form;
1060  }
1061 
1062  public function createQuestionObject(): void
1063  {
1065  $addContEditMode = $_POST['add_quest_cont_edit_mode'];
1066  } else {
1068  }
1069  $q_gui = assQuestionGUI::_getQuestionGUI($_POST['sel_question_types']);
1070  $q_gui->object->setObjId($this->object->getId());
1071  $q_gui->object->setAdditionalContentEditingMode($addContEditMode);
1072  $q_gui->object->createNewQuestion();
1073  $this->ctrl->setParameterByClass(get_class($q_gui), 'q_id', $q_gui->object->getId());
1074  $this->ctrl->setParameterByClass(get_class($q_gui), 'sel_question_types', $_POST['sel_question_types']);
1075  $this->ctrl->redirectByClass(get_class($q_gui), 'editQuestion');
1076  }
1077 
1078  public function createQuestionForTestObject(): void
1079  {
1080  if (!$this->qplrequest->raw('q_id')) {
1082  $add_cont_edit_mode = $this->qplrequest->raw('add_quest_cont_edit_mode');
1083  } else {
1085  }
1086  $q_gui = assQuestionGUI::_getQuestionGUI($this->qplrequest->raw('sel_question_types'));
1087  $q_gui->object->setObjId($this->object->getId());
1088  $q_gui->object->setAdditionalContentEditingMode($add_cont_edit_mode);
1089  $q_gui->object->createNewQuestion();
1090 
1091  $class = get_class($q_gui);
1092  $q_id = $q_gui->object->getId();
1093  } else {
1094  $class = $this->qplrequest->raw('sel_question_types') . 'gui';
1095  $q_id = $this->qplrequest->raw('q_id');
1096  }
1097 
1098  $this->ctrl->setParameterByClass($class, 'q_id', $q_id);
1099  $this->ctrl->setParameterByClass($class, 'sel_question_types', $this->qplrequest->raw('sel_question_types'));
1100  $this->ctrl->setParameterByClass($class, 'prev_qid', $this->qplrequest->raw('prev_qid'));
1101 
1102  $this->ctrl->redirectByClass($class, 'editQuestion');
1103  }
1104 
1105  public function afterSave(ilObject $new_object): void
1106  {
1107  // always send a message
1108  $this->tpl->setOnScreenMessage('success', $this->lng->txt('object_added'), true);
1109 
1111  'ilias.php?ref_id=' . $new_object->getRefId() .
1112  '&baseClass=ilObjQuestionPoolGUI'
1113  );
1114  }
1115 
1116  public function questionObject(): void
1117  {
1118  // @PHP8-CR: With this probably never working and no detectable usages, it would be a candidate for removal...
1119  // but it is one of the magic command-methods ($cmd.'Object' - pattern) so I live to leave this in here for now
1120  // until it can be further investigated.
1121  $type = $this->qplrequest->raw('sel_question_types');
1122  $this->editQuestionForm($type);
1123  }
1124 
1125  public function confirmDeleteQuestions(array $ids): void
1126  {
1127  $rbacsystem = $this->rbac_system;
1128 
1129  $questionIdsToDelete = array_filter(array_map('intval', $ids));
1130  if (0 === count($questionIdsToDelete)) {
1131  $this->tpl->setOnScreenMessage('info', $this->lng->txt('qpl_delete_select_none'), true);
1132  $this->ctrl->redirect($this, 'questions');
1133  }
1134 
1135  $this->tpl->setOnScreenMessage('question', $this->lng->txt('qpl_confirm_delete_questions'));
1136  $deleteable_questions = $this->object->getDeleteableQuestionDetails($questionIdsToDelete);
1137  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', (($rbacsystem->checkAccess('write', $this->qplrequest->getRefId()) ? true : false)), true);
1138  $table_gui->setShowRowsSelector(false);
1139  $table_gui->setLimit(PHP_INT_MAX);
1140  $table_gui->setEditable($rbacsystem->checkAccess('write', $this->qplrequest->getRefId()));
1141  $table_gui->setData($deleteable_questions);
1142  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
1143  }
1144 
1148  public function deleteQuestionsObject(): void
1149  {
1150  $rbacsystem = $this->rbac_system;
1151 
1152  $questionIdsToDelete = $this->qplrequest->isset('q_id') ? (array) $this->qplrequest->raw('q_id') : [];
1153  if (0 === count($questionIdsToDelete) && $this->qplrequest->isset('q_id')) {
1154  $questionIdsToDelete = [$this->qplrequest->getQuestionId()];
1155  }
1156 
1157  $questionIdsToDelete = array_filter(array_map('intval', $questionIdsToDelete));
1158  if (0 === count($questionIdsToDelete)) {
1159  $this->tpl->setOnScreenMessage('info', $this->lng->txt('qpl_delete_select_none'), true);
1160  $this->ctrl->redirect($this, 'questions');
1161  }
1162 
1163  $this->tpl->setOnScreenMessage('question', $this->lng->txt('qpl_confirm_delete_questions'));
1164  $deleteable_questions = &$this->object->getDeleteableQuestionDetails($questionIdsToDelete);
1165  $table_gui = new ilQuestionBrowserTableGUI(
1166  $this,
1167  'questions',
1168  (($rbacsystem->checkAccess('write', $this->qplrequest->getRefId()) ? true : false)),
1169  true
1170  );
1171  $table_gui->setShowRowsSelector(false);
1172  $table_gui->setLimit(PHP_INT_MAX);
1173  $table_gui->setEditable($rbacsystem->checkAccess('write', $this->qplrequest->getRefId()));
1174  $table_gui->setData($deleteable_questions);
1175  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
1176  }
1177 
1181  public function confirmDeleteQuestionsObject(): void
1182  {
1183  foreach ($_POST['q_id'] as $key => $value) {
1184  $this->object->deleteQuestion($value);
1185  $this->object->cleanupClipboard($value);
1186  }
1187  if (count($_POST['q_id'])) {
1188  $this->tpl->setOnScreenMessage('success', $this->lng->txt('qpl_questions_deleted'), true);
1189  }
1190 
1191  $this->ctrl->setParameter($this, 'q_id', '');
1192  $this->ctrl->redirect($this, 'questions');
1193  }
1194 
1195  public function cancelDeleteQuestionsObject(): void
1196  {
1197  $this->ctrl->redirect($this, 'questions');
1198  }
1199 
1200  public function exportQuestions(array $ids): void
1201  {
1202  if ($ids !== []) {
1203  $qpl_exp = new ilQuestionpoolExport($this->object, 'xml', $ids);
1204  // @PHP8-CR: This seems to be a pointer to an issue with exports. I like to leave this open for now and
1205  // schedule a thorough examination / analysis for later, eventually involved T&A TechSquad
1206  $export_file = $qpl_exp->buildExportFile();
1207  $filename = $export_file;
1208  $filename = preg_replace('/.*\//', '', $filename);
1209  if ($export_file === '') {
1210  $export_file = 'StandIn';
1211  }
1213  exit();
1214  } else {
1215  $this->tpl->setOnScreenMessage('info', $this->lng->txt('qpl_export_select_none'), true);
1216  }
1217  }
1218 
1219  protected function renoveImportFailsObject(): void
1220  {
1221  $qsaImportFails = new ilAssQuestionSkillAssignmentImportFails($this->object->getId());
1222  $qsaImportFails->deleteRegisteredImportFails();
1223 
1224  $this->ctrl->redirect($this, 'infoScreen');
1225  }
1226 
1230  public function questionsObject(): void
1231  {
1232  if (!$this->access->checkAccess("read", "", $this->qplrequest->getRefId())) {
1233  $this->infoScreenForward();
1234  return;
1235  }
1236 
1237  if (get_class($this->object) == 'ilObjTest') {
1238  if ($this->qplrequest->raw('calling_test') > 0) {
1239  $ref_id = $this->qplrequest->raw('calling_test');
1240  $q_id = $this->qplrequest->raw('q_id');
1241 
1242  if ($this->qplrequest->raw('test_express_mode')) {
1243  if ($q_id) {
1245  'ilias.php?ref_id=' . $ref_id . '&q_id=' . $q_id . '&test_express_mode=1&cmd=showPage&cmdClass=iltestexpresspageobjectgui&baseClass=ilObjTestGUI'
1246  );
1247  } else {
1249  'ilias.php?ref_id=' . $ref_id . '&test_express_mode=1&cmd=showPage&cmdClass=iltestexpresspageobjectgui&baseClass=ilObjTestGUI'
1250  );
1251  }
1252  } else {
1253  ilUtil::redirect('ilias.php?baseClass=ilObjTestGUI&ref_id=' . $ref_id . '&cmd=questions');
1254  }
1255  }
1256  }
1257 
1258  $this->object->purgeQuestions();
1259  // reset test_id SESSION variable
1260  ilSession::set('test_id', '');
1261  $qsa_import_fails = new ilAssQuestionSkillAssignmentImportFails($this->object->getId());
1262  if ($qsa_import_fails->failedImportsRegistered()) {
1263  $button = $this->ui_factory->button()->standard(
1264  $this->lng->txt('ass_skl_import_fails_remove_btn'),
1265  $this->ctrl->getLinkTarget($this, 'renoveImportFails')
1266  );
1267  $this->tpl->setOnScreenMessage(
1268  'failure',
1269  $qsa_import_fails->getFailedImportsMessage($this->lng) . '<br />' . $this->ui_renderer->render(
1270  $button
1271  )
1272  );
1273  }
1274 
1275  if ($this->rbac_system->checkAccess('write', $this->qplrequest->getRefId())) {
1276  $btn = $this->ui_factory->button()->primary(
1277  $this->lng->txt('ass_create_question'),
1278  $this->ctrl->getLinkTarget($this, 'createQuestionForm')
1279  );
1280  $this->toolbar->addComponent($btn);
1281 
1282  $btn_import = $this->ui_factory->button()->standard(
1283  $this->lng->txt('import'),
1284  $this->ctrl->getLinkTarget($this, 'importQuestions')
1285  );
1286  $this->toolbar->addComponent($btn_import);
1287 
1288  if (ilSession::get('qpl_clipboard') != null && count(ilSession::get('qpl_clipboard'))) {
1289  $btn_paste = $this->ui_factory->button()->standard(
1290  $this->lng->txt('paste'),
1291  $this->ctrl->getLinkTarget($this, 'paste')
1292  );
1293  $this->toolbar->addComponent($btn_paste);
1294  }
1295  }
1296 
1297  $this->tpl->setPermanentLink($this->object->getType(), $this->object->getRefId());
1298  $this->tpl->setContent($this->getTable());
1299  }
1300 
1302  {
1303  $q_id = $this->qplrequest->getQuestionId();
1304 
1305  if ($this->object->checkQuestionParent($q_id)) {
1306  return $q_id;
1307  }
1308 
1309  throw new ilTestQuestionPoolException('question id does not relate to parent object!');
1310  }
1311 
1312  private function createQuestionFormObject(): void
1313  {
1314  $ilHelp = $this->help;
1315 
1316  $ilHelp->setScreenId('assQuestions');
1317 
1319  $ilHelp->setSubScreenId('createQuestion_editMode');
1320  } else {
1321  $ilHelp->setSubScreenId('createQuestion');
1322  }
1323 
1324  $form = $this->buildCreateQuestionForm();
1325 
1326  $this->tpl->setContent($this->ctrl->getHTML($form));
1327  }
1328 
1330  {
1331  $form = new ilPropertyFormGUI();
1332  $form->setTitle($this->lng->txt('ass_create_question'));
1333  $form->setFormAction($this->ctrl->getFormAction($this));
1334 
1335  $options = [];
1336  foreach ($this->object->getQuestionTypes(false, true, false) as $translation => $data) {
1337  $options[$data['type_tag']] = $translation;
1338  }
1339  $si = new ilSelectInputGUI($this->lng->txt('question_type'), 'sel_question_types');
1340  $si->setOptions($options);
1341 
1342  $form->addItem($si);
1343 
1345  $ri = new ilRadioGroupInputGUI($this->lng->txt('tst_add_quest_cont_edit_mode'), 'add_quest_cont_edit_mode');
1346 
1347  $option_ipe = new ilRadioOption(
1348  $this->lng->txt('tst_add_quest_cont_edit_mode_IPE'),
1350  );
1351  $option_ipe->setInfo($this->lng->txt('tst_add_quest_cont_edit_mode_IPE_info'));
1352  $ri->addOption($option_ipe);
1353 
1354  $option_rte = new ilRadioOption(
1355  $this->lng->txt('tst_add_quest_cont_edit_mode_RTE'),
1357  );
1358  $option_rte->setInfo($this->lng->txt('tst_add_quest_cont_edit_mode_RTE_info'));
1359  $ri->addOption($option_rte);
1360 
1362 
1363  $form->addItem($ri, true);
1364  } else {
1365  $hi = new ilHiddenInputGUI('question_content_editing_type');
1367  $form->addItem($hi, true);
1368  }
1369 
1370  // commands
1371 
1372  $form->addCommandButton('createQuestion', $this->lng->txt('create'));
1373  $form->addCommandButton('questions', $this->lng->txt('cancel'));
1374 
1375  return $form;
1376  }
1377 
1378  public function printObject(): void
1379  {
1380  $this->ctrl->setParameter($this, 'output', 'overview');
1381  $output_link = $this->ctrl->getLinkTarget($this, 'print');
1382  $this->ctrl->setParameter($this, 'output', 'detailed_output_solutions');
1383  $output_link_detailed = $this->ctrl->getLinkTarget($this, 'print');
1384  $this->ctrl->setParameter($this, 'output', 'detailed_output_printview');
1385  $output_link_printview = $this->ctrl->getLinkTarget($this, 'print');
1386 
1387  $mode = $this->ui_factory->dropdown()->standard([
1388  $this->ui_factory->button()->shy($this->lng->txt('overview'), $output_link),
1389  $this->ui_factory->button()->shy($this->lng->txt('detailed_output_solutions'), $output_link_detailed),
1390  $this->ui_factory->button()->shy($this->lng->txt('detailed_output_printview'), $output_link_printview)
1391  ])->withLabel($this->lng->txt('output_mode'));
1392 
1393  $output = $this->qplrequest->raw('output') ?? '';
1394 
1395  $table_gui = new ilQuestionPoolPrintViewTableGUI($this, 'print', $output);
1396  $data = $this->object->getPrintviewQuestions();
1397  $totalPoints = 0;
1398  foreach ($data as $d) {
1399  $totalPoints += $d['points'];
1400  }
1401  $table_gui->setTotalPoints($totalPoints);
1402  $table_gui->initColumns();
1403  $table_gui->setData($data);
1404  $this->tpl->setContent($this->ui_renderer->render($mode) . $table_gui->getHTML());
1405  }
1406 
1407  public function updateObject(): void
1408  {
1409  $this->object->update();
1410  $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
1411  }
1412 
1413  public function pasteObject(): void
1414  {
1415  if (ilSession::get('qpl_clipboard') != null) {
1416  if ($this->object->pasteFromClipboard()) {
1417  $this->tpl->setOnScreenMessage('success', $this->lng->txt('qpl_paste_success'), true);
1418  } else {
1419  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('qpl_paste_error'), true);
1420  }
1421  } else {
1422  $this->tpl->setOnScreenMessage('info', $this->lng->txt('qpl_paste_no_objects'), true);
1423  }
1424  $this->ctrl->redirect($this, 'questions');
1425  }
1426 
1427  public function copyQuestions(array $ids): void
1428  {
1429  if ($ids) {
1430  foreach ($ids as $id) {
1431  $this->object->copyToClipboard($id);
1432  }
1433  $this->tpl->setOnScreenMessage('info', $this->lng->txt('qpl_copy_insert_clipboard'), true);
1434  } else {
1435  $this->tpl->setOnScreenMessage('info', $this->lng->txt('qpl_copy_select_none'), true);
1436  }
1437  }
1438 
1439  public function moveQuestions(array $ids): void
1440  {
1441  if ($ids) {
1442  foreach ($ids as $id) {
1443  $this->object->moveToClipboard($id);
1444  }
1445  $this->tpl->setOnScreenMessage('info', $this->lng->txt('qpl_move_insert_clipboard'), true);
1446  } else {
1447  $this->tpl->setOnScreenMessage('info', $this->lng->txt('qpl_move_select_none'), true);
1448  }
1449  }
1450 
1451  public function createExportExcel(): void
1452  {
1453  $rbacsystem = $this->rbac_system;
1454  if ($rbacsystem->checkAccess('write', $this->qplrequest->getRefId())) {
1455  $question_ids = &$this->object->getAllQuestionIds();
1456  $qpl_exp = new ilQuestionpoolExport($this->object, 'xlsx', $question_ids);
1457  $qpl_exp->buildExportFile();
1458  $this->ctrl->redirectByClass('ilquestionpoolexportgui', '');
1459  }
1460  }
1461 
1462  public function editQuestionForTestObject(): void
1463  {
1464  $this->ctrl->redirectByClass(ilAssQuestionPreviewGUI::class, 'show');
1465  }
1466 
1467  protected function initImportForm(string $new_type): ilPropertyFormGUI
1468  {
1469  $form = new ilPropertyFormGUI();
1470  $form->setTarget('_top');
1471  $form->setFormAction($this->ctrl->getFormAction($this));
1472  $form->setTitle($this->lng->txt('import_qpl'));
1473 
1474  $fi = new ilFileInputGUI($this->lng->txt('import_file'), 'xmldoc');
1475  $fi->setSuffixes(['zip']);
1476  $fi->setRequired(true);
1477  $form->addItem($fi);
1478 
1479  $form->addCommandButton('importFile', $this->lng->txt('import'));
1480  $form->addCommandButton('cancel', $this->lng->txt('cancel'));
1481 
1482  return $form;
1483  }
1484 
1488  protected function importFileObject(int $parent_id = null): void
1489  {
1490  if ($_REQUEST['new_type'] === null) {
1491  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('import_file_not_valid'), true);
1492  $this->ctrl->redirect($this, 'create');
1493  return;
1494  }
1495  if (!$this->checkPermissionBool('create', '', $_REQUEST['new_type'])) {
1496  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
1497  $this->ctrl->redirect($this, 'create');
1498  return;
1499  }
1500 
1501  $form = $this->initImportForm($this->qplrequest->raw('new_type'));
1502  if ($form->checkInput()) {
1503  $this->uploadQplObject();
1504  }
1505 
1506  // display form to correct errors
1507  $this->tpl->setContent($form->getHTML());
1508  }
1509 
1510  public function addLocatorItems(): void
1511  {
1512  $ilLocator = $this->locator;
1513 
1514  switch ($this->ctrl->getCmd()) {
1515  case 'create':
1516  case 'importFile':
1517  case 'cancel':
1518  break;
1519  default:
1520  $this->ctrl->clearParameterByClass(self::class, 'q_id');
1521  $ilLocator->addItem(
1522  $this->object->getTitle(),
1523  $this->ctrl->getLinkTarget($this, ''),
1524  '',
1525  $this->qplrequest->getRefId()
1526  );
1527  $this->ctrl->setParameter($this, 'q_id', $this->qplrequest->getQuestionId());
1528  break;
1529  }
1530 
1531  if (!is_array($this->qplrequest->raw('q_id')) && $this->qplrequest->raw('q_id') > 0 && $this->qplrequest->raw(
1532  'cmd'
1533  ) !== 'questions') {
1534  $q_gui = assQuestionGUI::_getQuestionGUI('', $this->qplrequest->raw('q_id'));
1535  if ($q_gui !== null && $q_gui->object instanceof assQuestion) {
1536  $q_gui->object->setObjId($this->object->getId());
1537  $title = $q_gui->object->getTitleForHTMLOutput();
1538  if (!$title) {
1539  $title = $this->lng->txt('new') . ': ' . $this->questioninfo->getQuestionTypeName(
1540  $q_gui->object->getId()
1541  );
1542  }
1543  $ilLocator->addItem($title, $this->ctrl->getLinkTargetByClass(get_class($q_gui), 'editQuestion'));
1544  } else {
1545  // Workaround for context issues: If no object was found, redirect without q_id parameter
1546  $this->ctrl->setParameter($this, 'q_id', '');
1547  $this->ctrl->redirect($this);
1548  }
1549  }
1550  }
1551 
1555  public function setTitleAndDescription(): void
1556  {
1557  parent::setTitleAndDescription();
1558 
1559  if (!is_array($this->qplrequest->raw('q_id')) && $this->qplrequest->raw('q_id') > 0 && $this->qplrequest->raw(
1560  'cmd'
1561  ) !== 'questions') {
1562  $q_gui = assQuestionGUI::_getQuestionGUI('', $this->qplrequest->getQuestionId());
1563  if ($q_gui->object instanceof assQuestion) {
1564  $q_gui->object->setObjId($this->object->getId());
1565  $title = $this->object->getTitle() . ': ' . $q_gui->object->getTitle();
1566  if (!$title) {
1567  $title = $this->lng->txt('new') . ': ' . $this->questioninfo->getQuestionTypeName(
1568  $q_gui->object->getId()
1569  );
1570  }
1571  $this->tpl->setTitle(
1572  strip_tags(
1573  $title,
1574  self::ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
1575  )
1576  );
1577  $this->tpl->setDescription(
1578  $q_gui->object->getDescriptionForHTMLOutput()
1579  );
1580  $this->tpl->setTitleIcon(ilObject2::_getIcon($this->object->getId(), 'big', $this->object->getType()));
1581  } else {
1582  // Workaround for context issues: If no object was found, redirect without q_id parameter
1583  $this->ctrl->setParameter($this, 'q_id', '');
1584  $this->ctrl->redirect($this);
1585  }
1586  } else {
1587  $this->tpl->setTitle(
1588  strip_tags(
1589  $this->object->getTitle(),
1590  self::ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
1591  )
1592  );
1593  $this->tpl->setDescription(
1594  strip_tags(
1595  $this->object->getLongDescription(),
1596  self::ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
1597  )
1598  );
1599  $this->tpl->setTitleIcon(ilObject2::_getIcon($this->object->getId(), 'big', $this->object->getType()));
1600  }
1601  }
1602 
1608  public function getTabs(): void
1609  {
1610  $ilHelp = $this->help;
1611 
1612  $currentUserHasWriteAccess = $this->access->checkAccess('write', '', $this->object->getRefId());
1613  $currentUserHasReadAccess = $this->access->checkAccess('read', '', $this->object->getRefId());
1614 
1615  $ilHelp->setScreenIdComponent('qpl');
1616 
1617  $next_class = strtolower($this->ctrl->getNextClass());
1618  switch ($next_class) {
1619  case '':
1620  case 'ilpermissiongui':
1621  case 'ilobjectmetadatagui':
1622  case 'ilquestionpoolexportgui':
1623  case 'ilquestionpoolskilladministrationgui':
1624  break;
1625 
1626  case strtolower(ilTaxonomySettingsGUI::class):
1627  case 'ilobjquestionpoolsettingsgeneralgui':
1628 
1629  if ($currentUserHasWriteAccess) {
1630  $this->addSettingsSubTabs($this->tabs_gui);
1631  }
1632 
1633  break;
1634 
1635  default:
1636  return;
1637  break;
1638  }
1639  // questions
1640  $force_active = false;
1641  $commands = $this->getQueryParamString('cmd');
1642  if (is_array($commands)) {
1643  foreach ($commands as $key => $value) {
1644  if (preg_match('/^delete_.*/', $key, $matches) ||
1645  preg_match('/^addSelectGap_.*/', $key, $matches) ||
1646  preg_match('/^addTextGap_.*/', $key, $matches) ||
1647  preg_match('/^deleteImage_.*/', $key, $matches) ||
1648  preg_match('/^upload_.*/', $key, $matches) ||
1649  preg_match('/^addSuggestedSolution_.*/', $key, $matches)
1650  ) {
1651  $force_active = true;
1652  }
1653  }
1654  }
1655  if (isset($_POST['imagemap_x'])) {
1656  $force_active = true;
1657  }
1658  if (!$force_active) {
1659  $force_active = ((strtolower($this->ctrl->getCmdClass()) == strtolower(get_class($this)) || strlen(
1660  $this->ctrl->getCmdClass()
1661  ) == 0) &&
1662  $this->ctrl->getCmd() == '')
1663  ? true
1664  : false;
1665  }
1666  if ($currentUserHasReadAccess) {
1667  $this->tabs_gui->addTarget(
1668  'assQuestions',
1669  $this->ctrl->getLinkTarget($this, 'questions'),
1670  [
1671  'questions',
1672  'filter',
1673  'resetFilter',
1674  'createQuestion',
1675  'importQuestions',
1676  'deleteQuestions',
1677  'filterQuestionBrowser',
1678  'view',
1679  'preview',
1680  'editQuestion',
1681  'exec_pg',
1682  'addItem',
1683  'upload',
1684  'save',
1685  'cancel',
1686  'addSuggestedSolution',
1687  'cancelExplorer',
1688  'linkChilds',
1689  'removeSuggestedSolution',
1690  'add',
1691  'addYesNo',
1692  'addTrueFalse',
1693  'createGaps',
1694  'saveEdit',
1695  'setMediaMode',
1696  'uploadingImage',
1697  'uploadingImagemap',
1698  'addArea',
1699  'deletearea',
1700  'saveShape',
1701  'back',
1702  'addPair',
1703  'uploadingJavaapplet',
1704  'addParameter',
1705  'assessment',
1706  'addGIT',
1707  'addST',
1708  'addPG',
1709  'delete',
1710  'toggleGraphicalAnswers',
1711  'deleteAnswer',
1712  'deleteImage',
1713  'removeJavaapplet'
1714  ],
1715  '',
1716  '',
1717  $force_active
1718  );
1719  }
1720  if ($currentUserHasReadAccess) {
1721  $this->tabs_gui->addTarget(
1722  'info_short',
1723  $this->ctrl->getLinkTarget($this, 'infoScreen'),
1724  ['infoScreen', 'showSummary']
1725  );
1726  }
1727 
1728  if ($currentUserHasWriteAccess) {
1729  // properties
1730  $this->tabs_gui->addTarget(
1731  'settings',
1732  $this->ctrl->getLinkTargetByClass('ilObjQuestionPoolSettingsGeneralGUI'),
1733  [],
1734  ['ilObjQuestionPoolSettingsGeneralGUI', 'ilObjTaxonomyGUI']
1735  );
1736 
1737  // skill service
1738  if ($this->isSkillsTabRequired()) {
1739  $link = $this->ctrl->getLinkTargetByClass(
1740  ['ilQuestionPoolSkillAdministrationGUI', 'ilAssQuestionSkillAssignmentsGUI'],
1742  );
1743 
1744  $this->tabs_gui->addTarget('qpl_tab_competences', $link, [], []);
1745  }
1746  }
1747 
1748  if ($currentUserHasReadAccess) {
1749  // print view
1750  $this->tabs_gui->addTarget(
1751  'print_view',
1752  $this->ctrl->getLinkTarget($this, 'print'),
1753  ['print'],
1754  '',
1755  ''
1756  );
1757  }
1758 
1759  if ($currentUserHasWriteAccess) {
1760  $mdgui = new ilObjectMetaDataGUI($this->object);
1761  $mdtab = $mdgui->getTab();
1762  if ($mdtab) {
1763  $this->tabs_gui->addTarget(
1764  'meta_data',
1765  $mdtab,
1766  '',
1767  'ilmdeditorgui'
1768  );
1769  }
1770  }
1771 
1772  if ($currentUserHasWriteAccess) {
1773  $this->tabs_gui->addTarget(
1774  'export',
1775  $this->ctrl->getLinkTargetByClass('ilquestionpoolexportgui', ''),
1776  '',
1777  'ilquestionpoolexportgui'
1778  );
1779  }
1780 
1781  if ($this->access->checkAccess('edit_permission', '', $this->object->getRefId())) {
1782  $this->tabs_gui->addTarget(
1783  'perm_settings',
1784  $this->ctrl->getLinkTargetByClass([get_class($this), 'ilpermissiongui'], 'perm'),
1785  ['perm', 'info', 'owner'],
1786  'ilpermissiongui'
1787  );
1788  }
1789  }
1790 
1791  private function isSkillsTabRequired(): bool
1792  {
1793  if (!($this->object instanceof ilObjQuestionPool)) {
1794  return false;
1795  }
1796 
1797  if (!$this->object->isSkillServiceEnabled()) {
1798  return false;
1799  }
1800 
1802  return false;
1803  }
1804 
1805  return true;
1806  }
1807 
1808  private function addSettingsSubTabs(ilTabsGUI $tabs): void
1809  {
1810  $tabs->addSubTab(
1812  $this->lng->txt('qpl_settings_subtab_general'),
1813  $this->ctrl->getLinkTargetByClass('ilObjQuestionPoolSettingsGeneralGUI'),
1814  );
1815  if ($this->object->getShowTaxonomies()) {
1816  $tabs->addSubTab(
1817  'tax_settings',
1818  $this->lng->txt('qpl_settings_subtab_taxonomies'),
1819  $this->ctrl->getLinkTargetByClass('ilTaxonomySettingsGUI', ''),
1820  );
1821  }
1822  }
1823 
1829  public function infoScreenObject(): void
1830  {
1831  $this->ctrl->setCmd('showSummary');
1832  $this->ctrl->setCmdClass('ilinfoscreengui');
1833  $this->infoScreenForward();
1834  }
1835 
1836  public function infoScreenForward(): void
1837  {
1838  if (!$this->access->checkAccess('visible', '', $this->ref_id)) {
1839  $this->error->raiseError($this->lng->txt('msg_no_perm_read'));
1840  }
1841  $info = new ilInfoScreenGUI($this);
1842  $info->enablePrivateNotes();
1843 
1844  // standard meta data
1845  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
1846 
1847  $this->ctrl->forwardCommand($info);
1848  }
1849 
1850  public static function _goto($a_target): void
1851  {
1852  global $DIC;
1853  $main_tpl = $DIC->ui()->mainTemplate();
1854  $ilAccess = $DIC['ilAccess'];
1855  $ilErr = $DIC['ilErr'];
1856  $lng = $DIC['lng'];
1857  $ctrl = $DIC['ilCtrl'];
1858 
1859  if ($ilAccess->checkAccess('write', '', (int) $a_target)
1860  || $ilAccess->checkAccess('read', '', (int) $a_target)
1861  ) {
1862  $target_class = ilObjQuestionPoolGUI::class;
1863  $target_cmd = 'questions';
1864  $ctrl->setParameterByClass($target_class, 'ref_id', $a_target);
1865  $ctrl->redirectByClass([ilRepositoryGUI::class, $target_class], $target_cmd);
1866  return;
1867  }
1868  if ($ilAccess->checkAccess('visible', "", $a_target)) {
1869  ilObjectGUI::_gotoRepositoryNode($a_target, 'infoScreen');
1870  return;
1871  }
1872  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1873  $main_tpl->setOnScreenMessage(
1874  'info',
1875  sprintf(
1876  $lng->txt("msg_no_perm_read_item"),
1878  ),
1879  true
1880  );
1882  return;
1883  }
1884  $ilErr->raiseError($lng->txt('msg_no_perm_read_lm'), $ilErr->FATAL);
1885  }
1886 
1887  protected function getTable(): string
1888  {
1891 
1892  $table = new QuestionTable(
1893  $f,
1894  $r,
1895  $this->data_factory,
1896  $this->refinery,
1897  $this->url_builder,
1898  $this->action_parameter_token,
1899  $this->row_id_token,
1900  $this->db,
1901  $this->lng,
1902  $this->component_repository,
1903  $this->rbac_system,
1904  $this->object->getShowTaxonomies() ? $this->taxonomy->domain() : null,
1906  $this->object->getId(),
1907  (int) $this->qplrequest->getRefId()
1908  );
1909 
1914  $filter_action = $this->ctrl->getLinkTarget($this, 'questions');
1915  $filter = $table->getFilter($this->ui_service, $filter_action);
1916 
1917  $filter_params = $this->ui_service->filter()->getData($filter);
1918 
1919  if ($filter_params) {
1920  foreach (array_filter($filter_params) as $item => $value) {
1921 
1922  switch ($item) {
1923  case 'taxonomies':
1924  foreach ($value as $tax_value) {
1925  if ($tax_value === 'null') {
1926  $table->addTaxonomyFilterNoTaxonomySet(true);
1927  } else {
1928  $tax_nodes = explode('-', $tax_value);
1929  $tax_id = array_shift($tax_nodes);
1930  $table->addTaxonomyFilter(
1931  $tax_id,
1932  $tax_nodes,
1933  $this->object->getId(),
1934  $this->object->getType()
1935  );
1936  }
1937  }
1938  break;
1939  case 'commented':
1940  $table->setCommentFilter($value);
1941  break;
1942  default:
1943  $table->addFieldFilter($item, $value);
1944  }
1945  }
1946  }
1947 
1948  return $r->render([
1949  $filter,
1950  $table->getTable()
1951  ->withRequest($this->request)
1952  ]);
1953  }
1954 }
const MATCHING_QUESTION_IDENTIFIER
const MULTIPLE_CHOICE_QUESTION_IDENTIFIER
const ADDITIONAL_CONTENT_EDITING_MODE_IPE
ilNavigationHistory $navigation_history
setEditPreview(bool $a_editpreview)
Set Display first Edit tab, then Preview tab, instead of Page and Edit.
raiseError(string $a_msg, int $a_err_obj)
wrapper for downward compability
static get(string $a_var)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Readable part of repository interface to ilComponentDataDB.
exit
Definition: login.php:29
ilRbacSystem $rbac_system
Class ilInfoScreenGUI.
ilTabsGUI $tabs_gui
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _getGUIClassNameForId($a_q_id)
confirmDeleteQuestionsObject()
delete questions after confirmation
GUI class for the workflow of copying objects.
const ROOT_FOLDER_ID
Definition: constants.php:32
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
__construct($data, int $id=0, bool $call_by_reference=true, bool $prepare_output=true)
Abstract basic class which is to be extended by the concrete assessment question type classes...
prepareOutput(bool $show_sub_objects=true)
This class represents a file property in a property form.
setInfo(string $a_info)
Help GUI class.
ILIAS TestQuestionPool InternalRequestService $qplrequest
const KPRIM_CHOICE_QUESTION_IDENTIFIER
acquireParameters(array $namespace, string ... $names)
Definition: URLBuilder.php:137
static _gotoRepositoryNode(int $ref_id, string $cmd="")
const LONG_MENU_QUESTION_IDENTIFIER
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const TEXTSUBSET_QUESTION_IDENTIFIER
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Import class.
setParameterByClass(string $a_class, string $a_parameter, $a_value)
Component logger with individual log levels by component id.
setSuffixes(array $a_suffixes)
setOptions(array $a_options)
getTabs()
adds tabs to tab gui object
download_paragraphObject()
download source code paragraph
static getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
Filter service.
exportObject()
Gateway for exports initiated from workspace, as there is a generic forward to {objTypeMainGUI}::expo...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getQuestionGUI(string $question_type='', int $question_id=-1)
Creates a question gui representation and returns the alias to the question gui.
const CMD_SHOW_LIST
command constants
importObject(?object $a_new_obj, string $a_tmp_file, string $a_filename, string $a_type, string $a_comp="", bool $a_copy_file=false)
$ilErr
Definition: raiseError.php:17
static _lookupObjId(int $ref_id)
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
Interface ilCtrlBaseClassInterface describes ilCtrl base classes.
global $DIC
Definition: feed.php:28
ilLanguage $lng
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilComponentRepository $component_repository
getActivePluginsInSlot(string $slot_id)
Get the active plugins for the given slot.
addSubTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
importQuestionsObject(ilPropertyFormGUI $form=null)
display the import form to import questions into the questionpool
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
This class represents a property in a property form.
__construct(VocabulariesInterface $vocabularies)
UIFactory $ui_factory
ilGlobalTemplateInterface $tpl
deleteQuestionsObject()
delete questions confirmation screen
ilComponentFactory $component_factory
static _lookupTitle(int $obj_id)
const NUMERIC_QUESTION_IDENTIFIER
setScreenId(string $a_id)
setContent(string $a_html)
Sets content for standard template.
ILIAS Notes Service $notes_service
ILIAS Filesystem Util Archive LegacyArchives $archives
setTitleAndDescription()
called by prepare output
questionsObject()
list questions of question pool
setScreenIdComponent(string $a_comp)
Class ilObjectGUI Basic methods of all Output classes.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
const ORDERING_QUESTION_IDENTIFIER
uploadQplObject($questions_only=false)
imports question(s) into the questionpool
$param
Definition: xapitoken.php:46
QuestionInfoService $questioninfo
Class ilObjFile.
string $key
Consumer key/client ID value.
Definition: System.php:193
Provides fluid interface to RBAC services.
Legacy Content Object Parser.
static _setImportDirectory($a_import_dir=null)
header include for all ilias files.
$url
Definition: ltiregstart.php:35
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
static getDataDir()
get data directory (outside webspace)
const TEXT_QUESTION_IDENTIFIER
setRequired(bool $a_required)
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
Last visited history for repository items.
$filename
Definition: buildRTE.php:78
ilErrorHandling $error
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
static redirect(string $a_script)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static buildAjaxHash(int $node_type, ?int $node_id, string $obj_type, int $obj_id, string $sub_type=null, int $sub_id=null, int $news_id=0)
Build ajax hash.
fullscreenObject()
show fullscreen view
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
sendParagraph(string $par_id, string $filename)
const ADDITIONAL_CONTENT_EDITING_MODE_RTE
ilAccessHandler $access
static isAdditionalQuestionContentEditingModePageObjectEnabled()
Returns the fact wether content editing with ilias page editor is enabled for questions or not...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getImportDirectory()
get import directory of lm
static getListCommentsJSCall(string $a_hash, string $a_update_code=null)
Get list comments js call.
URLBuilder.
Definition: URLBuilder.php:39
const SINGLE_CHOICE_QUESTION_IDENTIFIER
importFileObject(int $parent_id=null)
form for new questionpool object import
ilLocatorGUI $locator
UIRenderer $ui_renderer
static set(string $a_var, $a_val)
Set a value.
showMediaFullscreen(int $a_style_id=0)
show fullscreen view of media object
const CLOZE_TEST_IDENTIFIER
Question identifier constants.
uploadObject()
imports question(s) into the questionpool
static _setImportDirectory($a_import_dir=null)
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
const IMAGEMAP_QUESTION_IDENTIFIER
$r