ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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

 getCreatedCourses ()
 get created courses More...
 
 doAttributeMapping ($a_content_id, $course)
 Sync attribute mapping. More...
 
 createCourseReferenceObjects ($a_parent_ref_id)
 Create course reference objects. 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=null)
 Set new course object imported. More...
 
 addUrlEntry ($a_obj_id)
 Add an url entry. More...
 
 handleCourseUrlUpdate ()
 Update course url. More...
 

Protected Attributes

 $log
 

Private Attributes

 $server = null
 
 $mapping = null
 
 $course_url = null
 
 $object_created = false
 
 $courses_created = array()
 
 $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 35 of file class.ilECSCourseCreationHandler.php.

36 {
37 $this->log = $GLOBALS['DIC']->logger()->wsrv();
38
39 $this->server = $server;
40 $this->mid = $a_mid;
41 $this->mapping = ilECSNodeMappingSettings::getInstanceByServerMid($this->getServer()->getServerId(), $this->getMid());
42
43 include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseUrl.php';
44 $this->course_url = new ilECSCourseUrl();
45 }
Represents a ecs course url.
static getInstanceByServerMid($a_server_id, $a_mid)
Get instance.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

References $GLOBALS, $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 751 of file class.ilECSCourseCreationHandler.php.

752 {
753 $refs = ilObject::_getAllReferences($a_obj_id);
754 $ref_id = end($refs);
755
756 if(!$ref_id)
757 {
758 return false;
759 }
760 include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseLmsUrl.php';
761 $lms_url = new ilECSCourseLmsUrl();
762 $lms_url->setTitle(ilObject::_lookupTitle($a_obj_id));
763
764 include_once './Services/Link/classes/class.ilLink.php';
765 $lms_url->setUrl(ilLink::_getLink($ref_id));
766 $this->getCourseUrl()->addLmsCourseUrls($lms_url);
767 }
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 689 of file class.ilECSCourseCreationHandler.php.

690 {
691 include_once './Modules/Course/classes/class.ilObjCourse.php';
692 $course_obj = new ilObjCourse();
693 $course_obj->setOwner(SYSTEM_USER_ID);
694 $title = $course->title;
695 $GLOBALS['ilLog']->write(__METHOD__.': Creating new course instance from ecs : '. $title);
696 $course_obj->setTitle($title);
697 $course_obj->create();
698 return $course_obj;
699 }
Class ilObjCourse.

References $GLOBALS, and $title.

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 707 of file class.ilECSCourseCreationHandler.php.

708 {
709 $ref_ids = ilObject::_getAllReferences($a_parent_obj_id);
710 $ref_id = end($ref_ids);
711
712 $crs->createReference();
713 $crs->putInTree($ref_id);
714 $crs->setPermissions($ref_id);
715
716 $this->setObjectCreated(true);
717 $this->addUrlEntry($crs->getId());
718
719 $this->courses_created[] = $crs->getRefId();
720
721 return $crs;
722 }
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:

◆ createCourseReferenceObjects()

ilECSCourseCreationHandler::createCourseReferenceObjects (   $a_parent_ref_id)
protected

Create course reference objects.

Parameters
type$a_parent_ref_id

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

250 {
251 foreach($this->getCreatedCourses() as $ref_id)
252 {
253 include_once './Modules/CourseReference/classes/class.ilObjCourseReference.php';
254 $crsr = new ilObjCourseReference();
255 $crsr->setOwner(SYTEM_USER_ID);
256 $crsr->setTargetRefId($ref_id);
257 $crsr->setTargetId(ilObject::_lookupObjId($ref_id));
258 $crsr->create();
259 $crsr->update();
260 $crsr->createReference();
261 $crsr->putInTree($a_parent_ref_id);
262 $crsr->setPermissions($a_parent_ref_id);
263
264 $this->log->debug('Created new course reference in : ' . ilObject::_lookupTitle(ilObject::_lookupObjId($a_parent_ref_id)));
265 $this->log->debug('Created new course reference for : ' . ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)));
266 }
267 }
static _lookupObjId($a_id)

