ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 ($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:22
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 671 of file class.ilECSCourseCreationHandler.php.

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

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

671  : bool
672  {
673  $refs = ilObject::_getAllReferences($a_obj_id);
674  $ref_id = end($refs);
675 
676  if (!$ref_id) {
677  return false;
678  }
679  $lms_url = new ilECSCourseLmsUrl();
680  $lms_url->setTitle(ilObject::_lookupTitle($a_obj_id));
681 
682  $lms_url->setUrl(ilLink::_getLink($ref_id));
683  $this->course_url->addLmsCourseUrls($lms_url);
684  return true;
685  }
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 616 of file class.ilECSCourseCreationHandler.php.

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

Referenced by doSync().

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

631  : \ilObjCourse
632  {
633  $ref_ids = ilObject::_getAllReferences($a_parent_obj_id);
634  $ref_id = end($ref_ids);
635 
636  $crs->createReference();
637  $crs->putInTree($ref_id);
638  $crs->setPermissions($ref_id);
639 
640  $this->setObjectCreated(true);
641  $this->addUrlEntry($crs->getId());
642 
643  $this->courses_created[] = $crs->getRefId();
644 
645  return $crs;
646  }
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 454 of file class.ilECSCourseCreationHandler.php.

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

Referenced by createParallelCourses(), and updateParallelCourses().

454  : bool
455  {
456  if ($this->getImportId((int) $course->lectureID, (string) $group->id)) {
457  $this->logger->debug('Parallel course already created');
458  return false;
459  }
460 
461  $course_obj = new ilObjCourse();
462  $course_obj->setOwner(SYSTEM_USER_ID);
463  $title = $course->title;
464  if ($group->title !== '') {
465  $title .= ' (' . $group->title . ')';
466  }
467  $this->logger->debug('Creating new parallel course instance from ecs : ' . $title);
468  $course_obj->setTitle($title);
469  $course_obj->setSubscriptionMaxMembers((int) $group->maxParticipants);
470  $course_obj->setOfflineStatus(true);
471  $course_obj->create();
472 
473  $this->createCourseReference($course_obj, ilObject::_lookupObjId($parent_ref));
474  $this->setImported((int) $course->lectureID, $course_obj, $a_content_id, $group->id);
475  $this->setObjectCreated(true);
476  return true;
477  }
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 443 of file class.ilECSCourseCreationHandler.php.

References createParallelCourse().

Referenced by doSync().

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

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

Referenced by createParallelGroups(), and updateParallelGroups().

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

References createParallelGroup().

Referenced by doSync().

518  : bool
519  {
520  foreach ((array) $course->groups as $group) {
521  $this->createParallelGroup($a_content_id, $course, $group, $parent_ref);
522  }
523  return true;
524  }
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  $this->logger->debug('Group scenario ' . $course->groupScenario);
378  switch ((int) $course->groupScenario) {
380  $this->logger->debug('Performing update for parallel groups in course.');
381  $this->updateParallelGroups($a_content_id, $course, $obj_id);
382  break;
383 
385  $this->logger->debug('Performing update for parallel courses.');
386  $this->updateParallelCourses($a_content_id, $course, $a_parent_obj_id);
387  break;
388 
390  default:
391  // nothing to do
392  break;
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  // finally update course urls
436  $this->handleCourseUrlUpdate();
437  return true;
438  }
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 580 of file class.ilECSCourseCreationHandler.php.

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

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

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

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

Referenced by doSync().

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

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

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

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

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

Referenced by doSync().

593  : bool
594  {
595  // do update
596  $refs = ilObject::_getAllReferences($obj_id);
597  $ref_id = end($refs);
598  $crs_obj = ilObjectFactory::getInstanceByRefId($ref_id, false);
599  if (!$crs_obj instanceof ilObject) {
600  $this->logger->debug('Cannot instantiate course instance');
601  return true;
602  }
603 
604  // Update title
605  $title = $course->title;
606  $this->logger->debug('new title is : ' . $title);
607 
608  $crs_obj->setTitle($title);
609  $crs_obj->update();
610  return true;
611  }
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 482 of file class.ilECSCourseCreationHandler.php.

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

Referenced by doSync().

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

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

Referenced by doSync().

549  : void
550  {
551  $parent_refs = ilObject::_getAllReferences($parent_obj);
552  $parent_ref = end($parent_refs);
553 
554  foreach ((array) $course->groups as $group) {
555  $obj_id = $this->getImportId((int) $course->lectureID, (string) $group->id);
556  $this->logger->debug('Imported obj id is ' . $obj_id);
557  if (!$obj_id) {
558  $this->createParallelGroup($a_content_id, $course, $group, $parent_ref);
559  } else {
560  $group_obj = ilObjectFactory::getInstanceByObjId($obj_id, false);
561  if ($group_obj instanceof ilObjGroup) {
562  $title = $group->title !== '' ? $group->title : $course->title;
563  $this->logger->debug('New title is ' . $title);
564  $group_obj->setTitle($title);
565  if(!is_null($group->maxParticipants)) {
566  $group_obj->setMaxMembers((int) $group->maxParticipants);
567  }
568  $group_obj->update();
569  }
570  }
571  $this->addUrlEntry($this->getImportId((int)$course->lectureID, (string)$group->id));
572  }
573  }
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: