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


PHP student::delete方法代码示例

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


在下文中一共展示了student::delete方法的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: do_unenrol

 /**
  * do_unenrol() new method to unenrol user from class instance
  * ELIS-8524
  */
 public function do_unenrol()
 {
     $stuid = $this->optional_param('stuid', 0, PARAM_INT);
     $wlid = $this->optional_param('wlid', 0, PARAM_INT);
     if (!empty($stuid) && ($stu = new student($stuid))) {
         $stu->delete();
     } else {
         if (!empty($wlid) && ($waitlist = new waitlist($wlid))) {
             $waitlist->delete();
         }
     }
     $this->display('available');
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:17,代码来源:coursecatalogpage.class.php

示例3: class_enrolment_delete

 /**
  * Performs class_enrolment deletion
  * @throws moodle_exception If there was an error in passed parameters.
  * @throws data_object_exception If there was an error deleting the association.
  * @param array $data The incoming data parameter.
  * @return array An array of parameters, if successful.
  */
 public static function class_enrolment_delete(array $data)
 {
     global $DB, $USER;
     if (static::require_elis_dependencies() !== true) {
         throw new moodle_exception('ws_function_requires_elis', 'local_datahub');
     }
     // Parameter validation.
     $params = self::validate_parameters(self::class_enrolment_delete_parameters(), array('data' => $data));
     // Context validation.
     $context = context_user::instance($USER->id);
     self::validate_context($context);
     $data = (object) $data;
     // Parse class
     if (empty($data->class_idnumber) || !($classid = $DB->get_field(pmclass::TABLE, 'id', array('idnumber' => $data->class_idnumber)))) {
         throw new data_object_exception('ws_class_enrolment_delete_fail_invalid_class', 'local_datahub', '', $data);
     }
     // Capability checking.
     require_capability('local/elisprogram:class_enrol', \local_elisprogram\context\pmclass::instance($classid));
     // Initialize version1elis importplugin for utility functions.
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     $userparams = array();
     $userid = $importplugin->get_userid_from_record($data, '', $userparams);
     if ($userid == false) {
         $a = new stdClass();
         if (empty($userparams)) {
             $a->userparams = '{empty}';
         } else {
             $a->userparams = '';
             foreach ($userparams as $userfield => $uservalue) {
                 $subfield = strpos($userfield, '_');
                 $userfield = substr($userfield, $subfield === false ? 0 : $subfield + 1);
                 if (!empty($a->userparams)) {
                     $a->userparams .= ', ';
                 }
                 $a->userparams .= "{$userfield}: '{$uservalue}'";
             }
         }
         throw new data_object_exception('ws_class_enrolment_delete_fail_invalid_user', 'local_datahub', '', $a);
     }
     $id = $DB->get_field(student::TABLE, 'id', array('classid' => $classid, 'userid' => $userid));
     // Respond.
     if (!empty($id) && ($stu = new student($id))) {
         $stu->delete();
         return array('messagecode' => get_string('ws_class_enrolment_delete_success_code', 'local_datahub'), 'message' => get_string('ws_class_enrolment_delete_success_msg', 'local_datahub'));
     } else {
         throw new data_object_exception('ws_class_enrolment_delete_fail', 'local_datahub');
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:55,代码来源:class_enrolment_delete.class.php

示例4: array

 /**
  * Delete 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
  */
 function class_enrolment_delete_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;
     }
     $userid = $this->get_userid_from_record($record, $filename);
     // string to describe the user
     $user_descriptor = $this->get_user_descriptor($record, false, 'user_');
     if (!$DB->record_exists(student::TABLE, array('classid' => $crsid, 'userid' => $userid))) {
         $this->fslogger->log_failure("User with {$user_descriptor} is not enrolled in class instance \"{$idnumber}\" as student.", 0, $filename, $this->linenumber, $record, "enrolment");
         return false;
     }
     if (!$this->validate_class_enrolment_data('delete', $record, $filename)) {
         return false;
     }
     // obtain the class id
     $classid = $DB->get_field(pmclass::TABLE, 'id', array('idnumber' => $idnumber));
     // delete the association
     $studentid = $DB->get_field(student::TABLE, 'id', array('userid' => $userid, 'classid' => $classid));
     $student = new student($studentid);
     $student->load();
     $student->delete();
     // log success
     $success_message = "User with {$user_descriptor} successfully unenrolled from class instance \"{$idnumber}\" as a student.";
     $this->fslogger->log_success($success_message, 0, $filename, $this->linenumber);
     return true;
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:41,代码来源:version1elis.class.php

示例5: test_delete_enrols_waitlist

 public function test_delete_enrols_waitlist()
 {
     global $DB;
     $this->load_csv_data();
     $student = new student(array('userid' => 104, 'classid' => 100));
     $student->load();
     $student->save();
     $class = new pmclass(100);
     $class->load();
     $class->maxstudents = 1;
     $class->save();
     try {
         $student->delete();
     } catch (Exception $e) {
         $this->assertEquals(get_string('message_nodestinationuser', 'local_elisprogram'), $e->getMessage());
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:17,代码来源:student_test.php


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