3 include_once
'./Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingSettings.php';
4 include_once
'./Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
5 include_once
'./Services/WebServices/ECS/classes/class.ilECSParticipantSettings.php';
37 $this->log =
$GLOBALS[
'DIC']->logger()->wsrv();
43 include_once
'./Services/WebServices/ECS/classes/Course/class.ilECSCourseUrl.php';
90 $this->object_created = $a_status;
116 public function handle($a_content_id,$course)
125 if($this->
getMapping()->isAttributeMappingEnabled())
127 $this->log->debug(
'Handling advanced attribute mapping');
131 if($this->
getMapping()->isAllInOneCategoryEnabled())
133 $this->log->debug(
'Handling course all in one category setting');
142 $this->
doSync($a_content_id,$course,$parent_obj_id);
145 $this->log->info(
'Using course default category');
158 $course_id = $course->lectureID;
164 $this->log->debug(
'Performing update of already imported course.');
178 $matching_rules = [];
179 include_once
'./Services/WebServices/ECS/classes/Course/class.ilECSCourseMappingRule.php';
187 if(strcmp($matching_index,
'0') !== 0)
189 $matching_rules[$matching_index] =
$ref_id;
192 ksort($matching_rules);
194 $this->log->dump($matching_rules);
196 if(!count($matching_rules))
199 $this->log->debug(
'No matching attribute mapping rule found.');
200 $this->log->info(
'Using course default category');
205 $this->log->debug(
'Matching rules:');
208 $all_parent_refs = [];
209 foreach($matching_rules as $matching_rule)
211 $this->log->debug(
'Handling matching rule: '. $matching_rule);
214 $this->log->debug(
'Adding parent references: ');
215 $this->log->dump($parent_refs);
217 if(count($parent_refs))
219 $all_parent_refs = array_unique(array_merge($all_parent_refs,$parent_refs));
227 foreach($all_parent_refs as $category_ref)
231 $this->log->debug(
'Creating new course instance in: ' . $category_ref);
238 $this->log->debug(
'Creating new course reference instance in: ' . $category_ref);
253 include_once
'./Modules/CourseReference/classes/class.ilObjCourseReference.php';
255 $crsr->setOwner(SYTEM_USER_ID);
256 $crsr->setTargetRefId($ref_id);
260 $crsr->createReference();
261 $crsr->putInTree($a_parent_ref_id);
262 $crsr->setPermissions($a_parent_ref_id);
276 if(!is_array($course->allocations))
278 $GLOBALS[
'ilLog']->write(__METHOD__.
': No allocation in course defined.');
281 if(!$course->allocations[0]->parentID)
283 $GLOBALS[
'ilLog']->write(__METHOD__.
': No allocation parent in course defined.');
286 $parent_id = $course->allocations[0]->parentID;
288 include_once
'./Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
290 return $this->syncNodetoTop($parent_tid, $parent_id);
315 $GLOBALS[
'ilLog']->write(__METHOD__.
': ecs node with id '. $cms_id.
' is not imported for mid ' . $this->getMid().
' tree_id '.$tree_id);
318 include_once
'./Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignment.php';
327 $GLOBALS[
'ilLog']->write(__METHOD__.
': node is mapped');
332 include_once
'./Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
334 $parent_tobj_id = $tree->getParentId($tobj_id);
357 include_once
'./Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
360 include_once
'./Modules/Category/classes/class.ilObjCategory.php';
362 $cat->setOwner(SYSTEM_USER_ID);
363 $cat->setTitle(
$data->getTitle());
365 $cat->createReference();
366 $cat->putInTree($parent_ref_id);
367 $cat->setPermissions($parent_ref_id);
368 $cat->deleteTranslation(
$GLOBALS[
'lng']->getDefaultLanguage());
369 $cat->addTranslation(
371 $cat->getLongDescription(),
372 $GLOBALS[
'lng']->getDefaultLanguage(),
382 $import->setContentId(
$data->getCmsId());
383 $import->setImported(
true);
386 return $cat->getId();
395 protected function doSync($a_content_id, $course, $a_parent_obj_id)
398 $course_id = $course->lectureID;
403 $this->log->debug(
'Found obj_id '.$obj_id.
' for course_id '. $course_id );
409 $this->log->debug(
'Group scenario '.$course->groupScenario);
410 include_once
'./Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
411 switch((
int) $course->groupScenario)
414 $this->log->debug(
'Performing update for parallel groups in course.');
419 $this->log->debug(
'Performing update for parallel courses.');
435 include_once
'./Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
436 switch((
int) $course->groupScenario)
439 $this->log->debug(
'Parallel scenario "groups in courses".');
442 $this->
setImported($course_id, $crs, $a_content_id);
449 $this->log->debug(
'Parallel scenario "Courses foreach Lecturer".');
455 $this->log->debug(
'Parallel scenario "Many courses".');
467 $this->log->debug(
'Parallel scenario "One Course".');
470 $this->
setImported($course_id, $crs, $a_content_id);
489 foreach((
array) $course->groups as $group)
504 if($this->
getImportId($course->lectureID, $group->id))
506 $this->log->debug(
'Parallel course already created');
510 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
512 $course_obj->setOwner(SYSTEM_USER_ID);
514 if(strlen($group->title))
516 $title .=
' ('.$group->title.
')';
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();
524 $this->
setImported($course->lectureID, $course_obj,$a_content_id, $group->id);
537 $parent_ref = end($parent_refs);
539 foreach((
array) $course->groups as $group)
542 if(strlen($group->title))
544 $title .=
' ('.$group->title.
')';
547 $obj_id = $this->
getImportId($course->lectureID, $group->id);
548 $this->log->debug(
'Imported obj id is ' .$obj_id);
558 $this->log->debug(
'New title is '.
$title);
559 $course_obj->setTitle(
$title);
560 $course_obj->setSubscriptionMaxMembers($group->maxParticipants);
561 $course_obj->update();
578 foreach((
array) $course->groups as $group)
592 include_once
'./Modules/Group/classes/class.ilObjGroup.php';
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);
603 $this->
setImported($course->lectureID, $group_obj, $a_content_id, $group->id);
616 $parent_ref = end($parent_refs);
618 foreach((
array) $course->groups as $group)
620 $obj_id = $this->
getImportId($course->lectureID, $group->id);
621 $this->log->debug(
'Imported obj id is ' .$obj_id);
631 $title = strlen($group->title) ? $group->title : $course->title;
633 $group_obj->setTitle(
$title);
634 $group_obj->setMaxMembers((
int) $group->maxParticipants);
635 $group_obj->update();
651 include_once
'./Services/WebServices/ECS/classes/class.ilECSImport.php';
672 $GLOBALS[
'ilLog']->write(__METHOD__.
': Cannot instantiate course instance');
680 $crs_obj->setTitle(
$title);
691 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
693 $course_obj->setOwner(SYSTEM_USER_ID);
695 $GLOBALS[
'ilLog']->write(__METHOD__.
': Creating new course instance from ecs : '.
$title);
696 $course_obj->setTitle(
$title);
697 $course_obj->create();
712 $crs->createReference();
719 $this->courses_created[] = $crs->getRefId();
729 protected function setImported($a_content_id, $object, $a_ecs_id = 0, $a_sub_id = null)
731 include_once
'./Services/WebServices/ECS/classes/class.ilECSImport.php';
734 is_object($object) ? $object->getId() : 0
739 $import->setMID($this->
getMid());
740 $import->setEContentId($a_ecs_id);
741 $import->setContentId($a_content_id);
742 $import->setImported(
true);
760 include_once
'./Services/WebServices/ECS/classes/Course/class.ilECSCourseLmsUrl.php';
764 include_once
'./Services/Link/classes/class.ilLink.php';
774 $GLOBALS[
'ilLog']->write(__METHOD__.
': Starting course url update');
777 $GLOBALS[
'ilLog']->write(__METHOD__.
': Sending new course group url');
782 $GLOBALS[
'ilLog']->write(__METHOD__.
': No courses groups created. Aborting');
addUrlEntry($a_obj_id)
Add an url entry.
updateParallelCourses($a_content_id, $course, $parent_obj)
Update parallel group data.
syncNodeToTop($tree_id, $cms_id)
Sync node to top.
static doMappings($course, $a_sid, $a_mid, $a_ref_id)
static lookupObjId($a_server_id, $a_mid, $a_tree_id, $cms_id)
getCourseUrl()
Get course url.
static isMatching($course, $a_sid, $a_mid, $a_ref_id)
Check if rule matches.
handleCourseUrlUpdate()
Update course url.
Class ilObject Basic functions for all objects.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
createParallelCourses($a_content_id, $course, $parent_ref)
Create parallel courses.
syncCategory($tobj_id, $parent_ref_id)
Sync category.
static getInstanceByServerMid($a_server_id, $a_mid)
Get instance.
static _lookupTitle($a_id)
lookup object title
const PARALLEL_ONE_COURSE
static lookupObjIdByContentId($a_server_id, $a_mid, $a_content_id, $a_sub_id=null)
Lookup obj_id by content id.
static _getAllReferences($a_id)
get all reference ids of object
__construct(ilECSSetting $server, $a_mid)
Constructor
static lookupFirstTreeOfNode($a_server_id, $a_mid, $cms_id)
Lookup first obj_id of cms node $ilDB $ilDB.
createParallelCourse($a_content_id, $course, $group, $parent_ref)
Create parallel course.
createParallelGroup($a_content_id, $course, $group, $parent_ref)
Create parallel group.
createCourseReference($crs, $a_parent_obj_id)
Create course reference.
static _lookupObjId($a_id)
static lookupCmsIds($a_obj_ids)
setObjectCreated($a_status)
Set object created status.
Represents a ecs course lms url.
updateParallelGroups($a_content_id, $course, $parent_obj)
Update parallel group data.
Storage of ECS imported objects.
const PARALLEL_COURSES_FOR_LECTURERS
doAttributeMapping($a_content_id, $course)
Sync attribute mapping.
getCreatedCourses()
get created courses
static getRuleRefIds($a_sid, $a_mid)
handle($a_content_id, $course)
Handle sync request.
getMid()
Get mid of course event.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
createCourseReferenceObjects($a_parent_ref_id)
Create course reference objects.
Create styles array
The data for the language used.
const PARALLEL_ALL_COURSES
isObjectCreated()
Check if an object (course / group) has been created.
Represents a ecs course url.
setImported($a_content_id, $object, $a_ecs_id=0, $a_sub_id=null)
Set new course object imported.
doSync($a_content_id, $course, $a_parent_obj_id)
Handle all in one setting.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
updateCourseData($course, $obj_id)
Update course data.
const PARALLEL_GROUPS_IN_COURSE
createParallelGroups($a_content_id, $course, $parent_ref)
This create parallel groups.
createCourseData($course)
Create course data from json.
getImportId($a_content_id, $a_sub_id=NULL)
Get import id of remote course Return 0 if object isn't imported.
syncParentContainer($a_content_id, $course)
Sync parent container.
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")
getMapping()
Get mapping settings.
getServer()
Get server settings.