ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
11{
14 const SECTION_ITES = 3;
15 const SECTION_QTEST = 4;
18
19 protected static $instance = NULL;
20
21
22 protected $section = NULL;
23
24 protected $failures_by_section = array();
25
26 protected $objectives = array();
27
28 protected $settings = NULL;
29 protected $parent_obj = NULL;
30 protected $cmd_class = NULL;
31 protected $html = '';
32
33 protected $tpl = NULL;
34 protected $ctrl = NULL;
35 protected $lng = NULL;
36
41 public function __construct(ilObject $a_parent)
42 {
43 $this->parent_obj = $a_parent;
44 $this->settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId());
45
46 $this->ctrl = $GLOBALS['ilCtrl'];
47 $this->lng = $GLOBALS['lng'];
48
49 include_once './Modules/Course/classes/class.ilCourseObjective.php';
50 $this->objectives = ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId());
51 }
52
57 public static function getInstance(ilObject $a_parent)
58 {
59 if(self::$instance)
60 {
61 return self::$instance;
62 }
63 return self::$instance = new self($a_parent);
64 }
65
66 public function getObjectives()
67 {
68 return $this->objectives;
69 }
70
75 public function setSection($a_section)
76 {
77 $this->section = $a_section;
78 }
79
80 public function getSection()
81 {
82 return $this->section;
83 }
84
89 public function getFailures($a_section)
90 {
91 return (array) $this->failures_by_section[$a_section];
92 }
93
99 protected function appendFailure($a_section, $a_failure_msg_key)
100 {
101 $this->failures_by_section[$a_section][] = $a_failure_msg_key;
102 }
103
108 public function setCmdClass($a_cmd_class)
109 {
110 $this->cmd_class = $a_cmd_class;
111 }
112
117 public function getCmdClass()
118 {
119 return $this->cmd_class;
120 }
121
122
127 public function getParentObject()
128 {
129 return $this->parent_obj;
130 }
131
132 /*
133 * @return ilLOSettings
134 */
135 public function getSettings()
136 {
137 return $this->settings;
138 }
139
143 public function getFirstFailedStep()
144 {
145 if(!$this->getSettingsStatus(false))
146 {
147 return 'settings';
148 }
149 #if(!$this->getMaterialsStatus(false))
150 #{
151 # return 'materials';
152 #}
153 if(!$this->getObjectivesAvailableStatus())
154 {
155 return 'showObjectiveCreation';
156 }
157 if($this->getSettings()->worksWithInitialTest())
158 {
159 if(!$this->getInitialTestStatus(false))
160 {
162 return 'testOverview';
163 }
164 }
165 if(!$this->getQualifiedTestStatus(false))
166 {
168 return 'testOverview';
169 }
170 if(!$this->getObjectivesStatus(false))
171 {
172 return 'listObjectives';
173 }
174 return 'listObjectives';
175 }
176
177
181 public function getHTML()
182 {
183 include_once("./Services/UIComponent/Checklist/classes/class.ilChecklistGUI.php");
184 $list = new ilChecklistGUI();
185 $list->setHeading($this->lng->txt('crs_objective_status_configure'));
186
187
188 // Step 1
189 // course settings
190 $done = $this->getSettingsStatus();
191
192 $list->addEntry($this->lng->txt('crs_objective_status_settings'),
193 $this->ctrl->getLinkTarget($this->getCmdClass(),'settings'),
194 $done
197 ($this->section == self::SECTION_SETTINGS),
198 $this->getErrorMessages(self::SECTION_SETTINGS)
199 );
200
201
202 // Step 1.1
203 $done = $this->getObjectivesAvailableStatus();
204
205 $list->addEntry($this->lng->txt('crs_objective_status_objective_creation'),
206 $done
207 ? $this->ctrl->getLinkTarget($this->getCmdClass(),'listObjectives')
208 : $this->ctrl->getLinkTarget($this->getCmdClass(),'showObjectiveCreation'),
209 $done
212 ($this->section == self::SECTION_OBJECTIVES_NEW),
213 $this->getErrorMessages(self::SECTION_OBJECTIVES_NEW)
214 );
215
216 // Step 2
217 // course material
218 $done = $this->getMaterialsStatus(true);
219
220 $this->ctrl->setParameterByClass('ilobjcoursegui','cmd','enableAdministrationPanel');
221 $list->addEntry($this->lng->txt('crs_objective_status_materials'),
222 $this->ctrl->getLinkTargetByClass('ilobjcoursegui',''),
223 $done
226 ($this->section == self::SECTION_MATERIALS),
227 $this->getErrorMessages(self::SECTION_MATERIALS)
228 );
229
230
231 // Step 3
232 // course itest
233 if(ilLOSettings::getInstanceByObjId($this->getParentObject()->getId())->worksWithInitialTest())
234 {
235 $done = $this->getInitialTestStatus();
236
237 $this->ctrl->setParameter($this->getCmdClass(),'tt', 1);
238
239 $list->addEntry($this->lng->txt('crs_objective_status_itest'),
240 $this->ctrl->getLinkTarget($this->getCmdClass(),'testOverview'),
241 $done
244 ($this->section == self::SECTION_ITES),
245 $this->getErrorMessages(self::SECTION_ITES)
246 );
247 }
248
249 // Step 4
250 // course qtest
251 $done = $this->getQualifiedTestStatus();
252
253 $this->ctrl->setParameter($this->getCmdClass(),'tt', 2);
254
255 $list->addEntry($this->lng->txt('crs_objective_status_qtest'),
256 $this->ctrl->getLinkTarget($this->getCmdClass(),'testOverview'),
257 $done
260 ($this->section == self::SECTION_QTEST),
261 $this->getErrorMessages(self::SECTION_QTEST)
262 );
263
264 $this->ctrl->setParameter($this->getCmdClass(),'tt', $_GET["tt"]);
265
266 // Step 5
267 // course qtest
268 $done = $this->getObjectivesStatus();
269
270 $list->addEntry($this->lng->txt('crs_objective_status_objectives'),
271 $this->ctrl->getLinkTarget($this->getCmdClass(),'listObjectives'),
272 $done
275 ($this->section == self::SECTION_OBJECTIVES),
276 $this->getErrorMessages(self::SECTION_OBJECTIVES)
277 );
278
279 return $list->getHTML();
280 }
281
282
283
290 public function getErrorMessages($a_section)
291 {
292 $mess = array();
293 foreach($this->getFailures($a_section) as $failure_code)
294 {
295 $mess[] = $this->lng->txt($failure_code);
296 }
297 return $mess;
298 }
299
300
305 protected function getSettingsStatus()
306 {
307 return $this->getSettings()->settingsExist();
308 }
309
314 protected function getObjectivesAvailableStatus()
315 {
316 return count($this->getObjectives());
317 }
318
322 protected function getMaterialsStatus($a_set_errors = true)
323 {
324 $childs = $GLOBALS['tree']->getChilds($this->getParentObject()->getRefId());
325 foreach((array) $childs as $tnode)
326 {
327 if($tnode['type'] == 'rolf')
328 {
329 continue;
330 }
331 if($tnode['child'] == $this->getSettings()->getInitialTest())
332 {
333 continue;
334 }
335 if($tnode['child'] == $this->getSettings()->getQualifiedTest())
336 {
337 continue;
338 }
339 return true;
340 }
341 if($a_set_errors)
342 {
343 $this->appendFailure(self::SECTION_MATERIALS, 'crs_loc_err_stat_no_materials');
344 }
345 return false;
346 }
347
348 protected function getInitialTestStatus($a_set_errors = true)
349 {
350 $tst_ref = $this->getSettings()->getInitialTest();
351 if(!$GLOBALS['tree']->isInTree($tst_ref))
352 {
353 if($a_set_errors)
354 {
355 $this->appendFailure(self::SECTION_ITES, 'crs_loc_err_stat_no_it');
356 }
357 return false;
358 }
359 return true;
360 }
361
362 protected function getQualifiedTestStatus($a_set_errors = true)
363 {
364 $tst_ref = $this->getSettings()->getQualifiedTest();
365 if(!$GLOBALS['tree']->isInTree($tst_ref))
366 {
367 if($a_set_errors)
368 {
369 $this->appendFailure(self::SECTION_QTEST, 'crs_loc_err_stat_no_qt');
370 }
371 return false;
372 }
373 return true;
374 }
375
380 protected function lookupQuestionsAssigned($a_test_ref_id)
381 {
382 include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
384 {
385 foreach($this->getObjectives() as $objective_id)
386 {
387 include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
389 $this->parent_obj->getId(),
390 $objective_id,
391 ilObject::_lookupObjId($a_test_ref_id)
392 );
393 if(!$seq)
394 {
395 return false;
396 }
397 }
398 }
399 else
400 {
401 foreach($this->getObjectives() as $objective_id)
402 {
403 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
405 if(!count($qsts))
406 {
407 return false;
408 }
409 }
410 }
411 return true;
412 }
413
414
415 protected function getObjectivesStatus($a_set_errors = true)
416 {
417 if(!$this->getObjectivesAvailableStatus($a_set_errors))
418 {
419 return false;
420 }
421
422 include_once './Modules/Course/classes/class.ilCourseObjective.php';
423 $num_active = ilCourseObjective::_getCountObjectives($this->getParentObject()->getId(),true);
424 if(!$num_active)
425 {
426 if($a_set_errors)
427 {
428 $this->appendFailure(self::SECTION_OBJECTIVES, 'crs_loc_err_no_active_lo');
429 }
430 return false;
431 }
432 foreach(ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId(),true) as $objective_id)
433 {
434 include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
435 $obj = new ilCourseObjectiveMaterials($objective_id);
436 if(!count($obj->getMaterials()))
437 {
438 if($a_set_errors)
439 {
440 $this->appendFailure(self::SECTION_OBJECTIVES, 'crs_loc_err_no_active_mat');
441 }
442 return false;
443 }
444 }
445 // check for assigned initial test questions
446 if($this->getSettings()->worksWithInitialTest())
447 {
448 // check for assigned questions
449 if(!$this->lookupQuestionsAssigned($this->getSettings()->getInitialTest()))
450 {
451 if($a_set_errors)
452 {
453 $this->appendFailure(self::SECTION_OBJECTIVES, 'crs_loc_err_no_active_qst');
454 }
455 return false;
456 }
457 }
458 // check for assigned questions
459 if(!$this->lookupQuestionsAssigned($this->getSettings()->getQualifiedTest()))
460 {
461 if($a_set_errors)
462 {
463 $this->appendFailure(self::SECTION_OBJECTIVES, 'crs_loc_err_no_active_qst');
464 }
465 return false;
466 }
467
468 if(!$this->checkNumberOfTries())
469 {
470 if($a_set_errors)
471 {
472 $this->appendFailure(self::SECTION_OBJECTIVES, 'crs_loc_err_nr_tries_exceeded');
473 }
474 return false;
475 }
476
477
478
479 return true;
480 }
481
482 protected function getStartStatus()
483 {
484 return true;
485 }
486
487 protected function checkNumberOfTries()
488 {
489 $qt = $this->getSettings()->getQualifiedTest();
490 if(!$qt)
491 {
492 return true;
493 }
494
495 include_once './Services/Object/classes/class.ilObjectFactory.php';
496 $factory = new ilObjectFactory();
497 $tst = $factory->getInstanceByRefId($qt,false);
498
499 if(!$tst instanceof ilObjTest)
500 {
501 return true;
502 }
503 $tries = $tst->getNrOfTries();
504 if(!$tries)
505 {
506 return true;
507 }
508
509 $obj_tries = 0;
510 foreach($this->getObjectives() as $objective)
511 {
512 include_once './Modules/Course/classes/class.ilCourseObjective.php';
513 $obj_tries += ilCourseObjective::lookupMaxPasses($objective);
514 }
515 $GLOBALS['ilLog']->write(__METHOD__.': '.$obj_tries);
516 return $obj_tries <= $tries;
517 }
518}
519?>
$_GET["client_id"]
class ilCourseObjectiveMaterials
static lookupQuestionsByObjective($a_test_id, $a_objective)
static _getCountObjectives($a_obj_id, $a_activated_only=false)
get count objectives
static lookupMaxPasses($a_objective_id)
static _getObjectiveIds($course_id, $a_activated_only=false)
Presentation of the status of single steps during the configuration process.
getSettingsStatus()
Check if course is lo confgured.
lookupQuestionsAssigned($a_test_ref_id)
Check if questions are assigned.
getMaterialsStatus($a_set_errors=true)
Get status of materials.
getObjectivesAvailableStatus()
Get objectives.
getInitialTestStatus($a_set_errors=true)
getQualifiedTestStatus($a_set_errors=true)
static getInstance(ilObject $a_parent)
Get instance.
setSection($a_section)
Set current section.
getFirstFailedStep()
Get first failed step.
getFailures($a_section)
Get failures by section.
getCmdClass()
Get cmd class.
setCmdClass($a_cmd_class)
Command class.
getParentObject()
Get parent object.
getObjectivesStatus($a_set_errors=true)
getErrorMessages($a_section)
Get error messages.
__construct(ilObject $a_parent)
Constructor.
appendFailure($a_section, $a_failure_msg_key)
Append failure.
static lookupSequence($a_container_id, $a_objective_id, $a_test_id)
static getInstanceByObjId($a_obj_id)
get singleton instance
static lookupRandomTest($a_test_obj_id)
Check if test is a random test.
Class ilObjectFactory.
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
$GLOBALS['ct_recipient']
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7