Plugin description


This plugin allows the synchronization of cohorts and members in cohorts from the command line. There are 2 scripts CLI to do the synchronization.

  1. cohortsync.php
  2. cohortmembersync.php

The plugin configuration page


There are two level configuration:

Settings for cohorts synchronization

Settings for cohorts members synchronization

Plugin configuration page

Formats description


Cohorts synchronization

Since cohort synchronization is based on Upload cohorts (core), the full description is found here

Cohorts members synchronization

The file is a comma separated file (or any other delimiter set in the plugin page settings or as a param in the script CLI) assumed to have three fields per line:

operation, cohortidentifier, useridentifier

where:

It could look something like this:

   add, cohort1id, username1
   add, cohort2id, username2
   add, cohort2id, username3
   del, cohort3id, username4
   del, cohort4id, username5
   add, cohort4id, username5

Usage


Cohort synchronization

To synchronize cohorts from script CLI, you have to execute the script like this:

php admin/tool/cohortsync/cli/cohortsync.php --filepath=/pathfile/ --csvdelimeter=comma --csvencoding=UTF-8 --context=system

Here an example of csv file that can be used:

name,idnumber,description,category,visible
cohort name 1,cohortid1,first description,,
cohort name 2,cohortid2,,,
cohort name 3,cohortid3,,Miscellaneous,no
cohort name 4,cohortid4,,CAT1,yes
cohort name 5,cohortid5,,CAT2,0
cohort name 6,cohortid6,,CAT3,1

For more details about the script CLI, run this command:

php admin/tool/cohortsync/cli/cohortsync.php --help

Cohort sync help

Cohort member synchronization

To synchronize cohorts members from script CLI, you have to execute the script like this:

php admin/tool/cohortsync/cli/cohortmembersync.php --filepath=/pathfile/ --cohortidentifier=name --useridentifier=id --flatfiledelimiter=comma --flatfileencoding=UTF-8

Here an example of flatfile that can be used:

   add, my cohort A, 2
   add, my cohort A, 3
   add, my cohort B, 6
   del, my cohort B, 14
   del, my cohort C, 75
   add, my cohort C, 30

For more details about the script CLI, run this command:

php admin/tool/cohortsync/cli/cohortmembersync.php --help

Cohort sync help