ILIAS  release_7 Revision v7.30-3-g800a261c036
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 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Represents a ecs course url.
static getInstanceByServerMid($a_server_id, $a_mid)
Get instance.

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

716 {
717 $refs = ilObject::_getAllReferences($a_obj_id);
718 $ref_id = end($refs);
719
720 if (!$ref_id) {
721 return false;
722 }
723 include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseLmsUrl.php';
724 $lms_url = new ilECSCourseLmsUrl();
725 $lms_url->setTitle(ilObject::_lookupTitle($a_obj_id));
726
727 include_once './Services/Link/classes/class.ilLink.php';
728 $lms_url->setUrl(ilLink::_getLink($ref_id));
729 $this->getCourseUrl()->addLmsCourseUrls($lms_url);
730 }
Represents a ecs course lms url.
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object

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

653 {
654 include_once './Modules/Course/classes/class.ilObjCourse.php';
655 $course_obj = new ilObjCourse();
656 $course_obj->setOwner(SYSTEM_USER_ID);
657 $title = $course->title;
658 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Creating new course instance from ecs : ' . $title);
659 $course_obj->setTitle($title);
660 $course_obj->setOfflineStatus(true);
661 $course_obj->create();
662 return $course_obj;
663 }
Class ilObjCourse.
const SYSTEM_USER_ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: constants.php:24

References $GLOBALS, and SYSTEM_USER_ID.

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

672 {
673 $ref_ids = ilObject::_getAllReferences($a_parent_obj_id);
674 $ref_id = end($ref_ids);
675
676 $crs->createReference();
677 $crs->putInTree($ref_id);
678 $crs->setPermissions($ref_id);
679
680 $this->setObjectCreated(true);
681 $this->addUrlEntry($crs->getId());
682
683 $this->courses_created[] = $crs->getRefId();
684
685 return $crs;
686 }
setObjectCreated($a_status)
Set object created status.

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

238 {
239 foreach ($this->getCreatedCourses() as $ref_id) {
240 include_once './Modules/CourseReference/classes/class.ilObjCourseReference.php';
241 $crsr = new ilObjCourseReference();
242 $crsr->setOwner(SYSTEM_USER_ID);
243 $crsr->setTargetRefId($ref_id);
244 $crsr->setTargetId(ilObject::_lookupObjId($ref_id));
245 $crsr->create();
246 $crsr->update();
247 $crsr->createReference();
248 $crsr->putInTree($a_parent_ref_id);
249 $crsr->setPermissions($a_parent_ref_id);
250
251 $this->log->debug('Created new course reference in : ' . ilObject::_lookupTitle(ilObject::_lookupObjId($a_parent_ref_id)));
252 $this->log->debug('Created new course reference for : ' . ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)));
253 }
254 }
static _lookupObjId($a_id)

References ilObject\_lookupObjId(), ilObject\_lookupTitle(), getCreatedCourses(), and SYSTEM_USER_ID.

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

480 {
481 if ($this->getImportId($course->lectureID, $group->id)) {
482 $this->log->debug('Parallel course already created');
483 return false;
484 }
485
486 include_once './Modules/Course/classes/class.ilObjCourse.php';
487 $course_obj = new ilObjCourse();
488 $course_obj->setOwner(SYSTEM_USER_ID);
489 $title = $course->title;
490 if (strlen($group->title)) {
491 $title .= ' (' . $group->title . ')';
492 }
493 $this->log->debug('Creating new parallel course instance from ecs : ' . $title);
494 $course_obj->setTitle($title);
495 $course_obj->setSubscriptionMaxMembers((int) $group->maxParticipants);
496 $course_obj->setOfflineStatus(true);
497 $course_obj->create();
498
499 $this->createCourseReference($course_obj, ilObject::_lookupObjId($parent_ref));
500 $this->setImported($course->lectureID, $course_obj, $a_content_id, $group->id);
501 $this->setObjectCreated(true);
502 return true;
503 }
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 ilObject\_lookupObjId(), createCourseReference(), getImportId(), setImported(), setObjectCreated(), and SYSTEM_USER_ID.

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

