ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilECSCourseCreationHandler Class Reference

Description of class. More...

+ Collaboration diagram for ilECSCourseCreationHandler:

Public Member Functions

 __construct (ilECSSetting $server, $a_mid)
 @maybe Constructor More...
 
 getServer ()
 Get server settings. More...
 
 getMapping ()
 Get mapping settings. More...
 
 getCourseUrl ()
 Get course url. More...
 
 isObjectCreated ()
 Check if an object (course / group) has been created. More...
 
 setObjectCreated ($a_status)
 Set object created status. More...
 
 getMid ()
 Get mid of course event. More...
 
 handle ($a_content_id, $course)
 Handle sync request. More...
 

Protected Member Functions

 doAttributeMapping ($a_content_id, $course)
 Sync attribute mapping. More...
 
 syncParentContainer ($a_content_id, $course)
 Sync parent container. More...
 
 syncNodeToTop ($tree_id, $cms_id)
 Sync node to top. More...
 
 syncCategory ($tobj_id, $parent_ref_id)
 Sync category. More...
 
 doSync ($a_content_id, $course, $a_parent_obj_id)
 Handle all in one setting. More...
 
 createParallelCourses ($a_content_id, $course, $parent_ref)
 Create parallel courses. More...
 
 createParallelCourse ($a_content_id, $course, $group, $parent_ref)
 Create parallel course. More...
 
 updateParallelCourses ($a_content_id, $course, $parent_obj)
 Update parallel group data. More...
 
 createParallelGroups ($a_content_id, $course, $parent_ref)
 This create parallel groups. More...
 
 createParallelGroup ($a_content_id, $course, $group, $parent_ref)
 Create parallel group. More...
 
 updateParallelGroups ($a_content_id, $course, $parent_obj)
 Update parallel group data. More...
 
 getImportId ($a_content_id, $a_sub_id=NULL)
 Get import id of remote course Return 0 if object isn't imported. More...
 
 updateCourseData ($course, $obj_id)
 Update course data. More...
 
 createCourseData ($course)
 Create course data from json. More...
 
 createCourseReference ($crs, $a_parent_obj_id)
 Create course reference. More...
 
 setImported ($a_content_id, $object, $a_ecs_id=0, $a_sub_id=0)
 Set new course object imported. More...
 
 addUrlEntry ($a_obj_id)
 Add an url entry. More...
 
 handleCourseUrlUpdate ()
 Update course url. More...
 

Private Attributes

 $server = null
 
 $mapping = null
 
 $course_url = null
 
 $object_created = false
 
 $mid
 

Detailed Description

Description of class.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 14 of file class.ilECSCourseCreationHandler.php.

Constructor & Destructor Documentation

◆ __construct()

ilECSCourseCreationHandler::__construct ( ilECSSetting  $server,
  $a_mid 
)

@maybe Constructor

Definition at line 28 of file class.ilECSCourseCreationHandler.php.

29 {
30 $this->server = $server;
31 $this->mid = $a_mid;
32 $this->mapping = ilECSNodeMappingSettings::getInstanceByServerMid($this->getServer()->getServerId(), $this->getMid());
33
34 include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseUrl.php';
35 $this->course_url = new ilECSCourseUrl();
36 }
Represents a ecs course url.
static getInstanceByServerMid($a_server_id, $a_mid)
Get instance.

References $server, ilECSNodeMappingSettings\getInstanceByServerMid(), getMid(), and getServer().

+ Here is the call graph for this function:

Member Function Documentation

◆ addUrlEntry()

ilECSCourseCreationHandler::addUrlEntry (   $a_obj_id)
protected

Add an url entry.

Parameters
type$a_obj_id

Definition at line 644 of file class.ilECSCourseCreationHandler.php.

645 {
646 $refs = ilObject::_getAllReferences($a_obj_id);
647 $ref_id = end($refs);
648
649 if(!$ref_id)
650 {
651 return false;
652 }
653 include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseLmsUrl.php';
654 $lms_url = new ilECSCourseLmsUrl();
655 $lms_url->setTitle(ilObject::_lookupTitle($a_obj_id));
656
657 include_once './Services/Link/classes/class.ilLink.php';
658 $lms_url->setUrl(ilLink::_getLink($ref_id));
659 $this->getCourseUrl()->addLmsCourseUrls($lms_url);
660 }
Represents a ecs course lms url.
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
$ref_id
Definition: sahs_server.php:39

