ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 (int $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 38 of file class.ilECSCourseCreationHandler.php.

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

39  {
40  global $DIC;
41 
42  $this->logger = $DIC->logger()->wsrv();
43  $this->lng = $DIC->language();
44  $this->tree = $DIC->repositoryTree();
45 
46  $this->server = $server;
47  $this->mid = $a_mid;
48  $this->mapping = ilECSNodeMappingSettings::getInstanceByServerMid($this->server->getServerId(), $this->getMid());
49 
50  $this->course_url = new ilECSCourseUrl();
51  }
static getInstanceByServerMid(int $a_server_id, int $a_mid)
Get instance.
global $DIC
Definition: feed.php:28
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 673 of file class.ilECSCourseCreationHandler.php.

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

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

673  : bool
674  {
675  $refs = ilObject::_getAllReferences($a_obj_id);
676  $ref_id = end($refs);
677 
678  if (!$ref_id) {
679  return false;
680  }
681  $lms_url = new ilECSCourseLmsUrl();
682  $lms_url->setTitle(ilObject::_lookupTitle($a_obj_id));
683 
684  $lms_url->setUrl(ilLink::_getLink($ref_id));
685  $this->course_url->addLmsCourseUrls($lms_url);
686  return true;
687  }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:67
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 618 of file class.ilECSCourseCreationHandler.php.

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

Referenced by doSync().

618  : \ilObjCourse
619  {
620  $course_obj = new ilObjCourse();
621  $course_obj->setOwner(SYSTEM_USER_ID);
622  $title = $course->title;
623  $this->logger->debug('Creating new course instance from ecs : ' . $title);
624  $course_obj->setTitle($title);
625  $course_obj->setOfflineStatus(true);
626  $course_obj->create();
627  return $course_obj;
628  }
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 633 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().

633  : \ilObjCourse
634  {
635  $ref_ids = ilObject::_getAllReferences($a_parent_obj_id);
636  $ref_id = end($ref_ids);
637 
638  $crs->createReference();
639  $crs->putInTree($ref_id);
640  $crs->setPermissions($ref_id);
641 
642  $this->setObjectCreated(true);
643  $this->addUrlEntry($crs->getId());
644 
645  $this->courses_created[] = $crs->getRefId();
646 
647  return $crs;
648  }
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:67
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 ( int  $a_parent_ref_id)
protected

Create course reference objects.

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

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

Referenced by doAttributeMapping().

235  : void
236  {
237  $this->logger->debug('Created new course reference in : ' . ilObject::_lookupTitle(ilObject::_lookupObjId($a_parent_ref_id)));
238  foreach ($this->getCreatedCourses() as $ref_id) {
239  $crsr = new ilObjCourseReference();
240  $crsr->setOwner(SYSTEM_USER_ID);
241  $crsr->setTargetRefId($ref_id);
242  $crsr->setTargetId(ilObject::_lookupObjId($ref_id));
243  $crsr->create();
244  $crsr->update();
245  $crsr->createReference();
246  $crsr->putInTree($a_parent_ref_id);
247  $crsr->setPermissions($a_parent_ref_id);
248 
249  $this->logger->debug('Created new course reference for : ' . ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)));
250  }
251  }
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:67
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 456 of file class.ilECSCourseCreationHandler.php.

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

Referenced by createParallelCourses(), and updateParallelCourses().

456  : bool
457  {
458  if ($this->getImportId((int) $course->lectureID, (string) $group->id)) {
459  $this->logger->debug('Parallel course already created');
460  return false;
461  }
462 
463  $course_obj = new ilObjCourse();
464  $course_obj->setOwner(SYSTEM_USER_ID);
465  $title = $course->title;
466  if ($group->title !== '') {
467  $title .= ' (' . $group->title . ')';
468  }
469  $this->logger->debug('Creating new parallel course instance from ecs : ' . $title);
470  $course_obj->setTitle($title);
471  $course_obj->setSubscriptionMaxMembers((int) $group->maxParticipants);
472  $course_obj->setOfflineStatus(true);
473  $course_obj->create();
474 
475  $this->createCourseReference($course_obj, ilObject::_lookupObjId($parent_ref));
476  $this->setImported((int) $course->lectureID, $course_obj, $a_content_id, $group->id);
477  $this->setObjectCreated(true);
478  return true;
479  }
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
Definition: constants.php:26
getImportId(int $a_content_id, string $a_sub_id=null)
Get import id of remote course Return 0 if object isn't imported.
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 445 of file class.ilECSCourseCreationHandler.php.

References createParallelCourse().

Referenced by doSync().

