ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ilECSCourseCreationHandler Class Reference
+ Collaboration diagram for ilECSCourseCreationHandler:

Public Member Functions

 __construct (ilECSSetting $server, int $a_mid)
 
 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 (bool $a_status)
 Set object created status. More...
 
 getMid ()
 Get mid of course event. More...
 
 handle (int $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 (int $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, int $parent_obj)
 Update parallel group data. More...
 
 getImportId (int $a_content_id, ?string $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 (ilObjCourse $crs, int $a_parent_obj_id)
 Create course reference. More...
 
 setImported (int $a_content_id, $object, $a_ecs_id=0, $a_sub_id=null)
 Set new course object imported. More...
 
 addUrlEntry (int $a_obj_id)
 Add an url entry. More...
 
 handleCourseUrlUpdate ()
 Update course url. More...
 

Private Attributes

ilLogger $logger
 
ilLanguage $lng
 
ilTree $tree
 
ilECSSetting $server
 
ilECSNodeMappingSettings $mapping
 
ilECSCourseUrl $course_url = null
 
bool $object_created = false
 
array $courses_created = array()
 
int $mid
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

References $DIC, $server, ilECSNodeMappingSettings\getInstanceByServerMid(), getMid(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), and ILIAS\UI\examples\Progress\Bar\server().

40  {
41  global $DIC;
42 
43  $this->logger = $DIC->logger()->wsrv();
44  $this->lng = $DIC->language();
45  $this->tree = $DIC->repositoryTree();
46 
47  $this->server = $server;
48  $this->mid = $a_mid;
49  $this->mapping = ilECSNodeMappingSettings::getInstanceByServerMid($this->server->getServerId(), $this->getMid());
50 
51  $this->course_url = new ilECSCourseUrl();
52  }
static getInstanceByServerMid(int $a_server_id, int $a_mid)
Get instance.
server()
description: > This example shows how a Progress Bar can be rendered and updated by the server...
Definition: server.php:43
global $DIC
Definition: shib_login.php:26
Represents a ecs course url.
+ Here is the call graph for this function:

Member Function Documentation

◆ addUrlEntry()

ilECSCourseCreationHandler::addUrlEntry ( int  $a_obj_id)
protected

Add an url entry.

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

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

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

676  : bool
677  {
678  $refs = ilObject::_getAllReferences($a_obj_id);
679  $ref_id = end($refs);
680 
681  if (!$ref_id) {
682  return false;
683  }
684  $lms_url = new ilECSCourseLmsUrl();
685  $lms_url->setTitle(ilObject::_lookupTitle($a_obj_id));
686 
687  $lms_url->setUrl(ilLink::_getLink($ref_id));
688  $this->course_url->addLmsCourseUrls($lms_url);
689  return true;
690  }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:65
static _lookupTitle(int $obj_id)
Represents a ecs course lms url.
+ 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.

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

References ILIAS\Repository\logger(), and SYSTEM_USER_ID.

Referenced by doSync().

621  : \ilObjCourse
622  {
623  $course_obj = new ilObjCourse();
624  $course_obj->setOwner(SYSTEM_USER_ID);
625  $title = $course->title;
626  $this->logger->debug('Creating new course instance from ecs : ' . $title);
627  $course_obj->setTitle($title);
628  $course_obj->setOfflineStatus(true);
629  $course_obj->create();
630  return $course_obj;
631  }
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
Definition: constants.php:26
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createCourseReference()

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

Create course reference.

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

References $ref_id, ilObject\_getAllReferences(), addUrlEntry(), ilObject\createReference(), ilObject\getId(), ilObject\getRefId(), ilContainer\putInTree(), setObjectCreated(), and ilObject\setPermissions().

Referenced by createParallelCourse(), and doSync().

636  : \ilObjCourse
637  {
638  $ref_ids = ilObject::_getAllReferences($a_parent_obj_id);
639  $ref_id = end($ref_ids);
640 
641  $crs->createReference();
642  $crs->putInTree($ref_id);
643  $crs->setPermissions($ref_id);
644 
645  $this->setObjectCreated(true);
646  $this->addUrlEntry($crs->getId());
647 
648  $this->courses_created[] = $crs->getRefId();
649 
650  return $crs;
651  }
static _getAllReferences(int $id)
get all reference ids for object ID
putInTree(int $parent_ref_id)
setPermissions(int $parent_ref_id)
createReference()
creates reference for object
$ref_id
Definition: ltiauth.php:65
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setObjectCreated(bool $a_status)
Set object created status.
addUrlEntry(int $a_obj_id)
Add an url entry.
+ 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.

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

References $ref_id, ilObject\_lookupObjId(), ilObject\_lookupTitle(), getCreatedCourses(), ILIAS\Repository\logger(), and SYSTEM_USER_ID.

Referenced by doAttributeMapping().

236  : void
237  {
238  $this->logger->debug('Created new course reference in : ' . ilObject::_lookupTitle(ilObject::_lookupObjId($a_parent_ref_id)));
239  foreach ($this->getCreatedCourses() as $ref_id) {
240  $crsr = new ilObjCourseReference();
241  $crsr->setOwner(SYSTEM_USER_ID);
242  $crsr->setTargetRefId($ref_id);
243  $crsr->setTargetId(ilObject::_lookupObjId($ref_id));
244  $crsr->create();
245  $crsr->update();
246  $crsr->createReference();
247  $crsr->putInTree($a_parent_ref_id);
248  $crsr->setPermissions($a_parent_ref_id);
249 
250  $this->logger->debug('Created new course reference for : ' . ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)));
251  }
252  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
Definition: constants.php:26
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:65
static _lookupTitle(int $obj_id)
+ 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.

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

References ilObject\_lookupObjId(), createCourseReference(), getImportId(), ILIAS\Repository\logger(), setImported(), setObjectCreated(), and SYSTEM_USER_ID.

Referenced by createParallelCourses(), and updateParallelCourses().

455  : bool
456  {
457  if ($this->getImportId((int) $course->lectureID, (string) $group->id)) {
458  $this->logger->debug('Parallel course already created');
459  return false;
460  }
461 
462  $course_obj = new ilObjCourse();
463  $course_obj->setOwner(SYSTEM_USER_ID);
464  $title = $course->title;
465  if (property_exists($group, 'title') && $group->title !== '') {
466  $title .= ' (' . $group->title . ')';
467  }
468  $this->logger->debug('Creating new parallel course instance from ecs : ' . $title);
469  $course_obj->setTitle($title);
470  if (property_exists($group, 'maxParticipants')) {
471  $course_obj->setSubscriptionMaxMembers((int) $group->maxParticipants);
472  }
473  $course_obj->setOfflineStatus(true);
474  $course_obj->create();
475 
476  $this->createCourseReference($course_obj, ilObject::_lookupObjId($parent_ref));
477  $this->setImported((int) $course->lectureID, $course_obj, $a_content_id, $group->id);
478  $this->setObjectCreated(true);
479  return true;
480  }
getImportId(int $a_content_id, ?string $a_sub_id=null)
Get import id of remote course Return 0 if object isn't imported.
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
Definition: constants.php:26
static _lookupObjId(int $ref_id)
setObjectCreated(bool $a_status)
Set object created status.
createCourseReference(ilObjCourse $crs, int $a_parent_obj_id)
Create course reference.
setImported(int $a_content_id, $object, $a_ecs_id=0, $a_sub_id=null)
Set new course object imported.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createParallelCourses()

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

Create parallel courses.

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

References createParallelCourse().

Referenced by doSync().

444  : bool
445  {
446  foreach ((array) $course->groups as $group) {
447  $this->createParallelCourse($a_content_id, $course, $group, $parent_ref);
448  }
449  return true;
450  }
createParallelCourse($a_content_id, $course, $group, $parent_ref)
Create parallel course.
+ 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.

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

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

Referenced by createParallelGroups(), and updateParallelGroups().

532  : void
533  {
534  $group_obj = new ilObjGroup();
535  $group_obj->setOwner(SYSTEM_USER_ID);
536  $title = (property_exists($group, 'title') && $group->title !== '') ? $group->title : $course->title;
537  $group_obj->setTitle($title);
538  if (property_exists($group, 'maxParticipants')) {
539  $group_obj->setMaxMembers((int) $group->maxParticipants);
540  }
541  $group_obj->create();
542  $group_obj->createReference();
543  $group_obj->putInTree($parent_ref);
544  $group_obj->setPermissions($parent_ref);
545  $group_obj->updateGroupType(ilGroupConstants::GRP_TYPE_CLOSED);
546  $this->setImported((int) $course->lectureID, $group_obj, $a_content_id, $group->id);
547  $this->setObjectCreated(true);
548  }
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
Definition: constants.php:26
setObjectCreated(bool $a_status)
Set object created status.
Class ilObjGroup.
setImported(int $a_content_id, $object, $a_ecs_id=0, $a_sub_id=null)
Set new course object imported.
+ 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.

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

References createParallelGroup().

Referenced by doSync().

521  : bool
522  {
523  foreach ((array) $course->groups as $group) {
524  $this->createParallelGroup($a_content_id, $course, $group, $parent_ref);
525  }
526  return true;
527  }
createParallelGroup($a_content_id, $course, $group, $parent_ref)
Create parallel group.
+ 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.

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

References $ref_id, ilObject\_getAllReferences(), ilObject\_lookupObjId(), createCourseReferenceObjects(), ilLogLevel\DEBUG, ilECSCourseMappingRule\doMappings(), doSync(), getImportId(), getMapping(), getMid(), ilECSCourseMappingRule\getRuleRefIds(), getServer(), ilECSCourseMappingRule\isMatching(), and ILIAS\Repository\logger().

Referenced by handle().

151  : bool
152  {
153  // Check if course is already created
154  $course_id = $course->lectureID;
155  $obj_id = $this->getImportId((int) $course_id);
156 
157  if ($obj_id) {
158  // do update
159  $this->logger->debug('Performing update of already imported course.');
160 
161  $refs = ilObject::_getAllReferences($obj_id);
162  $ref = end($refs);
163 
164  $this->doSync(
165  $a_content_id,
166  $course,
167  ilObject::_lookupObjId($this->tree->getParentId($ref))
168  );
169  return true;
170  }
171 
172  // Get all rules
173  $matching_rules = [];
174  foreach (ilECSCourseMappingRule::getRuleRefIds($this->getServer()->getServerId(), $this->getMid()) as $ref_id) {
175  $matching_index = ilECSCourseMappingRule::isMatching(
176  $course,
177  $this->getServer()->getServerId(),
178  $this->getMid(),
179  $ref_id
180  );
181  if (strcmp($matching_index, '0') !== 0) {
182  $matching_rules[$matching_index] = $ref_id;
183  }
184  }
185  ksort($matching_rules);
186 
187  $this->logger->dump($matching_rules);
188 
189  if (!count($matching_rules)) {
190  // Put course in default category
191  $this->logger->debug('No matching attribute mapping rule found.');
192  $this->logger->info('Using course default category');
193  $this->doSync($a_content_id, $course, ilObject::_lookupObjId($this->getMapping()->getDefaultCourseCategory()));
194  return true;
195  }
196 
197  $this->logger->debug('Matching rules:');
198  $this->logger->dump($matching_rules, ilLogLevel::DEBUG);
199 
200  $all_parent_refs = [];
201  foreach ($matching_rules as $matching_rule) {
202  $this->logger->debug('Handling matching rule: ' . $matching_rule);
203  $parent_refs = ilECSCourseMappingRule::doMappings(
204  $course,
205  $this->getServer()->getServerId(),
206  $this->getMid(),
207  $matching_rule
208  );
209  // map according mapping rules
210  $this->logger->debug('Adding parent references: ' . print_r($parent_refs, true));
211  if (count($parent_refs)) {
212  $all_parent_refs = array_unique(array_merge($all_parent_refs, $parent_refs));
213  }
214  }
215 
216  // parent refs are an array of created categories
217  // the first ref should contain the main course or parallel courses.
218  // all other refs wil contain course references.
219  $first = true;
220  foreach ($all_parent_refs as $category_ref) {
221  if ($first) {
222  $this->logger->debug('Creating new course instance in: ' . $category_ref);
223  $this->doSync($a_content_id, $course, ilObject::_lookupObjId((int) $category_ref));
224  $first = false;
225  continue;
226  }
227  $this->logger->debug('Creating new course reference instance in: ' . $category_ref);
228  $this->createCourseReferenceObjects($category_ref);
229  }
230  return true;
231  }
static isMatching($course, $a_sid, $a_mid, $a_ref_id)
Check if rule matches.
getImportId(int $a_content_id, ?string $a_sub_id=null)
Get import id of remote course Return 0 if object isn't imported.
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:65
static getRuleRefIds(int $a_sid, int $a_mid)
createCourseReferenceObjects($a_parent_ref_id)
Create course reference objects.
static doMappings($course, int $a_sid, int $a_mid, int $a_ref_id)
doSync($a_content_id, $course, $a_parent_obj_id)
Handle all in one setting.
+ 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.

Returns
bool created course reference references TODO fix

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

References ilObject\_getAllReferences(), createCourseData(), createCourseReference(), createParallelCourses(), createParallelGroups(), getImportId(), handleCourseUrlUpdate(), ILIAS\Repository\logger(), null, 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().

364  : bool
365  {
366  // Check if course is already created
367  $course_id = $course->lectureID;
368  $this->course_url->setCmsLectureId((string) $course_id);
369 
370  $obj_id = $this->getImportId((int) $course_id);
371 
372  $this->logger->debug('Found obj_id ' . $obj_id . ' for course_id ' . $course_id);
373 
374  // Handle parallel groups
375  if ($obj_id) {
376  // update multiple courses/groups according to parallel scenario
377  if (property_exists($course, 'groupScenario')) {
378  $this->logger->debug('Group scenario ' . $course->groupScenario);
379  switch ((int) $course->groupScenario) {
381  $this->logger->debug('Performing update for parallel groups in course.');
382  $this->updateParallelGroups($a_content_id, $course, $obj_id);
383  break;
384 
386  $this->logger->debug('Performing update for parallel courses.');
387  $this->updateParallelCourses($a_content_id, $course, $a_parent_obj_id);
388  break;
389 
391  default:
392  // nothing to do
393  break;
394  }
395  }
396  // do update
397  $this->updateCourseData($course, $obj_id);
398  } else {
399  switch ((int) $course->groupScenario) {
401  $this->logger->debug('Parallel scenario "groups in courses".');
402  $crs = $this->createCourseData($course);
403  $crs = $this->createCourseReference($crs, $a_parent_obj_id);
404  $this->setImported((int) $course_id, $crs, $a_content_id);
405 
406  // Create parallel groups under crs
407  $this->createParallelGroups($a_content_id, $course, $crs->getRefId());
408  break;
409 
411  $this->logger->debug('Parallel scenario "Courses foreach Lecturer".');
412  // Import empty to store the ecs ressource id (used for course member update).
413  $this->setImported((int) $course_id, null, $a_content_id);
414  break;
415 
417  $this->logger->debug('Parallel scenario "Many courses".');
418  $refs = ilObject::_getAllReferences($a_parent_obj_id);
419  $ref = end($refs);
420  // do not create master course for this scenario
421  //$crs = $this->createCourseData($course);
422  //$this->createCourseReference($crs, $a_parent_obj_id);
423  //$this->setImported($course_id, $crs, $a_content_id);
424  $this->createParallelCourses($a_content_id, $course, $ref);
425  break;
426 
427  default:
429  $this->logger->debug('Parallel scenario "One Course".');
430  $crs = $this->createCourseData($course);
431  $this->createCourseReference($crs, $a_parent_obj_id);
432  $this->setImported((int) $course_id, $crs, $a_content_id);
433  break;
434  }
435  }
436  // finally update course urls
437  $this->handleCourseUrlUpdate();
438  return true;
439  }
updateParallelCourses($a_content_id, $course, $parent_obj)
Update parallel group data.
getImportId(int $a_content_id, ?string $a_sub_id=null)
Get import id of remote course Return 0 if object isn't imported.
static _getAllReferences(int $id)
get all reference ids for object ID
updateParallelGroups($a_content_id, $course, int $parent_obj)
Update parallel group data.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
createCourseReference(ilObjCourse $crs, int $a_parent_obj_id)
Create course reference.
updateCourseData($course, $obj_id)
Update course data.
createParallelCourses(int $a_content_id, $course, $parent_ref)
Create parallel courses.
createParallelGroups($a_content_id, $course, $parent_ref)
This create parallel groups.
createCourseData($course)
Create course data from json.
setImported(int $a_content_id, $object, $a_ecs_id=0, $a_sub_id=null)
Set new course object imported.
+ 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 76 of file class.ilECSCourseCreationHandler.php.

References $course_url.

77  {
78  return $this->course_url;
79  }
Represents a ecs course url.

◆ getCreatedCourses()

ilECSCourseCreationHandler::getCreatedCourses ( )
protected

get created courses

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

References $courses_created.

Referenced by createCourseReferenceObjects().

100  : array
101  {
102  return $this->courses_created;
103  }
+ Here is the caller graph for this function:

◆ getImportId()

ilECSCourseCreationHandler::getImportId ( int  $a_content_id,
?string  $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

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

References ilECSImportManager\getInstance(), getMid(), and getServer().

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

585  : int
586  {
587  return ilECSImportManager::getInstance()->lookupObjIdByContentId(
588  $this->getServer()->getServerId(),
589  $this->getMid(),
590  $a_content_id,
591  $a_sub_id
592  );
593  }
static getInstance()
Get the singleton instance of this ilECSImportManager.
+ 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 67 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.

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

References $mid.

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

108  : int
109  {
110  return $this->mid;
111  }
+ Here is the caller graph for this function:

◆ getServer()

ilECSCourseCreationHandler::getServer ( )

Get server settings.

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

References $server.

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

+ Here is the caller graph for this function:

◆ handle()

ilECSCourseCreationHandler::handle ( int  $a_content_id,
  $course 
)

Handle sync request.

Parameters
int$a_content_idecs content id

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

References ilObject\_lookupObjId(), ilObject\_lookupTitle(), doAttributeMapping(), doSync(), getMapping(), ILIAS\Repository\logger(), setObjectCreated(), and syncParentContainer().

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

◆ handleCourseUrlUpdate()

ilECSCourseCreationHandler::handleCourseUrlUpdate ( )
protected

Update course url.

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

References getMid(), getServer(), isObjectCreated(), and ILIAS\Repository\logger().

Referenced by doSync().

695  : void
696  {
697  $this->logger->debug('Starting course url update');
698  if ($this->isObjectCreated()) {
699  $this->logger->debug('Sending new course group url');
700  $this->course_url->send($this->getServer(), $this->getMid());
701  } else {
702  $this->logger->debug('No courses groups created. Aborting');
703  }
704  }
isObjectCreated()
Check if an object (course / group) has been created.
+ 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.

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

References $object_created.

Referenced by handleCourseUrlUpdate().

84  : bool
85  {
86  return $this->object_created;
87  }
+ Here is the caller graph for this function:

◆ setImported()

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

Set new course object imported.

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

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

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

656  : bool
657  {
658  $import = new ilECSImport(
659  $this->getServer()->getServerId(),
660  is_object($object) ? $object->getId() : 0
661  );
662 
663 
664  $import->setSubId((string) $a_sub_id);
665  $import->setMID($this->getMid());
666  $import->setEContentId((string) $a_ecs_id);
667  $import->setContentId((string) $a_content_id);
668  $import->setImported(true);
669  $import->save();
670  return true;
671  }
Storage of ECS imported objects.
setSubId(string $a_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setObjectCreated()

ilECSCourseCreationHandler::setObjectCreated ( bool  $a_status)

Set object created status.

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

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

92  : void
93  {
94  $this->object_created = $a_status;
95  }
+ Here is the caller graph for this function:

◆ syncCategory()

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

Sync category.

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

References $data, getMid(), getServer(), ILIAS\Repository\lng(), ilECSImport\setMID(), and SYSTEM_USER_ID.

Referenced by syncNodeToTop().

327  : int
328  {
329  $data = new ilECSCmsData($tobj_id);
330 
331  $cat = new ilObjCategory();
332  $cat->setOwner(SYSTEM_USER_ID);
333  $cat->setTitle($data->getTitle());
334  $cat->create(); // true for upload
335  $cat->createReference();
336  $cat->putInTree($parent_ref_id);
337  $cat->setPermissions($parent_ref_id);
338  $cat->deleteTranslation($this->lng->getDefaultLanguage());
339  $cat->addTranslation(
340  $data->getTitle(),
341  $cat->getLongDescription(),
342  $this->lng->getDefaultLanguage(),
343  $this->lng->getDefaultLanguage()
344  );
345 
346  // set imported
347  $import = new ilECSImport(
348  $this->getServer()->getServerId(),
349  $cat->getId()
350  );
351  $import->setMID($this->getMid());
352  $import->setContentId($data->getCmsId());
353  $import->setImported(true);
354  $import->save();
355 
356  return $cat->getId();
357  }
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
Definition: constants.php:26
Storage of ECS imported objects.
Class ilObjCategory.
setMID($a_mid)
set mid
+ 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.

Returns
int obj_id of container

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

References $ref_id, ilObject\_getAllReferences(), getImportId(), getMid(), getServer(), ILIAS\Repository\logger(), ilECSCmsData\lookupCmsIds(), ilECSCmsData\lookupObjId(), and syncCategory().

277  : int
278  {
279  $obj_id = $this->getImportId($cms_id);
280  if ($obj_id) {
281  // node already imported
282  return $obj_id;
283  }
284 
285  $tobj_id = ilECSCmsData::lookupObjId(
286  $this->getServer()->getServerId(),
287  $this->getMid(),
288  $tree_id,
289  $cms_id
290  );
291 
292  // node is not imported
293  $this->logger->debug('ecs node with id ' . $cms_id . ' is not imported for mid ' . $this->getMid() . ' tree_id ' . $tree_id);
294 
295  // check for mapping: if mapping is available create category
296  $ass = new ilECSNodeMappingAssignment(
297  $this->getServer()->getServerId(),
298  $this->getMid(),
299  $tree_id,
300  $tobj_id
301  );
302 
303  if ($ass->isMapped()) {
304  $this->logger->debug('node is mapped');
305  return $this->syncCategory($tobj_id, $ass->getRefId());
306  }
307 
308  // Start recursion to top
309  $tree = new ilECSCmsTree($tree_id);
310  $parent_tobj_id = $tree->getParentId($tobj_id);
311  if ($parent_tobj_id) {
312  $cms_ids = ilECSCmsData::lookupCmsIds(array($parent_tobj_id));
313  $obj_id = $this->syncNodeToTop($tree_id, $cms_ids[0]);
314  }
315 
316  if ($obj_id) {
317  $refs = ilObject::_getAllReferences($obj_id);
318  $ref_id = end($refs);
319  return $this->syncCategory($tobj_id, $ref_id);
320  }
321  return 0;
322  }
syncNodeToTop($tree_id, $cms_id)
Sync node to top.
getImportId(int $a_content_id, ?string $a_sub_id=null)
Get import id of remote course Return 0 if object isn't imported.
static _getAllReferences(int $id)
get all reference ids for object ID
syncCategory($tobj_id, $parent_ref_id)
Sync category.
static lookupObjId(int $a_server_id, int $a_mid, int $a_tree_id, string $cms_id)
$ref_id
Definition: ltiauth.php:65
static lookupCmsIds(array $a_obj_ids)
+ Here is the call graph for this function:

◆ syncParentContainer()

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

Sync parent container.

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

References getMid(), getServer(), ILIAS\Repository\logger(), and ilECSCmsData\lookupFirstTreeOfNode().

Referenced by handle().

257  : int
258  {
259  if (!property_exists($course, 'allocations') || !is_array($course->allocations)) {
260  $this->logger->debug('No allocation in course defined.');
261  return 0;
262  }
263  if (!$course->allocations[0]->parentID) {
264  $this->logger->debug('No allocation parent in course defined.');
265  return 0;
266  }
267  $parent_id = $course->allocations[0]->parentID;
268 
269  $parent_tid = ilECSCmsData::lookupFirstTreeOfNode($this->getServer()->getServerId(), $this->getMid(), $parent_id);
270  return $this->syncNodetoTop($parent_tid, $parent_id);
271  }
static lookupFirstTreeOfNode($a_server_id, $a_mid, $cms_id)
Lookup first obj_id of cms node.
+ 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.

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

References $ref_id, ilObject\_getAllReferences(), ilObjectFactory\getInstanceByRefId(), and ILIAS\Repository\logger().

Referenced by doSync().

598  : bool
599  {
600  // do update
601  $refs = ilObject::_getAllReferences($obj_id);
602  $ref_id = end($refs);
603  $crs_obj = ilObjectFactory::getInstanceByRefId($ref_id, false);
604  if (!$crs_obj instanceof ilObject) {
605  $this->logger->debug('Cannot instantiate course instance');
606  return true;
607  }
608 
609  // Update title
610  $title = $course->title;
611  $this->logger->debug('new title is : ' . $title);
612 
613  $crs_obj->setTitle($title);
614  $crs_obj->update();
615  return true;
616  }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:65
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
+ 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.

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

References ilObject\_getAllReferences(), addUrlEntry(), createParallelCourse(), getImportId(), ilObjectFactory\getInstanceByObjId(), and ILIAS\Repository\logger().

Referenced by doSync().

485  : bool
486  {
487  $parent_refs = ilObject::_getAllReferences($parent_obj);
488  $parent_ref = end($parent_refs);
489 
490  foreach ((array) $course->groups as $group) {
491  $title = $course->title;
492  if ($group->title !== '') {
493  $title .= ' (' . $group->title . ')';
494  }
495 
496  $obj_id = $this->getImportId((int) $course->lectureID, (string) $group->id);
497  $this->logger->debug('Imported obj id is ' . $obj_id);
498  if (!$obj_id) {
499  $this->createParallelCourse($a_content_id, $course, $group, $parent_ref);
500  } else {
501  $course_obj = ilObjectFactory::getInstanceByObjId($obj_id, false);
502  if ($course_obj instanceof ilObjCourse) {
503  $this->logger->debug('New title is ' . $title);
504  $course_obj->setTitle($title);
505  if (property_exists($group, 'maxParticipants') && !is_null($group->maxParticipants)) {
506  $course_obj->setSubscriptionMaxMembers($group->maxParticipants);
507  }
508  $course_obj->update();
509  }
510  }
511  $this->addUrlEntry($this->getImportId((int) $course->lectureID, (string) $group->id));
512  }
513  return true;
514  }
getImportId(int $a_content_id, ?string $a_sub_id=null)
Get import id of remote course Return 0 if object isn't imported.
static _getAllReferences(int $id)
get all reference ids for object ID
createParallelCourse($a_content_id, $course, $group, $parent_ref)
Create parallel course.
addUrlEntry(int $a_obj_id)
Add an url entry.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateParallelGroups()

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

Update parallel group data.

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

References ilObject\_getAllReferences(), addUrlEntry(), createParallelGroup(), getImportId(), ilObjectFactory\getInstanceByObjId(), and ILIAS\Repository\logger().

Referenced by doSync().

554  : void
555  {
556  $parent_refs = ilObject::_getAllReferences($parent_obj);
557  $parent_ref = end($parent_refs);
558 
559  foreach ((array) $course->groups as $group) {
560  $obj_id = $this->getImportId((int) $course->lectureID, (string) $group->id);
561  $this->logger->debug('Imported obj id is ' . $obj_id);
562  if (!$obj_id) {
563  $this->createParallelGroup($a_content_id, $course, $group, $parent_ref);
564  } else {
565  $group_obj = ilObjectFactory::getInstanceByObjId($obj_id, false);
566  if ($group_obj instanceof ilObjGroup) {
567  $title = $group->title !== '' ? $group->title : $course->title;
568  $this->logger->debug('New title is ' . $title);
569  $group_obj->setTitle($title);
570  if (property_exists($group, 'maxParticipants') && !is_null($group->maxParticipants)) {
571  $group_obj->setMaxMembers((int) $group->maxParticipants);
572  }
573  $group_obj->update();
574  }
575  }
576  $this->addUrlEntry($this->getImportId((int) $course->lectureID, (string) $group->id));
577  }
578  }
getImportId(int $a_content_id, ?string $a_sub_id=null)
Get import id of remote course Return 0 if object isn't imported.
static _getAllReferences(int $id)
get all reference ids for object ID
createParallelGroup($a_content_id, $course, $group, $parent_ref)
Create parallel group.
addUrlEntry(int $a_obj_id)
Add an url entry.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjGroup.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $course_url

ilECSCourseUrl ilECSCourseCreationHandler::$course_url = null
private

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

Referenced by getCourseUrl().

◆ $courses_created

array ilECSCourseCreationHandler::$courses_created = array()
private

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

Referenced by getCreatedCourses().

◆ $lng

ilLanguage ilECSCourseCreationHandler::$lng
private

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

◆ $logger

ilLogger ilECSCourseCreationHandler::$logger
private

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

◆ $mapping

ilECSNodeMappingSettings ilECSCourseCreationHandler::$mapping
private

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

Referenced by getMapping().

◆ $mid

int ilECSCourseCreationHandler::$mid
private

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

Referenced by getMid().

◆ $object_created

bool ilECSCourseCreationHandler::$object_created = false
private

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

Referenced by isObjectCreated().

◆ $server

ilECSSetting ilECSCourseCreationHandler::$server
private

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

Referenced by __construct(), and getServer().

◆ $tree

ilTree ilECSCourseCreationHandler::$tree
private

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


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