ILIAS  release_4-4 Revision
ilECSCourseCreationHandler Class Reference

Description of class. More...

+ Collaboration diagram for ilECSCourseCreationHandler:

Public Member Functions

 __construct (ilECSSetting $server, $a_mid)
 Constructor More...
 
 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 ($a_status)
 Set object created status. More...
 
 getMid ()
 Get mid of course event. More...
 
 handle ($a_content_id, $course)
 Handle sync request. More...
 

Protected Member Functions

 doAttributeMapping ($a_content_id, $course)
 Sync attribute mapping. 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 ($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, $parent_obj)
 Update parallel group data. More...
 
 getImportId ($a_content_id, $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 ($crs, $a_parent_obj_id)
 Create course reference. More...
 
 setImported ($a_content_id, $object, $a_ecs_id=0, $a_sub_id=0)
 Set new course object imported. More...
 
 addUrlEntry ($a_obj_id)
 Add an url entry. More...
 
 handleCourseUrlUpdate ()
 Update course url. More...
 

Private Attributes

 $server = null
 
 $mapping = null
 
 $course_url = null
 
 $object_created = false
 
 $mid
 

Detailed Description

Description of class.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor

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

References $server, ilECSNodeMappingSettings\getInstanceByServerMid(), getMid(), and getServer().

29  {
30  $this->server = $server;
31  $this->mid = $a_mid;
32  $this->mapping = ilECSNodeMappingSettings::getInstanceByServerMid($this->getServer()->getServerId(), $this->getMid());
33 
34  include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseUrl.php';
35  $this->course_url = new ilECSCourseUrl();
36  }
static getInstanceByServerMid($a_server_id, $a_mid)
Get instance.
Represents a ecs course url.
+ Here is the call graph for this function:

Member Function Documentation

◆ addUrlEntry()

ilECSCourseCreationHandler::addUrlEntry (   $a_obj_id)
protected

Add an url entry.

Parameters
type$a_obj_id

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

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

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

647  {
648  $refs = ilObject::_getAllReferences($a_obj_id);
649  $ref_id = end($refs);
650 
651  if(!$ref_id)
652  {
653  return false;
654  }
655  include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseLmsUrl.php';
656  $lms_url = new ilECSCourseLmsUrl();
657  $lms_url->setTitle(ilObject::_lookupTitle($a_obj_id));
658 
659  include_once './Services/Link/classes/class.ilLink.php';
660  $lms_url->setUrl(ilLink::_getLink($ref_id));
661  $this->getCourseUrl()->addLmsCourseUrls($lms_url);
662  }
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
Represents a ecs course lms url.
$ref_id
Definition: sahs_server.php:39
+ 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.

Returns
ilObjCourse

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

References $GLOBALS.

Referenced by doSync().

588  {
589  include_once './Modules/Course/classes/class.ilObjCourse.php';
590  $course_obj = new ilObjCourse();
591  $title = $course->title;
592  $GLOBALS['ilLog']->write(__METHOD__.': Creating new course instance from ecs : '. $title);
593  $course_obj->setTitle($title);
594  $course_obj->create();
595  return $course_obj;
596  }
Class ilObjCourse.
$GLOBALS['ct_recipient']
+ Here is the caller graph for this function:

◆ createCourseReference()

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

Create course reference.

Parameters
ilObjCourse$crs_obj
int$a_parent_obj_id
Returns
ilObjCourse

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

References $ref_id, ilObject\_getAllReferences(), addUrlEntry(), and setObjectCreated().

Referenced by createParallelCourse(), and doSync().

605  {
606  $ref_ids = ilObject::_getAllReferences($a_parent_obj_id);
607  $ref_id = end($ref_ids);
608 
609  $crs->createReference();
610  $crs->putInTree($ref_id);
611  $crs->setPermissions($ref_id);
612 
613  $this->setObjectCreated(true);
614  $this->addUrlEntry($crs->getId());
615  return $crs;
616  }
addUrlEntry($a_obj_id)
Add an url entry.
static _getAllReferences($a_id)
get all reference ids of object
setObjectCreated($a_status)
Set object created status.
$ref_id
Definition: sahs_server.php:39
+ 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.

Parameters
type$course
type$group
type$parent_ref

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

References $GLOBALS, ilObject\_lookupObjId(), createCourseReference(), setImported(), and setObjectCreated().

Referenced by createParallelCourses(), and updateParallelCourses().

418  {
419  include_once './Modules/Course/classes/class.ilObjCourse.php';
420  $course_obj = new ilObjCourse();
421  $title = strlen($group->title) ? $group->title : $course->title;
422  $GLOBALS['ilLog']->write(__METHOD__.': Creating new parallel course instance from ecs : '. $title);
423  $course_obj->setTitle($title);
424  $course_obj->setSubscriptionMaxMembers((int) $group->maxParticipants);
425  $course_obj->create();
426 
427  $this->createCourseReference($course_obj, ilObject::_lookupObjId($parent_ref));
428  $this->setImported($course->lectureID, $course_obj,$a_content_id, $group->id);
429  $this->setObjectCreated(true);
430  return true;
431  }
setImported($a_content_id, $object, $a_ecs_id=0, $a_sub_id=0)
Set new course object imported.
Class ilObjCourse.
$GLOBALS['ct_recipient']
createCourseReference($crs, $a_parent_obj_id)
Create course reference.
static _lookupObjId($a_id)
setObjectCreated($a_status)
Set object created status.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createParallelCourses()

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

Create parallel courses.

Parameters
intecontent id
type$course
type$parent_ref

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

References createParallelCourse().

Referenced by doSync().

403  {
404  foreach((array) $course->groups as $group)
405  {
406  $this->createParallelCourse($a_content_id,$course, $group, $parent_ref);
407  }
408  return true;
409  }
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.

Parameters
type$course
type$group

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

References GRP_TYPE_CLOSED, setImported(), and setObjectCreated().

Referenced by createParallelGroups(), and updateParallelGroups().

490  {
491  include_once './Modules/Group/classes/class.ilObjGroup.php';
492  $group_obj = new ilObjGroup();
493  $title = strlen($group->title) ? $group->title : $course->title;
494  $group_obj->setTitle($title);
495  $group_obj->setMaxMembers((int) $group->maxParticipants);
496  $group_obj->create();
497  $group_obj->createReference();
498  $group_obj->putInTree($parent_ref);
499  $group_obj->setPermissions($parent_ref);
500  $group_obj->initGroupStatus(GRP_TYPE_CLOSED);
501  $this->setImported($course->lectureID, $group_obj, $a_content_id, $group->id);
502  $this->setObjectCreated(true);
503  }
setImported($a_content_id, $object, $a_ecs_id=0, $a_sub_id=0)
Set new course object imported.
const GRP_TYPE_CLOSED
setObjectCreated($a_status)
Set object created status.
Class ilObjGroup.
+ 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.

Parameters
type$course
ilObjCourse

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

References createParallelGroup().

Referenced by doSync().

476  {
477  foreach((array) $course->groups as $group)
478  {
479  $this->createParallelGroup($a_content_id,$course, $group, $parent_ref);
480  }
481  return true;
482  }
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.

Parameters
type$a_content_id
type$course

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

References $GLOBALS, $ref_id, ilObject\_getAllReferences(), ilObject\_lookupObjId(), ilECSCourseMappingRule\doMappings(), doSync(), getImportId(), getMapping(), getMid(), ilECSCourseMappingRule\getRuleRefIds(), getServer(), and ilECSCourseMappingRule\isMatching().

Referenced by handle().

137  {
138  // Check if course is already created
139  $course_id = $course->lectureID;
140  $obj_id = $this->getImportId($course_id);
141 
142  if($obj_id)
143  {
144  // do update
145  $GLOBALS['ilLog']->write(__METHOD__.' Performing update of already imported course.');
146 
147  $refs = ilObject::_getAllReferences($obj_id);
148  $ref = end($refs);
149 
150  return $this->doSync(
151  $a_content_id,
152  $course,
153  ilObject::_lookupObjId($GLOBALS['tree']->getParentId($ref))
154  );
155  }
156 
157  // Get all rules
158  $matching_rule = 0;
159  include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseMappingRule.php';
160  foreach(ilECSCourseMappingRule::getRuleRefIds($this->getServer()->getServerId(), $this->getMid()) as $ref_id)
161  {
163  $course,
164  $this->getServer()->getServerId(),
165  $this->getMid(),
166  $ref_id))
167  {
168  $matching_rule = $ref_id;
169  }
170  }
171  if(!$matching_rule)
172  {
173  // Put course in default category
174  $GLOBALS['ilLog']->write(__METHOD__.': No matching attribute mapping rule found.');
175  $GLOBALS['ilLog']->write(__METHOD__.': Using course default category');
176  return $this->doSync($a_content_id,$course,ilObject::_lookupObjId($this->getMapping()->getDefaultCourseCategory()));
177  }
178  // map according mapping rules
179  $parent_ref = ilECSCourseMappingRule::doMappings($course,$this->getServer()->getServerId(),$this->getMid(),$ref_id);
180  $this->doSync($a_content_id, $course, ilObject::_lookupObjId($parent_ref));
181  return true;
182  }
static doMappings($course, $a_sid, $a_mid, $a_ref_id)
static isMatching($course, $a_sid, $a_mid, $a_ref_id)
Check if rule matches.
static _getAllReferences($a_id)
get all reference ids of object
$GLOBALS['ct_recipient']
static _lookupObjId($a_id)
static getRuleRefIds($a_sid, $a_mid)
$ref_id
Definition: sahs_server.php:39
doSync($a_content_id, $course, $a_parent_obj_id)
Handle all in one setting.
getImportId($a_content_id, $a_sub_id=NULL)
Get import id of remote course Return 0 if object isn't imported.
+ 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.