References $ref_id, ilObject\_getAllReferences(), ilLink\_getLink(), ilObject\_lookupTitle(), and getCourseUrl().

Referenced by createCourseReference(), updateParallelCourses(), and updateParallelGroups().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createCourseData()

ilECSCourseCreationHandler::createCourseData (   $course)
protected

Create course data from json.

Returns
ilObjCourse

Definition at line 585 of file class.ilECSCourseCreationHandler.php.

586 {
587 include_once './Modules/Course/classes/class.ilObjCourse.php';
588 $course_obj = new ilObjCourse();
589 $title = $course->title;
590 $GLOBALS['ilLog']->write(__METHOD__.': Creating new course instance from ecs : '. $title);
591 $course_obj->setTitle($title);
592 $course_obj->create();
593 return $course_obj;
594 }
Class ilObjCourse.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276

References $GLOBALS.

Referenced by doSync().

+ Here is the caller graph for this function:

◆ createCourseReference()

ilECSCourseCreationHandler::createCourseReference (   $crs,
  $a_parent_obj_id 
)
protected

Create course reference.

Parameters
ilObjCourse$crs_obj
int$a_parent_obj_id
Returns
ilObjCourse

Definition at line 602 of file class.ilECSCourseCreationHandler.php.

603 {
604 $ref_ids = ilObject::_getAllReferences($a_parent_obj_id);
605 $ref_id = end($ref_ids);
606
607 $crs->createReference();
608 $crs->putInTree($ref_id);
609 $crs->setPermissions($ref_id);
610
611 $this->setObjectCreated(true);
612 $this->addUrlEntry($crs->getId());
613 return $crs;
614 }
setObjectCreated($a_status)
Set object created status.

References $ref_id, ilObject\_getAllReferences(), addUrlEntry(), and setObjectCreated().

Referenced by createParallelCourse(), and doSync().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createParallelCourse()

ilECSCourseCreationHandler::createParallelCourse (   $a_content_id,
  $course,
  $group,
  $parent_ref 
)
protected

Create parallel course.

Parameters
type$course
type$group
type$parent_ref

Definition at line 415 of file class.ilECSCourseCreationHandler.php.

416 {
417 include_once './Modules/Course/classes/class.ilObjCourse.php';
418 $course_obj = new ilObjCourse();
419 $title = strlen($group->title) ? $group->title : $course->title;
420 $GLOBALS['ilLog']->write(__METHOD__.': Creating new parallel course instance from ecs : '. $title);
421 $course_obj->setTitle($title);
422 $course_obj->setSubscriptionMaxMembers((int) $group->maxParticipants);
423 $course_obj->create();
424
425 $this->createCourseReference($course_obj, ilObject::_lookupObjId($parent_ref));
426 $this->setImported($course->lectureID, $course_obj,$a_content_id, $group->id);
427 $this->setObjectCreated(true);
428 return true;
429 }
setImported($a_content_id, $object, $a_ecs_id=0, $a_sub_id=0)
Set new course object imported.
createCourseReference($crs, $a_parent_obj_id)
Create course reference.
static _lookupObjId($a_id)

References $GLOBALS, ilObject\_lookupObjId(), createCourseReference(), setImported(), and setObjectCreated().

Referenced by createParallelCourses(), and updateParallelCourses().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createParallelCourses()

ilECSCourseCreationHandler::createParallelCourses (   $a_content_id,
  $course,
  $parent_ref 
)
protected

Create parallel courses.

Parameters
intecontent id
type$course
type$parent_ref

Definition at line 400 of file class.ilECSCourseCreationHandler.php.

401 {
402 foreach((array) $course->groups as $group)
403 {
404 $this->createParallelCourse($a_content_id,$course, $group, $parent_ref);
405 }
406 return true;
407 }
createParallelCourse($a_content_id, $course, $group, $parent_ref)
Create parallel course.

References createParallelCourse().

Referenced by doSync().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createParallelGroup()

ilECSCourseCreationHandler::createParallelGroup (   $a_content_id,
  $course,
  $group,
  $parent_ref 
)
protected

Create parallel group.

Parameters
type$course
type$group

Definition at line 487 of file class.ilECSCourseCreationHandler.php.

