ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjQuestionPoolGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once './Services/Object/classes/class.ilObjectGUI.php';
5 require_once './Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
6 require_once './Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
7 require_once './Modules/TestQuestionPool/exceptions/class.ilTestQuestionPoolException.php';
8 require_once './Modules/Test/classes/inc.AssessmentConstants.php';
9 require_once './Modules/Test/classes/class.ilObjAssessmentFolder.php';
10 require_once './Modules/Test/classes/class.ilObjTest.php';
11 
33 {
37  public $object;
38 
44  {
45  global $lng, $ilCtrl, $rbacsystem;
46  $lng->loadLanguageModule("assessment");
47  $this->type = "qpl";
48  $this->ctrl =& $ilCtrl;
49 
50  $this->ctrl->saveParameter($this, array(
51  "ref_id", "test_ref_id", "calling_test", "test_express_mode", "q_id", 'tax_node'
52  ));
53 
54  $this->ilObjectGUI("",$_GET["ref_id"], true, false);
55  }
56 
69  function executeCommand()
70  {
71  global $ilLocator, $ilAccess, $ilNavigationHistory, $tpl, $ilCtrl, $ilErr, $ilTabs, $lng, $ilDB, $ilPluginAdmin;
72 
73  if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"])) && (!$ilAccess->checkAccess("visible", "", $_GET["ref_id"])))
74  {
75  global $ilias;
76  $ilias->raiseError($this->lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
77  }
78 
79  // add entry to navigation history
80  if (!$this->getCreationMode() &&
81  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
82  {
83  if('qpl' == $this->object->getType())
84  {
85  $ilNavigationHistory->addItem($_GET["ref_id"],
86  "ilias.php?baseClass=ilObjQuestionPoolGUI&cmd=questions&ref_id=".$_GET["ref_id"], "qpl");
87  }
88  }
89 
90  $cmd = $this->ctrl->getCmd("questions");
91  $next_class = $this->ctrl->getNextClass($this);
92 
93  if( in_array($next_class, array('', 'ilobjquestionpoolgui')) && $cmd == 'questions' )
94  {
95  $_GET['q_id'] = '';
96  }
97 
98  $this->prepareOutput();
99 
100  $this->ctrl->setReturn($this, "questions");
101 
102  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
103  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "ta.css", "Modules/Test"), "screen");
104 
105  if ($_GET["q_id"] < 1)
106  {
107  $q_type = ($_POST["sel_question_types"] != "")
108  ? $_POST["sel_question_types"]
109  : $_GET["sel_question_types"];
110  }
111  if ($cmd != "createQuestion" && $cmd != "createQuestionForTest"
112  && $next_class != "ilassquestionpagegui")
113  {
114  if (($_GET["test_ref_id"] != "") or ($_GET["calling_test"]))
115  {
116  $ref_id = $_GET["test_ref_id"];
117  if (!$ref_id)
118  {
119  $ref_id = $_GET["calling_test"];
120  }
121  }
122  }
123  switch($next_class)
124  {
125  case "ilcommonactiondispatchergui":
126  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
128  $this->ctrl->forwardCommand($gui);
129  break;
130 
131  case 'ilmdeditorgui':
132  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
133  {
134  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
135  }
136 
137  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
138 
139  $md_gui = new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
140  $md_gui->addObserver($this->object,'MDUpdateListener','General');
141  $this->ctrl->forwardCommand($md_gui);
142  break;
143  case "ilassquestionpagegui":
144  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
145  $this->tpl->setCurrentBlock("ContentStyle");
146  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
147  $this->tpl->parseCurrentBlock();
148 
149  // syntax style
150  $this->tpl->setCurrentBlock("SyntaxStyle");
151  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
152  $this->tpl->parseCurrentBlock();
153 
154  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
155  $q_gui = assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
156  $q_gui->setQuestionTabs();
157  $q_gui->outAdditionalOutput();
158  $q_gui->object->setObjId($this->object->getId());
159  $question = $q_gui->object;
160  $this->ctrl->saveParameter($this, "q_id");
161  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
162  $this->lng->loadLanguageModule("content");
163  $this->ctrl->setReturnByClass("ilAssQuestionPageGUI", "view");
164  $this->ctrl->setReturn($this, "questions");
165  $page_gui = new ilAssQuestionPageGUI($_GET["q_id"]);
166  $page_gui->setEditPreview(true);
167  $page_gui->setEnabledTabs(false);
168  if (strlen($this->ctrl->getCmd()) == 0 && !isset($_POST["editImagemapForward_x"])) // workaround for page edit imagemaps, keep in mind
169  {
170  $this->ctrl->setCmdClass(get_class($page_gui));
171  $this->ctrl->setCmd("preview");
172  }
173  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(TRUE)));
174  $page_gui->setTemplateTargetVar("ADM_CONTENT");
175  $page_gui->setOutputMode("edit");
176  $page_gui->setHeader($question->getTitle());
177  $page_gui->setPresentationTitle($question->getTitle());
178  $ret = $this->ctrl->forwardCommand($page_gui);
179  $tpl->setContent($ret);
180  break;
181 
182  case 'ilpermissiongui':
183  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
184  $perm_gui = new ilPermissionGUI($this);
185  $ret = $this->ctrl->forwardCommand($perm_gui);
186  break;
187 
188  case 'ilobjectcopygui':
189  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
190  $cp = new ilObjectCopyGUI($this);
191  $cp->setType('qpl');
192  $this->ctrl->forwardCommand($cp);
193  break;
194 
195  case "ilexportgui":
196  include_once("./Services/Export/classes/class.ilExportGUI.php");
197  $exp_gui = new ilExportGUI($this);
198  $exp_gui->addFormat("zip", $this->lng->txt('qpl_export_xml'), $this, "createExportQTI");
199  $exp_gui->addFormat("xls", $this->lng->txt('qpl_export_excel'), $this, "createExportExcel");
200  // $exp_gui->addCustomColumn($lng->txt("cont_public_access"), $this, "getPublicAccessColValue");
201  // $exp_gui->addCustomMultiCommand($lng->txt("cont_public_access"), $this, "publishExportFile");
202  $ret = $this->ctrl->forwardCommand($exp_gui);
203  break;
204 
205  case "ilinfoscreengui":
206  $this->infoScreenForward();
207  break;
208 
209  case 'ilassquestionhintsgui':
210 
211  // set return target
212  $this->ctrl->setReturn($this, "questions");
213 
214  // set context tabs
215  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
216  $questionGUI = assQuestionGUI::_getQuestionGUI($q_type, $_GET['q_id']);
217  $questionGUI->object->setObjId($this->object->getId());
218  $questionGUI->setQuestionTabs();
219 
220  // forward to ilAssQuestionHintsGUI
221  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsGUI.php';
222  $gui = new ilAssQuestionHintsGUI($questionGUI);
223  $ilCtrl->forwardCommand($gui);
224 
225  break;
226 
227  case 'illocalunitconfigurationgui':
228  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
229  {
230  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
231  }
232 
233  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
234  $questionGUI = assQuestionGUI::_getQuestionGUI($q_type, $_GET['q_id']);
235  $questionGUI->object->setObjId($this->object->getId());
236  $questionGUI->setQuestionTabs();
237 
238  $this->ctrl->setReturn($this, 'questions');
239 
240  require_once 'Modules/TestQuestionPool/classes/class.ilLocalUnitConfigurationGUI.php';
241  require_once 'Modules/TestQuestionPool/classes/class.ilUnitConfigurationRepository.php';
242  $gui = new ilLocalUnitConfigurationGUI(
243  new ilUnitConfigurationRepository((int)$_GET['q_id'])
244  );
245  $ilCtrl->forwardCommand($gui);
246  break;
247 
248  case 'ilassquestionfeedbackeditinggui':
249 
250  // set return target
251  $this->ctrl->setReturn($this, "questions");
252 
253  // set context tabs
254  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
255  $questionGUI = assQuestionGUI::_getQuestionGUI($q_type, $_GET['q_id']);
256  $questionGUI->object->setObjId($this->object->getId());
257  $questionGUI->setQuestionTabs();
258 
259  // forward to ilAssQuestionFeedbackGUI
260  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackEditingGUI.php';
261  $gui = new ilAssQuestionFeedbackEditingGUI($questionGUI, $ilCtrl, $ilAccess, $tpl, $ilTabs, $lng);
262  $ilCtrl->forwardCommand($gui);
263 
264  break;
265 
266  case 'ilobjquestionpoolsettingsgeneralgui':
267  require_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPoolSettingsGeneralGUI.php';
268  $gui = new ilObjQuestionPoolSettingsGeneralGUI($ilCtrl, $ilAccess, $lng, $tpl, $ilTabs, $this);
269  $this->ctrl->forwardCommand($gui);
270  break;
271 
272  case "ilobjtaxonomygui":
273 
274  require_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPoolTaxonomyEditingCommandForwarder.php';
276  $this->object, $ilDB, $ilPluginAdmin, $ilCtrl, $ilTabs, $lng
277  );
278 
279  $forwarder->forward();
280 
281  break;
282 
283  case 'ilquestionbrowsertablegui':
284  $this->ctrl->forwardCommand($this->buildQuestionBrowserTableGUI($taxIds = array())); // no tax ids required
285  break;
286 
287  case "ilobjquestionpoolgui":
288  case "":
289 
290  if( $cmd == 'questions' )
291  {
292  $this->ctrl->setParameter($this, 'q_id', '');
293  }
294 
295  $cmd.= "Object";
296  $ret = $this->$cmd();
297  break;
298 
299  default:
300  $this->ctrl->setReturn($this, "questions");
301  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
302  $q_gui = assQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
303  $q_gui->object->setObjId($this->object->getId());
304  if($this->object->getType() == 'qpl')
305  {
306  $q_gui->setTaxonomyIds($this->object->getTaxonomyIds());
307  $this->object->addQuestionChangeListeners($q_gui->object);
308  }
309  $q_gui->setQuestionTabs();
310  $ret = $this->ctrl->forwardCommand($q_gui);
311  break;
312  }
313 
314  if ( !(strtolower($_GET["baseClass"]) == "iladministrationgui"
315  || strtolower($_GET['baseClass']) == 'ilrepositorygui')
316  && $this->getCreationMode() != true)
317  {
318  $this->tpl->show();
319  }
320  }
321 
326  {
327  $file = explode("_", $_GET["file_id"]);
328  include_once("./Modules/File/classes/class.ilObjFile.php");
329  $fileObj =& new ilObjFile($file[count($file) - 1], false);
330  $fileObj->sendFile();
331  exit;
332  }
333 
337  function fullscreenObject()
338  {
339  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
340  $page_gui = new ilAssQuestionPageGUI($_GET["pg_id"]);
341  $page_gui->showMediaFullscreen();
342  }
343 
344 
348  function filterObject()
349  {
350  $this->questionsObject();
351  }
352 
356  function resetFilterObject()
357  {
358  $_POST["filter_text"] = "";
359  $_POST["sel_filter_type"] = "";
360  $this->questionsObject();
361  }
362 
367  {
368  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
369  $pg_obj = new ilAssQuestionPage($_GET["pg_id"]);
370  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
371  exit;
372  }
373 
377  function uploadQplObject($questions_only = false)
378  {
379  $this->ctrl->setParameter($this, 'new_type', $_REQUEST['new_type']);
380  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
381  {
382  ilUtil::sendFailure($this->lng->txt("error_upload"), true);
383  if(!$questions_only)
384  {
385  $this->ctrl->redirect($this, 'create');
386  }
387  return false;
388  }
389  // create import directory
390  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
392 
393  // copy uploaded file to import directory
394  $file = pathinfo($_FILES["xmldoc"]["name"]);
395  $full_path = $basedir."/".$_FILES["xmldoc"]["name"];
396  $GLOBALS['ilLog']->write(__METHOD__.": full path " . $full_path);
397  include_once "./Services/Utilities/classes/class.ilUtil.php";
398  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
399  $GLOBALS['ilLog']->write(__METHOD__.": full path " . $full_path);
400  if (strcmp($_FILES["xmldoc"]["type"], "text/xml") == 0)
401  {
402  $qti_file = $full_path;
404  }
405  else
406  {
407  // unzip file
408  ilUtil::unzip($full_path);
409 
410  // determine filenames of xml files
411  $subdir = basename($file["basename"],".".$file["extension"]);
413  $xml_file = ilObjQuestionPool::_getImportDirectory().'/'.$subdir.'/'.$subdir.".xml";
414  $qti_file = ilObjQuestionPool::_getImportDirectory().'/'.$subdir.'/'. str_replace("qpl", "qti", $subdir).".xml";
415  }
416 
417  // start verification of QTI files
418  include_once "./Services/QTI/classes/class.ilQTIParser.php";
419  $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
420  $result = $qtiParser->startParsing();
421  $founditems =& $qtiParser->getFoundItems();
422  if (count($founditems) == 0)
423  {
424  // nothing found
425 
426  // delete import directory
427  ilUtil::delDir($basedir);
428 
429  ilUtil::sendFailure($this->lng->txt("qpl_import_no_items"), true);
430  if(!$questions_only)
431  {
432  $this->ctrl->redirect($this, 'create');
433  }
434  return false;
435  }
436 
437  $complete = 0;
438  $incomplete = 0;
439  foreach ($founditems as $item)
440  {
441  if (strlen($item["type"]))
442  {
443  $complete++;
444  }
445  else
446  {
447  $incomplete++;
448  }
449  }
450 
451  if ($complete == 0)
452  {
453  // delete import directory
454  ilUtil::delDir($basedir);
455 
456  ilUtil::sendFailure($this->lng->txt("qpl_import_non_ilias_files"), true);
457  if(!$questions_only)
458  {
459  $this->ctrl->redirect($this, 'create');
460  }
461  return false;
462  }
463 
464  $_SESSION["qpl_import_xml_file"] = $xml_file;
465  $_SESSION["qpl_import_qti_file"] = $qti_file;
466  $_SESSION["qpl_import_subdir"] = $subdir;
467  // display of found questions
468  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_import_verification.html",
469  "Modules/TestQuestionPool");
470  $row_class = array("tblrow1", "tblrow2");
471  $counter = 0;
472  foreach ($founditems as $item)
473  {
474  $this->tpl->setCurrentBlock("verification_row");
475  $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
476  $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
477  $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
478  include_once "./Services/QTI/classes/class.ilQTIItem.php";
479  switch ($item["type"])
480  {
482  $type = $this->lng->txt("assClozeTest");
483  break;
485  $type = $this->lng->txt("assImagemapQuestion");
486  break;
488  $type = $this->lng->txt("assJavaApplet");
489  break;
491  $type = $this->lng->txt("assMatchingQuestion");
492  break;
494  $type = $this->lng->txt("assMultipleChoice");
495  break;
497  $type = $this->lng->txt("assSingleChoice");
498  break;
500  $type = $this->lng->txt("assOrderingQuestion");
501  break;
503  $type = $this->lng->txt("assTextQuestion");
504  break;
506  $type = $this->lng->txt("assNumeric");
507  break;
509  $type = $this->lng->txt("assTextSubset");
510  break;
511  default:
512  $type = $this->lng->txt($item["type"]);
513  break;
514  }
515 
516  if (strcmp($type, "-" . $item["type"] . "-") == 0)
517  {
518  global $ilPluginAdmin;
519  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "TestQuestionPool", "qst");
520  foreach ($pl_names as $pl_name)
521  {
522  $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "TestQuestionPool", "qst", $pl_name);
523  if (strcmp($pl->getQuestionType(), $item["type"]) == 0)
524  {
525  $type = $pl->getQuestionTypeTranslation();
526  }
527  }
528  }
529  $this->tpl->setVariable("QUESTION_TYPE", $type);
530  $this->tpl->parseCurrentBlock();
531  }
532 
533  $this->tpl->setCurrentBlock("import_qpl");
534  if (is_file($xml_file))
535  {
536  // read file into a string
537  $fh = @fopen($xml_file, "r") or die("");
538  $xml = @fread($fh, filesize($xml_file));
539  @fclose($fh);
540  if (preg_match("/<ContentObject.*?MetaData.*?General.*?Title[^>]*?>([^<]*?)</", $xml, $matches))
541  {
542  $this->tpl->setVariable("VALUE_NEW_QUESTIONPOOL", $matches[1]);
543  }
544  }
545  $this->tpl->setVariable("TEXT_CREATE_NEW_QUESTIONPOOL", $this->lng->txt("qpl_import_create_new_qpl"));
546  $this->tpl->parseCurrentBlock();
547 
548  $this->tpl->setCurrentBlock("adm_content");
549  $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
550  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
551  $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("qpl_import_verify_found_questions"));
552  if ($questions_only)
553  {
554  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_questions_into_qpl"));
555  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
556  }
557  else
558  {
559  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_qpl"));
560 
561  $this->ctrl->setParameter($this, "new_type", $this->type);
562  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
563 
564  //$this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".$_GET["ref_id"]."&new_type=".$this->type));
565  }
566  $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.png"));
567  $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
568  $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
569  $value_questions_only = 0;
570  if ($questions_only) $value_questions_only = 1;
571  $this->tpl->setVariable("VALUE_QUESTIONS_ONLY", $value_questions_only);
572 
573  $this->tpl->parseCurrentBlock();
574 
575  return true;
576  }
577 
582  {
583  if ($_POST["questions_only"] == 1)
584  {
585  $newObj =& $this->object;
586  }
587  else
588  {
589  include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
590  // create new questionpool object
591  $newObj = new ilObjQuestionPool(0, true);
592  // set type of questionpool object
593  $newObj->setType($_GET["new_type"]);
594  // set title of questionpool object to "dummy"
595  $newObj->setTitle("dummy");
596  // set description of questionpool object
597  $newObj->setDescription("questionpool import");
598  // create the questionpool class in the ILIAS database (object_data table)
599  $newObj->create(true);
600  // create a reference for the questionpool object in the ILIAS database (object_reference table)
601  $newObj->createReference();
602  // put the questionpool object in the administration tree
603  $newObj->putInTree($_GET["ref_id"]);
604  // get default permissions and set the permissions for the questionpool object
605  $newObj->setPermissions($_GET["ref_id"]);
606  // notify the questionpool object and all its parent objects that a "new" object was created
607  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
608  }
609 
610  // start parsing of QTI files
611  include_once "./Services/QTI/classes/class.ilQTIParser.php";
612  $qtiParser = new ilQTIParser($_SESSION["qpl_import_qti_file"], IL_MO_PARSE_QTI, $newObj->getId(), $_POST["ident"]);
613  $result = $qtiParser->startParsing();
614 
615  // import page data
616  if (strlen($_SESSION["qpl_import_xml_file"]))
617  {
618  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
619  $contParser = new ilContObjParser($newObj, $_SESSION["qpl_import_xml_file"], $_SESSION["qpl_import_subdir"]);
620  $contParser->setQuestionMapping($qtiParser->getImportMapping());
621  $contParser->startParsing();
622  }
623 
624  // set another question pool name (if possible)
625  $qpl_name = $_POST["qpl_new"];
626  if ((strcmp($qpl_name, $newObj->getTitle()) != 0) && (strlen($qpl_name) > 0))
627  {
628  $newObj->setTitle($qpl_name);
629  $newObj->update();
630  }
631 
632  // delete import directory
633  include_once "./Services/Utilities/classes/class.ilUtil.php";
635 
636  if ($_POST["questions_only"] == 1)
637  {
638  $this->ctrl->redirect($this, "questions");
639  }
640  else
641  {
642  ilUtil::sendSuccess($this->lng->txt("object_imported"),true);
643  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
644  "&baseClass=ilObjQuestionPoolGUI");
645  }
646  }
647 
649  {
650  if ($_POST["questions_only"] == 1)
651  {
652  $this->ctrl->redirect($this, "questions");
653  }
654  else
655  {
656  $this->ctrl->redirect($this, "cancel");
657  }
658  }
659 
663  function uploadObject()
664  {
665  $upload_valid = true;
666  $form = $this->getImportQuestionsForm();
667  if($form->checkInput())
668  {
669  if(!$this->uploadQplObject(true))
670  {
671  $form->setValuesByPost();
672  $this->importQuestionsObject($form);
673  }
674  }
675  else
676  {
677  $form->setValuesByPost();
678  $this->importQuestionsObject($form);
679  }
680  }
681 
685  public function importQuestionsObject(ilPropertyFormGUI $form = null)
686  {
687  if(!$form instanceof ilPropertyFormGUI)
688  {
689  $form = $this->getImportQuestionsForm();
690  }
691 
692  $this->tpl->setContent($form->getHtml());
693  }
694 
698  protected function getImportQuestionsForm()
699  {
700  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
701  $form = new ilPropertyFormGUI();
702  $form->setTitle($this->lng->txt('import_question'));
703  $form->setFormAction($this->ctrl->getFormAction($this, 'upload'));
704 
705  $file = new ilFileInputGUI($this->lng->txt('select_file'), 'xmldoc');
706  $file->setRequired(true);
707  $form->addItem($file);
708 
709  $form->addCommandButton('upload', $this->lng->txt('upload'));
710  $form->addCommandButton('questions', $this->lng->txt('cancel'));
711 
712  return $form;
713  }
714 
719  {
721  {
722  $addContEditMode = $_POST['add_quest_cont_edit_mode'];
723  }
724  else
725  {
727  }
728 
729  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
730  $q_gui =& assQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
731  $this->object->addQuestionChangeListeners($q_gui->object);
732  $q_gui->object->setObjId($this->object->getId());
733  $q_gui->object->setAdditionalContentEditingMode($addContEditMode);
734  $q_gui->object->createNewQuestion();
735  $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $q_gui->object->getId());
736  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_POST["sel_question_types"]);
737  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
738  }
739 
744  {
745  if( !$_REQUEST['q_id'] )
746  {
747  require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
749  {
750  $addContEditMode = $_REQUEST['add_quest_cont_edit_mode'];
751  }
752  else
753  {
755  }
756 
757  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
758  $q_gui =& assQuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
759  $q_gui->object->setObjId($this->object->getId());
760  $q_gui->object->setAdditionalContentEditingMode($addContEditMode);
761  $q_gui->object->createNewQuestion();
762 
763  $class = get_class($q_gui);
764  $qId = $q_gui->object->getId();
765  }
766  else
767  {
768  $class = $_GET["sel_question_types"] . 'gui';
769  $qId = $_REQUEST['q_id'];
770  }
771 
772  $this->ctrl->setParameterByClass($class, "q_id", $qId);
773  $this->ctrl->setParameterByClass($class, "sel_question_types", $_REQUEST["sel_question_types"]);
774  $this->ctrl->setParameterByClass($class, "prev_qid", $_REQUEST["prev_qid"]);
775 
776  $this->ctrl->redirectByClass($class, "editQuestion");
777  }
778 
783  function afterSave(ilObject $a_new_object)
784  {
785  // always send a message
786  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
787 
788  ilUtil::redirect("ilias.php?ref_id=".$a_new_object->getRefId().
789  "&baseClass=ilObjQuestionPoolGUI");
790  }
791 
795  function assessmentObject()
796  {
797  $this->tpl->addBlockFile("CONTENT", "content", "tpl.il_as_qpl_content.html", "Modules/TestQuestionPool");
798  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
799 
800  // catch feedback message
802 
803  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
804  $question_title = assQuestion::_getTitle($_GET["q_id"]);
805  $title = $this->lng->txt("statistics") . " - $question_title";
806  if (!empty($title))
807  {
808  $this->tpl->setVariable("HEADER", $title);
809  }
810  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
811  $total_of_answers = assQuestion::_getTotalAnswers($_GET["q_id"]);
812  $counter = 0;
813  $color_class = array("tblrow1", "tblrow2");
814  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_assessment_of_questions.html", "Modules/TestQuestionPool");
815  if (!$total_of_answers)
816  {
817  $this->tpl->setCurrentBlock("emptyrow");
818  $this->tpl->setVariable("TXT_NO_ASSESSMENT", $this->lng->txt("qpl_assessment_no_assessment_of_questions"));
819  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
820  $this->tpl->parseCurrentBlock();
821  }
822  else
823  {
824  $this->tpl->setCurrentBlock("row");
825  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_answers"));
826  $this->tpl->setVariable("TXT_VALUE", $total_of_answers);
827  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
828  $counter++;
829  $this->tpl->parseCurrentBlock();
830  $this->tpl->setCurrentBlock("row");
831  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_right_answers"));
832  $this->tpl->setVariable("TXT_VALUE", sprintf("%2.2f", assQuestion::_getTotalRightAnswers($_GET["edit"]) * 100.0) . " %");
833  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
834  $this->tpl->parseCurrentBlock();
835  }
836  $this->tpl->setCurrentBlock("adm_content");
837  $this->tpl->setVariable("TXT_QUESTION_TITLE", $question_title);
838  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("result"));
839  $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
840  $this->tpl->parseCurrentBlock();
841  }
842 
843  function questionObject()
844  {
845 //echo "<br>ilObjQuestionPoolGUI->questionObject()";
846  $type = $_GET["sel_question_types"];
847  $this->editQuestionForm($type);
848  }
849 
854  {
855  global $rbacsystem;
856 
857  if (count($_POST["q_id"]) < 1)
858  {
859  ilUtil::sendInfo($this->lng->txt("qpl_delete_select_none"), true);
860  $this->ctrl->redirect($this, "questions");
861  }
862 
863  ilUtil::sendQuestion($this->lng->txt("qpl_confirm_delete_questions"));
864  $deleteable_questions =& $this->object->getDeleteableQuestionDetails($_POST["q_id"]);
865  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
866  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', (($rbacsystem->checkAccess('write', $_GET['ref_id']) ? true : false)), true);
867  $table_gui->setEditable($rbacsystem->checkAccess('write', $_GET['ref_id']));
868  $table_gui->setData($deleteable_questions);
869  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
870  }
871 
872 
877  {
878  // delete questions after confirmation
879  foreach ($_POST["q_id"] as $key => $value)
880  {
881  $this->object->deleteQuestion($value);
882  $this->object->cleanupClipboard($value);
883  }
884  if (count($_POST["q_id"])) ilUtil::sendSuccess($this->lng->txt("qpl_questions_deleted"), true);
885 
886  $this->ctrl->setParameter($this, 'q_id', '');
887 
888  $this->ctrl->redirect($this, "questions");
889  }
890 
895  {
896  $this->ctrl->redirect($this, "questions");
897  }
898 
903  {
904  // export button was pressed
905  if (count($_POST["q_id"]) > 0)
906  {
907  include_once("./Modules/TestQuestionPool/classes/class.ilQuestionpoolExport.php");
908  $qpl_exp = new ilQuestionpoolExport($this->object, "xml", $_POST["q_id"]);
909  $export_file = $qpl_exp->buildExportFile();
910  $filename = $export_file;
911  $filename = preg_replace("/.*\//", "", $filename);
912  include_once "./Services/Utilities/classes/class.ilUtil.php";
913  ilUtil::deliverFile($export_file, $filename);
914  exit();
915  }
916  else
917  {
918  ilUtil::sendInfo($this->lng->txt("qpl_export_select_none"), true);
919  }
920  $this->ctrl->redirect($this, "questions");
921  }
922 
924  {
925  require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
926  $taxIds = ilObjTaxonomy::getUsageOfObject($this->object->getId());
927 
928  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
929  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', false, false, $taxIds);
930  $table_gui->resetOffset();
931  $table_gui->writeFilterToSession();
932  $this->questionsObject();
933  }
934 
936  {
937  require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
938  $taxIds = ilObjTaxonomy::getUsageOfObject($this->object->getId());
939 
940  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
941  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', false, false, $taxIds);
942  $table_gui->resetOffset();
943  $table_gui->resetFilter();
944  $this->questionsObject();
945  }
946 
950  function questionsObject()
951  {
952  global $rbacsystem, $ilUser, $ilCtrl, $ilDB, $lng, $ilPluginAdmin;
953 
954  if(get_class($this->object) == "ilObjTest")
955  {
956  if ($_GET["calling_test"] > 0)
957  {
958  $ref_id = $_GET["calling_test"];
959  $q_id = $_GET["q_id"];
960 
961  if ($_REQUEST['test_express_mode']) {
962  if ($q_id)
963  ilUtil::redirect("ilias.php?ref_id=".$ref_id."&q_id=".$q_id."&test_express_mode=1&cmd=showPage&cmdClass=iltestexpresspageobjectgui&baseClass=ilObjTestGUI");
964  else
965  ilUtil::redirect("ilias.php?ref_id=".$ref_id."&test_express_mode=1&cmd=showPage&cmdClass=iltestexpresspageobjectgui&baseClass=ilObjTestGUI");
966  }
967  else
968  ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&ref_id=".$ref_id."&cmd=questions");
969 
970  }
971  }
972 
973  $this->object->purgeQuestions();
974  // reset test_id SESSION variable
975  $_SESSION["test_id"] = "";
976 
977  require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
978  $taxIds = ilObjTaxonomy::getUsageOfObject($this->object->getId());
979 
980  $table_gui = $this->buildQuestionBrowserTableGUI($taxIds);
981 
982  if( $rbacsystem->checkAccess('write', $_GET['ref_id']) )
983  {
984  $toolbar = new ilToolbarGUI();
985 
986  $toolbar->addButton(
987  $this->lng->txt("ass_create_question"),
988  $this->ctrl->getLinkTarget($this, 'createQuestionForm')
989  );
990 
991  $this->tpl->setContent(
992  $this->ctrl->getHTML($toolbar) . $this->ctrl->getHTML($table_gui)
993  );
994  }
995  else
996  {
997  $this->tpl->setContent( $this->ctrl->getHTML($table_gui) );
998  }
999 
1000  if( $this->object->getShowTaxonomies() )
1001  {
1002  $this->lng->loadLanguageModule('tax');
1003 
1004  require_once 'Services/Taxonomy/classes/class.ilTaxonomyExplorerGUI.php';
1005 
1006  foreach($taxIds as $taxId)
1007  {
1008  if( $taxId != $this->object->getNavTaxonomyId() )
1009  {
1010  continue;
1011  }
1012 
1013  $taxExp = new ilTaxonomyExplorerGUI(
1014  $this, 'showNavTaxonomy', $taxId, 'ilobjquestionpoolgui', 'questions'
1015  );
1016 
1017  if( !$taxExp->handleCommand() )
1018  {
1019  $this->tpl->setLeftContent($taxExp->getHTML()."&nbsp;");
1020  }
1021 
1022  break;
1023  }
1024  }
1025  }
1026 
1027  private function createQuestionFormObject()
1028  {
1029  $form = $this->buildCreateQuestionForm();
1030 
1031  $this->tpl->setContent( $this->ctrl->getHTML($form) );
1032  }
1033 
1034  private function buildCreateQuestionForm()
1035  {
1036  global $ilUser;
1037 
1038  // form
1039 
1040  require_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1041  $form = new ilPropertyFormGUI();
1042  $form->setTitle($this->lng->txt('ass_create_question'));
1043  $form->setFormAction($this->ctrl->getFormAction($this));
1044 
1045  // question type
1046 
1047  $options = array();
1048  foreach( $this->object->getQuestionTypes(false, true) as $translation => $data )
1049  {
1050  $options[$data['type_tag']] = $translation;
1051  }
1052 
1053  require_once("Services/Form/classes/class.ilSelectInputGUI.php");
1054  $si = new ilSelectInputGUI($this->lng->txt('question_type'), 'sel_question_types');
1055  $si->setOptions($options);
1056  //$si->setValue($ilUser->getPref("tst_lastquestiontype"));
1057 
1058  $form->addItem($si);
1059 
1060  // content editing mode
1061 
1063  {
1064  $ri = new ilRadioGroupInputGUI($this->lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
1065 
1066  $ri->addOption(new ilRadioOption(
1067  $this->lng->txt('tst_add_quest_cont_edit_mode_default'),
1069  ));
1070 
1071  $ri->addOption(new ilRadioOption(
1072  $this->lng->txt('tst_add_quest_cont_edit_mode_page_object'),
1074  ));
1075 
1077 
1078  $form->addItem($ri, true);
1079  }
1080  else
1081  {
1082  $hi = new ilHiddenInputGUI("question_content_editing_type");
1084  $form->addItem($hi, true);
1085  }
1086 
1087  // commands
1088 
1089  $form->addCommandButton('createQuestion', $this->lng->txt('create'));
1090  $form->addCommandButton('questions', $this->lng->txt('cancel'));
1091 
1092  return $form;
1093  }
1094 
1098  public function printObject()
1099  {
1103  global $ilToolbar;
1104 
1105  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'print'));
1106  require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
1107  $mode = new ilSelectInputGUI($this->lng->txt('output_mode'), 'output');
1108  $mode->setOptions(array(
1109  'overview' => $this->lng->txt('overview'),
1110  'detailed' => $this->lng->txt('detailed_output_solutions'),
1111  'detailed_printview' => $this->lng->txt('detailed_output_printview')
1112  ));
1113  $mode->setValue(ilUtil::stripSlashes($_POST['output']));
1114 
1115  $ilToolbar->setFormName('printviewOptions');
1116  $ilToolbar->addInputItem($mode, true);
1117  $ilToolbar->addFormButton($this->lng->txt('submit'), 'print');
1118 
1119  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionPoolPrintViewTableGUI.php";
1120  $table_gui = new ilQuestionPoolPrintViewTableGUI($this, 'print', $_POST['output']);
1121  $data = $this->object->getPrintviewQuestions();
1122  $table_gui->setData($data);
1123  $this->tpl->setContent($table_gui->getHTML());
1124  }
1125 
1126  function updateObject()
1127  {
1128 // $this->update = $this->object->updateMetaData();
1129  $this->update = $this->object->update();
1130  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1131  }
1132 
1136  function pasteObject()
1137  {
1138  if (array_key_exists("qpl_clipboard", $_SESSION))
1139  {
1140  if($this->object->pasteFromClipboard())
1141  {
1142  ilUtil::sendSuccess($this->lng->txt("qpl_paste_success"), true);
1143  }
1144  else
1145  {
1146  ilUtil::sendFailure($this->lng->txt("qpl_paste_error"), true);
1147  }
1148  }
1149  else
1150  {
1151  ilUtil::sendInfo($this->lng->txt("qpl_paste_no_objects"), true);
1152  }
1153  $this->ctrl->redirect($this, "questions");
1154  }
1155 
1159  public function copyObject()
1160  {
1161  if (count($_POST["q_id"]) > 0)
1162  {
1163  foreach ($_POST["q_id"] as $key => $value)
1164  {
1165  $this->object->copyToClipboard($value);
1166  }
1167  ilUtil::sendInfo($this->lng->txt("qpl_copy_insert_clipboard"), true);
1168  }
1169  else
1170  {
1171  ilUtil::sendInfo($this->lng->txt("qpl_copy_select_none"), true);
1172  }
1173  $this->ctrl->redirect($this, "questions");
1174  }
1175 
1179  function moveObject()
1180  {
1181  if (count($_POST["q_id"]) > 0)
1182  {
1183  foreach ($_POST["q_id"] as $key => $value)
1184  {
1185  $this->object->moveToClipboard($value);
1186  }
1187  ilUtil::sendInfo($this->lng->txt("qpl_move_insert_clipboard"), true);
1188  }
1189  else
1190  {
1191  ilUtil::sendInfo($this->lng->txt("qpl_move_select_none"), true);
1192  }
1193  $this->ctrl->redirect($this, "questions");
1194  }
1195 
1199  function createExportQTI()
1200  {
1201  global $rbacsystem;
1202  if ($rbacsystem->checkAccess("write", $_GET['ref_id']))
1203  {
1204  include_once("./Modules/TestQuestionPool/classes/class.ilQuestionpoolExport.php");
1205  $question_ids =& $this->object->getAllQuestionIds();
1206  $qpl_exp = new ilQuestionpoolExport($this->object, 'xml', $question_ids);
1207  $qpl_exp->buildExportFile();
1208  $this->ctrl->redirectByClass("ilexportgui", "");
1209  }
1210  }
1211 
1213  {
1214  global $rbacsystem;
1215  if ($rbacsystem->checkAccess("write", $_GET['ref_id']))
1216  {
1217  include_once("./Modules/TestQuestionPool/classes/class.ilQuestionpoolExport.php");
1218  $question_ids =& $this->object->getAllQuestionIds();
1219  $qpl_exp = new ilQuestionpoolExport($this->object, 'xls', $question_ids);
1220  $qpl_exp->buildExportFile();
1221  $this->ctrl->redirectByClass("ilexportgui", "");
1222  }
1223  }
1224 
1229  {
1230  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1231  $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1232  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
1233  }
1234 
1235  protected function initImportForm($a_new_type)
1236  {
1237  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1238  $form = new ilPropertyFormGUI();
1239  $form->setTarget("_top");
1240  $form->setFormAction($this->ctrl->getFormAction($this));
1241  $form->setTitle($this->lng->txt("import_qpl"));
1242 
1243  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
1244  $fi = new ilFileInputGUI($this->lng->txt("import_file"), "xmldoc");
1245  $fi->setSuffixes(array("zip"));
1246  $fi->setRequired(true);
1247  $form->addItem($fi);
1248 
1249  $form->addCommandButton("importFile", $this->lng->txt("import"));
1250  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
1251 
1252  return $form;
1253  }
1254 
1258  function importFileObject()
1259  {
1260  $form = $this->initImportForm($_REQUEST["new_type"]);
1261  if($form->checkInput())
1262  {
1263  $this->uploadQplObject();
1264  }
1265 
1266  // display form to correct errors
1267  $this->tpl->setContent($form->getHTML());
1268  }
1269 
1270  function addLocatorItems()
1271  {
1272  global $ilLocator;
1273  switch ($this->ctrl->getCmd())
1274  {
1275  case "create":
1276  case "importFile":
1277  case "cancel":
1278  break;
1279  default:
1280  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
1281  break;
1282  }
1283  if ($_GET["q_id"] > 0)
1284  {
1285  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1286  $q_gui = assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1287  if($q_gui->object instanceof assQuestion)
1288  {
1289  $q_gui->object->setObjId($this->object->getId());
1290  $title = $q_gui->object->getTitle();
1291  if(!$title)
1292  {
1293  $title = $this->lng->txt('new').': '.assQuestion::_getQuestionTypeName($q_gui->object->getQuestionType());
1294  }
1295  $ilLocator->addItem($title, $this->ctrl->getLinkTargetByClass(get_class($q_gui), "editQuestion"));
1296  }
1297  else
1298  {
1299  // Workaround for context issues: If no object was found, redirect without q_id parameter
1300  $this->ctrl->setParameter($this, 'q_id', '');
1301  $this->ctrl->redirect($this);
1302  }
1303  }
1304  }
1305 
1310  {
1312  if ($_GET["q_id"] > 0)
1313  {
1314  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1315  $q_gui = assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1316  if($q_gui->object instanceof assQuestion)
1317  {
1318  $q_gui->object->setObjId($this->object->getId());
1319  $title = $q_gui->object->getTitle();
1320  if (strcmp($this->ctrl->getCmd(), "assessment") == 0)
1321  {
1322  $title .= " - " . $this->lng->txt("statistics");
1323  }
1324  if(!$title)
1325  {
1326  $title = $this->lng->txt('new').': '.assQuestion::_getQuestionTypeName($q_gui->object->getQuestionType());
1327  }
1328  $this->tpl->setTitle($title);
1329  $this->tpl->setDescription($q_gui->object->getComment());
1330  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.png"), $this->lng->txt("obj_qpl"));
1331  }
1332  else
1333  {
1334  // Workaround for context issues: If no object was found, redirect without q_id parameter
1335  $this->ctrl->setParameter($this, 'q_id', '');
1336  $this->ctrl->redirect($this);
1337  }
1338  }
1339  else
1340  {
1341  $this->tpl->setTitle($this->object->getTitle());
1342  $this->tpl->setDescription($this->object->getLongDescription());
1343  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.png"), $this->lng->txt("obj_qpl"));
1344  }
1345  }
1346 
1352  function getTabs(&$tabs_gui)
1353  {
1354  global $ilAccess, $ilHelp;
1355 
1356  $currentUserHasWriteAccess = $ilAccess->checkAccess("write", "", $this->object->getRefId());
1357 
1358  $ilHelp->setScreenIdComponent("qpl");
1359 
1360  $next_class = strtolower($this->ctrl->getNextClass());
1361  switch ($next_class)
1362  {
1363  case "":
1364  case "ilpermissiongui":
1365  case "ilmdeditorgui":
1366  case "ilexportgui":
1367  break;
1368 
1369  case 'ilobjtaxonomygui':
1370  case 'ilobjquestionpoolsettingsgeneralgui':
1371 
1372  if( $currentUserHasWriteAccess )
1373  {
1374  $this->addSettingsSubTabs($tabs_gui);
1375  }
1376 
1377  break;
1378 
1379  default:
1380  return;
1381  break;
1382  }
1383  // questions
1384  $force_active = false;
1385  $commands = $_POST["cmd"];
1386  if (is_array($commands))
1387  {
1388  foreach ($commands as $key => $value)
1389  {
1390  if (preg_match("/^delete_.*/", $key, $matches) ||
1391  preg_match("/^addSelectGap_.*/", $key, $matches) ||
1392  preg_match("/^addTextGap_.*/", $key, $matches) ||
1393  preg_match("/^deleteImage_.*/", $key, $matches) ||
1394  preg_match("/^upload_.*/", $key, $matches) ||
1395  preg_match("/^addSuggestedSolution_.*/", $key, $matches)
1396  )
1397  {
1398  $force_active = true;
1399  }
1400  }
1401  }
1402  if (array_key_exists("imagemap_x", $_POST))
1403  {
1404  $force_active = true;
1405  }
1406  if (!$force_active)
1407  {
1408  $force_active = ((strtolower($this->ctrl->getCmdClass()) == strtolower(get_class($this)) || strlen($this->ctrl->getCmdClass()) == 0) &&
1409  $this->ctrl->getCmd() == "")
1410  ? true
1411  : false;
1412  }
1413  $tabs_gui->addTarget("assQuestions",
1414  $this->ctrl->getLinkTarget($this, "questions"),
1415  array("questions", "filter", "resetFilter", "createQuestion",
1416  "importQuestions", "deleteQuestions", "filterQuestionBrowser",
1417  "view", "preview", "editQuestion", "exec_pg",
1418  "addItem", "upload", "save", "cancel", "addSuggestedSolution",
1419  "cancelExplorer", "linkChilds", "removeSuggestedSolution",
1420  "add", "addYesNo", "addTrueFalse", "createGaps", "saveEdit",
1421  "setMediaMode", "uploadingImage", "uploadingImagemap", "addArea",
1422  "deletearea", "saveShape", "back", "addPair", "uploadingJavaapplet",
1423  "addParameter", "assessment", "addGIT", "addST", "addPG", "delete",
1424  "toggleGraphicalAnswers", "deleteAnswer", "deleteImage", "removeJavaapplet"),
1425  "", "", $force_active);
1426 
1427  if ($ilAccess->checkAccess("visible", "", $this->ref_id))
1428  {
1429  $tabs_gui->addTarget("info_short",
1430  $this->ctrl->getLinkTarget($this, "infoScreen"),
1431  array("infoScreen", "showSummary"));
1432  }
1433 
1434  if ($ilAccess->checkAccess("write", "", $_GET['ref_id']))
1435  {
1436  // properties
1437  $tabs_gui->addTarget(
1438  'settings', $this->ctrl->getLinkTargetByClass('ilObjQuestionPoolSettingsGeneralGUI'),
1439  array(), array('ilObjQuestionPoolSettingsGeneralGUI', 'ilObjTaxonomyGUI')
1440  );
1441  }
1442 
1443  // print view
1444  $tabs_gui->addTarget("print_view",
1445  $this->ctrl->getLinkTarget($this,'print'),
1446  array("print"),
1447  "", "");
1448 
1449  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1450  {
1451  // meta data
1452  $tabs_gui->addTarget("meta_data",
1453  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
1454  "", "ilmdeditorgui");
1455 
1456 // $tabs_gui->addTarget("export",
1457 // $this->ctrl->getLinkTarget($this,'export'),
1458 // array("export", "createExportFile", "confirmDeleteExportFile", "downloadExportFile"),
1459 // "", "");
1460  }
1461 
1462  if( $currentUserHasWriteAccess )
1463  {
1464  $tabs_gui->addTarget("export",
1465  $this->ctrl->getLinkTargetByClass("ilexportgui", ""),
1466  "", "ilexportgui");
1467  }
1468 
1469  if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId()))
1470  {
1471  $tabs_gui->addTarget("perm_settings",
1472  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1473  }
1474  }
1475 
1476  private function addSettingsSubTabs(ilTabsGUI $tabs)
1477  {
1478  $tabs->addSubTabTarget(
1479  'qpl_settings_subtab_general',
1480  $this->ctrl->getLinkTargetByClass('ilObjQuestionPoolSettingsGeneralGUI'),
1481  '', 'ilObjQuestionPoolSettingsGeneralGUI'
1482  );
1483 
1484  $tabs->addSubTabTarget(
1485  'qpl_settings_subtab_taxonomies',
1486  $this->ctrl->getLinkTargetByClass('ilObjTaxonomyGUI', 'editAOTaxonomySettings'),
1487  '', 'ilObjTaxonomyGUI'
1488  );
1489  }
1490 
1496  function infoScreenObject()
1497  {
1498  $this->ctrl->setCmd("showSummary");
1499  $this->ctrl->setCmdClass("ilinfoscreengui");
1500  $this->infoScreenForward();
1501  }
1502 
1507  {
1508  global $ilErr, $ilAccess;
1509 
1510  if(!$ilAccess->checkAccess("visible", "", $this->ref_id))
1511  {
1512  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
1513  }
1514 
1515  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1516  $info = new ilInfoScreenGUI($this);
1517  $info->enablePrivateNotes();
1518 
1519  // standard meta data
1520  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
1521 
1522  $this->ctrl->forwardCommand($info);
1523  }
1524 
1533  function _goto($a_target)
1534  {
1535  global $ilAccess, $ilErr, $lng;
1536 
1537  if ($ilAccess->checkAccess("write", "", $a_target))
1538  {
1539  $_GET["baseClass"] = "ilObjQuestionPoolGUI";
1540  $_GET["cmd"] = "questions";
1541  $_GET["ref_id"] = $a_target;
1542  include_once("ilias.php");
1543  exit;
1544  }
1545  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1546  {
1547  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
1548  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1550  }
1551  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
1552  }
1553 
1562  private function buildQuestionBrowserTableGUI($taxIds)
1563  {
1564  global $rbacsystem, $ilDB, $lng, $ilPluginAdmin;
1565 
1566  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
1567  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', (($rbacsystem->checkAccess('write', $_GET['ref_id']) ? true : false)), false, $taxIds);
1568  $table_gui->setEditable($rbacsystem->checkAccess('write', $_GET['ref_id']));
1569 
1570  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
1571  $questionList = new ilAssQuestionList($ilDB, $lng, $ilPluginAdmin, $this->object->getId());
1572 
1573  foreach ($table_gui->getFilterItems() as $item)
1574  {
1575  if( substr($item->getPostVar(), 0, strlen('tax_')) == 'tax_' )
1576  {
1577  $v = $item->getValue();
1578 
1579  if( is_array($v) && count($v) && !(int)$v[0] )
1580  {
1581  continue;
1582  }
1583 
1584  $taxId = substr($item->getPostVar(), strlen('tax_'));
1585  $questionList->addTaxonomyFilter($taxId, $item->getValue());
1586  }
1587  elseif( $item->getValue() !== false )
1588  {
1589  $questionList->addFieldFilter($item->getPostVar(), $item->getValue());
1590  }
1591  }
1592 
1593  if( $this->object->isNavTaxonomyActive() && (int)$_GET['tax_node'] )
1594  {
1595  $questionList->addTaxonomyFilter( $this->object->getNavTaxonomyId(), array((int)$_GET['tax_node']) );
1596  }
1597 
1598  $questionList->load();
1599  $data = $questionList->getQuestionDataArray();
1600 
1601  $table_gui->setData($data);
1602 
1603  return $table_gui;
1604  }
1605 
1606 
1607 
1608 } // END class.ilObjQuestionPoolGUI
1609 ?>