ILIAS  Release_4_0_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 /*
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  $qplSetting = new ilSetting("qpl");
222  $tablecols = new ilCustomInputGUI($this->lng->txt('qpl_browsercolumns'), 'browsercolumn');
223  $tablecols->setInfo($this->lng->txt("qpl_browsercolumns_description"));
224  $description = new ilCheckboxInputGUI($this->lng->txt("description"), "description");
225  $description->setChecked($qplSetting->get("description", 1) ? true : false);
226  $type = new ilCheckboxInputGUI($this->lng->txt("question_type"), "type");
227  $type->setChecked($qplSetting->get("type", 1) ? true : false);
228  $points = new ilCheckboxInputGUI($this->lng->txt("points"), "points");
229  $points->setChecked($qplSetting->get("points", 1) ? true : false);
230  $statistics = new ilCheckboxInputGUI($this->lng->txt("statistics"), "statistics");
231  $statistics->setChecked($qplSetting->get("statistics", 1) ? true : false);
232  $author = new ilCheckboxInputGUI($this->lng->txt("author"), "author");
233  $author->setChecked($qplSetting->get("author", 1) ? true : false);
234  $created = new ilCheckboxInputGUI($this->lng->txt("create_date"), "created");
235  $created->setChecked($qplSetting->get("created", 1) ? true : false);
236  $updated = new ilCheckboxInputGUI($this->lng->txt("last_update"), "updated");
237  $updated->setChecked($qplSetting->get("updated", 1) ? true : false);
238  $tablecols->addSubitem($description);
239  $tablecols->addSubitem($type);
240  $tablecols->addSubitem($points);
241  $tablecols->addSubitem($statistics);
242  $tablecols->addSubitem($author);
243  $tablecols->addSubitem($created);
244  $tablecols->addSubitem($updated);
245  $form->addItem($tablecols);
246 
247  $form->addCommandButton("saveProperties", $this->lng->txt("save"));
248 
249  if ($save)
250  {
251  $form->checkInput();
252  }
253  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
254  }
255 
261  function cancelObject($in_rep = false)
262  {
263  ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
264  }
265 
266 
271  {
272  $qpl_online = $_POST["online"];
273  if (strlen($qpl_online) == 0) $qpl_online = "0";
274  $this->object->setOnline($qpl_online);
275  $this->object->saveToDb();
276 
277  $qplSetting = new ilSetting("qpl");
278  $qplSetting->set('description', ($_POST["description"]) ? 1 : 0);
279  $qplSetting->set('type', ($_POST["type"]) ? 1 : 0);
280  $qplSetting->set('points', ($_POST["points"]) ? 1 : 0);
281  $qplSetting->set('statistics', ($_POST["statistics"]) ? 1 : 0);
282  $qplSetting->set('author', ($_POST["author"]) ? 1 : 0);
283  $qplSetting->set('created', ($_POST["created"]) ? 1 : 0);
284  $qplSetting->set('updated', ($_POST["updated"]) ? 1 : 0);
285  ilUtil::sendSuccess($this->lng->txt("saved_successfully"), true);
286  $this->ctrl->redirect($this, "properties");
287  }
288 
293  {
294  $file = explode("_", $_GET["file_id"]);
295  include_once("./Modules/File/classes/class.ilObjFile.php");
296  $fileObj =& new ilObjFile($file[count($file) - 1], false);
297  $fileObj->sendFile();
298  exit;
299  }
300 
304  function fullscreenObject()
305  {
306  include_once("./Services/COPage/classes/class.ilPageObject.php");
307  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
308  //$page =& new ilPageObject("qpl", $_GET["pg_id"]);
309  $page_gui =& new ilPageObjectGUI("qpl", $_GET["pg_id"]);
310  $page_gui->showMediaFullscreen();
311 
312  }
313 
314 
318  function filterObject()
319  {
320  $this->questionsObject();
321  }
322 
326  function resetFilterObject()
327  {
328  $_POST["filter_text"] = "";
329  $_POST["sel_filter_type"] = "";
330  $this->questionsObject();
331  }
332 
337  {
338  include_once("./Services/COPage/classes/class.ilPageObject.php");
339  $pg_obj =& new ilPageObject("qpl", $_GET["pg_id"]);
340  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
341  exit;
342  }
343 
347  function uploadQplObject($questions_only = false)
348  {
349  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
350  {
351  ilUtil::sendFailure($this->lng->txt("error_upload"));
352  $this->importObject();
353  return;
354  }
355  // create import directory
356  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
358 
359  // copy uploaded file to import directory
360  $file = pathinfo($_FILES["xmldoc"]["name"]);
361  $full_path = ilObjQuestionPool::_getImportDirectory()."/".$_FILES["xmldoc"]["name"];
362  include_once "./Services/Utilities/classes/class.ilUtil.php";
363  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
364  if (strcmp($_FILES["xmldoc"]["type"], "text/xml") == 0)
365  {
366  $qti_file = $full_path;
367  }
368  else
369  {
370  // unzip file
371  ilUtil::unzip($full_path);
372 
373  // determine filenames of xml files
374  $subdir = basename($file["basename"],".".$file["extension"]);
375  $xml_file = ilObjQuestionPool::_getImportDirectory()."/".$subdir."/".$subdir.".xml";
376  $qti_file = ilObjQuestionPool::_getImportDirectory()."/".$subdir."/". str_replace("qpl", "qti", $subdir).".xml";
377  }
378 
379  // start verification of QTI files
380  include_once "./Services/QTI/classes/class.ilQTIParser.php";
381  $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
382  $result = $qtiParser->startParsing();
383  $founditems =& $qtiParser->getFoundItems();
384  if (count($founditems) == 0)
385  {
386  // nothing found
387 
388  // delete import directory
390 
391  ilUtil::sendInfo($this->lng->txt("qpl_import_no_items"));
392  $this->importObject();
393  return;
394  }
395 
396  $complete = 0;
397  $incomplete = 0;
398  foreach ($founditems as $item)
399  {
400  if (strlen($item["type"]))
401  {
402  $complete++;
403  }
404  else
405  {
406  $incomplete++;
407  }
408  }
409 
410  if ($complete == 0)
411  {
412  // delete import directory
414 
415  ilUtil::sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
416  $this->importObject();
417  return;
418  }
419 
420  $_SESSION["qpl_import_xml_file"] = $xml_file;
421  $_SESSION["qpl_import_qti_file"] = $qti_file;
422  $_SESSION["qpl_import_subdir"] = $subdir;
423  // display of found questions
424  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_import_verification.html");
425  $row_class = array("tblrow1", "tblrow2");
426  $counter = 0;
427  foreach ($founditems as $item)
428  {
429  $this->tpl->setCurrentBlock("verification_row");
430  $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
431  $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
432  $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
433  include_once "./Services/QTI/classes/class.ilQTIItem.php";
434  switch ($item["type"])
435  {
437  $type = $this->lng->txt("assClozeTest");
438  break;
440  $type = $this->lng->txt("assImagemapQuestion");
441  break;
443  $type = $this->lng->txt("assJavaApplet");
444  break;
446  $type = $this->lng->txt("assMatchingQuestion");
447  break;
449  $type = $this->lng->txt("assMultipleChoice");
450  break;
452  $type = $this->lng->txt("assSingleChoice");
453  break;
455  $type = $this->lng->txt("assOrderingQuestion");
456  break;
458  $type = $this->lng->txt("assTextQuestion");
459  break;
461  $type = $this->lng->txt("assNumeric");
462  break;
464  $type = $this->lng->txt("assTextSubset");
465  break;
466  default:
467  $type = $this->lng->txt($item["type"]);
468  break;
469  }
470 
471  if (strcmp($type, "-" . $item["type"] . "-") == 0)
472  {
473  global $ilPluginAdmin;
474  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "TestQuestionPool", "qst");
475  foreach ($pl_names as $pl_name)
476  {
477  $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "TestQuestionPool", "qst", $pl_name);
478  if (strcmp($pl->getQuestionType(), $item["type"]) == 0)
479  {
480  $type = $pl->getQuestionTypeTranslation();
481  }
482  }
483  }
484  $this->tpl->setVariable("QUESTION_TYPE", $type);
485  $this->tpl->parseCurrentBlock();
486  }
487 
488  $this->tpl->setCurrentBlock("import_qpl");
489  if (is_file($xml_file))
490  {
491  // read file into a string
492  $fh = @fopen($xml_file, "r") or die("");
493  $xml = @fread($fh, filesize($xml_file));
494  @fclose($fh);
495  if (preg_match("/<ContentObject.*?MetaData.*?General.*?Title[^>]*?>([^<]*?)</", $xml, $matches))
496  {
497  $this->tpl->setVariable("VALUE_NEW_QUESTIONPOOL", $matches[1]);
498  }
499  }
500  $this->tpl->setVariable("TEXT_CREATE_NEW_QUESTIONPOOL", $this->lng->txt("qpl_import_create_new_qpl"));
501  $this->tpl->parseCurrentBlock();
502 
503  $this->tpl->setCurrentBlock("adm_content");
504  $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
505  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
506  $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("qpl_import_verify_found_questions"));
507  if ($questions_only)
508  {
509  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_questions_into_qpl"));
510  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
511  }
512  else
513  {
514  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_qpl"));
515 
516  $this->ctrl->setParameter($this, "new_type", $this->type);
517  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
518 
519  //$this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".$_GET["ref_id"]."&new_type=".$this->type));
520  }
521  $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.gif"));
522  $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
523  $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
524  $value_questions_only = 0;
525  if ($questions_only) $value_questions_only = 1;
526  $this->tpl->setVariable("VALUE_QUESTIONS_ONLY", $value_questions_only);
527 
528  $this->tpl->parseCurrentBlock();
529  }
530 
535  {
536  if ($_POST["questions_only"] == 1)
537  {
538  $newObj =& $this->object;
539  }
540  else
541  {
542  include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
543  // create new questionpool object
544  $newObj = new ilObjQuestionPool(0, true);
545  // set type of questionpool object
546  $newObj->setType($_GET["new_type"]);
547  // set title of questionpool object to "dummy"
548  $newObj->setTitle("dummy");
549  // set description of questionpool object
550  $newObj->setDescription("questionpool import");
551  // create the questionpool class in the ILIAS database (object_data table)
552  $newObj->create(true);
553  // create a reference for the questionpool object in the ILIAS database (object_reference table)
554  $newObj->createReference();
555  // put the questionpool object in the administration tree
556  $newObj->putInTree($_GET["ref_id"]);
557  // get default permissions and set the permissions for the questionpool object
558  $newObj->setPermissions($_GET["ref_id"]);
559  // notify the questionpool object and all its parent objects that a "new" object was created
560  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
561  }
562 
563  // start parsing of QTI files
564  include_once "./Services/QTI/classes/class.ilQTIParser.php";
565  $qtiParser = new ilQTIParser($_SESSION["qpl_import_qti_file"], IL_MO_PARSE_QTI, $newObj->getId(), $_POST["ident"]);
566  $result = $qtiParser->startParsing();
567 
568  // import page data
569  if (strlen($_SESSION["qpl_import_xml_file"]))
570  {
571  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
572  $contParser = new ilContObjParser($newObj, $_SESSION["qpl_import_xml_file"], $_SESSION["qpl_import_subdir"]);
573  $contParser->setQuestionMapping($qtiParser->getImportMapping());
574  $contParser->startParsing();
575  }
576 
577  // set another question pool name (if possible)
578  $qpl_name = $_POST["qpl_new"];
579  if ((strcmp($qpl_name, $newObj->getTitle()) != 0) && (strlen($qpl_name) > 0))
580  {
581  $newObj->setTitle($qpl_name);
582  $newObj->update();
583  }
584 
585  // delete import directory
586  include_once "./Services/Utilities/classes/class.ilUtil.php";
588 
589  if ($_POST["questions_only"] == 1)
590  {
591  $this->ctrl->redirect($this, "questions");
592  }
593  else
594  {
595  ilUtil::sendSuccess($this->lng->txt("object_imported"),true);
596  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
597  "&baseClass=ilObjQuestionPoolGUI");
598  }
599  }
600 
602  {
603  if ($_POST["questions_only"] == 1)
604  {
605  $this->ctrl->redirect($this, "questions");
606  }
607  else
608  {
609  $this->ctrl->redirect($this, "cancel");
610  }
611  }
612 
616  function uploadObject()
617  {
618  $this->uploadQplObject(true);
619  }
620 
625  {
626  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_import_question.html", "Modules/TestQuestionPool");
627  $this->tpl->setCurrentBlock("adm_content");
628  $this->tpl->setVariable("TEXT_IMPORT_QUESTION", $this->lng->txt("import_question"));
629  $this->tpl->setVariable("TEXT_SELECT_FILE", $this->lng->txt("select_file"));
630  $this->tpl->setVariable("TEXT_UPLOAD", $this->lng->txt("upload"));
631  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
632  $this->tpl->parseCurrentBlock();
633  }
634 
640  function importObject()
641  {
642  global $rbacsystem;
643  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"]))
644  {
645  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
646  }
647  $this->getTemplateFile("import", "qpl");
648  $this->ctrl->setParameter($this, "new_type", $this->type);
649  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
650  //$this->tpl->setVariable("FORMACTION", "adm_object.php?&ref_id=".$_GET["ref_id"]."&cmd=gateway&new_type=".$this->type);
651  $this->tpl->setVariable("BTN_NAME", "uploadQpl");
652  $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("import"));
653  $this->tpl->setVariable("NEW_TYPE", $this->type);
654  $this->tpl->setVariable("TXT_IMPORT_QPL", $this->lng->txt("import_qpl"));
655  $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
656  $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
657  $this->tpl->parseCurrentBlock();
658  }
659 
664  {
665  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
666  $q_gui =& assQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
667  $q_gui->object->setObjId($this->object->getId());
668  $q_gui->object->createNewQuestion();
669  $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $q_gui->object->getId());
670  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_POST["sel_question_types"]);
671  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
672  }
673 
678  {
679  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
680  $q_gui =& assQuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
681  $q_gui->object->setObjId($this->object->getId());
682  $q_gui->object->createNewQuestion();
683  $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $q_gui->object->getId());
684  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_GET["sel_question_types"]);
685  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
686  }
687 
692  function saveObject()
693  {
694  global $rbacadmin;
695 
696  if (!strlen($_POST['Fobject']['title']))
697  {
698  ilUtil::sendFailure($this->lng->txt('title_required'), true);
699  $this->ctrl->setParameter($this, 'new_type', $_GET['new_type']);
700  $this->ctrl->redirect($this, 'create');
701  }
702 
703  // create and insert forum in objecttree
704  $newObj = parent::saveObject();
705 
706  // always send a message
707  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
708 
709  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
710  "&baseClass=ilObjQuestionPoolGUI");
711 
712 /* if (strlen($this->ctrl->getModuleDir()) == 0)
713  {
714  include_once "./Services/Utilities/classes/class.ilUtil.php";
715  ilUtil::redirect($this->getReturnLocation("save","adm_object.php?ref_id=".$_GET["ref_id"]));
716  }
717  else
718  {
719  $this->ctrl->redirect($this, "questions");
720  }*/
721  }
722 
726  function assessmentObject()
727  {
728  $this->tpl->addBlockFile("CONTENT", "content", "tpl.il_as_qpl_content.html", "Modules/TestQuestionPool");
729  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
730 
731  // catch feedback message
733 
734  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
735  $question_title = assQuestion::_getTitle($_GET["q_id"]);
736  $title = $this->lng->txt("statistics") . " - $question_title";
737  if (!empty($title))
738  {
739  $this->tpl->setVariable("HEADER", $title);
740  }
741  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
742  $total_of_answers = assQuestion::_getTotalAnswers($_GET["q_id"]);
743  $counter = 0;
744  $color_class = array("tblrow1", "tblrow2");
745  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_assessment_of_questions.html", "Modules/TestQuestionPool");
746  if (!$total_of_answers)
747  {
748  $this->tpl->setCurrentBlock("emptyrow");
749  $this->tpl->setVariable("TXT_NO_ASSESSMENT", $this->lng->txt("qpl_assessment_no_assessment_of_questions"));
750  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
751  $this->tpl->parseCurrentBlock();
752  }
753  else
754  {
755  $this->tpl->setCurrentBlock("row");
756  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_answers"));
757  $this->tpl->setVariable("TXT_VALUE", $total_of_answers);
758  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
759  $counter++;
760  $this->tpl->parseCurrentBlock();
761  $this->tpl->setCurrentBlock("row");
762  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_right_answers"));
763  $this->tpl->setVariable("TXT_VALUE", sprintf("%2.2f", assQuestion::_getTotalRightAnswers($_GET["edit"]) * 100.0) . " %");
764  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
765  $this->tpl->parseCurrentBlock();
766  }
767  $this->tpl->setCurrentBlock("adm_content");
768  $this->tpl->setVariable("TXT_QUESTION_TITLE", $question_title);
769  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("result"));
770  $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
771  $this->tpl->parseCurrentBlock();
772  }
773 
774  function questionObject()
775  {
776 //echo "<br>ilObjQuestionPoolGUI->questionObject()";
777  $type = $_GET["sel_question_types"];
778  $this->editQuestionForm($type);
779  }
780 
785  {
786  global $rbacsystem;
787 
788  if (count($_POST["q_id"]) < 1)
789  {
790  ilUtil::sendInfo($this->lng->txt("qpl_delete_select_none"), true);
791  $this->ctrl->redirect($this, "questions");
792  }
793 
794  ilUtil::sendQuestion($this->lng->txt("qpl_confirm_delete_questions"));
795  $deleteable_questions =& $this->object->getDeleteableQuestionDetails($_POST["q_id"]);
796  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
797  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', (($rbacsystem->checkAccess('write', $this->ref_id) ? true : false)), true);
798  $table_gui->setEditable($rbacsystem->checkAccess('write', $this->ref_id));
799  $table_gui->setData($deleteable_questions);
800  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
801  }
802 
803 
808  {
809  // delete questions after confirmation
810  foreach ($_POST["q_id"] as $key => $value)
811  {
812  $this->object->deleteQuestion($value);
813  }
814  if (count($_POST["q_id"])) ilUtil::sendSuccess($this->lng->txt("qpl_questions_deleted"), true);
815  $this->ctrl->redirect($this, "questions");
816  }
817 
822  {
823  $this->ctrl->redirect($this, "questions");
824  }
825 
830  {
831  // export button was pressed
832  if (count($_POST["q_id"]) > 0)
833  {
834  include_once("./Modules/TestQuestionPool/classes/class.ilQuestionpoolExport.php");
835  $qpl_exp = new ilQuestionpoolExport($this->object, "xml", $_POST["q_id"]);
836  $export_file = $qpl_exp->buildExportFile();
837  $filename = $export_file;
838  $filename = preg_replace("/.*\//", "", $filename);
839  include_once "./Services/Utilities/classes/class.ilUtil.php";
840  ilUtil::deliverFile($export_file, $filename);
841  exit();
842  }
843  else
844  {
845  ilUtil::sendInfo($this->lng->txt("qpl_export_select_none"), true);
846  }
847  $this->ctrl->redirect($this, "questions");
848  }
849 
851  {
852  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
853  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions');
854  $table_gui->resetOffset();
855  $table_gui->writeFilterToSession();
856  $this->questionsObject();
857  }
858 
860  {
861  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
862  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions');
863  $table_gui->resetOffset();
864  $table_gui->resetFilter();
865  $this->questionsObject();
866  }
867 
871  function questionsObject($arrFilter = null)
872  {
873  global $rbacsystem;
874  global $ilUser;
875 
876  $this->object->purgeQuestions();
877  // reset test_id SESSION variable
878  $_SESSION["test_id"] = "";
879 
880  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_questionbrowser.html", "Modules/TestQuestionPool");
881  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
882  $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', (($rbacsystem->checkAccess('write', $this->ref_id) ? true : false)));
883  $table_gui->setEditable($rbacsystem->checkAccess('write', $this->ref_id));
884  $arrFilter = array();
885  foreach ($table_gui->getFilterItems() as $item)
886  {
887  if ($item->getValue() !== false)
888  {
889  $arrFilter[$item->getPostVar()] = $item->getValue();
890  }
891  }
892  $data = $this->object->getQuestionBrowserData($arrFilter);
893  $table_gui->setData($data);
894  $this->tpl->setVariable('TABLE', $table_gui->getHTML());
895 
896  $this->tpl->setCurrentBlock("QTypes");
897  $types =& $this->object->getQuestionTypes();
898  $lastquestiontype = $ilUser->getPref("tst_lastquestiontype");
899  foreach ($types as $translation => $data)
900  {
901  if ($data["type_tag"] == $lastquestiontype)
902  {
903  $this->tpl->setVariable("QUESTION_TYPE_SELECTED", " selected=\"selected\"");
904  }
905  $this->tpl->setVariable("QUESTION_TYPE_ID", $data["type_tag"]);
906  $this->tpl->setVariable("QUESTION_TYPE", $translation);
907  $this->tpl->parseCurrentBlock();
908  }
909  $this->tpl->setVariable("QUESTION_ADD", $this->lng->txt("create"));
910  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, 'questions'));
911  $this->tpl->parseCurrentBlock();
912  }
913 
919  function printObject()
920  {
921  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_printview.html", "Modules/TestQuestionPool");
922  switch ($_POST["output"])
923  {
924  case 'detailed':
925  $this->tpl->setVariable("SELECTED_DETAILED", " selected=\"selected\"");
926  break;
927  case 'detailed_printview':
928  $this->tpl->setVariable("SELECTED_DETAILED_PRINTVIEW", " selected=\"selected\"");
929  break;
930  default:
931  break;
932  }
933  $this->tpl->setVariable("TEXT_DETAILED", $this->lng->txt("detailed_output_solutions"));
934  $this->tpl->setVariable("TEXT_DETAILED_PRINTVIEW", $this->lng->txt("detailed_output_printview"));
935  $this->tpl->setVariable("TEXT_OVERVIEW", $this->lng->txt("overview"));
936  $this->tpl->setVariable("TEXT_SUBMIT", $this->lng->txt("submit"));
937  $this->tpl->setVariable("OUTPUT_MODE", $this->lng->txt("output_mode"));
938  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, 'print'));
939 
940  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionPoolPrintViewTableGUI.php";
941  $table_gui = new ilQuestionPoolPrintViewTableGUI($this, 'print', $_POST['output']);
942  $data =& $this->object->getPrintviewQuestions();
943  $table_gui->setData($data);
944  $this->tpl->setVariable('TABLE', $table_gui->getHTML());
945  return;
946 
947 
948  $sortorder = array(
949  "title" => $this->lng->txt("title"),
950  "description" => $this->lng->txt("description"),
951  "type" => $this->lng->txt("question_type"),
952  "author" => $this->lng->txt("author"),
953  "created" => $this->lng->txt("create_date"),
954  "updated" => $this->lng->txt("last_update")
955  );
956  foreach ($sortorder as $value => $text)
957  {
958  $this->tpl->setCurrentBlock("sortorder");
959  $this->tpl->setVariable("VALUE_SORTORDER", $value);
960  $this->tpl->setVariable("TEXT_SORTORDER", $text);
961  if (strcmp($sort, $value) == 0)
962  {
963  $this->tpl->setVariable("SELECTED_SORTORDER", " selected=\"selected\"");
964  }
965  $this->tpl->parseCurrentBlock();
966  }
967  $table =& $this->object->getPrintviewQuestions($sort);
968  $colors = array("tblrow1top", "tblrow2top");
969  $counter = 1;
970  include_once "./classes/class.ilFormat.php";
971  foreach ($table as $row)
972  {
973  if ((strcmp($_POST["output"], "detailed") == 0) || (strcmp($_POST["output"], "detailed_printview") == 0))
974  {
975  $this->tpl->setCurrentBlock("overview_row_detail");
976  $this->tpl->setVariable("ROW_CLASS", $colors[$counter % 2]);
977  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
978  $question_gui = assQuestion::_instanciateQuestionGUI($row["question_id"]);
979  if (strcmp($_POST["output"], "detailed") == 0)
980  {
981  $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);
982  if (strlen($solutionoutput) == 0) $solutionoutput = $question_gui->getPreview();
983  $this->tpl->setVariable("PREVIEW", $solutionoutput);
984  }
985  else
986  {
987  $this->tpl->setVariable("PREVIEW", $question_gui->getPreview());
988  }
989  $this->tpl->parseCurrentBlock();
990  $this->tpl->setCurrentBlock("overview_row_detail");
991  $this->tpl->setVariable("ROW_CLASS", $colors[$counter % 2]);
992  $this->tpl->parseCurrentBlock();
993  }
994  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
995  $this->tpl->setCurrentBlock("overview_row");
996  $this->tpl->setVariable("ROW_CLASS", $colors[$counter % 2]);
997  $this->tpl->setVariable("TEXT_COUNTER", $counter);
998  $this->tpl->setVariable("TEXT_TITLE", ilUtil::prepareFormOutput($row["title"]));
999  $this->tpl->setVariable("TEXT_DESCRIPTION", ilUtil::prepareFormOutput($row["description"]));
1000  $this->tpl->setVariable("TEXT_QUESTIONTYPE", assQuestion::_getQuestionTypeName($row["type_tag"]));
1001  $this->tpl->setVariable("TEXT_AUTHOR", $row["author"]);
1002  $this->tpl->setVariable("TEXT_CREATED", ilDatePresentation::formatDate(new ilDate($row["created"],IL_CAL_UNIX)));
1003  $this->tpl->setVariable("TEXT_UPDATED", ilDatePresentation::formatDate(new ilDate($row["tstamp"],IL_CAL_UNIX)));
1004  $this->tpl->parseCurrentBlock();
1005  $counter++;
1006  }
1007  $this->tpl->setCurrentBlock("overview");
1008  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
1009  $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
1010  $this->tpl->setVariable("TEXT_QUESTIONTYPE", $this->lng->txt("question_type"));
1011  $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
1012  $this->tpl->setVariable("TEXT_CREATED", $this->lng->txt("create_date"));
1013  $this->tpl->setVariable("TEXT_UPDATED", $this->lng->txt("last_update"));
1014  $this->tpl->parseCurrentBlock();
1015  $this->tpl->setCurrentBlock("adm_content");
1016  $this->tpl->setVariable("SORT_TEXT", $this->lng->txt("sort_by_this_column"));
1017  $this->tpl->setVariable("TEXT_SUBMIT", $this->lng->txt("submit"));
1018  $this->tpl->setVariable("PRINT", $this->lng->txt("print"));
1019  $this->tpl->parseCurrentBlock();
1020  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1021  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "ta.css", "Modules/Test"), "screen");
1022  $this->tpl->setVariable("PAGETITLE", " - " . ilUtil::prepareFormOutput(ilObjQuestionPool::_getFullPathToQpl($this->object->getRefId()) . " > " . $this->object->getTitle()));
1023  }
1024 
1025  function updateObject()
1026  {
1027 // $this->update = $this->object->updateMetaData();
1028  $this->update = $this->object->update();
1029  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1030  }
1031 
1035  function pasteObject()
1036  {
1037  if (array_key_exists("qpl_clipboard", $_SESSION))
1038  {
1039  $this->object->pasteFromClipboard();
1040  ilUtil::sendSuccess($this->lng->txt("qpl_paste_success"), true);
1041  }
1042  else
1043  {
1044  ilUtil::sendInfo($this->lng->txt("qpl_paste_no_objects"), true);
1045  }
1046  $this->ctrl->redirect($this, "questions");
1047  }
1048 
1052  public function copyObject()
1053  {
1054  if (count($_POST["q_id"]) > 0)
1055  {
1056  foreach ($_POST["q_id"] as $key => $value)
1057  {
1058  $this->object->copyToClipboard($value);
1059  }
1060  ilUtil::sendInfo($this->lng->txt("qpl_copy_insert_clipboard"), true);
1061  }
1062  else
1063  {
1064  ilUtil::sendInfo($this->lng->txt("qpl_copy_select_none"), true);
1065  }
1066  $this->ctrl->redirect($this, "questions");
1067  }
1068 
1072  function moveObject()
1073  {
1074  if (count($_POST["q_id"]) > 0)
1075  {
1076  foreach ($_POST["q_id"] as $key => $value)
1077  {
1078  $this->object->moveToClipboard($value);
1079  }
1080  ilUtil::sendInfo($this->lng->txt("qpl_move_insert_clipboard"), true);
1081  }
1082  else
1083  {
1084  ilUtil::sendInfo($this->lng->txt("qpl_move_select_none"), true);
1085  }
1086  $this->ctrl->redirect($this, "questions");
1087  }
1088 
1089  /*
1090  * list all export files
1091  */
1092  function exportObject()
1093  {
1094  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionPoolExportTableGUI.php";
1095  $table_gui = new ilQuestionPoolExportTableGUI($this, 'export');
1096  $export_dir = $this->object->getExportDirectory();
1097  $export_files = $this->object->getExportFiles($export_dir);
1098  $data = array();
1099  foreach ($export_files as $exp_file)
1100  {
1101  $file_arr = explode("__", $exp_file);
1102  array_push($data, array('file' => $exp_file, 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => filesize($export_dir."/".$exp_file)));
1103  }
1104  $table_gui->setData($data);
1105  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
1106  }
1107 
1108 
1113  {
1114  global $rbacsystem;
1115  if ($rbacsystem->checkAccess("write", $this->ref_id))
1116  {
1117  include_once("./Modules/TestQuestionPool/classes/class.ilQuestionpoolExport.php");
1118  $question_ids =& $this->object->getAllQuestionIds();
1119  $qpl_exp = new ilQuestionpoolExport($this->object, $_POST["exporttype"], $question_ids);
1120  $qpl_exp->buildExportFile();
1121  $this->ctrl->redirect($this, "export");
1122  }
1123  else
1124  {
1125  ilUtil::sendInfo("cannot_export_qpl", TRUE);
1126  $this->ctrl->redirect($this, "export");
1127  }
1128  }
1129 
1134  {
1135  if(!isset($_POST["file"]))
1136  {
1137  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
1138  $this->ctrl->redirect($this, "export");
1139  }
1140 
1141  if (count($_POST["file"]) > 1)
1142  {
1143  ilUtil::sendInfo($this->lng->txt("cont_select_max_one_item"), true);
1144  $this->ctrl->redirect($this, "export");
1145  }
1146 
1147 
1148  $export_dir = $this->object->getExportDirectory();
1149  include_once "./Services/Utilities/classes/class.ilUtil.php";
1150  ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
1151  $_POST["file"][0]);
1152  $this->ctrl->redirect($this, "export");
1153  }
1154 
1159  {
1160  if(!isset($_POST["file"]))
1161  {
1162  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
1163  $this->ctrl->redirect($this, "export");
1164  }
1165 
1166  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
1167  include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionPoolExportTableGUI.php";
1168  $table_gui = new ilQuestionPoolExportTableGUI($this, 'export', true);
1169  $export_dir = $this->object->getExportDirectory();
1170  $data = array();
1171  foreach ($_POST['file'] as $exp_file)
1172  {
1173  $file_arr = explode("__", $exp_file);
1174  array_push($data, array('file' => $exp_file, 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => filesize($export_dir."/".$exp_file)));
1175  }
1176  $table_gui->setData($data);
1177  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
1178  }
1179 
1180 
1185  {
1186  session_unregister("ilExportFiles");
1187  $this->ctrl->redirect($this, "export");
1188  }
1189 
1194  {
1195  include_once "./Services/Utilities/classes/class.ilUtil.php";
1196  $export_dir = $this->object->getExportDirectory();
1197  foreach($_POST['file'] as $file)
1198  {
1199  $exp_file = $export_dir."/".$file;
1200  include_once "./Services/Utilities/classes/class.ilStr.php";
1201  $exp_dir = $export_dir."/".ilStr::subStr($file, 0, ilStr::strLen($file) - 4);
1202  if (@is_file($exp_file))
1203  {
1204  unlink($exp_file);
1205  }
1206  if (@is_dir($exp_dir))
1207  {
1208  ilUtil::delDir($exp_dir);
1209  }
1210  }
1211  $this->ctrl->redirect($this, "export");
1212  }
1213 
1218  {
1219  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1220  $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1221  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
1222  }
1223 
1227  function createObject()
1228  {
1229  global $rbacsystem;
1230  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
1231  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
1232  {
1233  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1234  }
1235  else
1236  {
1237  $this->getTemplateFile("create", $new_type);
1238 
1239 
1240  $this->fillCloneTemplate('DUPLICATE','qpl');
1241  $this->tpl->setCurrentBlock("adm_content");
1242 
1243  // fill in saved values in case of error
1244  $data = array();
1245  $data["fields"] = array();
1246  include_once "./Services/Utilities/classes/class.ilUtil.php";
1247  $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
1248  $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
1249 
1250  foreach ($data["fields"] as $key => $val)
1251  {
1252  $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
1253  $this->tpl->setVariable(strtoupper($key), $val);
1254 
1255  if ($this->prepare_output)
1256  {
1257  $this->tpl->parseCurrentBlock();
1258  }
1259  }
1260 
1261  $this->ctrl->setParameter($this, "new_type", $this->type);
1262  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1263  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
1264  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
1265  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
1266  $this->tpl->setVariable("CMD_SUBMIT", "save");
1267  $this->tpl->setVariable("TARGET", ' target="'.
1268  ilFrameTargetInfo::_getFrame("MainContent").'" ');
1269  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
1270 
1271  $this->tpl->setVariable("TXT_IMPORT_QPL", $this->lng->txt("import_qpl"));
1272  $this->tpl->setVariable("TXT_QPL_FILE", $this->lng->txt("qpl_upload_file"));
1273  $this->tpl->setVariable("NEW_TYPE", $this->type);
1274  $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
1275 
1276  $this->tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_qpl.gif'));
1277  $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_qpl"));
1278  $this->tpl->setVariable("TYPE_IMG2", ilUtil::getImagePath('icon_qpl.gif'));
1279  $this->tpl->setVariable("ALT_IMG2",$this->lng->txt("obj_qpl"));
1280 
1281  $this->tpl->parseCurrentBlock();
1282  }
1283  }
1284 
1288  function importFileObject()
1289  {
1290  if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
1291  {
1292  ilUtil::sendInfo($this->lng->txt("qpl_select_file_for_import"));
1293  $this->createObject();
1294  return;
1295  }
1296  $this->uploadQplObject();
1297  }
1298 
1299  function addLocatorItems()
1300  {
1301  global $ilLocator;
1302  switch ($this->ctrl->getCmd())
1303  {
1304  case "create":
1305  case "importFile":
1306  case "cancel":
1307  break;
1308  default:
1309  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
1310  break;
1311  }
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  $q_gui->object->setObjId($this->object->getId());
1317  if ($_GET["q_id"] > 0)
1318  {
1319  $ilLocator->addItem($q_gui->object->getTitle(), $this->ctrl->getLinkTargetByClass(get_class($q_gui), "editQuestion"));
1320  }
1321  }
1322  }
1323 
1328  {
1329  if ($_GET["q_id"] > 0)
1330  {
1331  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1332  $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1333  $q_gui->object->setObjId($this->object->getId());
1334  $title = $q_gui->object->getTitle();
1335  if (strcmp($this->ctrl->getCmd(), "assessment") == 0)
1336  {
1337  $title .= " - " . $this->lng->txt("statistics");
1338  }
1339  $this->tpl->setTitle($title);
1340  $this->tpl->setDescription($q_gui->object->getComment());
1341  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif"), $this->lng->txt("obj_qpl"));
1342  }
1343  else
1344  {
1345  $this->tpl->setTitle($this->object->getTitle());
1346  $this->tpl->setDescription($this->object->getLongDescription());
1347  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif"), $this->lng->txt("obj_qpl"));
1348  }
1349  }
1350 
1356  function getTabs(&$tabs_gui)
1357  {
1358  global $ilAccess;
1359 
1360  $next_class = $this->ctrl->getNextClass($this);
1361  switch ($next_class)
1362  {
1363  case "":
1364  case "ilpermissiongui":
1365  case "ilmdeditorgui":
1366  break;
1367  default:
1368  return;
1369  break;
1370  }
1371  // questions
1372  $force_active = false;
1373  $commands = $_POST["cmd"];
1374  if (is_array($commands))
1375  {
1376  foreach ($commands as $key => $value)
1377  {
1378  if (preg_match("/^delete_.*/", $key, $matches) ||
1379  preg_match("/^addSelectGap_.*/", $key, $matches) ||
1380  preg_match("/^addTextGap_.*/", $key, $matches) ||
1381  preg_match("/^deleteImage_.*/", $key, $matches) ||
1382  preg_match("/^upload_.*/", $key, $matches) ||
1383  preg_match("/^addSuggestedSolution_.*/", $key, $matches)
1384  )
1385  {
1386  $force_active = true;
1387  }
1388  }
1389  }
1390  if (array_key_exists("imagemap_x", $_POST))
1391  {
1392  $force_active = true;
1393  }
1394  if (!$force_active)
1395  {
1396  $force_active = ((strtolower($this->ctrl->getCmdClass()) == strtolower(get_class($this)) || strlen($this->ctrl->getCmdClass()) == 0) &&
1397  $this->ctrl->getCmd() == "")
1398  ? true
1399  : false;
1400  }
1401  $tabs_gui->addTarget("assQuestions",
1402  $this->ctrl->getLinkTarget($this, "questions"),
1403  array("questions", "filter", "resetFilter", "createQuestion",
1404  "importQuestions", "deleteQuestions", "filterQuestionBrowser",
1405  "view", "preview", "editQuestion", "exec_pg",
1406  "addItem", "upload", "save", "cancel", "addSuggestedSolution",
1407  "cancelExplorer", "linkChilds", "removeSuggestedSolution",
1408  "add", "addYesNo", "addTrueFalse", "createGaps", "saveEdit",
1409  "setMediaMode", "uploadingImage", "uploadingImagemap", "addArea",
1410  "deletearea", "saveShape", "back", "addPair", "uploadingJavaapplet",
1411  "addParameter", "assessment", "addGIT", "addST", "addPG", "delete",
1412  "toggleGraphicalAnswers", "deleteAnswer", "deleteImage", "removeJavaapplet"),
1413  "", "", $force_active);
1414 
1415  // properties
1416  $tabs_gui->addTarget("properties",
1417  $this->ctrl->getLinkTarget($this,'properties'),
1418  "properties", "",
1419  "");
1420 
1421  global $rbacsystem;
1422  if ($rbacsystem->checkAccess("write", $this->ref_id))
1423  {
1424  // meta data
1425  $tabs_gui->addTarget("meta_data",
1426  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
1427  "", "ilmdeditorgui");
1428  }
1429 
1430  // print view
1431  $tabs_gui->addTarget("print_view",
1432  $this->ctrl->getLinkTarget($this,'print'),
1433  array("print"),
1434  "", "");
1435 
1436  // export
1437  $tabs_gui->addTarget("export",
1438  $this->ctrl->getLinkTarget($this,'export'),
1439  array("export", "createExportFile", "confirmDeleteExportFile", "downloadExportFile"),
1440  "", "");
1441 
1442  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
1443  {
1444  $tabs_gui->addTarget("perm_settings",
1445  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1446  }
1447  }
1448 
1457  function _goto($a_target)
1458  {
1459  global $ilAccess, $ilErr, $lng;
1460 
1461  if ($ilAccess->checkAccess("write", "", $a_target))
1462  {
1463  $_GET["baseClass"] = "ilObjQuestionPoolGUI";
1464  $_GET["cmd"] = "questions";
1465  $_GET["ref_id"] = $a_target;
1466  include_once("ilias.php");
1467  exit;
1468  }
1469  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1470  {
1471  $_GET["cmd"] = "frameset";
1472  $_GET["target"] = "";
1473  $_GET["ref_id"] = ROOT_FOLDER_ID;
1474  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
1475  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1476  include("repository.php");
1477  exit;
1478  }
1479  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
1480  }
1481 
1482 } // END class.ilObjQuestionPoolGUI
1483 ?>