Parameters
type$a_content_id
type$course

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

References $GLOBALS, ilObject\_getAllReferences(), createCourseData(), createCourseReference(), createParallelCourses(), createParallelGroups(), getCourseUrl(), getImportId(), handleCourseUrlUpdate(), 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().

309  {
310  // Check if course is already created
311  $course_id = $course->lectureID;
312  $this->getCourseUrl()->setCmsLectureId($course_id);
313 
314  $obj_id = $this->getImportId($course_id);
315 
316  $GLOBALS['ilLog']->write(__METHOD__.': Handling course '. print_r($course,true));
317 
318  // Handle parallel groups
319  if($obj_id)
320  {
321  // update multiple courses/groups according to parallel scenario
322  $GLOBALS['ilLog']->write(__METHOD__.': '.$course->groupScenario);
323  include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
324  switch((int) $course->groupScenario)
325  {
327  $GLOBALS['ilLog']->write(__METHOD__.': Performing update for parallel groups in course.');
328  $this->updateParallelGroups($course,$obj_id);
329  break;
330 
332  $GLOBALS['ilLog']->write(__METHOD__.': Performing update for parallel courses.');
333  $this->updateParallelCourses($a_content_id,$course, $a_parent_obj_id);
334  break;
335 
337  default:
338  // nothing to do
339  break;
340 
341  }
342 
343  // do update
344  $this->updateCourseData($course,$obj_id);
345  }
346  else
347  {
348  include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
349  switch((int) $course->groupScenario)
350  {
352  $GLOBALS['ilLog']->write(__METHOD__.': Parallel scenario "groups in courses".');
353  $crs = $this->createCourseData($course);
354  $crs = $this->createCourseReference($crs, $a_parent_obj_id);
355  $this->setImported($course_id, $crs, $a_content_id);
356 
357  // Create parallel groups under crs
358  $this->createParallelGroups($a_content_id,$course,$crs->getRefId());
359  break;
360 
361 
362 
364  // Import empty to store the ecs ressource id (used for course member update).
365  $this->setImported($course_id,NULL,$a_content_id);
366  $GLOBALS['ilLog']->write(__METHOD__.': Parallel scenario "Courses foreach Lecturer".');
367  break;
368 
370  $GLOBALS['ilLog']->write(__METHOD__.': Parallel scenario "Many courses".');
371 
372  $refs = ilObject::_getAllReferences($a_parent_obj_id);
373  $ref = end($refs);
374  $crs = $this->createCourseData($course);
375  $this->createCourseReference($crs, $a_parent_obj_id);
376  $this->setImported($course_id, $crs, $a_content_id);
377  $this->createParallelCourses($a_content_id,$course, $ref);
378  break;
379 
380  default:
382  $GLOBALS['ilLog']->write(__METHOD__.': Parallel scenario "One Course".');
383  $crs = $this->createCourseData($course);
384  $this->createCourseReference($crs, $a_parent_obj_id);
385  $this->setImported($course_id, $crs, $a_content_id);
386  break;
387 
388 
389  }
390  }
391  // finally update course urls
392  $this->handleCourseUrlUpdate();
393  return true;
394  }
updateParallelCourses($a_content_id, $course, $parent_obj)
Update parallel group data.
createParallelCourses($a_content_id, $course, $parent_ref)
Create parallel courses.
setImported($a_content_id, $object, $a_ecs_id=0, $a_sub_id=0)
Set new course object imported.
static _getAllReferences($a_id)
get all reference ids of object
$GLOBALS['ct_recipient']
createCourseReference($crs, $a_parent_obj_id)
Create course reference.
updateParallelGroups($a_content_id, $course, $parent_obj)
Update parallel group data.
updateCourseData($course, $obj_id)
Update course data.
createParallelGroups($a_content_id, $course, $parent_ref)
This create parallel groups.
createCourseData($course)
Create course data from json.
getImportId($a_content_id, $a_sub_id=NULL)
Get import id of remote course Return 0 if object isn't imported.
+ 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 61 of file class.ilECSCourseCreationHandler.php.

