ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjQuestionPoolGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
43 include_once "./classes/class.ilObjectGUI.php";
44 include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
45 include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
46 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
47 
49 {
55  {
56  global $lng, $ilCtrl, $rbacsystem;
57  $lng->loadLanguageModule("assessment");
58  $this->type = "qpl";
59  $this->ctrl =& $ilCtrl;
60  $this->ctrl->saveParameter($this, array("ref_id", "test_ref_id", "calling_test"));
61 
62  $this->ilObjectGUI("",$_GET["ref_id"], true, false);
63  }
64 
68  function executeCommand()
69  {
70  global $ilLocator, $ilAccess, $ilNavigationHistory, $tpl;
71  if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"])) && (!$ilAccess->checkAccess("visible", "", $_GET["ref_id"])))
72  {
73  global $ilias;
74  $ilias->raiseError($this->lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
75  }
76 
77  // add entry to navigation history
78  if (!$this->getCreationMode() &&
79  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
80  {
81  $ilNavigationHistory->addItem($_GET["ref_id"],
82  "ilias.php?baseClass=ilObjQuestionPoolGUI&cmd=questions&ref_id=".$_GET["ref_id"], "qpl");
83  }
84  $this->prepareOutput();
85  $cmd = $this->ctrl->getCmd("questions");
86  $next_class = $this->ctrl->getNextClass($this);
87  $this->ctrl->setReturn($this, "questions");
88  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
89  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "ta.css", "Modules/Test"), "screen");
90  if ($_GET["q_id"] < 1)
91  {
92  $q_type = ($_POST["sel_question_types"] != "")
93  ? $_POST["sel_question_types"]
94  : $_GET["sel_question_types"];
95  }
96  if ($cmd != "createQuestion" && $cmd != "createQuestionForTest"
97  && $next_class != "ilpageobjectgui")
98  {
99  if (($_GET["test_ref_id"] != "") or ($_GET["calling_test"]))
100  {
101  $ref_id = $_GET["test_ref_id"];
102  if (!$ref_id)
103  {
104  $ref_id = $_GET["calling_test"];
105  }
106  }
107  }
108  switch($next_class)
109  {
110  case 'ilmdeditorgui':
111  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
112 
113  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
114  $md_gui->addObserver($this->object,'MDUpdateListener','General');
115  $this->ctrl->forwardCommand($md_gui);
116  break;
117  case "ilpageobjectgui":
118  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
119  $this->tpl->setCurrentBlock("ContentStyle");
120  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
122  $this->tpl->parseCurrentBlock();
123 
124  // syntax style
125  $this->tpl->setCurrentBlock("SyntaxStyle");
126  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
128  $this->tpl->parseCurrentBlock();
129  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
130  $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
131  $q_gui->setQuestionTabs();
132  $q_gui->outAdditionalOutput();
133  $q_gui->object->setObjId($this->object->getId());
134  $question =& $q_gui->object;
135  $this->ctrl->saveParameter($this, "q_id");
136  include_once("./Services/COPage/classes/class.ilPageObject.php");
137  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
138  $this->lng->loadLanguageModule("content");
139  $this->ctrl->setReturnByClass("ilPageObjectGUI", "view");
140  $this->ctrl->setReturn($this, "questions");
141  //$page =& new ilPageObject("qpl", $_GET["q_id"]);
142  $page_gui =& new ilPageObjectGUI("qpl", $_GET["q_id"]);
143  $page_gui->setEditPreview(true);
144  $page_gui->setEnabledTabs(false);
145  $page_gui->setEnabledInternalLinks(false);
146  if (strlen($this->ctrl->getCmd()) == 0)
147  {
148  $this->ctrl->setCmdClass(get_class($page_gui));
149  $this->ctrl->setCmd("preview");
150  }
151  //$page_gui->setQuestionXML($question->toXML(false, false, true));
152  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(TRUE)));
153  $page_gui->setTemplateTargetVar("ADM_CONTENT");
154  $page_gui->setOutputMode("edit");
155  $page_gui->setHeader($question->getTitle());
156  $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
157  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "fullscreen"));
158  $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this));
159  $page_gui->setPresentationTitle($question->getTitle());
160  $ret =& $this->ctrl->forwardCommand($page_gui);
161  $tpl->setContent($ret);
162  break;
163 
164  case 'ilpermissiongui':
165  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
166  $perm_gui =& new ilPermissionGUI($this);
167  $ret =& $this->ctrl->forwardCommand($perm_gui);
168  break;
169 
170  case 'ilobjectcopygui':
171  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
172  $cp = new ilObjectCopyGUI($this);
173  $cp->setType('qpl');
174  $this->ctrl->forwardCommand($cp);
175  break;
176 
177  case "ilobjquestionpoolgui":
178  case "":
179  $cmd.= "Object";
180  $ret =& $this->$cmd();
181  break;
182  default:
183  $this->ctrl->setReturn($this, "questions");
184  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
185  $q_gui =& assQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
186  $q_gui->object->setObjId($this->object->getId());
187  $q_gui->setQuestionTabs();
188  $ret =& $this->ctrl->forwardCommand($q_gui);
189  break;
190  }
191 
192  if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
193  $this->getCreationMode() != true)
194  {
195  $this->tpl->show();
196  }
197  }
198 
202  function propertiesObject()
203  {
204  $save = ((strcmp($this->ctrl->getCmd(), "save") == 0)) ? true : false;
205 // $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_properties.html", "Modules/TestQuestionPool");
206 
207  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
208  $form = new ilPropertyFormGUI();
209  $form->setFormAction($this->ctrl->getFormAction($this, 'properties'));
210  $form->setTitle($this->lng->txt("properties"));
211  $form->setMultipart(false);
212 // $form->setTableWidth("100%");
213  $form->setId("properties");
214 
215  // online
216  $online = new ilCheckboxInputGUI($this->lng->txt("qpl_online_property"), "online");
217  $online->setInfo($this->lng->txt("qpl_online_property_description"));
218  $online->setChecked($this->object->getOnline());
219  $form->addItem($online);
220 
221  $form->addCommandButton("saveProperties", $this->lng->txt("save"));
222 
223  if ($save)
224  {
225  $form->checkInput();
226  }
227  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
228  }
229 
235  function cancelObject($in_rep = false)
236  {
237  ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
238  }
239 
240 
245  {
246  $qpl_online = $_POST["online"];
247  if (strlen($qpl_online) == 0) $qpl_online = "0";
248  $this->object->setOnline($qpl_online);
249  $this->object->saveToDb();
250  ilUtil::sendSuccess($this->lng->txt("saved_successfully"), true);
251  $this->ctrl->redirect($this, "properties");
252  }
253 
258  {
259  $file = explode("_", $_GET["file_id"]);
260  include_once("./Modules/File/classes/class.ilObjFile.php");
261  $fileObj =& new ilObjFile($file[count($file) - 1], false);
262  $fileObj->sendFile();
263  exit;
264  }
265 
269  function fullscreenObject()
270  {
271  include_once("./Services/COPage/classes/class.ilPageObject.php");
272  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
273  //$page =& new ilPageObject("qpl", $_GET["pg_id"]);
274  $page_gui =& new ilPageObjectGUI("qpl", $_GET["pg_id"]);
275  $page_gui->showMediaFullscreen();
276 
277  }
278 
279 
283  function filterObject()
284  {
285  $this->questionsObject();
286  }
287 
291  function resetFilterObject()
292  {
293  $_POST["filter_text"] = "";
294  $_POST["sel_filter_type"] = "";
295  $this->questionsObject();
296  }
297 
302  {
303  include_once("./Services/COPage/classes/class.ilPageObject.php");
304  $pg_obj =& new ilPageObject("qpl", $_GET["pg_id"]);
305  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
306  exit;
307  }
308 
312  function uploadQplObject($questions_only = false)
313  {
314  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
315  {
316  ilUtil::sendFailure($this->lng->txt("error_upload"));
317  $this->importObject();
318  return;
319  }
320  // create import directory
321  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
323 
324  // copy uploaded file to import directory
325  $file = pathinfo($_FILES["xmldoc"]["name"]);
326  $full_path = ilObjQuestionPool::_getImportDirectory()."/".$_FILES["xmldoc"]["name"];
327  include_once "./Services/Utilities/classes/class.ilUtil.php";
328  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
329  if (strcmp($_FILES["xmldoc"]["type"], "text/xml") == 0)
330  {
331  $qti_file = $full_path;
332  }
333  else
334  {
335  // unzip file
336  ilUtil::unzip($full_path);
337 
338  // determine filenames of xml files
339  $subdir = basename($file["basename"],".".$file["extension"]);
340  $xml_file = ilObjQuestionPool::_getImportDirectory()."/".$subdir."/".$subdir.".xml";
341  $qti_file = ilObjQuestionPool::_getImportDirectory()."/".$subdir."/". str_replace("qpl", "qti", $subdir).".xml";
342  }
343 
344  // start verification of QTI files
345  include_once "./Services/QTI/classes/class.ilQTIParser.php";
346  $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
347  $result = $qtiParser->startParsing();
348  $founditems =& $qtiParser->getFoundItems();
349  if (count($founditems) == 0)
350  {
351  // nothing found
352 
353  // delete import directory
355 
356  ilUtil::sendInfo($this->lng->txt("qpl_import_no_items"));
357  $this->importObject();
358  return;
359  }
360 
361  $complete = 0;
362  $incomplete = 0;
363  foreach ($founditems as $item)
364  {
365  if (strlen($item["type"]))
366  {
367  $complete++;
368  }
369  else
370  {
371  $incomplete++;
372  }
373  }
374 
375  if ($complete == 0)
376  {
377  // delete import directory
379 
380  ilUtil::sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
381  $this->importObject();
382  return;
383  }
384 
385  $_SESSION["qpl_import_xml_file"] = $xml_file;
386  $_SESSION["qpl_import_qti_file"] = $qti_file;
387  $_SESSION["qpl_import_subdir"] = $subdir;
388  // display of found questions
389  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_import_verification.html");
390  $row_class = array("tblrow1", "tblrow2");
391  $counter = 0;
392  foreach ($founditems as $item)
393  {
394  $this->tpl->setCurrentBlock("verification_row");
395  $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
396  $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
397  $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
398  include_once "./Services/QTI/classes/class.ilQTIItem.php";
399  switch ($item["type"])
400  {
402  $type = $this->lng->txt("assClozeTest");
403  break;
405  $type = $this->lng->txt("assImagemapQuestion");
406  break;
408  $type = $this->lng->txt("assJavaApplet");
409  break;
411  $type = $this->lng->txt("assMatchingQuestion");
412  break;
414  $type = $this->lng->txt("assMultipleChoice");
415  break;
417  $type = $this->lng->txt("assSingleChoice");
418  break;
420  $type = $this->lng->txt("assOrderingQuestion");
421  break;
423  $type = $this->lng->txt("assTextQuestion");
424  break;
426  $type = $this->lng->txt("assNumeric");
427  break;
429  $type = $this->lng->txt("assTextSubset");
430  break;
431  default:
432  $type = $this->lng->txt($item["type"]);
433  break;
434  }
435 
436  if (strcmp($type, "-" . $item["type"] . "-") == 0)
437  {
438  global $ilPluginAdmin;
439  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "TestQuestionPool", "qst");
440  foreach ($pl_names as $pl_name)
441  {
442  $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "TestQuestionPool", "qst", $pl_name);
443  if (strcmp($pl->getQuestionType(), $item["type"]) == 0)
444  {
445  $type = $pl->getQuestionTypeTranslation();
446  }
447  }
448  }
449  $this->tpl->setVariable("QUESTION_TYPE", $type);
450  $this->tpl->parseCurrentBlock();
451  }
452 
453  $this->tpl->setCurrentBlock("import_qpl");
454  if (is_file($xml_file))
455  {
456  // read file into a string
457  $fh = @fopen($xml_file, "r") or die("");
458  $xml = @fread($fh, filesize($xml_file));
459  @fclose($fh);
460  if (preg_match("/<ContentObject.*?MetaData.*?General.*?Title[^>]*?>([^<]*?)</", $xml, $matches))
461  {
462  $this->tpl->setVariable("VALUE_NEW_QUESTIONPOOL", $matches[1]);
463  }
464  }
465  $this->tpl->setVariable("TEXT_CREATE_NEW_QUESTIONPOOL", $this->lng->txt("qpl_import_create_new_qpl"));
466  $this->tpl->parseCurrentBlock();
467 
468  $this->tpl->setCurrentBlock("adm_content");
469  $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
470  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
471  $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("qpl_import_verify_found_questions"));
472  if ($questions_only)
473  {
474  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_questions_into_qpl"));
475  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
476  }
477  else
478  {
479  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_qpl"));
480 
481  $this->ctrl->setParameter($this, "new_type", $this->type);
482  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
483 
484  //$this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".$_GET["ref_id"]."&new_type=".$this->type));
485  }
486  $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.gif"));
487  $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
488  $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
489  $value_questions_only = 0;
490  if ($questions_only) $value_questions_only = 1;
491  $this->tpl->setVariable("VALUE_QUESTIONS_ONLY", $value_questions_only);
492 
493  $this->tpl->parseCurrentBlock();
494  }
495 
500  {
501  if ($_POST["questions_only"] == 1)
502  {
503  $newObj =& $this->object;
504  }
505  else
506  {
507  include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
508  // create new questionpool object
509  $newObj = new ilObjQuestionPool(0, true);
510  // set type of questionpool object
511  $newObj->setType($_GET["new_type"]);
512  // set title of questionpool object to "dummy"
513  $newObj->setTitle("dummy");
514  // set description of questionpool object
515  $newObj->setDescription("questionpool import");
516  // create the questionpool class in the ILIAS database (object_data table)
517  $newObj->create(true);
518  // create a reference for the questionpool object in the ILIAS database (object_reference table)
519  $newObj->createReference();
520  // put the questionpool object in the administration tree
521  $newObj->putInTree($_GET["ref_id"]);
522  // get default permissions and set the permissions for the questionpool object
523  $newObj->setPermissions($_GET["ref_id"]);
524  // notify the questionpool object and all its parent objects that a "new" object was created
525  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
526  }
527 
528  // start parsing of QTI files
529  include_once "./Services/QTI/classes/class.ilQTIParser.php";
530  $qtiParser = new ilQTIParser($_SESSION["qpl_import_qti_file"], IL_MO_PARSE_QTI, $newObj->getId(), $_POST["ident"]);
531  $result = $qtiParser->startParsing();
532 
533  // import page data
534  if (strlen($_SESSION["qpl_import_xml_file"]))
535  {
536  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
537  $contParser = new ilContObjParser($newObj, $_SESSION["qpl_import_xml_file"], $_SESSION["qpl_import_subdir"]);
538  $contParser->setQuestionMapping($qtiParser->getImportMapping());
539  $contParser->startParsing();
540  }
541 
542  // set another question pool name (if possible)
543  $qpl_name = $_POST["qpl_new"];
544  if ((strcmp($qpl_name, $newObj->getTitle()) != 0) && (strlen($qpl_name) > 0))
545  {
546  $newObj->setTitle($qpl_name);
547  $newObj->update();
548  }
549 
550  // delete import directory
551  include_once "./Services/Utilities/classes/class.ilUtil.php";
553 
554  if ($_POST["questions_only"] == 1)
555  {
556  $this->ctrl->redirect($this, "questions");
557  }
558  else
559  {
560  ilUtil::sendSuccess($this->lng->txt("object_imported"),true);
561  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
562  "&baseClass=ilObjQuestionPoolGUI");
563  }
564  }
565 
567  {
568  if ($_POST["questions_only"] == 1)
569  {
570  $this->ctrl->redirect($this, "questions");
571  }
572  else
573  {
574  $this->ctrl->redirect($this, "cancel");
575  }
576  }
577 
581  function uploadObject()
582  {
583  $this->uploadQplObject(true);
584  }
585 
590  {
591  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_import_question.html", "Modules/TestQuestionPool");
592  $this->tpl->setCurrentBlock("adm_content");
593  $this->tpl->setVariable("TEXT_IMPORT_QUESTION", $this->lng->txt("import_question"));
594  $this->tpl->setVariable("TEXT_SELECT_FILE", $this->lng->txt("select_file"));
595  $this->tpl->setVariable("TEXT_UPLOAD", $this->lng->txt("upload"));
596  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
597  $this->tpl->parseCurrentBlock();
598  }
599 
605  function importObject()
606  {
607  global $rbacsystem;
608  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"]))
609  {
610  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
611  }
612  $this->getTemplateFile("import", "qpl");
613  $this->ctrl->setParameter($this, "new_type", $this->type);
614  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
615  //$this->tpl->setVariable("FORMACTION", "adm_object.php?&ref_id=".$_GET["ref_id"]."&cmd=gateway&new_type=".$this->type);
616  $this->tpl->setVariable("BTN_NAME", "uploadQpl");
617  $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("import"));
618  $this->tpl->setVariable("NEW_TYPE", $this->type);
619  $this->tpl->setVariable("TXT_IMPORT_QPL", $this->lng->txt("import_qpl"));
620  $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
621  $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
622  $this->tpl->parseCurrentBlock();
623  }
624 
629  {
630  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
631  $q_gui =& assQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
632  $q_gui->object->setObjId($this->object->getId());
633  $q_gui->object->createNewQuestion();
634  $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $q_gui->object->getId());
635  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_POST["sel_question_types"]);
636  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
637  }
638 
643  {
644  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
645  $q_gui =& assQuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
646  $q_gui->object->setObjId($this->object->getId());
647  $q_gui->object->createNewQuestion();
648  $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $q_gui->object->getId());
649  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_GET["sel_question_types"]);
650  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
651  }
652 
657  function saveObject()
658  {
659  global $rbacadmin;
660 
661  if (!strlen($_POST['Fobject']['title']))
662  {
663  ilUtil::sendFailure($this->lng->txt('title_required'), true);
664  $this->ctrl->setParameter($this, 'new_type', $_GET['new_type']);
665  $this->ctrl->redirect($this, 'create');
666  }
667 
668  // create and insert forum in objecttree
669  $newObj = parent::saveObject();
670 
671  // always send a message
672  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
673 
674  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
675  "&baseClass=ilObjQuestionPoolGUI");
676 
677 /* if (strlen($this->ctrl->getModuleDir()) == 0)
678  {
679  include_once "./Services/Utilities/classes/class.ilUtil.php";
680  ilUtil::redirect($this->getReturnLocation("save","adm_object.php?ref_id=".$_GET["ref_id"]));
681  }
682  else
683  {
684  $this->ctrl->redirect($this, "questions");
685  }*/
686  }
687 
691  function assessmentObject()
692  {
693  $this->tpl->addBlockFile("CONTENT", "content", "tpl.il_as_qpl_content.html", "Modules/TestQuestionPool");
694  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
695 
696  // catch feedback message
698 
699  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
700  $question_title = assQuestion::_getTitle($_GET["q_id"]);
701  $title = $this->lng->txt("statistics") . " - $question_title";
702  if (!empty($title))
703  {
704  $this->tpl->setVariable("HEADER", $title);
705  }
706  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
707  $total_of_answers = assQuestion::_getTotalAnswers($_GET["q_id"]);
708  $counter = 0;
709  $color_class = array("tblrow1", "tblrow2");
710  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_assessment_of_questions.html", "Modules/TestQuestionPool");
711  if (!$total_of_answers)
712  {
713  $this->tpl->setCurrentBlock("emptyrow");
714  $this->tpl->setVariable("TXT_NO_ASSESSMENT", $this->lng->txt("qpl_assessment_no_assessment_of_questions"));
715  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
716  $this->tpl->parseCurrentBlock();
717  }
718  else
719  {
720  $this->tpl->setCurrentBlock("row");
721  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_answers"));
722  $this->tpl->setVariable("TXT_VALUE", $total_of_answers);
723  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
724  $counter++;
725  $this->tpl->parseCurrentBlock();
726  $this->tpl->setCurrentBlock("row");
727  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_right_answers"));
728  $this->tpl->setVariable("TXT_VALUE", sprintf("%2.2f", assQuestion::_getTotalRightAnswers($_GET["edit"]) * 100.0) . " %");
729  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
730  $this->tpl->parseCurrentBlock();
731  }
732  $this->tpl->setCurrentBlock("adm_content");
733  $this->tpl->setVariable("TXT_QUESTION_TITLE", $question_title);
734  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("result"));
735  $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
736  $this->tpl->parseCurrentBlock();
737  }
738 
739  function questionObject()
740  {
741 //echo "<br>ilObjQuestionPoolGUI->questionObject()";
742  $type = $_GET["sel_question_types"];
743  $this->editQuestionForm($type);
744  }
745 
750  {
751  global $rbacsystem;
752 
753  if (count($_POST["q_id"]) < 1)
754  {
755  ilUtil::sendInfo($this->lng->txt("qpl_delete_select_none"), true);
756  $this->ctrl->redirect($this, "questions");
757  }
758 
759  ilUtil::sendQuestion($this->lng->txt("qpl_confirm_delete_questions"));
760  $deleteable_questions =& $this->object->getDeleteableQuestionDetails($_POST["q_id"]);
761  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
762  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', (($rbacsystem->checkAccess('write', $_GET['ref_id']) ? true : false)), true);
763  $table_gui->setEditable($rbacsystem->checkAccess('write', $_GET['ref_id']));
764  $table_gui->setData($deleteable_questions);
765  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
766  }
767 
768 
773  {
774  // delete questions after confirmation
775  foreach ($_POST["q_id"] as $key => $value)
776  {
777  $this->object->deleteQuestion($value);
778  }
779  if (count($_POST["q_id"])) ilUtil::sendSuccess($this->lng->txt("qpl_questions_deleted"), true);
780  $this->ctrl->redirect($this, "questions");
781  }
782 
787  {
788  $this->ctrl->redirect($this, "questions");
789  }
790 
795  {
796  // export button was pressed
797  if (count($_POST["q_id"]) > 0)
798  {
799  include_once("./Modules/TestQuestionPool/classes/class.ilQuestionpoolExport.php");
800  $qpl_exp = new ilQuestionpoolExport($this->object, "xml", $_POST["q_id"]);
801  $export_file = $qpl_exp->buildExportFile();
802  $filename = $export_file;
803  $filename = preg_replace("/.*\//", "", $filename);
804  include_once "./Services/Utilities/classes/class.ilUtil.php";
805  ilUtil::deliverFile($export_file, $filename);
806  exit();
807  }
808  else
809  {
810  ilUtil::sendInfo($this->lng->txt("qpl_export_select_none"), true);
811  }
812  $this->ctrl->redirect($this, "questions");
813  }
814 
816  {
817  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
818  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions');
819  $table_gui->resetOffset();
820  $table_gui->writeFilterToSession();
821  $this->questionsObject();
822  }
823 
825  {
826  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
827  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions');
828  $table_gui->resetOffset();
829  $table_gui->resetFilter();
830  $this->questionsObject();
831  }
832 
836  function questionsObject($arrFilter = null)
837  {
838  global $rbacsystem;
839  global $ilUser;
840 
841  $this->object->purgeQuestions();
842  // reset test_id SESSION variable
843  $_SESSION["test_id"] = "";
844 
845  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_questionbrowser.html", "Modules/TestQuestionPool");
846  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
847  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', (($rbacsystem->checkAccess('write', $_GET['ref_id']) ? true : false)));
848  $table_gui->setEditable($rbacsystem->checkAccess('write', $_GET['ref_id']));
849  $arrFilter = array();
850  foreach ($table_gui->getFilterItems() as $item)
851  {
852  if ($item->getValue() !== false)
853  {
854  $arrFilter[$item->getPostVar()] = $item->getValue();
855  }
856  }
857  $data = $this->object->getQuestionBrowserData($arrFilter);
858  $table_gui->setData($data);
859  $this->tpl->setVariable('TABLE', $table_gui->getHTML());
860 
861  if ($rbacsystem->checkAccess('write', $_GET['ref_id']))
862  {
863  $this->tpl->setCurrentBlock("QTypes");
864  $types =& $this->object->getQuestionTypes();
865  $lastquestiontype = $ilUser->getPref("tst_lastquestiontype");
866  foreach ($types as $translation => $data)
867  {
868  if ($data["type_tag"] == $lastquestiontype)
869  {
870  $this->tpl->setVariable("QUESTION_TYPE_SELECTED", " selected=\"selected\"");
871  }
872  $this->tpl->setVariable("QUESTION_TYPE_ID", $data["type_tag"]);
873  $this->tpl->setVariable("QUESTION_TYPE", $translation);
874  $this->tpl->parseCurrentBlock();
875  }
876  $this->tpl->setVariable("QUESTION_ADD", $this->lng->txt("create"));
877  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, 'questions'));
878  $this->tpl->parseCurrentBlock();
879  }
880  }
881 
887  function printObject()
888  {
889  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_printview.html", "Modules/TestQuestionPool");
890  switch ($_POST["output"])
891  {
892  case 'detailed':
893  $this->tpl->setVariable("SELECTED_DETAILED", " selected=\"selected\"");
894  break;
895  case 'detailed_printview':
896  $this->tpl->setVariable("SELECTED_DETAILED_PRINTVIEW", " selected=\"selected\"");
897  break;
898  default:
899  break;
900  }
901  $this->tpl->setVariable("TEXT_DETAILED", $this->lng->txt("detailed_output_solutions"));
902  $this->tpl->setVariable("TEXT_DETAILED_PRINTVIEW", $this->lng->txt("detailed_output_printview"));
903  $this->tpl->setVariable("TEXT_OVERVIEW", $this->lng->txt("overview"));
904  $this->tpl->setVariable("TEXT_SUBMIT", $this->lng->txt("submit"));
905  $this->tpl->setVariable("OUTPUT_MODE", $this->lng->txt("output_mode"));
906  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, 'print'));
907 
908  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionPoolPrintViewTableGUI.php";
909  $table_gui = new ilQuestionPoolPrintViewTableGUI($this, 'print', $_POST['output']);
910  $data =& $this->object->getPrintviewQuestions();
911  $table_gui->setData($data);
912  $this->tpl->setVariable('TABLE', $table_gui->getHTML());
913  return;
914 
915 
916  $sortorder = array(
917  "title" => $this->lng->txt("title"),
918  "description" => $this->lng->txt("description"),
919  "type" => $this->lng->txt("question_type"),
920  "author" => $this->lng->txt("author"),
921  "created" => $this->lng->txt("create_date"),
922  "updated" => $this->lng->txt("last_update")
923  );
924  foreach ($sortorder as $value => $text)
925  {
926  $this->tpl->setCurrentBlock("sortorder");
927  $this->tpl->setVariable("VALUE_SORTORDER", $value);
928  $this->tpl->setVariable("TEXT_SORTORDER", $text);
929  if (strcmp($sort, $value) == 0)
930  {
931  $this->tpl->setVariable("SELECTED_SORTORDER", " selected=\"selected\"");
932  }
933  $this->tpl->parseCurrentBlock();
934  }
935  $table =& $this->object->getPrintviewQuestions($sort);
936  $colors = array("tblrow1top", "tblrow2top");
937  $counter = 1;
938  include_once "./classes/class.ilFormat.php";
939  foreach ($table as $row)
940  {
941  if ((strcmp($_POST["output"], "detailed") == 0) || (strcmp($_POST["output"], "detailed_printview") == 0))
942  {
943  $this->tpl->setCurrentBlock("overview_row_detail");
944  $this->tpl->setVariable("ROW_CLASS", $colors[$counter % 2]);
945  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
946  $question_gui = assQuestion::_instanciateQuestionGUI($row["question_id"]);
947  if (strcmp($_POST["output"], "detailed") == 0)
948  {
949  $solutionoutput = $question_gui->getSolutionOutput($active_id = "", $pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = FALSE, $show_feedback = FALSE, $show_correct_solution = true, $show_manual_scoring = false);
950  if (strlen($solutionoutput) == 0) $solutionoutput = $question_gui->getPreview();
951  $this->tpl->setVariable("PREVIEW", $solutionoutput);
952  }
953  else
954  {
955  $this->tpl->setVariable("PREVIEW", $question_gui->getPreview());
956  }
957  $this->tpl->parseCurrentBlock();
958  $this->tpl->setCurrentBlock("overview_row_detail");
959  $this->tpl->setVariable("ROW_CLASS", $colors[$counter % 2]);
960  $this->tpl->parseCurrentBlock();
961  }
962  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
963  $this->tpl->setCurrentBlock("overview_row");
964  $this->tpl->setVariable("ROW_CLASS", $colors[$counter % 2]);
965  $this->tpl->setVariable("TEXT_COUNTER", $counter);
966  $this->tpl->setVariable("TEXT_TITLE", ilUtil::prepareFormOutput($row["title"]));
967  $this->tpl->setVariable("TEXT_DESCRIPTION", ilUtil::prepareFormOutput($row["description"]));
968  $this->tpl->setVariable("TEXT_QUESTIONTYPE", assQuestion::_getQuestionTypeName($row["type_tag"]));
969  $this->tpl->setVariable("TEXT_AUTHOR", $row["author"]);
970  $this->tpl->setVariable("TEXT_CREATED", ilDatePresentation::formatDate(new ilDate($row["created"],IL_CAL_UNIX)));
971  $this->tpl->setVariable("TEXT_UPDATED", ilDatePresentation::formatDate(new ilDate($row["tstamp"],IL_CAL_UNIX)));
972  $this->tpl->parseCurrentBlock();
973  $counter++;
974  }
975  $this->tpl->setCurrentBlock("overview");
976  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
977  $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
978  $this->tpl->setVariable("TEXT_QUESTIONTYPE", $this->lng->txt("question_type"));
979  $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
980  $this->tpl->setVariable("TEXT_CREATED", $this->lng->txt("create_date"));
981  $this->tpl->setVariable("TEXT_UPDATED", $this->lng->txt("last_update"));
982  $this->tpl->parseCurrentBlock();
983  $this->tpl->setCurrentBlock("adm_content");
984  $this->tpl->setVariable("SORT_TEXT", $this->lng->txt("sort_by_this_column"));
985  $this->tpl->setVariable("TEXT_SUBMIT", $this->lng->txt("submit"));
986  $this->tpl->setVariable("PRINT", $this->lng->txt("print"));
987  $this->tpl->parseCurrentBlock();
988  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
989  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "ta.css", "Modules/Test"), "screen");
990  $this->tpl->setVariable("PAGETITLE", " - " . ilUtil::prepareFormOutput(ilObjQuestionPool::_getFullPathToQpl($this->object->getRefId()) . " > " . $this->object->getTitle()));
991  }
992 
993  function updateObject()
994  {
995 // $this->update = $this->object->updateMetaData();
996  $this->update = $this->object->update();
997  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
998  }
999 
1003  function pasteObject()
1004  {
1005  if (array_key_exists("qpl_clipboard", $_SESSION))
1006  {
1007  $this->object->pasteFromClipboard();
1008  ilUtil::sendSuccess($this->lng->txt("qpl_paste_success"), true);
1009  }
1010  else
1011  {
1012  ilUtil::sendInfo($this->lng->txt("qpl_paste_no_objects"), true);
1013  }
1014  $this->ctrl->redirect($this, "questions");
1015  }
1016 
1020  public function copyObject()
1021  {
1022  if (count($_POST["q_id"]) > 0)
1023  {
1024  foreach ($_POST["q_id"] as $key => $value)
1025  {
1026  $this->object->copyToClipboard($value);
1027  }
1028  ilUtil::sendInfo($this->lng->txt("qpl_copy_insert_clipboard"), true);
1029  }
1030  else
1031  {
1032  ilUtil::sendInfo($this->lng->txt("qpl_copy_select_none"), true);
1033  }
1034  $this->ctrl->redirect($this, "questions");
1035  }
1036 
1040  function moveObject()
1041  {
1042  if (count($_POST["q_id"]) > 0)
1043  {
1044  foreach ($_POST["q_id"] as $key => $value)
1045  {
1046  $this->object->moveToClipboard($value);
1047  }
1048  ilUtil::sendInfo($this->lng->txt("qpl_move_insert_clipboard"), true);
1049  }
1050  else
1051  {
1052  ilUtil::sendInfo($this->lng->txt("qpl_move_select_none"), true);
1053  }
1054  $this->ctrl->redirect($this, "questions");
1055  }
1056 
1057  /*
1058  * list all export files
1059  */
1060  function exportObject()
1061  {
1062  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionPoolExportTableGUI.php";
1063  $table_gui = new ilQuestionPoolExportTableGUI($this, 'export');
1064  $export_dir = $this->object->getExportDirectory();
1065  $export_files = $this->object->getExportFiles($export_dir);
1066  $data = array();
1067  foreach ($export_files as $exp_file)
1068  {
1069  $file_arr = explode("__", $exp_file);
1070  array_push($data, array('file' => $exp_file, 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => filesize($export_dir."/".$exp_file)));
1071  }
1072  $table_gui->setData($data);
1073  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
1074  }
1075 
1076 
1081  {
1082  global $rbacsystem;
1083  if ($rbacsystem->checkAccess("write", $_GET['ref_id']))
1084  {
1085  include_once("./Modules/TestQuestionPool/classes/class.ilQuestionpoolExport.php");
1086  $question_ids =& $this->object->getAllQuestionIds();
1087  $qpl_exp = new ilQuestionpoolExport($this->object, $_POST["exporttype"], $question_ids);
1088  $qpl_exp->buildExportFile();
1089  $this->ctrl->redirect($this, "export");
1090  }
1091  else
1092  {
1093  ilUtil::sendInfo("cannot_export_qpl", TRUE);
1094  $this->ctrl->redirect($this, "export");
1095  }
1096  }
1097 
1102  {
1103  if(!isset($_POST["file"]))
1104  {
1105  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
1106  $this->ctrl->redirect($this, "export");
1107  }
1108 
1109  if (count($_POST["file"]) > 1)
1110  {
1111  ilUtil::sendInfo($this->lng->txt("cont_select_max_one_item"), true);
1112  $this->ctrl->redirect($this, "export");
1113  }
1114 
1115 
1116  $export_dir = $this->object->getExportDirectory();
1117  include_once "./Services/Utilities/classes/class.ilUtil.php";
1118  ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
1119  $_POST["file"][0]);
1120  $this->ctrl->redirect($this, "export");
1121  }
1122 
1127  {
1128  if(!isset($_POST["file"]))
1129  {
1130  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
1131  $this->ctrl->redirect($this, "export");
1132  }
1133 
1134  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
1135  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionPoolExportTableGUI.php";
1136  $table_gui = new ilQuestionPoolExportTableGUI($this, 'export', true);
1137  $export_dir = $this->object->getExportDirectory();
1138  $data = array();
1139  foreach ($_POST['file'] as $exp_file)
1140  {
1141  $file_arr = explode("__", $exp_file);
1142  array_push($data, array('file' => $exp_file, 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => filesize($export_dir."/".$exp_file)));
1143  }
1144  $table_gui->setData($data);
1145  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
1146  }
1147 
1148 
1153  {
1154  session_unregister("ilExportFiles");
1155  $this->ctrl->redirect($this, "export");
1156  }
1157 
1162  {
1163  include_once "./Services/Utilities/classes/class.ilUtil.php";
1164  $export_dir = $this->object->getExportDirectory();
1165  foreach($_POST['file'] as $file)
1166  {
1167  $exp_file = $export_dir."/".$file;
1168  include_once "./Services/Utilities/classes/class.ilStr.php";
1169  $exp_dir = $export_dir."/".ilStr::subStr($file, 0, ilStr::strLen($file) - 4);
1170  if (@is_file($exp_file))
1171  {
1172  unlink($exp_file);
1173  }
1174  if (@is_dir($exp_dir))
1175  {
1176  ilUtil::delDir($exp_dir);
1177  }
1178  }
1179  $this->ctrl->redirect($this, "export");
1180  }
1181 
1186  {
1187  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1188  $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1189  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
1190  }
1191 
1195  function createObject()
1196  {
1197  global $rbacsystem;
1198  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
1199  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
1200  {
1201  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1202  }
1203  else
1204  {
1205  $this->getTemplateFile("create", $new_type);
1206 
1207 
1208  $this->fillCloneTemplate('DUPLICATE','qpl');
1209  $this->tpl->setCurrentBlock("adm_content");
1210 
1211  // fill in saved values in case of error
1212  $data = array();
1213  $data["fields"] = array();
1214  include_once "./Services/Utilities/classes/class.ilUtil.php";
1215  $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
1216  $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
1217 
1218  foreach ($data["fields"] as $key => $val)
1219  {
1220  $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
1221  $this->tpl->setVariable(strtoupper($key), $val);
1222 
1223  if ($this->prepare_output)
1224  {
1225  $this->tpl->parseCurrentBlock();
1226  }
1227  }
1228 
1229  $this->ctrl->setParameter($this, "new_type", $this->type);
1230  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1231  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
1232  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
1233  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
1234  $this->tpl->setVariable("CMD_SUBMIT", "save");
1235  $this->tpl->setVariable("TARGET", ' target="'.
1236  ilFrameTargetInfo::_getFrame("MainContent").'" ');
1237  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
1238 
1239  $this->tpl->setVariable("TXT_IMPORT_QPL", $this->lng->txt("import_qpl"));
1240  $this->tpl->setVariable("TXT_QPL_FILE", $this->lng->txt("qpl_upload_file"));
1241  $this->tpl->setVariable("NEW_TYPE", $this->type);
1242  $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
1243 
1244  $this->tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_qpl.gif'));
1245  $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_qpl"));
1246  $this->tpl->setVariable("TYPE_IMG2", ilUtil::getImagePath('icon_qpl.gif'));
1247  $this->tpl->setVariable("ALT_IMG2",$this->lng->txt("obj_qpl"));
1248 
1249  $this->tpl->parseCurrentBlock();
1250  }
1251  }
1252 
1256  function importFileObject()
1257  {
1258  if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
1259  {
1260  ilUtil::sendInfo($this->lng->txt("qpl_select_file_for_import"));
1261  $this->createObject();
1262  return;
1263  }
1264  $this->uploadQplObject();
1265  }
1266 
1267  function addLocatorItems()
1268  {
1269  global $ilLocator;
1270  switch ($this->ctrl->getCmd())
1271  {
1272  case "create":
1273  case "importFile":
1274  case "cancel":
1275  break;
1276  default:
1277  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
1278  break;
1279  }
1280  if ($_GET["q_id"] > 0)
1281  {
1282  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1283  $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1284  $q_gui->object->setObjId($this->object->getId());
1285  if ($_GET["q_id"] > 0)
1286  {
1287  $ilLocator->addItem($q_gui->object->getTitle(), $this->ctrl->getLinkTargetByClass(get_class($q_gui), "editQuestion"));
1288  }
1289  }
1290  }
1291 
1296  {
1297  if ($_GET["q_id"] > 0)
1298  {
1299  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1300  $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1301  $q_gui->object->setObjId($this->object->getId());
1302  $title = $q_gui->object->getTitle();
1303  if (strcmp($this->ctrl->getCmd(), "assessment") == 0)
1304  {
1305  $title .= " - " . $this->lng->txt("statistics");
1306  }
1307  $this->tpl->setTitle($title);
1308  $this->tpl->setDescription($q_gui->object->getComment());
1309  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif"), $this->lng->txt("obj_qpl"));
1310  }
1311  else
1312  {
1313  $this->tpl->setTitle($this->object->getTitle());
1314  $this->tpl->setDescription($this->object->getLongDescription());
1315  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif"), $this->lng->txt("obj_qpl"));
1316  }
1317  }
1318 
1324  function getTabs(&$tabs_gui)
1325  {
1326  global $ilAccess;
1327 
1328  $next_class = $this->ctrl->getNextClass($this);
1329  switch ($next_class)
1330  {
1331  case "":
1332  case "ilpermissiongui":
1333  case "ilmdeditorgui":
1334  break;
1335  default:
1336  return;
1337  break;
1338  }
1339  // questions
1340  $force_active = false;
1341  $commands = $_POST["cmd"];
1342  if (is_array($commands))
1343  {
1344  foreach ($commands as $key => $value)
1345  {
1346  if (preg_match("/^delete_.*/", $key, $matches) ||
1347  preg_match("/^addSelectGap_.*/", $key, $matches) ||
1348  preg_match("/^addTextGap_.*/", $key, $matches) ||
1349  preg_match("/^deleteImage_.*/", $key, $matches) ||
1350  preg_match("/^upload_.*/", $key, $matches) ||
1351  preg_match("/^addSuggestedSolution_.*/", $key, $matches)
1352  )
1353  {
1354  $force_active = true;
1355  }
1356  }
1357  }
1358  if (array_key_exists("imagemap_x", $_POST))
1359  {
1360  $force_active = true;
1361  }
1362  if (!$force_active)
1363  {
1364  $force_active = ((strtolower($this->ctrl->getCmdClass()) == strtolower(get_class($this)) || strlen($this->ctrl->getCmdClass()) == 0) &&
1365  $this->ctrl->getCmd() == "")
1366  ? true
1367  : false;
1368  }
1369  $tabs_gui->addTarget("assQuestions",
1370  $this->ctrl->getLinkTarget($this, "questions"),
1371  array("questions", "filter", "resetFilter", "createQuestion",
1372  "importQuestions", "deleteQuestions", "filterQuestionBrowser",
1373  "view", "preview", "editQuestion", "exec_pg",
1374  "addItem", "upload", "save", "cancel", "addSuggestedSolution",
1375  "cancelExplorer", "linkChilds", "removeSuggestedSolution",
1376  "add", "addYesNo", "addTrueFalse", "createGaps", "saveEdit",
1377  "setMediaMode", "uploadingImage", "uploadingImagemap", "addArea",
1378  "deletearea", "saveShape", "back", "addPair", "uploadingJavaapplet",
1379  "addParameter", "assessment", "addGIT", "addST", "addPG", "delete",
1380  "toggleGraphicalAnswers", "deleteAnswer", "deleteImage", "removeJavaapplet"),
1381  "", "", $force_active);
1382 
1383  if ($ilAccess->checkAccess("write", "", $_GET['ref_id']))
1384  {
1385  // properties
1386  $tabs_gui->addTarget("settings",
1387  $this->ctrl->getLinkTarget($this,'properties'),
1388  "properties", "",
1389  "");
1390  }
1391 
1392  // print view
1393  $tabs_gui->addTarget("print_view",
1394  $this->ctrl->getLinkTarget($this,'print'),
1395  array("print"),
1396  "", "");
1397 
1398  if ($ilAccess->checkAccess("write", "", $_GET['ref_id']))
1399  {
1400  // meta data
1401  $tabs_gui->addTarget("meta_data",
1402  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
1403  "", "ilmdeditorgui");
1404 
1405  // export
1406  $tabs_gui->addTarget("export",
1407  $this->ctrl->getLinkTarget($this,'export'),
1408  array("export", "createExportFile", "confirmDeleteExportFile", "downloadExportFile"),
1409  "", "");
1410  }
1411 
1412  if ($ilAccess->checkAccess("edit_permission", "", $_GET['ref_id']))
1413  {
1414  $tabs_gui->addTarget("perm_settings",
1415  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1416  }
1417  }
1418 
1427  function _goto($a_target)
1428  {
1429  global $ilAccess, $ilErr, $lng;
1430 
1431  if ($ilAccess->checkAccess("write", "", $a_target))
1432  {
1433  $_GET["baseClass"] = "ilObjQuestionPoolGUI";
1434  $_GET["cmd"] = "questions";
1435  $_GET["ref_id"] = $a_target;
1436  include_once("ilias.php");
1437  exit;
1438  }
1439  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1440  {
1441  $_GET["cmd"] = "frameset";
1442  $_GET["target"] = "";
1443  $_GET["ref_id"] = ROOT_FOLDER_ID;
1444  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
1445  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1446  include("repository.php");
1447  exit;
1448  }
1449  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
1450  }
1451 
1452 } // END class.ilObjQuestionPoolGUI
1453 ?>