예제 #1
0
 static function cluster_assigned_handler($eventdata)
 {
     require_once elispm::lib('data/clusterassignment.class.php');
     require_once elispm::lib('data/clustercurriculum.class.php');
     require_once elispm::lib('data/curriculumstudent.class.php');
     require_once elispm::lib('data/clustertrack.class.php');
     require_once elispm::lib('data/usertrack.class.php');
     $assignment = new clusterassignment($eventdata);
     $userset = $assignment->cluster;
     // assign user to the curricula associated with the cluster
     /**
      * @todo we may need to change this if associating a user with a
      * curriculum does anything more complicated
      */
     // enrol user in associated curricula
     $prog_assocs = $userset->clustercurriculum;
     foreach ($prog_assocs as $prog_assoc) {
         if ($prog_assoc->autoenrol && !curriculumstudent::exists(array(new field_filter('userid', $eventdata->userid), new field_filter('curriculumid', $prog_assoc->curriculumid)))) {
             $progass = new curriculumstudent();
             $progass->userid = $eventdata->userid;
             $progass->curriculumid = $prog_assoc->curriculumid;
             $progass->timecreated = $progass->timemodified = time();
             $progass->save();
         }
     }
     // enrol user in associated tracks if autoenrol flag is set on the cluster-track associations
     $track_assocs = $userset->clustertrack;
     foreach ($track_assocs as $track_assoc) {
         if ($track_assoc->autoenrol && !usertrack::exists(array(new field_filter('userid', $eventdata->userid), new field_filter('trackid', $track_assoc->trackid)))) {
             usertrack::enrol($eventdata->userid, $track_assoc->trackid);
         }
     }
     return true;
 }