本文整理汇总了PHP中student::update方法的典型用法代码示例。如果您正苦于以下问题:PHP student::update方法的具体用法?PHP student::update怎么用?PHP student::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类student
的用法示例。
在下文中一共展示了student::update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pm_update_student_enrolment
/**
* Notifies that students have not passed their classes via the notifications where applicable,
* setting enrolment status to failed where applicable
*
* @param int $pmuserid optional userid to update, default(0) updates all users
*/
function pm_update_student_enrolment($pmuserid = 0)
{
global $DB;
require_once elispm::lib('data/student.class.php');
require_once elispm::lib('notifications.php');
//look for all enrolments where status is incomplete / in progress and end time has passed
$select = 'completestatusid = :status AND endtime > 0 AND endtime < :time';
$params = array('status' => STUSTATUS_NOTCOMPLETE, 'time' => time());
if ($pmuserid) {
$select .= ' AND userid = :userid';
$params['userid'] = $pmuserid;
}
$students = $DB->get_recordset_select(student::TABLE, $select, $params);
if (!empty($students)) {
foreach ($students as $s) {
// Send notification, if enabled.
$sendnotification = !empty(elis::$config->local_elisprogram->notify_incompletecourse_user) ? true : false;
if ($sendnotification === true) {
$a = $DB->get_field(pmclass::TABLE, 'idnumber', array('id' => $s->classid));
$message = get_string('incomplete_course_message', 'local_elisprogram', $a);
$cuser = new user($s->userid);
$from = get_admin();
notification::notify($message, $cuser, $from);
}
//set status to failed
$s->completetime = time();
$s->completestatusid = STUSTATUS_FAILED;
$stu = new student($s->id);
$stu->set_from_data($s);
$stu->update();
}
}
return true;
}
示例2: 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();
}