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