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