ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjTestGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once './Modules/Test/exceptions/class.ilTestException.php';
5 require_once './Services/Object/classes/class.ilObjectGUI.php';
6 require_once './Modules/Test/classes/inc.AssessmentConstants.php';
7 require_once './Modules/Test/classes/class.ilObjAssessmentFolderGUI.php';
8 require_once './Modules/Test/classes/class.ilObjAssessmentFolder.php';
9 require_once './Modules/Test/classes/class.ilTestExpressPage.php';
10 
49 {
50  private static $infoScreenChildClasses = array(
51  'ilpublicuserprofilegui', 'ilobjportfoliogui'
52  );
53 
55  public $object = null;
56 
59 
61  private $testPlayerFactory = null;
62 
64  private $testSessionFactory = null;
65 
67  private $testSequenceFactory = null;
68 
73 
78  public function __construct()
79  {
80  global $lng, $ilCtrl, $ilDB, $ilPluginAdmin, $tree;
81  $lng->loadLanguageModule("assessment");
82  $this->type = "tst";
83  $this->ctrl = $ilCtrl;
84  $this->ctrl->saveParameter($this, array("ref_id", "test_ref_id", "calling_test", "test_express_mode", "q_id"));
85  parent::__construct("",$_GET["ref_id"], true, false);
86 
87  if( $this->object instanceof ilObjTest )
88  {
89  require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
90  $this->testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $this->object);
91 
92  require_once 'Modules/Test/classes/class.ilTestPlayerFactory.php';
93  $this->testPlayerFactory = new ilTestPlayerFactory($this->object);
94 
95  require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
96  $this->testSessionFactory = new ilTestSessionFactory($this->object);
97 
98  require_once 'Modules/Test/classes/class.ilTestSequenceFactory.php';
99  $this->testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $ilPluginAdmin, $this->object);
100  }
101 
102  require_once 'Modules/Test/classes/class.ilTestObjectiveOrientedContainer.php';
103  $this->objectiveOrientedContainer = new ilTestObjectiveOrientedContainer();
104  }
105 
109  function executeCommand()
110  {
111  global $ilAccess, $ilNavigationHistory, $ilCtrl, $ilErr, $tpl, $lng, $ilTabs, $ilPluginAdmin, $ilDB, $tree, $ilias, $ilUser;
112 
113  if((!$ilAccess->checkAccess("read", "", $_GET["ref_id"])))
114  {
115  $ilias->raiseError($this->lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
116  }
117 
118  $cmd = $this->ctrl->getCmd("infoScreen");
119 
120  $cmdsDisabledDueToOfflineStatus = array(
121  'resumePlayer', 'resumePlayer', 'outUserResultsOverview', 'outUserListOfAnswerPasses'
122  );
123 
124  if(!$this->getCreationMode() && !$this->object->isOnline() && in_array($cmd, $cmdsDisabledDueToOfflineStatus))
125  {
126  $cmd = 'infoScreen';
127  }
128 
129  $next_class = $this->ctrl->getNextClass($this);
130  $this->ctrl->setReturn($this, "infoScreen");
131 
132  if(method_exists($this->object, "getTestStyleLocation")) $this->tpl->addCss($this->object->getTestStyleLocation("output"), "screen");
133 
134  // add entry to navigation history
135  if(!$this->getCreationMode() &&
136  $ilAccess->checkAccess("read", "", $_GET["ref_id"])
137  )
138  {
139  $ilNavigationHistory->addItem($_GET["ref_id"],
140  "ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=" . $_GET["ref_id"], "tst");
141  }
142 
143  // elba hack for storing question id for inserting new question after
144  if($_REQUEST['prev_qid'])
145  {
146  global $___prev_question_id;
147  $___prev_question_id = $_REQUEST['prev_qid'];
148  $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
149  }
150 
151  if( !$this->getCreationMode() && $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken() )
152  {
153  if( !$this->testQuestionSetConfigFactory->getQuestionSetConfig()->isValidRequestOnBrokenQuestionSetDepencies($next_class, $cmd) )
154  {
155  $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
156  }
157  }
158 
160 
161  switch($next_class)
162  {
163  case 'iltestexportgui':
164  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
165  {
166  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
167  }
168 
169  $this->prepareOutput();
170  $this->addHeaderAction();
171  require_once 'Modules/Test/classes/class.ilTestExportGUI.php';
172  $ilCtrl->forwardCommand(new ilTestExportGUI($this));
173  break;
174 
175  case "ilinfoscreengui":
176  $this->prepareOutput();
177  $this->addHeaderAction();
178  $this->infoScreen(); // forwards command
179  break;
180  case 'ilobjectmetadatagui':
181  if(!$ilAccess->checkAccess('write', '', $this->object->getRefId()))
182  {
183  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
184  }
185 
186  $this->prepareOutput();
187  $this->addHeaderAction();
188  include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
189  $md_gui = new ilObjectMetaDataGUI($this->object);
190  $this->ctrl->forwardCommand($md_gui);
191  break;
192 
193  case "iltestplayerfixedquestionsetgui":
194  $this->trackTestObjectReadEvent();
195  require_once "./Modules/Test/classes/class.ilTestPlayerFixedQuestionSetGUI.php";
196  if(!$this->object->getKioskMode()) $this->prepareOutput();
197  $gui = new ilTestPlayerFixedQuestionSetGUI($this->object);
198  $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
199  $this->ctrl->forwardCommand($gui);
200  break;
201 
202  case "iltestplayerrandomquestionsetgui":
203  $this->trackTestObjectReadEvent();
204  require_once "./Modules/Test/classes/class.ilTestPlayerRandomQuestionSetGUI.php";
205  if(!$this->object->getKioskMode()) $this->prepareOutput();
206  $gui = new ilTestPlayerRandomQuestionSetGUI($this->object);
207  $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
208  $this->ctrl->forwardCommand($gui);
209  break;
210 
211  case "iltestplayerdynamicquestionsetgui":
212  $this->trackTestObjectReadEvent();
213  require_once "./Modules/Test/classes/class.ilTestPlayerDynamicQuestionSetGUI.php";
214  if (!$this->object->getKioskMode()) $this->prepareOutput();
215  $gui = new ilTestPlayerDynamicQuestionSetGUI($this->object);
216  $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
217  $this->ctrl->forwardCommand($gui);
218  break;
219 
220  case "iltestevaluationgui":
221  $this->forwardToEvaluationGUI();
222  break;
223 
224  case "iltestevalobjectiveorientedgui":
226  break;
227 
228  case "iltestservicegui":
229  $this->prepareOutput();
230  $this->addHeaderAction();
231  require_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
232  $serviceGUI = new ilTestServiceGUI($this->object);
233  $this->ctrl->forwardCommand($serviceGUI);
234  break;
235 
236  case 'ilpermissiongui':
237  $this->prepareOutput();
238  $this->addHeaderAction();
239  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
240  $perm_gui = new ilPermissionGUI($this);
241  $ret = $this->ctrl->forwardCommand($perm_gui);
242  break;
243 
244  case "illearningprogressgui":
245  $this->prepareOutput();
246  $this->addHeaderAction();
247  require_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
249  $this->ctrl->forwardCommand($new_gui);
250 
251  break;
252 
253  case "ilcertificategui":
254  $this->prepareOutput();
255  $this->addHeaderAction();
256  require_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
257  require_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
258  $output_gui = new ilCertificateGUI(new ilTestCertificateAdapter($this->object));
259  $this->ctrl->forwardCommand($output_gui);
260  break;
261 
262  case "iltestscoringgui":
263  $this->prepareOutput();
264  $this->addHeaderAction();
265  require_once "./Modules/Test/classes/class.ilTestScoringGUI.php";
266  $output_gui = new ilTestScoringGUI($this->object);
267  $this->ctrl->forwardCommand($output_gui);
268  break;
269 
270  case 'ilmarkschemagui':
271  if(!$ilAccess->checkAccess('write', '', $this->object->getRefId()))
272  {
273  ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true);
274  $this->ctrl->redirect($this, 'infoScreen');
275  }
276  $this->prepareOutput();
277  $this->addHeaderAction();
278  require_once 'Modules/Test/classes/class.ilMarkSchemaGUI.php';
279  $mark_schema_gui = new ilMarkSchemaGUI($this->object);
280  $this->ctrl->forwardCommand($mark_schema_gui);
281  break;
282 
283  case 'iltestscoringbyquestionsgui':
284  $this->prepareOutput();
285  $this->addHeaderAction();
286  include_once 'Modules/Test/classes/class.ilTestScoringByQuestionsGUI.php';
287  $output_gui = new ilTestScoringByQuestionsGUI($this->object);
288  $this->ctrl->forwardCommand($output_gui);
289  break;
290 
291  case 'ilobjtestsettingsgeneralgui':
292  $this->prepareOutput();
293  $this->addHeaderAction();
294  require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
295  $gui = new ilObjTestSettingsGeneralGUI(
296  $this->ctrl, $ilAccess, $this->lng, $this->tpl, $this->tree, $ilDB, $ilPluginAdmin, $ilUser, $this
297  );
298  $this->ctrl->forwardCommand($gui);
299  break;
300 
301  case 'ilobjtestsettingsscoringresultsgui':
302  $this->prepareOutput();
303  $this->addHeaderAction();
304  require_once 'Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php';
306  $this->ctrl, $ilAccess, $this->lng, $this->tpl, $this->tree, $ilDB, $ilPluginAdmin, $this
307  );
308  $this->ctrl->forwardCommand($gui);
309  break;
310 
311  case 'ilobjtestdynamicquestionsetconfiggui':
312  $this->prepareOutput();
313  $this->addHeaderAction();
314  require_once 'Modules/Test/classes/class.ilObjTestDynamicQuestionSetConfigGUI.php';
315  $gui = new ilObjTestDynamicQuestionSetConfigGUI($this->ctrl, $ilAccess, $ilTabs, $this->lng, $this->tpl, $ilDB, $tree, $ilPluginAdmin, $this->object);
316  $this->ctrl->forwardCommand($gui);
317  break;
318 
319  case 'iltestrandomquestionsetconfiggui':
320  $this->prepareOutput();
321  $this->addHeaderAction();
322  require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetConfigGUI.php';
323  $gui = new ilTestRandomQuestionSetConfigGUI($this->ctrl, $ilAccess, $ilTabs, $this->lng, $this->tpl, $ilDB, $tree, $ilPluginAdmin, $this->object);
324  $this->ctrl->forwardCommand($gui);
325  break;
326 
327  case 'iltestquestionbrowsertablegui':
328  $this->prepareOutput();
329  $this->addHeaderAction();
330  require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php';
331  $gui = new ilTestQuestionBrowserTableGUI($this->ctrl, $this->tpl, $ilTabs, $this->lng, $tree, $ilDB, $ilPluginAdmin, $this->object, $ilAccess);
332  $gui->setWriteAccess($ilAccess->checkAccess("write", "", $this->ref_id));
333  $gui->init();
334  $this->ctrl->forwardCommand($gui);
335  break;
336 
337  case 'iltestskilladministrationgui':
338  $this->prepareOutput();
339  $this->addHeaderAction();
340  require_once 'Modules/Test/classes/class.ilTestSkillAdministrationGUI.php';
341  $gui = new ilTestSkillAdministrationGUI($ilias, $this->ctrl, $ilAccess, $ilTabs, $this->tpl, $this->lng, $ilDB, $tree, $ilPluginAdmin, $this->object, $this->ref_id);
342  $this->ctrl->forwardCommand($gui);
343  break;
344 
345  case 'iltestskillevaluationgui':
346  $this->prepareOutput();
347  $this->addHeaderAction();
348 
349  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
350  if( $this->object->isDynamicTest() )
351  {
352  require_once 'Modules/Test/classes/class.ilObjTestDynamicQuestionSetConfig.php';
353  $dynamicQuestionSetConfig = new ilObjTestDynamicQuestionSetConfig($tree, $ilDB, $ilPluginAdmin, $this->object);
354  $dynamicQuestionSetConfig->loadFromDb();
355  $questionList = new ilAssQuestionList($ilDB, $this->lng, $ilPluginAdmin);
356  $questionList->setParentObjId($dynamicQuestionSetConfig->getSourceQuestionPoolId());
357  $questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_ORIGINALS);
358  }
359  else
360  {
361  $questionList = new ilAssQuestionList($ilDB, $this->lng, $ilPluginAdmin);
362  $questionList->setParentObjId($this->object->getId());
363  $questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_DUPLICATES);
364  }
365  $questionList->load();
366 
367  require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
368  $testSessionFactory = new ilTestSessionFactory($this->object);
369  $testSession = $testSessionFactory->getSession();
370 
371  require_once 'Modules/Test/classes/class.ilTestSkillEvaluationGUI.php';
372  $gui = new ilTestSkillEvaluationGUI($this->ctrl, $ilTabs, $this->tpl, $this->lng, $ilDB, $this->object);
373  $gui->setQuestionList($questionList);
374  $gui->setTestSession($testSession);
375  $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
376  $this->ctrl->forwardCommand($gui);
377  break;
378 
379  case 'ilobjectcopygui':
380  $this->prepareOutput();
381  $this->addHeaderAction();
382  require_once './Services/Object/classes/class.ilObjectCopyGUI.php';
383  $cp = new ilObjectCopyGUI($this);
384  $cp->setType('tst');
385  $this->ctrl->forwardCommand($cp);
386  break;
387 
388  case 'ilrepositorysearchgui':
389  $this->prepareOutput();
390  $this->addHeaderAction();
391  require_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
392  $rep_search = new ilRepositorySearchGUI();
393  $rep_search->setCallback($this,
394  'addParticipantsObject',
395  array()
396  );
397 
398  // Set tabs
399  $this->ctrl->setReturn($this, 'participants');
400  $ret =& $this->ctrl->forwardCommand($rep_search);
401  $this->tabs_gui->setTabActive('participants');
402  break;
403 
404  case 'ilpageeditorgui':
405  case 'iltestexpresspageobjectgui':
406 
407  require_once 'Modules/TestQuestionPool/classes/class.ilAssIncompleteQuestionPurger.php';
408  $incompleteQuestionPurger = new ilAssIncompleteQuestionPurger($ilDB);
409  $incompleteQuestionPurger->setOwnerId($ilUser->getId());
410  $incompleteQuestionPurger->purge();
411 
412  try
413  {
414  $qid = $this->fetchAuthoringQuestionIdParameter();
415  }
416  catch(ilTestException $e)
417  {
418  $qid = 0;
419  }
420 
421  $this->prepareOutput();
422  if(!in_array($cmd, array('addQuestion', 'browseForQuestions')))
423  {
424  $this->buildPageViewToolbar($qid);
425  }
426 
427  if(!$qid || in_array($cmd, array('insertQuestions', 'browseForQuestions')))
428  {
429  require_once "./Modules/Test/classes/class.ilTestExpressPageObjectGUI.php";
430  $pageObject = new ilTestExpressPageObjectGUI (0);
431  $pageObject->test_object = $this->object;
432  $ret =& $this->ctrl->forwardCommand($pageObject);
433  break;
434  }
435  require_once "./Services/Style/Content/classes/class.ilObjStyleSheet.php";
436  $this->tpl->setCurrentBlock("ContentStyle");
437  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
439  $this->tpl->parseCurrentBlock();
440 
441  // syntax style
442  $this->tpl->setCurrentBlock("SyntaxStyle");
443  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
445  $this->tpl->parseCurrentBlock();
446  require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
447 
448  $q_gui = assQuestionGUI::_getQuestionGUI("", $qid);
449  if(!($q_gui instanceof assQuestionGUI))
450  {
451  $this->ctrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', '');
452  $this->ctrl->redirectByClass('iltestexpresspageobjectgui', $this->ctrl->getCmd());
453  }
454 
455  $q_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
456 
457  $q_gui->outAdditionalOutput();
458  $q_gui->object->setObjId($this->object->getId());
459 
460  $q_gui->setTargetGuiClass(null);
461  $q_gui->setQuestionActionCmd(null);
462 
463  $question = $q_gui->object;
464  $this->ctrl->saveParameter($this, "q_id");
465 
466  #$this->lng->loadLanguageModule("content");
467  $this->ctrl->setReturnByClass("ilTestExpressPageObjectGUI", "view");
468  $this->ctrl->setReturn($this, "questions");
469 
470  require_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php";
471  require_once "./Modules/Test/classes/class.ilTestExpressPageObjectGUI.php";
472 
473  $page_gui = new ilTestExpressPageObjectGUI($qid);
474  $page_gui->test_object = $this->object;
475  $page_gui->setEditPreview(true);
476  $page_gui->setEnabledTabs(false);
477  if(strlen($this->ctrl->getCmd()) == 0)
478  {
479  $this->ctrl->setCmdClass(get_class($page_gui));
480  $this->ctrl->setCmd("preview");
481  }
482 
483  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(TRUE)));
484  $page_gui->setTemplateTargetVar("ADM_CONTENT");
485 
486  $page_gui->setOutputMode($this->object->evalTotalPersons() == 0 ? "edit" : 'preview');
487 
488  $page_gui->setHeader($question->getTitle());
489  $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
490  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "fullscreen"));
491  $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this));
492  $page_gui->setPresentationTitle($question->getTitle() . ' ['. $this->lng->txt('question_id_short') . ': ' . $question->getId() . ']');
493  $ret =& $this->ctrl->forwardCommand($page_gui);
494 
495  global $ilTabs;
496  $ilTabs->activateTab('assQuestions');
497 
498  $this->tpl->setContent($ret);
499  break;
500 
501  case 'ilassquestionpreviewgui':
502 
503  $this->prepareOutput();
504 
505  $this->ctrl->saveParameter($this, "q_id");
506 
507  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewGUI.php';
508  $gui = new ilAssQuestionPreviewGUI($this->ctrl, $this->tabs_gui, $this->tpl, $this->lng, $ilDB, $ilUser);
509 
510  $gui->initQuestion($this->fetchAuthoringQuestionIdParameter(), $this->object->getId());
511  $gui->initPreviewSettings($this->object->getRefId());
512  $gui->initPreviewSession($ilUser->getId(), (int)$_GET['q_id']);
513  $gui->initHintTracking();
514  $gui->initStyleSheets();
515 
516  $this->ctrl->forwardCommand($gui);
517 
518  break;
519 
520  case 'ilassquestionpagegui':
521 
522  $_GET['q_id'] = $this->fetchAuthoringQuestionIdParameter();
523 
524  require_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php";
525  //echo $_REQUEST['prev_qid'];
526  if($_REQUEST['prev_qid'])
527  {
528  $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
529  }
530 
531  $this->prepareOutput();
532  //global $___test_express_mode;
533  //$___test_express_mode = true;
534  $_GET['calling_test'] = $this->object->getRefId();
535  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
536  $this->tpl->setCurrentBlock("ContentStyle");
537  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
539  $this->tpl->parseCurrentBlock();
540 
541  // syntax style
542  $this->tpl->setCurrentBlock("SyntaxStyle");
543  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
545  $this->tpl->parseCurrentBlock();
546  require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
547  $q_gui = assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
548  $q_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
549  $q_gui->setQuestionTabs();
550  $q_gui->outAdditionalOutput();
551  $q_gui->object->setObjId($this->object->getId());
552  $question =& $q_gui->object;
553  $this->ctrl->saveParameter($this, "q_id");
554  $this->lng->loadLanguageModule("content");
555  $this->ctrl->setReturnByClass("ilAssQuestionPageGUI", "view");
556  $this->ctrl->setReturn($this, "questions");
557  $page_gui = new ilAssQuestionPageGUI($_GET["q_id"]);
558  $page_gui->setEditPreview(true);
559  if(strlen($this->ctrl->getCmd()) == 0)
560  {
561  $this->ctrl->setCmdClass(get_class($page_gui));
562  $this->ctrl->setCmd("preview");
563  }
564  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(TRUE)));
565  $page_gui->setTemplateTargetVar("ADM_CONTENT");
566  $page_gui->setOutputMode($this->object->evalTotalPersons() == 0 ? "edit" : 'preview');
567  $page_gui->setHeader($question->getTitle());
568  $page_gui->setPresentationTitle($question->getTitle() . ' ['. $this->lng->txt('question_id_short') . ': ' . $question->getId() . ']');
569  $ret =& $this->ctrl->forwardCommand($page_gui);
570  $this->tpl->setContent($ret);
571  break;
572 
573  case 'ilassspecfeedbackpagegui':
574  require_once "./Modules/TestQuestionPool/classes/feedback/class.ilAssSpecFeedbackPageGUI.php";
575  $pg_gui = new ilAssSpecFeedbackPageGUI((int) $_GET["feedback_id"]);
576  $this->ctrl->forwardCommand($pg_gui);
577  break;
578 
579  case 'ilassgenfeedbackpagegui':
580  require_once "./Modules/TestQuestionPool/classes/feedback/class.ilAssGenFeedbackPageGUI.php";
581  $pg_gui = new ilAssGenFeedbackPageGUI((int) $_GET["feedback_id"]);
582  $this->ctrl->forwardCommand($pg_gui);
583  break;
584 
585  case 'illocalunitconfigurationgui':
586  $this->prepareSubGuiOutput();
587 
588  // set return target
589  $this->ctrl->setReturn($this, "questions");
590 
591  // set context tabs
592  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
594  $questionGUI->object->setObjId($this->object->getId());
595  $questionGUI->setQuestionTabs();
596 
597  require_once 'Modules/TestQuestionPool/classes/class.ilLocalUnitConfigurationGUI.php';
598  require_once 'Modules/TestQuestionPool/classes/class.ilUnitConfigurationRepository.php';
599  $gui = new ilLocalUnitConfigurationGUI(
600  new ilUnitConfigurationRepository((int)$_GET['q_id'])
601  );
602  $this->ctrl->forwardCommand($gui);
603  break;
604 
605  case "ilcommonactiondispatchergui":
606  require_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
608  $this->ctrl->forwardCommand($gui);
609  break;
610 
611  case 'ilassquestionhintsgui':
612 
613  $this->prepareSubGuiOutput();
614 
615  // set return target
616  $this->ctrl->setReturn($this, "questions");
617 
618  // set context tabs
619  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
620  $questionGUI =& assQuestionGUI::_getQuestionGUI($q_type, $this->fetchAuthoringQuestionIdParameter());
621  $questionGUI->object->setObjId($this->object->getId());
622  $questionGUI->setQuestionTabs();
623 
624  // forward to ilAssQuestionHintsGUI
625  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsGUI.php';
626  $gui = new ilAssQuestionHintsGUI($questionGUI);
627 
628  global $DIC; /* @var ILIAS\DI\Container $DIC */
629 
630  $gui->setEditingEnabled(
631  $DIC->access()->checkAccess('write', '', $this->object->getRefId())
632  );
633 
634  $ilCtrl->forwardCommand($gui);
635 
636  break;
637 
638  case 'ilassquestionfeedbackeditinggui':
639 
640  $this->prepareSubGuiOutput();
641 
642  // set return target
643  $this->ctrl->setReturn($this, "questions");
644 
645  // set context tabs
646  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
648  $questionGUI->object->setObjId($this->object->getId());
649  $questionGUI->setQuestionTabs();
650 
651  // forward to ilAssQuestionFeedbackGUI
652  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackEditingGUI.php';
653  $gui = new ilAssQuestionFeedbackEditingGUI($questionGUI, $ilCtrl, $ilAccess, $tpl, $ilTabs, $lng);
654  $ilCtrl->forwardCommand($gui);
655 
656  break;
657 
658  case 'iltesttoplistgui':
659  $this->prepareOutput();
660  require_once './Modules/Test/classes/class.ilTestToplistGUI.php';
661  $gui = new ilTestToplistGUI($this);
662  $this->ctrl->forwardCommand($gui);
663  break;
664 
665  case 'ilscoringadjustmentgui':
666  $this->prepareOutput();
667  require_once './Modules/Test/classes/class.ilScoringAdjustmentGUI.php';
668  $gui = new ilScoringAdjustmentGUI($this->object);
669  $this->ctrl->forwardCommand($gui);
670  break;
671 
672  case '':
673  case 'ilobjtestgui':
674  $this->prepareOutput();
675  $this->addHeaderAction();
676  if((strcmp($cmd, "properties") == 0) && ($_GET["browse"]))
677  {
678  $this->questionBrowser();
679  return;
680  }
681  if((strcmp($cmd, "properties") == 0) && ($_GET["up"] || $_GET["down"]))
682  {
683  $this->questionsObject();
684  return;
685  }
686  $cmd .= "Object";
687  $ret =& $this->$cmd();
688  break;
689  default:
690  // elba hack for storing question id for inserting new question after
691  if($_REQUEST['prev_qid'])
692  {
693  global $___prev_question_id;
694  $___prev_question_id = $_REQUEST['prev_qid'];
695  $this->ctrl->setParameterByClass('ilassquestionpagegui', 'prev_qid', $_REQUEST['prev_qid']);
696  $this->ctrl->setParameterByClass($_GET['sel_question_types'] . 'gui', 'prev_qid', $_REQUEST['prev_qid']);
697  }
698  $this->create_question_mode = true;
699  $this->prepareOutput();
700 
701  $this->ctrl->setReturn($this, "questions");
702  require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
703  $q_gui =& assQuestionGUI::_getQuestionGUI($_GET['sel_question_types'], $this->fetchAuthoringQuestionIdParameter());
704  $q_gui->setEditContext(assQuestionGUI::EDIT_CONTEXT_AUTHORING);
705  $q_gui->object->setObjId($this->object->getId());
706  if(!$_GET['sel_question_types'])
707  $qType = assQuestion::getQuestionTypeFromDb($_GET['q_id']);
708  else
709  {
710  $qType = $_GET['sel_question_types'];
711  }
712  $this->ctrl->setParameterByClass($qType . "GUI", 'prev_qid', $_REQUEST['prev_qid']);
713  $this->ctrl->setParameterByClass($qType . "GUI", 'test_ref_id', $_REQUEST['ref_id']);
714  $this->ctrl->setParameterByClass($qType . "GUI", 'q_id', $_REQUEST['q_id']);
715  if($_REQUEST['test_express_mode'])
716  $this->ctrl->setParameterByClass($qType . "GUI", 'test_express_mode', 1);
717 
718  #global $___test_express_mode;
719  #$___test_express_mode = true;
720  if(!$q_gui->isSaveCommand())
721  $_GET['calling_test'] = $this->object->getRefId();
722 
723  $q_gui->setQuestionTabs();
724  #unset($___test_express_mode);
725  $ret =& $this->ctrl->forwardCommand($q_gui);
726  break;
727  }
728  if ( !in_array(strtolower($_GET["baseClass"]), array('iladministrationgui', 'ilrepositorygui')) &&
729  $this->getCreationMode() != true)
730  {
731  $this->tpl->show();
732  }
733  }
734 
735  protected function trackTestObjectReadEvent()
736  {
737  /* @var ILIAS\DI\Container $DIC */ global $DIC;
738 
739  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
740 
742  $this->object->getType(), $this->object->getRefId(),
743  $this->object->getId(), $DIC->user()->getId()
744  );
745  }
746 
751  protected function exportObject()
752  {
753  global $DIC; /* @var ILIAS\DI\Container $DIC */
754  $DIC->ctrl()->redirectByClass('ilTestExportGUI');
755  }
756 
761  {
762  $qid = $_REQUEST['q_id'];
763 
764  if (!$qid || $qid == 'Array')
765  {
766  $questions = $this->object->getQuestionTitlesAndIndexes();
767  if (!is_array($questions))
768  $questions = array();
769 
770  $keys = array_keys($questions);
771  $qid = $keys[0];
772 
773  $_REQUEST['q_id'] = $qid;
774  $_GET['q_id'] = $qid;
775  $_POST['q_id'] = $qid;
776  }
777 
778  if( $this->object->checkQuestionParent($qid) )
779  {
780  return $qid;
781  }
782 
783  throw new ilTestException('question id does not relate to parent object!');
784  }
785 
786  private function questionsTabGatewayObject()
787  {
788  switch( $this->object->getQuestionSetType() )
789  {
791  $this->ctrl->redirectByClass('ilTestExpressPageObjectGUI', 'showPage');
792 
794  $this->ctrl->redirectByClass('ilTestRandomQuestionSetConfigGUI');
795 
797  $this->ctrl->redirectByClass('ilObjTestDynamicQuestionSetConfigGUI');
798  }
799  }
800 
801  private function userResultsGatewayObject()
802  {
803  $this->ctrl->setCmdClass('ilTestEvaluationGUI');
804  $this->ctrl->setCmd('outUserResultsOverview');
805  $this->tabs_gui->clearTargets();
806 
807  $this->forwardToEvaluationGUI();
808  }
809 
810  private function forwardToEvaluationGUI()
811  {
812  $this->prepareOutput();
813  $this->addHeaderAction();
814 
815  require_once 'Modules/Test/classes/class.ilTestEvaluationGUI.php';
816  $gui = new ilTestEvaluationGUI($this->object);
817  $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
818 
819  $this->ctrl->forwardCommand($gui);
820  }
821 
823  {
824  $this->prepareOutput();
825  $this->addHeaderAction();
826 
827  require_once 'Modules/Test/classes/class.ilTestEvalObjectiveOrientedGUI.php';
828  $gui = new ilTestEvalObjectiveOrientedGUI($this->object);
829  $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
830 
831  $this->ctrl->forwardCommand($gui);
832  }
833 
842  public function createUserResults($show_pass_details, $show_answers, $show_reached_points, $show_user_results)
843  {
844  global $ilTabs, $ilDB;
845 
846  // prepare generation before contents are processed (needed for mathjax)
847  if( $this->isPdfDeliveryRequest() )
848  {
849  require_once 'Services/PDFGeneration/classes/class.ilPDFGeneration.php';
851  }
852 
853  $ilTabs->setBackTarget(
854  $this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'participants')
855  );
856 
857  if( $this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() )
858  {
859  require_once 'Services/Link/classes/class.ilLink.php';
860  $courseLink = ilLink::_getLink($this->getObjectiveOrientedContainer()->getRefId());
861  $ilTabs->setBack2Target($this->lng->txt('back_to_objective_container'), $courseLink);
862  }
863 
864  $template = new ilTemplate("tpl.il_as_tst_participants_result_output.html", TRUE, TRUE, "Modules/Test");
865 
866  require_once 'Modules/Test/classes/toolbars/class.ilTestResultsToolbarGUI.php';
867  $toolbar = new ilTestResultsToolbarGUI($this->ctrl, $this->tpl, $this->lng);
868 
869  $this->ctrl->setParameter($this, 'pdf', '1');
870  $toolbar->setPdfExportLinkTarget( $this->ctrl->getLinkTarget($this, $this->ctrl->getCmd()) );
871  $this->ctrl->setParameter($this, 'pdf', '');
872 
873  if( $show_answers )
874  {
875  if( isset($_GET['show_best_solutions']) )
876  {
877  $_SESSION['tst_results_show_best_solutions'] = true;
878  }
879  elseif( isset($_GET['hide_best_solutions']) )
880  {
881  $_SESSION['tst_results_show_best_solutions'] = false;
882  }
883  elseif( !isset($_SESSION['tst_results_show_best_solutions']) )
884  {
885  $_SESSION['tst_results_show_best_solutions'] = false;
886  }
887 
888  if( $_SESSION['tst_results_show_best_solutions'] )
889  {
890  $this->ctrl->setParameter($this, 'hide_best_solutions', '1');
891  $toolbar->setHideBestSolutionsLinkTarget($this->ctrl->getLinkTarget($this, $this->ctrl->getCmd()));
892  $this->ctrl->setParameter($this, 'hide_best_solutions', '');
893  }
894  else
895  {
896  $this->ctrl->setParameter($this, 'show_best_solutions', '1');
897  $toolbar->setShowBestSolutionsLinkTarget($this->ctrl->getLinkTarget($this, $this->ctrl->getCmd()));
898  $this->ctrl->setParameterByClass('', 'show_best_solutions', '');
899  }
900  }
901 
902  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
903  $participantData = new ilTestParticipantData($ilDB, $this->lng);
904  if( $this->object->getFixedParticipants() )
905  {
906  $participantData->setUserIds($show_user_results);
907  }
908  else
909  {
910  $participantData->setActiveIds($show_user_results);
911  }
912  $participantData->load($this->object->getTestId());
913  $toolbar->setParticipantSelectorOptions($participantData->getOptionArray($show_user_results));
914 
915  $toolbar->build();
916  $template->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
917 
918  include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
919  $serviceGUI = new ilTestServiceGUI($this->object);
920  $serviceGUI->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
921  $serviceGUI->setParticipantData($participantData);
922 
923  $count = 0;
924  foreach ($show_user_results as $key => $active_id)
925  {
926  $count++;
927  $results = "";
928  if ($this->object->getFixedParticipants())
929  {
930  $active_id = $this->object->getActiveIdOfUser( $active_id );
931  }
932  if ($active_id > 0)
933  {
934  $results = $serviceGUI->getResultsOfUserOutput(
935  $this->testSessionFactory->getSession( $active_id ),
936  $active_id,
937  $this->object->_getResultPass( $active_id ),
938  $this,
939  $show_pass_details,
940  $show_answers,
941  FALSE,
942  $show_reached_points
943  );
944  }
945  if ($count < count( $show_user_results ))
946  {
947  $template->touchBlock( "break" );
948  }
949  $template->setCurrentBlock( "user_result" );
950  $template->setVariable( "USER_RESULT", $results );
951  $template->parseCurrentBlock();
952  }
953 
954  if( $this->isPdfDeliveryRequest() )
955  {
956  require_once 'class.ilTestPDFGenerator.php';
957 
959  $template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitle()
960  );
961  }
962  else
963  {
964  return $template;
965  }
966  }
967 
969  {
970  require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
971  $this->ctrl->redirectByClass('ilObjTestSettingsGeneralGUI', ilObjTestSettingsGeneralGUI::CMD_SHOW_FORM);
972  }
973 
982  private function prepareSubGuiOutput()
983  {
984  global $ilUser;
985 
986  $this->tpl->getStandardTemplate();
987 
988  // set locator
989  $this->setLocator();
990 
991  // catch feedback message
993 
994  // set title and description and title icon
995  $this->setTitleAndDescription();
996 
997  // BEGIN WebDAV: Display Mount Webfolder icon.
998  if ($ilUser->getId() != ANONYMOUS_USER_ID)
999  {
1000  require_once ('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
1002  {
1003  $this->showMountWebfolderIcon();
1004  }
1005  }
1006  // END WebDAV: Display Mount Webfolder icon.
1007  }
1008 
1009  function runObject()
1010  {
1011  $this->ctrl->redirect($this, "infoScreen");
1012  }
1013 
1015  {
1016  $this->ctrl->redirectByClass("iltestevaluationgui", "outEvaluation");
1017  }
1018 
1022  protected function importFileObject($parent_id = null, $a_catch_errors = true)
1023  {
1024  $form = $this->initImportForm($_REQUEST["new_type"]);
1025  if($form->checkInput())
1026  {
1027  $this->ctrl->setParameter($this, "new_type", $this->type);
1028  $this->uploadTstObject();
1029  }
1030 
1031  // display form to correct errors
1032  $form->setValuesByPost();
1033  $this->tpl->setContent($form->getHTML());
1034  }
1035 
1036  function addDidacticTemplateOptions(array &$a_options)
1037  {
1038  include_once("./Modules/Test/classes/class.ilObjTest.php");
1039  $tst = new ilObjTest();
1040  $defaults = $tst->getAvailableDefaults();
1041  if (count($defaults))
1042  {
1043  foreach ($defaults as $row)
1044  {
1045  $a_options["tstdef_".$row["test_defaults_id"]] = array($row["name"],
1046  $this->lng->txt("tst_default_settings"));
1047  }
1048  }
1049 
1050  // using template?
1051  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
1052  $templates = ilSettingsTemplate::getAllSettingsTemplates("tst");
1053  if($templates)
1054  {
1055  foreach($templates as $item)
1056  {
1057  $a_options["tsttpl_".$item["id"]] = array($item["title"],
1058  nl2br(trim($item["description"])));
1059  }
1060  }
1061  }
1062 
1067  function afterSave(ilObject $a_new_object)
1068  {
1069  $tstdef = $this->getDidacticTemplateVar("tstdef");
1070  if ($tstdef)
1071  {
1072  $testDefaultsId = $tstdef;
1073  $testDefaults = ilObjTest::_getTestDefaults($testDefaultsId);
1074  $a_new_object->applyDefaults($testDefaults);
1075  }
1076 
1077  $template_id = $this->getDidacticTemplateVar("tsttpl");
1078  if($template_id)
1079  {
1080  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
1082 
1083  $template_settings = $template->getSettings();
1084  if($template_settings)
1085  {
1086  $this->applyTemplate($template_settings, $a_new_object);
1087  }
1088 
1089  $a_new_object->setTemplate($template_id);
1090  }
1091 
1092  $a_new_object->saveToDb();
1093 
1094  // always send a message
1095  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
1096  $this->ctrl->setParameter($this, 'ref_id', $a_new_object->getRefId());
1097  $this->ctrl->redirectByClass('ilObjTestSettingsGeneralGUI');
1098  }
1099 
1101  {
1102  include_once "./Services/Utilities/classes/class.ilUtil.php";
1103  $path = $this->tree->getPathFull($this->object->getRefID());
1104  ilUtil::redirect($this->getReturnLocation("cancel","./ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
1105  }
1106 
1110  function uploadTstObject()
1111  {
1112  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
1113  {
1114  ilUtil::sendFailure($this->lng->txt("error_upload"));
1115  $this->createObject();
1116  return;
1117  }
1118  include_once("./Modules/Test/classes/class.ilObjTest.php");
1119  // create import directory
1120  $basedir = ilObjTest::_createImportDirectory();
1121 
1122  // copy uploaded file to import directory
1123  $file = pathinfo($_FILES["xmldoc"]["name"]);
1124  $full_path = $basedir."/".$_FILES["xmldoc"]["name"];
1125  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
1126 
1127  // unzip file
1128  ilUtil::unzip($full_path);
1129 
1130  // determine filenames of xml files
1131  $subdir = basename($file["basename"],".".$file["extension"]);
1133  $xml_file = ilObjTest::_getImportDirectory().'/'.$subdir.'/'.$subdir.".xml";
1134  $qti_file = ilObjTest::_getImportDirectory().'/'.$subdir.'/'. preg_replace("/test|tst/", "qti", $subdir).".xml";
1135  $results_file = ilObjTest::_getImportDirectory().'/'.$subdir.'/'. preg_replace("/test|tst/", "results", $subdir).".xml";
1136 
1137  if(!is_file($qti_file))
1138  {
1139  ilUtil::delDir($basedir);
1140  ilUtil::sendFailure($this->lng->txt("tst_import_non_ilias_zip"));
1141  $this->createObject();
1142  return;
1143  }
1144 
1145  // start verification of QTI files
1146  include_once "./Services/QTI/classes/class.ilQTIParser.php";
1147  $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
1148  $result = $qtiParser->startParsing();
1149  $founditems =& $qtiParser->getFoundItems();
1150 
1151  $complete = 0;
1152  $incomplete = 0;
1153  foreach ($founditems as $item)
1154  {
1155  if (strlen($item["type"]))
1156  {
1157  $complete++;
1158  }
1159  else
1160  {
1161  $incomplete++;
1162  }
1163  }
1164 
1165  if( count($founditems) && $complete == 0 )
1166  {
1167  // delete import directory
1168  ilUtil::delDir($basedir);
1169 
1170  ilUtil::sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
1171  $this->createObject();
1172  return;
1173  }
1174 
1175  $_SESSION["tst_import_results_file"] = $results_file;
1176  $_SESSION["tst_import_xml_file"] = $xml_file;
1177  $_SESSION["tst_import_qti_file"] = $qti_file;
1178  $_SESSION["tst_import_subdir"] = $subdir;
1179 
1180  if( $qtiParser->getQuestionSetType() != ilObjTest::QUESTION_SET_TYPE_FIXED )
1181  {
1182  $this->importVerifiedFileObject();
1183  return;
1184  }
1185 
1186  // display of found questions
1187  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tst_import_verification.html", "Modules/Test");
1188  $row_class = array("tblrow1", "tblrow2");
1189  $counter = 0;
1190  foreach ($founditems as $item)
1191  {
1192  $this->tpl->setCurrentBlock("verification_row");
1193  $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
1194  $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
1195  $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
1196  include_once "./Services/QTI/classes/class.ilQTIItem.php";
1197  switch ($item["type"])
1198  {
1200  case QT_MULTIPLE_CHOICE_MR:
1201  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMultipleChoice"));
1202  break;
1204  case QT_MULTIPLE_CHOICE_SR:
1205  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assSingleChoice"));
1206  break;
1208  case QT_KPRIM_CHOICE:
1209  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assKprimChoice"));
1210  break;
1212  case QT_LONG_MENU:
1213  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assLongMenu"));
1214  break;
1216  case QT_NUMERIC:
1217  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assNumeric"));
1218  break;
1220  case QT_FORMULA:
1221  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assFormulaQuestion"));
1222  break;
1224  case QT_TEXTSUBSET:
1225  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextSubset"));
1226  break;
1227  case CLOZE_TEST_IDENTIFIER:
1228  case QT_CLOZE:
1229  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assClozeTest"));
1230  break;
1231  case ERROR_TEXT_IDENTIFIER:
1232  case QT_ERRORTEXT:
1233  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assErrorText"));
1234  break;
1236  case QT_IMAGEMAP:
1237  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assImagemapQuestion"));
1238  break;
1240  case QT_JAVAAPPLET:
1241  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assJavaApplet"));
1242  break;
1244  case QT_FLASHAPPLET:
1245  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assFlashApplet"));
1246  break;
1248  case QT_MATCHING:
1249  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMatchingQuestion"));
1250  break;
1252  case QT_ORDERING:
1253  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingQuestion"));
1254  break;
1257  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingHorizontal"));
1258  break;
1260  case QT_TEXT:
1261  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextQuestion"));
1262  break;
1264  case QT_FILEUPLOAD:
1265  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assFileUpload"));
1266  break;
1267  }
1268  $this->tpl->parseCurrentBlock();
1269  }
1270 
1271  // on import creation screen the pool was chosen (-1 for no pool)
1272  // BUT when no pool is available the input on creation screen is missing, so the field value -1 for no pool is not submitted.
1273  $QplOrTstID = isset($_POST["qpl"]) && (int)$_POST["qpl"] != 0 ? $_POST["qpl"] : -1;
1274 
1275  $this->tpl->setCurrentBlock("adm_content");
1276  $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
1277  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
1278  $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("tst_import_verify_found_questions"));
1279  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_tst"));
1280  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1281  $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.svg"));
1282  $this->tpl->setVariable("QUESTIONPOOL_ID", $QplOrTstID);
1283  $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
1284  $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
1285  $this->tpl->parseCurrentBlock();
1286  }
1287 
1292  {
1293  include_once "./Modules/Test/classes/class.ilObjTest.php";
1294  // create new questionpool object
1295  $newObj = new ilObjTest(0, true);
1296  // set type of questionpool object
1297  $newObj->setType($_GET["new_type"]);
1298  // set title of questionpool object to "dummy"
1299  $newObj->setTitle("dummy");
1300  // set description of questionpool object
1301  $newObj->setDescription("test import");
1302  // create the questionpool class in the ILIAS database (object_data table)
1303  $newObj->create(true);
1304  // create a reference for the questionpool object in the ILIAS database (object_reference table)
1305  $newObj->createReference();
1306  // put the questionpool object in the administration tree
1307  $newObj->putInTree($_GET["ref_id"]);
1308  // get default permissions and set the permissions for the questionpool object
1309  $newObj->setPermissions($_GET["ref_id"]);
1310  // empty mark schema
1311  $newObj->mark_schema->flush();
1312 
1313  // start parsing of QTI files
1314  include_once "./Services/QTI/classes/class.ilQTIParser.php";
1315 
1316  // Handle selection of "no questionpool" as qpl_id = -1 -> use test object id instead.
1317  // possible hint: chek if empty strings in $_POST["qpl_id"] relates to a bug or not
1318  if (!isset($_POST["qpl"]) || "-1" === (string)$_POST["qpl"])
1319  {
1320  $questionParentObjId = $newObj->getId();
1321  }
1322  else
1323  {
1324  $questionParentObjId = $_POST["qpl"];
1325  }
1326 
1327  if( is_file($_SESSION["tst_import_dir"].'/'.$_SESSION["tst_import_subdir"]."/manifest.xml") )
1328  {
1329  $newObj->saveToDb();
1330 
1331  $_SESSION['tst_import_idents'] = $_POST['ident'];
1332  $_SESSION['tst_import_qst_parent'] = $questionParentObjId;
1333 
1334  $fileName = $_SESSION['tst_import_subdir'] . '.zip';
1335  $fullPath = $_SESSION['tst_import_dir'] . '/' . $fileName;
1336 
1337  include_once("./Services/Export/classes/class.ilImport.php");
1338  $imp = new ilImport((int)$_GET["ref_id"]);
1339  $map = $imp->getMapping();
1340  $map->addMapping('Modules/Test', 'tst', 'new_id', $newObj->getId());
1341  $imp->importObject($newObj, $fullPath, $fileName, 'tst', 'Modules/Test', true);
1342  }
1343  else
1344  {
1345  $qtiParser = new ilQTIParser($_SESSION["tst_import_qti_file"], IL_MO_PARSE_QTI, $questionParentObjId, $_POST["ident"]);
1346  if( !isset($_POST["ident"]) || !is_array($_POST["ident"]) || !count($_POST["ident"]) )
1347  {
1348  $qtiParser->setIgnoreItemsEnabled(true);
1349  }
1350  $qtiParser->setTestObject($newObj);
1351  $result = $qtiParser->startParsing();
1352  $newObj->saveToDb();
1353 
1354  // import page data
1355  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
1356  $contParser = new ilContObjParser($newObj, $_SESSION["tst_import_xml_file"], $_SESSION["tst_import_subdir"]);
1357  $contParser->setQuestionMapping($qtiParser->getImportMapping());
1358  $contParser->startParsing();
1359 
1360  if( isset($_POST["ident"]) && is_array($_POST["ident"]) && count($_POST["ident"]) == $qtiParser->getNumImportedItems() )
1361  {
1362  // import test results
1363  if(@file_exists($_SESSION["tst_import_results_file"]))
1364  {
1365  include_once ("./Modules/Test/classes/class.ilTestResultsImportParser.php");
1366  $results = new ilTestResultsImportParser($_SESSION["tst_import_results_file"], $newObj);
1367  $results->setQuestionIdMapping($qtiParser->getQuestionIdMapping());
1368  $results->startParsing();
1369  }
1370  }
1371  $newObj->update();
1372  }
1373 
1374 
1375  // delete import directory
1377 
1378  ilUtil::sendSuccess($this->lng->txt("object_imported"), true);
1379  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId()."&baseClass=ilObjTestGUI");
1380  }
1381 
1388  function uploadObject($redirect = true)
1389  {
1390  $this->uploadTstObject();
1391  }
1392 
1397  {
1398  $file = explode("_", $_GET["file_id"]);
1399  include_once("./Modules/File/classes/class.ilObjFile.php");
1400  $fileObj = new ilObjFile($file[count($file) - 1], false);
1401  $fileObj->sendFile();
1402  exit;
1403  }
1404 
1408  function fullscreenObject()
1409  {
1410  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
1411  $page_gui = new ilAssQuestionPageGUI($_GET["pg_id"]);
1412  $page_gui->showMediaFullscreen();
1413 
1414  }
1415 
1420  {
1421  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
1422  $pg_obj = new ilAssQuestionPage($_GET["pg_id"]);
1423  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
1424  exit;
1425  }
1426 
1434  function filterObject()
1435  {
1436  $this->questionBrowser();
1437  }
1438 
1447  {
1448  $this->questionBrowser();
1449  }
1450 
1458  function backObject()
1459  {
1460  $this->ctrl->redirect($this, "questions");
1461  }
1462 
1471  function createQuestionPool($name = "dummy", $description = "")
1472  {
1473  global $tree;
1474  $parent_ref = $tree->getParentId($this->object->getRefId());
1475  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1476  $qpl = new ilObjQuestionPool();
1477  $qpl->setType("qpl");
1478  $qpl->setTitle($name);
1479  $qpl->setDescription($description);
1480  $qpl->create();
1481  $qpl->createReference();
1482  $qpl->putInTree($parent_ref);
1483  $qpl->setPermissions($parent_ref);
1484  $qpl->setOnline(1); // must be online to be available
1485  $qpl->saveToDb();
1486  return $qpl->getRefId();
1487  }
1488 
1492  public function randomselectObject()
1493  {
1494  global $ilUser;
1495  $this->getQuestionsSubTabs();
1496  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_select.html", "Modules/Test");
1497  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE);
1498  $this->tpl->setCurrentBlock("option");
1499  $this->tpl->setVariable("VALUE_OPTION", "0");
1500  $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("all_available_question_pools"));
1501  $this->tpl->parseCurrentBlock();
1502  foreach ($questionpools as $key => $value)
1503  {
1504  $this->tpl->setCurrentBlock("option");
1505  $this->tpl->setVariable("VALUE_OPTION", $key);
1506  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
1507  $this->tpl->parseCurrentBlock();
1508  }
1509  $this->tpl->setCurrentBlock("hidden");
1510  $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
1511  $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
1512  $this->tpl->parseCurrentBlock();
1513  $this->tpl->setCurrentBlock("adm_content");
1514  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1515  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_random_select_questionpool"));
1516  $this->tpl->setVariable("TXT_NR_OF_QUESTIONS", $this->lng->txt("tst_random_nr_of_questions"));
1517  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
1518  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1519  $this->tpl->parseCurrentBlock();
1520  }
1521 
1530  {
1531  $this->ctrl->redirect($this, "questions");
1532  }
1533 
1542  {
1543  $this->getQuestionsSubTabs();
1544  $question_array = $this->object->randomSelectQuestions($_POST["nr_of_questions"], $_POST["sel_qpl"]);
1545  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_question_offer.html", "Modules/Test");
1546  $color_class = array("tblrow1", "tblrow2");
1547  $counter = 0;
1548  $questionpools =& $this->object->getAvailableQuestionpools(true);
1549  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1550  foreach ($question_array as $question_id)
1551  {
1552  $dataset = $this->object->getQuestionDataset($question_id);
1553  $this->tpl->setCurrentBlock("QTab");
1554  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
1555  $this->tpl->setVariable("QUESTION_TITLE", $dataset->title);
1556  $this->tpl->setVariable("QUESTION_COMMENT", $dataset->description);
1557  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($dataset->type_tag));
1558  $this->tpl->setVariable("QUESTION_AUTHOR", $dataset->author);
1559  $this->tpl->setVariable("QUESTION_POOL", $questionpools[$dataset->obj_fi]["title"]);
1560  $this->tpl->parseCurrentBlock();
1561  $counter++;
1562  }
1563  if (count($question_array) == 0)
1564  {
1565  $this->tpl->setCurrentBlock("Emptytable");
1566  $this->tpl->setVariable("TEXT_NO_QUESTIONS_AVAILABLE", $this->lng->txt("no_questions_available"));
1567  $this->tpl->parseCurrentBlock();
1568  }
1569  else
1570  {
1571  $this->tpl->setCurrentBlock("Selectionbuttons");
1572  $this->tpl->setVariable("BTN_YES", $this->lng->txt("random_accept_sample"));
1573  $this->tpl->setVariable("BTN_NO", $this->lng->txt("random_another_sample"));
1574  $this->tpl->parseCurrentBlock();
1575  }
1576  $chosen_questions = join($question_array, ",");
1577  $this->tpl->setCurrentBlock("adm_content");
1578  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1579  $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
1580  $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
1581  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("tst_question_type"));
1582  $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
1583  $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt("qpl"));
1584  $this->tpl->setVariable("VALUE_CHOSEN_QUESTIONS", $chosen_questions);
1585  $this->tpl->setVariable("VALUE_QUESTIONPOOL_SELECTION", $_POST["sel_qpl"]);
1586  $this->tpl->setVariable("VALUE_NR_OF_QUESTIONS", $_POST["nr_of_questions"]);
1587  $this->tpl->setVariable("TEXT_QUESTION_OFFER", $this->lng->txt("tst_question_offer"));
1588  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1589  $this->tpl->parseCurrentBlock();
1590  }
1591 
1600  {
1601  $selected_array = explode(",", $_POST["chosen_questions"]);
1602  if (!count($selected_array))
1603  {
1604  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"));
1605  }
1606  else
1607  {
1608  $total = $this->object->evalTotalPersons();
1609  if ($total)
1610  {
1611  // the test was executed previously
1612  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
1613  }
1614  else
1615  {
1616  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
1617  }
1618  foreach ($selected_array as $key => $value)
1619  {
1620  $this->object->insertQuestion( $this->testQuestionSetConfigFactory->getQuestionSetConfig(), $value );
1621  }
1622  $this->object->saveCompleteStatus( $this->testQuestionSetConfigFactory->getQuestionSetConfig() );
1623  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), true);
1624  $this->ctrl->redirect($this, "questions");
1625  return;
1626  }
1627  }
1628 
1630  {
1631  $this->questionBrowser();
1632  }
1633 
1642  {
1643  $qpl_ref_id = $_REQUEST["sel_qpl"];
1644 
1645  $qpl_mode = $_REQUEST['usage'];
1646 
1647  if(isset($_REQUEST['qtype']))
1648  {
1649  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
1650  $sel_question_types = ilObjQuestionPool::getQuestionTypeByTypeId($_REQUEST["qtype"]);
1651  }
1652  else if(isset($_REQUEST['sel_question_types']))
1653  {
1654  $sel_question_types = $_REQUEST["sel_question_types"];
1655  }
1656 
1657  if (!$qpl_mode || ($qpl_mode == 2 && strcmp($_REQUEST["txt_qpl"], "") == 0) || ($qpl_mode == 3 && strcmp($qpl_ref_id, "") == 0))
1658  //if ((strcmp($_REQUEST["txt_qpl"], "") == 0) && (strcmp($qpl_ref_id, "") == 0))
1659  {
1660  // Mantis #14890
1661  $_REQUEST['sel_question_types'] = $sel_question_types;
1662  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
1663  $this->createQuestionObject();
1664  return;
1665  }
1666  else
1667  {
1668  $_SESSION["test_id"] = $this->object->getRefId();
1669  if ($qpl_mode == 2 && strcmp($_REQUEST["txt_qpl"], "") != 0)
1670  {
1671  // create a new question pool and return the reference id
1672  $qpl_ref_id = $this->createQuestionPool($_REQUEST["txt_qpl"]);
1673  }
1674  else if ($qpl_mode == 1)
1675  {
1676  $qpl_ref_id = $_GET["ref_id"];
1677  }
1678 
1679  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPoolGUI.php";
1680  $baselink = "ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $qpl_ref_id . "&cmd=createQuestionForTest&test_ref_id=".$_GET["ref_id"]."&calling_test=".$_GET["ref_id"]."&sel_question_types=" . $sel_question_types;
1681 
1682  if (isset($_REQUEST['prev_qid']))
1683  {
1684  $baselink .= '&prev_qid=' . $_REQUEST['prev_qid'];
1685  }
1686  else if(isset($_REQUEST['position']))
1687  {
1688  $baselink .= '&prev_qid=' . $_REQUEST['position'];
1689  }
1690 
1691  if ($_REQUEST['test_express_mode']) {
1692  $baselink .= '&test_express_mode=1';
1693  }
1694 
1695  if( isset($_REQUEST['add_quest_cont_edit_mode']) )
1696  {
1698  $baselink, "add_quest_cont_edit_mode={$_REQUEST['add_quest_cont_edit_mode']}", false
1699  );
1700  }
1701 
1702 #var_dump($_REQUEST['prev_qid']);
1703  ilUtil::redirect($baselink);
1704 
1705  exit();
1706  }
1707  }
1708 
1717  {
1718  $this->ctrl->redirect($this, "questions");
1719  }
1720 
1729  {
1730  global $ilUser;
1731  $this->getQuestionsSubTabs();
1732  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select.html", "Modules/Test");
1733  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE, FALSE, "write");
1734 
1735  if ($this->object->getPoolUsage()) {
1736  global $lng, $ilCtrl, $tpl;
1737 
1738  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
1739 
1740  $form = new ilPropertyFormGUI();
1741  $form->setFormAction($ilCtrl->getFormAction($this, "executeCreateQuestion"));
1742  $form->setTitle($lng->txt("ass_create_question"));
1743  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
1744 
1745 
1746  $hidden = new ilHiddenInputGUI('sel_question_types');
1747  $hidden->setValue($_REQUEST["sel_question_types"]);
1748  $form->addItem($hidden);
1749 
1750  // content editing mode
1752  {
1753  $ri = new ilRadioGroupInputGUI($lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
1754 
1755  $ri->addOption(new ilRadioOption(
1756  $lng->txt('tst_add_quest_cont_edit_mode_default'),
1758  ));
1759 
1760  $ri->addOption(new ilRadioOption(
1761  $lng->txt('tst_add_quest_cont_edit_mode_page_object'),
1763  ));
1764 
1766 
1767  $form->addItem($ri, true);
1768  }
1769  else
1770  {
1771  $hi = new ilHiddenInputGUI("question_content_editing_type");
1773  $form->addItem($hi, true);
1774  }
1775 
1776  // use pool
1777  $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage");
1778  $usage->setRequired(true);
1779  $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1);
1780  $usage->addOption($no_pool);
1781  $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3);
1782  $usage->addOption($existing_pool);
1783  $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2);
1784  $usage->addOption($new_pool);
1785  $form->addItem($usage);
1786 
1787  $usage->setValue(1);
1788 
1789  $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(FALSE, FALSE, TRUE, FALSE, FALSE, "write");
1790  $pools_data = array();
1791  foreach($questionpools as $key => $p) {
1792  $pools_data[$key] = $p['title'];
1793  }
1794  $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl");
1795  $pools->setOptions($pools_data);
1796  $existing_pool->addSubItem($pools);
1797 
1798 
1799  $this->lng->loadLanguageModule('rbac');
1800  $name = new ilTextInputGUI($this->lng->txt("rbac_create_qpl"), "txt_qpl");
1801  $name->setSize(50);
1802  $name->setMaxLength(50);
1803  $new_pool->addSubItem($name);
1804 
1805  $form->addCommandButton("executeCreateQuestion", $lng->txt("submit"));
1806  $form->addCommandButton("cancelCreateQuestion", $lng->txt("cancel"));
1807 
1808  return $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
1809 
1810  }
1811  else {
1812  global $ilCtrl;
1813 
1814  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'sel_question_types', $_REQUEST["sel_question_types"]);
1815  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'add_quest_cont_edit_mode', $_REQUEST["add_quest_cont_edit_mode"]);
1816  $link = $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'handleToolbarCommand','',false,false);
1817  ilUtil::redirect($link);
1818  }
1819  }
1820 
1825  {
1826  $removeQuestionIds = (array)$_POST["q_id"];
1827 
1828  $questions = $this->object->getQuestionTitlesAndIndexes();
1829 
1830  $this->object->removeQuestions($removeQuestionIds);
1831 
1832  $this->object->saveCompleteStatus( $this->testQuestionSetConfigFactory->getQuestionSetConfig() );
1833 
1834  ilUtil::sendSuccess($this->lng->txt("tst_questions_removed"));
1835 
1836  if($_REQUEST['test_express_mode'])
1837  {
1838  $prev = null;
1839  $return_to = null;
1840  $deleted_tmp = $removeQuestionIds;
1841  $first = array_shift($deleted_tmp);
1842  foreach((array)$questions as $key => $value)
1843  {
1844  if(!in_array($key, $removeQuestionIds))
1845  {
1846  $prev = $key;
1847  if(!$first)
1848  {
1849  $return_to = $prev;
1850  break;
1851  }
1852  else continue;
1853  }
1854  else if($key == $first)
1855  {
1856  if($prev)
1857  {
1858  $return_to = $prev;
1859  break;
1860  }
1861  $first = array_shift($deleted_tmp);
1862  }
1863  }
1864 
1865  if(
1866  count($questions) == count($removeQuestionIds) ||
1867  !$return_to
1868  )
1869  {
1870  $this->ctrl->setParameter($this, 'q_id', '');
1871  $this->ctrl->redirect($this, 'showPage');
1872  }
1873 
1874  $this->ctrl->setParameter($this, 'q_id', $return_to);
1875  $this->ctrl->redirect($this, "showPage");
1876  }
1877  else
1878  {
1879  $this->ctrl->setParameter($this, 'q_id', '');
1880  $this->ctrl->redirect($this, 'questions');
1881  }
1882  }
1883 
1892  {
1893  if ($_REQUEST['test_express_mode']) {
1894  $this->ctrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
1895  $this->ctrl->redirect($this, "showPage");
1896  }
1897  else {
1898  $this->ctrl->redirect($this, "questions");
1899  }
1900  }
1901 
1909  function removeQuestionsForm($checked_questions)
1910  {
1911  $total = $this->object->evalTotalPersons();
1912  if ($total)
1913  {
1914  // the test was executed previously
1915  $question = sprintf($this->lng->txt("tst_remove_questions_and_results"), $total);
1916  }
1917  else
1918  {
1919  if (count($checked_questions) == 1)
1920  {
1921  $question = $this->lng->txt("tst_remove_question");
1922  }
1923  else
1924  {
1925  $question = $this->lng->txt("tst_remove_questions");
1926  }
1927  }
1928 
1929  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1930  $cgui = new ilConfirmationGUI();
1931  $cgui->setHeaderText($question);
1932 
1933  $this->ctrl->saveParameter($this, 'test_express_mode');
1934  $this->ctrl->saveParameter($this, 'q_id');
1935 
1936  $cgui->setFormAction($this->ctrl->getFormAction($this));
1937  $cgui->setCancel($this->lng->txt("cancel"), "cancelRemoveQuestions");
1938  $cgui->setConfirm($this->lng->txt("confirm"), "confirmRemoveQuestions");
1939 
1940  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1941  $removablequestions =& $this->object->getTestQuestions();
1942  if (count($removablequestions))
1943  {
1944  foreach ($removablequestions as $data)
1945  {
1946  if (in_array($data["question_id"], $checked_questions))
1947  {
1948  $txt = $data["title"]." (".assQuestion::_getQuestionTypeName($data["type_tag"]).")";
1949  $txt .= ' ['. $this->lng->txt('question_id_short') . ': ' . $data['question_id'] . ']';
1950 
1951  if($data["description"])
1952  {
1953  $txt .= "<div class=\"small\">".$data["description"]."</div>";
1954  }
1955 
1956  $cgui->addItem("q_id[]", $data["question_id"], $txt);
1957  }
1958  }
1959  }
1960 
1961  $this->tpl->setContent($cgui->getHTML());
1962  }
1963 
1967  public function removeQuestionsObject()
1968  {
1969  $this->getQuestionsSubTabs();
1970  $checked_questions = $_REQUEST["q_id"];
1971 
1972  if (!is_array($checked_questions) && $checked_questions) {
1973  $checked_questions = array($checked_questions);
1974  }
1975 
1976  if (!is_array($checked_questions)) {
1977  $checked_questions = [];
1978  }
1979 
1980  if (count($checked_questions) > 0) {
1981  $this->removeQuestionsForm($checked_questions);
1982  } elseif (0 === count($checked_questions)) {
1983  ilUtil::sendFailure($this->lng->txt("tst_no_question_selected_for_removal"), true);
1984  $this->ctrl->redirect($this, "questions");
1985  }
1986  }
1987 
1992  {
1993  $selected_questions = NULL;
1994  $selected_questions = $_POST['q_id'];
1995  if (is_array($selected_questions))
1996  {
1997  $_SESSION['tst_qst_move_' . $this->object->getTestId()] = $_POST['q_id'];
1998  ilUtil::sendSuccess($this->lng->txt("msg_selected_for_move"), true);
1999  }
2000  else
2001  {
2002  ilUtil::sendFailure($this->lng->txt('no_selection_for_move'), TRUE);
2003  }
2004  $this->ctrl->redirect($this, 'questions');
2005  }
2006 
2011  {
2012  // get all questions to move
2013  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
2014 
2015  if (!is_array($_POST['q_id']) || 0 === count($_POST['q_id']))
2016  {
2017  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
2018  $this->ctrl->redirect($this, 'questions');
2019  }
2020  if (count($_POST['q_id']) > 1)
2021  {
2022  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
2023  $this->ctrl->redirect($this, 'questions');
2024  }
2025  $insert_mode = 0;
2026  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
2027  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
2028  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
2029  $this->ctrl->redirect($this, "questions");
2030  }
2031 
2035  public function insertQuestionsAfterObject()
2036  {
2037  // get all questions to move
2038  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
2039  if (!is_array($_POST['q_id']) || 0 === count($_POST['q_id']))
2040  {
2041  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
2042  $this->ctrl->redirect($this, 'questions');
2043  }
2044  if (count($_POST['q_id']) > 1)
2045  {
2046  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
2047  $this->ctrl->redirect($this, 'questions');
2048  }
2049  $insert_mode = 1;
2050  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
2051  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
2052  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
2053  $this->ctrl->redirect($this, "questions");
2054  }
2055 
2062  {
2063  $selected_array = (is_array($_POST['q_id'])) ? $_POST['q_id'] : array();
2064  if (!count($selected_array))
2065  {
2066  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"), true);
2067  $this->ctrl->redirect($this, "browseForQuestions");
2068  }
2069  else
2070  {
2071  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
2072  $manscoring = FALSE;
2073  foreach ($selected_array as $key => $value)
2074  {
2075  $this->object->insertQuestion( $this->testQuestionSetConfigFactory->getQuestionSetConfig(), $value );
2076  if (!$manscoring)
2077  {
2078  $manscoring = $manscoring | assQuestion::_needsManualScoring($value);
2079  }
2080  }
2081  $this->object->saveCompleteStatus( $this->testQuestionSetConfigFactory->getQuestionSetConfig() );
2082  if ($manscoring)
2083  {
2084  ilUtil::sendInfo($this->lng->txt("manscoring_hint"), TRUE);
2085  }
2086  else
2087  {
2088  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), TRUE);
2089  }
2090  $this->ctrl->redirect($this, "questions");
2091  return;
2092  }
2093  }
2094 
2095  public function addQuestionObject()
2096  {
2097  global $lng, $ilCtrl, $tpl;
2098  global $DIC; /* @var \ILIAS\DI\Container $DIC */
2099  $ilHelp = $DIC['ilHelp']; /* @var ilHelpGUI $ilHelp */
2100 
2101  $subScreenId = array('createQuestion');
2102 
2103  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
2104 
2105  $ilCtrl->setParameter($this, 'qtype', $_REQUEST['qtype']);
2106 
2107  $form = new ilPropertyFormGUI();
2108 
2109  $form->setFormAction($ilCtrl->getFormAction($this, "executeCreateQuestion"));
2110  $form->setTitle($lng->txt("ass_create_question"));
2111  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
2112 
2113  $pool = new ilObjQuestionPool();
2114  $questionTypes = $pool->getQuestionTypes(false, true);
2115  $options = array();
2116 
2117  // question type
2118  foreach($questionTypes as $label => $data)
2119  {
2120  $options[$data['question_type_id']] = $label;
2121  }
2122 
2123  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
2124  $si = new ilSelectInputGUI($lng->txt("question_type"), "qtype");
2125  $si->setOptions($options);
2126  $form->addItem($si, true);
2127 
2128  // position
2129  $questions = $this->object->getQuestionTitlesAndIndexes();
2130  if($questions)
2131  {
2132  $si = new ilSelectInputGUI($lng->txt("position"), "position");
2133  $options = array('0' => $lng->txt('first'));
2134  foreach($questions as $key => $title)
2135  {
2136  $options[$key] = $lng->txt('behind') . ' '. $title . ' ['.$this->lng->txt('question_id_short') . ': '. $key .']';
2137  }
2138  $si->setOptions($options);
2139  $si->setValue($_REQUEST['q_id']);
2140  $form->addItem($si, true);
2141  }
2142 
2143  // content editing mode
2145  {
2146  $subScreenId[] = 'editMode';
2147 
2148  $ri = new ilRadioGroupInputGUI($lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
2149 
2150  $ri->addOption(new ilRadioOption(
2151  $lng->txt('tst_add_quest_cont_edit_mode_default'),
2153  ));
2154 
2155  $ri->addOption(new ilRadioOption(
2156  $lng->txt('tst_add_quest_cont_edit_mode_page_object'),
2158  ));
2159 
2161 
2162  $form->addItem($ri, true);
2163  }
2164  else
2165  {
2166  $hi = new ilHiddenInputGUI("question_content_editing_type");
2168  $form->addItem($hi, true);
2169  }
2170 
2171  if($this->object->getPoolUsage())
2172  {
2173  $subScreenId[] = 'poolSelect';
2174 
2175  // use pool
2176  $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage");
2177  $usage->setRequired(true);
2178  $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1);
2179  $usage->addOption($no_pool);
2180  $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3);
2181  $usage->addOption($existing_pool);
2182  $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2);
2183  $usage->addOption($new_pool);
2184  $form->addItem($usage);
2185 
2186  $usage->setValue(1);
2187 
2188  $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(FALSE, FALSE, TRUE, FALSE, FALSE, "write");
2189  $pools_data = array();
2190  foreach($questionpools as $key => $p)
2191  {
2192  $pools_data[$key] = $p['title'];
2193  }
2194  $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl");
2195  $pools->setOptions($pools_data);
2196  $existing_pool->addSubItem($pools);
2197 
2198  $name = new ilTextInputGUI($this->lng->txt("name"), "txt_qpl");
2199  $name->setSize(50);
2200  $name->setMaxLength(50);
2201  $new_pool->addSubItem($name);
2202  }
2203 
2204  $form->addCommandButton("executeCreateQuestion", $lng->txt("create"));
2205  $form->addCommandButton("questions", $lng->txt("cancel"));
2206 
2207  $ilHelp->setScreenId('assQuestions');
2208  $ilHelp->setSubScreenId(implode('_', $subScreenId));
2209 
2210  return $tpl->setContent($form->getHTML());
2211  }
2212 
2213  function questionsObject()
2214  {
2215  global $ilAccess, $ilTabs;
2216 
2217  $ilTabs->activateTab('assQuestions');
2218 
2219  // #12590
2220  $this->ctrl->setParameter($this, 'test_express_mode', '');
2221 
2222  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2223  {
2224  // allow only write access
2225  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2226  $this->ctrl->redirect($this, "infoScreen");
2227  }
2228 
2229  if ($_GET['browse'])
2230  {
2231  return $this->questionbrowser();
2232  }
2233 
2234  $this->getQuestionsSubTabs();
2235 
2236  // #11631, #12994
2237  $this->ctrl->setParameter($this, 'q_id', '');
2238 
2239  if ($_GET["eqid"] && $_GET["eqpl"])
2240  {
2241  ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForTest&calling_test=".$_GET["ref_id"]."&q_id=" . $_GET["eqid"]);
2242  }
2243 
2244  if ($_GET["up"] > 0)
2245  {
2246  $this->object->questionMoveUp($_GET["up"]);
2247  }
2248  if ($_GET["down"] > 0)
2249  {
2250  $this->object->questionMoveDown($_GET["down"]);
2251  }
2252 
2253  if ($_GET["add"])
2254  {
2255  $selected_array = array();
2256  array_push($selected_array, $_GET["add"]);
2257  $total = $this->object->evalTotalPersons();
2258  if ($total)
2259  {
2260  // the test was executed previously
2261  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
2262  }
2263  else
2264  {
2265  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
2266  }
2267  $this->insertQuestions($selected_array);
2268  return;
2269  }
2270 
2271  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", "Modules/Test");
2272 
2273  $total = $this->object->evalTotalPersons();
2274  if ($ilAccess->checkAccess("write", "", $this->ref_id))
2275  {
2276  if($total != 0)
2277  {
2278  $link = $this->ctrl->getLinkTarget($this, "participants");
2279  $link = "<a href=\"".$link."\">".$this->lng->txt("test_has_datasets_warning_page_view_link")."</a>";
2280  ilUtil::sendInfo($this->lng->txt("test_has_datasets_warning_page_view")." ".$link);
2281  }
2282  else {
2283  global $ilToolbar;
2284 
2285  $ilToolbar->addButton($this->lng->txt("ass_create_question"), $this->ctrl->getLinkTarget($this, "addQuestion"));
2286 
2287  if( $this->object->getPoolUsage() )
2288  {
2289  $ilToolbar->addSeparator();
2290 
2291  require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php';
2292 
2294  }
2295 
2296  $ilToolbar->addSeparator();
2297  $ilToolbar->addButton($this->lng->txt("random_selection"), $this->ctrl->getLinkTarget($this, "randomselect"));
2298 
2299 
2300  global $ilAccess, $ilUser, $lng, $ilCtrl;
2301  $online_access = false;
2302  if ($this->object->getFixedParticipants())
2303  {
2304  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
2305  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
2306  if ($online_access_result === true)
2307  {
2308  $online_access = true;
2309  }
2310  }
2311 
2312  if( $this->object->isOnline() && $this->object->isComplete( $this->testQuestionSetConfigFactory->getQuestionSetConfig() ) )
2313  {
2314  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
2315  {
2316  $testSession = $this->testSessionFactory->getSession();
2317  $testSequence = $this->testSequenceFactory->getSequenceByTestSession($testSession);
2318 
2319  $testPlayerGUI = $this->testPlayerFactory->getPlayerGUI();
2320 
2321  $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = TRUE);
2322 
2323  if ($executable["executable"])
2324  {
2325  if ($testSession->getActiveId() > 0)
2326  {
2327  // resume test
2328 
2329  if ($testSequence->hasStarted($testSession))
2330  {
2331  $execTestLabel = $this->lng->txt("tst_resume_test");
2332  $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'resumePlayer');
2333  }
2334  else
2335  {
2336  $execTestLabel = $this->object->getStartTestLabel($testSession->getActiveId());
2337  $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'startPlayer');
2338  }
2339  }
2340  else
2341  {
2342  // start new test
2343 
2344  $execTestLabel = $this->object->getStartTestLabel($testSession->getActiveId());
2345  $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'startPlayer');
2346  }
2347 
2348  $ilToolbar->addSeparator();
2349  $ilToolbar->addButton($execTestLabel, $execTestLink);
2350  }
2351  }
2352  }
2353 
2354 
2355  }
2356  }
2357 
2358  $this->tpl->setCurrentBlock("adm_content");
2359  include_once "./Modules/Test/classes/tables/class.ilTestQuestionsTableGUI.php";
2360  $checked_move = is_array($_SESSION['tst_qst_move_' . $this->object->getTestId()]) && (count($_SESSION['tst_qst_move_' . $this->object->getTestId()]));
2361  $table_gui = new ilTestQuestionsTableGUI($this, 'questions', (($ilAccess->checkAccess("write", "", $this->ref_id) ? true : false)), $checked_move, $total);
2362  $data = $this->object->getTestQuestions();
2363  $table_gui->setData($data);
2364  $this->tpl->setVariable('QUESTIONBROWSER', $table_gui->getHTML());
2365  $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
2366  $this->tpl->parseCurrentBlock();
2367  }
2368 
2373  private function populateQuestionBrowserToolbarButtons(ilToolbarGUI $toolbar, $context)
2374  {
2375  require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php';
2376 
2377  $this->ctrl->setParameterByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::CONTEXT_PARAMETER, $context);
2378 
2379  $this->ctrl->setParameterByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::MODE_PARAMETER, ilTestQuestionBrowserTableGUI::MODE_BROWSE_POOLS);
2380 
2381  $toolbar->addButton($this->lng->txt("tst_browse_for_qpl_questions"), $this->ctrl->getLinkTargetByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::CMD_BROWSE_QUESTIONS));
2382 
2383  $this->ctrl->setParameterByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::MODE_PARAMETER, ilTestQuestionBrowserTableGUI::MODE_BROWSE_TESTS);
2384 
2385  $toolbar->addButton($this->lng->txt("tst_browse_for_tst_questions"), $this->ctrl->getLinkTargetByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::CMD_BROWSE_QUESTIONS));
2386  }
2387 
2388  function takenObject() {
2389  }
2390 
2399  {
2400  global $ilDB, $lng;
2401 
2402  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
2403 
2404  $participantData = new ilTestParticipantData($ilDB, $lng);
2405  $participantData->load($this->object->getTestId());
2406 
2407  $this->object->removeTestResults($participantData);
2408 
2409  ilUtil::sendSuccess($this->lng->txt("tst_all_user_data_deleted"), true);
2410  $this->ctrl->redirect($this, "participants");
2411  }
2412 
2421  {
2422  global $ilDB, $lng;
2423 
2424  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
2425  $participantData = new ilTestParticipantData($ilDB, $lng);
2426 
2427  if( $this->object->getFixedParticipants() )
2428  {
2429  $participantData->setUserIds($_POST["chbUser"]);
2430  }
2431  else
2432  {
2433  $participantData->setActiveIds($_POST["chbUser"]);
2434  }
2435 
2436  $participantData->load($this->object->getTestId());
2437 
2438  $this->object->removeTestResults($participantData);
2439 
2440  ilUtil::sendSuccess($this->lng->txt("tst_selected_user_data_deleted"), true);
2441  $this->ctrl->redirect($this, "participants");
2442  }
2443 
2452  {
2453  $this->ctrl->redirect($this, "participants");
2454  }
2455 
2466  {
2467  ilUtil::sendQuestion($this->lng->txt("confirm_delete_all_user_data"));
2468  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", "Modules/Test");
2469 
2470  $this->tpl->setCurrentBlock("confirm_delete");
2471  $this->tpl->setVariable("BTN_CONFIRM_DELETE_ALL", $this->lng->txt("confirm"));
2472  $this->tpl->setVariable("BTN_CANCEL_DELETE_ALL", $this->lng->txt("cancel"));
2473  $this->tpl->parseCurrentBlock();
2474 
2475  $this->tpl->setCurrentBlock("adm_content");
2476  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2477  $this->tpl->parseCurrentBlock();
2478  }
2479 
2483  public function deleteAllUserResultsObject()
2484  {
2485  // display confirmation message
2486  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2487  $cgui = new ilConfirmationGUI();
2488  $cgui->setFormAction($this->ctrl->getFormAction($this, "participants"));
2489  $cgui->setHeaderText($this->lng->txt("delete_all_user_data_confirmation"));
2490  $cgui->setCancel($this->lng->txt("cancel"), "participants");
2491  $cgui->setConfirm($this->lng->txt("proceed"), "confirmDeleteAllUserResults");
2492 
2493  $this->tpl->setContent($cgui->getHTML());
2494  }
2495 
2504  {
2505  if (count($_POST["chbUser"]) == 0)
2506  {
2507  ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE);
2508  $this->ctrl->redirect($this, "participants");
2509  }
2510 
2511  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2512  $cgui = new ilConfirmationGUI();
2513  $cgui->setHeaderText($this->lng->txt("confirm_delete_single_user_data"));
2514 
2515  $cgui->setFormAction($this->ctrl->getFormAction($this));
2516  $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteSelectedUserData");
2517  $cgui->setConfirm($this->lng->txt("confirm"), "confirmDeleteSelectedUserData");
2518 
2519  include_once './Services/User/classes/class.ilObjUser.php';
2520  foreach ($_POST["chbUser"] as $key => $active_id)
2521  {
2522  if ($this->object->getFixedParticipants())
2523  {
2524  $user_id = $active_id;
2525  }
2526  else
2527  {
2528  $user_id = $this->object->_getUserIdFromActiveId($active_id);
2529  }
2530  $user = ilObjUser::_lookupName($user_id);
2531 
2532  if ($this->object->getAnonymity())
2533  {
2534  $name = $this->lng->txt("anonymous");
2535  }
2536  else if($user["lastname"])
2537  {
2538  $name = $user["lastname"].", ".$user["firstname"]." (".
2539  $user["login"].")";
2540  }
2541  else
2542  {
2543  $name = $this->lng->txt("deleted_user");
2544  }
2545 
2546  $cgui->addItem("chbUser[]", $active_id, $name,
2547  ilUtil::getImagePath("icon_usr.svg"), $this->lng->txt("usr"));
2548  }
2549 
2550  $this->tpl->setContent($cgui->getHTML());
2551  }
2552 
2560  function historyObject()
2561  {
2562  include_once "./Modules/Test/classes/tables/class.ilTestHistoryTableGUI.php";
2563  $table_gui = new ilTestHistoryTableGUI($this, 'history');
2564  $table_gui->setTestObject($this->object);
2565  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
2566  $log =& ilObjAssessmentFolder::_getLog(0, time(), $this->object->getId(), TRUE);
2567  $table_gui->setData($log);
2568  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2569  }
2570 
2571  function initImportForm($a_new_type)
2572  {
2573  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2574  $form = new ilPropertyFormGUI();
2575  $form->setTarget("_top");
2576  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
2577  $this->ctrl->setParameter($this, "new_type", $new_type);
2578  $form->setFormAction($this->ctrl->getFormAction($this));
2579  $form->setTitle($this->lng->txt("import_tst"));
2580 
2581  // file
2582  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
2583  $fi = new ilFileInputGUI($this->lng->txt("import_file"), "xmldoc");
2584  $fi->setSuffixes(array("zip"));
2585  $fi->setRequired(true);
2586  $form->addItem($fi);
2587 
2588  // question pool
2589  include_once("./Modules/Test/classes/class.ilObjTest.php");
2590  $tst = new ilObjTest();
2591  $questionpools = $tst->getAvailableQuestionpools(TRUE, FALSE, TRUE, TRUE);
2592  if (count($questionpools))
2593  {
2594  $options = array("-1" => $this->lng->txt("dont_use_questionpool"));
2595  foreach ($questionpools as $key => $value)
2596  {
2597  $options[$key] = $value["title"];
2598  }
2599 
2600  $pool = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "qpl");
2601  $pool->setInfo($this->lng->txt('select_question_pool_info'));
2602  $pool->setOptions($options);
2603  $form->addItem($pool);
2604  }
2605 
2606  $form->addCommandButton("importFile", $this->lng->txt("import"));
2607  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
2608 
2609  return $form;
2610  }
2611 
2618  {
2619  $command = $_POST["command"];
2620  if (strlen($command))
2621  {
2622  $method = $command . "Object";
2623  if (method_exists($this, $method))
2624  {
2625  $this->$method();
2626  return;
2627  }
2628  }
2629  $this->ctrl->redirect($this, "participants");
2630  }
2631 
2638  {
2639  global $ilAccess, $ilToolbar, $lng;
2640 
2641  $this->getParticipantsSubTabs();
2642 
2643  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2644  {
2645  // allow only write access
2646  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2647  $this->ctrl->redirect($this, "infoScreen");
2648  }
2649 
2650  if( $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken() )
2651  {
2653  $this->testQuestionSetConfigFactory->getQuestionSetConfig()->getDepenciesBrokenMessage($this->lng)
2654  );
2655  }
2656  elseif( $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesInVulnerableState() )
2657  {
2659  $this->testQuestionSetConfigFactory->getQuestionSetConfig()->getDepenciesInVulnerableStateMessage($this->lng)
2660  );
2661  }
2662 
2663  if ($this->object->getFixedParticipants())
2664  {
2665  // search button
2666  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
2668  $this,
2669  $ilToolbar,
2670  array(
2671  'auto_complete_name' => $lng->txt('user'),
2672  'submit_name' => $lng->txt('add')
2673  )
2674  );
2675 
2676  $ilToolbar->addSeparator();
2677  $search_btn = ilLinkButton::getInstance();
2678  $search_btn->setCaption('tst_search_users');
2679  $search_btn->setUrl($this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI','start'));
2680  $ilToolbar->addButtonInstance($search_btn);
2681  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
2682 
2683  $participants =& $this->object->getInvitedUsers();
2684  $rows = array();
2685  $unfinished_passes = false;
2686  foreach ($participants as $data)
2687  {
2688  $maxpass = $this->object->_getMaxPass($data["active_id"]);
2689  if (!is_null($maxpass))
2690  {
2691  $maxpass += 1;
2692  }
2693  $access = "";
2694  if (strlen($data["active_id"]))
2695  {
2696  $last_access = $this->object->_getLastAccess($data["active_id"]);
2697  $access = $last_access;
2698  }
2699  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
2700 
2701  if ($data['active_id'] == null) // if no active id is set, user is invitee not participant...
2702  {
2703  if ( strlen($data["firstname"].$data["lastname"]) == 0 )
2704  {
2705  $fullname = $lng->txt("deleted_user");
2706  }
2707  else if($this->object->getAnonymity())
2708  {
2709  $fullname = $lng->txt('anonymous');
2710  }
2711  else
2712  {
2713  $fullname = trim($data["lastname"] . ", " . $data["firstname"] . " " . $data["title"]);
2714  }
2715  } else {
2716  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
2717  $fullname = ilObjTestAccess::_getParticipantData($data['active_id']);
2718  }
2719 
2720  $unfinished_pass_data = 0;
2721  if($data["unfinished_passes"] == 1)
2722  {
2723  $unfinished_pass_data = 1;
2724  $unfinished_passes = true;
2725  }
2726 
2727  array_push($rows, array(
2728  'usr_id' => $data["usr_id"],
2729  'active_id' => $data['active_id'],
2730  'login' => $data["login"],
2731  'clientip' => $data["clientip"],
2732  'firstname' => $data["firstname"],
2733  'lastname' => $data["lastname"],
2734  'name' => $fullname,
2735  'started' => ($data["active_id"] > 0) ? 1 : 0,
2736  'unfinished' => $unfinished_pass_data,
2737  'finished' => ($data["test_finished"] == 1) ? 1 : 0,
2738  'access' => $access,
2739  'maxpass' => $maxpass,
2740  'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview'),
2741  'finish_link' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'finishTestPassForSingleUser')
2742  ));
2743  }
2744  include_once "./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php";
2745  $table_gui = new ilTestFixedParticipantsTableGUI( $this, 'participants',
2746  $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken(),
2747  $this->object->getAnonymity(), count($rows)
2748  );
2749  $table_gui->setFilterCommand('fpSetFilter');
2750  $table_gui->setResetCommand('fpResetFiler');
2751  $rows = $this->applyFilterCriteria($rows);
2752  $table_gui->setData($rows);
2753  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2754 
2755  if(count($rows) > 0)
2756  {
2757  $ilToolbar->addSeparator();
2758  $delete_all_results_btn = ilLinkButton::getInstance();
2759  $delete_all_results_btn->setCaption('delete_all_user_data');
2760  $delete_all_results_btn->setUrl($this->ctrl->getLinkTarget($this, 'deleteAllUserResults'));
2761  $ilToolbar->addButtonInstance($delete_all_results_btn);
2762  }
2763  $this->addFinishAllPassesButton($unfinished_passes, $ilToolbar);
2764  }
2765  else
2766  {
2767  $participants =& $this->object->getTestParticipants();
2768  $rows = array();
2769  $unfinished_passes = false;
2770 
2771  foreach ($participants as $data)
2772  {
2773  $maxpass = $this->object->_getMaxPass($data["active_id"]);
2774  if (!is_null($maxpass))
2775  {
2776  $maxpass += 1;
2777  }
2778  $access = "";
2779  if (strlen($data["active_id"]))
2780  {
2781  $last_access = $this->object->_getLastAccess($data["active_id"]);
2782  $access = $last_access;
2783  }
2784  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
2785 
2786  $unfinished_pass_data = 0;
2787  if($data["unfinished_passes"] == 1)
2788  {
2789  $unfinished_pass_data = 1;
2790  $unfinished_passes = true;
2791  }
2792 
2793  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
2794  $fullname = ilObjTestAccess::_getParticipantData($data['active_id']);
2795  array_push($rows, array(
2796  'usr_id' => $data["active_id"],
2797  'active_id' => $data['active_id'],
2798  'login' => $data["login"],
2799  'name' => $fullname,
2800  'firstname' => $data["firstname"],
2801  'lastname' => $data["lastname"],
2802  'started' => ($data["active_id"] > 0) ? 1 : 0,
2803  'unfinished' => $unfinished_pass_data,
2804  'finished' => ($data["test_finished"] == 1) ? 1 : 0,
2805  'access' => $access,
2806  'maxpass' => $maxpass,
2807  'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview'),
2808  'finish_link' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'finishTestPassForSingleUser')
2809  ));
2810  }
2811  include_once "./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php";
2812  $table_gui = new ilTestParticipantsTableGUI( $this, 'participants',
2813  $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken(),
2814  $this->object->getAnonymity(), count($rows)
2815  );
2816 
2817  if(count($rows) > 0)
2818  {
2819  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
2820  $delete_all_results_btn = ilLinkButton::getInstance();
2821  $delete_all_results_btn->setCaption('delete_all_user_data');
2822  $delete_all_results_btn->setUrl($this->ctrl->getLinkTarget($this, 'deleteAllUserResults'));
2823  $ilToolbar->addStickyItem($delete_all_results_btn);
2824  }
2825 
2826  $this->addFinishAllPassesButton($unfinished_passes, $ilToolbar);
2827 
2828  $table_gui->setFilterCommand('npSetFilter');
2829  $table_gui->setResetCommand('npResetFilter');
2830  $rows = $this->applyFilterCriteria($rows);
2831  $table_gui->setData($rows);
2832  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2833  }
2834  }
2835 
2840  protected function addFinishAllPassesButton($unfinished_passes, $ilToolbar)
2841  {
2842  if($unfinished_passes)
2843  {
2844  $ilToolbar->addSeparator();
2845  $finish_all_user_passes_btn = ilLinkButton::getInstance();
2846  $finish_all_user_passes_btn->setCaption('finish_all_user_passes');
2847  $finish_all_user_passes_btn->setUrl($this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'finishAllUserPasses'));
2848  $ilToolbar->addButtonInstance($finish_all_user_passes_btn);
2849  }
2850  }
2851 
2852  public function timingOverviewObject()
2853  {
2854  $this->getParticipantsSubTabs();
2855 
2856  include_once "./Modules/Test/classes/tables/class.ilTimingOverviewTableGUI.php";
2857  $table_gui = new ilTimingOverviewTableGUI($this, 'timingOverview');
2858 
2859  $participants =& $this->object->getTestParticipants();#
2860  $times = $this->object->getStartingTimeOfParticipants();
2861  $addons = $this->object->getTimeExtensionsOfParticipants();
2862 
2863  $tbl_data = array();
2864  foreach ($participants as $participant)
2865  {
2866  $tblRow = array();
2867 
2868  $started = "";
2869  if ($times[$participant['active_id']])
2870  {
2871  $started = $this->lng->txt('tst_started').': '.ilDatePresentation::formatDate(new ilDateTime($times[$participant['active_id']], IL_CAL_DATETIME));
2872  $tblRow['started'] = $started;
2873  }
2874  else
2875  {
2876  $tblRow['started'] = '';
2877  }
2878 
2879  if ($addons[$participant['active_id']] > 0)
2880  {
2881  $tblRow['extratime'] = $addons[$participant['active_id']];
2882  }
2883 
2884  $tblRow['login'] = $participant['login'];
2885 
2886  if ($this->object->getAnonymity())
2887  {
2888  $tblRow['name'] = $this->lng->txt("anonymous");
2889  }
2890  else
2891  {
2892  $tblRow['name'] = $participant['lastname'] . ', ' . $participant['firstname'];
2893  }
2894 
2895  $tbl_data[] = $tblRow;
2896  }
2897  $table_gui->setData($tbl_data);
2898 
2899  $this->tpl->setContent($table_gui->getHTML());
2900  }
2901 
2902  public function timingObject()
2903  {
2904  $this->getParticipantsSubTabs();
2905 
2906  global $ilAccess;
2907 
2908  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2909  {
2910  // allow only write access
2911  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2912  $this->ctrl->redirect($this, "infoScreen");
2913  }
2914 
2915  if ($this->object->getProcessingTimeInSeconds() > 0 && $this->object->getNrOfTries() == 1)
2916  {
2917  $form = $this->formTimingObject();
2918  if (count($_POST) && $form->checkInput())
2919  {
2920  $res = $this->object->addExtraTime($form->getInput('participant'), $form->getInput('extratime'));
2921  ilUtil::sendSuccess(sprintf($this->lng->txt('tst_extratime_added'), $form->getInput('extratime')), true);
2922  $this->ctrl->redirect($this, 'timingOverview');
2923  }
2924  else
2925  {
2926  return $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
2927  }
2928  }
2929  else
2930  {
2931  ilUtil::sendInfo($this->lng->txt("tst_extratime_notavailable"));
2932  }
2933  }
2934 
2935  private function formTimingObject()
2936  {
2937  global $ilAccess;
2938 
2939  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2940  $form = new ilPropertyFormGUI();
2941  $form->setFormAction($this->ctrl->getFormAction($this));
2942  $form->setTableWidth("100%");
2943  $form->setId("tst_change_workingtime");
2944  $form->setTitle($this->lng->txt("tst_change_workingtime"));
2945 
2946  // test users
2947  $participantslist = new ilSelectInputGUI($this->lng->txt('participants'), "participant");
2948  $participants =& $this->object->getTestParticipants();
2949  $times = $this->object->getStartingTimeOfParticipants();
2950  $addons = $this->object->getTimeExtensionsOfParticipants();
2951  $options = array(
2952  '' => $this->lng->txt('please_select'),
2953  '0' => $this->lng->txt('all_participants')
2954  );
2955  foreach ($participants as $participant)
2956  {
2957  $started = "";
2958 
2959  if ($this->object->getAnonymity())
2960  {
2961  $name = $this->lng->txt("anonymous");
2962  }
2963  else
2964  {
2965  $name = $participant['lastname'] . ', ' . $participant['firstname'];
2966  }
2967 
2968 
2969  if ($times[$participant['active_id']])
2970  {
2971  $started = ", ".$this->lng->txt('tst_started').': '.ilDatePresentation::formatDate(new ilDateTime($times[$participant['active_id']], IL_CAL_DATETIME));
2972  }
2973  if ($addons[$participant['active_id']] > 0) $started .= ", " . $this->lng->txt('extratime') . ': ' . $addons[$participant['active_id']] . ' ' . $this->lng->txt('minutes');
2974  $options[$participant['active_id']] = $participant['login'] . ' (' .$name. ')'.$started;
2975  }
2976  $participantslist->setRequired(true);
2977  $participantslist->setOptions($options);
2978  $form->addItem($participantslist);
2979 
2980  // extra time
2981  $extratime = new ilNumberInputGUI($this->lng->txt("extratime"), "extratime");
2982  $extratime->setInfo($this->lng->txt('tst_extratime_info'));
2983  $extratime->setRequired(true);
2984  $extratime->setMinValue(0);
2985  $extratime->setMinvalueShouldBeGreater(false);
2986  $extratime->setSuffix($this->lng->txt('minutes'));
2987  $extratime->setSize(5);
2988  $form->addItem($extratime);
2989 
2990  if (is_array($_POST) && strlen($_POST['cmd']['timing'])) $form->setValuesByArray($_POST);
2991 
2992  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form->addCommandButton("timing", $this->lng->txt("save"));
2993  $form->addCommandButton('timingOverview', $this->lng->txt("cancel"));
2994  return $form;
2995  }
2996 
2997  public function showTimingFormObject()
2998  {
2999  $form = $this->formTimingObject();
3000  $this->tpl->setContent($form->getHTML());
3001  }
3002 
3003  function applyFilterCriteria($in_rows)
3004  {
3005  global $ilDB;
3006  $sess_filter = $_SESSION['form_tst_participants_' . $this->ref_id]['selection'];
3007  $sess_filter = str_replace('"','',$sess_filter);
3008  $sess_filter = explode(':', $sess_filter);
3009  $filter = substr($sess_filter[2],0, strlen($sess_filter[2])-1);
3010 
3011  if ($filter == 'all' || $filter == false)
3012  {
3013  return $in_rows; #unchanged - no filter.
3014  }
3015 
3016  $with_result = array();
3017  $without_result = array();
3018  foreach ($in_rows as $row)
3019  {
3020  $result = $ilDB->query(
3021  'SELECT count(solution_id) count
3022  FROM tst_solutions
3023  WHERE active_fi = ' . $ilDB->quote($row['active_id'])
3024  );
3025  $count = $ilDB->fetchAssoc($result);
3026  $count = $count['count'];
3027 
3028  if ($count == 0)
3029  {
3030  $without_result[] = $row;
3031  }
3032  else
3033  {
3034  $with_result[] = $row;
3035  }
3036  }
3037 
3038  if ($filter == 'withSolutions')
3039  {
3040  return $with_result;
3041  }
3042  return $without_result;
3043 
3044  }
3045 
3047  {
3048  include_once("./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php");
3049  $table_gui = new ilTestFixedParticipantsTableGUI($this, "participants", false, $this->object->getAnonymity(), 0);
3050  $table_gui->writeFilterToSession(); // writes filter to session
3051  $table_gui->resetOffset(); // sets record offest to 0 (first page)
3052  $this->participantsObject();
3053  }
3054 
3056  {
3057  include_once("./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php");
3058  $table_gui = new ilTestFixedParticipantsTableGUI(
3059  $this, "participants", false, $this->object->getAnonymity(), 0
3060  );
3061  $table_gui->resetFilter(); // writes filter to session
3062  $table_gui->resetOffset(); // sets record offest to 0 (first page)
3063  $this->participantsObject();
3064  }
3065 
3067  {
3068  include_once("./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php");
3069  $table_gui = new ilTestParticipantsTableGUI(
3070  $this, "participants", false, $this->object->getAnonymity(), 0
3071  );
3072  $table_gui->writeFilterToSession(); // writes filter to session
3073  $table_gui->resetOffset(); // sets record offest to 0 (first page)
3074  $this->participantsObject();
3075 
3076  }
3077 
3079  {
3080  include_once("./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php");
3081  $table_gui = new ilTestParticipantsTableGUI(
3082  $this, "participants", false, $this->object->getAnonymity(), 0
3083  );
3084  $table_gui->resetFilter(); // writes filter to session
3085  $table_gui->resetOffset(); // sets record offest to 0 (first page)
3086  $this->participantsObject();
3087 
3088  }
3089 
3096  {
3097  if (count($_POST))
3098  {
3099  $_SESSION["show_user_results"] = $_POST["chbUser"];
3100  }
3101  $this->showUserResults($show_pass_details = TRUE, $show_answers = TRUE, $show_reached_points = TRUE);
3102  }
3103 
3110  {
3111  if (count($_POST))
3112  {
3113  $_SESSION["show_user_results"] = $_POST["chbUser"];
3114  }
3115  $this->showUserResults($show_pass_details = FALSE, $show_answers = TRUE);
3116  }
3117 
3124  {
3125  if (count($_POST))
3126  {
3127  $_SESSION["show_user_results"] = $_POST["chbUser"];
3128  }
3129  $this->showUserResults($show_pass_details = TRUE, $show_answers = FALSE);
3130  }
3131 
3137  function showUserResults($show_pass_details, $show_answers, $show_reached_points = FALSE)
3138  {
3139  $show_user_results = $_SESSION["show_user_results"];
3140 
3141  if (count($show_user_results) == 0)
3142  {
3143  ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE);
3144  $this->ctrl->redirect($this, "participants");
3145  }
3146 
3147 
3148  $template = $this->createUserResults( $show_pass_details, $show_answers, $show_reached_points, $show_user_results);
3149 
3150  if($template instanceof ilTemplate)
3151  {
3152  $this->tpl->setVariable("ADM_CONTENT", $template->get());
3153  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
3154  if ($this->object->getShowSolutionAnswersOnly())
3155  {
3156  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
3157  }
3158  }
3159  }
3160 
3162  {
3163  if (is_array($_POST["chbUser"]))
3164  {
3165  foreach ($_POST["chbUser"] as $user_id)
3166  {
3167  $this->object->disinviteUser($user_id);
3168  }
3169  }
3170  else
3171  {
3172  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
3173  }
3174  $this->ctrl->redirect($this, "participants");
3175  }
3176 
3178  {
3179  if (is_array($_POST["chbUser"]))
3180  {
3181  foreach ($_POST["chbUser"] as $user_id)
3182  {
3183  $this->object->setClientIP($user_id, $_POST["clientip_".$user_id]);
3184  }
3185  }
3186  else
3187  {
3188  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
3189  }
3190  $this->ctrl->redirect($this, "participants");
3191  }
3192 
3200  function printobject()
3201  {
3202  global $ilAccess, $ilias;
3203  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3204  {
3205  // allow only write access
3206  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3207  $this->ctrl->redirect($this, "infoScreen");
3208  }
3209 
3210  $isPdfDeliveryRequest = isset($_GET['pdf']) && $_GET['pdf'];
3211 
3212  $this->getQuestionsSubTabs();
3213  $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", TRUE, TRUE, "Modules/Test");
3214 
3215  if(!$isPdfDeliveryRequest) // #15243
3216  {
3217  $this->ctrl->setParameter($this, "pdf", "1");
3218  $template->setCurrentBlock("pdf_export");
3219  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "print"));
3220  $this->ctrl->setParameter($this, "pdf", "");
3221  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
3222  $template->parseCurrentBlock();
3223 
3224  $template->setCurrentBlock("navigation_buttons");
3225  $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
3226  $template->parseCurrentBlock();
3227  }
3228  // prepare generation before contents are processed (for mathjax)
3229  else
3230  {
3231  require_once 'Services/PDFGeneration/classes/class.ilPDFGeneration.php';
3233  }
3234 
3235  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
3236 
3237  global $ilUser;
3238  $print_date = mktime(date("H"), date("i"), date("s"), date("m") , date("d"), date("Y"));
3239  $max_points= 0;
3240  $counter = 1;
3241 
3242  require_once 'Modules/Test/classes/class.ilTestQuestionHeaderBlockBuilder.php';
3243  $questionHeaderBlockBuilder = new ilTestQuestionHeaderBlockBuilder($this->lng);
3244  $questionHeaderBlockBuilder->setHeaderMode($this->object->getTitleOutput());
3245 
3246  if($isPdfDeliveryRequest)
3247  {
3248  require_once 'Services/WebAccessChecker/classes/class.ilWACSignedPath.php';
3250  }
3251 
3252  foreach ($this->object->questions as $question)
3253  {
3254  $template->setCurrentBlock("question");
3255  $question_gui = $this->object->createQuestionGUI("", $question);
3256 
3257  if( $isPdfDeliveryRequest )
3258  {
3259  $question_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PRINT_PDF);
3260  }
3261 
3262  $questionHeaderBlockBuilder->setQuestionTitle($question_gui->object->getTitle());
3263  $questionHeaderBlockBuilder->setQuestionPoints($question_gui->object->getMaximumPoints());
3264  $questionHeaderBlockBuilder->setQuestionPosition($counter);
3265  $template->setVariable("QUESTION_HEADER", $questionHeaderBlockBuilder->getHTML());
3266 
3267  $template->setVariable("TXT_QUESTION_ID", $this->lng->txt('question_id_short'));
3268  $template->setVariable("QUESTION_ID", $question_gui->object->getId());
3269  $result_output = $question_gui->getSolutionOutput("", NULL, FALSE, TRUE, FALSE, $this->object->getShowSolutionFeedback());
3270  $template->setVariable("SOLUTION_OUTPUT", $result_output);
3271  $template->parseCurrentBlock("question");
3272  $counter ++;
3273  $max_points += $question_gui->object->getMaximumPoints();
3274  }
3275 
3276  $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
3277  $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("tst_print")));
3278  $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
3279  $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c",$print_date)));
3280  $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
3281  $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
3282 
3283  if( $isPdfDeliveryRequest )
3284  {
3285  require_once 'class.ilTestPDFGenerator.php';
3286  ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitleFilenameCompliant());
3287  }
3288  else
3289  {
3290  $this->tpl->setVariable("PRINT_CONTENT", $template->get());
3291  }
3292  }
3293 
3301  function reviewobject()
3302  {
3303  global $ilAccess, $ilias;
3304  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3305  {
3306  // allow only write access
3307  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3308  $this->ctrl->redirect($this, "infoScreen");
3309  }
3310  $this->getQuestionsSubTabs();
3311  $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", TRUE, TRUE, "Modules/Test");
3312 
3313  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
3314 
3315  $isPdfDeliveryRequest = isset($_GET['pdf']) && $_GET['pdf'];
3316 
3317  global $ilUser;
3318  $print_date = mktime(date("H"), date("i"), date("s"), date("m") , date("d"), date("Y"));
3319  $max_points= 0;
3320  $counter = 1;
3321 
3322  require_once 'Modules/Test/classes/class.ilTestQuestionHeaderBlockBuilder.php';
3323  $questionHeaderBlockBuilder = new ilTestQuestionHeaderBlockBuilder($this->lng);
3324  $questionHeaderBlockBuilder->setHeaderMode($this->object->getTitleOutput());
3325 
3326  if($isPdfDeliveryRequest)
3327  {
3328  require_once 'Services/WebAccessChecker/classes/class.ilWACSignedPath.php';
3330 
3331  // prepare generation before contents are processed (for mathjax)
3332  require_once 'Services/PDFGeneration/classes/class.ilPDFGeneration.php';
3334  }
3335 
3336  foreach ($this->object->questions as $question)
3337  {
3338  $template->setCurrentBlock("question");
3339  $question_gui = $this->object->createQuestionGUI("", $question);
3340  $question_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
3341 
3342  $questionHeaderBlockBuilder->setQuestionTitle($question_gui->object->getTitle());
3343  $questionHeaderBlockBuilder->setQuestionPoints($question_gui->object->getMaximumPoints());
3344  $questionHeaderBlockBuilder->setQuestionPosition($counter);
3345  $template->setVariable("QUESTION_HEADER", $questionHeaderBlockBuilder->getHTML());
3346 
3347  $template->setVariable("SOLUTION_OUTPUT", $question_gui->getPreview(false));
3348  $template->parseCurrentBlock("question");
3349  $counter ++;
3350  $max_points += $question_gui->object->getMaximumPoints();
3351  }
3352 
3353 
3354 
3355  $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
3356  $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("review_view")));
3357  $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
3358  $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c",$print_date)));
3359  $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
3360  $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
3361 
3362  if($isPdfDeliveryRequest)
3363  {
3364  require_once 'class.ilTestPDFGenerator.php';
3365  ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitleFilenameCompliant());
3366  }
3367  else
3368  {
3369  $this->ctrl->setParameter($this, "pdf", "1");
3370  $template->setCurrentBlock("pdf_export");
3371  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "review"));
3372  $this->ctrl->setParameter($this, "pdf", "");
3373  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
3374  $template->parseCurrentBlock();
3375 
3376  $template->setCurrentBlock("navigation_buttons");
3377  $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
3378  $template->parseCurrentBlock();
3379 
3380 
3381  $this->tpl->setVariable("PRINT_CONTENT", $template->get());
3382  }
3383  }
3384 
3385  function addParticipantsObject($a_user_ids = array())
3386  {
3387  $countusers = 0;
3388  // add users
3389  if (is_array($a_user_ids))
3390  {
3391  $i = 0;
3392  foreach ($a_user_ids as $user_id)
3393  {
3394  $client_ip = $_POST["client_ip"][$i];
3395  $this->object->inviteUser($user_id, $client_ip);
3396  $countusers++;
3397  $i++;
3398  }
3399  }
3400  $message = "";
3401  if ($countusers)
3402  {
3403  $message = $this->lng->txt("tst_invited_selected_users");
3404  }
3405  if (strlen($message))
3406  {
3407  ilUtil::sendInfo($message, TRUE);
3408  }
3409  else
3410  {
3411  ilUtil::sendInfo($this->lng->txt("tst_invited_nobody"), TRUE);
3412  return false;
3413  }
3414 
3415  $this->ctrl->redirect($this, "participants");
3416  }
3417 
3421  public function defaultsObject()
3422  {
3428  global $ilAccess, $ilToolbar, $tpl;
3429 
3430  if(!$ilAccess->checkAccess("write", "", $this->ref_id))
3431  {
3432  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3433  $this->ctrl->redirect($this, "infoScreen");
3434  }
3435 
3436  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'addDefaults'));
3437  $ilToolbar->addFormButton($this->lng->txt('add'), 'addDefaults');
3438  require_once 'Services/Form/classes/class.ilTextInputGUI.php';
3439  $ilToolbar->addInputItem(new ilTextInputGUI($this->lng->txt('tst_defaults_defaults_of_test'), 'name'), true);
3440 
3441  require_once 'Modules/Test/classes/tables/class.ilTestPersonalDefaultSettingsTableGUI.php';
3442  $table = new ilTestPersonalDefaultSettingsTableGUI($this, 'defaults');
3443  $defaults = $this->object->getAvailableDefaults();
3444  $table->setData((array)$defaults);
3445  $tpl->setContent($table->getHTML());
3446  }
3447 
3451  public function deleteDefaultsObject()
3452  {
3453  if(isset($_POST['chb_defaults']) && is_array($_POST['chb_defaults']) && count($_POST['chb_defaults']))
3454  {
3455  foreach($_POST['chb_defaults'] as $test_default_id)
3456  {
3457  $this->object->deleteDefaults($test_default_id);
3458  }
3459  }
3460  else
3461  {
3462  ilUtil::sendInfo($this->lng->txt('select_one'));
3463  }
3464  $this->defaultsObject();
3465  }
3466 
3471  {
3472  $this->applyDefaultsObject(true);
3473  return;
3474  }
3475 
3479  public function applyDefaultsObject($confirmed = false)
3480  {
3481  if( !is_array($_POST["chb_defaults"]) || 1 !== count($_POST["chb_defaults"]))
3482  {
3484  $this->lng->txt("tst_defaults_apply_select_one")
3485  );
3486 
3487  return $this->defaultsObject();
3488  }
3489 
3490  // do not apply if user datasets exist
3491  if($this->object->evalTotalPersons() > 0)
3492  {
3494  $this->lng->txt("tst_defaults_apply_not_possible")
3495  );
3496 
3497  return $this->defaultsObject();
3498  }
3499 
3500  $defaults =& $this->object->getTestDefaults($_POST["chb_defaults"][0]);
3501  $defaultSettings = unserialize($defaults["defaults"]);
3502 
3503  if( isset($defaultSettings['isRandomTest']) )
3504  {
3505  if( $defaultSettings['isRandomTest'] )
3506  {
3507  $newQuestionSetType = ilObjTest::QUESTION_SET_TYPE_RANDOM;
3508  $this->object->setQuestionSetType(ilObjTest::QUESTION_SET_TYPE_RANDOM);
3509  }
3510  else
3511  {
3512  $newQuestionSetType = ilObjTest::QUESTION_SET_TYPE_FIXED;
3513  $this->object->setQuestionSetType(ilObjTest::QUESTION_SET_TYPE_FIXED);
3514  }
3515  }
3516  elseif( isset($defaultSettings['questionSetType']) )
3517  {
3518  $newQuestionSetType = $defaultSettings['questionSetType'];
3519  }
3520  $oldQuestionSetType = $this->object->getQuestionSetType();
3521  $questionSetTypeSettingSwitched = ( $oldQuestionSetType != $newQuestionSetType );
3522 
3523  $oldQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfigByType($oldQuestionSetType);
3524 
3525  switch( true )
3526  {
3527  case !$questionSetTypeSettingSwitched:
3528  case !$oldQuestionSetConfig->doesQuestionSetRelatedDataExist():
3529  case $confirmed:
3530 
3531  break;
3532 
3533  default:
3534 
3535  require_once 'Modules/Test/classes/confirmations/class.ilTestSettingsChangeConfirmationGUI.php';
3536  $confirmation = new ilTestSettingsChangeConfirmationGUI($this->lng, $this->object);
3537 
3538  $confirmation->setFormAction( $this->ctrl->getFormAction($this) );
3539  $confirmation->setCancel($this->lng->txt('cancel'), 'defaults');
3540  $confirmation->setConfirm($this->lng->txt('confirm'), 'confirmedApplyDefaults');
3541 
3542  $confirmation->setOldQuestionSetType($this->object->getQuestionSetType());
3543  $confirmation->setNewQuestionSetType($newQuestionSetType);
3544  $confirmation->setQuestionLossInfoEnabled(false);
3545  $confirmation->build();
3546 
3547  $confirmation->populateParametersFromPost();
3548 
3549  $this->tpl->setContent( $this->ctrl->getHTML($confirmation) );
3550 
3551  return;
3552  }
3553 
3554  if( $questionSetTypeSettingSwitched && $this->object->isOnline() )
3555  {
3556  $this->object->setOnline(false);
3557 
3558  $info = $this->lng->txt("tst_set_offline_due_to_switched_question_set_type_setting");
3559 
3560  ilUtil::sendInfo($info, true);
3561  }
3562 
3563  $this->object->applyDefaults($defaults);
3564 
3565  ilUtil::sendSuccess($this->lng->txt("tst_defaults_applied"), true);
3566 
3567  if( $questionSetTypeSettingSwitched && $oldQuestionSetConfig->doesQuestionSetRelatedDataExist() )
3568  {
3569  $oldQuestionSetConfig->removeQuestionSetRelatedData();
3570  }
3571 
3572  $this->ctrl->redirect($this, 'defaults');
3573  }
3574 
3579  {
3580  if (strlen($_POST["name"]) > 0)
3581  {
3582  $this->object->addDefaults($_POST['name']);
3583  }
3584  else
3585  {
3586  ilUtil::sendInfo($this->lng->txt("tst_defaults_enter_name"));
3587  }
3588  $this->defaultsObject();
3589  }
3590 
3592  {
3593  if( in_array($this->ctrl->getCmdClass(), self::$infoScreenChildClasses) )
3594  {
3595  return true;
3596  }
3597 
3598  return false;
3599  }
3600 
3606  function infoScreenObject()
3607  {
3608  #if( !include 'competenzenRocker.php' ) exit;
3609 
3610  $this->ctrl->setCmd("showSummary");
3611  $this->ctrl->setCmdClass("ilinfoscreengui");
3612  $this->infoScreen();
3613  }
3614 
3616  {
3617  $this->ctrl->setCmd("showSummary");
3618  $this->ctrl->setCmdClass("ilinfoscreengui");
3619  $this->infoScreen($_GET['lock']);
3620  }
3621 
3625  function infoScreen($session_lock = "")
3626  {
3632  global $ilAccess, $ilUser, $ilToolbar;
3633 
3634  if ($_GET['createRandomSolutions'])
3635  {
3636  global $ilCtrl;
3637 
3638  $this->object->createRandomSolutions($_GET['createRandomSolutions']);
3639 
3640  $ilCtrl->redirect($this);
3641  }
3642 
3643  if (!$ilAccess->checkAccess("read", "", $this->ref_id))
3644  {
3645  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
3646  }
3647 
3648  $this->trackTestObjectReadEvent();
3649 
3650  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
3651  $info = new ilInfoScreenGUI($this);
3652  $info->setOpenFormTag(false);
3653 
3654  if( $this->isCommandClassAnyInfoScreenChild() )
3655  {
3656  return $this->ctrl->forwardCommand($info);
3657  }
3658 
3659  require_once 'Modules/Test/classes/class.ilTestInfoScreenToolbarFactory.php';
3660  $toolbarFactory = new ilTestInfoScreenToolbarFactory();
3661  $toolbarFactory->setTestOBJ($this->object);
3662  $toolbar = $toolbarFactory->getToolbarInstance();
3663 
3664  $toolbar->setGlobalToolbar($GLOBALS['DIC']['ilToolbar']);
3665  $toolbar->setCloseFormTag(false);
3666 
3667  $toolbar->setSessionLockString($session_lock);
3668  $toolbar->build();
3669  $toolbar->sendMessages();
3670 
3671  if ($this->object->getShowInfo())
3672  {
3673  $info->enablePrivateNotes();
3674  }
3675 
3676  if (strlen($this->object->getIntroduction()))
3677  {
3678  $info->addSection($this->lng->txt("tst_introduction"));
3679  $info->addProperty("", $this->object->prepareTextareaOutput($this->object->getIntroduction(), true).
3680  $info->getHiddenToggleButton());
3681  }
3682  else
3683  {
3684  $info->addSection("");
3685  $info->addProperty("", $info->getHiddenToggleButton());
3686  }
3687 
3688  $info->addSection($this->lng->txt("tst_general_properties"));
3689  if ($this->object->getShowInfo())
3690  {
3691  $info->addProperty($this->lng->txt("author"), $this->object->getAuthor());
3692  $info->addProperty($this->lng->txt("title"), $this->object->getTitle());
3693  }
3694  if( $this->object->isOnline() && $this->object->isComplete( $this->testQuestionSetConfigFactory->getQuestionSetConfig() ) )
3695  {
3696  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
3697  {
3698  if ($this->object->getShowInfo() || !$this->object->getForceJS())
3699  {
3700  // use javascript
3701  $checked_javascript = false;
3702  if ($this->object->getJavaScriptOutput())
3703  {
3704  $checked_javascript = true;
3705  }
3706  }
3707  // hide previous results
3708  if(!$this->object->isRandomTest() && !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired())
3709  {
3710  if ($this->object->getNrOfTries() != 1)
3711  {
3712  if ($this->object->getUsePreviousAnswers() == 0)
3713  {
3714  if ($this->object->getShowInfo())
3715  {
3716  $info->addProperty($this->lng->txt("tst_use_previous_answers"), $this->lng->txt("tst_dont_use_previous_answers"));
3717  }
3718  }
3719  else
3720  {
3721  $use_previous_answers = FALSE;
3722  if ($ilUser->prefs["tst_use_previous_answers"])
3723  {
3724  $checked_previous_answers = TRUE;
3725  }
3726  $info->addPropertyCheckbox($this->lng->txt("tst_use_previous_answers"), "chb_use_previous_answers", 1, $this->lng->txt("tst_use_previous_answers_user"), $checked_previous_answers);
3727  }
3728  }
3729  }
3730  }
3731  }
3732 
3733  $info->hideFurtherSections(false);
3734 
3735  if ($this->object->getShowInfo())
3736  {
3737  $info->addSection($this->lng->txt("tst_sequence_properties"));
3738  $info->addProperty($this->lng->txt("tst_sequence"), $this->lng->txt(($this->object->getSequenceSettings() == TEST_FIXED_SEQUENCE)? "tst_sequence_fixed":"tst_sequence_postpone"));
3739 
3740  $info->addSection($this->lng->txt("tst_heading_scoring"));
3741  $info->addProperty($this->lng->txt("tst_text_count_system"), $this->lng->txt(($this->object->getCountSystem() == COUNT_PARTIAL_SOLUTIONS)? "tst_count_partial_solutions":"tst_count_correct_solutions"));
3742  $info->addProperty($this->lng->txt("tst_score_mcmr_questions"), $this->lng->txt(($this->object->getMCScoring() == SCORE_ZERO_POINTS_WHEN_UNANSWERED)? "tst_score_mcmr_zero_points_when_unanswered":"tst_score_mcmr_use_scoring_system"));
3743  if ($this->object->isRandomTest())
3744  {
3745  $info->addProperty($this->lng->txt("tst_pass_scoring"), $this->lng->txt(($this->object->getPassScoring() == SCORE_BEST_PASS)? "tst_pass_best_pass":"tst_pass_last_pass"));
3746  }
3747 
3748  $info->addSection($this->lng->txt("tst_score_reporting"));
3749  $score_reporting_text = "";
3750  switch ($this->object->getScoreReporting())
3751  {
3752  case REPORT_AFTER_TEST:
3753  $score_reporting_text = $this->lng->txt("tst_report_after_test");
3754  break;
3755  case REPORT_ALWAYS:
3756  $score_reporting_text = $this->lng->txt("tst_report_after_first_question");
3757  break;
3758  case REPORT_AFTER_DATE:
3759  $score_reporting_text = $this->lng->txt("tst_report_after_date");
3760  break;
3761  case 4:
3762  $score_reporting_text = $this->lng->txt("tst_report_never");
3763  break;
3764  }
3765  $info->addProperty($this->lng->txt("tst_score_reporting"), $score_reporting_text);
3766  $reporting_date = $this->object->getReportingDate();
3767  if ($reporting_date)
3768  {
3769  #preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $reporting_date, $matches);
3770  #$txt_reporting_date = date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]));
3771  #$info->addProperty($this->lng->txt("tst_score_reporting_date"), $txt_reporting_date);
3772  $info->addProperty($this->lng->txt('tst_score_reporting_date'),
3774  }
3775 
3776  $info->addSection($this->lng->txt("tst_session_settings"));
3777  $info->addProperty($this->lng->txt("tst_nr_of_tries"), ($this->object->getNrOfTries() == 0)?$this->lng->txt("unlimited"):$this->object->getNrOfTries());
3778  if ($this->object->getNrOfTries() != 1)
3779  {
3780  $info->addProperty($this->lng->txt("tst_nr_of_tries_of_user"), ($toolbar->getTestSession()->getPass() == false)?$this->lng->txt("tst_no_tries"):$toolbar->getTestSequence()->getPass());
3781  }
3782 
3783  if ($this->object->getEnableProcessingTime())
3784  {
3785  $info->addProperty($this->lng->txt("tst_processing_time"), $this->object->getProcessingTime());
3786  }
3787  if (strlen($this->object->getAllowedUsers()) && ($this->object->getAllowedUsersTimeGap()))
3788  {
3789  $info->addProperty($this->lng->txt("tst_allowed_users"), $this->object->getAllowedUsers());
3790  }
3791 
3792  $starting_time = $this->object->getStartingTime();
3793  if ($this->object->isStartingTimeEnabled() && $starting_time != 0)
3794  {
3795  $info->addProperty($this->lng->txt("tst_starting_time"), ilDatePresentation::formatDate(new ilDateTime($starting_time, IL_CAL_UNIX)));
3796  }
3797  $ending_time = $this->object->getEndingTime();
3798  if ($this->object->isEndingTimeEnabled() && $ending_time != 0)
3799  {
3800  $info->addProperty($this->lng->txt("tst_ending_time"), ilDatePresentation::formatDate(new ilDateTime($ending_time, IL_CAL_UNIX)));
3801  }
3802  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
3803  // forward the command
3804  }
3805 
3806  $this->ctrl->forwardCommand($info);
3807  }
3808 
3809  protected function removeImportFailsObject()
3810  {
3811  require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImportFails.php';
3812  $qsaImportFails = new ilAssQuestionSkillAssignmentImportFails($this->object->getId());
3813  $qsaImportFails->deleteRegisteredImportFails();
3814 
3815  require_once 'Modules/Test/classes/class.ilTestSkillLevelThresholdImportFails.php';
3816  $sltImportFails = new ilTestSkillLevelThresholdImportFails($this->object->getId());
3817  $sltImportFails->deleteRegisteredImportFails();
3818 
3819  $this->ctrl->redirect($this, 'infoScreen');
3820  }
3821 
3822  function addLocatorItems()
3823  {
3824  global $ilLocator;
3825  switch ($this->ctrl->getCmd())
3826  {
3827  case "run":
3828  case "infoScreen":
3829  case "redirectToInfoScreen":
3830  case "start":
3831  case "resume":
3832  case "previous":
3833  case "next":
3834  case "summary":
3835  case "finishTest":
3836  case "outCorrectSolution":
3837  case "passDetails":
3838  case "showAnswersOfUser":
3839  case "outUserResultsOverview":
3840  case "backFromSummary":
3841  case "show_answers":
3842  case "setsolved":
3843  case "resetsolved":
3844  case "outTestSummary":
3845  case "outQuestionSummary":
3846  case "gotoQuestion":
3847  case "selectImagemapRegion":
3848  case "confirmSubmitAnswers":
3849  case "finalSubmission":
3850  case "postpone":
3851  case "outUserPassDetails":
3852  case "checkPassword":
3853  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
3854  break;
3855  case "eval_stat":
3856  case "evalAllUsers":
3857  case "evalUserDetail":
3858  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "eval_stat"), "", $_GET["ref_id"]);
3859  break;
3860  case "create":
3861  case "save":
3862  case "cancel":
3863  case "importFile":
3864  case "cloneAll":
3865  case "importVerifiedFile":
3866  case "cancelImport":
3867  break;
3868  default:
3869  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
3870  break;
3871  }
3872  }
3873 
3875  {
3876  global $ilAccess;
3877  if ($ilAccess->checkAccess("write", "", $this->ref_id))
3878  {
3879  $this->ctrl->saveParameterByClass($this->ctrl->getCmdClass(), 'q_id');
3880  // edit page
3881  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), "questions"));
3882  $tabs_gui->addTarget("tst_browse_for_questions",
3883  $this->ctrl->getLinkTarget($this, "browseForQuestions"),
3884  array("browseForQuestions", "filter", "resetFilter", "resetTextFilter", "insertQuestions"),
3885  "", "", TRUE
3886  );
3887  }
3888  }
3889 
3891  {
3892  global $ilAccess;
3893  if ($ilAccess->checkAccess("write", "", $this->ref_id))
3894  {
3895  // edit page
3896  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTarget($this, "questions"));
3897  $tabs_gui->addTarget("random_selection",
3898  $this->ctrl->getLinkTarget($this, "randomQuestions"),
3899  array("randomQuestions"),
3900  "", ""
3901  );
3902  }
3903  }
3904 
3905  function statisticsObject()
3906  {
3907  }
3908 
3913  {
3914  include_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
3915  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
3916  $output_gui = new ilCertificateGUI(new ilTestCertificateAdapter($this->object));
3917  $output_gui->certificateEditor();
3918  }
3919 
3921  {
3922  global $ilTabs, $ilCtrl;
3923  $ilTabs->activateTab('assQuestions');
3924  $a_cmd = $ilCtrl->getCmd();
3925 
3926  if (!$this->object->isRandomTest())
3927  {
3928  #if (in_array($this->object->getEnabledViewMode(), array('both', 'express'))) {
3929  $questions_per_page = ($a_cmd == 'questions_per_page' || ($a_cmd == 'removeQuestions' && $_REQUEST['test_express_mode'])) ? true : false;
3930 
3931  $this->tabs_gui->addSubTabTarget(
3932  "questions_per_page_view",
3933  $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'showPage'),
3934  "", "", "", $questions_per_page);
3935  #}
3936  }
3937  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
3938  $template = new ilSettingsTemplate($this->object->getTemplate(), ilObjAssessmentFolderGUI::getSettingsTemplateConfig());
3939 
3940  if (!in_array('questions', $template->getHiddenTabs())) {
3941  // questions subtab
3942  $ilTabs->addSubTabTarget("edit_test_questions",
3943  $this->ctrl->getLinkTarget($this,'questions'),
3944  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
3945  "randomselect", "filter", "resetFilter", "insertQuestions",
3946  "back", "createRandomSelection", "cancelRandomSelect",
3947  "insertRandomSelection", "removeQuestions", "moveQuestions",
3948  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
3949  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
3950  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode"),
3951  "");
3952 
3953  if (in_array($a_cmd, array('questions', 'createQuestion')) || ($a_cmd == 'removeQuestions' && !$_REQUEST['test_express_mode']))
3954  $this->tabs_gui->activateSubTab('edit_test_questions');
3955  }
3956  #}
3957 
3958  // print view subtab
3959  if (!$this->object->isRandomTest())
3960  {
3961  $ilTabs->addSubTabTarget("print_view",
3962  $this->ctrl->getLinkTarget($this,'print'),
3963  "print", "", "", $this->ctrl->getCmd() == 'print');
3964  $ilTabs->addSubTabTarget('review_view',
3965  $this->ctrl->getLinkTarget($this, 'review'),
3966  'review', '', '', $this->ctrl->getCmd() == 'review');
3967  }
3968 
3969 
3970  }
3971 
3973  {
3974  global $ilTabs;
3975 
3976  // user results subtab
3977  $ilTabs->addSubTabTarget("eval_all_users",
3978  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
3979  array("outEvaluation", "detailedEvaluation", "exportEvaluation", "evalUserDetail", "passDetails",
3980  "outStatisticsResultsOverview", "statisticsPassDetails")
3981  , "");
3982 
3983  // aggregated results subtab
3984  $ilTabs->addSubTabTarget("tst_results_aggregated",
3985  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "eval_a"),
3986  array("eval_a"),
3987  "", "");
3988 
3989  // question export
3990  $ilTabs->addSubTabTarget("tst_single_results",
3991  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "singleResults"),
3992  array("singleResults"),
3993  "", "");
3994  }
3995 
3996  function getSettingsSubTabs($hiddenTabs = array())
3997  {
4001  global $ilTabs, $ilias;
4002 
4003  // general subtab
4004  $ilTabs->addSubTabTarget('general', $this->ctrl->getLinkTargetByClass('ilObjTestSettingsGeneralGUI'),
4005  '', // auto activation regardless from cmd
4006  array('ilobjtestsettingsgeneralgui') // auto activation for ilObjTestSettingsGeneralGUI
4007  );
4008 
4009  if(!in_array('mark_schema', $hiddenTabs))
4010  {
4011  $ilTabs->addSubTabTarget(
4012  'mark_schema',
4013  $this->ctrl->getLinkTargetByClass('ilmarkschemagui', 'showMarkSchema'),
4014  '',
4015  array('ilmarkschemagui')
4016  );
4017  }
4018 
4019  // scoring subtab
4020  $ilTabs->addSubTabTarget('scoring', $this->ctrl->getLinkTargetByClass('ilObjTestSettingsScoringResultsGUI'),
4021  '', // auto activation regardless from cmd
4022  array('ilobjtestsettingsscoringresultsgui') // auto activation for ilObjTestSettingsScoringResultsGUI
4023  );
4024 
4025  // certificate subtab
4026  include_once "Services/Certificate/classes/class.ilCertificate.php";
4027  if( !in_array('certificate', $hiddenTabs) && ilCertificate::isActive())
4028  {
4029  $ilTabs->addSubTabTarget(
4030  "certificate",
4031  $this->ctrl->getLinkTarget($this,'certificate'),
4032  array("certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave",
4033  "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport"),
4034  array("", "ilobjtestgui", "ilcertificategui")
4035  );
4036  }
4037 
4038  if (!in_array('defaults', $hiddenTabs)) {
4039  // defaults subtab
4040  $ilTabs->addSubTabTarget(
4041  "tst_default_settings",
4042  $this->ctrl->getLinkTarget($this, "defaults"),
4043  array("defaults", "deleteDefaults", "addDefaults", "applyDefaults"),
4044  array("", "ilobjtestgui", "ilcertificategui")
4045  );
4046  }
4047  }
4048 
4050  {
4051  global $ilTabs;
4052 
4053  // participants subtab
4054  $ilTabs->addSubTabTarget( "participants",
4055  $this->ctrl->getLinkTarget($this,'participants'),
4056  array(
4057  "participants", "saveClientIP",
4058  "removeParticipant",
4059  "showParticipantAnswersForAuthor",
4060  "deleteAllUserResults",
4061  "cancelDeleteAllUserData", "deleteSingleUserResults",
4062  "outParticipantsResultsOverview", "outParticipantsPassDetails",
4063  "showPassOverview", "showUserAnswers", "participantsAction",
4064  "showDetailedResults",
4065  'npResetFilter', 'npSetFilter'
4066  ),
4067  ""
4068  );
4069 
4070  if( !$this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken() )
4071  {
4072  if($this->object->getProcessingTimeInSeconds() > 0 && $this->object->getNrOfTries() == 1)
4073  {
4074  // extratime subtab
4075  $ilTabs->addSubTabTarget( "timing",
4076  $this->ctrl->getLinkTarget($this,'timingOverview'),
4077  array("timing", "timingOverview"), "", ""
4078  );
4079  }
4080  }
4081  }
4082 
4088  function getTabs()
4089  {
4090  global $ilAccess, $ilHelp;
4091 
4092  if (preg_match('/^ass(.*?)gui$/i', $this->ctrl->getNextClass($this))) {
4093  return;
4094  }
4095  else if ($this->ctrl->getNextClass($this) == 'ilassquestionpagegui') {
4096  return;
4097  }
4098 
4099  $ilHelp->setScreenIdComponent("tst");
4100 
4101  $hidden_tabs = array();
4102 
4103  $template = $this->object->getTemplate();
4104  if($template)
4105  {
4106  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
4108 
4109  $hidden_tabs = $template->getHiddenTabs();
4110  }
4111 
4112  // for local use in this fucking sledge hammer method
4113  $curUserHasWriteAccess = $ilAccess->checkAccess("write", "", $this->ref_id);
4114 
4115  switch($this->ctrl->getCmdClass())
4116  {
4117  // no tabs .. no subtabs .. during test pass
4118  case 'iltestoutputgui':
4119 
4120  // tab handling happens within GUIs
4121  case 'iltestevaluationgui':
4122  $nonSelfTabbingCommands = array(
4123  'outParticipantsResultsOverview', 'outEvaluation',
4124  'eval_a', 'singleResults', 'detailedEvaluation'
4125  );
4126  if( in_array($this->ctrl->getCmd(), $nonSelfTabbingCommands) )
4127  {
4128  break;
4129  }
4130  case 'iltestevalobjectiveorientedgui':
4131  return;
4132 
4133  case 'ilmarkschemagui':
4134  case 'ilobjtestsettingsgeneralgui':
4135  case 'ilobjtestsettingsscoringresultsgui':
4136 
4137  if( $curUserHasWriteAccess )
4138  {
4139  $this->getSettingsSubTabs($hidden_tabs);
4140  }
4141 
4142  break;
4143  }
4144 
4145  if( $this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() )
4146  {
4147  require_once 'Services/Link/classes/class.ilLink.php';
4148  $courseLink = ilLink::_getLink($this->getObjectiveOrientedContainer()->getRefId());
4149  $this->tabs_gui->setBack2Target($this->lng->txt('back_to_objective_container'), $courseLink);
4150  }
4151 
4152  switch($this->ctrl->getCmd())
4153  {
4154  case "resume":
4155  case "previous":
4156  case "next":
4157  case "summary":
4158  case "directfeedback":
4159  case "finishTest":
4160  case "outCorrectSolution":
4161  case "passDetails":
4162  case "showAnswersOfUser":
4163  case "outUserResultsOverview":
4164  case "backFromSummary":
4165  case "show_answers":
4166  case "setsolved":
4167  case "resetsolved":
4168  case "confirmFinish":
4169  case "outTestSummary":
4170  case "outQuestionSummary":
4171  case "gotoQuestion":
4172  case "selectImagemapRegion":
4173  case "confirmSubmitAnswers":
4174  case "finalSubmission":
4175  case "postpone":
4176  case "outUserPassDetails":
4177  case "checkPassword":
4178  case "exportCertificate":
4179  case "finishListOfAnswers":
4180  case "backConfirmFinish":
4181  case "showFinalStatement":
4182  return;
4183  break;
4184  case "browseForQuestions":
4185  case "filter":
4186  case "resetFilter":
4187  case "resetTextFilter":
4188  case "insertQuestions":
4189  // #8497: resetfilter is also used in lp
4190  if($this->ctrl->getNextClass($this) != "illearningprogressgui")
4191  {
4192  return $this->getBrowseForQuestionsTab($this->tabs_gui);
4193  }
4194  break;
4195  case "scoring":
4196  case "certificate":
4197  case "certificateservice":
4198  case "certificateImport":
4199  case "certificateUpload":
4200  case "certificateEditor":
4201  case "certificateDelete":
4202  case "certificateSave":
4203  case "defaults":
4204  case "deleteDefaults":
4205  case "addDefaults":
4206  case "applyDefaults":
4207  case "inviteParticipants":
4208  case "searchParticipants":
4209  if( $curUserHasWriteAccess && in_array($this->ctrl->getCmdClass(), array('ilobjtestgui', 'ilcertificategui')) )
4210  {
4211  $this->getSettingsSubTabs($hidden_tabs);
4212  }
4213  break;
4214  case "export":
4215  case "print":
4216  break;
4217  case "statistics":
4218  case "eval_a":
4219  case "detailedEvaluation":
4220  case "outEvaluation":
4221  case "singleResults":
4222  case "exportEvaluation":
4223  case "evalUserDetail":
4224  case "outStatisticsResultsOverview":
4225  case "statisticsPassDetails":
4226  $this->getStatisticsSubTabs();
4227  break;
4228  }
4229 
4230  if (strcmp(strtolower(get_class($this->object)), "ilobjtest") == 0)
4231  {
4232  // questions tab
4233  if ($ilAccess->checkAccess("write", "", $this->ref_id) && !in_array('assQuestions', $hidden_tabs))
4234  {
4235  $force_active = ($_GET["up"] != "" || $_GET["down"] != "")
4236  ? true
4237  : false;
4238  if (!$force_active)
4239  {
4240  if ($_GET["browse"] == 1) $force_active = true;
4241  }
4242 
4243  switch( $this->object->getQuestionSetType() )
4244  {
4246  $target = $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui','showPage');
4247  break;
4248 
4250  $target = $this->ctrl->getLinkTargetByClass('ilTestRandomQuestionSetConfigGUI');
4251  break;
4252 
4254  $target = $this->ctrl->getLinkTargetByClass('ilObjTestDynamicQuestionSetConfigGUI');
4255  break;
4256  }
4257 
4258  $this->tabs_gui->addTarget("assQuestions",
4259  //$this->ctrl->getLinkTarget($this,'questions'),
4260  $target,
4261  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
4262  "randomselect", "filter", "resetFilter", "insertQuestions",
4263  "back", "createRandomSelection", "cancelRandomSelect",
4264  "insertRandomSelection", "removeQuestions", "moveQuestions",
4265  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
4266  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
4267  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode", "print",
4268  "addsource", "removesource", "randomQuestions"),
4269  "", "", $force_active);
4270  }
4271 
4272  // info tab
4273  if ($ilAccess->checkAccess("read", "", $this->ref_id) && !in_array('info_short', $hidden_tabs))
4274  {
4275  $this->tabs_gui->addTarget("info_short",
4276  $this->ctrl->getLinkTarget($this,'infoScreen'),
4277  array("infoScreen", "outIntroductionPage", "showSummary",
4278  "setAnonymousId", "outUserListOfAnswerPasses", "redirectToInfoScreen"));
4279  }
4280 
4281  // settings tab
4282  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4283  {
4284  if (!in_array('settings', $hidden_tabs))
4285  {
4286  $settingsCommands = array(
4287  "marks", "showMarkSchema","addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema", "saveMarks",
4288  "certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave",
4289  "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport",
4290  "scoring", "defaults", "addDefaults", "deleteDefaults", "applyDefaults",
4291  "inviteParticipants", "saveFixedParticipantsStatus", "searchParticipants", "addParticipants" // ARE THEY RIGHT HERE
4292  );
4293 
4294  require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
4295  $reflection = new ReflectionClass('ilObjTestSettingsGeneralGUI');
4296  foreach($reflection->getConstants() as $name => $value)
4297  if(substr($name, 0, 4) == 'CMD_') $settingsCommands[] = $value;
4298 
4299  require_once 'Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php';
4300  $reflection = new ReflectionClass('ilObjTestSettingsScoringResultsGUI');
4301  foreach($reflection->getConstants() as $name => $value)
4302  if(substr($name, 0, 4) == 'CMD_') $settingsCommands[] = $value;
4303 
4304  $settingsCommands[] = ""; // DO NOT KNOW WHAT THIS IS DOING, BUT IT'S REQUIRED
4305 
4306  $this->tabs_gui->addTarget("settings",
4307  $this->ctrl->getLinkTargetByClass('ilObjTestSettingsGeneralGUI'),
4308  $settingsCommands,
4309  array("ilmarkschemagui", "ilobjtestsettingsgeneralgui", "ilobjtestsettingsscoringresultsgui", "ilobjtestgui", "ilcertificategui")
4310  );
4311  }
4312 
4313  // skill service
4314  if( $this->object->isSkillServiceEnabled() && ilObjTest::isSkillManagementGloballyActivated() )
4315  {
4316  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentsGUI.php';
4317 
4318  $link = $this->ctrl->getLinkTargetByClass(
4319  array('ilTestSkillAdministrationGUI', 'ilAssQuestionSkillAssignmentsGUI'),
4321  );
4322 
4323  $this->tabs_gui->addTarget('tst_tab_competences', $link, array(), array());
4324  }
4325 
4326  if (!in_array('participants', $hidden_tabs))
4327  {
4328  // participants
4329  $this->tabs_gui->addTarget("participants",
4330  $this->ctrl->getLinkTarget($this,'participants'),
4331  array(
4332  "participants", "saveClientIP",
4333  "removeParticipant",
4334  "showParticipantAnswersForAuthor",
4335  "deleteAllUserResults",
4336  "cancelDeleteAllUserData", "deleteSingleUserResults",
4337  "outParticipantsResultsOverview", "outParticipantsPassDetails",
4338  "showPassOverview", "showUserAnswers", "participantsAction",
4339  "showDetailedResults",
4340  'timing', 'timingOverview', 'npResetFilter', 'npSetFilter', 'showTimingForm'
4341  ),
4342  ""
4343  );
4344  }
4345  }
4346 
4347  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
4348  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()) && !in_array('learning_progress', $hidden_tabs))
4349  {
4350  $this->tabs_gui->addTarget('learning_progress',
4351  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
4352  '',
4353  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
4354  }
4355 
4356  if ($ilAccess->checkAccess("write", "", $this->ref_id) && !in_array('manscoring', $hidden_tabs))
4357  {
4358  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
4360  if (count($scoring))
4361  {
4362  // scoring tab
4363  $this->tabs_gui->addTarget(
4364  "manscoring", $this->ctrl->getLinkTargetByClass('ilTestScoringByQuestionsGUI', 'showManScoringByQuestionParticipantsTable'),
4365  array(
4366  'showManScoringParticipantsTable', 'applyManScoringParticipantsFilter', 'resetManScoringParticipantsFilter', 'showManScoringParticipantScreen',
4367  'showManScoringByQuestionParticipantsTable', 'applyManScoringByQuestionFilter', 'resetManScoringByQuestionFilter', 'saveManScoringByQuestion'
4368 
4369  ), ''
4370  );
4371  }
4372  }
4373 
4374  // Scoring Adjustment
4375  $setting = new ilSetting('assessment');
4376  $scoring_adjust_active = (bool) $setting->get('assessment_adjustments_enabled', false);
4377  if ($ilAccess->checkAccess("write", "", $this->ref_id) && $scoring_adjust_active && !in_array('scoringadjust', $hidden_tabs))
4378  {
4379  // scoring tab
4380  $this->tabs_gui->addTarget(
4381  "scoringadjust", $this->ctrl->getLinkTargetByClass('ilScoringAdjustmentGUI', 'showquestionlist'),
4382  array(
4383  'showquestionlist',
4384  'savescoringfortest',
4385  'adjustscoringfortest'
4386  ), ''
4387  );
4388  }
4389 
4390  if ((($ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) || ($ilAccess->checkAccess("write", "", $this->ref_id))) && !in_array('statistics', $hidden_tabs))
4391  {
4392  // statistics tab
4393  $this->tabs_gui->addTarget(
4394  "statistics",
4395  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
4396  array(
4397  "statistics", "outEvaluation", "exportEvaluation", "detailedEvaluation", "eval_a", "evalUserDetail",
4398  "passDetails", "outStatisticsResultsOverview", "statisticsPassDetails", "singleResults"
4399  ),
4400  ""
4401  );
4402  }
4403 
4404  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4405  {
4406  if (!in_array('history', $hidden_tabs)) {
4407 
4408  // history
4409  $this->tabs_gui->addTarget("history",
4410  $this->ctrl->getLinkTarget($this,'history'),
4411  "history", "");
4412  }
4413 
4414  if (!in_array('meta_data', $hidden_tabs)) {
4415  // meta data
4416  include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
4417  $mdgui = new ilObjectMetaDataGUI($this->object);
4418  $mdtab = $mdgui->getTab();
4419  if($mdtab)
4420  {
4421  $this->tabs_gui->addTarget("meta_data",
4422  $mdtab,
4423  "", "ilmdeditorgui");
4424  }
4425  }
4426 
4427  if(!in_array('export', $hidden_tabs))
4428  {
4429  // export tab
4430  $this->tabs_gui->addTarget(
4431  "export",
4432  $this->ctrl->getLinkTargetByClass('iltestexportgui' ,''),
4433  '',
4434  array('iltestexportgui')
4435  );
4436  }
4437  }
4438 
4439  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id)&& !in_array('permissions', $hidden_tabs))
4440  {
4441  $this->tabs_gui->addTarget("perm_settings",
4442  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
4443  }
4444  }
4445 
4446  if( $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken() )
4447  {
4448  $hideTabs = $this->testQuestionSetConfigFactory->getQuestionSetConfig()->getHiddenTabsOnBrokenDepencies();
4449 
4450  foreach($hideTabs as $tabId)
4451  {
4452  $this->tabs_gui->removeTab($tabId);
4453  }
4454  }
4455  }
4456 
4457  public static function accessViolationRedirect()
4458  {
4459  global $DIC; /* @var ILIAS\DI\Container $DIC */
4460 
4461  ilUtil::sendInfo($DIC->language()->txt("no_permission"), true);
4462  $DIC->ctrl()->redirectByClass('ilObjTestGUI', "infoScreen");
4463  }
4464 
4473  public static function _goto($a_target)
4474  {
4475  global $ilAccess, $ilErr, $lng;
4476 
4477  if ($ilAccess->checkAccess("read", "", $a_target))
4478  {
4479  //include_once "./Services/Utilities/classes/class.ilUtil.php";
4480  $_GET["baseClass"] = "ilObjTestGUI";
4481  $_GET["cmd"] = "infoScreen";
4482  $_GET["ref_id"] = $a_target;
4483  include_once("ilias.php");
4484  exit;
4485  //ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=$a_target");
4486  }
4487  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
4488  {
4489  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
4490  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
4492  }
4493 
4494  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
4495  }
4496 
4503  function buildPageViewToolbar($qid = 0)
4504  {
4505  if($this->create_question_mode)
4506  return;
4507 
4508  global $ilToolbar, $ilCtrl, $lng;
4509 
4510  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
4511 
4512  $this->getQuestionsSubTabs();
4513 
4514  $ilCtrl->saveParameter($this, 'q_mode');
4515 
4516  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'test_express_mode', 1);
4517  $ilCtrl->setParameter($this, 'test_express_mode', 1);
4518  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']);
4519  $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
4520  $ilToolbar->setFormAction($ilCtrl->getFormActionByClass('iltestexpresspageobjectgui', 'edit'));
4521 
4522  if($this->object->evalTotalPersons() == 0)
4523  {
4524  /*
4525  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
4526  $pool = new ilObjQuestionPool();
4527  $questionTypes = $pool->getQuestionTypes();$options = array();
4528  foreach($questionTypes as $label => $data) {
4529  $options[$data['question_type_id']] = $label;
4530  }
4531 
4532  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
4533  $si = new ilSelectInputGUI($lng->txt("test_add_new_question"), "qtype");
4534  $si->setOptions($options);
4535  $ilToolbar->addInputItem($si, true);
4536  /*
4537  // use pool
4538  if ($this->object->isExpressModeQuestionPoolAllowed()) {
4539  include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
4540  $cb = new ilCheckboxInputGUI($lng->txt("test_use_pool"), "use_pool");
4541  $ilToolbar->addInputItem($cb, true);
4542  }
4543  */
4544  $ilToolbar->addFormButton($lng->txt("ass_create_question"), "addQuestion");
4545 
4546  $ilToolbar->addSeparator();
4547 
4548  if($this->object->getPoolUsage())
4549  {
4550  require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php';
4551 
4553 
4554  $show_separator = true;
4555  }
4556  }
4557 
4558  $questions = $this->object->getQuestionTitlesAndIndexes();
4559 
4560  // desc
4561  $options = array();
4562  foreach($questions as $id => $label)
4563  {
4564  $options[$id] = $label . ' ['. $this->lng->txt('question_id_short') . ': ' . $id . ']';
4565  }
4566 
4567  $optionKeys = array_keys($options);
4568 
4569  if(!$options)
4570  {
4571  $options[] = $lng->txt('none');
4572  }
4573  //else if (count($options) > 1) {
4574 // $addSeparator = false;
4575 // if ($optionKeys[0] != $qid) {
4576 // //$ilToolbar->addFormButton($lng->txt("test_prev_question"), "prevQuestion");
4577 // $ilToolbar->addLink($lng->txt("test_prev_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'));
4578 // $addSeparator = true;
4579 // }
4580 // else {
4581 // $ilToolbar->addSpacer(45);
4582 // }
4583 //
4584 // if ($optionKeys[count($optionKeys)-1] != $qid) {
4585 // //$ilToolbar->addFormButton($lng->txt("test_next_question"), "nextQuestion");
4586 // $ilToolbar->addLink($lng->txt("test_next_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'));
4587 // $addSeparator = true;
4588 // }
4589 // else {
4590 // $ilToolbar->addSpacer(45);
4591 // }
4592 //
4593 // //if ($addSeparator) {
4594 // $ilToolbar->addSeparator();
4595 // //}
4596 
4597  if(count($questions))
4598  {
4599  if(isset($show_separator) && $show_separator)
4600  {
4601  $ilToolbar->addSeparator();
4602  }
4603 
4604  $btn = ilLinkButton::getInstance();
4605  $btn->setCaption("test_prev_question");
4606  $btn->setUrl($ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'));
4607  $ilToolbar->addButtonInstance($btn);
4608 
4609  if( count($options) <= 1 || $optionKeys[0] == $qid )
4610  {
4611  $btn->setDisabled(true);
4612  }
4613 
4614  $btn = ilLinkButton::getInstance();
4615  $btn->setCaption("test_next_question");
4616  $btn->setUrl($ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'));
4617  $ilToolbar->addButtonInstance($btn);
4618 
4619  if( count($options) <= 1 || $optionKeys[count($optionKeys) - 1] == $qid )
4620  {
4621  $btn->setDisabled(true);
4622  }
4623  }
4624 
4625  if(count($questions) > 1)
4626  {
4627 
4628  $ilToolbar->addSeparator();
4629 
4630  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
4631  $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id");
4632  $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
4633  $si->setOptions($options);
4634 
4635  if($qid)
4636  {
4637  $si->setValue($qid);
4638  }
4639 
4640  $ilToolbar->addInputItem($si, true);
4641  }
4642 
4643  $total = $this->object->evalTotalPersons();
4644 
4645  /*if (count($options)) {
4646  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
4647  $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id");
4648  $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
4649  $si->setOptions($options);
4650 
4651  if ($qid) {
4652  $si->setValue($qid);
4653  }
4654 
4655  $ilToolbar->addInputItem($si, true);
4656  }*/
4657 
4658  if(count($questions) && !$total)
4659  {
4660  $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
4661  $ilToolbar->addSeparator();
4662  $ilToolbar->addButton($lng->txt("test_delete_page"), $ilCtrl->getLinkTarget($this, "removeQuestions"));
4663  }
4664 
4665  if(count($questions) > 1 && !$total)
4666  {
4667  $ilToolbar->addSeparator();
4668  $ilToolbar->addButton($lng->txt("test_move_page"), $ilCtrl->getLinkTarget($this, "movePageForm"));
4669  }
4670 
4671  global $ilAccess, $ilUser;
4672 
4673  $online_access = false;
4674  if($this->object->getFixedParticipants())
4675  {
4676  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
4677  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
4678  if($online_access_result === true)
4679  {
4680  $online_access = true;
4681  }
4682  }
4683 
4684  if($this->object->isOnline() && $this->object->isComplete( $this->testQuestionSetConfigFactory->getQuestionSetConfig() ))
4685  {
4686  if((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
4687  {
4688  $testSession = $this->testSessionFactory->getSession();
4689 
4690  $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = TRUE);
4691 
4692  if($executable["executable"])
4693  {
4694  $player_factory = new ilTestPlayerFactory($this->object);
4695  $player_instance = $player_factory->getPlayerGUI();
4696 
4697  if ($testSession->getActiveId() > 0)
4698  {
4699  $ilToolbar->addSeparator();
4700  $ilToolbar->addButton($lng->txt('tst_resume_test'), $ilCtrl->getLinkTarget($player_instance, 'resumePlayer'));
4701  }
4702  else
4703  {
4704  $ilToolbar->addSeparator();
4705  $ilToolbar->addButton($lng->txt('tst_start_test'), $ilCtrl->getLinkTarget($player_instance, 'startTest'));
4706  }
4707  }
4708  }
4709  }
4710  }
4711 
4712  public function copyQuestionsToPoolObject()
4713  {
4714  $this->copyQuestionsToPool($_REQUEST['q_id'], $_REQUEST['sel_qpl']);
4715  $this->ctrl->redirect($this, 'questions');
4716  }
4717 
4718  public function copyQuestionsToPool($questionIds, $qplId)
4719  {
4720  $newIds = array();
4721  foreach($questionIds as $q_id)
4722  {
4723  $newId = $this->copyQuestionToPool($q_id, $qplId);
4724  $newIds[$q_id] = $newId;
4725  }
4726 
4727  $result = new stdClass();
4728  $result->ids = $newIds;
4729  $result->qpoolid = $qplId;
4730 
4731  return $result;
4732  }
4733 
4734  public function copyQuestionToPool($sourceQuestionId, $targetParentId)
4735  {
4736  require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
4737  $question_gui = assQuestion::instantiateQuestionGUI($sourceQuestionId);
4738 
4739  $newtitle = $question_gui->object->getTitle();
4740  if ($question_gui->object->questionTitleExists($targetParentId, $question_gui->object->getTitle()))
4741  {
4742  $counter = 2;
4743  while ($question_gui->object->questionTitleExists($targetParentId, $question_gui->object->getTitle() . " ($counter)"))
4744  {
4745  $counter++;
4746  }
4747  $newtitle = $question_gui->object->getTitle() . " ($counter)";
4748  }
4749 
4750  return $question_gui->object->createNewOriginalFromThisDuplicate($targetParentId, $newtitle);
4751  }
4752 
4757  {
4758  global $ilObjDataCache;
4759 
4760  $qplId = $ilObjDataCache->lookupObjId($_REQUEST['sel_qpl']);
4761  $result = $this->copyQuestionsToPool($_REQUEST['q_id'], $qplId);
4762 
4763  foreach($result->ids as $oldId => $newId)
4764  {
4765  $questionInstance = assQuestion::_instanciateQuestion($oldId);
4766 
4767  if( assQuestion::originalQuestionExists($questionInstance->getOriginalId()) )
4768  {
4769  $oldOriginal = assQuestion::_instanciateQuestion($questionInstance->getOriginalId());
4770  $oldOriginal->delete($oldOriginal->getId());
4771  }
4772 
4773  $questionInstance->setNewOriginalId($newId);
4774  }
4775 
4776  ilUtil::sendSuccess($this->lng->txt('tst_qst_added_to_pool_' . (count($result->ids) > 1 ? 'p' : 's')), true);
4777  $this->ctrl->redirect($this, 'questions');
4778  }
4779 
4780  private function getQuestionpoolCreationForm()
4781  {
4782  global $lng;
4783  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
4784  $form = new ilPropertyFormGUI();
4785 
4786  $title = new ilTextInputGUI($lng->txt('title'), 'title');
4787  $title->setRequired(true);
4788  $form->addItem($title);
4789 
4790  $description = new ilTextAreaInputGUI($lng->txt('description'), 'description');
4791  $form->addItem($description);
4792 
4793  $form->addCommandButton('createQuestionPoolAndCopy', $lng->txt('create'));
4794 
4795  if(isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id']))
4796  {
4797  foreach($_REQUEST['q_id'] as $id)
4798  {
4799  $hidden = new ilHiddenInputGUI('q_id[]');
4800  $hidden->setValue($id);
4801  $form->addItem($hidden);
4802  }
4803  }
4804 
4805  return $form;
4806  }
4807 
4808  public function copyToQuestionpoolObject()
4809  {
4810  $this->createQuestionpoolTargetObject('copyQuestionsToPool');
4811  }
4812 
4814  {
4815  global $lng;
4816 
4817  require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
4818 
4819  // #13761; All methods use for this request should be revised, thx japo ;-)
4820  if(
4821  'copyAndLinkToQuestionpool' == $this->ctrl->getCmd() &&
4822  (!isset($_REQUEST['q_id']) || !is_array($_REQUEST['q_id']))
4823  )
4824  {
4825  ilUtil::sendFailure($this->lng->txt('tst_no_question_selected_for_moving_to_qpl'), true);
4826  $this->ctrl->redirect($this, 'questions');
4827  }
4828 
4829  if(isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id']))
4830  {
4831  foreach($_REQUEST['q_id'] as $q_id)
4832  {
4834  {
4835  continue;
4836  }
4837 
4839 
4840  if($type !== 'tst')
4841  {
4842  ilUtil::sendFailure($lng->txt('tst_link_only_unassigned'), true);
4843  $this->ctrl->redirect($this, 'questions');
4844  return;
4845  }
4846  }
4847  }
4848 
4849  $this->createQuestionpoolTargetObject('copyAndLinkQuestionsToPool');
4850  }
4851 
4853  {
4854  $form = $this->getQuestionpoolCreationForm();
4855 
4856  if ($_REQUEST['title'])
4857  {
4858  $title = $_REQUEST['title'];
4859  }
4860  else
4861  {
4862  $title = $_REQUEST['txt_qpl'];
4863  }
4864 
4865  if (!$title)
4866  {
4867  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
4868  return $this->copyAndLinkToQuestionpoolObject();
4869  }
4870 
4871  $ref_id = $this->createQuestionPool($title, $_REQUEST['description']);
4872  $_REQUEST['sel_qpl'] = $ref_id;
4873 
4874  //if ($_REQUEST['link'])
4875  //{
4877  //}
4878  //else
4879  //{
4880  // $this->copyQuestionsToPoolObject();
4881  //}
4882  }
4883 
4891  {
4892  global $ilUser, $ilTabs;
4893  $this->getQuestionsSubTabs();
4894  $ilTabs->activateSubTab('edit_test_questions');
4895 
4896  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select_copy.html", "Modules/Test");
4897  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE, FALSE, "write");
4898  if(count($questionpools) == 0)
4899  {
4900  $this->tpl->setCurrentBlock("option");
4901  $this->tpl->setVariable("VALUE_QPL", "");
4902  $this->tpl->parseCurrentBlock();
4903  }
4904  else
4905  {
4906  foreach($questionpools as $key => $value)
4907  {
4908  $this->tpl->setCurrentBlock("option");
4909  $this->tpl->setVariable("VALUE_OPTION", $key);
4910  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
4911  $this->tpl->parseCurrentBlock();
4912  }
4913  }
4914 
4915  if(isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id']))
4916  {
4917  foreach($_REQUEST['q_id'] as $id)
4918  {
4919  $this->tpl->setCurrentBlock("hidden");
4920  $this->tpl->setVariable("HIDDEN_NAME", "q_id[]");
4921  $this->tpl->setVariable("HIDDEN_VALUE", $id);
4922  $this->tpl->parseCurrentBlock();
4923  $this->tpl->setCurrentBlock("adm_content");
4924  }
4925  }
4926  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
4927 
4928  if(count($questionpools) == 0)
4929  {
4930  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_enter_questionpool"));
4931  $cmd = 'createQuestionPoolAndCopy';
4932  }
4933  else
4934  {
4935  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_select_questionpool"));
4936  }
4937 
4938  $this->tpl->setVariable("CMD_SUBMIT", $cmd);
4939  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
4940  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
4941 
4942  $createForm = $this->getQuestionpoolCreationForm();
4943  switch($cmd)
4944  {
4945  case 'copyAndLinkQuestionsToPool':
4946  $hidden = new ilHiddenInputGUI('link');
4947  $hidden->setValue(1);
4948  $createForm->addItem($hidden);
4949  break;
4950  case 'copyQuestionsToPool':
4951  break;
4952  }
4953  $createForm->setFormAction($this->ctrl->getFormAction($this));
4954 
4955  $this->tpl->parseCurrentBlock();
4956  }
4957 
4958  // begin-patch lok
4959  public function applyTemplate($templateData, $object)
4960  // end-patch lok
4961  {
4962  // map formFieldName => setterName
4963  $simpleSetters = array(
4964 
4965  // general properties
4966  'use_pool' => 'setPoolUsage',
4967  'question_set_type' => 'setQuestionSetType',
4968 
4969  // test intro properties
4970  'intro_enabled' => 'setIntroductionEnabled',
4971  'showinfo' => 'setShowInfo',
4972 
4973  // test access properties
4974  'chb_starting_time' => 'setStartingTimeEnabled',
4975  'chb_ending_time' => 'setEndingTimeEnabled',
4976  'password_enabled' => 'setPasswordEnabled',
4977  'fixedparticipants' => 'setFixedParticipants',
4978  'limitUsers' => 'setLimitUsersEnabled',
4979 
4980  // test run properties
4981  'nr_of_tries' => 'setNrOfTries',
4982  'chb_processing_time' => 'setEnableProcessingTime',
4983  'kiosk' => 'setKiosk',
4984  'examid_in_test_pass' => 'setShowExamIdInTestPassEnabled',
4985 
4986  // question behavior properties
4987  'title_output' => 'setTitleOutput',
4988  'autosave' => null, // handled specially in loop below
4989  'chb_shuffle_questions' => 'setShuffleQuestions',
4990  'offer_hints' => 'setOfferingQuestionHintsEnabled',
4991  'instant_feedback' => 'setScoringFeedbackOptionsByArray',
4992  'obligations_enabled' => 'setObligationsEnabled',
4993 
4994  // test sequence properties
4995  'chb_use_previous_answers' => 'setUsePreviousAnswers',
4996  'chb_show_cancel' => 'setShowCancel',
4997  'chb_postpone' => 'setPostponingEnabled',
4998  'list_of_questions' => 'setListOfQuestionsSettings',
4999  'chb_show_marker' => 'setShowMarker',
5000 
5001  // test finish properties
5002  'enable_examview' => 'setEnableExamview',
5003  'showfinalstatement' => 'setShowFinalStatement',
5004  'redirection_enabled' => null, // handled specially in loop below
5005  'sign_submission' => 'setSignSubmission',
5006  'mailnotification' => 'setMailNotification',
5007 
5008  // scoring options properties
5009  'count_system' => 'setCountSystem',
5010  'mc_scoring' => 'setMCScoring',
5011  'score_cutting' => 'setScoreCutting',
5012  'pass_scoring' => 'setPassScoring',
5013  'pass_deletion_allowed' => 'setPassDeletionAllowed',
5014 
5015  // result summary properties
5016  'results_access_enabled' => 'setScoreReporting',
5017  'grading_status' => 'setShowGradingStatusEnabled',
5018  'grading_mark' => 'setShowGradingMarkEnabled',
5019 
5020  // result details properties
5021  'solution_details' => 'setShowSolutionDetails',
5022  'solution_feedback' => 'setShowSolutionFeedback',
5023  'solution_suggested' => 'setShowSolutionSuggested',
5024  'solution_printview' => 'setShowSolutionPrintview',
5025  'highscore_enabled' => 'setHighscoreEnabled',
5026  'solution_signature' => 'setShowSolutionSignature',
5027  'examid_in_test_res' => 'setShowExamIdInTestResultsEnabled',
5028  'exp_sc_short' => 'setExportSettingsSingleChoiceShort',
5029 
5030  // misc scoring & result properties
5031  'anonymity' => 'setAnonymity',
5032  'enable_archiving' => 'setEnableArchiving'
5033  );
5034 
5035  if (!$templateData['results_presentation']['value'])
5036  {
5037  $templateData['results_presentation']['value'] = array();
5038  }
5039 
5040  foreach($simpleSetters as $field => $setter)
5041  {
5042  if($templateData[$field] && strlen($setter))
5043  {
5044  $object->$setter($templateData[$field]['value']);
5045  continue;
5046  }
5047 
5048  switch($field)
5049  {
5050  case 'autosave':
5051  if( $templateData[$field]['value'] > 0 )
5052  {
5053  $object->setAutosave(true);
5054  $object->setAutosaveIval($templateData[$field]['value'] * 1000);
5055  }
5056  else
5057  {
5058  $object->setAutosave(false);
5059  }
5060  break;
5061 
5062  case 'redirection_enabled':
5063  /* if( $templateData[$field]['value'] > REDIRECT_NONE )
5064  {
5065  $object->setRedirectionMode($templateData[$field]['value']);
5066  }
5067  else
5068  {
5069  $object->setRedirectionMode(REDIRECT_NONE);
5070  } */
5071  if( strlen($templateData[$field]['value']) )
5072  {
5073  $object->setRedirectionMode(REDIRECT_ALWAYS);
5074  $object->setRedirectionUrl($templateData[$field]['value']);
5075  }
5076  else
5077  {
5078  $object->setRedirectionMode(REDIRECT_NONE);
5079  $object->setRedirectionUrl('');
5080  }
5081  }
5082  }
5083  }
5084 
5086  {
5087  global $ilAccess;
5088  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
5089  {
5090  // allow only write access
5091  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
5092  $this->ctrl->redirect($this, "infoScreen");
5093  }
5094 
5095  global $ilCtrl;
5096 
5097  $orders = $obligations = array();
5098 
5099  foreach((array)$_REQUEST['order'] as $qId => $order)
5100  {
5101  $id = (int)str_replace('q_', '', $qId);
5102 
5103  $orders[$id] = $order;
5104  }
5105 
5106  if( $this->object->areObligationsEnabled() && isset($_REQUEST['obligatory']) && is_array($_REQUEST['obligatory']) )
5107  {
5108  foreach($_REQUEST['obligatory'] as $qId => $obligation)
5109  {
5110  $id = (int)str_replace('q_', '', $qId);
5111 
5113  {
5114  $obligations[$id] = $obligation;
5115  }
5116  }
5117  }
5118 
5119  $this->object->setQuestionOrderAndObligations(
5120  $orders, $obligations
5121  );
5122 
5123  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
5124  $ilCtrl->redirect($this, 'questions');
5125  }
5126 
5130  protected function movePageFormObject()
5131  {
5132  global $lng, $ilCtrl, $tpl;
5133 
5134  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
5135  $form = new ilPropertyFormGUI();
5136  $form->setFormAction($ilCtrl->getFormAction($this, "movePage"));
5137  $form->setTitle($lng->txt("test_move_page"));
5138 
5139  $old_pos = new ilHiddenInputGUI("q_id");
5140  $old_pos->setValue($_REQUEST['q_id']);
5141  $form->addItem($old_pos);
5142 
5143  $questions = $this->object->getQuestionTitlesAndIndexes();
5144  if (!is_array($questions))
5145  $questions = array();
5146 
5147  foreach($questions as $k => $q) {
5148  if ($k == $_REQUEST['q_id']) {
5149  unset($questions[$k]);
5150  continue;
5151  }
5152  $questions[$k] = $lng->txt('behind') . ' '. $q;
5153  }
5154  #$questions['0'] = $lng->txt('first');
5155 
5156  $options = array(
5157  0 => $lng->txt('first')
5158  );
5159  foreach($questions as $k => $q) {
5160  $options[$k] = $q . ' ['. $this->lng->txt('question_id_short') . ': ' . $k . ']';
5161  }
5162 
5163  $pos = new ilSelectInputGUI($lng->txt("position"), "position_after");
5164  $pos->setOptions($options);
5165  $form->addItem($pos);
5166 
5167  $form->addCommandButton("movePage", $lng->txt("submit"));
5168  $form->addCommandButton("showPage", $lng->txt("cancel"));
5169 
5170  return $tpl->setContent($form->getHTML());
5171  }
5172 
5173  public function movePageObject() {
5174  global $ilAccess;
5175  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
5176  {
5177  // allow only write access
5178  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
5179  $this->ctrl->redirect($this, "infoScreen");
5180  }
5181 
5182  $this->object->moveQuestionAfter($_REQUEST['q_id'], $_REQUEST['position_after']);
5183  $this->showPageObject();
5184  }
5185 
5186  public function showPageObject() {
5187  global $ilCtrl;
5188 
5189  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']);
5190  $ilCtrl->redirectByClass('iltestexpresspageobjectgui', 'showPage');
5191  }
5192 
5193  public function copyQuestionObject() {
5194  global $ilAccess;
5195  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
5196  {
5197  // allow only write access
5198  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
5199  $this->ctrl->redirect($this, "infoScreen");
5200  }
5201 
5202  if ($_REQUEST['q_id'] && !is_array($_REQUEST['q_id']))
5203  $ids = array($_REQUEST['q_id']);
5204  else if ($_REQUEST['q_id'])
5205  $ids = $_REQUEST['q_id'];
5206  else
5207  {
5208  ilUtil::sendFailure( $this->lng->txt('copy_no_questions_selected'), true );
5209  $this->ctrl->redirect($this, 'questions');
5210  }
5211 
5212  $copy_count = 0;
5213 
5214  $questionTitles = $this->object->getQuestionTitles();
5215 
5216  foreach($ids as $id)
5217  {
5218  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
5219  $question = assQuestion::_instanciateQuestionGUI($id);
5220  if ($question)
5221  {
5222  $title = $question->object->getTitle();
5223  $i = 2;
5224  while( in_array( $title . ' (' . $i . ')', $questionTitles ))
5225  $i++;
5226 
5227  $title .= ' (' . $i . ')';
5228 
5229  $questionTitles[] = $title;
5230 
5231  $new_id = $question->object->duplicate(false, $title);
5232 
5233  $clone = assQuestion::_instanciateQuestionGUI($new_id);
5234  $clone->object->setObjId($this->object->getId());
5235  $clone->object->saveToDb();
5236 
5237  $this->object->insertQuestion( $this->testQuestionSetConfigFactory->getQuestionSetConfig(), $new_id, true );
5238 
5239  $copy_count++;
5240  }
5241  }
5242 
5243  ilUtil::sendSuccess($this->lng->txt('copy_questions_success'), true);
5244 
5245  $this->ctrl->redirect($this, 'questions');
5246  }
5247 
5251  private function isPdfDeliveryRequest()
5252  {
5253  if( !isset($_GET['pdf']) )
5254  {
5255  return false;
5256  }
5257 
5258  if( !(bool)$_GET['pdf'] )
5259  {
5260  return false;
5261  }
5262 
5263  return true;
5264  }
5265 
5267  {
5268  require_once 'Modules/Course/classes/Objectives/class.ilLOSettings.php';
5269  $containerObjId = (int)ilLOSettings::isObjectiveTest($this->ref_id);
5270 
5271  $containerRefId = current(ilObject::_getAllReferences($containerObjId));
5272 
5273  $this->objectiveOrientedContainer->setObjId($containerObjId);
5274  $this->objectiveOrientedContainer->setRefId($containerRefId);
5275  }
5276 
5277  protected function getObjectiveOrientedContainer()
5278  {
5280  }
5281 }
const MATCHING_QUESTION_IDENTIFIER
const MULTIPLE_CHOICE_QUESTION_IDENTIFIER
const QT_MATCHING
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _lookupName($a_user_id)
lookup user name
Scoring class for tests.
const QT_FORMULA
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
applyTemplate($templateData, $object)
global $ilErr
Definition: raiseError.php:16
This class represents an option in a radio group.
const REPORT_AFTER_TEST
ILIAS Setting Class.
Class ilObjectMetaDataGUI.
const REPORT_AFTER_DATE
static getAllSettingsTemplates($a_type, $a_include_auto_generated=false)
Get all settings templates of type.
$path
Definition: aliased.php:25
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _getOriginalId($question_id)
Returns the original id of a question.
Content Object Parser.
const QT_FILEUPLOAD
Class ilInfoScreenGUI.
static getQuestionTypeFromDb($question_id)
get question type for question id
const ERROR_TEXT_IDENTIFIER
static _getParticipantData($active_id)
Retrieves a participant name from active id.
$template_id
Definition: example_062.php:89
createQuestionObject()
Called when a new question should be created from a test.
const IL_CAL_DATETIME
getTabs()
adds tabs to tab gui object
Export User Interface Class.
Class ilObjTestGUI.
$_SESSION["AccountId"]
This class represents a selection list property in a property form.
$result
const QT_TEXT
reviewobject()
Review tab to create a print of all questions without points and solutions.
This class represents a property form user interface.
fullscreenObject()
show fullscreen view
GUI class for the workflow of copying objects.
static originalQuestionExists($questionId)
const QUESTION_SET_TYPE_RANDOM
type setting value for random question set
copyQuestionToPool($sourceQuestionId, $targetParentId)
uploadObject($redirect=true)
display status information or report errors messages in case of error
const ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT
constant for additional content editing mode "pageobject"
Generic feedback page GUI class.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
static _needsManualScoring($question_id)
cancelCreateQuestionObject()
Called when the creation of a new question is cancelled.
This class represents a file property in a property form.
buildPageViewToolbar($qid=0)
Questions per page.
addButton($a_txt, $a_cmd, $a_target="", $a_acc_key="", $a_additional_attrs='', $a_id="", $a_class='submit')
Add button to toolbar.
showDetailedResultsObject()
Shows the pass overview and the answers of one ore more users for the scored pass.
Class ilObject Basic functions for all objects.
static getQuestionTypeByTypeId($type_id)
applyFilterCriteria($in_rows)
static & _instanciateQuestionGUI($question_id)
Creates an instance of a question gui with a given question id.
insertQuestionsBeforeObject()
Insert checked questions before the actual selection.
addDidacticTemplateOptions(array &$a_options)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _getLog($ts_from, $ts_to, $test_id, $test_only=FALSE)
Retrieve assessment log datasets from the database.
const QT_ORDERING_HORIZONTAL
$cmd
Definition: sahs_server.php:35
const KPRIM_CHOICE_QUESTION_IDENTIFIER
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
const LONG_MENU_QUESTION_IDENTIFIER
static isObjectiveTest($a_trst_ref_id)
Check if test ref_id is used in an objective course.
Class ilUnitConfigurationRepository.
const TEXTSUBSET_QUESTION_IDENTIFIER
deleteSingleUserResultsObject()
Asks for a confirmation to delete selected user data of the test object.
static _goto($a_target)
Redirect script to call a test with the test reference id.
Question page object.
Import class.
static _lookupTitle($a_id)
lookup object title
const REDIRECT_NONE
Redirect after finishing test constants.
const QT_KPRIM_CHOICE
showUserResults($show_pass_details, $show_answers, $show_reached_points=FALSE)
Shows the pass overview of the scored pass for one ore more users.
historyObject()
Creates the change history for a test.
downloadFileObject()
download file
createQuestionpoolTargetObject($cmd)
Called when a new question should be created from a test Important: $cmd may be overwritten if no que...
createObject()
create new object form
static _isActive()
Static getter.
insertRandomSelectionObject()
Inserts a random selection into the test.
const QT_IMAGEMAP
redirectTo_ilObjTestSettingsGeneralGUI_showForm_Object()
Scoring class for tests.
confirmRemoveQuestionsObject()
Remove questions from the test after confirmation.
const IL_CAL_UNIX
static lookupParentObjId($questionId)
ilDBInterface $ilDB
static accessViolationRedirect()
cancelDeleteSelectedUserDataObject()
Cancels the deletion of all user data for the test object.
Question page GUI class.
static $infoScreenChildClasses
$total
Definition: Utf8Test.php:87
static _getAllReferences($a_id)
get all reference ids of object
addDefaultsObject()
Adds the defaults of this test to the defaults.
deleteAllUserDataObject()
Asks for a confirmation to delete all user data of the test object.
Base Exception for all Exceptions relating to Modules/Test.
createUserResults($show_pass_details, $show_answers, $show_reached_points, $show_user_results)
participantsActionObject()
Evaluates the actions on the participants page.
afterSave(ilObject $a_new_object)
save object public
const FILE_UPLOAD_IDENTIFIER
const QT_MULTIPLE_CHOICE_SR
const JAVAAPPLET_QUESTION_IDENTIFIER
global $ilCtrl
Definition: ilias.php:18
confirmDeleteSelectedUserDataObject()
Deletes the selected user data for the test object.
cancelRemoveQuestionsObject()
Cancels the removal of questions from the test.
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$counter
const REDIRECT_ALWAYS
deleteAllUserResultsObject()
Asks for a confirmation to delete all user data of the test object.
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
prepareSubGuiOutput()
prepares ilias to get output rendered by sub gui class
copyAndLinkQuestionsToPoolObject()
ilObjectDataCache $ilObjDataCache
This class represents a hidden form property in a property form.
$info
Definition: example_052.php:80
static _lookupOnlineTestAccess($a_test_id, $a_user_id)
Checks if a user is allowd to run an online exam.
prepareOutput($a_show_subobjects=true)
prepare output
showUserAnswersObject()
Shows the answers of one ore more users for the scored pass.
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
This class represents a property in a property form.
addOption($a_option)
Add Option.
const QT_LONG_MENU
getBrowseForQuestionsTab(&$tabs_gui)
setValue($a_value)
Set Value.
const NUMERIC_QUESTION_IDENTIFIER
if(!is_array($argv)) $options
const IL_MO_PARSE_QTI
removeQuestionsObject()
Called when a selection of questions should be removed from the test.
const ORDERING_HORIZONTAL_IDENTIFIER
const SCORE_ZERO_POINTS_WHEN_UNANSWERED
initImportForm($a_new_type)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class represents a number property in a property form.
Class ilTimingOverviewTableGUI.
confirmDeleteAllUserResultsObject()
Deletes all user data for the test object.
const COUNT_PARTIAL_SOLUTIONS
applyDefaultsObject($confirmed=false)
Applies the selected test defaults.
static _getQuestionGUI($question_type, $question_id=-1)
Creates a question gui representation and returns the alias to the question gui note: please do not u...
download_paragraphObject()
download source code paragraph
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
const ORDERING_QUESTION_IDENTIFIER
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
insertQuestionsAfterObject()
Insert checked questions after the actual selection.
special template class to simplify handling of ITX/PEAR
createQuestionPool($name="dummy", $description="")
Creates a new questionpool and returns the reference id.
Class ilObjFile.
setSize($a_size)
Set Size.
This class represents a text property in a property form.
static formatDate(ilDateTime $date)
Format a date public.
Output class for assessment test evaluation.
GUI class to create PDF certificates.
static infoPanel($a_keep=true)
Date and time handling
$ilUser
Definition: imgupload.php:18
redirection script todo: (a better solution should control the processing via a xml file) ...
static isSkillManagementGloballyActivated()
static _recordReadEvent($a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
setTitleAndDescription()
called by prepare output
$results
static getSyntaxStylePath()
get syntax style path
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
setOptions($a_options)
Set Options.
const TEXT_QUESTION_IDENTIFIER
Basic GUI class for assessment questions.
$txt
Definition: error.php:12
static isQuestionObligationPossible($questionId)
checks wether the obligation for question with given id is possible or not
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
filterObject()
Sets the filter for the question browser.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
participantsObject()
Creates the output of the test participants.
const QT_JAVAAPPLET
const FLASHAPPLET_QUESTION_IDENTIFIER
writeFilterToSession()
Write filter values to session.
static _createImportDirectory()
creates data directory for import files (data_dir/tst_data/tst_<id>/import, depending on data directo...
const TEST_FIXED_SEQUENCE
Test constants.
const ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT
constant for additional content editing mode "default"
executeCommand()
execute command
exportObject()
Gateway for exports initiated from workspace, as there is a generic forward to {objTypeMainGUI}export...
static getContentStylePath($a_style_id)
get content style path
static prepareGeneration()
Prepare the PDF generation This initializes the purpose for MathJax rendering It has to be called bef...
const QT_NUMERIC
Specific feedback page GUI class.
randomselectObject()
Creates a form for random selection of questions.
importVerifiedFileObject()
imports question(s) into the questionpool (after verification)
const QT_TEXTSUBSET
createRandomSelectionObject()
Offers a random selection for insertion in the test.
certificateObject()
Shows the certificate editor.
const QT_FLASHAPPLET
Create new PHPExcel object
obj_idprivate
static _getManualScoring()
Retrieve the manual scoring settings.
cancelRandomSelectObject()
Cancels the form for random selection of questions.
This class represents a text area property in a property form.
static generatePDF($pdf_output, $output_mode, $filename=null)
importFileObject($parent_id=null, $a_catch_errors=true)
form for new test object import
executeCreateQuestionObject()
Called when a new question should be created from a test after confirmation.
global $ilDB
$ret
Definition: parser.php:6
static isAdditionalQuestionContentEditingModePageObjectEnabled()
returns the fact wether content editing with ilias page editor is enabled for questions or not ...
const QUESTION_SET_TYPE_FIXED
type setting value for fixed question set
getCreationMode()
get creation mode
movePageFormObject()
Move current page.
getRefId()
get reference id public
Class ilLocalUnitConfigurationGUI.
getDidacticTemplateVar($a_type)
Get didactic template setting from creation screen.
moveQuestionsObject()
Marks selected questions for moving.
populateQuestionBrowserToolbarButtons(ilToolbarGUI $toolbar, $context)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
const REPORT_ALWAYS
addFinishAllPassesButton($unfinished_passes, $ilToolbar)
global $DIC
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
Service GUI class for tests.
insertQuestionsObject()
Insert questions from the questionbrowser into the test.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
fill toolbar with
printobject()
Print tab to create a print of all questions with points and solutions.
const IL_CAL_TIMESTAMP
const QT_CLOZE
const QT_MULTIPLE_CHOICE_MR
const IL_MO_VERIFY_QTI
Class ilScoringAdjustmentGUI.
uploadTstObject()
imports test and question(s)
deleteDefaultsObject()
Deletes selected test defaults.
backObject()
Called when the back button in the question browser was pressed.
static redirect($a_script)
http redirect to other script
const QUESTION_SET_TYPE_DYNAMIC
type setting value for dynamic question set (continues testing mode)
const SINGLE_CHOICE_QUESTION_IDENTIFIER
const QT_ORDERING
addHeaderAction()
Add header action menu.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
copyQuestionsToPool($questionIds, $qplId)
getRandomQuestionsTab(&$tabs_gui)
setSuffixes($a_suffixes)
Set Accepted Suffixes.
ilTestExpressPageObjectGUI: assMultipleChoiceGUI, assClozeTestGUI, assMatchingQuestionGUI ilTestExpr...
Class ilObjUserTrackingGUI.
getReturnLocation($a_cmd, $a_location="")
get return location for command (command is method name without "Object", e.g.
$_POST["username"]
static _getAvailableQuestionpools($use_object_id=FALSE, $equal_points=FALSE, $could_be_offline=FALSE, $showPath=FALSE, $with_questioncount=FALSE, $permission="read", $usr_id="")
Returns the available question pools for the active user.
resetFilter()
Reset filter.
Settings template application class.
const CLOZE_TEST_IDENTIFIER
Question identifier constants.
static instantiateQuestionGUI($a_question_id)
Creates an instance of a question gui with a given question id.
const SCORE_BEST_PASS
setRequired($a_required)
Set Required.
static _setImportDirectory($a_import_dir=null)
set import directory
showPassOverviewObject()
Shows the pass overview of the scored pass for one ore more users.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static _getTestDefaults($test_defaults_id)
__construct()
Constructor public.
setLocator()
set Locator
static _getImportDirectory()
Get the import directory location of the test.
resetFilterObject()
Resets the filter for the question browser.
Confirmation screen class.
const IMAGEMAP_QUESTION_IDENTIFIER
const QT_ERRORTEXT
const FORMULA_QUESTION_IDENTIFIER
addParticipantsObject($a_user_ids=array())
setFilterCommand($a_val, $a_caption=null)
Set filter command.
removeQuestionsForm($checked_questions)
Displays a form to confirm the removal of questions from the test.