Skip to content
Philip Cali edited this page Dec 12, 2011 · 3 revisions

The enrollment module gives the developer working on outside plugins to interact directly with the enrollment process through the public API, synonymously, the cps object.

Reprocessing

The enrollment module is scheduled to run daily somewhere between 2 and 3 am. By this time, new enrollment information may be available. To reprocess a course on demand (fetches new enrollment from the provider and performs enrollment):

$errors = cps::reprocess_course($course); // Done

The following reprocess functions are available:

  • reprocess_course takes in a Moodle course
  • reprocess_sections takes in a collection of cps_sections
  • reprocess_for takes in a cps_teacher, and reprocesses all section for him / her

Handling Enrollment

Outside systems may add or modify how Moodle data is representing the CPS enrollment data (the CPS Enrollment Process is actually very simple).

$sections = cps_section::from_course($course);

// Going to unenroll everyone
cps::unenroll_users($sections);

// Going to reenroll everyone
cps::enroll_users($sections);

A common idiom is: unenroll users, do some work, enroll users / create courses. the inject_manifest function takes care of this for you.

cps::inject_manifest($sections, function($section) use ($newid) {
    $section->idnumber = $newid;
});

Why call it inject_manifest? When called in such a way, that is exactly what the public API is doing for you.

Other Helpful Functions

  • require_daos just loads the dao library with a single call.
  • require_extensions these are provider extensions.
  • require_libs calls require_daos and require_extensions... useful for provider development

Clone this wiki locally