References $ref_id, ilObject\_lookupObjId(), ilObject\_lookupTitle(), and getCreatedCourses().

Referenced by doAttributeMapping().

+ 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 502 of file class.ilECSCourseCreationHandler.php.

503 {
504 if($this->getImportId($course->lectureID, $group->id))
505 {
506 $this->log->debug('Parallel course already created');
507 return false;
508 }
509
510 include_once './Modules/Course/classes/class.ilObjCourse.php';
511 $course_obj = new ilObjCourse();
512 $course_obj->setOwner(SYSTEM_USER_ID);
513 $title = $course->title;
514 if(strlen($group->title))
515 {
516 $title .= ' ('.$group->title.')';
517 }
518 $this->log->debug('Creating new parallel course instance from ecs : '. $title);
519 $course_obj->setTitle($title);
520 $course_obj->setSubscriptionMaxMembers((int) $group->maxParticipants);
521 $course_obj->create();
522
523 $this->createCourseReference($course_obj, ilObject::_lookupObjId($parent_ref));
524 $this->setImported($course->lectureID, $course_obj,$a_content_id, $group->id);
525 $this->setObjectCreated(true);
526 return true;
527 }
getImportId($a_content_id, $a_sub_id=NULL)
Get import id of remote course Return 0 if object isn't imported.
setImported($a_content_id, $object, $a_ecs_id=0, $a_sub_id=null)
Set new course object imported.
createCourseReference($crs, $a_parent_obj_id)
Create course reference.

References $title, ilObject\_lookupObjId(), createCourseReference(), getImportId(), 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 487 of file class.ilECSCourseCreationHandler.php.

488 {
489 foreach((array) $course->groups as $group)
490 {
491 $this->createParallelCourse($a_content_id,$course, $group, $parent_ref);
492 }
493 return true;
494 }
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 590 of file class.ilECSCourseCreationHandler.php.

591 {
592 include_once './Modules/Group/classes/class.ilObjGroup.php';
593 $group_obj = new ilObjGroup();
594 $group_obj->setOwner(SYSTEM_USER_ID);
595 $title = strlen($group->title) ? $group->title : $course->title;
596 $group_obj->setTitle($title);
597 $group_obj->setMaxMembers((int) $group->maxParticipants);
598 $group_obj->create();
599 $group_obj->createReference();
600 $group_obj->putInTree($parent_ref);
601 $group_obj->setPermissions($parent_ref);
602 $group_obj->initGroupStatus(GRP_TYPE_CLOSED);
603 $this->setImported($course->lectureID, $group_obj, $a_content_id, $group->id);
604 $this->setObjectCreated(true);
605 }
const GRP_TYPE_CLOSED
Class ilObjGroup.

References $title, 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 576 of file class.ilECSCourseCreationHandler.php.

577 {
578 foreach((array) $course->groups as $group)
579 {
580 $this->createParallelGroup($a_content_id,$course, $group, $parent_ref);
581 }
582 return true;
583 }
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 155 of file class.ilECSCourseCreationHandler.php.

