ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilLOEditorStatus.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
5 
13 {
14  const SECTION_SETTINGS = 1;
15  const SECTION_MATERIALS = 2;
16  const SECTION_ITES = 3;
17  const SECTION_QTEST = 4;
18  const SECTION_OBJECTIVES = 5;
20 
21  protected static $instance = NULL;
22 
23 
24  protected $section = NULL;
25 
26  protected $failures_by_section = array();
27 
28  protected $objectives = array();
29 
30  protected $settings = NULL;
31  protected $assignments = null;
32  protected $parent_obj = NULL;
33  protected $cmd_class = NULL;
34  protected $html = '';
35 
36  protected $tpl = NULL;
37  protected $ctrl = NULL;
38  protected $lng = NULL;
39 
44  public function __construct(ilObject $a_parent)
45  {
46  $this->parent_obj = $a_parent;
47  $this->settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId());
48  $this->assignments = ilLOTestAssignments::getInstance($this->getParentObject()->getId());
49 
50  $this->ctrl = $GLOBALS['ilCtrl'];
51  $this->lng = $GLOBALS['lng'];
52 
53  include_once './Modules/Course/classes/class.ilCourseObjective.php';
54  $this->objectives = ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId());
55  }
56 
61  public static function getInstance(ilObject $a_parent)
62  {
63  if(self::$instance)
64  {
65  return self::$instance;
66  }
67  return self::$instance = new self($a_parent);
68  }
69 
73  public function getObjectives()
74  {
75  return $this->objectives;
76  }
77 
82  public function getAssignments()
83  {
84  return $this->assignments;
85  }
86 
87 
92  public function setSection($a_section)
93  {
94  $this->section = $a_section;
95  }
96 
97  public function getSection()
98  {
99  return $this->section;
100  }
101 
106  public function getFailures($a_section)
107  {
108  return (array) $this->failures_by_section[$a_section];
109  }
110 
116  protected function appendFailure($a_section, $a_failure_msg_key)
117  {
118  $this->failures_by_section[$a_section][] = $a_failure_msg_key;
119  }
120 
125  public function setCmdClass($a_cmd_class)
126  {
127  $this->cmd_class = $a_cmd_class;
128  }
129 
134  public function getCmdClass()
135  {
136  return $this->cmd_class;
137  }
138 
139 
144  public function getParentObject()
145  {
146  return $this->parent_obj;
147  }
148 
149  /*
150  * @return ilLOSettings
151  */
152  public function getSettings()
153  {
154  return $this->settings;
155  }
156 
160  public function getFirstFailedStep()
161  {
162  if(!$this->getSettingsStatus(false))
163  {
164  return 'settings';
165  }
166  #if(!$this->getMaterialsStatus(false))
167  #{
168  # return 'materials';
169  #}
170  if(!$this->getObjectivesAvailableStatus())
171  {
172  return 'showObjectiveCreation';
173  }
174  if($this->getSettings()->worksWithInitialTest())
175  {
176  if(!$this->getInitialTestStatus(false))
177  {
178  $_REQUEST['tt'] = ilLOSettings::TYPE_TEST_INITIAL;
179  if($this->getSettings()->hasSeparateInitialTests())
180  {
181  return 'testsOverview';
182  }
183  else
184  {
185  return 'testOverview';
186  }
187  }
188  }
189  if(!$this->getQualifiedTestStatus(false))
190  {
191  $_REQUEST['tt'] = ilLOSettings::TYPE_TEST_QUALIFIED;
192  if($this->getSettings()->hasSeparateQualifiedTests())
193  {
194  return 'testsOverview';
195  }
196  else
197  {
198  return 'testOverview';
199  }
200  }
201  if(!$this->getObjectivesStatus(false))
202  {
203  return 'listObjectives';
204  }
205  return 'listObjectives';
206  }
207 
208 
212  public function getHTML()
213  {
214  include_once("./Services/UIComponent/Checklist/classes/class.ilChecklistGUI.php");
215  $list = new ilChecklistGUI();
216  $list->setHeading($this->lng->txt('crs_objective_status_configure'));
217 
218 
219  // Step 1
220  // course settings
221  $done = $this->getSettingsStatus();
222 
223  $list->addEntry($this->lng->txt('crs_objective_status_settings'),
224  $this->ctrl->getLinkTarget($this->getCmdClass(),'settings'),
225  $done
228  ($this->section == self::SECTION_SETTINGS),
229  $this->getErrorMessages(self::SECTION_SETTINGS)
230  );
231 
232 
233  // Step 1.1
234  $done = $this->getObjectivesAvailableStatus(true);
235 
236  $list->addEntry($this->lng->txt('crs_objective_status_objective_creation'),
237  $done
238  ? $this->ctrl->getLinkTarget($this->getCmdClass(),'listObjectives')
239  : $this->ctrl->getLinkTarget($this->getCmdClass(),'showObjectiveCreation'),
240  $done
243  ($this->section == self::SECTION_OBJECTIVES_NEW),
244  $this->getErrorMessages(self::SECTION_OBJECTIVES_NEW)
245  );
246 
247  // Step 2
248  // course material
249  $done = $this->getMaterialsStatus(true);
250 
251  $this->ctrl->setParameterByClass('ilobjcoursegui','cmd','enableAdministrationPanel');
252  $list->addEntry($this->lng->txt('crs_objective_status_materials'),
253  $this->ctrl->getLinkTargetByClass('ilobjcoursegui',''),
254  $done
257  ($this->section == self::SECTION_MATERIALS),
258  $this->getErrorMessages(self::SECTION_MATERIALS)
259  );
260 
261 
262  // Step 3
263  // course itest
264  if(ilLOSettings::getInstanceByObjId($this->getParentObject()->getId())->worksWithInitialTest())
265  {
266  $done = $this->getInitialTestStatus();
267 
268  $command = $this->getSettings()->hasSeparateInitialTests() ?
269  'testsOverview' :
270  'testOverview';
271 
272  $this->ctrl->setParameter($this->getCmdClass(),'tt', ilLOSettings::TYPE_TEST_INITIAL);
273  $list->addEntry(
274  $this->lng->txt('crs_objective_status_itest'),
275  $this->ctrl->getLinkTarget($this->getCmdClass(),$command),
276  $done
279  ($this->section == self::SECTION_ITES),
280  $this->getErrorMessages(self::SECTION_ITES)
281  );
282  }
283 
284  // Step 4
285  // course qtest
286  $done = $this->getQualifiedTestStatus();
287 
288  $command = $this->getSettings()->hasSeparateQualifiedTests() ?
289  'testsOverview' :
290  'testOverview';
291 
292  $this->ctrl->setParameter($this->getCmdClass(),'tt', ilLOSettings::TYPE_TEST_QUALIFIED);
293  $list->addEntry($this->lng->txt('crs_objective_status_qtest'),
294  $this->ctrl->getLinkTarget($this->getCmdClass(),$command),
295  $done
298  ($this->section == self::SECTION_QTEST),
299  $this->getErrorMessages(self::SECTION_QTEST)
300  );
301 
302  $this->ctrl->setParameter($this->getCmdClass(),'tt', $_GET["tt"]);
303 
304  // Step 5
305  // course qtest
306  $done = $this->getObjectivesStatus();
307 
308  $list->addEntry($this->lng->txt('crs_objective_status_objectives'),
309  $this->ctrl->getLinkTarget($this->getCmdClass(),'listObjectives'),
310  $done
313  ($this->section == self::SECTION_OBJECTIVES),
314  $this->getErrorMessages(self::SECTION_OBJECTIVES)
315  );
316 
317  return $list->getHTML();
318  }
319 
320 
321 
328  public function getErrorMessages($a_section)
329  {
330  $mess = array();
331  foreach($this->getFailures($a_section) as $failure_code)
332  {
333  $mess[] = $this->lng->txt($failure_code);
334  }
335  return $mess;
336  }
337 
338 
343  protected function getSettingsStatus()
344  {
345  return $this->getSettings()->settingsExist();
346  }
347 
354  protected function getObjectivesAvailableStatus($a_set_errors = false)
355  {
356  $ret = count($this->getObjectives());
357 
358  if(!$ret && $a_set_errors)
359  {
360  $this->appendFailure(self::SECTION_OBJECTIVES_NEW, 'crs_no_objectives_created');
361  }
362 
363  return $ret;
364  }
365 
369  protected function getMaterialsStatus($a_set_errors = true)
370  {
371  $childs = $GLOBALS['tree']->getChilds($this->getParentObject()->getRefId());
372  foreach((array) $childs as $tnode)
373  {
374  if($tnode['type'] == 'rolf')
375  {
376  continue;
377  }
378  if($tnode['child'] == $this->getSettings()->getInitialTest())
379  {
380  continue;
381  }
382  if($tnode['child'] == $this->getSettings()->getQualifiedTest())
383  {
384  continue;
385  }
386  return true;
387  }
388  if($a_set_errors)
389  {
390  $this->appendFailure(self::SECTION_MATERIALS, 'crs_loc_err_stat_no_materials');
391  }
392  return false;
393  }
394 
400  protected function getInitialTestStatus($a_set_errors = true)
401  {
402  if($this->getSettings()->hasSeparateInitialTests())
403  {
404  foreach($this->getObjectives() as $objective_id)
405  {
406  $tst_ref = $this->getAssignments()->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL);
407  if(!$GLOBALS['tree']->isInTree($tst_ref))
408  {
409  if($a_set_errors)
410  {
411  $this->appendFailure(self::SECTION_ITES, 'crs_loc_err_stat_no_it');
412  }
413  return FALSE;
414  }
415  if(!$this->checkTestOnline($tst_ref))
416  {
417  if($a_set_errors)
418  {
419  $this->appendFailure(self::SECTION_ITES, 'crs_loc_err_stat_tst_offline');
420  }
421  return false;
422  }
423 
424  }
425  return TRUE;
426  }
427 
428 
429  $tst_ref = $this->getSettings()->getInitialTest();
430  if(!$GLOBALS['tree']->isInTree($tst_ref))
431  {
432  if($a_set_errors)
433  {
434  $this->appendFailure(self::SECTION_ITES, 'crs_loc_err_stat_no_it');
435  }
436  return FALSE;
437  }
438  if(!$this->checkTestOnline($tst_ref))
439  {
440  if($a_set_errors)
441  {
442  $this->appendFailure(self::SECTION_ITES, 'crs_loc_err_stat_tst_offline');
443  }
444  return false;
445  }
446  return TRUE;
447  }
448 
454  protected function getQualifiedTestStatus($a_set_errors = true)
455  {
456  if($this->getSettings()->hasSeparateQualifiedTests())
457  {
458  foreach($this->getObjectives() as $objective_id)
459  {
460  $tst_ref = $this->getAssignments()->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED);
461  if(!$GLOBALS['tree']->isInTree($tst_ref))
462  {
463  if($a_set_errors)
464  {
465  $this->appendFailure(self::SECTION_QTEST, 'crs_loc_err_stat_no_qt');
466  }
467  return FALSE;
468  }
469  if(!$this->checkTestOnline($tst_ref))
470  {
471  if($a_set_errors)
472  {
473  $this->appendFailure(self::SECTION_QTEST, 'crs_loc_err_stat_tst_offline');
474  }
475  return false;
476  }
477  }
478  return TRUE;
479  }
480  $tst_ref = $this->getSettings()->getQualifiedTest();
481  if(!$GLOBALS['tree']->isInTree($tst_ref))
482  {
483  if($a_set_errors)
484  {
485  $this->appendFailure(self::SECTION_QTEST, 'crs_loc_err_stat_no_qt');
486  }
487  return false;
488  }
489  if(!$this->checkTestOnline($tst_ref))
490  {
491  if($a_set_errors)
492  {
493  $this->appendFailure(self::SECTION_QTEST, 'crs_loc_err_stat_tst_offline');
494  }
495  return false;
496  }
497  return true;
498  }
499 
504  protected function lookupQuestionsAssigned($a_test_ref_id)
505  {
506  include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
508  {
509  foreach($this->getObjectives() as $objective_id)
510  {
511  include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
513  $this->parent_obj->getId(),
514  $objective_id,
515  ilObject::_lookupObjId($a_test_ref_id)
516  );
517  if(!$seq)
518  {
519  return false;
520  }
521  }
522  }
523  else
524  {
525  foreach($this->getObjectives() as $objective_id)
526  {
527  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
529  if(!count($qsts))
530  {
531  return false;
532  }
533  }
534  }
535  return true;
536  }
537 
538 
539  protected function getObjectivesStatus($a_set_errors = true)
540  {
541  if(!$this->getObjectivesAvailableStatus($a_set_errors))
542  {
543  return false;
544  }
545 
546  include_once './Modules/Course/classes/class.ilCourseObjective.php';
547  $num_active = ilCourseObjective::_getCountObjectives($this->getParentObject()->getId(),true);
548  if(!$num_active)
549  {
550  if($a_set_errors)
551  {
552  $this->appendFailure(self::SECTION_OBJECTIVES, 'crs_loc_err_no_active_lo');
553  }
554  return false;
555  }
556  foreach(ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId(),true) as $objective_id)
557  {
558  include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
559  $obj = new ilCourseObjectiveMaterials($objective_id);
560  if(!count($obj->getMaterials()))
561  {
562  if($a_set_errors)
563  {
564  $this->appendFailure(self::SECTION_OBJECTIVES, 'crs_loc_err_no_active_mat');
565  }
566  return false;
567  }
568  }
569  // check for assigned initial test questions
570  if($this->getSettings()->worksWithInitialTest() && !$this->getSettings()->hasSeparateInitialTests())
571  {
572  // check for assigned questions
573  if(!$this->lookupQuestionsAssigned($this->getSettings()->getInitialTest()))
574  {
575  if($a_set_errors)
576  {
577  $this->appendFailure(self::SECTION_OBJECTIVES, 'crs_loc_err_no_active_qst');
578  }
579  return false;
580  }
581  }
582  // check for assigned questions
583  if(!$this->getSettings()->hasSeparateQualifiedTests() and !$this->lookupQuestionsAssigned($this->getSettings()->getQualifiedTest()))
584  {
585  if($a_set_errors)
586  {
587  $this->appendFailure(self::SECTION_OBJECTIVES, 'crs_loc_err_no_active_qst');
588  }
589  return false;
590  }
591 
592  // @deprecated
593  /*
594  if(!$this->checkNumberOfTries())
595  {
596  if($a_set_errors)
597  {
598  $this->appendFailure(self::SECTION_OBJECTIVES, 'crs_loc_err_nr_tries_exceeded');
599  }
600  return false;
601  }
602  */
603 
604  return true;
605  }
606 
607  protected function getStartStatus()
608  {
609  return true;
610  }
611 
612  protected function checkNumberOfTries()
613  {
614  $qt = $this->getSettings()->getQualifiedTest();
615  if(!$qt)
616  {
617  return true;
618  }
619 
620  include_once './Services/Object/classes/class.ilObjectFactory.php';
621  $factory = new ilObjectFactory();
622  $tst = $factory->getInstanceByRefId($qt,false);
623 
624  if(!$tst instanceof ilObjTest)
625  {
626  return true;
627  }
628  $tries = $tst->getNrOfTries();
629  if(!$tries)
630  {
631  return true;
632  }
633 
634  $obj_tries = 0;
635  foreach($this->getObjectives() as $objective)
636  {
637  include_once './Modules/Course/classes/class.ilCourseObjective.php';
638  $obj_tries += ilCourseObjective::lookupMaxPasses($objective);
639  }
640  $GLOBALS['ilLog']->write(__METHOD__.': '.$obj_tries);
641  return $obj_tries <= $tries;
642  }
643 
648  protected function checkTestOnline($a_ref_id)
649  {
650  include_once './Modules/Test/classes/class.ilObjTestAccess.php';
652  }
653 }
654 ?>
getQualifiedTestStatus($a_set_errors=true)
Check status of qualified test.
static getInstanceByObjId($a_obj_id)
get singleton instance
getFailures($a_section)
Get failures by section.
static getInstance($a_container_id)
Get instance by container id.
Class ilObjectFactory.
getObjectivesAvailableStatus($a_set_errors=false)
getMaterialsStatus($a_set_errors=true)
Get status of materials.
static lookupMaxPasses($a_objective_id)
checkTestOnline($a_ref_id)
Check if test is online.
lookupQuestionsAssigned($a_test_ref_id)
Check if questions are assigned.
$_GET["client_id"]
Presentation of the status of single steps during the configuration process.
Class ilObject Basic functions for all objects.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _getObjectiveIds($course_id, $a_activated_only=false)
static _isOnline($a_obj_id)
returns the objects&#39;s ONline status
getFirstFailedStep()
Get first failed step.
class ilCourseObjectiveMaterials
static lookupSequence($a_container_id, $a_objective_id, $a_test_id)
setCmdClass($a_cmd_class)
Command class.
static lookupRandomTest($a_test_obj_id)
Check if test is a random test.
static getInstance(ilObject $a_parent)
Get instance.
static _lookupObjId($a_id)
appendFailure($a_section, $a_failure_msg_key)
Append failure.
setSection($a_section)
Set current section.
Create styles array
The data for the language used.
getParentObject()
Get parent object.
settings()
Definition: settings.php:2
getCmdClass()
Get cmd class.
static _getCountObjectives($a_obj_id, $a_activated_only=false)
get count objectives
$ret
Definition: parser.php:6
getErrorMessages($a_section)
Get error messages.
__construct(ilObject $a_parent)
Constructor.
getInitialTestStatus($a_set_errors=true)
Get initial test status.
static lookupQuestionsByObjective($a_test_id, $a_objective)
getSettingsStatus()
Check if course is lo confgured.
getObjectivesStatus($a_set_errors=true)