466 {
467 foreach ((array) $course->groups as $group) {
468 $this->createParallelCourse($a_content_id, $course, $group, $parent_ref);
469 }
470 return true;
471 }
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 559 of file class.ilECSCourseCreationHandler.php.

560 {
561 include_once './Modules/Group/classes/class.ilObjGroup.php';
562 $group_obj = new ilObjGroup();
563 $group_obj->setOwner(SYSTEM_USER_ID);
564 $title = strlen($group->title) ? $group->title : $course->title;
565 $group_obj->setTitle($title);
566 $group_obj->setMaxMembers((int) $group->maxParticipants);
567 $group_obj->create();
568 $group_obj->createReference();
569 $group_obj->putInTree($parent_ref);
570 $group_obj->setPermissions($parent_ref);
571 $group_obj->updateGroupType(GRP_TYPE_CLOSED);
572 $this->setImported($course->lectureID, $group_obj, $a_content_id, $group->id);
573 $this->setObjectCreated(true);
574 }
const GRP_TYPE_CLOSED
Class ilObjGroup.

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

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

547 {
548 foreach ((array) $course->groups as $group) {
549 $this->createParallelGroup($a_content_id, $course, $group, $parent_ref);
550 }
551 return true;
552 }
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 152 of file class.ilECSCourseCreationHandler.php.

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

379 {
380 // Check if course is already created
381 $course_id = $course->lectureID;
382 $this->getCourseUrl()->setCmsLectureId($course_id);
383
384 $obj_id = $this->getImportId($course_id);
385
386 $this->log->debug('Found obj_id ' . $obj_id . ' for course_id ' . $course_id);
387
388 // Handle parallel groups
389 if ($obj_id) {
390 // update multiple courses/groups according to parallel scenario
391 $this->log->debug('Group scenario ' . $course->groupScenario);
392 include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
393 switch ((int) $course->groupScenario) {
395 $this->log->debug('Performing update for parallel groups in course.');
396 $this->updateParallelGroups($a_content_id, $course, $obj_id);
397 break;
398
400 $this->log->debug('Performing update for parallel courses.');
401 $this->updateParallelCourses($a_content_id, $course, $a_parent_obj_id);
402 break;
403
405 default:
406 // nothing to do
407 break;
408
409 }
410
411 // do update
412 $this->updateCourseData($course, $obj_id);
413 } else {
414 include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
415 switch ((int) $course->groupScenario) {
417 $this->log->debug('Parallel scenario "groups in courses".');
418 $crs = $this->createCourseData($course);
419 $crs = $this->createCourseReference($crs, $a_parent_obj_id);
420 $this->setImported($course_id, $crs, $a_content_id);
421
422 // Create parallel groups under crs
423 $this->createParallelGroups($a_content_id, $course, $crs->getRefId());
424 break;
425
427 $this->log->debug('Parallel scenario "Courses foreach Lecturer".');
428 // Import empty to store the ecs ressource id (used for course member update).
429 $this->setImported($course_id, null, $a_content_id);
430 break;
431
433 $this->log->debug('Parallel scenario "Many courses".');
434 $refs = ilObject::_getAllReferences($a_parent_obj_id);
435 $ref = end($refs);
436 // do not create master course for this scenario
437 //$crs = $this->createCourseData($course);
438 //$this->createCourseReference($crs, $a_parent_obj_id);
439 //$this->setImported($course_id, $crs, $a_content_id);
440 $this->createParallelCourses($a_content_id, $course, $ref);
441 break;
442
443 default:
445 $this->log->debug('Parallel scenario "One Course".');
446 $crs = $this->createCourseData($course);
447 $this->createCourseReference($crs, $a_parent_obj_id);
448 $this->setImported($course_id, $crs, $a_content_id);
449 break;
450
451
452 }
453 }
454 // finally update course urls
455 $this->handleCourseUrlUpdate();
456 return true;
457 }
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 613 of file class.ilECSCourseCreationHandler.php.