156 {
157 // Check if course is already created
158 $course_id = $course->lectureID;
159 $obj_id = $this->getImportId($course_id);
160
161 if($obj_id)
162 {
163 // do update
164 $this->log->debug('Performing update of already imported course.');
165
166 $refs = ilObject::_getAllReferences($obj_id);
167 $ref = end($refs);
168
169 $this->doSync(
170 $a_content_id,
171 $course,
172 ilObject::_lookupObjId($GLOBALS['tree']->getParentId($ref))
173 );
174 return true;
175 }
176
177 // Get all rules
178 $matching_rules = [];
179 include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseMappingRule.php';
180 foreach(ilECSCourseMappingRule::getRuleRefIds($this->getServer()->getServerId(), $this->getMid()) as $ref_id)
181 {
182 $matching_index = ilECSCourseMappingRule::isMatching(
183 $course,
184 $this->getServer()->getServerId(),
185 $this->getMid(),
186 $ref_id);
187 if(strcmp($matching_index, '0') !== 0)
188 {
189 $matching_rules[$matching_index] = $ref_id;
190 }
191 }
192 ksort($matching_rules);
193
194 $this->log->dump($matching_rules);
195
196 if(!count($matching_rules))
197 {
198 // Put course in default category
199 $this->log->debug('No matching attribute mapping rule found.');
200 $this->log->info('Using course default category');
201 $this->doSync($a_content_id,$course,ilObject::_lookupObjId($this->getMapping()->getDefaultCourseCategory()));
202 return true;
203 }
204
205 $this->log->debug('Matching rules:');
206 $this->log->dump($matching_rules, ilLogLevel::DEBUG);
207
208 $all_parent_refs = [];
209 foreach($matching_rules as $matching_rule)
210 {
211 $this->log->debug('Handling matching rule: '. $matching_rule);
212 $parent_refs = ilECSCourseMappingRule::doMappings($course,$this->getServer()->getServerId(),$this->getMid(),$matching_rule);
213 // map according mapping rules
214 $this->log->debug('Adding parent references: ');
215 $this->log->dump($parent_refs);
216
217 if(count($parent_refs))
218 {
219 $all_parent_refs = array_unique(array_merge($all_parent_refs,$parent_refs));
220 }
221 }
222
223 // parent refs are an array of created categories
224 // the first ref should contain the main course or parallel courses.
225 // all other refs wil contain course references.
226 $first = true;
227 foreach($all_parent_refs as $category_ref)
228 {
229 if($first)
230 {
231 $this->log->debug('Creating new course instance in: ' . $category_ref);
232 $this->doSync($a_content_id, $course, ilObject::_lookupObjId($category_ref));
233 $first = false;
234 continue;
235 }
236 else
237 {
238 $this->log->debug('Creating new course reference instance in: ' . $category_ref);
239 $this->createCourseReferenceObjects($category_ref);
240 }
241 }
242 return true;
243 }
createCourseReferenceObjects($a_parent_ref_id)
Create course reference objects.
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(), createCourseReferenceObjects(), ilLogLevel\DEBUG, 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
Returns
array created course reference references

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

396 {
397 // Check if course is already created
398 $course_id = $course->lectureID;
399 $this->getCourseUrl()->setCmsLectureId($course_id);
400
401 $obj_id = $this->getImportId($course_id);
402
403 $this->log->debug('Found obj_id '.$obj_id. ' for course_id '. $course_id );
404
405 // Handle parallel groups
406 if($obj_id)
407 {
408 // update multiple courses/groups according to parallel scenario
409 $this->log->debug('Group scenario '.$course->groupScenario);
410 include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
411 switch((int) $course->groupScenario)
412 {
414 $this->log->debug('Performing update for parallel groups in course.');
415 $this->updateParallelGroups($a_content_id,$course, $obj_id);
416 break;
417
419 $this->log->debug('Performing update for parallel courses.');
420 $this->updateParallelCourses($a_content_id,$course, $a_parent_obj_id);
421 break;
422
424 default:
425 // nothing to do
426 break;
427
428 }
429
430 // do update
431 $this->updateCourseData($course,$obj_id);
432 }
433 else
434 {
435 include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
436 switch((int) $course->groupScenario)
437 {
439 $this->log->debug('Parallel scenario "groups in courses".');
440 $crs = $this->createCourseData($course);
441 $crs = $this->createCourseReference($crs, $a_parent_obj_id);
442 $this->setImported($course_id, $crs, $a_content_id);
443
444 // Create parallel groups under crs
445 $this->createParallelGroups($a_content_id,$course,$crs->getRefId());
446 break;
447
449 $this->log->debug('Parallel scenario "Courses foreach Lecturer".');
450 // Import empty to store the ecs ressource id (used for course member update).
451 $this->setImported($course_id,NULL,$a_content_id);
452 break;
453
455 $this->log->debug('Parallel scenario "Many courses".');
456 $refs = ilObject::_getAllReferences($a_parent_obj_id);
457 $ref = end($refs);
458 // do not create master course for this scenario
459 //$crs = $this->createCourseData($course);
460 //$this->createCourseReference($crs, $a_parent_obj_id);
461 //$this->setImported($course_id, $crs, $a_content_id);
462 $this->createParallelCourses($a_content_id,$course, $ref);
463 break;
464
465 default:
467 $this->log->debug('Parallel scenario "One Course".');
468 $crs = $this->createCourseData($course);
469 $this->createCourseReference($crs, $a_parent_obj_id);
470 $this->setImported($course_id, $crs, $a_content_id);
471 break;
472
473
474 }
475 }
476 // finally update course urls
477 $this->handleCourseUrlUpdate();
478 return true;
479 }
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 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 70 of file class.ilECSCourseCreationHandler.php.

References $course_url.

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

+ Here is the caller graph for this function:

◆ getCreatedCourses()

ilECSCourseCreationHandler::getCreatedCourses ( )
protected

get created courses

Returns
array

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

References $courses_created.

Referenced by createCourseReferenceObjects().

+ 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 649 of file class.ilECSCourseCreationHandler.php.

650 {
651 include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
653 $this->getServer()->getServerId(),
654 $this->getMid(),
655 $a_content_id,
656 $a_sub_id
657 );
658 }
static lookupObjIdByContentId($a_server_id, $a_mid, $a_content_id, $a_sub_id=null)
Lookup obj_id by content id.

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

Referenced by createParallelCourse(), 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 61 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 106 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 52 of file class.ilECSCourseCreationHandler.php.

53 {
54 return $this->server;
55 }

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 116 of file class.ilECSCourseCreationHandler.php.

117 {
118 // prepare course url
119 // if any object (course group) will be created, a list of all course urls
120 // will be sent to ecs.
121 $this->setObjectCreated(false);
122 $this->getCourseUrl()->setECSId($a_content_id);
123
124
125 if($this->getMapping()->isAttributeMappingEnabled())
126 {
127 $this->log->debug('Handling advanced attribute mapping');
128 return $this->doAttributeMapping($a_content_id,$course);
129 }
130
131 if($this->getMapping()->isAllInOneCategoryEnabled())
132 {
133 $this->log->debug('Handling course all in one category setting');
134 $this->doSync($a_content_id, $course,ilObject::_lookupObjId($this->getMapping()->getAllInOneCategory()));
135 return true;
136 }
137
138 $parent_obj_id = $this->syncParentContainer($a_content_id,$course);
139 if($parent_obj_id)
140 {
141 $this->log->info('Using already mapped category: '. ilObject::_lookupTitle($parent_obj_id));
142 $this->doSync($a_content_id,$course,$parent_obj_id);
143 return true;
144 }
145 $this->log->info('Using course default category');
146 $this->doSync($a_content_id,$course,ilObject::_lookupObjId($this->getMapping()->getDefaultCourseCategory()));
147 return true;
148 }
doAttributeMapping($a_content_id, $course)
Sync attribute mapping.
syncParentContainer($a_content_id, $course)
Sync parent container.

References 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 772 of file class.ilECSCourseCreationHandler.php.

773 {
774 $GLOBALS['ilLog']->write(__METHOD__.': Starting course url update');
775 if($this->isObjectCreated())
776 {
777 $GLOBALS['ilLog']->write(__METHOD__.': Sending new course group url');
778 $this->getCourseUrl()->send($this->getServer(), $this->getMid());
779 }
780 else
781 {
782 $GLOBALS['ilLog']->write(__METHOD__.': No courses groups created. Aborting');
783 }
784 }
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 79 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 = null 
)
protected

Set new course object imported.

Parameters
int$a_content_id
ilObjCourse$crs

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