488 {
489 include_once './Modules/Group/classes/class.ilObjGroup.php';
490 $group_obj = new ilObjGroup();
491 $title = strlen($group->title) ? $group->title : $course->title;
492 $group_obj->setTitle($title);
493 $group_obj->setMaxMembers((int) $group->maxParticipants);
494 $group_obj->create();
495 $group_obj->createReference();
496 $group_obj->putInTree($parent_ref);
497 $group_obj->setPermissions($parent_ref);
498 $group_obj->initGroupStatus(GRP_TYPE_CLOSED);
499 $this->setImported($course->lectureID, $group_obj, $a_content_id, $group->id);
500 $this->setObjectCreated(true);
501 }
const GRP_TYPE_CLOSED
Class ilObjGroup.

References GRP_TYPE_CLOSED, setImported(), and setObjectCreated().

Referenced by createParallelGroups(), and updateParallelGroups().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createParallelGroups()

ilECSCourseCreationHandler::createParallelGroups (   $a_content_id,
  $course,
  $parent_ref 
)
protected

This create parallel groups.

Parameters
type$course
ilObjCourse

Definition at line 473 of file class.ilECSCourseCreationHandler.php.

474 {
475 foreach((array) $course->groups as $group)
476 {
477 $this->createParallelGroup($a_content_id,$course, $group, $parent_ref);
478 }
479 return true;
480 }
createParallelGroup($a_content_id, $course, $group, $parent_ref)
Create parallel group.

References createParallelGroup().

Referenced by doSync().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doAttributeMapping()

ilECSCourseCreationHandler::doAttributeMapping (   $a_content_id,
  $course 
)
protected

Sync attribute mapping.

Parameters
type$a_content_id
type$course

Definition at line 136 of file class.ilECSCourseCreationHandler.php.

137 {
138 // Check if course is already created
139 $course_id = $course->lectureID;
140 $obj_id = $this->getImportId($course_id);
141
142 if($obj_id)
143 {
144 // do update
145 $GLOBALS['ilLog']->write(__METHOD__.' Performing update of already imported course.');
146
147 $refs = ilObject::_getAllReferences($obj_id);
148 $ref = end($refs);
149
150 return $this->doSync(
151 $a_content_id,
152 $course,
153 ilObject::_lookupObjId($GLOBALS['tree']->getParentId($ref))
154 );
155 }
156
157 // Get all rules
158 $matching_rule = 0;
159 include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseMappingRule.php';
160 foreach(ilECSCourseMappingRule::getRuleRefIds($this->getServer()->getServerId(), $this->getMid()) as $ref_id)
161 {
163 $course,
164 $this->getServer()->getServerId(),
165 $this->getMid(),
166 $ref_id))
167 {
168 $matching_rule = $ref_id;
169 }
170 }
171 if(!$matching_rule)
172 {
173 // Put course in default category
174 $GLOBALS['ilLog']->write(__METHOD__.': No matching attribute mapping rule found.');
175 $GLOBALS['ilLog']->write(__METHOD__.': Using course default category');
176 return $this->doSync($a_content_id,$course,ilObject::_lookupObjId($this->getMapping()->getDefaultCourseCategory()));
177 }
178 // map according mapping rules
179 $parent_ref = ilECSCourseMappingRule::doMappings($course,$this->getServer()->getServerId(),$this->getMid(),$ref_id);
180 $this->doSync($a_content_id, $course, ilObject::_lookupObjId($parent_ref));
181 return true;
182 }
getImportId($a_content_id, $a_sub_id=NULL)
Get import id of remote course Return 0 if object isn't imported.
doSync($a_content_id, $course, $a_parent_obj_id)
Handle all in one setting.
static isMatching($course, $a_sid, $a_mid, $a_ref_id)
Check if rule matches.
static doMappings($course, $a_sid, $a_mid, $a_ref_id)
static getRuleRefIds($a_sid, $a_mid)

References $GLOBALS, $ref_id, ilObject\_getAllReferences(), ilObject\_lookupObjId(), ilECSCourseMappingRule\doMappings(), doSync(), getImportId(), getMapping(), getMid(), ilECSCourseMappingRule\getRuleRefIds(), getServer(), and ilECSCourseMappingRule\isMatching().

Referenced by handle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doSync()

ilECSCourseCreationHandler::doSync (   $a_content_id,
  $course,
  $a_parent_obj_id 
)
protected