614 {
615 include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
617 $this->getServer()->getServerId(),
618 $this->getMid(),
619 $a_content_id,
620 $a_sub_id
621 );
622 }
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 $this->log->debug('Handling advanced attribute mapping');
127 return $this->doAttributeMapping($a_content_id, $course);
128 }
129
130 if ($this->getMapping()->isAllInOneCategoryEnabled()) {
131 $this->log->debug('Handling course all in one category setting');
132 $this->doSync($a_content_id, $course, ilObject::_lookupObjId($this->getMapping()->getAllInOneCategory()));
133 return true;
134 }
135
136 $parent_obj_id = $this->syncParentContainer($a_content_id, $course);
137 if ($parent_obj_id) {
138 $this->log->info('Using already mapped category: ' . ilObject::_lookupTitle($parent_obj_id));
139 $this->doSync($a_content_id, $course, $parent_obj_id);
140 return true;
141 }
142 $this->log->info('Using course default category');
143 $this->doSync($a_content_id, $course, ilObject::_lookupObjId($this->getMapping()->getDefaultCourseCategory()));
144 return true;
145 }
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 735 of file class.ilECSCourseCreationHandler.php.

736 {
737 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Starting course url update');
738 if ($this->isObjectCreated()) {
739 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Sending new course group url');
740 $this->getCourseUrl()->send($this->getServer(), $this->getMid());
741 } else {
742 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': No courses groups created. Aborting');
743 }
744 }
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 693 of file class.ilECSCourseCreationHandler.php.

694 {
695 include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
696 $import = new ilECSImport(
697 $this->getServer()->getServerId(),
698 is_object($object) ? $object->getId() : 0
699 );
700
701
702 $import->setSubId($a_sub_id);
703 $import->setMID($this->getMid());
704 $import->setEContentId($a_ecs_id);
705 $import->setContentId($a_content_id);
706 $import->setImported(true);
707 $import->save();
708 return true;
709 }
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 338 of file class.ilECSCourseCreationHandler.php.

339 {
340 include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
341 $data = new ilECSCmsData($tobj_id);
342
343 include_once './Modules/Category/classes/class.ilObjCategory.php';
344 $cat = new ilObjCategory();
345 $cat->setOwner(SYSTEM_USER_ID);
346 $cat->setTitle($data->getTitle());
347 $cat->create(); // true for upload
348 $cat->createReference();
349 $cat->putInTree($parent_ref_id);
350 $cat->setPermissions($parent_ref_id);
351 $cat->deleteTranslation($GLOBALS['DIC']['lng']->getDefaultLanguage());
352 $cat->addTranslation(
353 $data->getTitle(),
354 $cat->getLongDescription(),
355 $GLOBALS['DIC']['lng']->getDefaultLanguage(),
356 1
357 );
358
359 // set imported
360 $import = new ilECSImport(
361 $this->getServer()->getServerId(),
362 $cat->getId()
363 );
364 $import->setMID($this->getMid());
365 $import->setContentId($data->getCmsId());
366 $import->setImported(true);
367 $import->save();
368
369 return $cat->getId();
370 }
Class ilObjCategory.
$data
Definition: storeScorm.php:23

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

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

285 {
286 $obj_id = $this->getImportId($cms_id);
287 if ($obj_id) {
288 // node already imported
289 return $obj_id;
290 }
291
292 $tobj_id = ilECSCmsData::lookupObjId(
293 $this->getServer()->getServerId(),
294 $this->getMid(),
295 $tree_id,
296 $cms_id
297 );
298
299 // node is not imported
300 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': ecs node with id ' . $cms_id . ' is not imported for mid ' . $this->getMid() . ' tree_id ' . $tree_id);
301
302 // check for mapping: if mapping is available create category
303 include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignment.php';
305 $this->getServer()->getServerId(),
306 $this->getMid(),
307 $tree_id,
308 $tobj_id
309 );
310
311 if ($ass->isMapped()) {
312 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': node is mapped');
313 return $this->syncCategory($tobj_id, $ass->getRefId());
314 }
315
316 // Start recursion to top
317 include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
318 $tree = new ilECSCmsTree($tree_id);
319 $parent_tobj_id = $tree->getParentId($tobj_id);
320 if ($parent_tobj_id) {
321 $cms_ids = ilECSCmsData::lookupCmsIds(array($parent_tobj_id));
322 $obj_id = $this->syncNodeToTop($tree_id, $cms_ids[0]);
323 }
324
325 if ($obj_id) {
326 $refs = ilObject::_getAllReferences($obj_id);
327 $ref_id = end($refs);
328 return $this->syncCategory($tobj_id, $ref_id);
329 }
330 return 0;
331 }
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, 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 261 of file class.ilECSCourseCreationHandler.php.

