/**
  *  make sure the start time is before the end time and the start date is before the end date for the class
  * @param array $data
  * @param mixed $files
  * @return array
  */
 function validation($data, $files)
 {
     global $CURMAN;
     $errors = parent::validation($data, $files);
     if ($CURMAN->db->record_exists_select(CLSTABLE, "idnumber = '{$data['idnumber']}'" . ($data['id'] ? " AND id != {$data['id']}" : ''))) {
         $errors['idnumber'] = get_string('idnumber_already_used', 'block_curr_admin');
     }
     if ($data['starttime'] > $data['endtime']) {
         $errors['starttime'] = get_string('error_duration', 'block_curr_admin');
     }
     if (!empty($data['startdate']) && !empty($data['enddate']) && !empty($data['disablestart']) && !empty($data['disableend'])) {
         if ($data['startdate'] > $data['enddate']) {
             $errors['start'] = get_string('error_date_range', 'block_curr_admin');
         }
     }
     if (!empty($this->_customdata['obj']) && !empty($this->_customdata['obj']->maxstudents)) {
         if ($data['maxstudents'] < $this->_customdata['obj']->maxstudents && $data['maxstudents'] < student::count_enroled($this->_customdata['obj']->id)) {
             $context = get_context_instance(CONTEXT_SYSTEM);
             if (!has_capability('block/curr_admin:overrideclasslimit', $context)) {
                 $errors['maxstudents'] = get_string('error_n_overenrol', 'block_curr_admin');
             }
         }
     }
     return $errors;
 }
示例#2
0
 /**
  * Perform all necessary tasks to remove a student enrolment from the system.
  */
 function delete()
 {
     /// Remove any grade records for this enrolment.
     $result = student_grade::delete_for_user_and_class($this->userid, $this->classid);
     /// Unenrol them from the Moodle class.
     if (!empty($this->classid) && !empty($this->userid) && ($moodlecourseid = get_field('crlm_class_moodle', 'moodlecourseid', 'classid', $this->classid)) && ($muserid = cm_get_moodleuserid($this->userid))) {
         $context = get_context_instance(CONTEXT_COURSE, $moodlecourseid);
         if ($context && $context->id) {
             role_unassign(0, $muserid, 0, $context->id);
         }
     }
     $result = $result && $this->data_delete_record();
     if ($this->completestatusid == STUSTATUS_NOTCOMPLETE) {
         $cmclass = new cmclass($this->classid);
         if (empty($cmclass->maxstudents) || $cmclass->maxstudents > student::count_enroled($cmclass->id)) {
             $wlst = waitlist::get_next($this->classid);
             if (!empty($wlst)) {
                 $wlst->enrol();
             }
         }
     }
     return $result;
 }
示例#3
0
 function get_item_display_options($column, $class)
 {
     $classobj = new pmclass($class);
     if (!$classobj->is_enrollable()) {
         return get_string('notenrollable', 'enrol');
     }
     if (student::count_enroled($class->id) < $class->maxstudents || empty($class->maxstudents)) {
         $action = 'savenew';
     } else {
         $action = 'confirmwaitlist';
     }
     return '<a href="index.php?s=crscat&amp;section=curr&amp;clsid=' . "{$class->id}&amp;action={$action}\">" . get_string('choose') . '</a>';
 }
示例#4
0
 public static function check_autoenrol_after_course_completion($enrolment)
 {
     if ($enrolment->completestatusid != STUSTATUS_NOTCOMPLETE) {
         $pmclass = new pmclass($enrolment->classid);
         $pmclass->load();
         if ((empty($pmclass->maxstudents) || $pmclass->maxstudents > student::count_enroled($pmclass->id)) && !empty($pmclass->enrol_from_waitlist)) {
             $wlst = waitlist::get_next($enrolment->classid);
             if (!empty($wlst)) {
                 $crsid = $pmclass->course->id;
                 foreach ($pmclass->course->curriculumcourse as $curcrs) {
                     if ($curcrs->courseid == $crsid && $curcrs->prerequisites_satisfied($wlst->userid)) {
                         $wlst->enrol();
                     }
                 }
             }
         }
     }
     return true;
 }
示例#5
0
 /**
  *  make sure the start time is before the end time and the start date is before the end date for the class
  * @param array $data
  * @param mixed $files
  * @return array
  */
 function validation($data, $files)
 {
     global $DB;
     $errors = parent::validation($data, $files);
     $sql = 'idnumber = ?';
     $params = array($data['idnumber']);
     if ($data['id']) {
         $sql .= ' AND id != ?';
         $params[] = $data['id'];
     }
     if ($DB->record_exists_select(pmclass::TABLE, $sql, $params)) {
         $errors['idnumber'] = get_string('idnumber_already_used', 'local_elisprogram');
     }
     if (isset($data['starttime']) && isset($data['endtime'])) {
         if ($data['starttime'] > $data['endtime']) {
             $errors['starttime'] = get_string('error_duration', 'local_elisprogram');
         }
         if (!empty($data['startdate']) && !empty($data['enddate']) && !empty($data['disablestart']) && !empty($data['disableend'])) {
             if ($data['startdate'] > $data['enddate']) {
                 $errors['start'] = get_string('error_date_range', 'local_elisprogram');
             }
         }
     }
     if (!empty($this->_customdata['obj']) && !empty($this->_customdata['obj']->maxstudents)) {
         if ($data['maxstudents'] < $this->_customdata['obj']->maxstudents && $data['maxstudents'] < student::count_enroled($this->_customdata['obj']->id)) {
             $context = context_system::instance();
             if (!has_capability('local/elisprogram:overrideclasslimit', $context)) {
                 $errors['maxstudents'] = get_string('error_n_overenrol', 'local_elisprogram');
             }
         }
     }
     $errors += parent::validate_custom_fields($data, 'class');
     return $errors;
 }
示例#6
0
 public function check_autoenrol_after_course_completion($enrolment)
 {
     if ($enrolment->completestatusid != STUSTATUS_NOTCOMPLETE) {
         $cmclass = new cmclass($enrolment->classid);
         if ((empty($cmclass->maxstudents) || $cmclass->maxstudents > student::count_enroled($cmclass->id)) && !empty($cmclass->enrol_from_waitlist)) {
             $wlst = waitlist::get_next($enrolment->classid);
             if (!empty($wlst)) {
                 $wlst->enrol();
             }
         }
     }
     return true;
 }