730 {
731 include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
732 $import = new ilECSImport(
733 $this->getServer()->getServerId(),
734 is_object($object) ? $object->getId() : 0
735 );
736
737
738 $import->setSubId($a_sub_id);
739 $import->setMID($this->getMid());
740 $import->setEContentId($a_ecs_id);
741 $import->setContentId($a_content_id);
742 $import->setImported(true);
743 $import->save();
744 return true;
745 }
Storage of ECS imported objects.

References 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 88 of file class.ilECSCourseCreationHandler.php.

89 {
90 $this->object_created = $a_status;
91 }

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 355 of file class.ilECSCourseCreationHandler.php.

356 {
357 include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
358 $data = new ilECSCmsData($tobj_id);
359
360 include_once './Modules/Category/classes/class.ilObjCategory.php';
361 $cat = new ilObjCategory();
362 $cat->setOwner(SYSTEM_USER_ID);
363 $cat->setTitle($data->getTitle());
364 $cat->create(); // true for upload
365 $cat->createReference();
366 $cat->putInTree($parent_ref_id);
367 $cat->setPermissions($parent_ref_id);
368 $cat->deleteTranslation($GLOBALS['lng']->getDefaultLanguage());
369 $cat->addTranslation(
370 $data->getTitle(),
371 $cat->getLongDescription(),
372 $GLOBALS['lng']->getDefaultLanguage(),
373 1
374 );
375
376 // set imported
377 $import = new ilECSImport(
378 $this->getServer()->getServerId(),
379 $cat->getId()
380 );
381 $import->setMID($this->getMid());
382 $import->setContentId($data->getCmsId());
383 $import->setImported(true);
384 $import->save();
385
386 return $cat->getId();
387 }
Class ilObjCategory.

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 299 of file class.ilECSCourseCreationHandler.php.

300 {
301 $obj_id = $this->getImportId($cms_id);
302 if($obj_id)
303 {
304 // node already imported
305 return $obj_id;
306 }
307
308 $tobj_id = ilECSCmsData::lookupObjId(
309 $this->getServer()->getServerId(),
310 $this->getMid(),
311 $tree_id,
312 $cms_id);
313
314 // node is not imported
315 $GLOBALS['ilLog']->write(__METHOD__.': ecs node with id '. $cms_id. ' is not imported for mid ' . $this->getMid().' tree_id '.$tree_id);
316
317 // check for mapping: if mapping is available create category
318 include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignment.php';
320 $this->getServer()->getServerId(),
321 $this->getMid(),
322 $tree_id,
323 $tobj_id);
324
325 if($ass->isMapped())
326 {
327 $GLOBALS['ilLog']->write(__METHOD__.': node is mapped');
328 return $this->syncCategory($tobj_id,$ass->getRefId());
329 }
330
331 // Start recursion to top
332 include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
333 $tree = new ilECSCmsTree($tree_id);
334 $parent_tobj_id = $tree->getParentId($tobj_id);
335 if($parent_tobj_id)
336 {
337 $cms_ids = ilECSCmsData::lookupCmsIds(array($parent_tobj_id));
338 $obj_id = $this->syncNodeToTop($tree_id, $cms_ids[0]);
339 }
340
341 if($obj_id)
342 {
343 $refs = ilObject::_getAllReferences($obj_id);
344 $ref_id = end($refs);
345 return $this->syncCategory($tobj_id, $ref_id);
346 }
347 return 0;
348 }
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 274 of file class.ilECSCourseCreationHandler.php.

275 {
276 if(!is_array($course->allocations))
277 {
278 $GLOBALS['ilLog']->write(__METHOD__.': No allocation in course defined.');
279 return 0;
280 }
281 if(!$course->allocations[0]->parentID)
282 {
283 $GLOBALS['ilLog']->write(__METHOD__.': No allocation parent in course defined.');
284 return 0;
285 }
286 $parent_id = $course->allocations[0]->parentID;
287
288 include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
289 $parent_tid = ilECSCmsData::lookupFirstTreeOfNode($this->getServer()->getServerId(), $this->getMid(), $parent_id);
290 return $this->syncNodetoTop($parent_tid, $parent_id);
291 }
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 664 of file class.ilECSCourseCreationHandler.php.