Handle all in one setting.

Parameters
type$a_content_id
type$course

Definition at line 308 of file class.ilECSCourseCreationHandler.php.

309 {
310 // Check if course is already created
311 $course_id = $course->lectureID;
312 $this->getCourseUrl()->setCmsLectureId($course_id);
313
314 $obj_id = $this->getImportId($course_id);
315
316 $GLOBALS['ilLog']->write(__METHOD__.': Found obj_id '.$obj_id. ' for course_id '. $course_id );
317
318 // Handle parallel groups
319 if($obj_id)
320 {
321 // update multiple courses/groups according to parallel scenario
322 $GLOBALS['ilLog']->write(__METHOD__.': Group scenario '.$course->groupScenario);
323 include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
324 switch((int) $course->groupScenario)
325 {
327 $GLOBALS['ilLog']->write(__METHOD__.': Performing update for parallel groups in course.');
328 $this->updateParallelGroups($course,$obj_id);
329 break;
330
332 $GLOBALS['ilLog']->write(__METHOD__.': Performing update for parallel courses.');
333 $this->updateParallelCourses($a_content_id,$course, $a_parent_obj_id);
334 break;
335
337 default:
338 // nothing to do
339 break;
340
341 }
342
343 // do update
344 $this->updateCourseData($course,$obj_id);
345 }
346 else
347 {
348 include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
349 switch((int) $course->groupScenario)
350 {
352 $GLOBALS['ilLog']->write(__METHOD__.': Parallel scenario "groups in courses".');
353 $crs = $this->createCourseData($course);
354 $crs = $this->createCourseReference($crs, $a_parent_obj_id);
355 $this->setImported($course_id, $crs, $a_content_id);
356
357 // Create parallel groups under crs
358 $this->createParallelGroups($a_content_id,$course,$crs->getRefId());
359 break;
360
362 // Import empty to store the ecs ressource id (used for course member update).
363 $this->setImported($course_id,NULL,$a_content_id);
364 $GLOBALS['ilLog']->write(__METHOD__.': Parallel scenario "Courses foreach Lecturer".');
365 break;
366
368 $GLOBALS['ilLog']->write(__METHOD__.': Parallel scenario "Many courses".');
369
370 $refs = ilObject::_getAllReferences($a_parent_obj_id);
371 $ref = end($refs);
372 $crs = $this->createCourseData($course);
373 $this->createCourseReference($crs, $a_parent_obj_id);
374 $this->setImported($course_id, $crs, $a_content_id);
375 $this->createParallelCourses($a_content_id,$course, $ref);
376 break;
377
378 default:
380 $GLOBALS['ilLog']->write(__METHOD__.': Parallel scenario "One Course".');
381 $crs = $this->createCourseData($course);
382 $this->createCourseReference($crs, $a_parent_obj_id);
383 $this->setImported($course_id, $crs, $a_content_id);
384 break;
385
386
387 }
388 }
389 // finally update course urls
390 $this->handleCourseUrlUpdate();
391 return true;
392 }
updateCourseData($course, $obj_id)
Update course data.
createParallelGroups($a_content_id, $course, $parent_ref)
This create parallel groups.
createCourseData($course)
Create course data from json.
updateParallelGroups($a_content_id, $course, $parent_obj)
Update parallel group data.
createParallelCourses($a_content_id, $course, $parent_ref)
Create parallel courses.
updateParallelCourses($a_content_id, $course, $parent_obj)
Update parallel group data.

References $GLOBALS, ilObject\_getAllReferences(), createCourseData(), createCourseReference(), createParallelCourses(), createParallelGroups(), getCourseUrl(), getImportId(), handleCourseUrlUpdate(), ilECSMappingUtils\PARALLEL_ALL_COURSES, ilECSMappingUtils\PARALLEL_COURSES_FOR_LECTURERS, ilECSMappingUtils\PARALLEL_GROUPS_IN_COURSE, ilECSMappingUtils\PARALLEL_ONE_COURSE, setImported(), updateCourseData(), updateParallelCourses(), and updateParallelGroups().

Referenced by doAttributeMapping(), and handle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCourseUrl()

ilECSCourseCreationHandler::getCourseUrl ( )

Get course url.

Returns
ilECSCourseUrl Description

