ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
4require_once './Services/Object/classes/class.ilObjectGUI.php';
5require_once './Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
6require_once './Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
7require_once './Modules/TestQuestionPool/exceptions/class.ilTestQuestionPoolException.php';
8require_once './Modules/Test/classes/inc.AssessmentConstants.php';
9require_once './Modules/Test/classes/class.ilObjAssessmentFolder.php';
10require_once './Modules/Test/classes/class.ilObjTest.php';
11
36{
40 public $object;
41
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 $this->ilObjectGUI("",$_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(), (int)$_GET['q_id']);
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/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";
180 $q_gui = assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
181 $q_gui->setQuestionTabs();
182 $q_gui->outAdditionalOutput();
183 $q_gui->object->setObjId($this->object->getId());
184
185 $q_gui->setTargetGuiClass(null);
186 $q_gui->setQuestionActionCmd(null);
187
188 $question = $q_gui->object;
189 $this->ctrl->saveParameter($this, "q_id");
190 include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
191 $this->lng->loadLanguageModule("content");
192 $this->ctrl->setReturnByClass("ilAssQuestionPageGUI", "view");
193 $this->ctrl->setReturn($this, "questions");
194 $page_gui = new ilAssQuestionPageGUI($_GET["q_id"]);
195 $page_gui->obj->addUpdateListener(
196 $question,
197 'updateTimestamp'
198 );
199 $page_gui->setEditPreview(true);
200 $page_gui->setEnabledTabs(false);
201 if (strlen($this->ctrl->getCmd()) == 0 && !isset($_POST["editImagemapForward_x"])) // workaround for page edit imagemaps, keep in mind
202 {
203 $this->ctrl->setCmdClass(get_class($page_gui));
204 $this->ctrl->setCmd("preview");
205 }
206 $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(TRUE)));
207 $page_gui->setTemplateTargetVar("ADM_CONTENT");
208 $page_gui->setOutputMode("edit");
209 $page_gui->setHeader($question->getTitle());
210 $page_gui->setPresentationTitle($question->getTitle());
211 $ret = $this->ctrl->forwardCommand($page_gui);
212 $tpl->setContent($ret);
213 break;
214
215 case 'ilpermissiongui':
216 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
217 $perm_gui = new ilPermissionGUI($this);
218 $ret = $this->ctrl->forwardCommand($perm_gui);
219 break;
220
221 case 'ilobjectcopygui':
222 include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
223 $cp = new ilObjectCopyGUI($this);
224 $cp->setType('qpl');
225 $this->ctrl->forwardCommand($cp);
226 break;
227
228 case "ilquestionpoolexportgui":
229 require_once 'Modules/TestQuestionPool/classes/class.ilQuestionPoolExportGUI.php';
230 $exp_gui = new ilQuestionPoolExportGUI($this);
231 $exp_gui->addFormat('xml', $this->lng->txt('qpl_export_xml'));
232 $exp_gui->addFormat('xls', $this->lng->txt('qpl_export_excel'), $this, 'createExportExcel');
233 $ret = $this->ctrl->forwardCommand($exp_gui);
234 break;
235
236 case "ilinfoscreengui":
237 $this->infoScreenForward();
238 break;
239
240 case 'ilassquestionhintsgui':
241
242 // set return target
243 $this->ctrl->setReturn($this, "questions");
244
245 // set context tabs
246 require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
247 $questionGUI = assQuestionGUI::_getQuestionGUI($q_type, $_GET['q_id']);
248 $questionGUI->object->setObjId($this->object->getId());
249 $questionGUI->setQuestionTabs();
250 global $ilHelp;
251 $ilHelp->setScreenIdComponent("qpl");
252
253 // forward to ilAssQuestionHintsGUI
254 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsGUI.php';
255 $gui = new ilAssQuestionHintsGUI($questionGUI);
256 $ilCtrl->forwardCommand($gui);
257
258 break;
259
260 case 'illocalunitconfigurationgui':
261 if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
262 {
263 $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
264 }
265
266 require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
267 $questionGUI = assQuestionGUI::_getQuestionGUI($q_type, $_GET['q_id']);
268 $questionGUI->object->setObjId($this->object->getId());
269 $questionGUI->setQuestionTabs();
270
271 $this->ctrl->setReturn($this, 'questions');
272
273 require_once 'Modules/TestQuestionPool/classes/class.ilLocalUnitConfigurationGUI.php';
274 require_once 'Modules/TestQuestionPool/classes/class.ilUnitConfigurationRepository.php';
276 new ilUnitConfigurationRepository((int)$_GET['q_id'])
277 );
278 $ilCtrl->forwardCommand($gui);
279 break;
280
281 case 'ilassquestionfeedbackeditinggui':
282
283 // set return target
284 $this->ctrl->setReturn($this, "questions");
285
286 // set context tabs
287 require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
288 $questionGUI = assQuestionGUI::_getQuestionGUI($q_type, $_GET['q_id']);
289 $questionGUI->object->setObjId($this->object->getId());
290 $questionGUI->setQuestionTabs();
291 global $ilHelp;
292 $ilHelp->setScreenIdComponent("qpl");
293
294 // forward to ilAssQuestionFeedbackGUI
295 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackEditingGUI.php';
296 $gui = new ilAssQuestionFeedbackEditingGUI($questionGUI, $ilCtrl, $ilAccess, $tpl, $ilTabs, $lng);
297 $ilCtrl->forwardCommand($gui);
298
299 break;
300
301 case 'ilobjquestionpoolsettingsgeneralgui':
302 require_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPoolSettingsGeneralGUI.php';
303 $gui = new ilObjQuestionPoolSettingsGeneralGUI($ilCtrl, $ilAccess, $lng, $tpl, $ilTabs, $this);
304 $this->ctrl->forwardCommand($gui);
305 break;
306
307 case "ilobjtaxonomygui":
308
309 require_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPoolTaxonomyEditingCommandForwarder.php';
311 $this->object, $ilDB, $ilPluginAdmin, $ilCtrl, $ilTabs, $lng
312 );
313
314 $forwarder->forward();
315
316 break;
317
318 case 'ilquestionpoolskilladministrationgui':
319
320 require_once 'Modules/TestQuestionPool/classes/class.ilQuestionPoolSkillAdministrationGUI.php';
322 $ilias, $ilCtrl, $ilAccess, $ilTabs, $tpl, $lng, $ilDB, $ilPluginAdmin, $this->object, $this->ref_id
323 );
324
325 $this->ctrl->forwardCommand($gui);
326
327 break;
328
329 case 'ilquestionbrowsertablegui':
330 $this->ctrl->forwardCommand($this->buildQuestionBrowserTableGUI($taxIds = array())); // no tax ids required
331 break;
332
333 case "ilobjquestionpoolgui":
334 case "":
335
336 if( $cmd == 'questions' )
337 {
338 $this->ctrl->setParameter($this, 'q_id', '');
339 }
340
341 $cmd.= "Object";
342 $ret = $this->$cmd();
343 break;
344
345 default:
346 $this->ctrl->setReturn($this, "questions");
347 include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
348 $q_gui = assQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
349 $q_gui->object->setObjId($this->object->getId());
350 if($this->object->getType() == 'qpl')
351 {
352 $q_gui->setTaxonomyIds($this->object->getTaxonomyIds());
353 $this->object->addQuestionChangeListeners($q_gui->object);
354 }
355 $q_gui->setQuestionTabs();
356 global $ilHelp;
357 $ilHelp->setScreenIdComponent("qpl");
358 $ret = $this->ctrl->forwardCommand($q_gui);
359 break;
360 }
361
362 if ( !(strtolower($_GET["baseClass"]) == "iladministrationgui"
363 || strtolower($_GET['baseClass']) == 'ilrepositorygui')
364 && $this->getCreationMode() != true)
365 {
366 $this->tpl->show();
367 }
368 }
369
374 protected function exportObject()
375 {
376 global $DIC; /* @var ILIAS\DI\Container $DIC */
377 $DIC->ctrl()->redirectByClass('ilQuestionPoolExportGUI');
378 }
379
384 {
385 $file = explode("_", $_GET["file_id"]);
386 include_once("./Modules/File/classes/class.ilObjFile.php");
387 $fileObj =& new ilObjFile($file[count($file) - 1], false);
388 $fileObj->sendFile();
389 exit;
390 }
391
396 {
397 include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
398 $page_gui = new ilAssQuestionPageGUI($_GET["pg_id"]);
399 $page_gui->showMediaFullscreen();
400 }
401
402
406 function filterObject()
407 {
408 $this->questionsObject();
409 }
410
415 {
416 $_POST["filter_text"] = "";
417 $_POST["sel_filter_type"] = "";
418 $this->questionsObject();
419 }
420
425 {
426 include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
427 $pg_obj = new ilAssQuestionPage($_GET["pg_id"]);
428 $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
429 exit;
430 }
431
435 function uploadQplObject($questions_only = false)
436 {
437 $this->ctrl->setParameter($this, 'new_type', $_REQUEST['new_type']);
438 if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
439 {
440 ilUtil::sendFailure($this->lng->txt("error_upload"), true);
441 if(!$questions_only)
442 {
443 $this->ctrl->redirect($this, 'create');
444 }
445 return false;
446 }
447 // create import directory
448 include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
450
451 // copy uploaded file to import directory
452 $file = pathinfo($_FILES["xmldoc"]["name"]);
453 $full_path = $basedir."/".$_FILES["xmldoc"]["name"];
454 $GLOBALS['ilLog']->write(__METHOD__.": full path " . $full_path);
455 include_once "./Services/Utilities/classes/class.ilUtil.php";
456 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
457 $GLOBALS['ilLog']->write(__METHOD__.": full path " . $full_path);
458 if (strcmp($_FILES["xmldoc"]["type"], "text/xml") == 0)
459 {
460 $qti_file = $full_path;
462 }
463 else
464 {
465 // unzip file
466 ilUtil::unzip($full_path);
467
468 // determine filenames of xml files
469 $subdir = basename($file["basename"],".".$file["extension"]);
471 $xml_file = ilObjQuestionPool::_getImportDirectory().'/'.$subdir.'/'.$subdir.".xml";
472 $qti_file = ilObjQuestionPool::_getImportDirectory().'/'.$subdir.'/'. str_replace("qpl", "qti", $subdir).".xml";
473 }
474
475 // start verification of QTI files
476 include_once "./Services/QTI/classes/class.ilQTIParser.php";
477 $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
478 $result = $qtiParser->startParsing();
479 $founditems =& $qtiParser->getFoundItems();
480 if (count($founditems) == 0)
481 {
482 // nothing found
483
484 // delete import directory
485 ilUtil::delDir($basedir);
486
487 ilUtil::sendFailure($this->lng->txt("qpl_import_no_items"), true);
488 if(!$questions_only)
489 {
490 $this->ctrl->redirect($this, 'create');
491 }
492 return false;
493 }
494
495 $complete = 0;
496 $incomplete = 0;
497 foreach ($founditems as $item)
498 {
499 if (strlen($item["type"]))
500 {
501 $complete++;
502 }
503 else
504 {
505 $incomplete++;
506 }
507 }
508
509 if ($complete == 0)
510 {
511 // delete import directory
512 ilUtil::delDir($basedir);
513
514 ilUtil::sendFailure($this->lng->txt("qpl_import_non_ilias_files"), true);
515 if(!$questions_only)
516 {
517 $this->ctrl->redirect($this, 'create');
518 }
519 return false;
520 }
521
522 $_SESSION["qpl_import_xml_file"] = $xml_file;
523 $_SESSION["qpl_import_qti_file"] = $qti_file;
524 $_SESSION["qpl_import_subdir"] = $subdir;
525 // display of found questions
526 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_import_verification.html",
527 "Modules/TestQuestionPool");
528 $row_class = array("tblrow1", "tblrow2");
529 $counter = 0;
530 foreach ($founditems as $item)
531 {
532 $this->tpl->setCurrentBlock("verification_row");
533 $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
534 $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
535 $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
536 include_once "./Services/QTI/classes/class.ilQTIItem.php";
537 switch ($item["type"])
538 {
540 $type = $this->lng->txt("assClozeTest");
541 break;
543 $type = $this->lng->txt("assImagemapQuestion");
544 break;
546 $type = $this->lng->txt("assJavaApplet");
547 break;
549 $type = $this->lng->txt("assMatchingQuestion");
550 break;
552 $type = $this->lng->txt("assMultipleChoice");
553 break;
555 $type = $this->lng->txt("assKprimChoice");
556 break;
558 $type = $this->lng->txt("assLongMenu");
559 break;
561 $type = $this->lng->txt("assSingleChoice");
562 break;
564 $type = $this->lng->txt("assOrderingQuestion");
565 break;
567 $type = $this->lng->txt("assTextQuestion");
568 break;
570 $type = $this->lng->txt("assNumeric");
571 break;
573 $type = $this->lng->txt("assTextSubset");
574 break;
575 default:
576 $type = $this->lng->txt($item["type"]);
577 break;
578 }
579
580 if (strcmp($type, "-" . $item["type"] . "-") == 0)
581 {
582 global $ilPluginAdmin;
583 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "TestQuestionPool", "qst");
584 foreach ($pl_names as $pl_name)
585 {
586 $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "TestQuestionPool", "qst", $pl_name);
587 if (strcmp($pl->getQuestionType(), $item["type"]) == 0)
588 {
589 $type = $pl->getQuestionTypeTranslation();
590 }
591 }
592 }
593 $this->tpl->setVariable("QUESTION_TYPE", $type);
594 $this->tpl->parseCurrentBlock();
595 }
596
597 $this->tpl->setCurrentBlock("import_qpl");
598 if (is_file($xml_file))
599 {
600 // read file into a string
601 $fh = @fopen($xml_file, "r") or die("");
602 $xml = @fread($fh, filesize($xml_file));
603 @fclose($fh);
604 if (preg_match("/<ContentObject.*?MetaData.*?General.*?Title[^>]*?>([^<]*?)</", $xml, $matches))
605 {
606 $this->tpl->setVariable("VALUE_NEW_QUESTIONPOOL", $matches[1]);
607 }
608 }
609 $this->tpl->setVariable("TEXT_CREATE_NEW_QUESTIONPOOL", $this->lng->txt("qpl_import_create_new_qpl"));
610 $this->tpl->parseCurrentBlock();
611
612 $this->tpl->setCurrentBlock("adm_content");
613 $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
614 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
615 $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("qpl_import_verify_found_questions"));
616 if ($questions_only)
617 {
618 $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_questions_into_qpl"));
619 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
620 }
621 else
622 {
623 $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_qpl"));
624
625 $this->ctrl->setParameter($this, "new_type", $this->type);
626 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
627
628 //$this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".$_GET["ref_id"]."&new_type=".$this->type));
629 }
630 $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.svg"));
631 $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
632 $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
633 $value_questions_only = 0;
634 if ($questions_only) $value_questions_only = 1;
635 $this->tpl->setVariable("VALUE_QUESTIONS_ONLY", $value_questions_only);
636
637 $this->tpl->parseCurrentBlock();
638
639 return true;
640 }
641
646 {
647 if ($_POST["questions_only"] == 1)
648 {
649 $newObj =& $this->object;
650 }
651 else
652 {
653 include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
654 // create new questionpool object
655 $newObj = new ilObjQuestionPool(0, true);
656 // set type of questionpool object
657 $newObj->setType($_GET["new_type"]);
658 // set title of questionpool object to "dummy"
659 $newObj->setTitle("dummy");
660 // set description of questionpool object
661 $newObj->setDescription("questionpool import");
662 // create the questionpool class in the ILIAS database (object_data table)
663 $newObj->create(true);
664 // create a reference for the questionpool object in the ILIAS database (object_reference table)
665 $newObj->createReference();
666 // put the questionpool object in the administration tree
667 $newObj->putInTree($_GET["ref_id"]);
668 // get default permissions and set the permissions for the questionpool object
669 $newObj->setPermissions($_GET["ref_id"]);
670 // notify the questionpool object and all its parent objects that a "new" object was created
671 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
672 }
673
674 if (is_file($_SESSION["qpl_import_dir"].'/'.$_SESSION["qpl_import_subdir"]."/manifest.xml"))
675 {
676 $_SESSION["qpl_import_idents"] = $_POST["ident"];
677
678 $fileName = $_SESSION["qpl_import_subdir"].'.zip';
679 $fullPath = $_SESSION["qpl_import_dir"].'/'.$fileName;
680
681 include_once("./Services/Export/classes/class.ilImport.php");
682 $imp = new ilImport((int) $_GET["ref_id"]);
683 $map = $imp->getMapping();
684 $map->addMapping("Modules/TestQuestionPool", "qpl", "new_id", $newObj->getId());
685 $imp->importObject($newObj, $fullPath, $fileName, "qpl", "Modules/TestQuestionPool", true);
686 }
687 else
688 {
689 // start parsing of QTI files
690 include_once "./Services/QTI/classes/class.ilQTIParser.php";
691 $qtiParser = new ilQTIParser($_SESSION["qpl_import_qti_file"], IL_MO_PARSE_QTI, $newObj->getId(), $_POST["ident"]);
692 $result = $qtiParser->startParsing();
693
694 // import page data
695 if (strlen($_SESSION["qpl_import_xml_file"]))
696 {
697 include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
698 $contParser = new ilContObjParser($newObj, $_SESSION["qpl_import_xml_file"], $_SESSION["qpl_import_subdir"]);
699 $contParser->setQuestionMapping($qtiParser->getImportMapping());
700 $contParser->startParsing();
701
702 // #20494
703 $newObj->fromXML($_SESSION["qpl_import_xml_file"]);
704 }
705
706 // set another question pool name (if possible)
707 if( isset($_POST["qpl_new"]) && strlen($_POST["qpl_new"]) )
708 {
709 $newObj->setTitle($_POST["qpl_new"]);
710 }
711
712 $newObj->update();
713 $newObj->saveToDb();
714 }
715
716 // delete import directory
717 include_once "./Services/Utilities/classes/class.ilUtil.php";
719
720 if ($_POST["questions_only"] == 1)
721 {
722 $this->ctrl->redirect($this, "questions");
723 }
724 else
725 {
726 ilUtil::sendSuccess($this->lng->txt("object_imported"),true);
727 ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
728 "&baseClass=ilObjQuestionPoolGUI");
729 }
730 }
731
733 {
734 if ($_POST["questions_only"] == 1)
735 {
736 $this->ctrl->redirect($this, "questions");
737 }
738 else
739 {
740 $this->ctrl->redirect($this, "cancel");
741 }
742 }
743
747 function uploadObject()
748 {
749 $upload_valid = true;
750 $form = $this->getImportQuestionsForm();
751 if($form->checkInput())
752 {
753 if(!$this->uploadQplObject(true))
754 {
755 $form->setValuesByPost();
756 $this->importQuestionsObject($form);
757 }
758 }
759 else
760 {
761 $form->setValuesByPost();
762 $this->importQuestionsObject($form);
763 }
764 }
765
769 public function importQuestionsObject(ilPropertyFormGUI $form = null)
770 {
771 if(!$form instanceof ilPropertyFormGUI)
772 {
773 $form = $this->getImportQuestionsForm();
774 }
775
776 $this->tpl->setContent($form->getHtml());
777 }
778
782 protected function getImportQuestionsForm()
783 {
784 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
785 $form = new ilPropertyFormGUI();
786 $form->setTitle($this->lng->txt('import_question'));
787 $form->setFormAction($this->ctrl->getFormAction($this, 'upload'));
788
789 $file = new ilFileInputGUI($this->lng->txt('select_file'), 'xmldoc');
790 $file->setRequired(true);
791 $form->addItem($file);
792
793 $form->addCommandButton('upload', $this->lng->txt('upload'));
794 $form->addCommandButton('questions', $this->lng->txt('cancel'));
795
796 return $form;
797 }
798
803 {
805 {
806 $addContEditMode = $_POST['add_quest_cont_edit_mode'];
807 }
808 else
809 {
811 }
812
813 include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
814 $q_gui =& assQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
815 $this->object->addQuestionChangeListeners($q_gui->object);
816 $q_gui->object->setObjId($this->object->getId());
817 $q_gui->object->setAdditionalContentEditingMode($addContEditMode);
818 $q_gui->object->createNewQuestion();
819 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $q_gui->object->getId());
820 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_POST["sel_question_types"]);
821 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
822 }
823
828 {
829 if( !$_REQUEST['q_id'] )
830 {
831 require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
833 {
834 $addContEditMode = $_REQUEST['add_quest_cont_edit_mode'];
835 }
836 else
837 {
839 }
840
841 include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
842 $q_gui =& assQuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
843 $q_gui->object->setObjId($this->object->getId());
844 $q_gui->object->setAdditionalContentEditingMode($addContEditMode);
845 $q_gui->object->createNewQuestion();
846
847 $class = get_class($q_gui);
848 $qId = $q_gui->object->getId();
849 }
850 else
851 {
852 $class = $_GET["sel_question_types"] . 'gui';
853 $qId = $_REQUEST['q_id'];
854 }
855
856 $this->ctrl->setParameterByClass($class, "q_id", $qId);
857 $this->ctrl->setParameterByClass($class, "sel_question_types", $_REQUEST["sel_question_types"]);
858 $this->ctrl->setParameterByClass($class, "prev_qid", $_REQUEST["prev_qid"]);
859
860 $this->ctrl->redirectByClass($class, "editQuestion");
861 }
862
867 function afterSave(ilObject $a_new_object)
868 {
869 // always send a message
870 ilUtil::sendSuccess($this->lng->txt("object_added"),true);
871
872 ilUtil::redirect("ilias.php?ref_id=".$a_new_object->getRefId().
873 "&baseClass=ilObjQuestionPoolGUI");
874 }
875
876 function questionObject()
877 {
878//echo "<br>ilObjQuestionPoolGUI->questionObject()";
879 $type = $_GET["sel_question_types"];
880 $this->editQuestionForm($type);
881 }
882
887 {
888 global $rbacsystem;
889
890 if (count($_POST["q_id"]) < 1)
891 {
892 ilUtil::sendInfo($this->lng->txt("qpl_delete_select_none"), true);
893 $this->ctrl->redirect($this, "questions");
894 }
895
896 ilUtil::sendQuestion($this->lng->txt("qpl_confirm_delete_questions"));
897 $deleteable_questions =& $this->object->getDeleteableQuestionDetails($_POST["q_id"]);
898 include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
899 $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', (($rbacsystem->checkAccess('write', $_GET['ref_id']) ? true : false)), true);
900 $table_gui->setEditable($rbacsystem->checkAccess('write', $_GET['ref_id']));
901 $table_gui->setData($deleteable_questions);
902 $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
903 }
904
905
910 {
911 // delete questions after confirmation
912 foreach ($_POST["q_id"] as $key => $value)
913 {
914 $this->object->deleteQuestion($value);
915 $this->object->cleanupClipboard($value);
916 }
917 if (count($_POST["q_id"])) ilUtil::sendSuccess($this->lng->txt("qpl_questions_deleted"), true);
918
919 $this->ctrl->setParameter($this, 'q_id', '');
920
921 $this->ctrl->redirect($this, "questions");
922 }
923
928 {
929 $this->ctrl->redirect($this, "questions");
930 }
931
936 {
937 // export button was pressed
938 if (count($_POST["q_id"]) > 0)
939 {
940 include_once("./Modules/TestQuestionPool/classes/class.ilQuestionpoolExport.php");
941 $qpl_exp = new ilQuestionpoolExport($this->object, "xml", $_POST["q_id"]);
942 $export_file = $qpl_exp->buildExportFile();
943 $filename = $export_file;
944 $filename = preg_replace("/.*\//", "", $filename);
945 include_once "./Services/Utilities/classes/class.ilUtil.php";
946 ilUtil::deliverFile($export_file, $filename);
947 exit();
948 }
949 else
950 {
951 ilUtil::sendInfo($this->lng->txt("qpl_export_select_none"), true);
952 }
953 $this->ctrl->redirect($this, "questions");
954 }
955
957 {
958 require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
959 $taxIds = ilObjTaxonomy::getUsageOfObject($this->object->getId());
960
961 include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
962 $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', false, false, $taxIds);
963 $table_gui->resetOffset();
964 $table_gui->writeFilterToSession();
965 $this->questionsObject();
966 }
967
969 {
970 require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
971 $taxIds = ilObjTaxonomy::getUsageOfObject($this->object->getId());
972
973 include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
974 $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', false, false, $taxIds);
975 $table_gui->resetOffset();
976 $table_gui->resetFilter();
977 $this->questionsObject();
978 }
979
984 {
985 global $rbacsystem, $ilUser, $ilCtrl, $ilDB, $lng, $ilPluginAdmin;
986
987 if(get_class($this->object) == "ilObjTest")
988 {
989 if ($_GET["calling_test"] > 0)
990 {
991 $ref_id = $_GET["calling_test"];
992 $q_id = $_GET["q_id"];
993
994 if ($_REQUEST['test_express_mode']) {
995 if ($q_id)
996 ilUtil::redirect("ilias.php?ref_id=".$ref_id."&q_id=".$q_id."&test_express_mode=1&cmd=showPage&cmdClass=iltestexpresspageobjectgui&baseClass=ilObjTestGUI");
997 else
998 ilUtil::redirect("ilias.php?ref_id=".$ref_id."&test_express_mode=1&cmd=showPage&cmdClass=iltestexpresspageobjectgui&baseClass=ilObjTestGUI");
999 }
1000 else
1001 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&ref_id=".$ref_id."&cmd=questions");
1002
1003 }
1004 }
1005 else if(isset($_GET['calling_consumer']) && (int)$_GET['calling_consumer'])
1006 {
1007 $ref_id = (int)$_GET['calling_consumer'];
1009 if($consumer instanceof ilQuestionEditingFormConsumer)
1010 {
1011 ilUtil::redirect($consumer->getQuestionEditingFormBackTarget($_GET['consumer_context']));
1012 }
1013 require_once 'Services/Link/classes/class.ilLink.php';
1015 }
1016
1017 $this->object->purgeQuestions();
1018 // reset test_id SESSION variable
1019 $_SESSION["test_id"] = "";
1020
1021 require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
1022 $taxIds = ilObjTaxonomy::getUsageOfObject($this->object->getId());
1023
1024 $table_gui = $this->buildQuestionBrowserTableGUI($taxIds);
1025 $table_gui->setPreventDoubleSubmission(false);
1026
1027 if( $rbacsystem->checkAccess('write', $_GET['ref_id']) )
1028 {
1029 $toolbar = new ilToolbarGUI();
1030
1031 require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
1033 $btn->setCaption('ass_create_question');
1034 $btn->setUrl($this->ctrl->getLinkTarget($this, 'createQuestionForm'));
1035 $btn->setPrimary(true);
1036 $toolbar->addButtonInstance($btn);
1037
1038 $this->tpl->setContent(
1039 $this->ctrl->getHTML($toolbar) . $this->ctrl->getHTML($table_gui)
1040 );
1041 }
1042 else
1043 {
1044 $this->tpl->setContent( $this->ctrl->getHTML($table_gui) );
1045 }
1046
1047 if( $this->object->getShowTaxonomies() )
1048 {
1049 $this->lng->loadLanguageModule('tax');
1050
1051 require_once 'Services/Taxonomy/classes/class.ilTaxonomyExplorerGUI.php';
1052
1053 foreach($taxIds as $taxId)
1054 {
1055 if( $taxId != $this->object->getNavTaxonomyId() )
1056 {
1057 continue;
1058 }
1059
1060 $taxExp = new ilTaxonomyExplorerGUI(
1061 $this, 'showNavTaxonomy', $taxId, 'ilobjquestionpoolgui', 'questions'
1062 );
1063
1064 if( !$taxExp->handleCommand() )
1065 {
1066 $this->tpl->setLeftContent($taxExp->getHTML()."&nbsp;");
1067 }
1068
1069 break;
1070 }
1071 }
1072 }
1073
1074 private function createQuestionFormObject()
1075 {
1076 $form = $this->buildCreateQuestionForm();
1077
1078 $this->tpl->setContent( $this->ctrl->getHTML($form) );
1079 }
1080
1081 private function buildCreateQuestionForm()
1082 {
1083 global $ilUser;
1084
1085 // form
1086
1087 require_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1088 $form = new ilPropertyFormGUI();
1089 $form->setTitle($this->lng->txt('ass_create_question'));
1090 $form->setFormAction($this->ctrl->getFormAction($this));
1091
1092 // question type
1093
1094 $options = array();
1095 foreach( $this->object->getQuestionTypes(false, true) as $translation => $data )
1096 {
1097 $options[$data['type_tag']] = $translation;
1098 }
1099
1100 require_once("Services/Form/classes/class.ilSelectInputGUI.php");
1101 $si = new ilSelectInputGUI($this->lng->txt('question_type'), 'sel_question_types');
1102 $si->setOptions($options);
1103 //$si->setValue($ilUser->getPref("tst_lastquestiontype"));
1104
1105 $form->addItem($si);
1106
1107 // content editing mode
1108
1110 {
1111 $ri = new ilRadioGroupInputGUI($this->lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
1112
1113 $ri->addOption(new ilRadioOption(
1114 $this->lng->txt('tst_add_quest_cont_edit_mode_default'),
1116 ));
1117
1118 $ri->addOption(new ilRadioOption(
1119 $this->lng->txt('tst_add_quest_cont_edit_mode_page_object'),
1121 ));
1122
1124
1125 $form->addItem($ri, true);
1126 }
1127 else
1128 {
1129 $hi = new ilHiddenInputGUI("question_content_editing_type");
1131 $form->addItem($hi, true);
1132 }
1133
1134 // commands
1135
1136 $form->addCommandButton('createQuestion', $this->lng->txt('create'));
1137 $form->addCommandButton('questions', $this->lng->txt('cancel'));
1138
1139 return $form;
1140 }
1141
1145 public function printObject()
1146 {
1150 global $ilToolbar;
1151
1152 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'print'));
1153 require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
1154 $mode = new ilSelectInputGUI($this->lng->txt('output_mode'), 'output');
1155 $mode->setOptions(array(
1156 'overview' => $this->lng->txt('overview'),
1157 'detailed' => $this->lng->txt('detailed_output_solutions'),
1158 'detailed_printview' => $this->lng->txt('detailed_output_printview')
1159 ));
1160 $mode->setValue(ilUtil::stripSlashes($_POST['output']));
1161
1162 $ilToolbar->setFormName('printviewOptions');
1163 $ilToolbar->addInputItem($mode, true);
1164 $ilToolbar->addFormButton($this->lng->txt('submit'), 'print');
1165
1166 include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionPoolPrintViewTableGUI.php";
1167 $table_gui = new ilQuestionPoolPrintViewTableGUI($this, 'print', $_POST['output']);
1168 $data = $this->object->getPrintviewQuestions();
1169 $totalPoints = 0;
1170 foreach($data as $d)
1171 {
1172 $totalPoints += $d['points'];
1173 }
1174 $table_gui->setTotalPoints($totalPoints);
1175 $table_gui->initColumns();
1176 $table_gui->setData($data);
1177 $this->tpl->setContent($table_gui->getHTML());
1178 }
1179
1180 function updateObject()
1181 {
1182// $this->update = $this->object->updateMetaData();
1183 $this->update = $this->object->update();
1184 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1185 }
1186
1190 function pasteObject()
1191 {
1192 if (array_key_exists("qpl_clipboard", $_SESSION))
1193 {
1194 if($this->object->pasteFromClipboard())
1195 {
1196 ilUtil::sendSuccess($this->lng->txt("qpl_paste_success"), true);
1197 }
1198 else
1199 {
1200 ilUtil::sendFailure($this->lng->txt("qpl_paste_error"), true);
1201 }
1202 }
1203 else
1204 {
1205 ilUtil::sendInfo($this->lng->txt("qpl_paste_no_objects"), true);
1206 }
1207 $this->ctrl->redirect($this, "questions");
1208 }
1209
1213 public function copyObject()
1214 {
1215 if (count($_POST["q_id"]) > 0)
1216 {
1217 foreach ($_POST["q_id"] as $key => $value)
1218 {
1219 $this->object->copyToClipboard($value);
1220 }
1221 ilUtil::sendInfo($this->lng->txt("qpl_copy_insert_clipboard"), true);
1222 }
1223 else
1224 {
1225 ilUtil::sendInfo($this->lng->txt("qpl_copy_select_none"), true);
1226 }
1227 $this->ctrl->redirect($this, "questions");
1228 }
1229
1233 function moveObject()
1234 {
1235 if (count($_POST["q_id"]) > 0)
1236 {
1237 foreach ($_POST["q_id"] as $key => $value)
1238 {
1239 $this->object->moveToClipboard($value);
1240 }
1241 ilUtil::sendInfo($this->lng->txt("qpl_move_insert_clipboard"), true);
1242 }
1243 else
1244 {
1245 ilUtil::sendInfo($this->lng->txt("qpl_move_select_none"), true);
1246 }
1247 $this->ctrl->redirect($this, "questions");
1248 }
1249
1251 {
1252 global $rbacsystem;
1253 if ($rbacsystem->checkAccess("write", $_GET['ref_id']))
1254 {
1255 include_once("./Modules/TestQuestionPool/classes/class.ilQuestionpoolExport.php");
1256 $question_ids =& $this->object->getAllQuestionIds();
1257 $qpl_exp = new ilQuestionpoolExport($this->object, 'xls', $question_ids);
1258 $qpl_exp->buildExportFile();
1259 $this->ctrl->redirectByClass("ilquestionpoolexportgui", "");
1260 }
1261 }
1262
1267 {
1268 include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1269 $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1270 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
1271 }
1272
1273 protected function initImportForm($a_new_type)
1274 {
1275 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1276 $form = new ilPropertyFormGUI();
1277 $form->setTarget("_top");
1278 $form->setFormAction($this->ctrl->getFormAction($this));
1279 $form->setTitle($this->lng->txt("import_qpl"));
1280
1281 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
1282 $fi = new ilFileInputGUI($this->lng->txt("import_file"), "xmldoc");
1283 $fi->setSuffixes(array("zip"));
1284 $fi->setRequired(true);
1285 $form->addItem($fi);
1286
1287 $form->addCommandButton("importFile", $this->lng->txt("import"));
1288 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
1289
1290 return $form;
1291 }
1292
1297 {
1298 $form = $this->initImportForm($_REQUEST["new_type"]);
1299 if($form->checkInput())
1300 {
1301 $this->uploadQplObject();
1302 }
1303
1304 // display form to correct errors
1305 $this->tpl->setContent($form->getHTML());
1306 }
1307
1309 {
1310 global $ilLocator;
1311 switch ($this->ctrl->getCmd())
1312 {
1313 case "create":
1314 case "importFile":
1315 case "cancel":
1316 break;
1317 default:
1318 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
1319 break;
1320 }
1321 if ($_GET["q_id"] > 0)
1322 {
1323 include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1324 $q_gui = assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1325 if($q_gui->object instanceof assQuestion)
1326 {
1327 $q_gui->object->setObjId($this->object->getId());
1328 $title = $q_gui->object->getTitle();
1329 if(!$title)
1330 {
1331 $title = $this->lng->txt('new').': '.assQuestion::_getQuestionTypeName($q_gui->object->getQuestionType());
1332 }
1333 $ilLocator->addItem($title, $this->ctrl->getLinkTargetByClass(get_class($q_gui), "editQuestion"));
1334 }
1335 else
1336 {
1337 // Workaround for context issues: If no object was found, redirect without q_id parameter
1338 $this->ctrl->setParameter($this, 'q_id', '');
1339 $this->ctrl->redirect($this);
1340 }
1341 }
1342 }
1343
1348 {
1349 parent::setTitleAndDescription();
1350 if ($_GET["q_id"] > 0)
1351 {
1352 include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1353 $q_gui = assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1354 if($q_gui->object instanceof assQuestion)
1355 {
1356 $q_gui->object->setObjId($this->object->getId());
1357 $title = $q_gui->object->getTitle();
1358 if(!$title)
1359 {
1360 $title = $this->lng->txt('new').': '.assQuestion::_getQuestionTypeName($q_gui->object->getQuestionType());
1361 }
1362 $this->tpl->setTitle($title);
1363 $this->tpl->setDescription($q_gui->object->getComment());
1364 if($this->object instanceof ilObjectPlugin)
1365 {
1366 $this->tpl->setTitleIcon($this->object->plugin->getImagePath("icon_".$this->object->getType().".svg"), $this->lng->txt("obj_" . $this->object->getType()));
1367 }
1368 else
1369 {
1370 $this->tpl->setTitleIcon(ilObject::_getIcon("", "big", $this->object->getType()));
1371 }
1372 }
1373 else
1374 {
1375 // Workaround for context issues: If no object was found, redirect without q_id parameter
1376 $this->ctrl->setParameter($this, 'q_id', '');
1377 $this->ctrl->redirect($this);
1378 }
1379 }
1380 else
1381 {
1382 $this->tpl->setTitle($this->object->getTitle());
1383 $this->tpl->setDescription($this->object->getLongDescription());
1384 $this->tpl->setTitleIcon(ilObject::_getIcon("", "big", $this->object->getType()));
1385 }
1386 }
1387
1393 function getTabs(&$tabs_gui)
1394 {
1395 global $ilAccess, $ilHelp;
1396
1397 $currentUserHasWriteAccess = $ilAccess->checkAccess("write", "", $this->object->getRefId());
1398
1399 $ilHelp->setScreenIdComponent("qpl");
1400
1401 $next_class = strtolower($this->ctrl->getNextClass());
1402 switch ($next_class)
1403 {
1404 case "":
1405 case "ilpermissiongui":
1406 case "ilobjectmetadatagui":
1407 case "ilquestionpoolexportgui":
1408 case "ilquestionpoolskilladministrationgui":
1409 break;
1410
1411 case 'ilobjtaxonomygui':
1412 case 'ilobjquestionpoolsettingsgeneralgui':
1413
1414 if( $currentUserHasWriteAccess )
1415 {
1416 $this->addSettingsSubTabs($tabs_gui);
1417 }
1418
1419 break;
1420
1421 default:
1422 return;
1423 break;
1424 }
1425 // questions
1426 $force_active = false;
1427 $commands = $_POST["cmd"];
1428 if (is_array($commands))
1429 {
1430 foreach ($commands as $key => $value)
1431 {
1432 if (preg_match("/^delete_.*/", $key, $matches) ||
1433 preg_match("/^addSelectGap_.*/", $key, $matches) ||
1434 preg_match("/^addTextGap_.*/", $key, $matches) ||
1435 preg_match("/^deleteImage_.*/", $key, $matches) ||
1436 preg_match("/^upload_.*/", $key, $matches) ||
1437 preg_match("/^addSuggestedSolution_.*/", $key, $matches)
1438 )
1439 {
1440 $force_active = true;
1441 }
1442 }
1443 }
1444 if (array_key_exists("imagemap_x", $_POST))
1445 {
1446 $force_active = true;
1447 }
1448 if (!$force_active)
1449 {
1450 $force_active = ((strtolower($this->ctrl->getCmdClass()) == strtolower(get_class($this)) || strlen($this->ctrl->getCmdClass()) == 0) &&
1451 $this->ctrl->getCmd() == "")
1452 ? true
1453 : false;
1454 }
1455 $tabs_gui->addTarget("assQuestions",
1456 $this->ctrl->getLinkTarget($this, "questions"),
1457 array("questions", "filter", "resetFilter", "createQuestion",
1458 "importQuestions", "deleteQuestions", "filterQuestionBrowser",
1459 "view", "preview", "editQuestion", "exec_pg",
1460 "addItem", "upload", "save", "cancel", "addSuggestedSolution",
1461 "cancelExplorer", "linkChilds", "removeSuggestedSolution",
1462 "add", "addYesNo", "addTrueFalse", "createGaps", "saveEdit",
1463 "setMediaMode", "uploadingImage", "uploadingImagemap", "addArea",
1464 "deletearea", "saveShape", "back", "addPair", "uploadingJavaapplet",
1465 "addParameter", "assessment", "addGIT", "addST", "addPG", "delete",
1466 "toggleGraphicalAnswers", "deleteAnswer", "deleteImage", "removeJavaapplet"),
1467 "", "", $force_active);
1468
1469 if ($ilAccess->checkAccess("read", "", $this->ref_id) || $ilAccess->checkAccess("visible", "", $this->ref_id))
1470 {
1471 $tabs_gui->addTarget("info_short",
1472 $this->ctrl->getLinkTarget($this, "infoScreen"),
1473 array("infoScreen", "showSummary"));
1474 }
1475
1476 if ($ilAccess->checkAccess("write", "", $_GET['ref_id']))
1477 {
1478 // properties
1479 $tabs_gui->addTarget(
1480 'settings', $this->ctrl->getLinkTargetByClass('ilObjQuestionPoolSettingsGeneralGUI'),
1481 array(), array('ilObjQuestionPoolSettingsGeneralGUI', 'ilObjTaxonomyGUI')
1482 );
1483
1484 // skill service
1485 if( $this->isSkillsTabRequired() )
1486 {
1487 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentsGUI.php';
1488
1489 $link = $this->ctrl->getLinkTargetByClass(
1490 array('ilQuestionPoolSkillAdministrationGUI', 'ilAssQuestionSkillAssignmentsGUI'),
1492 );
1493
1494 $tabs_gui->addTarget('qpl_tab_competences', $link, array(), array());
1495 }
1496 }
1497
1498 // print view
1499 $tabs_gui->addTarget("print_view",
1500 $this->ctrl->getLinkTarget($this,'print'),
1501 array("print"),
1502 "", "");
1503
1504 if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1505 {
1506 // meta data
1507 include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
1508 $mdgui = new ilObjectMetaDataGUI($this->object);
1509 $mdtab = $mdgui->getTab();
1510 if($mdtab)
1511 {
1512 $tabs_gui->addTarget("meta_data",
1513 $mdtab,
1514 "", "ilmdeditorgui");
1515 }
1516
1517// $tabs_gui->addTarget("export",
1518// $this->ctrl->getLinkTarget($this,'export'),
1519// array("export", "createExportFile", "confirmDeleteExportFile", "downloadExportFile"),
1520// "", "");
1521 }
1522
1523 if( $currentUserHasWriteAccess )
1524 {
1525 $tabs_gui->addTarget("export",
1526 $this->ctrl->getLinkTargetByClass("ilquestionpoolexportgui", ""),
1527 "", "ilquestionpoolexportgui");
1528 }
1529
1530 if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId()))
1531 {
1532 $tabs_gui->addTarget("perm_settings",
1533 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1534 }
1535 }
1536
1537 private function isSkillsTabRequired()
1538 {
1539 if( !($this->object instanceof ilObjQuestionPool) )
1540 {
1541 return false;
1542 }
1543
1544 if( !$this->object->isSkillServiceEnabled() )
1545 {
1546 return false;
1547 }
1548
1550 {
1551 return false;
1552 }
1553
1554 return true;
1555 }
1556
1557 private function addSettingsSubTabs(ilTabsGUI $tabs)
1558 {
1559 $tabs->addSubTabTarget(
1560 'qpl_settings_subtab_general',
1561 $this->ctrl->getLinkTargetByClass('ilObjQuestionPoolSettingsGeneralGUI'),
1562 '', 'ilObjQuestionPoolSettingsGeneralGUI'
1563 );
1564
1565 $tabs->addSubTabTarget(
1566 'qpl_settings_subtab_taxonomies',
1567 $this->ctrl->getLinkTargetByClass('ilObjTaxonomyGUI', 'editAOTaxonomySettings'),
1568 '', 'ilObjTaxonomyGUI'
1569 );
1570 }
1571
1578 {
1579 $this->ctrl->setCmd("showSummary");
1580 $this->ctrl->setCmdClass("ilinfoscreengui");
1581 $this->infoScreenForward();
1582 }
1583
1588 {
1589 global $ilErr, $ilAccess;
1590
1591 if(!$ilAccess->checkAccess("visible", "", $this->ref_id))
1592 {
1593 $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
1594 }
1595
1596 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1597 $info = new ilInfoScreenGUI($this);
1598 $info->enablePrivateNotes();
1599
1600 // standard meta data
1601 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
1602
1603 $this->ctrl->forwardCommand($info);
1604 }
1605
1614 public static function _goto($a_target)
1615 {
1616 global $ilAccess, $ilErr, $lng;
1617
1618 if ($ilAccess->checkAccess("write", "", $a_target) || $ilAccess->checkAccess('read', '', $a_target))
1619 {
1620 $_GET["baseClass"] = "ilObjQuestionPoolGUI";
1621 $_GET["cmd"] = "questions";
1622 $_GET["ref_id"] = $a_target;
1623 include_once("ilias.php");
1624 exit;
1625 }
1626 else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1627 {
1628 ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
1631 }
1632 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
1633 }
1634
1643 private function buildQuestionBrowserTableGUI($taxIds)
1644 {
1645 global $rbacsystem, $ilDB, $lng, $ilPluginAdmin;
1646
1647 include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
1648 $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', (($rbacsystem->checkAccess('write', $_GET['ref_id']) ? true : false)), false, $taxIds);
1649 $table_gui->setEditable($rbacsystem->checkAccess('write', $_GET['ref_id']));
1650
1651 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
1652 $questionList = new ilAssQuestionList($ilDB, $lng, $ilPluginAdmin);
1653 $questionList->setParentObjId($this->object->getId());
1654
1655 foreach ($table_gui->getFilterItems() as $item)
1656 {
1657 if( substr($item->getPostVar(), 0, strlen('tax_')) == 'tax_' )
1658 {
1659 $v = $item->getValue();
1660
1661 if( is_array($v) && count($v) && !(int)$v[0] )
1662 {
1663 continue;
1664 }
1665
1666 $taxId = substr($item->getPostVar(), strlen('tax_'));
1667
1668 $questionList->addTaxonomyFilter(
1669 $taxId, $item->getValue(), $this->object->getId(), $this->object->getType()
1670 );
1671 }
1672 elseif( $item->getValue() !== false )
1673 {
1674 $questionList->addFieldFilter($item->getPostVar(), $item->getValue());
1675 }
1676 }
1677
1678 if( $this->object->isNavTaxonomyActive() && (int)$_GET['tax_node'] )
1679 {
1680 $questionList->addTaxonomyFilter(
1681 $this->object->getNavTaxonomyId(), array((int)$_GET['tax_node']),
1682 $this->object->getId(), $this->object->getType()
1683 );
1684 }
1685
1686 $questionList->load();
1687 $data = $questionList->getQuestionDataArray();
1688
1689 $table_gui->setData($data);
1690
1691 return $table_gui;
1692 }
1693
1694
1695
1696} // END class.ilObjQuestionPoolGUI
1697?>
$result
print $file
$filename
Definition: buildRTE.php:89
$_GET["client_id"]
$_SESSION["AccountId"]
const IL_COMP_MODULE
const IL_MO_VERIFY_QTI
const IL_MO_PARSE_QTI
& _getQuestionGUI($question_type, $question_id=-1)
Creates a question gui representation and returns the alias to the question gui note: please do not u...
Abstract basic class which is to be extended by the concrete assessment question type classes.
const ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT
constant for additional content editing mode "default"
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
const ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT
constant for additional content editing mode "pageobject"
Question page GUI class.
Question page object.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Content Object Parser.
This class represents a file property in a property form.
This class represents a hidden form property in a property form.
Import class.
Class ilInfoScreenGUI.
static getInstance()
Factory.
Class ilLocalUnitConfigurationGUI.
static isAdditionalQuestionContentEditingModePageObjectEnabled()
returns the fact wether content editing with ilias page editor is enabled for questions or not
Class ilObjFile.
Class ilObjQuestionPoolGUI.
ilObjQuestionPoolGUI()
Constructor @access public.
uploadQplObject($questions_only=false)
imports question(s) into the questionpool
confirmDeleteQuestionsObject()
delete questions
afterSave(ilObject $a_new_object)
save object @access public
updateObject()
updates object entry in object_data
download_paragraphObject()
download source code paragraph
deleteQuestionsObject()
delete questions confirmation screen
& createQuestionForTestObject()
create new question
filterObject()
set question list filter
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
questionsObject()
list questions of question pool
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
importVerifiedFileObject()
imports question(s) into the questionpool (after verification)
uploadObject()
imports question(s) into the questionpool
moveObject()
mark one or more question objects for moving
& createQuestionObject()
create new question
pasteObject()
paste questios from the clipboard into the question pool
initImportForm($a_new_type)
Init object import form.
importFileObject()
form for new questionpool object import
cancelDeleteQuestionsObject()
Cancel question deletion.
& editQuestionForTestObject()
edit question
setTitleAndDescription()
called by prepare output
infoScreenForward()
show information screen
static _goto($a_target)
Redirect script to call a test with the question pool reference id.
copyObject()
copy one or more question objects to the clipboard
exportObject()
Gateway for exports initiated from workspace, as there is a generic forward to {objTypeMainGUI}::expo...
importQuestionsObject(ilPropertyFormGUI $form=null)
display the import form to import questions into the questionpool
fullscreenObject()
show fullscreen view
getTabs(&$tabs_gui)
adds tabs to tab gui object
_getImportDirectory()
get import directory of lm
static _createImportDirectory()
creates data directory for import files (data_dir/qpl_data/qpl_<id>/import, depending on data directo...
_setImportDirectory($a_import_dir=null)
set import directory
getContentStylePath($a_style_id)
get content style path
getSyntaxStylePath()
get syntax style path
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
_setImportDirectory($a_import_dir=null)
set import directory
GUI class for the workflow of copying objects.
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObjectGUI Basic methods of all Output classes.
ilObjectGUI($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
Constructor @access public.
prepareOutput()
prepare output
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
getCreationMode()
get creation mode
Class ilObjectMetaDataGUI.
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
getRefId()
get reference id @access public
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
This class represents a property form user interface.
Export User Interface Class.
Export class for questionpools.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
Tabs GUI.
addSubTabTarget($a_text, $a_link, $a_cmd="", $a_cmdClass="", $a_frame="", $a_activate=false, $a_dir_text=false)
DEPRECATED.
Taxonomy explorer GUI class.
Class ilUnitConfigurationRepository.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static redirect($a_script)
http redirect to other script
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
$_POST['username']
Definition: cron.php:12
$info
Definition: example_052.php:80
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilCtrl
Definition: ilias.php:18
const CLOZE_TEST_IDENTIFIER
Question identifier constants.
const IMAGEMAP_QUESTION_IDENTIFIER
const SINGLE_CHOICE_QUESTION_IDENTIFIER
const TEXTSUBSET_QUESTION_IDENTIFIER
const NUMERIC_QUESTION_IDENTIFIER
const JAVAAPPLET_QUESTION_IDENTIFIER
const TEXT_QUESTION_IDENTIFIER
const LONG_MENU_QUESTION_IDENTIFIER
const KPRIM_CHOICE_QUESTION_IDENTIFIER
const MATCHING_QUESTION_IDENTIFIER
const MULTIPLE_CHOICE_QUESTION_IDENTIFIER
const ORDERING_QUESTION_IDENTIFIER
exit
Definition: login.php:54
$cmd
Definition: sahs_server.php:35
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
global $ilDB
if(!is_array($argv)) $options
global $ilUser
Definition: imgupload.php:15