ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  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  {
83  global $ilias;
84  $ilias->raiseError($this->lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
85  }
86 
87  // add entry to navigation history
88  if (!$this->getCreationMode() &&
89  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
90  {
91  if('qpl' == $this->object->getType())
92  {
93  $ilNavigationHistory->addItem($_GET["ref_id"],
94  "ilias.php?baseClass=ilObjQuestionPoolGUI&cmd=questions&ref_id=".$_GET["ref_id"], "qpl");
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  {
103  $_GET['q_id'] = '';
104  }
105 
106  $this->prepareOutput();
107 
108  $this->ctrl->setReturn($this, "questions");
109 
110  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
111  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "ta.css", "Modules/Test"), "screen");
112 
113  if ($_GET["q_id"] < 1)
114  {
115  $q_type = ($_POST["sel_question_types"] != "")
116  ? $_POST["sel_question_types"]
117  : $_GET["sel_question_types"];
118  }
119  if ($cmd != "createQuestion" && $cmd != "createQuestionForTest"
120  && $next_class != "ilassquestionpagegui")
121  {
122  if (($_GET["test_ref_id"] != "") or ($_GET["calling_test"]))
123  {
124  $ref_id = $_GET["test_ref_id"];
125  if (!$ref_id)
126  {
127  $ref_id = $_GET["calling_test"];
128  }
129  }
130  }
131  switch($next_class)
132  {
133  case "ilcommonactiondispatchergui":
134  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
136  $this->ctrl->forwardCommand($gui);
137  break;
138 
139  case 'ilobjectmetadatagui':
140  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
141  {
142  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
143  }
144  include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
145  $md_gui = new ilObjectMetaDataGUI($this->object);
146  $this->ctrl->forwardCommand($md_gui);
147  break;
148 
149  case 'ilassquestionpreviewgui':
150 
151  $this->ctrl->saveParameter($this, "q_id");
152 
153  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewGUI.php';
154  $gui = new ilAssQuestionPreviewGUI($this->ctrl, $this->tabs_gui, $this->tpl, $this->lng, $ilDB, $ilUser);
155 
156  $gui->initQuestion((int)$_GET['q_id'], $this->object->getId());
157  $gui->initPreviewSettings($this->object->getRefId());
158  $gui->initPreviewSession($ilUser->getId(), $this->fetchAuthoringQuestionIdParamater());
159  $gui->initHintTracking();
160  $gui->initStyleSheets();
161 
162  global $ilHelp;
163  $ilHelp->setScreenIdComponent("qpl");
164 
165  $this->ctrl->forwardCommand($gui);
166  break;
167 
168  case "ilassquestionpagegui":
169  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
170  $this->tpl->setCurrentBlock("ContentStyle");
171  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
172  $this->tpl->parseCurrentBlock();
173 
174  // syntax style
175  $this->tpl->setCurrentBlock("SyntaxStyle");
176  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
177  $this->tpl->parseCurrentBlock();
178 
179  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
181  $q_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
182  $q_gui->setQuestionTabs();
183  $q_gui->outAdditionalOutput();
184  $q_gui->object->setObjId($this->object->getId());
185 
186  $q_gui->setTargetGuiClass(null);
187  $q_gui->setQuestionActionCmd(null);
188 
189  $question = $q_gui->object;
190  $this->ctrl->saveParameter($this, "q_id");
191  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
192  $this->lng->loadLanguageModule("content");
193  $this->ctrl->setReturnByClass("ilAssQuestionPageGUI", "view");
194  $this->ctrl->setReturn($this, "questions");
195  $page_gui = new ilAssQuestionPageGUI($_GET["q_id"]);
196  $page_gui->obj->addUpdateListener(
197  $question,
198  'updateTimestamp'
199  );
200  $page_gui->setEditPreview(true);
201  $page_gui->setEnabledTabs(false);
202  if (strlen($this->ctrl->getCmd()) == 0 && !isset($_POST["editImagemapForward_x"])) // workaround for page edit imagemaps, keep in mind
203  {
204  $this->ctrl->setCmdClass(get_class($page_gui));
205  $this->ctrl->setCmd("preview");
206  }
207  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(TRUE)));
208  $page_gui->setTemplateTargetVar("ADM_CONTENT");
209  $page_gui->setOutputMode("edit");
210  $page_gui->setHeader($question->getTitle());
211  $page_gui->setPresentationTitle($question->getTitle());
212  $ret = $this->ctrl->forwardCommand($page_gui);
213  $tpl->setContent($ret);
214  break;
215 
216  case 'ilpermissiongui':
217  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
218  $perm_gui = new ilPermissionGUI($this);
219  $ret = $this->ctrl->forwardCommand($perm_gui);
220  break;
221 
222  case 'ilobjectcopygui':
223  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
224  $cp = new ilObjectCopyGUI($this);
225  $cp->setType('qpl');
226  $this->ctrl->forwardCommand($cp);
227  break;
228 
229  case "ilquestionpoolexportgui":
230  require_once 'Modules/TestQuestionPool/classes/class.ilQuestionPoolExportGUI.php';
231  $exp_gui = new ilQuestionPoolExportGUI($this);
232  $exp_gui->addFormat('xml', $this->lng->txt('qpl_export_xml'));
233  $exp_gui->addFormat('xls', $this->lng->txt('qpl_export_excel'), $this, 'createExportExcel');
234  $ret = $this->ctrl->forwardCommand($exp_gui);
235  break;
236 
237  case "ilinfoscreengui":
238  $this->infoScreenForward();
239  break;
240 
241  case 'ilassquestionhintsgui':
242 
243  // set return target
244  $this->ctrl->setReturn($this, "questions");
245 
246  // set context tabs
247  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
248  $questionGUI = assQuestionGUI::_getQuestionGUI($q_type, $this->fetchAuthoringQuestionIdParamater());
249  $questionGUI->object->setObjId($this->object->getId());
250  $questionGUI->setQuestionTabs();
251  global $ilHelp;
252  $ilHelp->setScreenIdComponent("qpl");
253 
254  // forward to ilAssQuestionHintsGUI
255  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsGUI.php';
256  $gui = new ilAssQuestionHintsGUI($questionGUI);
257 
258  global $DIC; /* @var ILIAS\DI\Container $DIC */
259 
260  $gui->setEditingEnabled(
261  $DIC->access()->checkAccess('write', '', $this->object->getRefId())
262  );
263 
264  $ilCtrl->forwardCommand($gui);
265 
266  break;
267 
268  case 'illocalunitconfigurationgui':
269  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
270  {
271  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
272  }
273 
274  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
275  $questionGUI = assQuestionGUI::_getQuestionGUI($q_type, $this->fetchAuthoringQuestionIdParamater());
276  $questionGUI->object->setObjId($this->object->getId());
277  $questionGUI->setQuestionTabs();
278 
279  $this->ctrl->setReturn($this, 'questions');
280 
281  require_once 'Modules/TestQuestionPool/classes/class.ilLocalUnitConfigurationGUI.php';
282  require_once 'Modules/TestQuestionPool/classes/class.ilUnitConfigurationRepository.php';
283  $gui = new ilLocalUnitConfigurationGUI(
284  new ilUnitConfigurationRepository((int)$_GET['q_id'])
285  );
286  $ilCtrl->forwardCommand($gui);
287  break;
288 
289  case 'ilassquestionfeedbackeditinggui':
290 
291  // set return target
292  $this->ctrl->setReturn($this, "questions");
293 
294  // set context tabs
295  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
296  $questionGUI = assQuestionGUI::_getQuestionGUI($q_type, $this->fetchAuthoringQuestionIdParamater());
297  $questionGUI->object->setObjId($this->object->getId());
298  $questionGUI->setQuestionTabs();
299  global $ilHelp;
300  $ilHelp->setScreenIdComponent("qpl");
301 
302  // forward to ilAssQuestionFeedbackGUI
303  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackEditingGUI.php';
304  $gui = new ilAssQuestionFeedbackEditingGUI($questionGUI, $ilCtrl, $ilAccess, $tpl, $ilTabs, $lng);
305  $ilCtrl->forwardCommand($gui);
306 
307  break;
308 
309  case 'ilobjquestionpoolsettingsgeneralgui':
310  require_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPoolSettingsGeneralGUI.php';
311  $gui = new ilObjQuestionPoolSettingsGeneralGUI($ilCtrl, $ilAccess, $lng, $tpl, $ilTabs, $this);
312  $this->ctrl->forwardCommand($gui);
313  break;
314 
315  case "ilobjtaxonomygui":
316 
317  require_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPoolTaxonomyEditingCommandForwarder.php';
319  $this->object, $ilDB, $ilPluginAdmin, $ilCtrl, $ilTabs, $lng
320  );
321 
322  $forwarder->forward();
323 
324  break;
325 
326  case 'ilquestionpoolskilladministrationgui':
327 
328  require_once 'Modules/TestQuestionPool/classes/class.ilQuestionPoolSkillAdministrationGUI.php';
330  $ilias, $ilCtrl, $ilAccess, $ilTabs, $tpl, $lng, $ilDB, $ilPluginAdmin, $this->object, $this->ref_id
331  );
332 
333  $this->ctrl->forwardCommand($gui);
334 
335  break;
336 
337  case 'ilquestionbrowsertablegui':
338  $this->ctrl->forwardCommand($this->buildQuestionBrowserTableGUI($taxIds = array())); // no tax ids required
339  break;
340 
341  case "ilobjquestionpoolgui":
342  case "":
343 
344  if( $cmd == 'questions' )
345  {
346  $this->ctrl->setParameter($this, 'q_id', '');
347  }
348 
349  $cmd.= "Object";
350  $ret = $this->$cmd();
351  break;
352 
353  default:
354  $this->ctrl->setReturn($this, "questions");
355  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
357  $q_gui->setEditContext(assQuestionGUI::EDIT_CONTEXT_AUTHORING);
358  $q_gui->object->setObjId($this->object->getId());
359  if($this->object->getType() == 'qpl')
360  {
361  $q_gui->setTaxonomyIds($this->object->getTaxonomyIds());
362  $this->object->addQuestionChangeListeners($q_gui->object);
363  }
364  $q_gui->setQuestionTabs();
365  global $ilHelp;
366  $ilHelp->setScreenIdComponent("qpl");
367  $ret = $this->ctrl->forwardCommand($q_gui);
368  break;
369  }
370 
371  if ( !(strtolower($_GET["baseClass"]) == "iladministrationgui"
372  || strtolower($_GET['baseClass']) == 'ilrepositorygui')
373  && $this->getCreationMode() != true)
374  {
375  $this->tpl->show();
376  }
377  }
378 
383  protected function exportObject()
384  {
385  global $DIC; /* @var ILIAS\DI\Container $DIC */
386  $DIC->ctrl()->redirectByClass('ilQuestionPoolExportGUI');
387  }
388 
393  {
394  $file = explode("_", $_GET["file_id"]);
395  include_once("./Modules/File/classes/class.ilObjFile.php");
396  $fileObj = new ilObjFile($file[count($file) - 1], false);
397  $fileObj->sendFile();
398  exit;
399  }
400 
404  function fullscreenObject()
405  {
406  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
407  $page_gui = new ilAssQuestionPageGUI($_GET["pg_id"]);
408  $page_gui->showMediaFullscreen();
409  }
410 
411 
415  function filterObject()
416  {
417  $this->questionsObject();
418  }
419 
423  function resetFilterObject()
424  {
425  $_POST["filter_text"] = "";
426  $_POST["sel_filter_type"] = "";
427  $this->questionsObject();
428  }
429 
434  {
435  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
436  $pg_obj = new ilAssQuestionPage($_GET["pg_id"]);
437  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
438  exit;
439  }
440 
444  function uploadQplObject($questions_only = false)
445  {
446  $this->ctrl->setParameter($this, 'new_type', $_REQUEST['new_type']);
447  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
448  {
449  ilUtil::sendFailure($this->lng->txt("error_upload"), true);
450  if(!$questions_only)
451  {
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  {
469  $qti_file = $full_path;
471  }
472  else
473  {
474  // unzip file
475  ilUtil::unzip($full_path);
476 
477  // determine filenames of xml files
478  $subdir = basename($file["basename"],".".$file["extension"]);
480  $xml_file = ilObjQuestionPool::_getImportDirectory().'/'.$subdir.'/'.$subdir.".xml";
481  $qti_file = ilObjQuestionPool::_getImportDirectory().'/'.$subdir.'/'. str_replace("qpl", "qti", $subdir).".xml";
482  }
483 
484  // start verification of QTI files
485  include_once "./Services/QTI/classes/class.ilQTIParser.php";
486  $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
487  $result = $qtiParser->startParsing();
488  $founditems =& $qtiParser->getFoundItems();
489  if (count($founditems) == 0)
490  {
491  // nothing found
492 
493  // delete import directory
494  ilUtil::delDir($basedir);
495 
496  ilUtil::sendFailure($this->lng->txt("qpl_import_no_items"), true);
497  if(!$questions_only)
498  {
499  $this->ctrl->redirect($this, 'create');
500  }
501  return false;
502  }
503 
504  $complete = 0;
505  $incomplete = 0;
506  foreach ($founditems as $item)
507  {
508  if (strlen($item["type"]))
509  {
510  $complete++;
511  }
512  else
513  {
514  $incomplete++;
515  }
516  }
517 
518  if ($complete == 0)
519  {
520  // delete import directory
521  ilUtil::delDir($basedir);
522 
523  ilUtil::sendFailure($this->lng->txt("qpl_import_non_ilias_files"), true);
524  if(!$questions_only)
525  {
526  $this->ctrl->redirect($this, 'create');
527  }
528  return false;
529  }
530 
531  $_SESSION["qpl_import_xml_file"] = $xml_file;
532  $_SESSION["qpl_import_qti_file"] = $qti_file;
533  $_SESSION["qpl_import_subdir"] = $subdir;
534 
535  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_import_verification.html", "Modules/TestQuestionPool");
536 
537  require_once 'Modules/TestQuestionPool/classes/tables/class.ilQuestionPoolImportVerificationTableGUI.php';
538  $table = new ilQuestionPoolImportVerificationTableGUI($this, 'uploadQplObject');
539  $rows = array();
540 
541  foreach($founditems as $item)
542  {
543  $row = array(
544  'title' => $item['title'],
545  'ident' => $item['ident'],
546  );
547 
548  include_once "./Services/QTI/classes/class.ilQTIItem.php";
549  switch ($item["type"])
550  {
552  $type = $this->lng->txt("assClozeTest");
553  break;
555  $type = $this->lng->txt("assImagemapQuestion");
556  break;
558  $type = $this->lng->txt("assJavaApplet");
559  break;
561  $type = $this->lng->txt("assMatchingQuestion");
562  break;
564  $type = $this->lng->txt("assMultipleChoice");
565  break;
567  $type = $this->lng->txt("assKprimChoice");
568  break;
570  $type = $this->lng->txt("assLongMenu");
571  break;
573  $type = $this->lng->txt("assSingleChoice");
574  break;
576  $type = $this->lng->txt("assOrderingQuestion");
577  break;
579  $type = $this->lng->txt("assTextQuestion");
580  break;
582  $type = $this->lng->txt("assNumeric");
583  break;
585  $type = $this->lng->txt("assTextSubset");
586  break;
587  default:
588  $type = $this->lng->txt($item["type"]);
589  break;
590  }
591 
592  if (strcmp($type, "-" . $item["type"] . "-") == 0)
593  {
594  global $ilPluginAdmin;
595  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "TestQuestionPool", "qst");
596  foreach ($pl_names as $pl_name)
597  {
598  $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "TestQuestionPool", "qst", $pl_name);
599  if (strcmp($pl->getQuestionType(), $item["type"]) == 0)
600  {
601  $type = $pl->getQuestionTypeTranslation();
602  }
603  }
604  }
605 
606  $row['type'] = $type;
607 
608  $rows[] = $row;
609  }
610  $table->setData($rows);
611 
612  $this->tpl->setCurrentBlock("import_qpl");
613  if (is_file($xml_file))
614  {
615  // read file into a string
616  $fh = @fopen($xml_file, "r") or die("");
617  $xml = @fread($fh, filesize($xml_file));
618  @fclose($fh);
619  if (preg_match("/<ContentObject.*?MetaData.*?General.*?Title[^>]*?>([^<]*?)</", $xml, $matches))
620  {
621  $this->tpl->setVariable("VALUE_NEW_QUESTIONPOOL", $matches[1]);
622  }
623  }
624  $this->tpl->setVariable("TEXT_CREATE_NEW_QUESTIONPOOL", $this->lng->txt("qpl_import_create_new_qpl"));
625  $this->tpl->parseCurrentBlock();
626 
627  $this->tpl->setCurrentBlock("adm_content");
628  $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("qpl_import_verify_found_questions"));
629  if ($questions_only)
630  {
631  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_questions_into_qpl"));
632  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
633  }
634  else
635  {
636  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_qpl"));
637 
638  $this->ctrl->setParameter($this, "new_type", $this->type);
639  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
640  }
641 
642  $value_questions_only = 0;
643  if ($questions_only) $value_questions_only = 1;
644  $this->tpl->setVariable("VALUE_QUESTIONS_ONLY", $value_questions_only);
645  $this->tpl->setVariable("VERIFICATION_TABLE", $table->getHtml());
646  $this->tpl->setVariable("VERIFICATION_FORM_NAME", $table->getFormName());
647 
648  $this->tpl->parseCurrentBlock();
649 
650  return true;
651  }
652 
657  {
658  if ($_POST["questions_only"] == 1)
659  {
660  $newObj =& $this->object;
661  }
662  else
663  {
664  include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
665  // create new questionpool object
666  $newObj = new ilObjQuestionPool(0, true);
667  // set type of questionpool object
668  $newObj->setType($_GET["new_type"]);
669  // set title of questionpool object to "dummy"
670  $newObj->setTitle("dummy");
671  // set description of questionpool object
672  $newObj->setDescription("questionpool import");
673  // create the questionpool class in the ILIAS database (object_data table)
674  $newObj->create(true);
675  // create a reference for the questionpool object in the ILIAS database (object_reference table)
676  $newObj->createReference();
677  // put the questionpool object in the administration tree
678  $newObj->putInTree($_GET["ref_id"]);
679  // get default permissions and set the permissions for the questionpool object
680  $newObj->setPermissions($_GET["ref_id"]);
681  }
682 
683  if (is_file($_SESSION["qpl_import_dir"].'/'.$_SESSION["qpl_import_subdir"]."/manifest.xml"))
684  {
685  $_SESSION["qpl_import_idents"] = $_POST["ident"];
686 
687  $fileName = $_SESSION["qpl_import_subdir"].'.zip';
688  $fullPath = $_SESSION["qpl_import_dir"].'/'.$fileName;
689 
690  include_once("./Services/Export/classes/class.ilImport.php");
691  $imp = new ilImport((int) $_GET["ref_id"]);
692  $map = $imp->getMapping();
693  $map->addMapping("Modules/TestQuestionPool", "qpl", "new_id", $newObj->getId());
694  $imp->importObject($newObj, $fullPath, $fileName, "qpl", "Modules/TestQuestionPool", true);
695  }
696  else
697  {
698  // start parsing of QTI files
699  include_once "./Services/QTI/classes/class.ilQTIParser.php";
700  $qtiParser = new ilQTIParser($_SESSION["qpl_import_qti_file"], IL_MO_PARSE_QTI, $newObj->getId(), $_POST["ident"]);
701  $result = $qtiParser->startParsing();
702 
703  // import page data
704  if (strlen($_SESSION["qpl_import_xml_file"]))
705  {
706  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
707  $contParser = new ilContObjParser($newObj, $_SESSION["qpl_import_xml_file"], $_SESSION["qpl_import_subdir"]);
708  $contParser->setQuestionMapping($qtiParser->getImportMapping());
709  $contParser->startParsing();
710 
711  // #20494
712  $newObj->fromXML($_SESSION["qpl_import_xml_file"]);
713  }
714 
715  // set another question pool name (if possible)
716  if( isset($_POST["qpl_new"]) && strlen($_POST["qpl_new"]) )
717  {
718  $newObj->setTitle($_POST["qpl_new"]);
719  }
720 
721  $newObj->update();
722  $newObj->saveToDb();
723  }
724 
725  // delete import directory
726  include_once "./Services/Utilities/classes/class.ilUtil.php";
728 
729  if ($_POST["questions_only"] == 1)
730  {
731  $this->ctrl->redirect($this, "questions");
732  }
733  else
734  {
735  ilUtil::sendSuccess($this->lng->txt("object_imported"),true);
736  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
737  "&baseClass=ilObjQuestionPoolGUI");
738  }
739  }
740 
742  {
743  if ($_POST["questions_only"] == 1)
744  {
745  $this->ctrl->redirect($this, "questions");
746  }
747  else
748  {
749  $this->ctrl->redirect($this, "cancel");
750  }
751  }
752 
756  function uploadObject()
757  {
758  $upload_valid = true;
759  $form = $this->getImportQuestionsForm();
760  if($form->checkInput())
761  {
762  if(!$this->uploadQplObject(true))
763  {
764  $form->setValuesByPost();
765  $this->importQuestionsObject($form);
766  }
767  }
768  else
769  {
770  $form->setValuesByPost();
771  $this->importQuestionsObject($form);
772  }
773  }
774 
778  public function importQuestionsObject(ilPropertyFormGUI $form = null)
779  {
780  if(!$form instanceof ilPropertyFormGUI)
781  {
782  $form = $this->getImportQuestionsForm();
783  }
784 
785  $this->tpl->setContent($form->getHtml());
786  }
787 
791  protected function getImportQuestionsForm()
792  {
793  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
794  $form = new ilPropertyFormGUI();
795  $form->setTitle($this->lng->txt('import_question'));
796  $form->setFormAction($this->ctrl->getFormAction($this, 'upload'));
797 
798  $file = new ilFileInputGUI($this->lng->txt('select_file'), 'xmldoc');
799  $file->setRequired(true);
800  $form->addItem($file);
801 
802  $form->addCommandButton('upload', $this->lng->txt('upload'));
803  $form->addCommandButton('questions', $this->lng->txt('cancel'));
804 
805  return $form;
806  }
807 
812  {
814  {
815  $addContEditMode = $_POST['add_quest_cont_edit_mode'];
816  }
817  else
818  {
820  }
821 
822  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
823  $q_gui =& assQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
824  $this->object->addQuestionChangeListeners($q_gui->object);
825  $q_gui->object->setObjId($this->object->getId());
826  $q_gui->object->setAdditionalContentEditingMode($addContEditMode);
827  $q_gui->object->createNewQuestion();
828  $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $q_gui->object->getId());
829  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_POST["sel_question_types"]);
830  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
831  }
832 
837  {
838  if( !$_REQUEST['q_id'] )
839  {
840  require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
842  {
843  $addContEditMode = $_REQUEST['add_quest_cont_edit_mode'];
844  }
845  else
846  {
848  }
849 
850  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
851  $q_gui =& assQuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
852  $q_gui->object->setObjId($this->object->getId());
853  $q_gui->object->setAdditionalContentEditingMode($addContEditMode);
854  $q_gui->object->createNewQuestion();
855 
856  $class = get_class($q_gui);
857  $qId = $q_gui->object->getId();
858  }
859  else
860  {
861  $class = $_GET["sel_question_types"] . 'gui';
862  $qId = $_REQUEST['q_id'];
863  }
864 
865  $this->ctrl->setParameterByClass($class, "q_id", $qId);
866  $this->ctrl->setParameterByClass($class, "sel_question_types", $_REQUEST["sel_question_types"]);
867  $this->ctrl->setParameterByClass($class, "prev_qid", $_REQUEST["prev_qid"]);
868 
869  $this->ctrl->redirectByClass($class, "editQuestion");
870  }
871 
876  function afterSave(ilObject $a_new_object)
877  {
878  // always send a message
879  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
880 
881  ilUtil::redirect("ilias.php?ref_id=".$a_new_object->getRefId().
882  "&baseClass=ilObjQuestionPoolGUI");
883  }
884 
885  function questionObject()
886  {
887 //echo "<br>ilObjQuestionPoolGUI->questionObject()";
888  $type = $_GET["sel_question_types"];
889  $this->editQuestionForm($type);
890  }
891 
896  {
897  global $rbacsystem;
898 
899  if (count($_POST["q_id"]) < 1)
900  {
901  ilUtil::sendInfo($this->lng->txt("qpl_delete_select_none"), true);
902  $this->ctrl->redirect($this, "questions");
903  }
904 
905  ilUtil::sendQuestion($this->lng->txt("qpl_confirm_delete_questions"));
906  $deleteable_questions =& $this->object->getDeleteableQuestionDetails($_POST["q_id"]);
907  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
908  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', (($rbacsystem->checkAccess('write', $_GET['ref_id']) ? true : false)), true);
909  $table_gui->setEditable($rbacsystem->checkAccess('write', $_GET['ref_id']));
910  $table_gui->setData($deleteable_questions);
911  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
912  }
913 
914 
919  {
920  // delete questions after confirmation
921  foreach ($_POST["q_id"] as $key => $value)
922  {
923  $this->object->deleteQuestion($value);
924  $this->object->cleanupClipboard($value);
925  }
926  if (count($_POST["q_id"])) ilUtil::sendSuccess($this->lng->txt("qpl_questions_deleted"), true);
927 
928  $this->ctrl->setParameter($this, 'q_id', '');
929 
930  $this->ctrl->redirect($this, "questions");
931  }
932 
937  {
938  $this->ctrl->redirect($this, "questions");
939  }
940 
945  {
946  // export button was pressed
947  if (count($_POST["q_id"]) > 0)
948  {
949  include_once("./Modules/TestQuestionPool/classes/class.ilQuestionpoolExport.php");
950  $qpl_exp = new ilQuestionpoolExport($this->object, "xml", $_POST["q_id"]);
951  $export_file = $qpl_exp->buildExportFile();
952  $filename = $export_file;
953  $filename = preg_replace("/.*\//", "", $filename);
954  include_once "./Services/Utilities/classes/class.ilUtil.php";
955  ilUtil::deliverFile($export_file, $filename);
956  exit();
957  }
958  else
959  {
960  ilUtil::sendInfo($this->lng->txt("qpl_export_select_none"), true);
961  }
962  $this->ctrl->redirect($this, "questions");
963  }
964 
966  {
967  require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
968  $taxIds = ilObjTaxonomy::getUsageOfObject($this->object->getId());
969 
970  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
971  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', false, false, $taxIds);
972  $table_gui->resetOffset();
973  $table_gui->writeFilterToSession();
974  $this->questionsObject();
975  }
976 
978  {
979  require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
980  $taxIds = ilObjTaxonomy::getUsageOfObject($this->object->getId());
981 
982  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
983  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', false, false, $taxIds);
984  $table_gui->resetOffset();
985  $table_gui->resetFilter();
986  $this->questionsObject();
987  }
988 
989  protected function renoveImportFailsObject()
990  {
991  require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImportFails.php';
992  $qsaImportFails = new ilAssQuestionSkillAssignmentImportFails($this->object->getId());
993  $qsaImportFails->deleteRegisteredImportFails();
994 
995  $this->ctrl->redirect($this, 'infoScreen');
996  }
997 
1001  function questionsObject()
1002  {
1003  global $rbacsystem, $ilUser, $ilCtrl, $ilDB, $lng, $ilPluginAdmin;
1004 
1005  if(get_class($this->object) == "ilObjTest")
1006  {
1007  if ($_GET["calling_test"] > 0)
1008  {
1009  $ref_id = $_GET["calling_test"];
1010  $q_id = $_GET["q_id"];
1011 
1012  if ($_REQUEST['test_express_mode']) {
1013  if ($q_id)
1014  ilUtil::redirect("ilias.php?ref_id=".$ref_id."&q_id=".$q_id."&test_express_mode=1&cmd=showPage&cmdClass=iltestexpresspageobjectgui&baseClass=ilObjTestGUI");
1015  else
1016  ilUtil::redirect("ilias.php?ref_id=".$ref_id."&test_express_mode=1&cmd=showPage&cmdClass=iltestexpresspageobjectgui&baseClass=ilObjTestGUI");
1017  }
1018  else
1019  ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&ref_id=".$ref_id."&cmd=questions");
1020 
1021  }
1022  }
1023  else if(isset($_GET['calling_consumer']) && (int)$_GET['calling_consumer'])
1024  {
1025  $ref_id = (int)$_GET['calling_consumer'];
1027  if($consumer instanceof ilQuestionEditingFormConsumer)
1028  {
1029  ilUtil::redirect($consumer->getQuestionEditingFormBackTarget($_GET['consumer_context']));
1030  }
1031  require_once 'Services/Link/classes/class.ilLink.php';
1033  }
1034 
1035  $this->object->purgeQuestions();
1036  // reset test_id SESSION variable
1037  $_SESSION["test_id"] = "";
1038 
1039  require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImportFails.php';
1040  $qsaImportFails = new ilAssQuestionSkillAssignmentImportFails($this->object->getId());
1041  if( $qsaImportFails->failedImportsRegistered() )
1042  {
1043  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
1044  $button = ilLinkButton::getInstance();
1045  $button->setUrl($this->ctrl->getLinkTarget($this, 'renoveImportFails'));
1046  $button->setCaption('ass_skl_import_fails_remove_btn');
1047 
1048  ilUtil::sendFailure($qsaImportFails->getFailedImportsMessage($this->lng).'<br />'.$button->render());
1049  }
1050 
1051  require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
1052  $taxIds = ilObjTaxonomy::getUsageOfObject($this->object->getId());
1053 
1054  $table_gui = $this->buildQuestionBrowserTableGUI($taxIds);
1055  $table_gui->setPreventDoubleSubmission(false);
1056 
1057  if( $rbacsystem->checkAccess('write', $_GET['ref_id']) )
1058  {
1059  $toolbar = new ilToolbarGUI();
1060 
1061  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
1062  $btn = ilLinkButton::getInstance();
1063  $btn->setCaption('ass_create_question');
1064  $btn->setUrl($this->ctrl->getLinkTarget($this, 'createQuestionForm'));
1065  $btn->setPrimary(true);
1066  $toolbar->addButtonInstance($btn);
1067 
1068  $this->tpl->setContent(
1069  $this->ctrl->getHTML($toolbar) . $this->ctrl->getHTML($table_gui)
1070  );
1071  }
1072  else
1073  {
1074  $this->tpl->setContent( $this->ctrl->getHTML($table_gui) );
1075  }
1076 
1077  if( $this->object->getShowTaxonomies() )
1078  {
1079  $this->lng->loadLanguageModule('tax');
1080 
1081  require_once 'Services/Taxonomy/classes/class.ilTaxonomyExplorerGUI.php';
1082 
1083  foreach($taxIds as $taxId)
1084  {
1085  if( $taxId != $this->object->getNavTaxonomyId() )
1086  {
1087  continue;
1088  }
1089 
1090  $taxExp = new ilTaxonomyExplorerGUI(
1091  $this, 'showNavTaxonomy', $taxId, 'ilobjquestionpoolgui', 'questions'
1092  );
1093 
1094  if( !$taxExp->handleCommand() )
1095  {
1096  $this->tpl->setLeftContent($taxExp->getHTML()."&nbsp;");
1097  }
1098 
1099  break;
1100  }
1101  }
1102  }
1103 
1108  {
1109  $qId = (int)$_GET['q_id'];
1110 
1111  if( $this->object->checkQuestionParent($qId) )
1112  {
1113  return $qId;
1114  }
1115 
1116  throw new ilTestQuestionPoolException('question id does not relate to parent object!');
1117  }
1118 
1119  private function createQuestionFormObject()
1120  {
1121  global $DIC; /* @var \ILIAS\DI\Container $DIC */
1122  $ilHelp = $DIC['ilHelp']; /* @var ilHelpGUI $ilHelp */
1123 
1124  $ilHelp->setScreenId('assQuestions');
1125 
1127  {
1128  $ilHelp->setSubScreenId('createQuestion_editMode');
1129  }
1130  else
1131  {
1132  $ilHelp->setSubScreenId('createQuestion');
1133  }
1134 
1135  $form = $this->buildCreateQuestionForm();
1136 
1137  $this->tpl->setContent( $this->ctrl->getHTML($form) );
1138  }
1139 
1140  private function buildCreateQuestionForm()
1141  {
1142  global $ilUser;
1143 
1144  // form
1145 
1146  require_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1147  $form = new ilPropertyFormGUI();
1148  $form->setTitle($this->lng->txt('ass_create_question'));
1149  $form->setFormAction($this->ctrl->getFormAction($this));
1150 
1151  // question type
1152 
1153  $options = array();
1154  foreach( $this->object->getQuestionTypes(false, true) as $translation => $data )
1155  {
1156  $options[$data['type_tag']] = $translation;
1157  }
1158 
1159  require_once("Services/Form/classes/class.ilSelectInputGUI.php");
1160  $si = new ilSelectInputGUI($this->lng->txt('question_type'), 'sel_question_types');
1161  $si->setOptions($options);
1162  //$si->setValue($ilUser->getPref("tst_lastquestiontype"));
1163 
1164  $form->addItem($si);
1165 
1166  // content editing mode
1167 
1169  {
1170  $ri = new ilRadioGroupInputGUI($this->lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
1171 
1172  $ri->addOption(new ilRadioOption(
1173  $this->lng->txt('tst_add_quest_cont_edit_mode_default'),
1175  ));
1176 
1177  $ri->addOption(new ilRadioOption(
1178  $this->lng->txt('tst_add_quest_cont_edit_mode_page_object'),
1180  ));
1181 
1183 
1184  $form->addItem($ri, true);
1185  }
1186  else
1187  {
1188  $hi = new ilHiddenInputGUI("question_content_editing_type");
1190  $form->addItem($hi, true);
1191  }
1192 
1193  // commands
1194 
1195  $form->addCommandButton('createQuestion', $this->lng->txt('create'));
1196  $form->addCommandButton('questions', $this->lng->txt('cancel'));
1197 
1198  return $form;
1199  }
1200 
1204  public function printObject()
1205  {
1209  global $ilToolbar;
1210 
1211  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'print'));
1212  require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
1213  $mode = new ilSelectInputGUI($this->lng->txt('output_mode'), 'output');
1214  $mode->setOptions(array(
1215  'overview' => $this->lng->txt('overview'),
1216  'detailed' => $this->lng->txt('detailed_output_solutions'),
1217  'detailed_printview' => $this->lng->txt('detailed_output_printview')
1218  ));
1219  $mode->setValue(ilUtil::stripSlashes($_POST['output']));
1220 
1221  $ilToolbar->setFormName('printviewOptions');
1222  $ilToolbar->addInputItem($mode, true);
1223  $ilToolbar->addFormButton($this->lng->txt('submit'), 'print');
1224 
1225  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionPoolPrintViewTableGUI.php";
1226  $table_gui = new ilQuestionPoolPrintViewTableGUI($this, 'print', $_POST['output']);
1227  $data = $this->object->getPrintviewQuestions();
1228  $totalPoints = 0;
1229  foreach($data as $d)
1230  {
1231  $totalPoints += $d['points'];
1232  }
1233  $table_gui->setTotalPoints($totalPoints);
1234  $table_gui->initColumns();
1235  $table_gui->setData($data);
1236  $this->tpl->setContent($table_gui->getHTML());
1237  }
1238 
1239  function updateObject()
1240  {
1241 // $this->update = $this->object->updateMetaData();
1242  $this->update = $this->object->update();
1243  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1244  }
1245 
1249  function pasteObject()
1250  {
1251  if (array_key_exists("qpl_clipboard", $_SESSION))
1252  {
1253  if($this->object->pasteFromClipboard())
1254  {
1255  ilUtil::sendSuccess($this->lng->txt("qpl_paste_success"), true);
1256  }
1257  else
1258  {
1259  ilUtil::sendFailure($this->lng->txt("qpl_paste_error"), true);
1260  }
1261  }
1262  else
1263  {
1264  ilUtil::sendInfo($this->lng->txt("qpl_paste_no_objects"), true);
1265  }
1266  $this->ctrl->redirect($this, "questions");
1267  }
1268 
1272  public function copyObject()
1273  {
1274  if (isset($_POST["q_id"]) && is_array($_POST["q_id"]) && count($_POST["q_id"]) > 0)
1275  {
1276  foreach ($_POST["q_id"] as $key => $value)
1277  {
1278  $this->object->copyToClipboard($value);
1279  }
1280  ilUtil::sendInfo($this->lng->txt("qpl_copy_insert_clipboard"), true);
1281  }
1282  else
1283  {
1284  ilUtil::sendInfo($this->lng->txt("qpl_copy_select_none"), true);
1285  }
1286  $this->ctrl->redirect($this, "questions");
1287  }
1288 
1292  function moveObject()
1293  {
1294  if (isset($_POST["q_id"]) && is_array($_POST["q_id"]) && count($_POST["q_id"]) > 0)
1295  {
1296  foreach ($_POST["q_id"] as $key => $value)
1297  {
1298  $this->object->moveToClipboard($value);
1299  }
1300  ilUtil::sendInfo($this->lng->txt("qpl_move_insert_clipboard"), true);
1301  }
1302  else
1303  {
1304  ilUtil::sendInfo($this->lng->txt("qpl_move_select_none"), true);
1305  }
1306  $this->ctrl->redirect($this, "questions");
1307  }
1308 
1310  {
1311  global $rbacsystem;
1312  if ($rbacsystem->checkAccess("write", $_GET['ref_id']))
1313  {
1314  include_once("./Modules/TestQuestionPool/classes/class.ilQuestionpoolExport.php");
1315  $question_ids =& $this->object->getAllQuestionIds();
1316  $qpl_exp = new ilQuestionpoolExport($this->object, 'xls', $question_ids);
1317  $qpl_exp->buildExportFile();
1318  $this->ctrl->redirectByClass("ilquestionpoolexportgui", "");
1319  }
1320  }
1321 
1326  {
1327  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1328  $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1329  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
1330  }
1331 
1332  protected function initImportForm($a_new_type)
1333  {
1334  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1335  $form = new ilPropertyFormGUI();
1336  $form->setTarget("_top");
1337  $form->setFormAction($this->ctrl->getFormAction($this));
1338  $form->setTitle($this->lng->txt("import_qpl"));
1339 
1340  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
1341  $fi = new ilFileInputGUI($this->lng->txt("import_file"), "xmldoc");
1342  $fi->setSuffixes(array("zip"));
1343  $fi->setRequired(true);
1344  $form->addItem($fi);
1345 
1346  $form->addCommandButton("importFile", $this->lng->txt("import"));
1347  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
1348 
1349  return $form;
1350  }
1351 
1355  protected function importFileObject($parent_id = null, $a_catch_errors = true)
1356  {
1357  $form = $this->initImportForm($_REQUEST["new_type"]);
1358  if($form->checkInput())
1359  {
1360  $this->uploadQplObject();
1361  }
1362 
1363  // display form to correct errors
1364  $this->tpl->setContent($form->getHTML());
1365  }
1366 
1367  function addLocatorItems()
1368  {
1369  global $ilLocator;
1370  switch ($this->ctrl->getCmd())
1371  {
1372  case "create":
1373  case "importFile":
1374  case "cancel":
1375  break;
1376  default:
1377  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
1378  break;
1379  }
1380  if ($_GET["q_id"] > 0)
1381  {
1382  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1383  $q_gui = assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1384  if($q_gui->object instanceof assQuestion)
1385  {
1386  $q_gui->object->setObjId($this->object->getId());
1387  $title = $q_gui->object->getTitle();
1388  if(!$title)
1389  {
1390  $title = $this->lng->txt('new').': '.assQuestion::_getQuestionTypeName($q_gui->object->getQuestionType());
1391  }
1392  $ilLocator->addItem($title, $this->ctrl->getLinkTargetByClass(get_class($q_gui), "editQuestion"));
1393  }
1394  else
1395  {
1396  // Workaround for context issues: If no object was found, redirect without q_id parameter
1397  $this->ctrl->setParameter($this, 'q_id', '');
1398  $this->ctrl->redirect($this);
1399  }
1400  }
1401  }
1402 
1407  {
1408  parent::setTitleAndDescription();
1409  if ($_GET["q_id"] > 0)
1410  {
1411  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1412  $q_gui = assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1413  if($q_gui->object instanceof assQuestion)
1414  {
1415  $q_gui->object->setObjId($this->object->getId());
1416  $title = $q_gui->object->getTitle();
1417  if(!$title)
1418  {
1419  $title = $this->lng->txt('new').': '.assQuestion::_getQuestionTypeName($q_gui->object->getQuestionType());
1420  }
1421  $this->tpl->setTitle($title);
1422  $this->tpl->setDescription($q_gui->object->getComment());
1423  $this->tpl->setTitleIcon(ilObject2::_getIcon("", "big", $this->object->getType()));
1424  }
1425  else
1426  {
1427  // Workaround for context issues: If no object was found, redirect without q_id parameter
1428  $this->ctrl->setParameter($this, 'q_id', '');
1429  $this->ctrl->redirect($this);
1430  }
1431  }
1432  else
1433  {
1434  $this->tpl->setTitle($this->object->getTitle());
1435  $this->tpl->setDescription($this->object->getLongDescription());
1436  $this->tpl->setTitleIcon(ilObject2::_getIcon("", "big", $this->object->getType()));
1437  }
1438  }
1439 
1445  function getTabs()
1446  {
1447  global $ilAccess, $ilHelp;
1448 
1449  $currentUserHasWriteAccess = $ilAccess->checkAccess("write", "", $this->object->getRefId());
1450 
1451  $ilHelp->setScreenIdComponent("qpl");
1452 
1453  $next_class = strtolower($this->ctrl->getNextClass());
1454  switch ($next_class)
1455  {
1456  case "":
1457  case "ilpermissiongui":
1458  case "ilobjectmetadatagui":
1459  case "ilquestionpoolexportgui":
1460  case "ilquestionpoolskilladministrationgui":
1461  break;
1462 
1463  case 'ilobjtaxonomygui':
1464  case 'ilobjquestionpoolsettingsgeneralgui':
1465 
1466  if( $currentUserHasWriteAccess )
1467  {
1468  $this->addSettingsSubTabs($this->tabs_gui);
1469  }
1470 
1471  break;
1472 
1473  default:
1474  return;
1475  break;
1476  }
1477  // questions
1478  $force_active = false;
1479  $commands = $_POST["cmd"];
1480  if (is_array($commands))
1481  {
1482  foreach ($commands as $key => $value)
1483  {
1484  if (preg_match("/^delete_.*/", $key, $matches) ||
1485  preg_match("/^addSelectGap_.*/", $key, $matches) ||
1486  preg_match("/^addTextGap_.*/", $key, $matches) ||
1487  preg_match("/^deleteImage_.*/", $key, $matches) ||
1488  preg_match("/^upload_.*/", $key, $matches) ||
1489  preg_match("/^addSuggestedSolution_.*/", $key, $matches)
1490  )
1491  {
1492  $force_active = true;
1493  }
1494  }
1495  }
1496  if (array_key_exists("imagemap_x", $_POST))
1497  {
1498  $force_active = true;
1499  }
1500  if (!$force_active)
1501  {
1502  $force_active = ((strtolower($this->ctrl->getCmdClass()) == strtolower(get_class($this)) || strlen($this->ctrl->getCmdClass()) == 0) &&
1503  $this->ctrl->getCmd() == "")
1504  ? true
1505  : false;
1506  }
1507  $this->tabs_gui->addTarget("assQuestions",
1508  $this->ctrl->getLinkTarget($this, "questions"),
1509  array("questions", "filter", "resetFilter", "createQuestion",
1510  "importQuestions", "deleteQuestions", "filterQuestionBrowser",
1511  "view", "preview", "editQuestion", "exec_pg",
1512  "addItem", "upload", "save", "cancel", "addSuggestedSolution",
1513  "cancelExplorer", "linkChilds", "removeSuggestedSolution",
1514  "add", "addYesNo", "addTrueFalse", "createGaps", "saveEdit",
1515  "setMediaMode", "uploadingImage", "uploadingImagemap", "addArea",
1516  "deletearea", "saveShape", "back", "addPair", "uploadingJavaapplet",
1517  "addParameter", "assessment", "addGIT", "addST", "addPG", "delete",
1518  "toggleGraphicalAnswers", "deleteAnswer", "deleteImage", "removeJavaapplet"),
1519  "", "", $force_active);
1520 
1521  if ($ilAccess->checkAccess("read", "", $this->ref_id) || $ilAccess->checkAccess("visible", "", $this->ref_id))
1522  {
1523  $this->tabs_gui->addTarget("info_short",
1524  $this->ctrl->getLinkTarget($this, "infoScreen"),
1525  array("infoScreen", "showSummary"));
1526  }
1527 
1528  if ($ilAccess->checkAccess("write", "", $_GET['ref_id']))
1529  {
1530  // properties
1531  $this->tabs_gui->addTarget(
1532  'settings', $this->ctrl->getLinkTargetByClass('ilObjQuestionPoolSettingsGeneralGUI'),
1533  array(), array('ilObjQuestionPoolSettingsGeneralGUI', 'ilObjTaxonomyGUI')
1534  );
1535 
1536  // skill service
1537  if( $this->isSkillsTabRequired() )
1538  {
1539  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentsGUI.php';
1540 
1541  $link = $this->ctrl->getLinkTargetByClass(
1542  array('ilQuestionPoolSkillAdministrationGUI', 'ilAssQuestionSkillAssignmentsGUI'),
1544  );
1545 
1546  $this->tabs_gui->addTarget('qpl_tab_competences', $link, array(), array());
1547  }
1548  }
1549 
1550  // print view
1551  $this->tabs_gui->addTarget("print_view",
1552  $this->ctrl->getLinkTarget($this,'print'),
1553  array("print"),
1554  "", "");
1555 
1556  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1557  {
1558  // meta data
1559  include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
1560  $mdgui = new ilObjectMetaDataGUI($this->object);
1561  $mdtab = $mdgui->getTab();
1562  if($mdtab)
1563  {
1564  $this->tabs_gui->addTarget("meta_data",
1565  $mdtab,
1566  "", "ilmdeditorgui");
1567  }
1568 
1569 // $this->tabs_gui->addTarget("export",
1570 // $this->ctrl->getLinkTarget($this,'export'),
1571 // array("export", "createExportFile", "confirmDeleteExportFile", "downloadExportFile"),
1572 // "", "");
1573  }
1574 
1575  if( $currentUserHasWriteAccess )
1576  {
1577  $this->tabs_gui->addTarget("export",
1578  $this->ctrl->getLinkTargetByClass("ilquestionpoolexportgui", ""),
1579  "", "ilquestionpoolexportgui");
1580  }
1581 
1582  if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId()))
1583  {
1584  $this->tabs_gui->addTarget("perm_settings",
1585  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1586  }
1587  }
1588 
1589  private function isSkillsTabRequired()
1590  {
1591  if( !($this->object instanceof ilObjQuestionPool) )
1592  {
1593  return false;
1594  }
1595 
1596  if( !$this->object->isSkillServiceEnabled() )
1597  {
1598  return false;
1599  }
1600 
1602  {
1603  return false;
1604  }
1605 
1606  return true;
1607  }
1608 
1609  private function addSettingsSubTabs(ilTabsGUI $tabs)
1610  {
1611  $tabs->addSubTabTarget(
1612  'qpl_settings_subtab_general',
1613  $this->ctrl->getLinkTargetByClass('ilObjQuestionPoolSettingsGeneralGUI'),
1614  '', 'ilObjQuestionPoolSettingsGeneralGUI'
1615  );
1616 
1617  $tabs->addSubTabTarget(
1618  'qpl_settings_subtab_taxonomies',
1619  $this->ctrl->getLinkTargetByClass('ilObjTaxonomyGUI', 'editAOTaxonomySettings'),
1620  '', 'ilObjTaxonomyGUI'
1621  );
1622  }
1623 
1629  function infoScreenObject()
1630  {
1631  $this->ctrl->setCmd("showSummary");
1632  $this->ctrl->setCmdClass("ilinfoscreengui");
1633  $this->infoScreenForward();
1634  }
1635 
1640  {
1641  global $ilErr, $ilAccess;
1642 
1643  if(!$ilAccess->checkAccess("visible", "", $this->ref_id))
1644  {
1645  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
1646  }
1647 
1648  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1649  $info = new ilInfoScreenGUI($this);
1650  $info->enablePrivateNotes();
1651 
1652  // standard meta data
1653  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
1654 
1655  $this->ctrl->forwardCommand($info);
1656  }
1657 
1666  public static function _goto($a_target)
1667  {
1668  global $ilAccess, $ilErr, $lng;
1669 
1670  if ($ilAccess->checkAccess("write", "", $a_target) || $ilAccess->checkAccess('read', '', $a_target))
1671  {
1672  $_GET['cmdClass'] = 'ilObjQuestionPoolGUI';
1673  $_GET['cmd'] = 'questions';
1674  $_GET['baseClass'] = 'ilRepositoryGUI';
1675  $_GET["ref_id"] = $a_target;
1676  include_once("ilias.php");
1677  exit;
1678  }
1679  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1680  {
1681  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
1682  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1684  }
1685  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
1686  }
1687 
1696  private function buildQuestionBrowserTableGUI($taxIds)
1697  {
1698  global $rbacsystem, $ilDB, $lng, $ilPluginAdmin;
1699 
1700  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
1701  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', (($rbacsystem->checkAccess('write', $_GET['ref_id']) ? true : false)), false, $taxIds);
1702  $table_gui->setEditable($rbacsystem->checkAccess('write', $_GET['ref_id']));
1703 
1704  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
1705  $questionList = new ilAssQuestionList($ilDB, $lng, $ilPluginAdmin);
1706  $questionList->setParentObjId($this->object->getId());
1707 
1708  foreach ($table_gui->getFilterItems() as $item)
1709  {
1710  if( substr($item->getPostVar(), 0, strlen('tax_')) == 'tax_' )
1711  {
1712  $v = $item->getValue();
1713 
1714  if( is_array($v) && count($v) && !(int)$v[0] )
1715  {
1716  continue;
1717  }
1718 
1719  $taxId = substr($item->getPostVar(), strlen('tax_'));
1720 
1721  $questionList->addTaxonomyFilter(
1722  $taxId, $item->getValue(), $this->object->getId(), $this->object->getType()
1723  );
1724  }
1725  elseif( $item->getValue() !== false )
1726  {
1727  $questionList->addFieldFilter($item->getPostVar(), $item->getValue());
1728  }
1729  }
1730 
1731  if( $this->object->isNavTaxonomyActive() && (int)$_GET['tax_node'] )
1732  {
1733  require_once 'Services/Taxonomy/classes/class.ilTaxonomyTree.php';
1734  $taxTree = new ilTaxonomyTree($this->object->getNavTaxonomyId());
1735  $rootNodeId = $taxTree->readRootId();
1736 
1737  if( (int)$_GET['tax_node'] != $rootNodeId )
1738  {
1739  $questionList->addTaxonomyFilter(
1740  $this->object->getNavTaxonomyId(), array((int)$_GET['tax_node']),
1741  $this->object->getId(), $this->object->getType()
1742  );
1743  }
1744  }
1745 
1746  $questionList->load();
1747  $data = $questionList->getQuestionDataArray();
1748 
1749  $table_gui->setData($data);
1750 
1751  return $table_gui;
1752  }
1753 
1754 
1755 
1756 } // END class.ilObjQuestionPoolGUI
1757 ?>
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
global $ilErr
Definition: raiseError.php:16
This class represents an option in a radio group.
Class ilObjectMetaDataGUI.
Content Object Parser.
Class ilInfoScreenGUI.
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.
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.
Class ilObject Basic functions for all objects.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$cmd
Definition: sahs_server.php:35
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.
for($col=0; $col< 50; $col++) $d
const JAVAAPPLET_QUESTION_IDENTIFIER
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
This class represents a hidden form property in a property form.
$info
Definition: example_052.php:80
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(!is_array($argv)) $options
addSubTabTarget($a_text, $a_link, $a_cmd="", $a_cmdClass="", $a_frame="", $a_activate=false, $a_dir_text=false)
DEPRECATED.
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...
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
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
Class ilObjFile.
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 deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
setOptions($a_options)
Set Options.
const TEXT_QUESTION_IDENTIFIER
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.
const ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT
constant for additional content editing mode "default"
static getContentStylePath($a_style_id)
get content style path
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 ...
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.
global $DIC
static _getImportDirectory()
get import directory of lm
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
importFileObject($parent_id=null, $a_catch_errors=true)
form for new questionpool object import
const IL_MO_VERIFY_QTI
static redirect($a_script)
http redirect to other 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
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
const IMAGEMAP_QUESTION_IDENTIFIER
readRootId()
read root id from database