Definition at line 61 of file class.ilECSCourseCreationHandler.php.

References $course_url.

Referenced by addUrlEntry(), doSync(), handle(), and handleCourseUrlUpdate().

+ Here is the caller graph for this function:

◆ getImportId()

ilECSCourseCreationHandler::getImportId (   $a_content_id,
  $a_sub_id = NULL 
)
protected

Get import id of remote course Return 0 if object isn't imported.

Searches for the (hopefully) unique content id of an imported object

Parameters
type$a_content_id
Returns
type

Definition at line 545 of file class.ilECSCourseCreationHandler.php.

546 {
547 include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
549 $this->getServer()->getServerId(),
550 $this->getMid(),
551 $a_content_id,
552 $a_sub_id
553 );
554 }
static lookupObjIdByContentId($a_server_id, $a_mid, $a_content_id, $a_sub_id='')
Lookup obj_id by content id.

References getMid(), getServer(), and ilECSImport\lookupObjIdByContentId().

Referenced by doAttributeMapping(), doSync(), syncNodeToTop(), updateParallelCourses(), and updateParallelGroups().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMapping()

ilECSCourseCreationHandler::getMapping ( )

Get mapping settings.

Returns
ilECSNodeMappingSettings

Definition at line 52 of file class.ilECSCourseCreationHandler.php.

References $mapping.

Referenced by doAttributeMapping(), and handle().

+ Here is the caller graph for this function:

◆ getMid()

ilECSCourseCreationHandler::getMid ( )

Get mid of course event.

Returns
type

Definition at line 88 of file class.ilECSCourseCreationHandler.php.

References $mid.

Referenced by __construct(), doAttributeMapping(), getImportId(), handleCourseUrlUpdate(), setImported(), syncCategory(), syncNodeToTop(), and syncParentContainer().

+ Here is the caller graph for this function:

◆ getServer()

ilECSCourseCreationHandler::getServer ( )

Get server settings.

Returns
ilECSSetting

Definition at line 43 of file class.ilECSCourseCreationHandler.php.

44 {
45 return $this->server;
46 }

References $server.

Referenced by __construct(), doAttributeMapping(), getImportId(), handleCourseUrlUpdate(), setImported(), syncCategory(), syncNodeToTop(), and syncParentContainer().

+ Here is the caller graph for this function:

◆ handle()

ilECSCourseCreationHandler::handle (   $a_content_id,
  $course 
)

Handle sync request.

Parameters
intecs content id
type$course

Definition at line 98 of file class.ilECSCourseCreationHandler.php.

99 {
100 $GLOBALS['ilLog']->write(__METHOD__.': --------- content id '.$a_content_id);
101
102 // prepare course url
103 // if any object (course group) will be created, a list of all course urls
104 // will be sent to ecs.
105 $this->setObjectCreated(false);
106 $this->getCourseUrl()->setECSId($a_content_id);
107
108
109 if($this->getMapping()->isAttributeMappingEnabled())
110 {
111 $GLOBALS['ilLog']->write(__METHOD__.': Handling advanced attribute mapping');
112 return $this->doAttributeMapping($a_content_id,$course);
113 }
114
115 if($this->getMapping()->isAllInOneCategoryEnabled())
116 {
117 $GLOBALS['ilLog']->write(__METHOD__.': Handling course all in one category setting');
118 return $this->doSync($a_content_id, $course,ilObject::_lookupObjId($this->getMapping()->getAllInOneCategory()));
119 }
120
121 $parent_obj_id = $this->syncParentContainer($a_content_id,$course);
122 if($parent_obj_id)
123 {
124 $GLOBALS['ilLog']->write(__METHOD__.': Using already mapped category: '. ilObject::_lookupTitle($parent_obj_id));
125 return $this->doSync($a_content_id,$course,$parent_obj_id);
126 }
127 $GLOBALS['ilLog']->write(__METHOD__.': Using course default category');
128 return $this->doSync($a_content_id,$course,ilObject::_lookupObjId($this->getMapping()->getDefaultCourseCategory()));
129 }
doAttributeMapping($a_content_id, $course)
Sync attribute mapping.
syncParentContainer($a_content_id, $course)
Sync parent container.

References $GLOBALS, ilObject\_lookupObjId(), ilObject\_lookupTitle(), doAttributeMapping(), doSync(), getCourseUrl(), getMapping(), setObjectCreated(), and syncParentContainer().

