ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjQuestionPoolGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once './Services/Object/classes/class.ilObjectGUI.php';
5 require_once './Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
6 require_once './Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
7 require_once './Modules/TestQuestionPool/exceptions/class.ilTestQuestionPoolException.php';
8 require_once './Modules/Test/classes/inc.AssessmentConstants.php';
9 require_once './Modules/Test/classes/class.ilObjAssessmentFolder.php';
10 require_once './Modules/Test/classes/class.ilObjTest.php';
11 
36 {
40  public $object;
41 
46  public function __construct()
47  {
48  global $lng, $ilCtrl, $rbacsystem;
49  $lng->loadLanguageModule("assessment");
50  $this->type = "qpl";
51  $this->ctrl =&$ilCtrl;
52 
53  $this->ctrl->saveParameter($this, array(
54  "ref_id", "test_ref_id", "calling_test", "test_express_mode", "q_id", 'tax_node', 'calling_consumer', 'consumer_context'
55  ));
56  $this->ctrl->saveParameter($this, "calling_consumer");
57  $this->ctrl->saveParameterByClass('ilAssQuestionPageGUI', 'calling_consumer');
58  $this->ctrl->saveParameterByClass('ilAssQuestionPageGUI', 'consumer_context');
59  $this->ctrl->saveParameterByClass('ilobjquestionpoolgui', 'calling_consumer');
60  $this->ctrl->saveParameterByClass('ilobjquestionpoolgui', 'consumer_context');
61 
62  parent::__construct("", $_GET["ref_id"], true, false);
63  }
64 
77  public function executeCommand()
78  {
79  global $ilUser, $ilLocator, $ilAccess, $ilNavigationHistory, $tpl, $ilCtrl, $ilErr, $ilTabs, $lng, $ilDB, $ilPluginAdmin, $ilias;
80 
81  if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"])) && (!$ilAccess->checkAccess("visible", "", $_GET["ref_id"]))) {
82  global $ilias;
83  $ilias->raiseError($this->lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
84  }
85 
86  // add entry to navigation history
87  if (!$this->getCreationMode() &&
88  $ilAccess->checkAccess("read", "", $_GET["ref_id"])) {
89  if ('qpl' == $this->object->getType()) {
90  $ilNavigationHistory->addItem(
91  $_GET["ref_id"],
92  "ilias.php?baseClass=ilObjQuestionPoolGUI&cmd=questions&ref_id=" . $_GET["ref_id"],
93  "qpl"
94  );
95  }
96  }
97 
98  $cmd = $this->ctrl->getCmd("questions");
99  $next_class = $this->ctrl->getNextClass($this);
100 
101  if (in_array($next_class, array('', 'ilobjquestionpoolgui')) && $cmd == 'questions') {
102  $_GET['q_id'] = '';
103  }
104 
105  $this->prepareOutput();
106 
107  $this->ctrl->setReturn($this, "questions");
108 
109  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
110  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "ta.css", "Modules/Test"), "screen");
111 
112  if ($_GET["q_id"] < 1) {
113  $q_type = ($_POST["sel_question_types"] != "")
114  ? $_POST["sel_question_types"]
115  : $_GET["sel_question_types"];
116  }
117  if ($cmd != "createQuestion" && $cmd != "createQuestionForTest"
118  && $next_class != "ilassquestionpagegui") {
119  if (($_GET["test_ref_id"] != "") or ($_GET["calling_test"])) {
120  $ref_id = $_GET["test_ref_id"];
121  if (!$ref_id) {
122  $ref_id = $_GET["calling_test"];
123  }
124  }
125  }
126  switch ($next_class) {
127  case "ilcommonactiondispatchergui":
128  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
130  $this->ctrl->forwardCommand($gui);
131  break;
132 
133  case 'ilobjectmetadatagui':
134  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
135  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
136  }
137  include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
138  $md_gui = new ilObjectMetaDataGUI($this->object);
139  $this->ctrl->forwardCommand($md_gui);
140  break;
141 
142  case 'ilassquestionpreviewgui':
143 
144  $this->ctrl->saveParameter($this, "q_id");
145 
146  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewGUI.php';
147  $gui = new ilAssQuestionPreviewGUI($this->ctrl, $this->tabs_gui, $this->tpl, $this->lng, $ilDB, $ilUser);
148 
149  $gui->initQuestion((int) $_GET['q_id'], $this->object->getId());
150  $gui->initPreviewSettings($this->object->getRefId());
151  $gui->initPreviewSession($ilUser->getId(), $this->fetchAuthoringQuestionIdParamater());
152  $gui->initHintTracking();
153  $gui->initStyleSheets();
154 
155  global $ilHelp;
156  $ilHelp->setScreenIdComponent("qpl");
157 
158  $this->ctrl->forwardCommand($gui);
159  break;
160 
161  case "ilassquestionpagegui":
162  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
163  $this->tpl->setCurrentBlock("ContentStyle");
164  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
165  $this->tpl->parseCurrentBlock();
166 
167  // syntax style
168  $this->tpl->setCurrentBlock("SyntaxStyle");
169  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
170  $this->tpl->parseCurrentBlock();
171 
172  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
174  $q_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
175  $q_gui->setQuestionTabs();
176  $q_gui->outAdditionalOutput();
177  $q_gui->object->setObjId($this->object->getId());
178 
179  $q_gui->setTargetGuiClass(null);
180  $q_gui->setQuestionActionCmd(null);
181 
182  $question = $q_gui->object;
183  $this->ctrl->saveParameter($this, "q_id");
184  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
185  $this->lng->loadLanguageModule("content");
186  $this->ctrl->setReturnByClass("ilAssQuestionPageGUI", "view");
187  $this->ctrl->setReturn($this, "questions");
188  $page_gui = new ilAssQuestionPageGUI($_GET["q_id"]);
189  $page_gui->obj->addUpdateListener(
190  $question,
191  'updateTimestamp'
192  );
193  $page_gui->setEditPreview(true);
194  $page_gui->setEnabledTabs(false);
195  if (strlen($this->ctrl->getCmd()) == 0 && !isset($_POST["editImagemapForward_x"])) { // workaround for page edit imagemaps, keep in mind
196  $this->ctrl->setCmdClass(get_class($page_gui));
197  $this->ctrl->setCmd("preview");
198  }
199  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(true)));
200  $page_gui->setTemplateTargetVar("ADM_CONTENT");
201  $page_gui->setOutputMode("edit");
202  $page_gui->setHeader($question->getTitle());
203  $page_gui->setPresentationTitle($question->getTitle());
204  $ret = $this->ctrl->forwardCommand($page_gui);
205  $tpl->setContent($ret);
206  break;
207 
208  case 'ilpermissiongui':
209  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
210  $perm_gui = new ilPermissionGUI($this);
211  $ret = $this->ctrl->forwardCommand($perm_gui);
212  break;
213 
214  case 'ilobjectcopygui':
215  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
216  $cp = new ilObjectCopyGUI($this);
217  $cp->setType('qpl');
218  $this->ctrl->forwardCommand($cp);
219  break;
220 
221  case "ilquestionpoolexportgui":
222  require_once 'Modules/TestQuestionPool/classes/class.ilQuestionPoolExportGUI.php';
223  $exp_gui = new ilQuestionPoolExportGUI($this);
224  $exp_gui->addFormat('xml', $this->lng->txt('qpl_export_xml'));
225  $exp_gui->addFormat('xls', $this->lng->txt('qpl_export_excel'), $this, 'createExportExcel');
226  $ret = $this->ctrl->forwardCommand($exp_gui);
227  break;
228 
229  case "ilinfoscreengui":
230  $this->infoScreenForward();
231  break;
232 
233  case 'ilassquestionhintsgui':
234 
235  // set return target
236  $this->ctrl->setReturn($this, "questions");
237 
238  // set context tabs
239  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
240  $questionGUI = assQuestionGUI::_getQuestionGUI($q_type, $this->fetchAuthoringQuestionIdParamater());
241  $questionGUI->object->setObjId($this->object->getId());
242  $questionGUI->setQuestionTabs();
243  global $ilHelp;
244  $ilHelp->setScreenIdComponent("qpl");
245 
246  // forward to ilAssQuestionHintsGUI
247  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsGUI.php';
248  $gui = new ilAssQuestionHintsGUI($questionGUI);
249 
250  global $DIC; /* @var ILIAS\DI\Container $DIC */
251 
252  $gui->setEditingEnabled(
253  $DIC->access()->checkAccess('write', '', $this->object->getRefId())
254  );
255 
256  $ilCtrl->forwardCommand($gui);
257 
258  break;
259 
260  case 'illocalunitconfigurationgui':
261  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
262  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
263  }
264 
265  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
266  $questionGUI = assQuestionGUI::_getQuestionGUI($q_type, $this->fetchAuthoringQuestionIdParamater());
267  $questionGUI->object->setObjId($this->object->getId());
268  $questionGUI->setQuestionTabs();
269 
270  $this->ctrl->setReturn($this, 'questions');
271 
272  require_once 'Modules/TestQuestionPool/classes/class.ilLocalUnitConfigurationGUI.php';
273  require_once 'Modules/TestQuestionPool/classes/class.ilUnitConfigurationRepository.php';
274  $gui = new ilLocalUnitConfigurationGUI(
275  new ilUnitConfigurationRepository((int) $_GET['q_id'])
276  );
277  $ilCtrl->forwardCommand($gui);
278  break;
279 
280  case 'ilassquestionfeedbackeditinggui':
281 
282  // set return target
283  $this->ctrl->setReturn($this, "questions");
284 
285  // set context tabs
286  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
287  $questionGUI = assQuestionGUI::_getQuestionGUI($q_type, $this->fetchAuthoringQuestionIdParamater());
288  $questionGUI->object->setObjId($this->object->getId());
289  $questionGUI->setQuestionTabs();
290  global $ilHelp;
291  $ilHelp->setScreenIdComponent("qpl");
292 
293  // forward to ilAssQuestionFeedbackGUI
294  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackEditingGUI.php';
295  $gui = new ilAssQuestionFeedbackEditingGUI($questionGUI, $ilCtrl, $ilAccess, $tpl, $ilTabs, $lng);
296  $ilCtrl->forwardCommand($gui);
297 
298  break;
299 
300  case 'ilobjquestionpoolsettingsgeneralgui':
301  require_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPoolSettingsGeneralGUI.php';
302  $gui = new ilObjQuestionPoolSettingsGeneralGUI($ilCtrl, $ilAccess, $lng, $tpl, $ilTabs, $this);
303  $this->ctrl->forwardCommand($gui);
304  break;
305 
306  case "ilobjtaxonomygui":
307 
308  require_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPoolTaxonomyEditingCommandForwarder.php';
310  $this->object,
311  $ilDB,
312  $ilPluginAdmin,
313  $ilCtrl,
314  $ilTabs,
315  $lng
316  );
317 
318  $forwarder->forward();
319 
320  break;
321 
322  case 'ilquestionpoolskilladministrationgui':
323 
324  require_once 'Modules/TestQuestionPool/classes/class.ilQuestionPoolSkillAdministrationGUI.php';
326  $ilias,
327  $ilCtrl,
328  $ilAccess,
329  $ilTabs,
330  $tpl,
331  $lng,
332  $ilDB,
333  $ilPluginAdmin,
334  $this->object,
335  $this->ref_id
336  );
337 
338  $this->ctrl->forwardCommand($gui);
339 
340  break;
341 
342  case 'ilquestionbrowsertablegui':
343  $this->ctrl->forwardCommand($this->buildQuestionBrowserTableGUI($taxIds = array())); // no tax ids required
344  break;
345 
346  case "ilobjquestionpoolgui":
347  case "":
348 
349  if ($cmd == 'questions') {
350  $this->ctrl->setParameter($this, 'q_id', '');
351  }
352 
353  $cmd.= "Object";
354  $ret = $this->$cmd();
355  break;
356 
357  default:
358  $this->ctrl->setReturn($this, "questions");
359  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
361  $q_gui->setEditContext(assQuestionGUI::EDIT_CONTEXT_AUTHORING);
362  $q_gui->object->setObjId($this->object->getId());
363  if ($this->object->getType() == 'qpl') {
364  $q_gui->setTaxonomyIds($this->object->getTaxonomyIds());
365  $this->object->addQuestionChangeListeners($q_gui->object);
366  }
367  $q_gui->setQuestionTabs();
368  global $ilHelp;
369  $ilHelp->setScreenIdComponent("qpl");
370  $ret = $this->ctrl->forwardCommand($q_gui);
371  break;
372  }
373 
374  if (!(strtolower($_GET["baseClass"]) == "iladministrationgui"
375  || strtolower($_GET['baseClass']) == 'ilrepositorygui')
376  && $this->getCreationMode() != true) {
377  $this->tpl->show();
378  }
379  }
380 
385  protected function exportObject()
386  {
387  global $DIC; /* @var ILIAS\DI\Container $DIC */
388  $DIC->ctrl()->redirectByClass('ilQuestionPoolExportGUI');
389  }
390 
394  public function downloadFileObject()
395  {
396  $file = explode("_", $_GET["file_id"]);
397  include_once("./Modules/File/classes/class.ilObjFile.php");
398  $fileObj = new ilObjFile($file[count($file) - 1], false);
399  $fileObj->sendFile();
400  exit;
401  }
402 
406  public function fullscreenObject()
407  {
408  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
409  $page_gui = new ilAssQuestionPageGUI($_GET["pg_id"]);
410  $page_gui->showMediaFullscreen();
411  }
412 
413 
417  public function filterObject()
418  {
419  $this->questionsObject();
420  }
421 
425  public function resetFilterObject()
426  {
427  $_POST["filter_text"] = "";
428  $_POST["sel_filter_type"] = "";
429  $this->questionsObject();
430  }
431 
435  public function download_paragraphObject()
436  {
437  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
438  $pg_obj = new ilAssQuestionPage($_GET["pg_id"]);
439  $pg_obj->send_paragraph($_GET["par_id"], $_GET["downloadtitle"]);
440  exit;
441  }
442 
446  public function uploadQplObject($questions_only = false)
447  {
448  $this->ctrl->setParameter($this, 'new_type', $_REQUEST['new_type']);
449  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK) {
450  ilUtil::sendFailure($this->lng->txt("error_upload"), true);
451  if (!$questions_only) {
452  $this->ctrl->redirect($this, 'create');
453  }
454  return false;
455  }
456  // create import directory
457  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
459 
460  // copy uploaded file to import directory
461  $file = pathinfo($_FILES["xmldoc"]["name"]);
462  $full_path = $basedir . "/" . $_FILES["xmldoc"]["name"];
463  $GLOBALS['ilLog']->write(__METHOD__ . ": full path " . $full_path);
464  include_once "./Services/Utilities/classes/class.ilUtil.php";
465  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
466  $GLOBALS['ilLog']->write(__METHOD__ . ": full path " . $full_path);
467  if (strcmp($_FILES["xmldoc"]["type"], "text/xml") == 0) {
468  $qti_file = $full_path;
470  } else {
471  // unzip file
472  ilUtil::unzip($full_path);
473 
474  // determine filenames of xml files
475  $subdir = basename($file["basename"], "." . $file["extension"]);
477  $xml_file = ilObjQuestionPool::_getImportDirectory() . '/' . $subdir . '/' . $subdir . ".xml";
478  $qti_file = ilObjQuestionPool::_getImportDirectory() . '/' . $subdir . '/' . str_replace("qpl", "qti", $subdir) . ".xml";
479  }
480 
481  // start verification of QTI files
482  include_once "./Services/QTI/classes/class.ilQTIParser.php";
483  $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
484  $result = $qtiParser->startParsing();
485  $founditems =&$qtiParser->getFoundItems();
486  if (count($founditems) == 0) {
487  // nothing found
488 
489  // delete import directory
490  ilUtil::delDir($basedir);
491 
492  ilUtil::sendFailure($this->lng->txt("qpl_import_no_items"), true);
493  if (!$questions_only) {
494  $this->ctrl->redirect($this, 'create');
495  }
496  return false;
497  }
498 
499  $complete = 0;
500  $incomplete = 0;
501  foreach ($founditems as $item) {
502  if (strlen($item["type"])) {
503  $complete++;
504  } else {
505  $incomplete++;
506  }
507  }
508 
509  if ($complete == 0) {
510  // delete import directory
511  ilUtil::delDir($basedir);
512 
513  ilUtil::sendFailure($this->lng->txt("qpl_import_non_ilias_files"), true);
514  if (!$questions_only) {
515  $this->ctrl->redirect($this, 'create');
516  }
517  return false;
518  }
519 
520  $_SESSION["qpl_import_xml_file"] = $xml_file;
521  $_SESSION["qpl_import_qti_file"] = $qti_file;
522  $_SESSION["qpl_import_subdir"] = $subdir;
523 
524  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_import_verification.html", "Modules/TestQuestionPool");
525 
526  require_once 'Modules/TestQuestionPool/classes/tables/class.ilQuestionPoolImportVerificationTableGUI.php';
527  $table = new ilQuestionPoolImportVerificationTableGUI($this, 'uploadQplObject');
528  $rows = array();
529 
530  foreach ($founditems as $item) {
531  $row = array(
532  'title' => $item['title'],
533  'ident' => $item['ident'],
534  );
535 
536  include_once "./Services/QTI/classes/class.ilQTIItem.php";
537  switch ($item["type"]) {
539  $type = $this->lng->txt("assClozeTest");
540  break;
542  $type = $this->lng->txt("assImagemapQuestion");
543  break;
545  $type = $this->lng->txt("assJavaApplet");
546  break;
548  $type = $this->lng->txt("assMatchingQuestion");
549  break;
551  $type = $this->lng->txt("assMultipleChoice");
552  break;
554  $type = $this->lng->txt("assKprimChoice");
555  break;
557  $type = $this->lng->txt("assLongMenu");
558  break;
560  $type = $this->lng->txt("assSingleChoice");
561  break;
563  $type = $this->lng->txt("assOrderingQuestion");
564  break;
566  $type = $this->lng->txt("assTextQuestion");
567  break;
569  $type = $this->lng->txt("assNumeric");
570  break;
572  $type = $this->lng->txt("assTextSubset");
573  break;
574  default:
575  $type = $this->lng->txt($item["type"]);
576  break;
577  }
578 
579  if (strcmp($type, "-" . $item["type"] . "-") == 0) {
580  global $ilPluginAdmin;
581  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "TestQuestionPool", "qst");
582  foreach ($pl_names as $pl_name) {
583  $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "TestQuestionPool", "qst", $pl_name);
584  if (strcmp($pl->getQuestionType(), $item["type"]) == 0) {
585  $type = $pl->getQuestionTypeTranslation();
586  }
587  }
588  }
589 
590  $row['type'] = $type;
591 
592  $rows[] = $row;
593  }
594  $table->setData($rows);
595 
596  $this->tpl->setCurrentBlock("import_qpl");
597  if (is_file($xml_file)) {
598  // read file into a string
599  $fh = @fopen($xml_file, "r") or die("");
600  $xml = @fread($fh, filesize($xml_file));
601  @fclose($fh);
602  if (preg_match("/<ContentObject.*?MetaData.*?General.*?Title[^>]*?>([^<]*?)</", $xml, $matches)) {
603  $this->tpl->setVariable("VALUE_NEW_QUESTIONPOOL", $matches[1]);
604  }
605  }
606  $this->tpl->setVariable("TEXT_CREATE_NEW_QUESTIONPOOL", $this->lng->txt("qpl_import_create_new_qpl"));
607  $this->tpl->parseCurrentBlock();
608 
609  $this->tpl->setCurrentBlock("adm_content");
610  $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("qpl_import_verify_found_questions"));
611  if ($questions_only) {
612  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_questions_into_qpl"));
613  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
614  } else {
615  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_qpl"));
616 
617  $this->ctrl->setParameter($this, "new_type", $this->type);
618  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
619  }
620 
621  $value_questions_only = 0;
622  if ($questions_only) {
623  $value_questions_only = 1;
624  }
625  $this->tpl->setVariable("VALUE_QUESTIONS_ONLY", $value_questions_only);
626  $this->tpl->setVariable("VERIFICATION_TABLE", $table->getHtml());
627  $this->tpl->setVariable("VERIFICATION_FORM_NAME", $table->getFormName());
628 
629  $this->tpl->parseCurrentBlock();
630 
631  return true;
632  }
633 
637  public function importVerifiedFileObject()
638  {
639  if ($_POST["questions_only"] == 1) {
640  $newObj =&$this->object;
641  } else {
642  include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
643  // create new questionpool object
644  $newObj = new ilObjQuestionPool(0, true);
645  // set type of questionpool object
646  $newObj->setType($_GET["new_type"]);
647  // set title of questionpool object to "dummy"
648  $newObj->setTitle("dummy");
649  // set description of questionpool object
650  $newObj->setDescription("questionpool import");
651  // create the questionpool class in the ILIAS database (object_data table)
652  $newObj->create(true);
653  // create a reference for the questionpool object in the ILIAS database (object_reference table)
654  $newObj->createReference();
655  // put the questionpool object in the administration tree
656  $newObj->putInTree($_GET["ref_id"]);
657  // get default permissions and set the permissions for the questionpool object
658  $newObj->setPermissions($_GET["ref_id"]);
659  }
660 
661  if (is_file($_SESSION["qpl_import_dir"] . '/' . $_SESSION["qpl_import_subdir"] . "/manifest.xml")) {
662  $_SESSION["qpl_import_idents"] = $_POST["ident"];
663 
664  $fileName = $_SESSION["qpl_import_subdir"] . '.zip';
665  $fullPath = $_SESSION["qpl_import_dir"] . '/' . $fileName;
666 
667  include_once("./Services/Export/classes/class.ilImport.php");
668  $imp = new ilImport((int) $_GET["ref_id"]);
669  $map = $imp->getMapping();
670  $map->addMapping("Modules/TestQuestionPool", "qpl", "new_id", $newObj->getId());
671  $imp->importObject($newObj, $fullPath, $fileName, "qpl", "Modules/TestQuestionPool", true);
672  } else {
673  // start parsing of QTI files
674  include_once "./Services/QTI/classes/class.ilQTIParser.php";
675  $qtiParser = new ilQTIParser($_SESSION["qpl_import_qti_file"], IL_MO_PARSE_QTI, $newObj->getId(), $_POST["ident"]);
676  $result = $qtiParser->startParsing();
677 
678  // import page data
679  if (strlen($_SESSION["qpl_import_xml_file"])) {
680  include_once("./Modules/LearningModule/classes/class.ilContObjParser.php");
681  $contParser = new ilContObjParser($newObj, $_SESSION["qpl_import_xml_file"], $_SESSION["qpl_import_subdir"]);
682  $contParser->setQuestionMapping($qtiParser->getImportMapping());
683  $contParser->startParsing();
684 
685  // #20494
686  $newObj->fromXML($_SESSION["qpl_import_xml_file"]);
687  }
688 
689  // set another question pool name (if possible)
690  if (isset($_POST["qpl_new"]) && strlen($_POST["qpl_new"])) {
691  $newObj->setTitle($_POST["qpl_new"]);
692  }
693 
694  $newObj->update();
695  $newObj->saveToDb();
696  }
697 
698  // delete import directory
699  include_once "./Services/Utilities/classes/class.ilUtil.php";
701 
702  if ($_POST["questions_only"] == 1) {
703  $this->ctrl->redirect($this, "questions");
704  } else {
705  ilUtil::sendSuccess($this->lng->txt("object_imported"), true);
706  ilUtil::redirect("ilias.php?ref_id=" . $newObj->getRefId() .
707  "&baseClass=ilObjQuestionPoolGUI");
708  }
709  }
710 
711  public function cancelImportObject()
712  {
713  if ($_POST["questions_only"] == 1) {
714  $this->ctrl->redirect($this, "questions");
715  } else {
716  $this->ctrl->redirect($this, "cancel");
717  }
718  }
719 
723  public function uploadObject()
724  {
725  $upload_valid = true;
726  $form = $this->getImportQuestionsForm();
727  if ($form->checkInput()) {
728  if (!$this->uploadQplObject(true)) {
729  $form->setValuesByPost();
731  }
732  } else {
733  $form->setValuesByPost();
735  }
736  }
737 
742  {
743  if (!$form instanceof ilPropertyFormGUI) {
744  $form = $this->getImportQuestionsForm();
745  }
746 
747  $this->tpl->setContent($form->getHtml());
748  }
749 
753  protected function getImportQuestionsForm()
754  {
755  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
756  $form = new ilPropertyFormGUI();
757  $form->setTitle($this->lng->txt('import_question'));
758  $form->setFormAction($this->ctrl->getFormAction($this, 'upload'));
759 
760  $file = new ilFileInputGUI($this->lng->txt('select_file'), 'xmldoc');
761  $file->setRequired(true);
762  $form->addItem($file);
763 
764  $form->addCommandButton('upload', $this->lng->txt('upload'));
765  $form->addCommandButton('questions', $this->lng->txt('cancel'));
766 
767  return $form;
768  }
769 
773  public function &createQuestionObject()
774  {
776  $addContEditMode = $_POST['add_quest_cont_edit_mode'];
777  } else {
779  }
780 
781  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
782  $q_gui =&assQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
783  $this->object->addQuestionChangeListeners($q_gui->object);
784  $q_gui->object->setObjId($this->object->getId());
785  $q_gui->object->setAdditionalContentEditingMode($addContEditMode);
786  $q_gui->object->createNewQuestion();
787  $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $q_gui->object->getId());
788  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_POST["sel_question_types"]);
789  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
790  }
791 
795  public function &createQuestionForTestObject()
796  {
797  if (!$_REQUEST['q_id']) {
798  require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
800  $addContEditMode = $_REQUEST['add_quest_cont_edit_mode'];
801  } else {
803  }
804 
805  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
806  $q_gui =&assQuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
807  $q_gui->object->setObjId($this->object->getId());
808  $q_gui->object->setAdditionalContentEditingMode($addContEditMode);
809  $q_gui->object->createNewQuestion();
810 
811  $class = get_class($q_gui);
812  $qId = $q_gui->object->getId();
813  } else {
814  $class = $_GET["sel_question_types"] . 'gui';
815  $qId = $_REQUEST['q_id'];
816  }
817 
818  $this->ctrl->setParameterByClass($class, "q_id", $qId);
819  $this->ctrl->setParameterByClass($class, "sel_question_types", $_REQUEST["sel_question_types"]);
820  $this->ctrl->setParameterByClass($class, "prev_qid", $_REQUEST["prev_qid"]);
821 
822  $this->ctrl->redirectByClass($class, "editQuestion");
823  }
824 
829  public function afterSave(ilObject $a_new_object)
830  {
831  // always send a message
832  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
833 
834  ilUtil::redirect("ilias.php?ref_id=" . $a_new_object->getRefId() .
835  "&baseClass=ilObjQuestionPoolGUI");
836  }
837 
838  public function questionObject()
839  {
840  //echo "<br>ilObjQuestionPoolGUI->questionObject()";
841  $type = $_GET["sel_question_types"];
842  $this->editQuestionForm($type);
843  }
844 
848  public function deleteQuestionsObject()
849  {
850  global $rbacsystem;
851 
852  $questionIdsToDelete = isset($_POST['q_id']) ? (array) $_POST['q_id'] : array();
853  if (0 === count($questionIdsToDelete) && isset($_GET['q_id'])) {
854  $questionIdsToDelete = array($_GET['q_id']);
855  }
856 
857  $questionIdsToDelete = array_filter(array_map('intval', $questionIdsToDelete));
858  if (0 === count($questionIdsToDelete)) {
859  ilUtil::sendInfo($this->lng->txt("qpl_delete_select_none"), true);
860  $this->ctrl->redirect($this, "questions");
861  }
862 
863  ilUtil::sendQuestion($this->lng->txt("qpl_confirm_delete_questions"));
864  $deleteable_questions =&$this->object->getDeleteableQuestionDetails($questionIdsToDelete);
865  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
866  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', (($rbacsystem->checkAccess('write', (int) $_GET['ref_id']) ? true : false)), true);
867  $table_gui->setShowRowsSelector(false);
868  $table_gui->setLimit(PHP_INT_MAX);
869  $table_gui->setEditable($rbacsystem->checkAccess('write', (int) $_GET['ref_id']));
870  $table_gui->setData($deleteable_questions);
871  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
872  }
873 
874 
879  {
880  // delete questions after confirmation
881  foreach ($_POST["q_id"] as $key => $value) {
882  $this->object->deleteQuestion($value);
883  $this->object->cleanupClipboard($value);
884  }
885  if (count($_POST["q_id"])) {
886  ilUtil::sendSuccess($this->lng->txt("qpl_questions_deleted"), true);
887  }
888 
889  $this->ctrl->setParameter($this, 'q_id', '');
890 
891  $this->ctrl->redirect($this, "questions");
892  }
893 
897  public function cancelDeleteQuestionsObject()
898  {
899  $this->ctrl->redirect($this, "questions");
900  }
901 
905  public function exportQuestionObject()
906  {
907  // export button was pressed
908  if (count($_POST["q_id"]) > 0) {
909  include_once("./Modules/TestQuestionPool/classes/class.ilQuestionpoolExport.php");
910  $qpl_exp = new ilQuestionpoolExport($this->object, "xml", $_POST["q_id"]);
911  $export_file = $qpl_exp->buildExportFile();
912  $filename = $export_file;
913  $filename = preg_replace("/.*\//", "", $filename);
914  include_once "./Services/Utilities/classes/class.ilUtil.php";
915  ilUtil::deliverFile($export_file, $filename);
916  exit();
917  } else {
918  ilUtil::sendInfo($this->lng->txt("qpl_export_select_none"), true);
919  }
920  $this->ctrl->redirect($this, "questions");
921  }
922 
923  public function filterQuestionBrowserObject()
924  {
925  require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
926  $taxIds = ilObjTaxonomy::getUsageOfObject($this->object->getId());
927 
928  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
929  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', false, false, $taxIds);
930  $table_gui->resetOffset();
931  $table_gui->writeFilterToSession();
932  $this->questionsObject();
933  }
934 
935  public function resetQuestionBrowserObject()
936  {
937  require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
938  $taxIds = ilObjTaxonomy::getUsageOfObject($this->object->getId());
939 
940  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
941  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', false, false, $taxIds);
942  $table_gui->resetOffset();
943  $table_gui->resetFilter();
944  $this->questionsObject();
945  }
946 
947  protected function renoveImportFailsObject()
948  {
949  require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImportFails.php';
950  $qsaImportFails = new ilAssQuestionSkillAssignmentImportFails($this->object->getId());
951  $qsaImportFails->deleteRegisteredImportFails();
952 
953  $this->ctrl->redirect($this, 'infoScreen');
954  }
955 
959  public function questionsObject()
960  {
961  global $rbacsystem, $ilUser, $ilCtrl, $ilDB, $lng, $ilPluginAdmin;
962 
963  if (get_class($this->object) == "ilObjTest") {
964  if ($_GET["calling_test"] > 0) {
965  $ref_id = $_GET["calling_test"];
966  $q_id = $_GET["q_id"];
967 
968  if ($_REQUEST['test_express_mode']) {
969  if ($q_id) {
970  ilUtil::redirect("ilias.php?ref_id=" . $ref_id . "&q_id=" . $q_id . "&test_express_mode=1&cmd=showPage&cmdClass=iltestexpresspageobjectgui&baseClass=ilObjTestGUI");
971  } else {
972  ilUtil::redirect("ilias.php?ref_id=" . $ref_id . "&test_express_mode=1&cmd=showPage&cmdClass=iltestexpresspageobjectgui&baseClass=ilObjTestGUI");
973  }
974  } else {
975  ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&ref_id=" . $ref_id . "&cmd=questions");
976  }
977  }
978  } elseif (isset($_GET['calling_consumer']) && (int) $_GET['calling_consumer']) {
979  $ref_id = (int) $_GET['calling_consumer'];
981  if ($consumer instanceof ilQuestionEditingFormConsumer) {
982  ilUtil::redirect($consumer->getQuestionEditingFormBackTarget($_GET['consumer_context']));
983  }
984  require_once 'Services/Link/classes/class.ilLink.php';
986  }
987 
988  $this->object->purgeQuestions();
989  // reset test_id SESSION variable
990  $_SESSION["test_id"] = "";
991 
992  require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImportFails.php';
993  $qsaImportFails = new ilAssQuestionSkillAssignmentImportFails($this->object->getId());
994  if ($qsaImportFails->failedImportsRegistered()) {
995  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
996  $button = ilLinkButton::getInstance();
997  $button->setUrl($this->ctrl->getLinkTarget($this, 'renoveImportFails'));
998  $button->setCaption('ass_skl_import_fails_remove_btn');
999 
1000  ilUtil::sendFailure($qsaImportFails->getFailedImportsMessage($this->lng) . '<br />' . $button->render());
1001  }
1002 
1003  require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
1004  $taxIds = ilObjTaxonomy::getUsageOfObject($this->object->getId());
1005 
1006  $table_gui = $this->buildQuestionBrowserTableGUI($taxIds);
1007  $table_gui->setPreventDoubleSubmission(false);
1008 
1009  if ($rbacsystem->checkAccess('write', $_GET['ref_id'])) {
1010  $toolbar = new ilToolbarGUI();
1011 
1012  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
1013  $btn = ilLinkButton::getInstance();
1014  $btn->setCaption('ass_create_question');
1015  $btn->setUrl($this->ctrl->getLinkTarget($this, 'createQuestionForm'));
1016  $btn->setPrimary(true);
1017  $toolbar->addButtonInstance($btn);
1018 
1019 
1020  $btnImport = ilLinkButton::getInstance();
1021  $btnImport->setCaption('import');
1022  $btnImport->setUrl($this->ctrl->getLinkTarget($this, 'importQuestions'));
1023  $toolbar->addButtonInstance($btnImport);
1024 
1025  if (array_key_exists("qpl_clipboard", $_SESSION) && count($_SESSION['qpl_clipboard'])) {
1026  $btnPaste = ilLinkButton::getInstance();
1027  $btnPaste->setCaption('paste');
1028  $btnPaste->setUrl($this->ctrl->getLinkTarget($this, 'paste'));
1029  $toolbar->addButtonInstance($btnPaste);
1030  }
1031 
1032  $this->tpl->setContent(
1033  $this->ctrl->getHTML($toolbar) . $this->ctrl->getHTML($table_gui)
1034  );
1035  } else {
1036  $this->tpl->setContent($this->ctrl->getHTML($table_gui));
1037  }
1038 
1039  if ($this->object->getShowTaxonomies()) {
1040  $this->lng->loadLanguageModule('tax');
1041 
1042  require_once 'Services/Taxonomy/classes/class.ilTaxonomyExplorerGUI.php';
1043 
1044  foreach ($taxIds as $taxId) {
1045  if ($taxId != $this->object->getNavTaxonomyId()) {
1046  continue;
1047  }
1048 
1049  $taxExp = new ilTaxonomyExplorerGUI(
1050  $this,
1051  'showNavTaxonomy',
1052  $taxId,
1053  'ilobjquestionpoolgui',
1054  'questions'
1055  );
1056 
1057  if (!$taxExp->handleCommand()) {
1058  $this->tpl->setLeftContent($taxExp->getHTML() . "&nbsp;");
1059  }
1060 
1061  break;
1062  }
1063  }
1064  }
1065 
1070  {
1071  $qId = (int) $_GET['q_id'];
1072 
1073  if ($this->object->checkQuestionParent($qId)) {
1074  return $qId;
1075  }
1076 
1077  throw new ilTestQuestionPoolException('question id does not relate to parent object!');
1078  }
1079 
1080  private function createQuestionFormObject()
1081  {
1082  global $DIC; /* @var \ILIAS\DI\Container $DIC */
1083  $ilHelp = $DIC['ilHelp']; /* @var ilHelpGUI $ilHelp */
1084 
1085  $ilHelp->setScreenId('assQuestions');
1086 
1088  $ilHelp->setSubScreenId('createQuestion_editMode');
1089  } else {
1090  $ilHelp->setSubScreenId('createQuestion');
1091  }
1092 
1093  $form = $this->buildCreateQuestionForm();
1094 
1095  $this->tpl->setContent($this->ctrl->getHTML($form));
1096  }
1097 
1098  private function buildCreateQuestionForm()
1099  {
1100  global $ilUser;
1101 
1102  // form
1103 
1104  require_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1105  $form = new ilPropertyFormGUI();
1106  $form->setTitle($this->lng->txt('ass_create_question'));
1107  $form->setFormAction($this->ctrl->getFormAction($this));
1108 
1109  // question type
1110 
1111  $options = array();
1112  foreach ($this->object->getQuestionTypes(false, true) as $translation => $data) {
1113  $options[$data['type_tag']] = $translation;
1114  }
1115 
1116  require_once("Services/Form/classes/class.ilSelectInputGUI.php");
1117  $si = new ilSelectInputGUI($this->lng->txt('question_type'), 'sel_question_types');
1118  $si->setOptions($options);
1119  //$si->setValue($ilUser->getPref("tst_lastquestiontype"));
1120 
1121  $form->addItem($si);
1122 
1123  // content editing mode
1124 
1126  $ri = new ilRadioGroupInputGUI($this->lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
1127 
1128  $ri->addOption(new ilRadioOption(
1129  $this->lng->txt('tst_add_quest_cont_edit_mode_default'),
1131  ));
1132 
1133  $ri->addOption(new ilRadioOption(
1134  $this->lng->txt('tst_add_quest_cont_edit_mode_page_object'),
1136  ));
1137 
1139 
1140  $form->addItem($ri, true);
1141  } else {
1142  $hi = new ilHiddenInputGUI("question_content_editing_type");
1144  $form->addItem($hi, true);
1145  }
1146 
1147  // commands
1148 
1149  $form->addCommandButton('createQuestion', $this->lng->txt('create'));
1150  $form->addCommandButton('questions', $this->lng->txt('cancel'));
1151 
1152  return $form;
1153  }
1154 
1158  public function printObject()
1159  {
1163  global $ilToolbar;
1164 
1165  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'print'));
1166  require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
1167  $mode = new ilSelectInputGUI($this->lng->txt('output_mode'), 'output');
1168  $mode->setOptions(array(
1169  'overview' => $this->lng->txt('overview'),
1170  'detailed' => $this->lng->txt('detailed_output_solutions'),
1171  'detailed_printview' => $this->lng->txt('detailed_output_printview')
1172  ));
1173  $mode->setValue(ilUtil::stripSlashes($_POST['output']));
1174 
1175  $ilToolbar->setFormName('printviewOptions');
1176  $ilToolbar->addInputItem($mode, true);
1177  $ilToolbar->addFormButton($this->lng->txt('submit'), 'print');
1178 
1179  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionPoolPrintViewTableGUI.php";
1180  $table_gui = new ilQuestionPoolPrintViewTableGUI($this, 'print', $_POST['output']);
1181  $data = $this->object->getPrintviewQuestions();
1182  $totalPoints = 0;
1183  foreach ($data as $d) {
1184  $totalPoints += $d['points'];
1185  }
1186  $table_gui->setTotalPoints($totalPoints);
1187  $table_gui->initColumns();
1188  $table_gui->setData($data);
1189  $this->tpl->setContent($table_gui->getHTML());
1190  }
1191 
1192  public function updateObject()
1193  {
1194  // $this->update = $this->object->updateMetaData();
1195  $this->update = $this->object->update();
1196  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1197  }
1198 
1202  public function pasteObject()
1203  {
1204  if (array_key_exists("qpl_clipboard", $_SESSION)) {
1205  if ($this->object->pasteFromClipboard()) {
1206  ilUtil::sendSuccess($this->lng->txt("qpl_paste_success"), true);
1207  } else {
1208  ilUtil::sendFailure($this->lng->txt("qpl_paste_error"), true);
1209  }
1210  } else {
1211  ilUtil::sendInfo($this->lng->txt("qpl_paste_no_objects"), true);
1212  }
1213  $this->ctrl->redirect($this, "questions");
1214  }
1215 
1219  public function copyObject()
1220  {
1221  if (isset($_POST["q_id"]) && is_array($_POST["q_id"]) && count($_POST["q_id"]) > 0) {
1222  foreach ($_POST["q_id"] as $key => $value) {
1223  $this->object->copyToClipboard($value);
1224  }
1225  ilUtil::sendInfo($this->lng->txt("qpl_copy_insert_clipboard"), true);
1226  } elseif (isset($_GET['q_id']) && $_GET['q_id'] > 0) {
1227  $this->object->copyToClipboard((int) $_GET['q_id']);
1228  ilUtil::sendInfo($this->lng->txt("qpl_copy_insert_clipboard"), true);
1229  } else {
1230  ilUtil::sendInfo($this->lng->txt("qpl_copy_select_none"), true);
1231  }
1232  $this->ctrl->redirect($this, "questions");
1233  }
1234 
1238  public function moveObject()
1239  {
1240  if (isset($_POST["q_id"]) && is_array($_POST["q_id"]) && count($_POST["q_id"]) > 0) {
1241  foreach ($_POST["q_id"] as $key => $value) {
1242  $this->object->moveToClipboard($value);
1243  }
1244  ilUtil::sendInfo($this->lng->txt("qpl_move_insert_clipboard"), true);
1245  } elseif (isset($_GET['q_id']) && $_GET['q_id'] > 0) {
1246  $this->object->moveToClipboard((int) $_GET['q_id']);
1247  ilUtil::sendInfo($this->lng->txt("qpl_copy_insert_clipboard"), true);
1248  } else {
1249  ilUtil::sendInfo($this->lng->txt("qpl_move_select_none"), true);
1250  }
1251  $this->ctrl->redirect($this, "questions");
1252  }
1253 
1254  public function createExportExcel()
1255  {
1256  global $rbacsystem;
1257  if ($rbacsystem->checkAccess("write", $_GET['ref_id'])) {
1258  include_once("./Modules/TestQuestionPool/classes/class.ilQuestionpoolExport.php");
1259  $question_ids =&$this->object->getAllQuestionIds();
1260  $qpl_exp = new ilQuestionpoolExport($this->object, 'xls', $question_ids);
1261  $qpl_exp->buildExportFile();
1262  $this->ctrl->redirectByClass("ilquestionpoolexportgui", "");
1263  }
1264  }
1265 
1269  public function &editQuestionForTestObject()
1270  {
1271  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1272  $q_gui =&assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1273  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
1274  }
1275 
1276  protected function initImportForm($a_new_type)
1277  {
1278  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1279  $form = new ilPropertyFormGUI();
1280  $form->setTarget("_top");
1281  $form->setFormAction($this->ctrl->getFormAction($this));
1282  $form->setTitle($this->lng->txt("import_qpl"));
1283 
1284  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
1285  $fi = new ilFileInputGUI($this->lng->txt("import_file"), "xmldoc");
1286  $fi->setSuffixes(array("zip"));
1287  $fi->setRequired(true);
1288  $form->addItem($fi);
1289 
1290  $form->addCommandButton("importFile", $this->lng->txt("import"));
1291  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
1292 
1293  return $form;
1294  }
1295 
1299  protected function importFileObject($parent_id = null, $a_catch_errors = true)
1300  {
1301  $form = $this->initImportForm($_REQUEST["new_type"]);
1302  if ($form->checkInput()) {
1303  $this->uploadQplObject();
1304  }
1305 
1306  // display form to correct errors
1307  $this->tpl->setContent($form->getHTML());
1308  }
1309 
1310  public function addLocatorItems()
1311  {
1312  global $ilLocator;
1313  switch ($this->ctrl->getCmd()) {
1314  case "create":
1315  case "importFile":
1316  case "cancel":
1317  break;
1318  default:
1319  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
1320  break;
1321  }
1322  if ($_GET["q_id"] > 0) {
1323  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1324  $q_gui = assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1325  if ($q_gui->object instanceof assQuestion) {
1326  $q_gui->object->setObjId($this->object->getId());
1327  $title = $q_gui->object->getTitle();
1328  if (!$title) {
1329  $title = $this->lng->txt('new') . ': ' . assQuestion::_getQuestionTypeName($q_gui->object->getQuestionType());
1330  }
1331  $ilLocator->addItem($title, $this->ctrl->getLinkTargetByClass(get_class($q_gui), "editQuestion"));
1332  } else {
1333  // Workaround for context issues: If no object was found, redirect without q_id parameter
1334  $this->ctrl->setParameter($this, 'q_id', '');
1335  $this->ctrl->redirect($this);
1336  }
1337  }
1338  }
1339 
1343  public function setTitleAndDescription()
1344  {
1345  parent::setTitleAndDescription();
1346  if ($_GET["q_id"] > 0) {
1347  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1348  $q_gui = assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1349  if ($q_gui->object instanceof assQuestion) {
1350  $q_gui->object->setObjId($this->object->getId());
1351  $title = $q_gui->object->getTitle();
1352  if (!$title) {
1353  $title = $this->lng->txt('new') . ': ' . assQuestion::_getQuestionTypeName($q_gui->object->getQuestionType());
1354  }
1355  $this->tpl->setTitle($title);
1356  $this->tpl->setDescription($q_gui->object->getComment());
1357  $this->tpl->setTitleIcon(ilObject2::_getIcon("", "big", $this->object->getType()));
1358  } else {
1359  // Workaround for context issues: If no object was found, redirect without q_id parameter
1360  $this->ctrl->setParameter($this, 'q_id', '');
1361  $this->ctrl->redirect($this);
1362  }
1363  } else {
1364  $this->tpl->setTitle($this->object->getTitle());
1365  $this->tpl->setDescription($this->object->getLongDescription());
1366  $this->tpl->setTitleIcon(ilObject2::_getIcon("", "big", $this->object->getType()));
1367  }
1368  }
1369 
1375  public function getTabs()
1376  {
1377  global $ilAccess, $ilHelp;
1378 
1379  $currentUserHasWriteAccess = $ilAccess->checkAccess("write", "", $this->object->getRefId());
1380 
1381  $ilHelp->setScreenIdComponent("qpl");
1382 
1383  $next_class = strtolower($this->ctrl->getNextClass());
1384  switch ($next_class) {
1385  case "":
1386  case "ilpermissiongui":
1387  case "ilobjectmetadatagui":
1388  case "ilquestionpoolexportgui":
1389  case "ilquestionpoolskilladministrationgui":
1390  break;
1391 
1392  case 'ilobjtaxonomygui':
1393  case 'ilobjquestionpoolsettingsgeneralgui':
1394 
1395  if ($currentUserHasWriteAccess) {
1396  $this->addSettingsSubTabs($this->tabs_gui);
1397  }
1398 
1399  break;
1400 
1401  default:
1402  return;
1403  break;
1404  }
1405  // questions
1406  $force_active = false;
1407  $commands = $_POST["cmd"];
1408  if (is_array($commands)) {
1409  foreach ($commands as $key => $value) {
1410  if (preg_match("/^delete_.*/", $key, $matches) ||
1411  preg_match("/^addSelectGap_.*/", $key, $matches) ||
1412  preg_match("/^addTextGap_.*/", $key, $matches) ||
1413  preg_match("/^deleteImage_.*/", $key, $matches) ||
1414  preg_match("/^upload_.*/", $key, $matches) ||
1415  preg_match("/^addSuggestedSolution_.*/", $key, $matches)
1416  ) {
1417  $force_active = true;
1418  }
1419  }
1420  }
1421  if (array_key_exists("imagemap_x", $_POST)) {
1422  $force_active = true;
1423  }
1424  if (!$force_active) {
1425  $force_active = ((strtolower($this->ctrl->getCmdClass()) == strtolower(get_class($this)) || strlen($this->ctrl->getCmdClass()) == 0) &&
1426  $this->ctrl->getCmd() == "")
1427  ? true
1428  : false;
1429  }
1430  $this->tabs_gui->addTarget(
1431  "assQuestions",
1432  $this->ctrl->getLinkTarget($this, "questions"),
1433  array("questions", "filter", "resetFilter", "createQuestion",
1434  "importQuestions", "deleteQuestions", "filterQuestionBrowser",
1435  "view", "preview", "editQuestion", "exec_pg",
1436  "addItem", "upload", "save", "cancel", "addSuggestedSolution",
1437  "cancelExplorer", "linkChilds", "removeSuggestedSolution",
1438  "add", "addYesNo", "addTrueFalse", "createGaps", "saveEdit",
1439  "setMediaMode", "uploadingImage", "uploadingImagemap", "addArea",
1440  "deletearea", "saveShape", "back", "addPair", "uploadingJavaapplet",
1441  "addParameter", "assessment", "addGIT", "addST", "addPG", "delete",
1442  "toggleGraphicalAnswers", "deleteAnswer", "deleteImage", "removeJavaapplet"),
1443  "",
1444  "",
1445  $force_active
1446  );
1447 
1448  if ($ilAccess->checkAccess("read", "", $this->ref_id) || $ilAccess->checkAccess("visible", "", $this->ref_id)) {
1449  $this->tabs_gui->addTarget(
1450  "info_short",
1451  $this->ctrl->getLinkTarget($this, "infoScreen"),
1452  array("infoScreen", "showSummary")
1453  );
1454  }
1455 
1456  if ($ilAccess->checkAccess("write", "", $_GET['ref_id'])) {
1457  // properties
1458  $this->tabs_gui->addTarget(
1459  'settings',
1460  $this->ctrl->getLinkTargetByClass('ilObjQuestionPoolSettingsGeneralGUI'),
1461  array(),
1462  array('ilObjQuestionPoolSettingsGeneralGUI', 'ilObjTaxonomyGUI')
1463  );
1464 
1465  // skill service
1466  if ($this->isSkillsTabRequired()) {
1467  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentsGUI.php';
1468 
1469  $link = $this->ctrl->getLinkTargetByClass(
1470  array('ilQuestionPoolSkillAdministrationGUI', 'ilAssQuestionSkillAssignmentsGUI'),
1472  );
1473 
1474  $this->tabs_gui->addTarget('qpl_tab_competences', $link, array(), array());
1475  }
1476  }
1477 
1478  // print view
1479  $this->tabs_gui->addTarget(
1480  "print_view",
1481  $this->ctrl->getLinkTarget($this, 'print'),
1482  array("print"),
1483  "",
1484  ""
1485  );
1486 
1487  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1488  // meta data
1489  include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
1490  $mdgui = new ilObjectMetaDataGUI($this->object);
1491  $mdtab = $mdgui->getTab();
1492  if ($mdtab) {
1493  $this->tabs_gui->addTarget(
1494  "meta_data",
1495  $mdtab,
1496  "",
1497  "ilmdeditorgui"
1498  );
1499  }
1500 
1501  // $this->tabs_gui->addTarget("export",
1502 // $this->ctrl->getLinkTarget($this,'export'),
1503 // array("export", "createExportFile", "confirmDeleteExportFile", "downloadExportFile"),
1504 // "", "");
1505  }
1506 
1507  if ($currentUserHasWriteAccess) {
1508  $this->tabs_gui->addTarget(
1509  "export",
1510  $this->ctrl->getLinkTargetByClass("ilquestionpoolexportgui", ""),
1511  "",
1512  "ilquestionpoolexportgui"
1513  );
1514  }
1515 
1516  if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId())) {
1517  $this->tabs_gui->addTarget(
1518  "perm_settings",
1519  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
1520  array("perm","info","owner"),
1521  'ilpermissiongui'
1522  );
1523  }
1524  }
1525 
1526  private function isSkillsTabRequired()
1527  {
1528  if (!($this->object instanceof ilObjQuestionPool)) {
1529  return false;
1530  }
1531 
1532  if (!$this->object->isSkillServiceEnabled()) {
1533  return false;
1534  }
1535 
1537  return false;
1538  }
1539 
1540  return true;
1541  }
1542 
1544  {
1545  $tabs->addSubTabTarget(
1546  'qpl_settings_subtab_general',
1547  $this->ctrl->getLinkTargetByClass('ilObjQuestionPoolSettingsGeneralGUI'),
1548  '',
1549  'ilObjQuestionPoolSettingsGeneralGUI'
1550  );
1551 
1552  $tabs->addSubTabTarget(
1553  'qpl_settings_subtab_taxonomies',
1554  $this->ctrl->getLinkTargetByClass('ilObjTaxonomyGUI', 'editAOTaxonomySettings'),
1555  '',
1556  'ilObjTaxonomyGUI'
1557  );
1558  }
1559 
1565  public function infoScreenObject()
1566  {
1567  $this->ctrl->setCmd("showSummary");
1568  $this->ctrl->setCmdClass("ilinfoscreengui");
1569  $this->infoScreenForward();
1570  }
1571 
1575  public function infoScreenForward()
1576  {
1577  global $ilErr, $ilAccess;
1578 
1579  if (!$ilAccess->checkAccess("visible", "", $this->ref_id)) {
1580  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
1581  }
1582 
1583  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1584  $info = new ilInfoScreenGUI($this);
1585  $info->enablePrivateNotes();
1586 
1587  // standard meta data
1588  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
1589 
1590  $this->ctrl->forwardCommand($info);
1591  }
1592 
1601  public static function _goto($a_target)
1602  {
1603  global $ilAccess, $ilErr, $lng;
1604 
1605  if ($ilAccess->checkAccess("write", "", $a_target) || $ilAccess->checkAccess('read', '', $a_target)) {
1606  $_GET['cmdClass'] = 'ilObjQuestionPoolGUI';
1607  $_GET['cmd'] = 'questions';
1608  $_GET['baseClass'] = 'ilRepositoryGUI';
1609  $_GET["ref_id"] = $a_target;
1610  include_once("ilias.php");
1611  exit;
1612  } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1613  ilUtil::sendInfo(sprintf(
1614  $lng->txt("msg_no_perm_read_item"),
1616  ), true);
1618  }
1619  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
1620  }
1621 
1630  private function buildQuestionBrowserTableGUI($taxIds)
1631  {
1632  global $rbacsystem, $ilDB, $lng, $ilPluginAdmin;
1633 
1634  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
1635  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', (($rbacsystem->checkAccess('write', $_GET['ref_id']) ? true : false)), false, $taxIds);
1636  $table_gui->setEditable($rbacsystem->checkAccess('write', $_GET['ref_id']));
1637 
1638  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
1639  $questionList = new ilAssQuestionList($ilDB, $lng, $ilPluginAdmin);
1640  $questionList->setParentObjId($this->object->getId());
1641 
1642  foreach ($table_gui->getFilterItems() as $item) {
1643  if (substr($item->getPostVar(), 0, strlen('tax_')) == 'tax_') {
1644  $v = $item->getValue();
1645 
1646  if (is_array($v) && count($v) && !(int) $v[0]) {
1647  continue;
1648  }
1649 
1650  $taxId = substr($item->getPostVar(), strlen('tax_'));
1651 
1652  $questionList->addTaxonomyFilter(
1653  $taxId,
1654  $item->getValue(),
1655  $this->object->getId(),
1656  $this->object->getType()
1657  );
1658  } elseif ($item->getValue() !== false) {
1659  $questionList->addFieldFilter($item->getPostVar(), $item->getValue());
1660  }
1661  }
1662 
1663  if ($this->object->isNavTaxonomyActive() && (int) $_GET['tax_node']) {
1664  require_once 'Services/Taxonomy/classes/class.ilTaxonomyTree.php';
1665  $taxTree = new ilTaxonomyTree($this->object->getNavTaxonomyId());
1666  $rootNodeId = $taxTree->readRootId();
1667 
1668  if ((int) $_GET['tax_node'] != $rootNodeId) {
1669  $questionList->addTaxonomyFilter(
1670  $this->object->getNavTaxonomyId(),
1671  array((int) $_GET['tax_node']),
1672  $this->object->getId(),
1673  $this->object->getType()
1674  );
1675  }
1676  }
1677 
1678  $questionList->load();
1679  $data = $questionList->getQuestionDataArray();
1680 
1681  $table_gui->setData($data);
1682 
1683  return $table_gui;
1684  }
1685 } // END class.ilObjQuestionPoolGUI
const MATCHING_QUESTION_IDENTIFIER
const MULTIPLE_CHOICE_QUESTION_IDENTIFIER
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _goto($a_target)
Redirect script to call a test with the question pool reference id.
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
& createQuestionForTestObject()
create new question
This class represents an option in a radio group.
Class ilObjectMetaDataGUI.
Content Object Parser.
Class ilInfoScreenGUI.
addSubTabTarget( $a_text, $a_link, $a_cmd="", $a_cmdClass="", $a_frame="", $a_activate=false, $a_dir_text=false)
DEPRECATED.
Export User Interface Class.
$_SESSION["AccountId"]
This class represents a selection list property in a property form.
$result
Tabs GUI.
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
copyObject()
copy one or more question objects to the clipboard
This class represents a property form user interface.
confirmDeleteQuestionsObject()
delete questions
GUI class for the workflow of copying objects.
$type
global $DIC
Definition: saml.php:7
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
const ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT
constant for additional content editing mode "pageobject"
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
filterObject()
set question list filter
Abstract basic class which is to be extended by the concrete assessment question type classes...
This class represents a file property in a property form.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
const KPRIM_CHOICE_QUESTION_IDENTIFIER
Taxonomy explorer GUI class.
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
const LONG_MENU_QUESTION_IDENTIFIER
Class ilUnitConfigurationRepository.
const TEXTSUBSET_QUESTION_IDENTIFIER
__construct()
Constructor public.
Question page object.
Import class.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
static _lookupTitle($a_id)
lookup object title
getTabs()
adds tabs to tab gui object
download_paragraphObject()
download source code paragraph
exportObject()
Gateway for exports initiated from workspace, as there is a generic forward to {objTypeMainGUI}export...
Question page GUI class.
const JAVAAPPLET_QUESTION_IDENTIFIER
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$xml
Definition: metadata.php:240
This class represents a hidden form property in a property form.
prepareOutput($a_show_subobjects=true)
prepare output
& editQuestionForTestObject()
edit question
importQuestionsObject(ilPropertyFormGUI $form=null)
display the import form to import questions into the questionpool
Export class for questionpools.
This class represents a property in a property form.
addOption($a_option)
Add Option.
deleteQuestionsObject()
delete questions confirmation screen
const NUMERIC_QUESTION_IDENTIFIER
if(isset($_POST['submit'])) $form
const IL_MO_PARSE_QTI
setTitleAndDescription()
called by prepare output
questionsObject()
list questions of question pool
static _getQuestionGUI($question_type, $question_id=-1)
Creates a question gui representation and returns the alias to the question gui note: please do not u...
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
const ORDERING_QUESTION_IDENTIFIER
uploadQplObject($questions_only=false)
imports question(s) into the questionpool
cancelDeleteQuestionsObject()
Cancel question deletion.
static _setImportDirectory($a_import_dir=null)
set import directory
const IL_COMP_MODULE
$ilUser
Definition: imgupload.php:18
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getSyntaxStylePath()
get syntax style path
importVerifiedFileObject()
imports question(s) into the questionpool (after verification)
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static getContentStylePath($a_style_id, $add_random=true)
get content style path
setOptions($a_options)
Set Options.
const TEXT_QUESTION_IDENTIFIER
$consumer
Definition: demo.php:30
Class ilObjQuestionPoolGUI.
Create styles array
The data for the language used.
& createQuestionObject()
create new question
moveObject()
mark one or more question objects for moving
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$rows
Definition: xhr_table.php:10
const ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT
constant for additional content editing mode "default"
update($pash, $contents, Config $config)
if(!empty($this->data['faventry'])) $tabs
Definition: disco.tpl.php:124
fullscreenObject()
show fullscreen view
afterSave(ilObject $a_new_object)
save object public
Create new PHPExcel object
obj_idprivate
pasteObject()
paste questios from the clipboard into the question pool
global $ilDB
$ret
Definition: parser.php:6
static isAdditionalQuestionContentEditingModePageObjectEnabled()
returns the fact wether content editing with ilias page editor is enabled for questions or not ...
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
getCreationMode()
get creation mode
getRefId()
get reference id public
exportQuestionObject()
export question
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilLocalUnitConfigurationGUI.
infoScreenForward()
show information screen
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static _getImportDirectory()
get import directory of lm
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
if(empty($password)) $table
Definition: pwgen.php:24
importFileObject($parent_id=null, $a_catch_errors=true)
form for new questionpool object import
const IL_MO_VERIFY_QTI
$info
Definition: index.php:5
static redirect($a_script)
static _createImportDirectory()
creates data directory for import files (data_dir/qpl_data/qpl_<id>/import, depending on data directo...
const SINGLE_CHOICE_QUESTION_IDENTIFIER
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
$key
Definition: croninfo.php:18
setSuffixes($a_suffixes)
Set Accepted Suffixes.
$_POST["username"]
const CLOZE_TEST_IDENTIFIER
Question identifier constants.
uploadObject()
imports question(s) into the questionpool
static _setImportDirectory($a_import_dir=null)
set import directory
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
const IMAGEMAP_QUESTION_IDENTIFIER
readRootId()
read root id from database