References $course_url.

Referenced by addUrlEntry(), doSync(), handle(), and handleCourseUrlUpdate().

+ Here is the caller graph for this function:

◆ getImportId()

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

Parameters
type$a_content_id
Returns
type

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

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

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

548  {
549  include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
551  $this->getServer()->getServerId(),
552  $this->getMid(),
553  $a_content_id,
554  $a_sub_id
555  );
556  }
static lookupObjIdByContentId($a_server_id, $a_mid, $a_content_id, $a_sub_id='')
Lookup obj_id by content id.
+ 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 52 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.

Returns
type

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

References $mid.

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

+ Here is the caller graph for this function:

◆ getServer()

ilECSCourseCreationHandler::getServer ( )

Get server settings.

Returns
ilECSSetting

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

References $server.

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

+ Here is the caller graph for this function:

◆ handle()

ilECSCourseCreationHandler::handle (   $a_content_id,
  $course 
)

Handle sync request.

Parameters
intecs content id
type$course

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

References $GLOBALS, ilObject\_lookupObjId(), ilObject\_lookupTitle(), doAttributeMapping(), doSync(), getCourseUrl(), getMapping(), setObjectCreated(), and syncParentContainer().

99  {
100  $GLOBALS['ilLog']->write(__METHOD__.': --------- content id '.$a_content_id);
101 
102  // prepare course url
103  // if any object (course group) will be created, a list of all course urls
104  // will be sent to ecs.
105  $this->setObjectCreated(false);
106  $this->getCourseUrl()->setECSId($a_content_id);
107 
108 
109  if($this->getMapping()->isAttributeMappingEnabled())
110  {
111  $GLOBALS['ilLog']->write(__METHOD__.': Handling advanced attribute mapping');
112  return $this->doAttributeMapping($a_content_id,$course);
113  }
114 
115  if($this->getMapping()->isAllInOneCategoryEnabled())
116  {
117  $GLOBALS['ilLog']->write(__METHOD__.': Handling course all in one category setting');
118  return $this->doSync($a_content_id, $course,ilObject::_lookupObjId($this->getMapping()->getAllInOneCategory()));
119  }
120 
121  $parent_obj_id = $this->syncParentContainer($a_content_id,$course);
122  if($parent_obj_id)
123  {
124  $GLOBALS['ilLog']->write(__METHOD__.': Using already mapped category: '. ilObject::_lookupTitle($parent_obj_id));
125  return $this->doSync($a_content_id,$course,$parent_obj_id);
126  }
127  $GLOBALS['ilLog']->write(__METHOD__.': Using course default category');
128  return $this->doSync($a_content_id,$course,ilObject::_lookupObjId($this->getMapping()->getDefaultCourseCategory()));
129  }
static _lookupTitle($a_id)
lookup object title
$GLOBALS['ct_recipient']
static _lookupObjId($a_id)
setObjectCreated($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 667 of file class.ilECSCourseCreationHandler.php.

References $GLOBALS, getCourseUrl(), getMid(), getServer(), and isObjectCreated().

Referenced by doSync().

668  {
669  $GLOBALS['ilLog']->write(__METHOD__.': Starting course url update');
670  if($this->isObjectCreated())
671  {
672  $GLOBALS['ilLog']->write(__METHOD__.': Sending new course group url');
673  $this->getCourseUrl()->send($this->getServer(), $this->getMid());
674  }
675  else
676  {
677  $GLOBALS['ilLog']->write(__METHOD__.': No courses groups created. Aborting');
678  }
679  }
$GLOBALS['ct_recipient']
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.

Returns
bool

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

References $object_created.

Referenced by handleCourseUrlUpdate().

+ Here is the caller graph for this function:

◆ setImported()

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

Set new course object imported.

Parameters
int$a_content_id
ilObjCourse$crs

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

References $GLOBALS, getMid(), and getServer().

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

624  {
625  include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
626  $import = new ilECSImport(
627  $this->getServer()->getServerId(),
628  is_object($object) ? $object->getId() : 0
629  );
630 
631  $GLOBALS['ilLog']->write(__METHOD__.': Imported with ecs id '.$a_ecs_id);
632 
633  $import->setSubId($a_sub_id);
634  $import->setMID($this->getMid());
635  $import->setEContentId($a_ecs_id);
636  $import->setContentId($a_content_id);
637  $import->setImported(true);
638  $import->save();
639  return true;
640  }
$GLOBALS['ct_recipient']
Storage of ECS imported objects.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setObjectCreated()

ilECSCourseCreationHandler::setObjectCreated (   $a_status)

Set object created status.

Parameters
bool$a_status

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

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

80  {
81  $this->object_created = $a_status;
82  }
+ Here is the caller graph for this function:

◆ syncCategory()

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

Sync category.

Parameters
type$tobj_id
type$parent_ref_id

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

References $data, $GLOBALS, getMid(), getServer(), and ilECSImport\setMID().

Referenced by syncNodeToTop().

271  {
272  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
273  $data = new ilECSCmsData($tobj_id);
274 
275  include_once './Modules/Category/classes/class.ilObjCategory.php';
276  $cat = new ilObjCategory();
277  $cat->setTitle($data->getTitle());
278  $cat->create(); // true for upload
279  $cat->createReference();
280  $cat->putInTree($parent_ref_id);
281  $cat->setPermissions($parent_ref_id);
282  $cat->deleteTranslation($GLOBALS['lng']->getDefaultLanguage());
283  $cat->addTranslation(
284  $data->getTitle(),
285  $cat->getLongDescription(),
286  $GLOBALS['lng']->getDefaultLanguage(),
287  1
288  );
289 
290  // set imported
291  $import = new ilECSImport(
292  $this->getServer()->getServerId(),
293  $cat->getId()
294  );
295  $import->setMID($this->getMid());
296  $import->setEContentId($data->getCmsId());
297  $import->setImported(true);
298  $import->save();
299 
300  return $cat->getId();
301  }
$GLOBALS['ct_recipient']
Storage of ECS imported objects.
Class ilObjCategory.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
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.

Parameters
type$tree_id
type$parent_id
Returns
int obj_id of container

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

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

215  {
216  $obj_id = $this->getImportId($cms_id);
217  if($obj_id)
218  {
219  // node already imported
220  return $obj_id;
221  }
222 
223  $tobj_id = ilECSCmsData::lookupObjId(
224  $this->getServer()->getServerId(),
225  $this->getMid(),
226  $tree_id,
227  $cms_id);
228 
229  // node is not imported
230  $GLOBALS['ilLog']->write(__METHOD__.': ecs node with id '. $cms_id. ' is not imported!');
231 
232  // check for mapping: if mapping is available create category
233  include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignment.php';
234  $ass = new ilECSNodeMappingAssignment(
235  $this->getServer()->getServerId(),
236  $this->getMid(),
237  $tree_id,
238  $tobj_id);
239 
240  if($ass->isMapped())
241  {
242  $GLOBALS['ilLog']->write(__METHOD__.': node is mapped');
243  return $this->syncCategory($tobj_id,$ass->getRefId());
244  }
245 
246  // Start recursion to top
247  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
248  $tree = new ilECSCmsTree($tree_id);
249  $parent_tobj_id = $tree->getParentId($tobj_id);
250  if($parent_tobj_id)
251  {
252  $cms_ids = ilECSCmsData::lookupCmsIds(array($parent_tobj_id));
253  $obj_id = $this->syncNodeToTop($tree_id, $cms_ids[0]);
254  }
255 
256  if($obj_id)
257  {
258  $refs = ilObject::_getAllReferences($obj_id);
259  $ref_id = end($refs);
260  return $this->syncCategory($tobj_id, $ref_id);
261  }
262  return 0;
263  }
syncNodeToTop($tree_id, $cms_id)
Sync node to top.
static lookupObjId($a_server_id, $a_mid, $a_tree_id, $cms_id)
syncCategory($tobj_id, $parent_ref_id)
Sync category.
static _getAllReferences($a_id)
get all reference ids of object
$GLOBALS['ct_recipient']
static lookupCmsIds($a_obj_ids)
$ref_id
Definition: sahs_server.php:39
getImportId($a_content_id, $a_sub_id=NULL)
Get import id of remote course Return 0 if object isn't imported.
+ Here is the call graph for this function:

◆ syncParentContainer()

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

Sync parent container.

Parameters
type$a_content_id
type$course

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

References $GLOBALS, getMid(), getServer(), and ilECSCmsData\lookupFirstTreeOfNode().

Referenced by handle().

190  {
191  if(!is_array($course->allocations))
192  {
193  $GLOBALS['ilLog']->write(__METHOD__.': No allocation in course defined.');
194  return 0;
195  }
196  if(!$course->allocations[0]->parentID)
197  {
198  $GLOBALS['ilLog']->write(__METHOD__.': No allocation parent in course defined.');
199  return 0;
200  }
201  $parent_id = $course->allocations[0]->parentID;
202 
203  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
204  $parent_tid = ilECSCmsData::lookupFirstTreeOfNode($this->getServer()->getServerId(), $this->getMid(), $parent_id);
205  return $this->syncNodetoTop($parent_tid, $parent_id);
206  }
static lookupFirstTreeOfNode($a_server_id, $a_mid, $cms_id)
Lookup first obj_id of cms node $ilDB $ilDB.
$GLOBALS['ct_recipient']
+ 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.

Parameters
type$course

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

References $GLOBALS, $ref_id, ilObject\_getAllReferences(), and ilObjectFactory\getInstanceByRefId().

Referenced by doSync().

563  {
564  // do update
565  $refs = ilObject::_getAllReferences($obj_id);
566  $ref_id = end($refs);
568  if(!$crs_obj instanceof ilObject)
569  {
570  $GLOBALS['ilLog']->write(__METHOD__.': Cannot instantiate course instance');
571  return true;
572  }
573 
574  // Update title
575  $title = $course->title;
576  $GLOBALS['ilLog']->write(__METHOD__.': new title is : '. $title);
577 
578  $crs_obj->setTitle($title);
579  $crs_obj->update();
580  return true;
581  }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObject Basic functions for all objects.
static _getAllReferences($a_id)
get all reference ids of object
$GLOBALS['ct_recipient']
$ref_id
Definition: sahs_server.php:39
+ 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.

Parameters
type$course
type$parent_obj

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

References $GLOBALS, ilObject\_getAllReferences(), addUrlEntry(), createParallelCourse(), getImportId(), and ilObjectFactory\getInstanceByObjId().

Referenced by doSync().

439  {
440  $parent_refs = ilObject::_getAllReferences($parent_obj);
441  $parent_ref = end($parent_refs);
442 
443  foreach((array) $course->groups as $group)
444  {
445  $title = strlen($group->title) ? $group->title : $course->title;
446  $obj_id = $this->getImportId($course->lectureID, $group->id);
447  $GLOBALS['ilLog']->write(__METHOD__.': Imported obj id is ' .$obj_id);
448  if(!$obj_id)
449  {
450  $this->createParallelCourse($a_content_id, $course, $group, $parent_ref);
451  }
452  else
453  {
454  $course_obj = ilObjectFactory::getInstanceByObjId($obj_id,false);
455  if($course_obj instanceof ilObjCourse)
456  {
457  $GLOBALS['ilLog']->write(__METHOD__.': New title is '. $title);
458  $course_obj->setTitle($title);
459  $course_obj->setSubscriptionMaxMembers($group->maxParticipants);
460  $course_obj->update();
461  }
462  }
463  $this->addUrlEntry($this->getImportId($course->lectureID, $group->ID));
464  }
465  return true;
466  }
addUrlEntry($a_obj_id)
Add an url entry.
static _getAllReferences($a_id)
get all reference ids of object
createParallelCourse($a_content_id, $course, $group, $parent_ref)
Create parallel course.
Class ilObjCourse.
$GLOBALS['ct_recipient']
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
getImportId($a_content_id, $a_sub_id=NULL)
Get import id of remote course Return 0 if object isn't imported.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateParallelGroups()

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

Update parallel group data.

Parameters
type$course
type$parent_obj

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

References $GLOBALS, ilObject\_getAllReferences(), addUrlEntry(), createParallelGroup(), getImportId(), and ilObjectFactory\getInstanceByObjId().

Referenced by doSync().

512  {
513  $parent_refs = ilObject::_getAllReferences($parent_obj);
514  $parent_ref = end($parent_refs);
515 
516  foreach((array) $course->groups as $group)
517  {
518  $obj_id = $this->getImportId($course->lectureID, $group->id);
519  $GLOBALS['ilLog']->write(__METHOD__.': Imported obj id is ' .$obj_id);
520  if(!$obj_id)
521  {
522  $this->createParallelGroup($a_content_id,$course, $group, $parent_ref);
523  }
524  else
525  {
526  $group_obj = ilObjectFactory::getInstanceByObjId($obj_id,false);
527  if($group_obj instanceof ilObjGroup)
528  {
529  $title = strlen($group->title) ? $group->title : $course->title;
530  $GLOBALS['ilLog']->write(__METHOD__.': New title is '. $title);
531  $group_obj->setTitle($title);
532  $group_obj->setMaxMembers((int) $group->maxParticipants);
533  $group_obj->update();
534  }
535  }
536  $this->addUrlEntry($this->getImportId($course->lectureID, $group->id));
537  }
538  }
addUrlEntry($a_obj_id)
Add an url entry.
static _getAllReferences($a_id)
get all reference ids of object
$GLOBALS['ct_recipient']
createParallelGroup($a_content_id, $course, $group, $parent_ref)
Create parallel group.
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjGroup.
getImportId($a_content_id, $a_sub_id=NULL)
Get import id of remote course Return 0 if object isn't imported.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $course_url

ilECSCourseCreationHandler::$course_url = null
private

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

Referenced by getCourseUrl().

◆ $mapping

ilECSCourseCreationHandler::$mapping = null
private

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

Referenced by getMapping().

◆ $mid

ilECSCourseCreationHandler::$mid
private

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

Referenced by getMid().

◆ $object_created

ilECSCourseCreationHandler::$object_created = false
private

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

Referenced by isObjectCreated().

◆ $server

ilECSCourseCreationHandler::$server = null
private

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

Referenced by __construct(), and getServer().


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