+ Here is the call graph for this function:

◆ handleCourseUrlUpdate()

ilECSCourseCreationHandler::handleCourseUrlUpdate ( )
protected

Update course url.

Definition at line 665 of file class.ilECSCourseCreationHandler.php.

666 {
667 $GLOBALS['ilLog']->write(__METHOD__.': Starting course url update');
668 if($this->isObjectCreated())
669 {
670 $GLOBALS['ilLog']->write(__METHOD__.': Sending new course group url');
671 $this->getCourseUrl()->send($this->getServer(), $this->getMid());
672 }
673 else
674 {
675 $GLOBALS['ilLog']->write(__METHOD__.': No courses groups created. Aborting');
676 }
677 }
isObjectCreated()
Check if an object (course / group) has been created.

References $GLOBALS, getCourseUrl(), getMid(), getServer(), and isObjectCreated().

Referenced by doSync().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isObjectCreated()

ilECSCourseCreationHandler::isObjectCreated ( )

Check if an object (course / group) has been created.

Returns
bool

Definition at line 70 of file class.ilECSCourseCreationHandler.php.

References $object_created.

Referenced by handleCourseUrlUpdate().

+ Here is the caller graph for this function:

◆ setImported()

ilECSCourseCreationHandler::setImported (   $a_content_id,
  $object,
  $a_ecs_id = 0,
  $a_sub_id = 0 
)
protected

Set new course object imported.

Parameters
int$a_content_id
ilObjCourse$crs

Definition at line 621 of file class.ilECSCourseCreationHandler.php.

622 {
623 include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
624 $import = new ilECSImport(
625 $this->getServer()->getServerId(),
626 is_object($object) ? $object->getId() : 0
627 );
628
629 $GLOBALS['ilLog']->write(__METHOD__.': Imported with ecs id '.$a_ecs_id);
630
631 $import->setSubId($a_sub_id);
632 $import->setMID($this->getMid());
633 $import->setEContentId($a_ecs_id);
634 $import->setContentId($a_content_id);
635 $import->setImported(true);
636 $import->save();
637 return true;
638 }
Storage of ECS imported objects.

References $GLOBALS, getMid(), and getServer().

Referenced by createParallelCourse(), createParallelGroup(), and doSync().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setObjectCreated()

ilECSCourseCreationHandler::setObjectCreated (   $a_status)

Set object created status.

Parameters
bool$a_status

Definition at line 79 of file class.ilECSCourseCreationHandler.php.

80 {
81 $this->object_created = $a_status;
82 }

Referenced by createCourseReference(), createParallelCourse(), createParallelGroup(), and handle().

+ Here is the caller graph for this function:

◆ syncCategory()

ilECSCourseCreationHandler::syncCategory (   $tobj_id,
  $parent_ref_id 
)
protected

Sync category.

Parameters
type$tobj_id
type$parent_ref_id

Definition at line 270 of file class.ilECSCourseCreationHandler.php.

271 {
272 include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
273 $data = new ilECSCmsData($tobj_id);
274
275 include_once './Modules/Category/classes/class.ilObjCategory.php';
276 $cat = new ilObjCategory();
277 $cat->setTitle($data->getTitle());
278 $cat->create(); // true for upload
279 $cat->createReference();
280 $cat->putInTree($parent_ref_id);
281 $cat->setPermissions($parent_ref_id);
282 $cat->deleteTranslation($GLOBALS['lng']->getDefaultLanguage());
283 $cat->addTranslation(
284 $data->getTitle(),
285 $cat->getLongDescription(),
286 $GLOBALS['lng']->getDefaultLanguage(),
287 1
288 );
289
290 // set imported
291 $import = new ilECSImport(
292 $this->getServer()->getServerId(),
293 $cat->getId()
294 );
295 $import->setMID($this->getMid());
296 $import->setContentId($data->getCmsId());
297 $import->setImported(true);
298 $import->save();
299
300 return $cat->getId();
301 }
Class ilObjCategory.
$data

References $data, $GLOBALS, getMid(), and getServer().

Referenced by syncNodeToTop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ syncNodeToTop()

ilECSCourseCreationHandler::syncNodeToTop (   $tree_id,
  $cms_id 
)
protected

Sync node to top.