445  : bool
446  {
447  foreach ((array) $course->groups as $group) {
448  $this->createParallelCourse($a_content_id, $course, $group, $parent_ref);
449  }
450  return true;
451  }
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 531 of file class.ilECSCourseCreationHandler.php.

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

Referenced by createParallelGroups(), and updateParallelGroups().

531  : void
532  {
533  $group_obj = new ilObjGroup();
534  $group_obj->setOwner(SYSTEM_USER_ID);
535  $title = $group->title !== '' ? $group->title : $course->title;
536  $group_obj->setTitle($title);
537  $group_obj->setMaxMembers((int) $group->maxParticipants);
538  $group_obj->create();
539  $group_obj->createReference();
540  $group_obj->putInTree($parent_ref);
541  $group_obj->setPermissions($parent_ref);
542  $group_obj->updateGroupType(ilGroupConstants::GRP_TYPE_CLOSED);
543  $this->setImported((int) $course->lectureID, $group_obj, $a_content_id, $group->id);
544  $this->setObjectCreated(true);
545  }
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 520 of file class.ilECSCourseCreationHandler.php.

References createParallelGroup().

Referenced by doSync().

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

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

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

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

References $course_url.

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

◆ getCreatedCourses()

ilECSCourseCreationHandler::getCreatedCourses ( )
protected

get created courses

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

References $courses_created.

Referenced by createCourseReferenceObjects().

99  : array
100  {
101  return $this->courses_created;
102  }
+ 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 582 of file class.ilECSCourseCreationHandler.php.

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

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

582  : int
583  {
584  return ilECSImportManager::getInstance()->lookupObjIdByContentId(
585  $this->getServer()->getServerId(),
586  $this->getMid(),
587  $a_content_id,
588  $a_sub_id
589  );
590  }
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 66 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 107 of file class.ilECSCourseCreationHandler.php.

References $mid.

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

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

◆ getServer()

ilECSCourseCreationHandler::getServer ( )

Get server settings.

Definition at line 57 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 116 of file class.ilECSCourseCreationHandler.php.

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

116  : bool
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->course_url->setECSId($a_content_id);
123 
124 
125  if ($this->getMapping()->isAttributeMappingEnabled()) {
126  $this->logger->debug('Handling advanced attribute mapping');
127  return $this->doAttributeMapping($a_content_id, $course);
128  }
129 
130  if ($this->getMapping()->isAllInOneCategoryEnabled()) {
131  $this->logger->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->logger->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->logger->info('Using course default category');
143  $this->doSync($a_content_id, $course, ilObject::_lookupObjId($this->getMapping()->getDefaultCourseCategory()));
144  return true;
145  }
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 692 of file class.ilECSCourseCreationHandler.php.

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

Referenced by doSync().

692  : void
693  {
694  $this->logger->debug('Starting course url update');
695  if ($this->isObjectCreated()) {
696  $this->logger->debug('Sending new course group url');
697  $this->course_url->send($this->getServer(), $this->getMid());
698  } else {
699  $this->logger->debug('No courses groups created. Aborting');
700  }
701  }
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 83 of file class.ilECSCourseCreationHandler.php.

References $object_created.

Referenced by handleCourseUrlUpdate().

83  : bool
84  {
85  return $this->object_created;
86  }
+ 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 653 of file class.ilECSCourseCreationHandler.php.

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

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

653  : bool
654  {
655  $import = new ilECSImport(
656  $this->getServer()->getServerId(),
657  is_object($object) ? $object->getId() : 0
658  );
659 
660 
661  $import->setSubId((string) $a_sub_id);
662  $import->setMID($this->getMid());
663  $import->setEContentId((string) $a_ecs_id);
664  $import->setContentId((string) $a_content_id);
665  $import->setImported(true);
666  $import->save();
667  return true;
668  }
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 91 of file class.ilECSCourseCreationHandler.php.

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

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

◆ syncCategory()

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

Sync category.

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

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

Referenced by syncNodeToTop().

326  : int
327  {
328  $data = new ilECSCmsData($tobj_id);
329 
330  $cat = new ilObjCategory();
331  $cat->setOwner(SYSTEM_USER_ID);
332  $cat->setTitle($data->getTitle());
333  $cat->create(); // true for upload
334  $cat->createReference();
335  $cat->putInTree($parent_ref_id);
336  $cat->setPermissions($parent_ref_id);
337  $cat->deleteTranslation($this->lng->getDefaultLanguage());
338  $cat->addTranslation(
339  $data->getTitle(),
340  $cat->getLongDescription(),
341  $this->lng->getDefaultLanguage(),
342  $this->lng->getDefaultLanguage()
343  );
344 
345  // set imported
346  $import = new ilECSImport(
347  $this->getServer()->getServerId(),
348  $cat->getId()
349  );
350  $import->setMID($this->getMid());
351  $import->setContentId($data->getCmsId());
352  $import->setImported(true);
353  $import->save();
354 
355  return $cat->getId();
356  }
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 276 of file class.ilECSCourseCreationHandler.php.

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

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

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

Referenced by handle().

256  : int
257  {
258  if (!is_array($course->allocations)) {
259  $this->logger->debug('No allocation in course defined.');
260  return 0;
261  }
262  if (!$course->allocations[0]->parentID) {
263  $this->logger->debug('No allocation parent in course defined.');
264  return 0;
265  }
266  $parent_id = $course->allocations[0]->parentID;
267 
268  $parent_tid = ilECSCmsData::lookupFirstTreeOfNode($this->getServer()->getServerId(), $this->getMid(), $parent_id);
269  return $this->syncNodetoTop($parent_tid, $parent_id);
270  }
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 595 of file class.ilECSCourseCreationHandler.php.

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

Referenced by doSync().

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

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

Referenced by doSync().

484  : bool
485  {
486  $parent_refs = ilObject::_getAllReferences($parent_obj);
487  $parent_ref = end($parent_refs);
488 
489  foreach ((array) $course->groups as $group) {
490  $title = $course->title;
491  if ($group->title !== '') {
492  $title .= ' (' . $group->title . ')';
493  }
494 
495  $obj_id = $this->getImportId((int) $course->lectureID, (string) $group->id);
496  $this->logger->debug('Imported obj id is ' . $obj_id);
497  if (!$obj_id) {
498  $this->createParallelCourse($a_content_id, $course, $group, $parent_ref);
499  } else {
500  $course_obj = ilObjectFactory::getInstanceByObjId($obj_id, false);
501  if ($course_obj instanceof ilObjCourse) {
502  $this->logger->debug('New title is ' . $title);
503  $course_obj->setTitle($title);
504  if(!is_null($group->maxParticipants)) {
505  $course_obj->setSubscriptionMaxMembers($group->maxParticipants);
506  }
507  $course_obj->update();
508  }
509  }
510  $this->addUrlEntry($this->getImportId((int) $course->lectureID, (string) $group->ID));
511  }
512  return true;
513  }
static _getAllReferences(int $id)
get all reference ids for object ID
getImportId(int $a_content_id, string $a_sub_id=null)
Get import id of remote course Return 0 if object isn't imported.
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 551 of file class.ilECSCourseCreationHandler.php.

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

Referenced by doSync().

551  : void
552  {
553  $parent_refs = ilObject::_getAllReferences($parent_obj);
554  $parent_ref = end($parent_refs);
555 
556  foreach ((array) $course->groups as $group) {
557  $obj_id = $this->getImportId((int) $course->lectureID, (string) $group->id);
558  $this->logger->debug('Imported obj id is ' . $obj_id);
559  if (!$obj_id) {
560  $this->createParallelGroup($a_content_id, $course, $group, $parent_ref);
561  } else {
562  $group_obj = ilObjectFactory::getInstanceByObjId($obj_id, false);
563  if ($group_obj instanceof ilObjGroup) {
564  $title = $group->title !== '' ? $group->title : $course->title;
565  $this->logger->debug('New title is ' . $title);
566  $group_obj->setTitle($title);
567  if(!is_null($group->maxParticipants)) {
568  $group_obj->setMaxMembers((int) $group->maxParticipants);
569  }
570  $group_obj->update();
571  }
572  }
573  $this->addUrlEntry($this->getImportId((int) $course->lectureID, (string) $group->id));
574  }
575  }
static _getAllReferences(int $id)
get all reference ids for object ID
getImportId(int $a_content_id, string $a_sub_id=null)
Get import id of remote course Return 0 if object isn't imported.
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 32 of file class.ilECSCourseCreationHandler.php.

Referenced by getCourseUrl().

◆ $courses_created

array ilECSCourseCreationHandler::$courses_created = array()
private

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

Referenced by getCreatedCourses().

◆ $lng

ilLanguage ilECSCourseCreationHandler::$lng
private

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

◆ $logger

ilLogger ilECSCourseCreationHandler::$logger
private

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

◆ $mapping

ilECSNodeMappingSettings ilECSCourseCreationHandler::$mapping
private

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

Referenced by getMapping().

◆ $mid

int ilECSCourseCreationHandler::$mid
private

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

Referenced by getMid().

◆ $object_created

bool ilECSCourseCreationHandler::$object_created = false
private

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

Referenced by isObjectCreated().

◆ $server

ilECSSetting ilECSCourseCreationHandler::$server
private

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

Referenced by __construct(), and getServer().

◆ $tree

ilTree ilECSCourseCreationHandler::$tree
private

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


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