当前位置: 首页>>代码示例>>PHP>>正文


PHP student::add方法代码示例

本文整理汇总了PHP中student::add方法的典型用法代码示例。如果您正苦于以下问题:PHP student::add方法的具体用法?PHP student::add怎么用?PHP student::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在student的用法示例。


在下文中一共展示了student::add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 /**
  * When a role is selected from the sync configuration, create class
  * enrolments for the specified role assignments.
  */
 static function student_sync_role_set()
 {
     require_once CURMAN_DIRLOCATION . '/lib/student.class.php';
     global $CURMAN;
     $contextlevel = context_level_base::get_custom_context_level('class', 'block_curr_admin');
     // find all class role assignments
     $sql = "SELECT ra.id, cu.id AS userid, ctx.instanceid AS classid\n                  FROM {$CURMAN->db->prefix_table('role_assignments')} ra\n                  JOIN {$CURMAN->db->prefix_table('user')} mu ON ra.userid = mu.id\n                  JOIN {$CURMAN->db->prefix_table('crlm_user')} cu ON mu.idnumber = cu.idnumber\n                  JOIN {$CURMAN->db->prefix_table('context')} ctx ON ctx.id = ra.contextid\n                 WHERE ctx.contextlevel = {$contextlevel}\n                   AND ra.roleid = {$CURMAN->config->enrolment_role_sync_student_role}";
     $studentswanted = $CURMAN->db->get_records_sql($sql);
     $studentswanted = $studentswanted ? $studentswanted : array();
     foreach ($studentswanted as $student) {
         unset($student->id);
         $student = new student($student);
         $student->add();
     }
     return true;
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:20,代码来源:lib.php

示例2: action_waitlistconfirm

 /**
  *
  */
 public function action_waitlistconfirm()
 {
     $id = required_param('userid', PARAM_INT);
     $form_url = new moodle_url(null, array('s' => $this->pagename, 'section' => $this->section, 'action' => 'waitlistconfirm'));
     $waitlistform = new waitlistaddform($form_url, array('student_ids' => $id));
     if ($data = $waitlistform->get_data()) {
         $now = time();
         foreach ($data->userid as $uid) {
             if (isset($data->enrol[$uid]) && isset($data->classid[$uid]) && isset($data->enrolmenttime[$uid])) {
                 if ($data->enrol[$uid] == 1) {
                     $wait_record = new object();
                     $wait_record->userid = $uid;
                     $wait_record->classid = $data->classid[$uid];
                     $wait_record->enrolmenttime = $data->enrolmenttime[$uid];
                     $wait_record->timecreated = $now;
                     $wait_record->position = 0;
                     $wait_list = new waitlist($wait_record);
                     $wait_list->add();
                 } else {
                     if ($data->enrol[$uid] == 2) {
                         $user = new user($uid);
                         $student_data = array();
                         $student_data['classid'] = $data->classid[$uid];
                         $student_data['userid'] = $uid;
                         $student_data['enrolmenttime'] = $data->enrolmenttime[$uid];
                         $student_data['timecreated'] = $now;
                         $student_data['completestatusid'] = STUSTATUS_NOTCOMPLETE;
                         $newstu = new student($student_data);
                         $status = $newstu->add();
                         if ($status !== true) {
                             if (!empty($status->message)) {
                                 echo cm_error(get_string('record_not_created_reason', 'block_curr_admin', $status->message));
                             } else {
                                 echo cm_error(get_string('record_not_created', 'block_curr_admin'));
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->action_default();
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:46,代码来源:studentpage.class.php

示例3: enrol

 /**
  * Enrols a user in a track.
  *
  * @param int $userid The user id
  * @param int $trackid The track id
  */
 static function enrol($userid, $trackid)
 {
     global $CURMAN;
     // make sure we don't double-enrol
     if ($CURMAN->db->record_exists(USRTRKTABLE, 'userid', $userid, 'trackid', $trackid)) {
         return false;
     }
     $record = new usertrack();
     $record->userid = $userid;
     $record->trackid = $trackid;
     $record->data_insert_record();
     $user = new user($userid);
     $track = new track($trackid);
     // add the student to the associated curriculum, if they're not already
     // enrolled
     if (!$CURMAN->db->record_exists(CURASSTABLE, 'userid', $userid, 'curriculumid', $track->curid)) {
         $curstu = new curriculumstudent();
         $curstu->userid = $userid;
         $curstu->curriculumid = $track->curid;
         $curstu->completed = 0;
         $curstu->credits = 0;
         $curstu->locked = 0;
         $curstu->add();
     }
     events_trigger('track_assigned', $record);
     /**
      * Get autoenrollable classes in the track.  Classes are autoenrollable
      * if:
      * - the autoenrol flag is set
      * - it is the only class in that course slot for the track
      */
     $sql = 'SELECT classid, courseid ' . 'FROM ' . $CURMAN->db->prefix_table(TRACKCLASSTABLE) . ' ' . 'WHERE trackid = \'' . $trackid . '\' ' . 'GROUP BY courseid ' . 'HAVING COUNT(*) = 1 AND MAX(autoenrol) = 1';
     $classes = $CURMAN->db->get_records_sql($sql);
     if (!empty($classes)) {
         foreach ($classes as $class) {
             // enrol user in each autoenrolable class
             $stu_record = new object();
             $stu_record->userid = $userid;
             $stu_record->classid = $class->classid;
             $stu_record->enrolmenttime = time();
             $enrolment = new student($stu_record);
             // check prerequisites and enrolment limits
             $enrolment->add(array('prereq' => 1, 'waitlist' => 1), true);
         }
     }
     return true;
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:53,代码来源:usertrack.class.php

示例4: EXISTS

 function enrol_all_track_users_in_class()
 {
     global $CURMAN;
     // find all users who are not enrolled in the class
     $users = $CURMAN->db->get_records_select('crlm_user_track', "NOT EXISTS (SELECT 'x'\n                                FROM {$CURMAN->db->prefix_table(STUTABLE)} s\n                                WHERE s.classid = {$this->classid} AND s.userid = {$CURMAN->db->prefix_table('crlm_user_track')}.userid)\n                  AND trackid = {$this->trackid}", 'userid');
     if ($users) {
         $timenow = time();
         $count = 0;
         $waitlisted = 0;
         $prereq = 0;
         foreach ($users as $user) {
             // enrol user in track
             $enrol = new student();
             $enrol->classid = $this->classid;
             $enrol->userid = $user->userid;
             $enrol->enrolmenttime = $timenow;
             $result = $enrol->add(array('prereq' => 1, 'waitlist' => 1));
             if ($result === true) {
                 $count++;
             } elseif (is_object($result)) {
                 if ($result->code = 'user_waitlisted') {
                     $waitlisted++;
                 } elseif ($result->code = 'user_waitlisted') {
                     $prereq++;
                 }
             }
         }
         print_string('n_users_enrolled', 'block_curr_admin', $count);
         if ($waitlisted) {
             print_string('n_users_waitlisted', 'block_curr_admin', $waitlisted);
         }
         if ($prereq) {
             print_string('n_users_unsatisfied_prereq', 'block_curr_admin', $prereq);
         }
     } else {
         print_string('all_users_already_enrolled', 'block_curr_admin');
     }
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:38,代码来源:track.class.php

示例5: enrol

 /**
  *
  * @global object $CFG
  * @global object $CURMAN 
  */
 public function enrol()
 {
     global $CFG, $CURMAN;
     $this->data_delete_record();
     $class = new cmclass($this->classid);
     $courseid = $class->get_moodle_course_id();
     // enrol directly in the course
     $student = new student($this);
     $student->enrolmenttime = max(time(), $class->startdate);
     $student->add();
     if ($courseid) {
         $course = $CURMAN->db->get_record('course', 'id', $this->id);
         // the elis plugin is treated specially
         if ($course->enrol != 'elis') {
             // send the user to the Moodle enrolment page
             $a = new stdClass();
             $a->crs = $course;
             $a->class = $class;
             $a->wwwroot = $CFG->wwwroot;
             $subject = get_string('moodleenrol_subj', 'block_curr_admin', $a);
             $message = get_string('moodleenrol', 'block_curr_admin', $a);
         }
     }
     if (!isset($message)) {
         $a = $class->idnumber;
         $subject = get_string('nowenroled', 'block_curr_admin', $a);
         $message = get_string('nowenroled', 'block_curr_admin', $a);
     }
     $user = cm_get_moodleuser($this->userid);
     $from = get_admin();
     notification::notify($message, $user, $from);
     email_to_user($user, $from, $subject, $message);
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:38,代码来源:waitlist.class.php

示例6: cmclass

 function action_savenew()
 {
     global $USER, $CFG, $CURMAN;
     $clsid = cm_get_param('clsid', 0);
     $class = new cmclass($clsid);
     if (!$class->is_enrollable()) {
         print_error('notenrollable');
     }
     // check if class is full
     if (!empty($class->maxstudents) && student::count_enroled($class->id) >= $class->maxstudents) {
         $form = $this->create_waitlistform($classid);
         $form->display();
         return;
     }
     // call the Moodle enrolment plugin if attached to a Moodle course, and
     // it's not the elis plugin
     $courseid = $class->get_moodle_course_id();
     if ($courseid) {
         $course = $CURMAN->db->get_record('course', 'id', $courseid);
         // the elis plugin is treated specially
         if ($course->enrol != 'elis') {
             // FIXME: add message
             redirect("{$CFG->wwwroot}/course/enrol.php?id={$courseid}");
         }
     }
     $cuserid = cm_get_crlmuserid($USER->id);
     $sturecord = array();
     $sturecord['classid'] = $class->id;
     $sturecord['userid'] = $cuserid;
     $sturecord['enrolmenttime'] = max(time(), $class->startdate);
     $sturecord['completetime'] = 0;
     $newstu = new student($sturecord);
     if (($status = $newstu->add()) !== true) {
         if (!empty($status->message)) {
             echo cm_error('Record not created. Reason: ' . $status->message);
         } else {
             echo cm_error('Record not created.');
         }
     }
     $this->action_default();
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:41,代码来源:coursecatalogpage.class.php


注:本文中的student::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。