Parameters
type$tree_id
type$parent_id
Returns
int obj_id of container

Definition at line 214 of file class.ilECSCourseCreationHandler.php.

215 {
216 $obj_id = $this->getImportId($cms_id);
217 if($obj_id)
218 {
219 // node already imported
220 return $obj_id;
221 }
222
223 $tobj_id = ilECSCmsData::lookupObjId(
224 $this->getServer()->getServerId(),
225 $this->getMid(),
226 $tree_id,
227 $cms_id);
228
229 // node is not imported
230 $GLOBALS['ilLog']->write(__METHOD__.': ecs node with id '. $cms_id. ' is not imported for mid ' . $this->getMid().' tree_id '.$tree_id);
231
232 // check for mapping: if mapping is available create category
233 include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignment.php';
235 $this->getServer()->getServerId(),
236 $this->getMid(),
237 $tree_id,
238 $tobj_id);
239
240 if($ass->isMapped())
241 {
242 $GLOBALS['ilLog']->write(__METHOD__.': node is mapped');
243 return $this->syncCategory($tobj_id,$ass->getRefId());
244 }
245
246 // Start recursion to top
247 include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
248 $tree = new ilECSCmsTree($tree_id);
249 $parent_tobj_id = $tree->getParentId($tobj_id);
250 if($parent_tobj_id)
251 {
252 $cms_ids = ilECSCmsData::lookupCmsIds(array($parent_tobj_id));
253 $obj_id = $this->syncNodeToTop($tree_id, $cms_ids[0]);
254 }
255
256 if($obj_id)
257 {
258 $refs = ilObject::_getAllReferences($obj_id);
259 $ref_id = end($refs);
260 return $this->syncCategory($tobj_id, $ref_id);
261 }
262 return 0;
263 }
static lookupObjId($a_server_id, $a_mid, $a_tree_id, $cms_id)
static lookupCmsIds($a_obj_ids)
syncCategory($tobj_id, $parent_ref_id)
Sync category.
syncNodeToTop($tree_id, $cms_id)
Sync node to top.

References $GLOBALS, $ref_id, ilObject\_getAllReferences(), getImportId(), getMid(), getServer(), ilECSCmsData\lookupCmsIds(), ilECSCmsData\lookupObjId(), syncCategory(), and syncNodeToTop().

Referenced by syncNodeToTop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ syncParentContainer()

ilECSCourseCreationHandler::syncParentContainer (   $a_content_id,
  $course 
)
protected

Sync parent container.

Parameters
type$a_content_id
type$course

Definition at line 189 of file class.ilECSCourseCreationHandler.php.

190 {
191 if(!is_array($course->allocations))
192 {
193 $GLOBALS['ilLog']->write(__METHOD__.': No allocation in course defined.');
194 return 0;
195 }
196 if(!$course->allocations[0]->parentID)
197 {
198 $GLOBALS['ilLog']->write(__METHOD__.': No allocation parent in course defined.');
199 return 0;
200 }
201 $parent_id = $course->allocations[0]->parentID;
202
203 include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
204 $parent_tid = ilECSCmsData::lookupFirstTreeOfNode($this->getServer()->getServerId(), $this->getMid(), $parent_id);
205 return $this->syncNodetoTop($parent_tid, $parent_id);
206 }
static lookupFirstTreeOfNode($a_server_id, $a_mid, $cms_id)
Lookup first obj_id of cms node @global $ilDB $ilDB.

References $GLOBALS, getMid(), getServer(), and ilECSCmsData\lookupFirstTreeOfNode().

Referenced by handle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateCourseData()

ilECSCourseCreationHandler::updateCourseData (   $course,
  $obj_id 
)
protected

Update course data.

Parameters
type$course

Definition at line 560 of file class.ilECSCourseCreationHandler.php.

561 {
562 // do update
563 $refs = ilObject::_getAllReferences($obj_id);
564 $ref_id = end($refs);
566 if(!$crs_obj instanceof ilObject)
567 {
568 $GLOBALS['ilLog']->write(__METHOD__.': Cannot instantiate course instance');
569 return true;
570 }
571
572 // Update title
573 $title = $course->title;
574 $GLOBALS['ilLog']->write(__METHOD__.': new title is : '. $title);
575
576 $crs_obj->setTitle($title);
577 $crs_obj->update();
578 return true;
579 }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObject Basic functions for all objects.