665 {
666 // do update
667 $refs = ilObject::_getAllReferences($obj_id);
668 $ref_id = end($refs);
670 if(!$crs_obj instanceof ilObject)
671 {
672 $GLOBALS['ilLog']->write(__METHOD__.': Cannot instantiate course instance');
673 return true;
674 }
675
676 // Update title
677 $title = $course->title;
678 $GLOBALS['ilLog']->write(__METHOD__.': new title is : '. $title);
679
680 $crs_obj->setTitle($title);
681 $crs_obj->update();
682 return true;
683 }
static 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, $title, 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 534 of file class.ilECSCourseCreationHandler.php.

535 {
536 $parent_refs = ilObject::_getAllReferences($parent_obj);
537 $parent_ref = end($parent_refs);
538
539 foreach((array) $course->groups as $group)
540 {
541 $title = $course->title;
542 if(strlen($group->title))
543 {
544 $title .= ' ('.$group->title.')';
545 }
546
547 $obj_id = $this->getImportId($course->lectureID, $group->id);
548 $this->log->debug('Imported obj id is ' .$obj_id);
549 if(!$obj_id)
550 {
551 $this->createParallelCourse($a_content_id, $course, $group, $parent_ref);
552 }
553 else
554 {
555 $course_obj = ilObjectFactory::getInstanceByObjId($obj_id,false);
556 if($course_obj instanceof ilObjCourse)
557 {
558 $this->log->debug('New title is '. $title);
559 $course_obj->setTitle($title);
560 $course_obj->setSubscriptionMaxMembers($group->maxParticipants);
561 $course_obj->update();
562 }
563 }
564 $this->addUrlEntry($this->getImportId($course->lectureID, $group->ID));
565 }
566 return true;
567 }
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id

References $title, 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 613 of file class.ilECSCourseCreationHandler.php.

614 {
615 $parent_refs = ilObject::_getAllReferences($parent_obj);
616 $parent_ref = end($parent_refs);
617
618 foreach((array) $course->groups as $group)
619 {
620 $obj_id = $this->getImportId($course->lectureID, $group->id);
621 $this->log->debug('Imported obj id is ' .$obj_id);
622 if(!$obj_id)
623 {
624 $this->createParallelGroup($a_content_id,$course, $group, $parent_ref);
625 }
626 else
627 {
628 $group_obj = ilObjectFactory::getInstanceByObjId($obj_id,false);
629 if($group_obj instanceof ilObjGroup)
630 {
631 $title = strlen($group->title) ? $group->title : $course->title;
632 $GLOBALS['ilLog']->write(__METHOD__.': New title is '. $title);
633 $group_obj->setTitle($title);
634 $group_obj->setMaxMembers((int) $group->maxParticipants);
635 $group_obj->update();
636 }
637 }
638 $this->addUrlEntry($this->getImportId($course->lectureID, $group->id));
639 }
640 }

References $GLOBALS, $title, 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 24 of file class.ilECSCourseCreationHandler.php.

Referenced by getCourseUrl().

◆ $courses_created

ilECSCourseCreationHandler::$courses_created = array()
private

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

Referenced by getCreatedCourses().

◆ $log

ilECSCourseCreationHandler::$log
protected

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

◆ $mapping

ilECSCourseCreationHandler::$mapping = null
private

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

Referenced by getMapping().

◆ $mid

ilECSCourseCreationHandler::$mid
private

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

Referenced by getMid().

◆ $object_created

ilECSCourseCreationHandler::$object_created = false
private

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

Referenced by isObjectCreated().

◆ $server

ilECSCourseCreationHandler::$server = null
private

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

Referenced by __construct(), and getServer().


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