262 {
263 if (!is_array($course->allocations)) {
264 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': No allocation in course defined.');
265 return 0;
266 }
267 if (!$course->allocations[0]->parentID) {
268 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': No allocation parent in course defined.');
269 return 0;
270 }
271 $parent_id = $course->allocations[0]->parentID;
272
273 include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
274 $parent_tid = ilECSCmsData::lookupFirstTreeOfNode($this->getServer()->getServerId(), $this->getMid(), $parent_id);
275 return $this->syncNodetoTop($parent_tid, $parent_id);
276 }
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 628 of file class.ilECSCourseCreationHandler.php.

629 {
630 // do update
631 $refs = ilObject::_getAllReferences($obj_id);
632 $ref_id = end($refs);
633 $crs_obj = ilObjectFactory::getInstanceByRefId($ref_id, false);
634 if (!$crs_obj instanceof ilObject) {
635 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Cannot instantiate course instance');
636 return true;
637 }
638
639 // Update title
640 $title = $course->title;
641 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': new title is : ' . $title);
642
643 $crs_obj->setTitle($title);
644 $crs_obj->update();
645 return true;
646 }
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, 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 510 of file class.ilECSCourseCreationHandler.php.

511 {
512 $parent_refs = ilObject::_getAllReferences($parent_obj);
513 $parent_ref = end($parent_refs);
514
515 foreach ((array) $course->groups as $group) {
516 $title = $course->title;
517 if (strlen($group->title)) {
518 $title .= ' (' . $group->title . ')';
519 }
520
521 $obj_id = $this->getImportId($course->lectureID, $group->id);
522 $this->log->debug('Imported obj id is ' . $obj_id);
523 if (!$obj_id) {
524 $this->createParallelCourse($a_content_id, $course, $group, $parent_ref);
525 } else {
526 $course_obj = ilObjectFactory::getInstanceByObjId($obj_id, false);
527 if ($course_obj instanceof ilObjCourse) {
528 $this->log->debug('New title is ' . $title);
529 $course_obj->setTitle($title);
530 $course_obj->setSubscriptionMaxMembers($group->maxParticipants);
531 $course_obj->update();
532 }
533 }
534 $this->addUrlEntry($this->getImportId($course->lectureID, $group->ID));
535 }
536 return true;
537 }
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id

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

583 {
584 $parent_refs = ilObject::_getAllReferences($parent_obj);
585 $parent_ref = end($parent_refs);
586
587 foreach ((array) $course->groups as $group) {
588 $obj_id = $this->getImportId($course->lectureID, $group->id);
589 $this->log->debug('Imported obj id is ' . $obj_id);
590 if (!$obj_id) {
591 $this->createParallelGroup($a_content_id, $course, $group, $parent_ref);
592 } else {
593 $group_obj = ilObjectFactory::getInstanceByObjId($obj_id, false);
594 if ($group_obj instanceof ilObjGroup) {
595 $title = strlen($group->title) ? $group->title : $course->title;
596 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': New title is ' . $title);
597 $group_obj->setTitle($title);
598 $group_obj->setMaxMembers((int) $group->maxParticipants);
599 $group_obj->update();
600 }
601 }
602 $this->addUrlEntry($this->getImportId($course->lectureID, $group->id));
603 }
604 }

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 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: