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