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


PHP student::complete方法代码示例

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


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

示例1: array

 /**
  *
  */
 function action_updatemultiple()
 {
     global $CURMAN;
     $clsid = $this->required_param('id', PARAM_INT);
     $users = $this->optional_param('users', array());
     foreach ($users as $uid => $user) {
         $sturecord = array();
         $sturecord['id'] = $user['association_id'];
         $sturecord['classid'] = $clsid;
         $sturecord['userid'] = $uid;
         $startyear = $user['startyear'];
         $startmonth = $user['startmonth'];
         $startday = $user['startday'];
         $sturecord['enrolmenttime'] = mktime(0, 0, 0, $startmonth, $startday, $startyear);
         $endyear = $user['endyear'];
         $endmonth = $user['endmonth'];
         $endday = $user['endday'];
         $sturecord['completetime'] = mktime(0, 0, 0, $endmonth, $endday, $endyear);
         $sturecord['completestatusid'] = $user['completestatusid'];
         $sturecord['grade'] = $user['grade'];
         $sturecord['credits'] = $user['credits'];
         $sturecord['locked'] = !empty($user['locked']) ? 1 : 0;
         $stu = new student($sturecord);
         if ($stu->completestatusid == STUSTATUS_PASSED && $CURMAN->db->get_field(STUTABLE, 'completestatusid', 'id', $stu->id) != STUSTATUS_PASSED) {
             $stu->complete();
         } else {
             if (($status = $stu->update()) !== true) {
                 echo cm_error('Record not updated.  Reason: ' . $status->message);
             }
         }
         // Now once we've done all this, delete the student if we've been asked to
         if (isset($user['unenrol']) && cmclasspage::can_enrol_into_class($clsid)) {
             $stu_delete = new student($user['association_id']);
             if (!$stu_delete->delete()) {
                 echo cm_error('Student "name: ' . cm_fullname($stu->user) . '" not unenrolled.');
             }
         }
     }
     $this->action_default();
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:43,代码来源:studentpage.class.php

示例2: array

 /**
  * Update grades for this class
  *
  * @param array The class grades
  */
 function update_all_class_grades($classgrades = array())
 {
     global $CURMAN;
     if (isset($this->course) && get_class($this->course) == 'course') {
         $elements = $this->course->get_completion_elements();
     } else {
         $elements = false;
     }
     $timenow = time();
     if (!empty($elements)) {
         // for each student, find out how many required completion elements are
         // incomplete, and when the last completion element was graded
         $sql = "SELECT s.*, grades.incomplete, grades.maxtime\n                      FROM {$CURMAN->db->prefix_table(STUTABLE)} s\n                      JOIN (SELECT s.userid, COUNT(CASE WHEN grades.id IS NULL AND cc.required = 1 THEN 1\n                                                        ELSE NULL END) AS incomplete,\n                                    MAX(timegraded) AS maxtime\n                              FROM {$CURMAN->db->prefix_table(STUTABLE)} s\n                              JOIN {$CURMAN->db->prefix_table(CRSCOMPTABLE)} cc\n                                   ON cc.courseid = {$this->courseid}\n                         LEFT JOIN {$CURMAN->db->prefix_table(CLSGRTABLE)} grades\n                                   ON grades.userid = s.userid\n                                      AND grades.completionid = cc.id\n                                      AND grades.classid = {$this->id}\n                                      AND grades.grade >= cc.completion_grade\n                             WHERE s.classid = {$this->id} AND s.locked = 0\n                          GROUP BY s.userid\n                           ) grades ON grades.userid = s.userid\n                     WHERE s.classid = {$this->id} AND s.locked = 0";
         $rs = get_recordset_sql($sql);
         if ($rs) {
             while ($rec = rs_fetch_next_record($rs)) {
                 if ($rec->incomplete == 0 && $rec->grade > 0 && $rec->grade >= $this->course->completion_grade) {
                     $student = new student($rec, $this, null);
                     $student->completestatusid = STUSTATUS_PASSED;
                     $student->completetime = $rec->maxtime;
                     $student->credits = $this->course->credits;
                     $student->locked = 1;
                     $student->complete();
                 }
             }
         }
     } else {
         /// We have no completion elements so just make sure the user's grade is at least the
         /// minimum value required for the course.
         /// Get all unlocked enrolments
         $select = "classid = {$this->id} AND locked = 0";
         $rs = get_recordset_select(STUTABLE, $select, 'userid');
         if ($rs) {
             while ($rec = rs_fetch_next_record($rs)) {
                 if ($rec->grade > 0 && $rec->grade >= $this->course->completion_grade) {
                     $student = new student($rec, $this, null);
                     $student->completestatusid = STUSTATUS_PASSED;
                     $student->completetime = $timenow;
                     $student->credits = $this->course->credits;
                     $student->locked = 1;
                     $student->complete();
                 }
             }
         }
     }
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:51,代码来源:cmclass.class.php

示例3: class_enrolment_update_student

 /**
  * Update a student class instance enrolment
  *
  * @param object $record One record of import data
  * @param string $filename The import file name, used for logging
  * @param string $idnumber The idnumber of the class instance
  *
  * @return boolean true on success, otherwise false
  */
 public function class_enrolment_update_student($record, $filename, $idnumber)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
     require_once elispm::lib('data/pmclass.class.php');
     require_once elispm::lib('data/student.class.php');
     if (!($crsid = $DB->get_field(pmclass::TABLE, 'id', array('idnumber' => $idnumber)))) {
         $this->fslogger->log_failure("instance value of \"{$idnumber}\" does not refer to a valid instance of a class context.", 0, $filename, $this->linenumber, $record, "enrolment");
         return false;
     }
     if (!$this->validate_class_enrolment_data('update', $record, $filename)) {
         return false;
     }
     //obtain the class id
     $classid = $DB->get_field(pmclass::TABLE, 'id', array('idnumber' => $idnumber));
     //obtain the user id
     $userid = $this->get_userid_from_record($record, $filename);
     //update the record
     $id = $DB->get_field(student::TABLE, 'id', array('classid' => $classid, 'userid' => $userid));
     $student = new student($id);
     //need to call load because saving a student needs the full object for events
     //and dynamic loading will blow away changes otherwise
     $student->load();
     $student->userid = $userid;
     //enrolment and completion times
     if (isset($record->enrolmenttime)) {
         $student->enrolmenttime = $this->parse_date($record->enrolmenttime);
     }
     if (isset($record->completetime)) {
         $student->completetime = $this->parse_date($record->completetime);
     }
     $completestatusid = $this->get_completestatusid($record);
     //set up a completion status, if set
     if ($completestatusid !== NULL) {
         $student->completestatusid = $completestatusid;
     }
     if (isset($record->grade)) {
         $student->grade = $record->grade;
     }
     if (isset($record->credits)) {
         $student->credits = $record->credits;
     }
     if (isset($record->locked)) {
         $student->locked = $record->locked;
     }
     //TODO: consider refactoring once ELIS-6546 is resolved
     if (isset($student->completestatusid) && $student->completestatusid == STUSTATUS_PASSED && $DB->get_field(student::TABLE, 'completestatusid', array('id' => $student->id)) != STUSTATUS_PASSED) {
         $student->complete();
     } else {
         try {
             $student->save();
         } catch (Exception $e) {
             // Student save may attempt to sync ELIS user to Moodle.
             $useridnumber = $student->users->idnumber;
             $this->fslogger->log_failure("Error creating associated Moodle user for idnumber \"{$useridnumber}\": " . $e->getMessage(), 0, $filename, $this->linenumber, $record, "enrolment");
             return false;
         }
     }
     //string to describe the user
     $user_descriptor = $this->get_user_descriptor($record, false, 'user_');
     //log success
     $success_message = "Student enrolment for user with {$user_descriptor} in class instance \"{$idnumber}\" successfully updated.";
     $this->fslogger->log_success($success_message, 0, $filename, $this->linenumber);
     return true;
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:74,代码来源:version1elis.class.php

示例4: do_update

 /**
  * Perform an update for a single user/class pair.
  *
  * @param int $userid The user ID we're updating.
  * @param int $classid The class ID we're updating information for.
  * @param array $enroldata The updated enrolment data.
  * @param array $learningobjectives The updated learning objective data.
  */
 protected function do_update($userid, $classid, array $enroldata, array $learningobjectives)
 {
     global $DB;
     if (student::can_manage_assoc($userid, $classid) !== true) {
         throw new Exception('Unauthorized');
     }
     if (!isset($enroldata['id'])) {
         $associationid = $DB->get_field(student::TABLE, 'id', array('classid' => $classid, 'userid' => $userid));
         if (empty($associationid)) {
             return false;
         } else {
             $enroldata['id'] = $associationid;
         }
     }
     $enroldata['userid'] = $userid;
     $stu = new student($enroldata);
     if ($stu->completestatusid == STUSTATUS_PASSED && $DB->get_field(student::TABLE, 'completestatusid', array('id' => $stu->id)) != STUSTATUS_PASSED) {
         $stu->complete();
     } else {
         $status = $stu->save();
     }
     foreach ($learningobjectives as $id => $data) {
         $graderec = array('userid' => $userid, 'classid' => $classid, 'completionid' => $id);
         $existingrec = $DB->get_record(student_grade::TABLE, $graderec);
         if (!empty($existingrec)) {
             $graderec = (array) $existingrec;
         }
         $graderec['timegraded'] = $data['timegraded'];
         $graderec['grade'] = $data['grade'];
         $graderec['locked'] = $data['locked'];
         $sgrade = new student_grade($graderec);
         $sgrade->save();
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:42,代码来源:enroledit.action.php

示例5: course

 /**
  * Update enrolment status of users enroled in the current class, completing and locking
  * records where applicable based on class grade and required completion elements
  *
  * @param int $pmuserid  optional userid to update, default(0) updates all users
  */
 function update_enrolment_status($pmuserid = 0)
 {
     //information about which course this belongs to may not have been
     //loaded due to lazy-loading
     $this->load();
     //        if (isset($this->course) && (get_class($this->course) == 'course')) {
     if (isset($this->courseid)) {
         $course = new course($this->courseid);
         $elements = $course->get_completion_elements();
     } else {
         $elements = false;
     }
     $timenow = time();
     if (!empty($elements) && $elements->valid() === true) {
         // for each student, find out how many required completion elements are
         // incomplete, and when the last completion element was graded
         $sql = 'SELECT s.*, grades.incomplete, grades.maxtime
                   FROM {' . student::TABLE . '} s
                   JOIN (SELECT s.userid, COUNT(CASE WHEN grades.id IS NULL AND cc.required = 1 THEN 1
                                                     ELSE NULL END) AS incomplete,
                                 MAX(timegraded) AS maxtime
                           FROM {' . student::TABLE . '} s
                           JOIN {' . coursecompletion::TABLE . '} cc
                                ON cc.courseid = :courseid
                      LEFT JOIN {' . student_grade::TABLE . '} grades
                                ON grades.userid = s.userid
                                   AND grades.completionid = cc.id
                                   AND grades.classid = :joinclassid
                                   AND grades.grade >= cc.completion_grade
                          WHERE s.classid = :innerclassid AND s.locked = 0
                       GROUP BY s.userid
                        ) grades ON grades.userid = s.userid
                  WHERE s.classid = :outerclassid AND s.locked = 0';
         $params = array('courseid' => $this->courseid, 'joinclassid' => $this->id, 'innerclassid' => $this->id, 'outerclassid' => $this->id);
         if ($pmuserid) {
             $sql .= ' AND s.userid = :userid';
             $params['userid'] = $pmuserid;
         }
         $rs = $this->_db->get_recordset_sql($sql, $params);
         foreach ($rs as $rec) {
             if ($rec->incomplete == 0 && $rec->grade > 0 && $rec->grade >= $this->course->completion_grade) {
                 $student = new student($rec);
                 $student->completestatusid = STUSTATUS_PASSED;
                 $student->completetime = $rec->maxtime;
                 $student->credits = $this->course->credits;
                 $student->locked = 1;
                 $student->complete();
             }
         }
     } else {
         /// We have no completion elements so just make sure the user's grade is at least the
         /// minimum value required for the course.
         /// Get all unlocked enrolments
         $stufilters = array(new field_filter('classid', $this->id), new field_filter('locked', 0));
         if ($pmuserid) {
             $stufilters[] = new field_filter('userid', $pmuserid);
         }
         $rs = student::find($stufilters);
         foreach ($rs as $rec) {
             if ($rec->grade > 0 && $rec->grade >= $this->course->completion_grade) {
                 $rec->completestatusid = STUSTATUS_PASSED;
                 $rec->completetime = $timenow;
                 $rec->credits = $this->course->credits;
                 $rec->locked = 1;
                 $rec->complete();
             }
         }
     }
     unset($elements);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:76,代码来源:pmclass.class.php


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