References $GLOBALS, $ref_id, ilObject\_getAllReferences(), and ilObjectFactory\getInstanceByRefId().

Referenced by doSync().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateParallelCourses()

ilECSCourseCreationHandler::updateParallelCourses (   $a_content_id,
  $course,
  $parent_obj 
)
protected

Update parallel group data.

Parameters
type$course
type$parent_obj

Definition at line 436 of file class.ilECSCourseCreationHandler.php.

437 {
438 $parent_refs = ilObject::_getAllReferences($parent_obj);
439 $parent_ref = end($parent_refs);
440
441 foreach((array) $course->groups as $group)
442 {
443 $title = strlen($group->title) ? $group->title : $course->title;
444 $obj_id = $this->getImportId($course->lectureID, $group->id);
445 $GLOBALS['ilLog']->write(__METHOD__.': Imported obj id is ' .$obj_id);
446 if(!$obj_id)
447 {
448 $this->createParallelCourse($a_content_id, $course, $group, $parent_ref);
449 }
450 else
451 {
452 $course_obj = ilObjectFactory::getInstanceByObjId($obj_id,false);
453 if($course_obj instanceof ilObjCourse)
454 {
455 $GLOBALS['ilLog']->write(__METHOD__.': New title is '. $title);
456 $course_obj->setTitle($title);
457 $course_obj->setSubscriptionMaxMembers($group->maxParticipants);
458 $course_obj->update();
459 }
460 }
461 $this->addUrlEntry($this->getImportId($course->lectureID, $group->ID));
462 }
463 return true;
464 }
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id

References $GLOBALS, ilObject\_getAllReferences(), addUrlEntry(), createParallelCourse(), getImportId(), and ilObjectFactory\getInstanceByObjId().

Referenced by doSync().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateParallelGroups()

ilECSCourseCreationHandler::updateParallelGroups (   $a_content_id,
  $course,
  $parent_obj 
)
protected

Update parallel group data.

Parameters
type$course
type$parent_obj

Definition at line 509 of file class.ilECSCourseCreationHandler.php.

510 {
511 $parent_refs = ilObject::_getAllReferences($parent_obj);
512 $parent_ref = end($parent_refs);
513
514 foreach((array) $course->groups as $group)
515 {
516 $obj_id = $this->getImportId($course->lectureID, $group->id);
517 $GLOBALS['ilLog']->write(__METHOD__.': Imported obj id is ' .$obj_id);
518 if(!$obj_id)
519 {
520 $this->createParallelGroup($a_content_id,$course, $group, $parent_ref);
521 }
522 else
523 {
524 $group_obj = ilObjectFactory::getInstanceByObjId($obj_id,false);
525 if($group_obj instanceof ilObjGroup)
526 {
527 $title = strlen($group->title) ? $group->title : $course->title;
528 $GLOBALS['ilLog']->write(__METHOD__.': New title is '. $title);
529 $group_obj->setTitle($title);
530 $group_obj->setMaxMembers((int) $group->maxParticipants);
531 $group_obj->update();
532 }
533 }
534 $this->addUrlEntry($this->getImportId($course->lectureID, $group->id));
535 }
536 }

References $GLOBALS, ilObject\_getAllReferences(), addUrlEntry(), createParallelGroup(), getImportId(), and ilObjectFactory\getInstanceByObjId().

Referenced by doSync().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $course_url

ilECSCourseCreationHandler::$course_url = null
private

Definition at line 18 of file class.ilECSCourseCreationHandler.php.

Referenced by getCourseUrl().

◆ $mapping

ilECSCourseCreationHandler::$mapping = null
private

Definition at line 17 of file class.ilECSCourseCreationHandler.php.

Referenced by getMapping().

◆ $mid

ilECSCourseCreationHandler::$mid
private

Definition at line 21 of file class.ilECSCourseCreationHandler.php.

Referenced by getMid().

◆ $object_created

ilECSCourseCreationHandler::$object_created = false
private

Definition at line 19 of file class.ilECSCourseCreationHandler.php.

Referenced by isObjectCreated().

◆ $server

ilECSCourseCreationHandler::$server = null
private

Definition at line 16 of file class.ilECSCourseCreationHandler.php.

Referenced by __construct(), and getServer().


The documentation for this class was generated from the following file: