예제 #1
0
 public function update()
 {
     $result = parent::update();
     if (isset($this->curriculum)) {
         $this->add_course_to_curricula($this->curriculum);
     }
     // Add moodle course template
     if (isset($this->location)) {
         $template = new coursetemplate($this->id);
         $template->location = $this->location;
         $template->templateclass = $this->templateclass;
         $template->courseid = $this->id;
         $template->data_update_record(true);
     } else {
         coursetemplate::delete_for_course($this->id);
     }
     $result = $result && field_data::set_for_context_from_datarecord('course', $this);
     return $result;
 }
예제 #2
0
 public function save()
 {
     //add
     parent::save();
     //add
     if ($this->autocreate) {
         $this->track_auto_create();
     }
     $status = field_data::set_for_context_from_datarecord(CONTEXT_ELIS_TRACK, $this);
     return $status;
 }
예제 #3
0
 public function update()
 {
     $result = parent::update();
     $result = $result && field_data::set_for_context_from_datarecord('curriculum', $this);
     // If this setting is changed, we need to update the existing curriclum expiration values (ELIS-1172)
     if ($rs = get_recordset_select(CURASSTABLE, "timeexpired != 0 AND curriculumid = {$this->id}", '', 'id, userid')) {
         $timenow = time();
         while ($curass = rs_fetch_next_record($rs)) {
             $update = new stdClass();
             $update->id = $curass->id;
             $update->timeexpired = calculate_curriculum_expiry(NULL, $this->id, $curass->userid);
             $update->timemodified = $timenow;
             update_record(CURASSTABLE, $update);
         }
         rs_close($rs);
     }
     return $result;
 }
예제 #4
0
 function update()
 {
     global $CFG;
     global $CURMAN;
     $old = new cluster($this->id);
     $parent_obj = new cluster($this->parent);
     $this->depth = empty($parent_obj->depth) ? 1 : $parent_obj->depth + 1;
     $result = parent::update();
     if ($this->parent != $old->parent) {
         $cluster_context_level = context_level_base::get_custom_context_level('cluster', 'block_curr_admin');
         $cluster_context_instance = get_context_instance($cluster_context_level, $this->id);
         // find all subclusters and adjust their depth
         $delta_depth = $this->depth - $old->depth;
         $sql = "UPDATE {$CURMAN->db->prefix_table(CLSTTABLE)}\n                       SET depth = depth + {$delta_depth}\n                     WHERE id IN (SELECT instanceid\n                                    FROM {$CURMAN->db->prefix_table('context')}\n                                   WHERE contextlevel = {$cluster_context_level}\n                                     AND path LIKE '{$cluster_context_instance->path}/%')";
         execute_sql($sql, false);
         // Blank out the depth and path for associated records and child records in context table
         $sql = "UPDATE {$CFG->prefix}context\n                       SET depth=0, path=NULL\n                     WHERE id={$cluster_context_instance->id} OR path LIKE '{$cluster_context_instance->path}/%'";
         execute_sql($sql, false);
         // Rebuild any blanked out records in context table
         build_context_path();
     }
     $plugins = cluster::get_plugins();
     foreach ($plugins as $plugin) {
         require_once CURMAN_DIRLOCATION . '/cluster/' . $plugin . '/lib.php';
         call_user_func('cluster_' . $plugin . '_update', $this);
     }
     $result = $result && field_data::set_for_context_from_datarecord('cluster', $this);
     events_trigger('crlm_cluster_updated', $this);
     return $result;
 }
예제 #5
0
 function save_field_data()
 {
     static $loopdetect;
     if (!empty($loopdetect)) {
         return true;
     }
     field_data::set_for_context_from_datarecord('user', $this);
     $loopdetect = true;
     events_trigger('user_updated', cm_get_moodleuser($this->id));
     $loopdetect = false;
     return true;
 }
예제 #6
0
 public function update()
 {
     $status = parent::update();
     if ($this->moodlecourseid || $this->autocreate) {
         moodle_attach_class($this->id, $this->moodlecourseid, '', true, true, $this->autocreate);
     }
     if (!empty($this->oldmax) && $this->oldmax < $this->maxstudents && waitlist::count_records($this->id) > 0) {
         for ($i = $this->oldmax; $i < $this->maxstudents; $i++) {
             $next_student = waitlist::get_next($this->id);
             if (!empty($next_student)) {
                 $next_student->enrol();
             } else {
                 break;
             }
         }
     }
     $status = $status && field_data::set_for_context_from_datarecord('class', $this);
     return $status;
 }
예제 #7
0
 function update()
 {
     $result = parent::update();
     $result = $result && field_data::set_for_context_from_datarecord('track', $this);
     return $result;
 }
예제 #8
0
 public function save()
 {
     parent::save();
     if (isset($this->curriculum)) {
         $this->add_course_to_curricula($this->curriculum);
     }
     // Add moodle course template
     if (isset($this->location)) {
         $template = $this->coursetemplate->current();
         $template->location = $this->location;
         $template->templateclass = $this->templateclass;
         $template->courseid = $this->id;
         $template->save();
     } else {
         coursetemplate::delete_records(new field_filter('courseid', $this->id));
     }
     field_data::set_for_context_from_datarecord(CONTEXT_ELIS_COURSE, $this);
 }
예제 #9
0
 public function save()
 {
     $isnew = empty($this->id);
     parent::save();
     if (!$isnew) {
         // If this setting is changed, we need to update the existing curriclum expiration values (ELIS-1172)
         if ($rs = $this->_db->get_recordset_select(curriculumstudent::TABLE, "timecompleted = 0 AND curriculumid = {$this->id}", null, 'id, userid')) {
             $timenow = time();
             foreach ($rs as $rec) {
                 $update = new stdClass();
                 $update->id = $rec->id;
                 $update->timeexpired = calculate_curriculum_expiry(NULL, $this->id, $rec->userid);
                 $update->timemodified = $timenow;
                 $this->_db->update_record(curriculumstudent::TABLE, $update);
             }
             $rs->close();
         }
     }
     field_data::set_for_context_from_datarecord(CONTEXT_ELIS_PROGRAM, $this);
 }
예제 #10
0
 public function save()
 {
     $isnew = empty($this->id);
     parent::save();
     if (isset($this->track) && is_array($this->track)) {
         $param['classid'] = $this->id;
         $param['courseid'] = $this->courseid;
         foreach ($this->track as $t) {
             if (trackassignment::exists(array(new field_filter('classid', $this->id), new field_filter('trackid', $t)))) {
                 continue;
             }
             $param['trackid'] = $t;
             $trackassignobj = new trackassignment($param);
             $trackassignobj->save();
         }
     }
     if (isset($this->unlink_attached_course) && isset($this->moodlecourseid)) {
         // process unlink moodle course id request
         $return = moodle_detach_class($this->id, $this->moodlecourseid);
         $this->moodlecourseid = 0;
     }
     if ($this->moodlecourseid || $this->autocreate) {
         moodle_attach_class($this->id, $this->moodlecourseid, '', true, true, $this->autocreate);
     }
     if (!$isnew) {
         if (!empty($this->oldmax) && (!$this->maxstudents || $this->oldmax < $this->maxstudents) && ($waiting = waitlist::count_records($this->id)) > 0) {
             $start = student_count_records($this->id);
             $max = $this->maxstudents ? $this->maxstudents : $start + $waiting + 1;
             //error_log("pmclass.class.php::save() oldmax = {$this->oldmax}, start = {$start}, newmax = {$this->maxstudents}, waiting = {$waiting} ... max = {$max}");
             for ($i = $start; $i < $max; $i++) {
                 $next_student = waitlist::get_next($this->id);
                 if (empty($next_student)) {
                     break;
                 }
                 $next_student->enrol();
             }
         }
     }
     field_data::set_for_context_from_datarecord(CONTEXT_ELIS_CLASS, $this);
 }