ILIAS  Release_3_10_x_branch Revision 61812
 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 
72  global $rbacsystem;
73  if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))
74  {
75  $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
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 
85  $this->prepareOutput();
86  $cmd = $this->ctrl->getCmd("questions");
87  $next_class = $this->ctrl->getNextClass($this);
88  $this->ctrl->setReturn($this, "questions");
89  if ($_GET["q_id"] < 1)
90  {
91  $q_type = ($_POST["sel_question_types"] != "")
92  ? $_POST["sel_question_types"]
93  : $_GET["sel_question_types"];
94  }
95  if ($cmd != "createQuestion" && $cmd != "createQuestionForTest"
96  && $next_class != "ilpageobjectgui")
97  {
98  if (($_GET["test_ref_id"] != "") or ($_GET["calling_test"]))
99  {
100  $ref_id = $_GET["test_ref_id"];
101  if (!$ref_id)
102  {
103  $ref_id = $_GET["calling_test"];
104  }
105  }
106  }
107  switch($next_class)
108  {
109  case 'ilmdeditorgui':
110  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
111 
112  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
113  $md_gui->addObserver($this->object,'MDUpdateListener','General');
114  $this->ctrl->forwardCommand($md_gui);
115  break;
116  case "ilpageobjectgui":
117  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
118  $this->tpl->setCurrentBlock("ContentStyle");
119  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
121  $this->tpl->parseCurrentBlock();
122 
123  // syntax style
124  $this->tpl->setCurrentBlock("SyntaxStyle");
125  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
127  $this->tpl->parseCurrentBlock();
128  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
129  $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
130  $q_gui->setQuestionTabs();
131  $q_gui->outAdditionalOutput();
132  $q_gui->object->setObjId($this->object->getId());
133  $question =& $q_gui->object;
134  $this->ctrl->saveParameter($this, "q_id");
135  include_once("./Services/COPage/classes/class.ilPageObject.php");
136  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
137  $this->lng->loadLanguageModule("content");
138  $this->ctrl->setReturnByClass("ilPageObjectGUI", "view");
139  $this->ctrl->setReturn($this, "questions");
140  //$page =& new ilPageObject("qpl", $_GET["q_id"]);
141  $page_gui =& new ilPageObjectGUI("qpl", $_GET["q_id"]);
142  $page_gui->setEditPreview(true);
143  $page_gui->setEnabledTabs(false);
144  $page_gui->setEnabledInternalLinks(false);
145  if (strlen($this->ctrl->getCmd()) == 0)
146  {
147  $this->ctrl->setCmdClass(get_class($page_gui));
148  $this->ctrl->setCmd("preview");
149  }
150  //$page_gui->setQuestionXML($question->toXML(false, false, true));
151  $page_gui->setQuestionHTML($q_gui->getPreview(TRUE));
152  $page_gui->setTemplateTargetVar("ADM_CONTENT");
153  $page_gui->setOutputMode("edit");
154  $page_gui->setHeader($question->getTitle());
155  $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
156  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "fullscreen"));
157  $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this));
158  $page_gui->setPresentationTitle($question->getTitle());
159  $ret =& $this->ctrl->forwardCommand($page_gui);
160  $tpl->setContent($ret);
161  break;
162 
163  case 'ilpermissiongui':
164  include_once("./classes/class.ilPermissionGUI.php");
165  $perm_gui =& new ilPermissionGUI($this);
166  $ret =& $this->ctrl->forwardCommand($perm_gui);
167  break;
168  case "ilobjquestionpoolgui":
169  case "":
170  $cmd.= "Object";
171  $ret =& $this->$cmd();
172  break;
173  default:
174  $this->ctrl->setReturn($this, "questions");
175  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
176  $q_gui =& assQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
177  $q_gui->object->setObjId($this->object->getId());
178  $q_gui->setQuestionTabs();
179  $ret =& $this->ctrl->forwardCommand($q_gui);
180  break;
181  }
182 
183  if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
184  $this->getCreationMode() != true)
185  {
186  $this->tpl->show();
187  }
188  }
189 
193  function propertiesObject()
194  {
195  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_properties.html", "Modules/TestQuestionPool");
196  $this->tpl->setCurrentBlock("adm_content");
197  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
198  $this->tpl->setVariable("HEADING_GENERAL", $this->lng->txt("qpl_general_properties"));
199  $this->tpl->setVariable("PROPERTY_ONLINE", $this->lng->txt("qpl_online_property"));
200  $this->tpl->setVariable("PROPERTY_ONLINE_DESCRIPTION", $this->lng->txt("qpl_online_property_description"));
201  if ($this->object->getOnline() == 1)
202  {
203  $this->tpl->setVariable("PROPERTY_ONLINE_CHECKED", " checked=\"checked\"");
204  }
205  global $rbacsystem;
206  if ($rbacsystem->checkAccess("write", $this->ref_id))
207  {
208  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
209  }
210  else
211  {
212  $this->tpl->setVariable("PROPERTY_ONLINE_DISABLED", " disabled=\"disabled\"");
213  }
214  $this->tpl->parseCurrentBlock();
215  }
216 
222  function cancelObject($in_rep = false)
223  {
224  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
225  ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
226  }
227 
228 
233  {
234  $qpl_online = $_POST["online"];
235  if (strlen($qpl_online) == 0) $qpl_online = "0";
236  $this->object->setOnline($qpl_online);
237  $this->object->saveToDb();
238  ilUtil::sendInfo($this->lng->txt("saved_successfully"), true);
239  $this->ctrl->redirect($this, "properties");
240  }
241 
246  {
247  $file = explode("_", $_GET["file_id"]);
248  include_once("./Modules/File/classes/class.ilObjFile.php");
249  $fileObj =& new ilObjFile($file[count($file) - 1], false);
250  $fileObj->sendFile();
251  exit;
252  }
253 
257  function fullscreenObject()
258  {
259  include_once("./Services/COPage/classes/class.ilPageObject.php");
260  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
261  //$page =& new ilPageObject("qpl", $_GET["pg_id"]);
262  $page_gui =& new ilPageObjectGUI("qpl", $_GET["pg_id"]);
263  $page_gui->showMediaFullscreen();
264 
265  }
266 
267 
271  function filterObject()
272  {
273  $this->questionsObject();
274  }
275 
279  function resetFilterObject()
280  {
281  $_POST["filter_text"] = "";
282  $_POST["sel_filter_type"] = "";
283  $this->questionsObject();
284  }
285 
290  {
291  include_once("./Services/COPage/classes/class.ilPageObject.php");
292  $pg_obj =& new ilPageObject("qpl", $_GET["pg_id"]);
293  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
294  exit;
295  }
296 
300  function uploadQplObject($questions_only = false)
301  {
302  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
303  {
304  ilUtil::sendInfo($this->lng->txt("error_upload"));
305  $this->importObject();
306  return;
307  }
308  // create import directory
309  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
311 
312  // copy uploaded file to import directory
313  $file = pathinfo($_FILES["xmldoc"]["name"]);
314  $full_path = ilObjQuestionPool::_getImportDirectory()."/".$_FILES["xmldoc"]["name"];
315  include_once "./Services/Utilities/classes/class.ilUtil.php";
316  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
317  if (strcmp($_FILES["xmldoc"]["type"], "text/xml") == 0)
318  {
319  $qti_file = $full_path;
320  }
321  else
322  {
323  // unzip file
324  ilUtil::unzip($full_path);
325 
326  // determine filenames of xml files
327  $subdir = basename($file["basename"],".".$file["extension"]);
328  $xml_file = ilObjQuestionPool::_getImportDirectory()."/".$subdir."/".$subdir.".xml";
329  $qti_file = ilObjQuestionPool::_getImportDirectory()."/".$subdir."/". str_replace("qpl", "qti", $subdir).".xml";
330  }
331 
332  // start verification of QTI files
333  include_once "./Services/QTI/classes/class.ilQTIParser.php";
334  $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
335  $result = $qtiParser->startParsing();
336  $founditems =& $qtiParser->getFoundItems();
337  if (count($founditems) == 0)
338  {
339  // nothing found
340 
341  // delete import directory
343 
344  ilUtil::sendInfo($this->lng->txt("qpl_import_no_items"));
345  $this->importObject();
346  return;
347  }
348 
349  $complete = 0;
350  $incomplete = 0;
351  foreach ($founditems as $item)
352  {
353  if (strlen($item["type"]))
354  {
355  $complete++;
356  }
357  else
358  {
359  $incomplete++;
360  }
361  }
362 
363  if ($complete == 0)
364  {
365  // delete import directory
367 
368  ilUtil::sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
369  $this->importObject();
370  return;
371  }
372 
373  $_SESSION["qpl_import_xml_file"] = $xml_file;
374  $_SESSION["qpl_import_qti_file"] = $qti_file;
375  $_SESSION["qpl_import_subdir"] = $subdir;
376  // display of found questions
377  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_import_verification.html");
378  $row_class = array("tblrow1", "tblrow2");
379  $counter = 0;
380  foreach ($founditems as $item)
381  {
382  $this->tpl->setCurrentBlock("verification_row");
383  $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
384  $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
385  $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
386  include_once "./Services/QTI/classes/class.ilQTIItem.php";
387  switch ($item["type"])
388  {
390  $type = $this->lng->txt("assClozeTest");
391  break;
393  $type = $this->lng->txt("assImagemapQuestion");
394  break;
396  $type = $this->lng->txt("assJavaApplet");
397  break;
399  $type = $this->lng->txt("assMatchingQuestion");
400  break;
402  $type = $this->lng->txt("assMultipleChoice");
403  break;
405  $type = $this->lng->txt("assSingleChoice");
406  break;
408  $type = $this->lng->txt("assOrderingQuestion");
409  break;
411  $type = $this->lng->txt("assTextQuestion");
412  break;
414  $type = $this->lng->txt("assNumeric");
415  break;
417  $type = $this->lng->txt("assTextSubset");
418  break;
419  default:
420  $type = $this->lng->txt($item["type"]);
421  break;
422  }
423 
424  if (strcmp($type, "-" . $item["type"] . "-") == 0)
425  {
426  global $ilPluginAdmin;
427  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "TestQuestionPool", "qst");
428  foreach ($pl_names as $pl_name)
429  {
430  $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "TestQuestionPool", "qst", $pl_name);
431  if (strcmp($pl->getQuestionType(), $item["type"]) == 0)
432  {
433  $type = $pl->getQuestionTypeTranslation();
434  }
435  }
436  }
437  $this->tpl->setVariable("QUESTION_TYPE", $type);
438  $this->tpl->parseCurrentBlock();
439  }
440 
441  $this->tpl->setCurrentBlock("import_qpl");
442  if (is_file($xml_file))
443  {
444  // read file into a string
445  $fh = @fopen($xml_file, "r") or die("");
446  $xml = @fread($fh, filesize($xml_file));
447  @fclose($fh);
448  if (preg_match("/<ContentObject.*?MetaData.*?General.*?Title[^>]*?>([^<]*?)</", $xml, $matches))
449  {
450  $this->tpl->setVariable("VALUE_NEW_QUESTIONPOOL", $matches[1]);
451  }
452  }
453  $this->tpl->setVariable("TEXT_CREATE_NEW_QUESTIONPOOL", $this->lng->txt("qpl_import_create_new_qpl"));
454  $this->tpl->parseCurrentBlock();
455 
456  $this->tpl->setCurrentBlock("adm_content");
457  $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
458  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
459  $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("qpl_import_verify_found_questions"));
460  if ($questions_only)
461  {
462  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_questions_into_qpl"));
463  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
464  }
465  else
466  {
467  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_qpl"));
468 
469  $this->ctrl->setParameter($this, "new_type", $this->type);
470  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
471 
472  //$this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".$_GET["ref_id"]."&new_type=".$this->type));
473  }
474  $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.gif"));
475  $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
476  $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
477  $value_questions_only = 0;
478  if ($questions_only) $value_questions_only = 1;
479  $this->tpl->setVariable("VALUE_QUESTIONS_ONLY", $value_questions_only);
480 
481  $this->tpl->parseCurrentBlock();
482  }
483 
488  {
489  if ($_POST["questions_only"] == 1)
490  {
491  $newObj =& $this->object;
492  }
493  else
494  {
495  include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
496  // create new questionpool object
497  $newObj = new ilObjQuestionPool(0, true);
498  // set type of questionpool object
499  $newObj->setType($_GET["new_type"]);
500  // set title of questionpool object to "dummy"
501  $newObj->setTitle("dummy");
502  // set description of questionpool object
503  $newObj->setDescription("questionpool import");
504  // create the questionpool class in the ILIAS database (object_data table)
505  $newObj->create(true);
506  // create a reference for the questionpool object in the ILIAS database (object_reference table)
507  $newObj->createReference();
508  // put the questionpool object in the administration tree
509  $newObj->putInTree($_GET["ref_id"]);
510  // get default permissions and set the permissions for the questionpool object
511  $newObj->setPermissions($_GET["ref_id"]);
512  // notify the questionpool object and all its parent objects that a "new" object was created
513  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
514  }
515 
516  // start parsing of QTI files
517  include_once "./Services/QTI/classes/class.ilQTIParser.php";
518  $qtiParser = new ilQTIParser($_SESSION["qpl_import_qti_file"], IL_MO_PARSE_QTI, $newObj->getId(), $_POST["ident"]);
519  $result = $qtiParser->startParsing();
520 
521  // import page data
522  if (strlen($_SESSION["qpl_import_xml_file"]))
523  {
524  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
525  $contParser = new ilContObjParser($newObj, $_SESSION["qpl_import_xml_file"], $_SESSION["qpl_import_subdir"]);
526  $contParser->setQuestionMapping($qtiParser->getImportMapping());
527  $contParser->startParsing();
528  }
529 
530  // set another question pool name (if possible)
531  $qpl_name = $_POST["qpl_new"];
532  if ((strcmp($qpl_name, $newObj->getTitle()) != 0) && (strlen($qpl_name) > 0))
533  {
534  $newObj->setTitle($qpl_name);
535  $newObj->update();
536  }
537 
538  // delete import directory
539  include_once "./Services/Utilities/classes/class.ilUtil.php";
541 
542  if ($_POST["questions_only"] == 1)
543  {
544  $this->ctrl->redirect($this, "questions");
545  }
546  else
547  {
548  ilUtil::sendInfo($this->lng->txt("object_imported"),true);
549  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
550  "&baseClass=ilObjQuestionPoolGUI");
551  }
552  }
553 
555  {
556  if ($_POST["questions_only"] == 1)
557  {
558  $this->ctrl->redirect($this, "questions");
559  }
560  else
561  {
562  $this->ctrl->redirect($this, "cancel");
563  }
564  }
565 
569  function uploadObject()
570  {
571  $this->uploadQplObject(true);
572  }
573 
578  {
579  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_import_question.html", "Modules/TestQuestionPool");
580  $this->tpl->setCurrentBlock("adm_content");
581  $this->tpl->setVariable("TEXT_IMPORT_QUESTION", $this->lng->txt("import_question"));
582  $this->tpl->setVariable("TEXT_SELECT_FILE", $this->lng->txt("select_file"));
583  $this->tpl->setVariable("TEXT_UPLOAD", $this->lng->txt("upload"));
584  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
585  $this->tpl->parseCurrentBlock();
586  }
587 
593  function importObject()
594  {
595  global $rbacsystem;
596  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"]))
597  {
598  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
599  }
600  $this->getTemplateFile("import", "qpl");
601  $this->ctrl->setParameter($this, "new_type", $this->type);
602  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
603  //$this->tpl->setVariable("FORMACTION", "adm_object.php?&ref_id=".$_GET["ref_id"]."&cmd=gateway&new_type=".$this->type);
604  $this->tpl->setVariable("BTN_NAME", "uploadQpl");
605  $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("import"));
606  $this->tpl->setVariable("NEW_TYPE", $this->type);
607  $this->tpl->setVariable("TXT_IMPORT_QPL", $this->lng->txt("import_qpl"));
608  $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
609  $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
610  $this->tpl->parseCurrentBlock();
611  }
612 
617  {
618  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
619  $q_gui =& assQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
620  $q_gui->object->setObjId($this->object->getId());
621  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_POST["sel_question_types"]);
622  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
623  }
624 
629  {
630  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
631  $q_gui =& assQuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
632  $q_gui->object->setObjId($this->object->getId());
633  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_GET["sel_question_types"]);
634  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
635  }
636 
641  function saveObject()
642  {
643  global $rbacadmin;
644 
645  // create and insert forum in objecttree
646  $newObj = parent::saveObject();
647 
648  // always send a message
649  ilUtil::sendInfo($this->lng->txt("object_added"),true);
650 
651  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
652  "&baseClass=ilObjQuestionPoolGUI");
653 
654 /* if (strlen($this->ctrl->getModuleDir()) == 0)
655  {
656  include_once "./Services/Utilities/classes/class.ilUtil.php";
657  ilUtil::redirect($this->getReturnLocation("save","adm_object.php?ref_id=".$_GET["ref_id"]));
658  }
659  else
660  {
661  $this->ctrl->redirect($this, "questions");
662  }*/
663  }
664 
668  function assessmentObject()
669  {
670  $this->tpl->addBlockFile("CONTENT", "content", "tpl.il_as_qpl_content.html", "Modules/TestQuestionPool");
671  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
672 
673  // catch feedback message
675 
676  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
677  $question_title = assQuestion::_getTitle($_GET["q_id"]);
678  $title = $this->lng->txt("statistics") . " - $question_title";
679  if (!empty($title))
680  {
681  $this->tpl->setVariable("HEADER", $title);
682  }
683  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
684  $total_of_answers = assQuestion::_getTotalAnswers($_GET["q_id"]);
685  $counter = 0;
686  $color_class = array("tblrow1", "tblrow2");
687  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_assessment_of_questions.html", "Modules/TestQuestionPool");
688  if (!$total_of_answers)
689  {
690  $this->tpl->setCurrentBlock("emptyrow");
691  $this->tpl->setVariable("TXT_NO_ASSESSMENT", $this->lng->txt("qpl_assessment_no_assessment_of_questions"));
692  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
693  $this->tpl->parseCurrentBlock();
694  }
695  else
696  {
697  $this->tpl->setCurrentBlock("row");
698  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_answers"));
699  $this->tpl->setVariable("TXT_VALUE", $total_of_answers);
700  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
701  $counter++;
702  $this->tpl->parseCurrentBlock();
703  $this->tpl->setCurrentBlock("row");
704  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("qpl_assessment_total_of_right_answers"));
705  $this->tpl->setVariable("TXT_VALUE", sprintf("%2.2f", assQuestion::_getTotalRightAnswers($_GET["edit"]) * 100.0) . " %");
706  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
707  $this->tpl->parseCurrentBlock();
708  }
709  $this->tpl->setCurrentBlock("adm_content");
710  $this->tpl->setVariable("TXT_QUESTION_TITLE", $question_title);
711  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("result"));
712  $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
713  $this->tpl->parseCurrentBlock();
714  }
715 
716  function questionObject()
717  {
718 //echo "<br>ilObjQuestionPoolGUI->questionObject()";
719  $type = $_GET["sel_question_types"];
720  $this->editQuestionForm($type);
721  }
722 
727  {
728  if (count($_POST["q_id"]) < 1)
729  {
730  ilUtil::sendInfo($this->lng->txt("qpl_delete_select_none"), true);
731  $this->ctrl->redirect($this, "questions");
732  }
733 
734  $checked_questions =& $this->object->getQuestionDetails($_POST["q_id"]);
735  $deleteable_questions =& $this->object->getDeleteableQuestionDetails($_POST["q_id"]);
736  $used_questions =& $this->object->getUsedQuestionDetails($_POST["q_id"]);
737  $_SESSION["ass_q_id"] = $deleteable_questions;
738  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_confirm_delete_questions.html", "Modules/TestQuestionPool");
739 
740  $colors = array("tblrow1", "tblrow2");
741  $counter = 0;
742  include_once "./Services/Utilities/classes/class.ilUtil.php";
743  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
744  if (count($deleteable_questions) > 0)
745  {
746  foreach ($deleteable_questions as $question)
747  {
748  $this->tpl->setCurrentBlock("row");
749  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
750  $this->tpl->setVariable("TXT_TITLE", $question["title"]);
751  $this->tpl->setVariable("TXT_DESCRIPTION", $question["comment"]);
752  $this->tpl->setVariable("TXT_TYPE", assQuestion::_getQuestionTypeName($question["type_tag"]));
753  $this->tpl->parseCurrentBlock();
754  $counter++;
755 
756  $this->tpl->setCurrentBlock("hidden");
757  $this->tpl->setVariable("HIDDEN_NAME", "id_" . $question["question_id"]);
758  $this->tpl->setVariable("HIDDEN_VALUE", "1");
759  $this->tpl->parseCurrentBlock();
760  }
761  }
762  else
763  {
764  $this->tpl->setCurrentBlock("emptyrow");
765  $this->tpl->setVariable("TEXT_EMPTY_ROW", $this->lng->txt("qpl_delete_no_deleteable_questions"));
766  $this->tpl->parseCurrentBlock();
767  }
768 
769  if (count($used_questions))
770  {
771  foreach ($used_questions as $question)
772  {
773  $this->tpl->setCurrentBlock("undeleteable_row");
774  $this->tpl->setVariable("QUESTION_TITLE", $question["title"]);
775  $this->tpl->parseCurrentBlock();
776  }
777  $this->tpl->setCurrentBlock("undeleteable_questions");
778  $this->tpl->setVariable("TEXT_UNDELETEABLE_QUESTIONS", $this->lng->txt("qpl_delete_describe_undeleteable_questions"));
779  $this->tpl->parseCurrentBlock();
780  }
781 
782  $this->tpl->setCurrentBlock("adm_content");
783  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("tst_question_title"));
784  $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
785  $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("tst_question_type"));
786  $this->tpl->setVariable("TXT_LOCKED", $this->lng->txt("locked"));
787  $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
788  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
789  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
790  $this->tpl->setVariable("DELETE_QUESTION", $this->lng->txt("qpl_confirm_delete_questions"));
791  $this->tpl->parseCurrentBlock();
792  }
793 
794 
799  {
800  // delete questions after confirmation
801  if (count($_SESSION["ass_q_id"])) ilUtil::sendInfo($this->lng->txt("qpl_questions_deleted"), true);
802  foreach ($_SESSION["ass_q_id"] as $key => $value)
803  {
804  $this->object->deleteQuestion($value["question_id"]);
805  }
806  $this->ctrl->redirect($this, "questions");
807  }
808 
813  {
814  $this->ctrl->redirect($this, "questions");
815  }
816 
821  {
822  // export button was pressed
823  if (count($_POST["q_id"]) > 0)
824  {
825  include_once("./Modules/TestQuestionPool/classes/class.ilQuestionpoolExport.php");
826  $qpl_exp = new ilQuestionpoolExport($this->object, "xml", $_POST["q_id"]);
827  $export_file = $qpl_exp->buildExportFile();
828  $filename = $export_file;
829  $filename = preg_replace("/.*\//", "", $filename);
830  include_once "./Services/Utilities/classes/class.ilUtil.php";
831  ilUtil::deliverFile($export_file, $filename);
832  exit();
833  }
834  else
835  {
836  ilUtil::sendInfo($this->lng->txt("qpl_export_select_none"), true);
837  }
838  $this->ctrl->redirect($this, "questions");
839  }
840 
844  function questionsObject()
845  {
846  global $rbacsystem;
847  global $ilUser;
848 
849  $lastquestiontype = $ilUser->getPref("tst_lastquestiontype");
850  $type = $_GET["sel_question_types"];
851 
852  // reset test_id SESSION variable
853  $_SESSION["test_id"] = "";
854 
855  // create an array of all checked checkboxes
856  $checked_questions = array();
857  foreach ($_POST as $key => $value)
858  {
859  if (preg_match("/cb_(\d+)/", $key, $matches))
860  {
861  array_push($checked_questions, $matches[1]);
862  }
863  }
864 
865  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_questions.html", "Modules/TestQuestionPool");
866  if ($rbacsystem->checkAccess('write', $this->ref_id))
867  {
868  $this->tpl->addBlockFile("CREATE_QUESTION", "create_question", "tpl.il_as_create_new_question.html", "Modules/TestQuestionPool");
869  }
870  $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_as_qpl_action_buttons.html", "Modules/TestQuestionPool");
871  $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_as_qpl_filter_questions.html", "Modules/TestQuestionPool");
872 
873  // create filter form
874  $filter_fields = array(
875  "title" => $this->lng->txt("title"),
876  "comment" => $this->lng->txt("description"),
877  "author" => $this->lng->txt("author"),
878  );
879  $this->tpl->setCurrentBlock("filterrow");
880  foreach ($filter_fields as $key => $value)
881  {
882  $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
883  $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
884  if (strcmp($_POST["sel_filter_type"], $key) == 0)
885  {
886  $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
887  }
888  $this->tpl->parseCurrentBlock();
889  }
890 
891  $this->tpl->setCurrentBlock("filter_questions");
892  $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
893  $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
894  $this->tpl->setVariable("VALUE_FILTER_TEXT", $_POST["filter_text"]);
895  $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
896  $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
897  $this->tpl->parseCurrentBlock();
898 
899  // create edit buttons & table footer
900  if ($rbacsystem->checkAccess('write', $this->ref_id))
901  {
902  $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
903  $this->tpl->setVariable("EXPORT", $this->lng->txt("export"));
904  $this->tpl->setVariable("COPY", $this->lng->txt("copy"));
905  $this->tpl->setVariable("MOVE", $this->lng->txt("move"));
906  $this->tpl->parseCurrentBlock();
907  if (array_key_exists("qpl_clipboard", $_SESSION))
908  {
909  $this->tpl->setCurrentBlock("pastebutton");
910  $this->tpl->setVariable("PASTE", $this->lng->txt("paste"));
911  $this->tpl->parseCurrentBlock();
912  }
913  }
914  else
915  {
916  $this->tpl->setVariable("EXPORT", $this->lng->txt("export"));
917  $this->tpl->setVariable("COPY", $this->lng->txt("copy"));
918  }
919 
920  $this->tpl->setCurrentBlock("Footer");
921  include_once "./Services/Utilities/classes/class.ilUtil.php";
922  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
923  $this->tpl->parseCurrentBlock();
924 
925  $this->tpl->setCurrentBlock("QTab");
926 
927  // reset the filter
928  $startrow = 0;
929  if ($_GET["prevrow"])
930  {
931  $startrow = $_GET["prevrow"];
932  }
933  if ($_GET["nextrow"])
934  {
935  $startrow = $_GET["nextrow"];
936  }
937  if ($_GET["startrow"])
938  {
939  $startrow = $_GET["startrow"];
940  }
941  $sort = ($_GET["sort"]) ? $_GET["sort"] : (($_SESSION["qpl_sort"]) ? $_SESSION["qpl_sort"] : "title");
942  $sortorder = ($_GET["sortorder"]) ? $_GET["sortorder"] : (($_SESSION["qpl_sortorder"]) ? $_SESSION["qpl_sortorder"] : "ASC");
943  $_SESSION["qpl_sort"] = $sort;
944  $_SESSION["qpl_sortorder"] = $sortorder;
945  $this->ctrl->setParameter($this, "sort", $sort);
946  $this->ctrl->setParameter($this, "sortorder", $sortorder);
947  $table = $this->object->getQuestionsTable($sort, $sortorder, $_POST["filter_text"], $_POST["sel_filter_type"], $startrow);
948  $colors = array("tblrow1", "tblrow2");
949  include_once "./Services/Utilities/classes/class.ilUtil.php";
950  $counter = 0;
951  $sumPoints = 0;
952  $editable = $rbacsystem->checkAccess('write', $this->ref_id);
953  foreach ($table["rows"] as $data)
954  {
955  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
956  $class = strtolower(assQuestionGUI::_getGUIClassNameForId($data["question_id"]));
957  $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $data["question_id"]);
958  $this->ctrl->setParameterByClass($class, "q_id", $data["question_id"]);
959 
960  if ($data["complete"] == 0)
961  {
962  $this->tpl->setCurrentBlock("qpl_warning");
963  $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("warning.gif"));
964  $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete"));
965  $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete"));
966  $this->tpl->parseCurrentBlock();
967  $points = 0;
968  } else
969  {
970  $points = assQuestion::_getMaximumPoints($data["question_id"]);
971  }
972  $sumPoints += $points;
973 
974  $this->tpl->setCurrentBlock("checkable");
975  $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
976  $this->tpl->parseCurrentBlock();
977  if ($editable)
978  {
979  $this->tpl->setCurrentBlock("edit_link");
980  $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
981  $this->tpl->setVariable("LINK_EDIT", $this->ctrl->getLinkTargetByClass("ilpageobjectgui", "edit"));
982  $this->tpl->parseCurrentBlock();
983  }
984  $this->tpl->setCurrentBlock("QTab");
985  $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
986  $this->tpl->setVariable("QUESTION_TITLE", "<strong>" .$data["title"] . "</strong>");
987 
988  $this->tpl->setVariable("TXT_PREVIEW", $this->lng->txt("preview"));
989  $this->tpl->setVariable("LINK_PREVIEW", $this->ctrl->getLinkTargetByClass("ilpageobjectgui", "preview"));
990 
991  $this->tpl->setVariable("QUESTION_COMMENT", $data["comment"]);
992  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
993  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($data["type_tag"]));
994  $this->tpl->setVariable("LINK_ASSESSMENT", $this->ctrl->getLinkTargetByClass($class, "assessment"));
995  $this->tpl->setVariable("TXT_ASSESSMENT", $this->lng->txt("statistics"));
996  include_once "./Services/Utilities/classes/class.ilUtil.php";
997  $this->tpl->setVariable("IMG_ASSESSMENT", ilUtil::getImagePath("assessment.gif", "Modules/TestQuestionPool"));
998  $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
999  include_once "./classes/class.ilFormat.php";
1000  $this->tpl->setVariable("QUESTION_CREATED", ilDatePresentation::formatDate(new ilDate($data['created'],IL_CAL_TIMESTAMP)));
1001  $this->tpl->setVariable("QUESTION_UPDATED", ilDatePresentation::formatDate(new ilDate($data["timestamp14"],IL_CAL_TIMESTAMP)));
1002  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
1003  $this->tpl->setVariable("QUESTION_POINTS", $points);
1004  $this->tpl->parseCurrentBlock();
1005  $counter++;
1006  }
1007 
1008  if ($table["rowcount"] > count($table["rows"]))
1009  {
1010  $nextstep = $table["nextrow"] + $table["step"];
1011  if ($nextstep > $table["rowcount"])
1012  {
1013  $nextstep = $table["rowcount"];
1014  }
1015  $counter = 1;
1016  for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
1017  {
1018  $this->tpl->setCurrentBlock("pages");
1019  if ($table["startrow"] == $i)
1020  {
1021  $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
1022  }
1023  else
1024  {
1025  $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getFormAction($this) . "&nextrow=$i" . "\">$counter</a>");
1026  }
1027  $this->tpl->parseCurrentBlock();
1028  $counter++;
1029  }
1030  $this->tpl->setCurrentBlock("navigation_bottom");
1031  $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
1032  $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
1033  $end = $table["startrow"] + $table["step"];
1034  if ($end > $table["rowcount"])
1035  {
1036  $end = $table["rowcount"];
1037  }
1038  $this->tpl->setVariable("TEXT_ITEM_END", $end);
1039  $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
1040  $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
1041  $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
1042  $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
1043  $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getFormAction($this) . "&prevrow=" . $table["prevrow"]);
1044  $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getFormAction($this) . "&nextrow=" . $table["nextrow"]);
1045  $this->tpl->parseCurrentBlock();
1046  }
1047 
1048  // if there are no questions, display a message
1049  if ($counter == 0)
1050  {
1051  $this->tpl->setCurrentBlock("Emptytable");
1052  $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
1053  $this->tpl->parseCurrentBlock();
1054  }
1055  else
1056  {
1057  $counter++;
1058  $this->tpl->setCurrentBlock("selectall");
1059  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
1060  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
1061  $this->tpl->setVariable("SUM_POINTS", $sumPoints);
1062  $this->tpl->parseCurrentBlock();
1063  }
1064 
1065  if ($rbacsystem->checkAccess('write', $this->ref_id))
1066  {
1067  // "create question" form
1068  $this->tpl->setCurrentBlock("QTypes");
1069  $types =& $this->object->getQuestionTypes();
1070  foreach ($types as $translation => $data)
1071  {
1072  if ($data["type_tag"] == $lastquestiontype)
1073  {
1074  $this->tpl->setVariable("QUESTION_TYPE_SELECTED", " selected=\"selected\"");
1075  }
1076  $this->tpl->setVariable("QUESTION_TYPE_ID", $data["type_tag"]);
1077  $this->tpl->setVariable("QUESTION_TYPE", $translation);
1078  $this->tpl->parseCurrentBlock();
1079 // }
1080  }
1081  $this->tpl->setCurrentBlock("CreateQuestion");
1082  $this->tpl->setVariable("QUESTION_ADD", $this->lng->txt("create"));
1083  $this->tpl->setVariable("ACTION_QUESTION_ADD", $this->ctrl->getFormAction($this));
1084  $this->tpl->setVariable("QUESTION_IMPORT", $this->lng->txt("import"));
1085  $this->tpl->parseCurrentBlock();
1086  }
1087 
1088  // define the sort column parameters
1089  $sortarray = array(
1090  "title" => (strcmp($sort, "title") == 0) ? $sortorder : "",
1091  "comment" => (strcmp($sort, "comment") == 0) ? $sortorder : "",
1092  "type" => (strcmp($sort, "type") == 0) ? $sortorder : "",
1093  "author" => (strcmp($sort, "author") == 0) ? $sortorder : "",
1094  "created" => (strcmp($sort, "created") == 0) ? $sortorder : "",
1095  "updated" => (strcmp($sort, "updated") == 0) ? $sortorder : ""
1096  );
1097  foreach ($sortarray as $key => $value)
1098  {
1099  if (strcmp($value, "ASC") == 0)
1100  {
1101  $sortarray[$key] = "DESC";
1102  }
1103  else
1104  {
1105  $sortarray[$key] = "ASC";
1106  }
1107  }
1108 
1109  $this->tpl->setCurrentBlock("adm_content");
1110  // create table header
1111  $this->ctrl->setParameterByClass(get_class($this), "startrow", $table["startrow"]);
1112  $this->ctrl->setParameter($this, "sort", "title");
1113  $this->ctrl->setParameter($this, "sortorder", $sortarray["title"]);
1114  $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
1115  $this->ctrl->setParameter($this, "sort", "comment");
1116  $this->ctrl->setParameter($this, "sortorder", $sortarray["comment"]);
1117  $this->tpl->setVariable("QUESTION_COMMENT", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["comment"]);
1118  $this->ctrl->setParameter($this, "sort", "type");
1119  $this->ctrl->setParameter($this, "sortorder", $sortarray["type"]);
1120  $this->tpl->setVariable("QUESTION_TYPE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("question_type") . "</a>" . $table["images"]["type"]);
1121  $this->ctrl->setParameter($this, "sort", "author");
1122  $this->ctrl->setParameter($this, "sortorder", $sortarray["author"]);
1123  $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
1124  $this->ctrl->setParameter($this, "sort", "created");
1125  $this->ctrl->setParameter($this, "sortorder", $sortarray["created"]);
1126  $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
1127  $this->ctrl->setParameter($this, "sort", "updated");
1128  $this->ctrl->setParameter($this, "sortorder", $sortarray["updated"]);
1129  $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
1130  $this->tpl->setVariable("QUESTION_POINTS", $this->lng->txt("points"));
1131  $this->ctrl->setParameter($this, "sort", $sort);
1132  $this->ctrl->setParameter($this, "sortorder", $sortorder);
1133  $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
1134  $this->tpl->parseCurrentBlock();
1135  }
1136 
1144  function printObject()
1145  {
1146  $sort = "title";
1147  if (strlen($_POST["sortorder"]))
1148  {
1149  $sort = $_POST["sortorder"];
1150  }
1151  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_printview.html", "Modules/TestQuestionPool");
1152  $sortorder = array(
1153  "title" => $this->lng->txt("title"),
1154  "comment" => $this->lng->txt("description"),
1155  "type" => $this->lng->txt("question_type"),
1156  "author" => $this->lng->txt("author"),
1157  "created" => $this->lng->txt("create_date"),
1158  "updated" => $this->lng->txt("last_update")
1159  );
1160  foreach ($sortorder as $value => $text)
1161  {
1162  $this->tpl->setCurrentBlock("sortorder");
1163  $this->tpl->setVariable("VALUE_SORTORDER", $value);
1164  $this->tpl->setVariable("TEXT_SORTORDER", $text);
1165  if (strcmp($sort, $value) == 0)
1166  {
1167  $this->tpl->setVariable("SELECTED_SORTORDER", " selected=\"selected\"");
1168  }
1169  $this->tpl->parseCurrentBlock();
1170  }
1171  $table =& $this->object->getPrintviewQuestions($sort);
1172  $colors = array("tblrow1top", "tblrow2top");
1173  $counter = 1;
1174  include_once "./classes/class.ilFormat.php";
1175  foreach ($table as $row)
1176  {
1177  if ((strcmp($_POST["output"], "detailed") == 0) || (strcmp($_POST["output"], "detailed_printview") == 0))
1178  {
1179  $this->tpl->setCurrentBlock("overview_row_detail");
1180  $this->tpl->setVariable("ROW_CLASS", $colors[$counter % 2]);
1181  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1182  $question_gui = assQuestion::_instanciateQuestionGUI($row["question_id"]);
1183  if (strcmp($_POST["output"], "detailed") == 0)
1184  {
1185  $solutionoutput = $question_gui->getSolutionOutput($active_id = "", $pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = FALSE, $show_feedback = FALSE);
1186  if (strlen($solutionoutput) == 0) $solutionoutput = $question_gui->getPreview();
1187  $this->tpl->setVariable("PREVIEW", $solutionoutput);
1188  }
1189  else
1190  {
1191  $this->tpl->setVariable("PREVIEW", $question_gui->getPreview());
1192  }
1193  $this->tpl->parseCurrentBlock();
1194  $this->tpl->setCurrentBlock("overview_row_detail");
1195  $this->tpl->setVariable("ROW_CLASS", $colors[$counter % 2]);
1196  $this->tpl->parseCurrentBlock();
1197  }
1198  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1199  $this->tpl->setCurrentBlock("overview_row");
1200  $this->tpl->setVariable("ROW_CLASS", $colors[$counter % 2]);
1201  $this->tpl->setVariable("TEXT_COUNTER", $counter);
1202  $this->tpl->setVariable("TEXT_TITLE", ilUtil::prepareFormOutput($row["title"]));
1203  $this->tpl->setVariable("TEXT_DESCRIPTION", ilUtil::prepareFormOutput($row["comment"]));
1204  $this->tpl->setVariable("TEXT_QUESTIONTYPE", assQuestion::_getQuestionTypeName($row["type_tag"]));
1205  $this->tpl->setVariable("TEXT_AUTHOR", $row["author"]);
1206  $this->tpl->setVariable("TEXT_CREATED", ilDatePresentation::formatDate(new ilDate($row["created"],IL_CAL_TIMESTAMP)));
1207  $this->tpl->setVariable("TEXT_UPDATED", ilDatePresentation::formatDate(new ilDate($row["timestamp14"],IL_CAL_TIMESTAMP)));
1208  $this->tpl->parseCurrentBlock();
1209  $counter++;
1210  }
1211  $this->tpl->setCurrentBlock("overview");
1212  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
1213  $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
1214  $this->tpl->setVariable("TEXT_QUESTIONTYPE", $this->lng->txt("question_type"));
1215  $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
1216  $this->tpl->setVariable("TEXT_CREATED", $this->lng->txt("create_date"));
1217  $this->tpl->setVariable("TEXT_UPDATED", $this->lng->txt("last_update"));
1218  $this->tpl->parseCurrentBlock();
1219  $this->tpl->setCurrentBlock("adm_content");
1220  if (strcmp($_POST["output"], "detailed") == 0)
1221  {
1222  $this->tpl->setVariable("SELECTED_DETAILED", " selected=\"selected\"");
1223  }
1224  else if (strcmp($_POST["output"], "detailed_printview") == 0)
1225  {
1226  $this->tpl->setVariable("SELECTED_DETAILED_PRINTVIEW", " selected=\"selected\"");
1227  }
1228  $this->tpl->setVariable("TEXT_DETAILED", $this->lng->txt("detailed_output_solutions"));
1229  $this->tpl->setVariable("TEXT_DETAILED_PRINTVIEW", $this->lng->txt("detailed_output_printview"));
1230  $this->tpl->setVariable("TEXT_OVERVIEW", $this->lng->txt("overview"));
1231  $this->tpl->setVariable("OUTPUT_MODE", $this->lng->txt("output_mode"));
1232  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1233  $this->tpl->setVariable("SORT_TEXT", $this->lng->txt("sort_by_this_column"));
1234  $this->tpl->setVariable("TEXT_SUBMIT", $this->lng->txt("submit"));
1235  $this->tpl->setVariable("PRINT", $this->lng->txt("print"));
1236  $this->tpl->parseCurrentBlock();
1237  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1238  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "ta.css", "Modules/Test"), "screen");
1239  $this->tpl->setVariable("PAGETITLE", " - " . ilUtil::prepareFormOutput(ilObjQuestionPool::_getFullPathToQpl($this->object->getRefId()) . " > " . $this->object->getTitle()));
1240  }
1241 
1242  function updateObject()
1243  {
1244 // $this->update = $this->object->updateMetaData();
1245  $this->update = $this->object->update();
1246  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
1247  }
1248 
1252  function pasteObject()
1253  {
1254  if (array_key_exists("qpl_clipboard", $_SESSION))
1255  {
1256  $this->object->pasteFromClipboard();
1257  ilUtil::sendInfo($this->lng->txt("qpl_paste_success"), true);
1258  }
1259  else
1260  {
1261  ilUtil::sendInfo($this->lng->txt("qpl_paste_no_objects"), true);
1262  }
1263  $this->ctrl->redirect($this, "questions");
1264  }
1265 
1269  function copyObject()
1270  {
1271  if (count($_POST["q_id"]) > 0)
1272  {
1273  foreach ($_POST["q_id"] as $key => $value)
1274  {
1275  $this->object->copyToClipboard($value);
1276  }
1277  ilUtil::sendInfo($this->lng->txt("qpl_copy_insert_clipboard"), true);
1278  }
1279  else
1280  {
1281  ilUtil::sendInfo($this->lng->txt("qpl_copy_select_none"), true);
1282  }
1283  $this->ctrl->redirect($this, "questions");
1284  }
1285 
1289  function moveObject()
1290  {
1291  if (count($_POST["q_id"]) > 0)
1292  {
1293  foreach ($_POST["q_id"] as $key => $value)
1294  {
1295  $this->object->moveToClipboard($value);
1296  }
1297  ilUtil::sendInfo($this->lng->txt("qpl_move_insert_clipboard"), true);
1298  }
1299  else
1300  {
1301  ilUtil::sendInfo($this->lng->txt("qpl_move_select_none"), true);
1302  }
1303  $this->ctrl->redirect($this, "questions");
1304  }
1305 
1306  /*
1307  * list all export files
1308  */
1309  function exportObject()
1310  {
1311  global $tree;
1312 
1313  //add template for view button
1314  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.il_as_qpl_export.html", "Modules/TestQuestionPool");
1315 
1316  // create export file button
1317  $this->tpl->setCurrentBlock("exporttype");
1318  $this->tpl->setVariable("VALUE_EXPORTTYPE", "xml");
1319  $this->tpl->setVariable("TEXT_EXPORTTYPE", $this->lng->txt("qpl_export_xml"));
1320  $this->tpl->parseCurrentBlock();
1321  $this->tpl->setCurrentBlock("exporttype");
1322  $this->tpl->setVariable("VALUE_EXPORTTYPE", "xls");
1323  $this->tpl->setVariable("TEXT_EXPORTTYPE", $this->lng->txt("qpl_export_excel"));
1324  $this->tpl->parseCurrentBlock();
1325  $this->tpl->setCurrentBlock("buttons");
1326  $this->tpl->setVariable("FORMACTION_BUTTONS", $this->ctrl->getFormAction($this));
1327  $this->tpl->setVariable("BTN_CREATE", $this->lng->txt("create"));
1328  $this->tpl->parseCurrentBlock();
1329 
1330  $export_dir = $this->object->getExportDirectory();
1331  $export_files = $this->object->getExportFiles($export_dir);
1332 
1333  // create table
1334  include_once("./Services/Table/classes/class.ilTableGUI.php");
1335  $tbl = new ilTableGUI();
1336 
1337  // load files templates
1338  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
1339 
1340  // load template for table content data
1341  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", "Modules/TestQuestionPool");
1342 
1343  $num = 0;
1344 
1345  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1346 
1347  $tbl->setTitle($this->lng->txt("ass_export_files"));
1348 
1349  $tbl->setHeaderNames(array("", $this->lng->txt("ass_file"),
1350  $this->lng->txt("ass_size"), $this->lng->txt("date") ));
1351  $tbl->enabled["sort"] = false;
1352  $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
1353 
1354  // control
1355  $tbl->setOrderColumn($_GET["sort_by"]);
1356  $tbl->setOrderDirection($_GET["sort_order"]);
1357  $tbl->setLimit($_GET["limit"]);
1358  $tbl->setOffset($_GET["offset"]);
1359  $header_params = $this->ctrl->getParameterArray($this, "export");
1360  $tbl->setHeaderVars(array("", "file", "size", "date"), $header_params);
1361 
1362  // footer
1363  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1364  //$tbl->disable("footer");
1365 
1366  $tbl->setMaxCount(count($export_files));
1367  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
1368 
1369  $tbl->render();
1370  include_once "./Services/Utilities/classes/class.ilUtil.php";
1371  if(count($export_files) > 0)
1372  {
1373  $this->tpl->setVariable("COLUMN_COUNTS", 4);
1374 
1375  $i=0;
1376  foreach($export_files as $exp_file)
1377  {
1378  $this->tpl->setCurrentBlock("tbl_content");
1379  $this->tpl->setVariable("TXT_FILENAME", $exp_file);
1380 
1381  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
1382  $this->tpl->setVariable("CSS_ROW", $css_row);
1383 
1384  $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
1385  $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
1386 
1387  $file_arr = explode("__", $exp_file);
1388  $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
1389 
1390  $this->tpl->parseCurrentBlock();
1391  }
1392  $this->tpl->setCurrentBlock("selectall");
1393  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
1394  $this->tpl->setVariable("CSS_ROW", $css_row);
1395  $this->tpl->parseCurrentBlock();
1396 
1397  // delete button
1398  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1399  $this->tpl->setCurrentBlock("tbl_action_btn");
1400  $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
1401  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
1402  $this->tpl->parseCurrentBlock();
1403 
1404  $this->tpl->setCurrentBlock("tbl_action_btn");
1405  $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
1406  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
1407  $this->tpl->parseCurrentBlock();
1408  } //if is_array
1409  else
1410  {
1411  $this->tpl->setCurrentBlock("notfound");
1412  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1413  $this->tpl->setVariable("NUM_COLS", 3);
1414  $this->tpl->parseCurrentBlock();
1415  }
1416 
1417  $this->tpl->parseCurrentBlock();
1418  }
1419 
1420 
1425  {
1426  global $rbacsystem;
1427  if ($rbacsystem->checkAccess("write", $this->ref_id))
1428  {
1429  include_once("./Modules/TestQuestionPool/classes/class.ilQuestionpoolExport.php");
1430  $question_ids =& $this->object->getAllQuestionIds();
1431  $qpl_exp = new ilQuestionpoolExport($this->object, $_POST["exporttype"], $question_ids);
1432  $qpl_exp->buildExportFile();
1433  $this->ctrl->redirect($this, "export");
1434  }
1435  else
1436  {
1437  ilUtil::sendInfo("cannot_export_qpl", TRUE);
1438  $this->ctrl->redirect($this, "export");
1439  }
1440  }
1441 
1446  {
1447  if(!isset($_POST["file"]))
1448  {
1449  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
1450  $this->ctrl->redirect($this, "export");
1451  }
1452 
1453  if (count($_POST["file"]) > 1)
1454  {
1455  ilUtil::sendInfo($this->lng->txt("cont_select_max_one_item"), true);
1456  $this->ctrl->redirect($this, "export");
1457  }
1458 
1459 
1460  $export_dir = $this->object->getExportDirectory();
1461  include_once "./Services/Utilities/classes/class.ilUtil.php";
1462  ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
1463  $_POST["file"][0]);
1464  $this->ctrl->redirect($this, "export");
1465  }
1466 
1471  {
1472  if(!isset($_POST["file"]))
1473  {
1474  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
1475  $this->ctrl->redirect($this, "export");
1476  }
1477 
1478  // SAVE POST VALUES
1479  $_SESSION["ilExportFiles"] = $_POST["file"];
1480 
1481  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/TestQuestionPool");
1482 
1483  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
1484 
1485  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1486 
1487  // BEGIN TABLE HEADER
1488  $this->tpl->setCurrentBlock("table_header");
1489  $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
1490  $this->tpl->parseCurrentBlock();
1491 
1492  // BEGIN TABLE DATA
1493  $counter = 0;
1494  include_once "./Services/Utilities/classes/class.ilUtil.php";
1495  foreach($_POST["file"] as $file)
1496  {
1497  $this->tpl->setCurrentBlock("table_row");
1498  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
1499  $this->tpl->setVariable("TEXT_CONTENT", $file);
1500  $this->tpl->parseCurrentBlock();
1501  }
1502 
1503  // cancel/confirm button
1504  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
1505  $buttons = array(
1506  "deleteExportFile" => $this->lng->txt("confirm"),
1507  "cancelDeleteExportFile" => $this->lng->txt("cancel")
1508  );
1509  foreach ($buttons as $name => $value)
1510  {
1511  $this->tpl->setCurrentBlock("operation_btn");
1512  $this->tpl->setVariable("BTN_NAME",$name);
1513  $this->tpl->setVariable("BTN_VALUE",$value);
1514  $this->tpl->parseCurrentBlock();
1515  }
1516  }
1517 
1518 
1523  {
1524  session_unregister("ilExportFiles");
1525  $this->ctrl->redirect($this, "export");
1526  }
1527 
1532  {
1533  include_once "./Services/Utilities/classes/class.ilUtil.php";
1534  $export_dir = $this->object->getExportDirectory();
1535  foreach($_SESSION["ilExportFiles"] as $file)
1536  {
1537  $exp_file = $export_dir."/".$file;
1538  include_once "./Services/Utilities/classes/class.ilStr.php";
1539  $exp_dir = $export_dir."/".ilStr::subStr($file, 0, ilStr::strLen($file) - 4);
1540  if (@is_file($exp_file))
1541  {
1542  unlink($exp_file);
1543  }
1544  if (@is_dir($exp_dir))
1545  {
1546  ilUtil::delDir($exp_dir);
1547  }
1548  }
1549  $this->ctrl->redirect($this, "export");
1550  }
1551 
1556  {
1557  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1558  $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1559  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
1560  }
1561 
1565  function createObject()
1566  {
1567  global $rbacsystem;
1568  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
1569  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
1570  {
1571  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1572  }
1573  else
1574  {
1575  $this->getTemplateFile("create", $new_type);
1576 
1577 
1578  $this->fillCloneTemplate('DUPLICATE','qpl');
1579  $this->tpl->setCurrentBlock("adm_content");
1580 
1581  // fill in saved values in case of error
1582  $data = array();
1583  $data["fields"] = array();
1584  include_once "./Services/Utilities/classes/class.ilUtil.php";
1585  $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
1586  $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
1587 
1588  foreach ($data["fields"] as $key => $val)
1589  {
1590  $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
1591  $this->tpl->setVariable(strtoupper($key), $val);
1592 
1593  if ($this->prepare_output)
1594  {
1595  $this->tpl->parseCurrentBlock();
1596  }
1597  }
1598 
1599  $this->ctrl->setParameter($this, "new_type", $this->type);
1600  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1601  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
1602  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
1603  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
1604  $this->tpl->setVariable("CMD_SUBMIT", "save");
1605  $this->tpl->setVariable("TARGET", ' target="'.
1606  ilFrameTargetInfo::_getFrame("MainContent").'" ');
1607  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
1608 
1609  $this->tpl->setVariable("TXT_IMPORT_QPL", $this->lng->txt("import_qpl"));
1610  $this->tpl->setVariable("TXT_QPL_FILE", $this->lng->txt("qpl_upload_file"));
1611  $this->tpl->setVariable("NEW_TYPE", $this->type);
1612  $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
1613 
1614  $this->tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_qpl.gif'));
1615  $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_qpl"));
1616  $this->tpl->setVariable("TYPE_IMG2", ilUtil::getImagePath('icon_qpl.gif'));
1617  $this->tpl->setVariable("ALT_IMG2",$this->lng->txt("obj_qpl"));
1618 
1619  $this->tpl->parseCurrentBlock();
1620  }
1621  }
1622 
1626  function importFileObject()
1627  {
1628  if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
1629  {
1630  ilUtil::sendInfo($this->lng->txt("qpl_select_file_for_import"));
1631  $this->createObject();
1632  return;
1633  }
1634  $this->uploadQplObject();
1635  }
1636 
1637  function addLocatorItems()
1638  {
1639  global $ilLocator;
1640  switch ($this->ctrl->getCmd())
1641  {
1642  case "create":
1643  case "importFile":
1644  case "cancel":
1645  break;
1646  default:
1647  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
1648  break;
1649  }
1650  if ($_GET["q_id"] > 0)
1651  {
1652  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1653  $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1654  $q_gui->object->setObjId($this->object->getId());
1655  if ($_GET["q_id"] > 0)
1656  {
1657  $ilLocator->addItem($q_gui->object->getTitle(), $this->ctrl->getLinkTargetByClass(get_class($q_gui), "editQuestion"));
1658  }
1659  }
1660  }
1661 
1666  {
1667  if ($_GET["q_id"] > 0)
1668  {
1669  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
1670  $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1671  $q_gui->object->setObjId($this->object->getId());
1672  $title = $q_gui->object->getTitle();
1673  if (strcmp($this->ctrl->getCmd(), "assessment") == 0)
1674  {
1675  $title .= " - " . $this->lng->txt("statistics");
1676  }
1677  $this->tpl->setTitle($title);
1678  $this->tpl->setDescription($q_gui->object->getComment());
1679  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif"), $this->lng->txt("obj_qpl"));
1680  }
1681  else
1682  {
1683  $this->tpl->setTitle($this->object->getTitle());
1684  $this->tpl->setDescription($this->object->getLongDescription());
1685  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif"), $this->lng->txt("obj_qpl"));
1686  }
1687  }
1688 
1689  function getEmbeddedTabs(&$tabs_gui)
1690  {
1691  global $rbacsystem;
1692  $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
1693  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1694  $q_type = assQuestion::getQuestionTypeFromDb($_GET["q_id"]);
1695 
1696  if (strlen($q_type))
1697  {
1698  $classname = $q_type . "GUI";
1699  $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
1700  $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
1701  }
1702 
1703  if ($_GET["q_id"])
1704  {
1705  if ($rbacsystem->checkAccess('write', $this->ref_id))
1706  {
1707  // edit page
1708  $tabs_gui->addTarget("edit_content",
1709  $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "edit"),
1710  array("edit", "insert", "exec_pg"),
1711  "", "", $force_active);
1712  }
1713 
1714  // edit page
1715  $tabs_gui->addTarget("preview",
1716  $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "preview"),
1717  array("preview"),
1718  "ilPageObjectGUI", "", $force_active);
1719  }
1720 
1721  $force_active = false;
1722  $commands = $_POST["cmd"];
1723  if (is_array($commands))
1724  {
1725  foreach ($commands as $key => $value)
1726  {
1727  if (preg_match("/^delete_.*/", $key, $matches) ||
1728  preg_match("/^addSelectGap_.*/", $key, $matches) ||
1729  preg_match("/^addTextGap_.*/", $key, $matches) ||
1730  preg_match("/^deleteImage_.*/", $key, $matches) ||
1731  preg_match("/^upload_.*/", $key, $matches) ||
1732  preg_match("/^addSuggestedSolution_.*/", $key, $matches)
1733  )
1734  {
1735  $force_active = true;
1736  }
1737  }
1738  }
1739  if (array_key_exists("imagemap_x", $_POST))
1740  {
1741  $force_active = true;
1742  }
1743  if ($rbacsystem->checkAccess('write', $this->ref_id))
1744  {
1745  $url = "";
1746  if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
1747  // edit question properties
1748  $tabs_gui->addTarget("edit_properties",
1749  $url,
1750  array("questions", "filter", "resetFilter", "createQuestion",
1751  "importQuestions", "deleteQuestions",
1752  "view", "preview", "editQuestion", "exec_pg",
1753  "addItem", "upload", "save", "cancel", "addSuggestedSolution",
1754  "cancelExplorer", "linkChilds", "removeSuggestedSolution",
1755  "add", "addYesNo", "addTrueFalse", "createGaps", "saveEdit",
1756  "setMediaMode", "uploadingImage", "uploadingImagemap", "addArea",
1757  "deletearea", "saveShape", "back", "addPair", "uploadingJavaapplet",
1758  "addParameter", "addGIT", "addST", "addPG", "delete",
1759  "editMode", "deleteAnswer", "deleteImage", "changeGapType"),
1760  $classname, "", $force_active);
1761  }
1762 
1763  if ($_GET["q_id"])
1764  {
1765  $tabs_gui->addTarget("feedback",
1766  $this->ctrl->getLinkTargetByClass($classname, "feedback"),
1767  array("feedback", "saveFeedback"),
1768  $classname, "");
1769  }
1770 
1771  // Assessment of questions sub menu entry
1772  if ($_GET["q_id"])
1773  {
1774  $tabs_gui->addTarget("statistics",
1775  $this->ctrl->getLinkTargetByClass($classname, "assessment"),
1776  array("assessment"),
1777  $classname, "");
1778  }
1779  if (($_GET["calling_test"] > 0) || ($_GET["test_ref_id"] > 0))
1780  {
1781  $ref_id = $_GET["calling_test"];
1782  if (strlen($ref_id) == 0) $ref_id = $_GET["test_ref_id"];
1783  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
1784  }
1785  else
1786  {
1787  $tabs_gui->setBackTarget($this->lng->txt("qpl"), $this->ctrl->getLinkTarget($this, "questions"));
1788  }
1789  }
1790 
1796  function getTabs(&$tabs_gui)
1797  {
1798  global $ilAccess;
1799 
1800  $next_class = $this->ctrl->getNextClass($this);
1801  switch ($next_class)
1802  {
1803  case "":
1804  case "ilpermissiongui":
1805  case "ilmdeditorgui":
1806  break;
1807  default:
1808  return;
1809  break;
1810  }
1811  // questions
1812  $force_active = false;
1813  $commands = $_POST["cmd"];
1814  if (is_array($commands))
1815  {
1816  foreach ($commands as $key => $value)
1817  {
1818  if (preg_match("/^delete_.*/", $key, $matches) ||
1819  preg_match("/^addSelectGap_.*/", $key, $matches) ||
1820  preg_match("/^addTextGap_.*/", $key, $matches) ||
1821  preg_match("/^deleteImage_.*/", $key, $matches) ||
1822  preg_match("/^upload_.*/", $key, $matches) ||
1823  preg_match("/^addSuggestedSolution_.*/", $key, $matches)
1824  )
1825  {
1826  $force_active = true;
1827  }
1828  }
1829  }
1830  if (array_key_exists("imagemap_x", $_POST))
1831  {
1832  $force_active = true;
1833  }
1834  if (!$force_active)
1835  {
1836  $force_active = ((strtolower($this->ctrl->getCmdClass()) == strtolower(get_class($this)) || strlen($this->ctrl->getCmdClass()) == 0) &&
1837  $this->ctrl->getCmd() == "")
1838  ? true
1839  : false;
1840  }
1841  $tabs_gui->addTarget("assQuestions",
1842  $this->ctrl->getLinkTarget($this, "questions"),
1843  array("questions", "filter", "resetFilter", "createQuestion",
1844  "importQuestions", "deleteQuestions",
1845  "view", "preview", "editQuestion", "exec_pg",
1846  "addItem", "upload", "save", "cancel", "addSuggestedSolution",
1847  "cancelExplorer", "linkChilds", "removeSuggestedSolution",
1848  "add", "addYesNo", "addTrueFalse", "createGaps", "saveEdit",
1849  "setMediaMode", "uploadingImage", "uploadingImagemap", "addArea",
1850  "deletearea", "saveShape", "back", "addPair", "uploadingJavaapplet",
1851  "addParameter", "assessment", "addGIT", "addST", "addPG", "delete",
1852  "toggleGraphicalAnswers", "deleteAnswer", "deleteImage", "removeJavaapplet"),
1853  "", "", $force_active);
1854 
1855  // properties
1856  $tabs_gui->addTarget("properties",
1857  $this->ctrl->getLinkTarget($this,'properties'),
1858  "properties", "",
1859  "");
1860 
1861  global $rbacsystem;
1862  if ($rbacsystem->checkAccess("write", $this->ref_id))
1863  {
1864  // meta data
1865  $tabs_gui->addTarget("meta_data",
1866  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
1867  "", "ilmdeditorgui");
1868  }
1869 
1870  // print view
1871  $tabs_gui->addTarget("print_view",
1872  $this->ctrl->getLinkTarget($this,'print'),
1873  array("print"),
1874  "", "");
1875 
1876  // export
1877  $tabs_gui->addTarget("export",
1878  $this->ctrl->getLinkTarget($this,'export'),
1879  array("export", "createExportFile", "confirmDeleteExportFile", "downloadExportFile"),
1880  "", "");
1881 
1882  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
1883  {
1884  $tabs_gui->addTarget("perm_settings",
1885  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1886  }
1887  }
1888 
1897  function _goto($a_target)
1898  {
1899  global $ilAccess, $ilErr, $lng;
1900 
1901  if ($ilAccess->checkAccess("write", "", $a_target))
1902  {
1903  $_GET["baseClass"] = "ilObjQuestionPoolGUI";
1904  $_GET["cmd"] = "questions";
1905  $_GET["ref_id"] = $a_target;
1906  include_once("ilias.php");
1907  exit;
1908  }
1909  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1910  {
1911  $_GET["cmd"] = "frameset";
1912  $_GET["target"] = "";
1913  $_GET["ref_id"] = ROOT_FOLDER_ID;
1914  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
1915  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1916  include("repository.php");
1917  exit;
1918  }
1919  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
1920  }
1921 
1922 } // END class.ilObjQuestionPoolGUI
1923 ?>