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()) {
126 $this->log->debug(
'Handling advanced attribute mapping');
130 if ($this->
getMapping()->isAllInOneCategoryEnabled()) {
131 $this->log->debug(
'Handling course all in one category setting');
137 if ($parent_obj_id) {
139 $this->
doSync($a_content_id, $course, $parent_obj_id);
142 $this->log->info(
'Using course default category');
155 $course_id = $course->lectureID;
160 $this->log->debug(
'Performing update of already imported course.');
174 $matching_rules = [];
175 include_once
'./Services/WebServices/ECS/classes/Course/class.ilECSCourseMappingRule.php';
183 if (strcmp($matching_index,
'0') !== 0) {
184 $matching_rules[$matching_index] = $ref_id;
187 ksort($matching_rules);
189 $this->log->dump($matching_rules);
191 if (!count($matching_rules)) {
193 $this->log->debug(
'No matching attribute mapping rule found.');
194 $this->log->info(
'Using course default category');
199 $this->log->debug(
'Matching rules:');
202 $all_parent_refs = [];
203 foreach ($matching_rules as $matching_rule) {
204 $this->log->debug(
'Handling matching rule: ' . $matching_rule);
207 $this->log->debug(
'Adding parent references: ');
208 $this->log->dump($parent_refs);
210 if (count($parent_refs)) {
211 $all_parent_refs = array_unique(array_merge($all_parent_refs, $parent_refs));
219 foreach ($all_parent_refs as $category_ref) {
221 $this->log->debug(
'Creating new course instance in: ' . $category_ref);
226 $this->log->debug(
'Creating new course reference instance in: ' . $category_ref);
240 include_once
'./Modules/CourseReference/classes/class.ilObjCourseReference.php';
242 $crsr->setOwner(SYTEM_USER_ID);
243 $crsr->setTargetRefId($ref_id);
247 $crsr->createReference();
248 $crsr->putInTree($a_parent_ref_id);
249 $crsr->setPermissions($a_parent_ref_id);
263 if (!is_array($course->allocations)) {
264 $GLOBALS[
'ilLog']->write(__METHOD__ .
': No allocation in course defined.');
267 if (!$course->allocations[0]->parentID) {
268 $GLOBALS[
'ilLog']->write(__METHOD__ .
': No allocation parent in course defined.');
271 $parent_id = $course->allocations[0]->parentID;
273 include_once
'./Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
275 return $this->syncNodetoTop($parent_tid, $parent_id);
300 $GLOBALS[
'ilLog']->write(__METHOD__ .
': ecs node with id ' . $cms_id .
' is not imported for mid ' . $this->
getMid() .
' tree_id ' . $tree_id);
303 include_once
'./Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignment.php';
311 if ($ass->isMapped()) {
312 $GLOBALS[
'ilLog']->write(__METHOD__ .
': node is mapped');
317 include_once
'./Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
319 $parent_tobj_id = $tree->getParentId($tobj_id);
320 if ($parent_tobj_id) {
327 $ref_id = end($refs);
340 include_once
'./Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
343 include_once
'./Modules/Category/classes/class.ilObjCategory.php';
345 $cat->setOwner(SYSTEM_USER_ID);
346 $cat->setTitle(
$data->getTitle());
348 $cat->createReference();
349 $cat->putInTree($parent_ref_id);
350 $cat->setPermissions($parent_ref_id);
351 $cat->deleteTranslation(
$GLOBALS[
'lng']->getDefaultLanguage());
352 $cat->addTranslation(
354 $cat->getLongDescription(),
355 $GLOBALS[
'lng']->getDefaultLanguage(),
365 $import->setContentId(
$data->getCmsId());
366 $import->setImported(
true);
369 return $cat->getId();
378 protected function doSync($a_content_id, $course, $a_parent_obj_id)
381 $course_id = $course->lectureID;
386 $this->log->debug(
'Found obj_id ' . $obj_id .
' for course_id ' . $course_id);
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.');
400 $this->log->debug(
'Performing update for parallel courses.');
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".');
420 $this->
setImported($course_id, $crs, $a_content_id);
427 $this->log->debug(
'Parallel scenario "Courses foreach Lecturer".');
429 $this->
setImported($course_id, null, $a_content_id);
433 $this->log->debug(
'Parallel scenario "Many courses".');
445 $this->log->debug(
'Parallel scenario "One Course".');
448 $this->
setImported($course_id, $crs, $a_content_id);
467 foreach ((
array) $course->groups as $group) {
481 if ($this->
getImportId($course->lectureID, $group->id)) {
482 $this->log->debug(
'Parallel course already created');
486 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
488 $course_obj->setOwner(SYSTEM_USER_ID);
490 if (strlen($group->title)) {
491 $title .=
' (' . $group->title .
')';
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->create();
499 $this->
setImported($course->lectureID, $course_obj, $a_content_id, $group->id);
512 $parent_ref = end($parent_refs);
514 foreach ((
array) $course->groups as $group) {
516 if (strlen($group->title)) {
517 $title .=
' (' . $group->title .
')';
520 $obj_id = $this->
getImportId($course->lectureID, $group->id);
521 $this->log->debug(
'Imported obj id is ' . $obj_id);
527 $this->log->debug(
'New title is ' .
$title);
528 $course_obj->setTitle(
$title);
529 $course_obj->setSubscriptionMaxMembers($group->maxParticipants);
530 $course_obj->update();
547 foreach ((
array) $course->groups as $group) {
560 include_once
'./Modules/Group/classes/class.ilObjGroup.php';
562 $group_obj->setOwner(SYSTEM_USER_ID);
563 $title = strlen($group->title) ? $group->title : $course->title;
564 $group_obj->setTitle(
$title);
565 $group_obj->setMaxMembers((
int) $group->maxParticipants);
566 $group_obj->create();
567 $group_obj->createReference();
568 $group_obj->putInTree($parent_ref);
569 $group_obj->setPermissions($parent_ref);
571 $this->
setImported($course->lectureID, $group_obj, $a_content_id, $group->id);
584 $parent_ref = end($parent_refs);
586 foreach ((
array) $course->groups as $group) {
587 $obj_id = $this->
getImportId($course->lectureID, $group->id);
588 $this->log->debug(
'Imported obj id is ' . $obj_id);
594 $title = strlen($group->title) ? $group->title : $course->title;
595 $GLOBALS[
'ilLog']->write(__METHOD__ .
': New title is ' .
$title);
596 $group_obj->setTitle($title);
597 $group_obj->setMaxMembers((
int) $group->maxParticipants);
598 $group_obj->update();
614 include_once
'./Services/WebServices/ECS/classes/class.ilECSImport.php';
631 $ref_id = end($refs);
633 if (!$crs_obj instanceof
ilObject) {
634 $GLOBALS[
'ilLog']->write(__METHOD__ .
': Cannot instantiate course instance');
640 $GLOBALS[
'ilLog']->write(__METHOD__ .
': new title is : ' .
$title);
642 $crs_obj->setTitle($title);
653 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
655 $course_obj->setOwner(SYSTEM_USER_ID);
657 $GLOBALS[
'ilLog']->write(__METHOD__ .
': Creating new course instance from ecs : ' .
$title);
658 $course_obj->setTitle($title);
659 $course_obj->create();
672 $ref_id = end($ref_ids);
674 $crs->createReference();
675 $crs->putInTree($ref_id);
676 $crs->setPermissions($ref_id);
681 $this->courses_created[] = $crs->getRefId();
691 protected function setImported($a_content_id, $object, $a_ecs_id = 0, $a_sub_id = null)
693 include_once
'./Services/WebServices/ECS/classes/class.ilECSImport.php';
696 is_object($object) ? $object->getId() : 0
701 $import->setMID($this->
getMid());
702 $import->setEContentId($a_ecs_id);
703 $import->setContentId($a_content_id);
704 $import->setImported(
true);
716 $ref_id = end($refs);
721 include_once
'./Services/WebServices/ECS/classes/Course/class.ilECSCourseLmsUrl.php';
725 include_once
'./Services/Link/classes/class.ilLink.php';
735 $GLOBALS[
'ilLog']->write(__METHOD__ .
': Starting course url update');
737 $GLOBALS[
'ilLog']->write(__METHOD__ .
': Sending new course group url');
740 $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.
$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
getImportId($a_content_id, $a_sub_id=null)
Get import id of remote course Return 0 if object isn't imported.
__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.
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.