本文整理汇总了PHP中student::save方法的典型用法代码示例。如果您正苦于以下问题:PHP student::save方法的具体用法?PHP student::save怎么用?PHP student::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类student
的用法示例。
在下文中一共展示了student::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_student_save_nouserobject
/**
* Test student save works when $USER object not set
*/
public function test_student_save_nouserobject()
{
global $DB, $USER;
// Create Moodle course category.
$crscat = create_course_category((object) array('name' => 'Test Course category', 'idnumber' => 'MCC-1'));
// Create Moodle course.
$crsdata = array('category' => $crscat->id, 'fullname' => 'MC-TEST-ELIS-8484', 'shortname' => 'MC-TEST-ELIS-8484', 'idnumber' => 'MC-TEST-ELIS-8484');
$mdlcrs = new stdClass();
$mdlcrs->id = $DB->insert_record('course', (object) $crsdata);
$cddata = array('name' => 'CD-ELIS-8484', 'code' => 'CD-ELIS-8484', 'idnumber' => 'CD-ELIS-8484', 'syllabus' => 'syllabus');
$cd = new course($cddata);
$cd->save();
$ci = new pmclass(array('idnumber' => 'CI-ELIS-8484', 'courseid' => $cd->id, 'moodlecourseid' => $mdlcrs->id, 'autocreate' => 0));
$ci->save();
$testuser = new user(array('idnumber' => 'testuserelis8484', 'username' => 'testuserelis8484', 'firstname' => 'Test', 'lastname' => 'User-ELIS8484', 'email' => 'tu8484@noreply.com', 'city' => 'Waterloo', 'country' => 'CA'));
$testuser->save();
$USER = null;
$sturec = new stdClass();
$sturec->userid = $testuser->id;
$sturec->classid = $ci->id;
$sturec->grade = 0;
$sturec->enrolmenttime = time();
$student = new student($sturec);
$student->save();
$this->assertFalse(empty($student));
if (!empty($student)) {
$this->assertFalse(empty($student->id));
}
}
示例2: save_enrolments
/**
* Save a set of enrolments and LO grades to the database
* @param array $enrolments Enrolment data to save
* @param array $grades LO grade data to save
*/
protected function save_enrolments($enrolments, $grades = array())
{
// Enrolments.
foreach ($enrolments as $enrolment) {
$student = new student($enrolment);
$sink = $this->redirectMessages();
$student->save();
}
// LO grades.
foreach ($grades as $grade) {
$studentgrade = new student_grade($grade);
$studentgrade->save();
}
}
示例3: create_class_enrolment
/**
* Method to create test user class enrolment
* @param int $userid the user DB id
* @param int $classid the class DB id
*/
public function create_class_enrolment($userid, $classid)
{
// Initialize version1elis importplugin for utility functions.
$importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
$record = new stdClass();
$record->userid = $userid;
$record->classid = $classid;
$record->completestatusid = 0;
$record->grade = 50;
$record->credits = 1;
$record->locked = 0;
$record->enrolmenttime = $importplugin->parse_date('Jan/10/2013');
$stu = new student($record);
$stu->save();
}
示例4: savepass
protected function savepass()
{
$required = array("current" => "Current Password", "new" => "New Password");
foreach ($required as $key => $value) {
if (!isset($_POST[$key]) || $_POST[$key] == '' || $_POST[$key] == 'select') {
echo $value . ' is Required<br/>';
return;
}
}
global $user;
global $objPDO;
$student = new student($objPDO, $user->getuserId());
if (md5($_POST['current']) == $student->getPassword()) {
$student->setPassword(md5($_POST['new']));
$student->save();
} else {
echo 'The Current Password is Wrong';
return;
}
echo '<meta http-equiv="Refresh" content="0;url=http://localhost/cloud/profile"/>';
}
示例5: test_success
/**
* Test successful class enrolment deletion.
*/
public function test_success()
{
global $DB;
$this->give_permissions(array('local/elisprogram:class_enrol'));
// Initialize version1elis importplugin for utility functions.
$importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
// Create test course and class.
$datagen = new elis_program_datagenerator($DB);
$crs = $datagen->create_course(array('idnumber' => 'TestCourse'));
$cls = $datagen->create_pmclass(array('idnumber' => 'TestClassEnrolmentCreate', 'courseid' => $crs->id));
$data = array('class_idnumber' => $cls->idnumber, 'user_username' => 'assigninguser', 'user_email' => 'assigninguser@example.com');
// Create the class enrolment record to delete.
$userid = $DB->get_field(user::TABLE, 'id', array('username' => 'assigninguser'));
$stu = new student(array('classid' => $cls->id, 'userid' => $userid));
$stu->save();
$response = local_datahub_elis_class_enrolment_delete::class_enrolment_delete($data);
$this->assertNotEmpty($response);
$this->assertInternalType('array', $response);
$this->assertArrayHasKey('messagecode', $response);
$this->assertArrayHasKey('message', $response);
$this->assertEquals(get_string('ws_class_enrolment_delete_success_code', 'local_datahub'), $response['messagecode']);
$this->assertEquals(get_string('ws_class_enrolment_delete_success_msg', 'local_datahub'), $response['message']);
$this->assertFalse($DB->record_exists(student::TABLE, array('classid' => $cls->id, 'userid' => $userid)));
}
示例6: test_methodonlyupdatesunlockedenrolmentsforspecificuserid
/**
* Validate that the method respects the locked status when run for a
* specific user
*/
public function test_methodonlyupdatesunlockedenrolmentsforspecificuserid()
{
global $DB;
$this->load_csv_data();
// Set up enrolments.
$this->make_course_enrollable();
enrol_try_internal_enrol(2, 100, 1);
enrol_try_internal_enrol(2, 101, 1);
// Set required PM course grade.
$pmcourse = new \course(array('id' => 100, 'completion_grade' => 50));
$pmcourse->save();
// Set up course grade item.
$coursegradeitem = \grade_item::fetch_course_item(2);
$coursegradeitem->grademax = 100;
$coursegradeitem->needsupdate = false;
$coursegradeitem->locked = true;
$coursegradeitem->update();
// Assign student grades.
$coursegradegrade = new \grade_grade(array('itemid' => 1, 'userid' => 100, 'finalgrade' => 100));
$coursegradegrade->insert();
$coursegradegrade = new \grade_grade(array('itemid' => 1, 'userid' => 101, 'finalgrade' => 100));
$coursegradegrade->insert();
// Enrol the student.
$student = new \student();
$student->userid = 103;
$student->classid = 100;
$student->grade = 0;
$student->completestatusid = STUSTATUS_NOTCOMPLETE;
$student->locked = 1;
$student->save();
// Call and validate that locked record is not changed.
$sync = new \local_elisprogram\moodle\synchronize();
$sync->synchronize_moodle_class_grades(100);
$this->assert_student_exists(100, 103, 0, STUSTATUS_NOTCOMPLETE, null, null, 1);
$DB->execute("UPDATE {" . \student::TABLE . "} SET locked = 0");
// Call and validate that unlocked record is changed.
$sync = new \local_elisprogram\moodle\synchronize();
$sync->synchronize_moodle_class_grades(100);
// Validate count.
$count = $DB->count_records(\student::TABLE, array('completestatusid' => STUSTATUS_PASSED));
$this->assertEquals(1, $count);
// NOTE: this method does not lock enrolments.
$this->assert_student_exists(100, 103, 100, STUSTATUS_PASSED, null, null, 0);
}
示例7: create_enrolment
/**
* Enrol the test user in the provided context
*
* @param string $contextlevel The string descriptor of the context level
* @param string $role The shortname of the import record's role column
*/
private function create_enrolment($contextlevel, $role)
{
global $CFG, $DB;
require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
switch ($contextlevel) {
case 'curriculum':
// Program enrolment.
require_once elispm::lib('data/curriculumstudent.class.php');
$data = array('curriculumid' => 1, 'userid' => 1);
$curriculumstudent = new curriculumstudent($data);
$curriculumstudent->save();
break;
case 'track':
// Track enrolment.
require_once elispm::lib('data/usertrack.class.php');
$data = array('trackid' => 1, 'userid' => 1);
$usertrack = new usertrack($data);
$usertrack->save();
break;
case 'cluster':
// User set enrolment.
require_once elispm::lib('data/clusterassignment.class.php');
$data = array('clusterid' => 1, 'userid' => 1);
$clusterassignment = new clusterassignment($data);
$clusterassignment->save();
break;
case 'class':
if ($role == 'instructor') {
// Class instance instructor enrolment.
require_once elispm::lib('data/instructor.class.php');
$data = array('classid' => 1, 'userid' => 1);
$instructor = new instructor($data);
$instructor->save();
} else {
// Class instance student enrolment.
require_once elispm::lib('data/student.class.php');
$data = array('classid' => 1, 'userid' => 1);
$student = new student($data);
$student->save();
}
break;
case 'user':
// Moodle user role assignment.
$roleid = $DB->get_field('role', 'id', array('shortname' => $role));
$userid = $DB->get_field('user', 'id', array('idnumber' => 'testuseridnumber'));
$context = context_user::instance($userid);
role_assign($roleid, $userid, $context->id);
break;
default:
break;
}
}
示例8: test_checkformoodlecoursesrespectsuseridparameter
/**
* Validate that the check_for_moodle_courses method deletes the correct set of orphaned associations for a specific user.
* @param array $associations The list of associations and information regarding whether they should be cleaned up or not.
* @dataProvider dataprovider_checkformoodlecourses
*/
public function test_checkformoodlecoursesrespectsuseridparameter($associations)
{
global $DB;
// Set up our classes.
$this->load_csv_data();
$student = new student(array('userid' => 103, 'classid' => 103));
$sink = $this->redirectMessages();
$student->save();
// Track which associations should remain.
$remainingassociations = array();
foreach ($associations as $association) {
// Persist the record.
$record = new classmoodlecourse($association);
$record->save();
// Test user is enrolled in class 103, so this one should be deleted.
if ($association['classid'] != 103) {
// It should persist after the method is called.
$remainingassociations[] = $association;
}
}
// Delete orphaned records.
pmclass::check_for_moodle_courses(103);
// Validate count.
$this->assertEquals(count($remainingassociations), $DB->count_records(classmoodlecourse::TABLE));
// Validate records specifically.
foreach ($remainingassociations as $remainingassociation) {
$params = array('classid' => $remainingassociation['classid'], 'moodlecourseid' => $remainingassociation['moodlecourseid']);
$exists = $DB->record_exists(classmoodlecourse::TABLE, $params);
$this->assertTrue($exists);
}
}
示例9: test_pmupdateenrolmentstatusrespectsuseridparameter
/**
* Validate that the pm_update_enrolment_status method respects its userid parameter, i.e. it can run only for a specific user.
* NOTE: this unit test does not test all cases because that should be specifically tested for $pmclass->update_enrolment_status
*
* @param array $enrolments A list of class enrolment records we are processing
* @param array $classgraded A list of learning objective grades we are processing
* @dataProvider dataprovider_updatedelegation
*/
public function test_pmupdateenrolmentstatusrespectsuseridparameter($enrolments, $classgraded)
{
global $DB;
// Necessary data.
$this->load_csv_data();
foreach ($enrolments as $key => $enrolment) {
// Create student enrolment.
$record = new student($enrolment);
$record->save();
}
foreach ($classgraded as $lograde) {
// Create learning objective grade.
$record = new student_grade($lograde);
$record->save();
}
// Pass the appropriate student.
pm_update_enrolment_status(2);
// We should have one passed student in the PM class instance, and that student should be the second user.
$enrolments = $DB->get_records(student::TABLE, array('completestatusid' => STUSTATUS_PASSED));
$this->assertEquals(1, count($enrolments));
$enrolment = reset($enrolments);
$this->assertEquals(100, $enrolment->classid);
$this->assertEquals(2, $enrolment->userid);
$this->assertEquals(100, $enrolment->grade);
}
示例10: test_pmupdatestudentenrolmentfailsstudentwithspecificuserid
/**
* Validate the "succss" case of the method, i.e. failing students for a specific user id, i.e. can only for a specific user.
*
* @param array $associations A list of enrolments / associations to validate against.
* @dataProvider dataprovider_enrolmentfail
*/
public function test_pmupdatestudentenrolmentfailsstudentwithspecificuserid($associations)
{
global $DB;
// Prevent messaging emails from being sent.
set_config('noemailever', true);
// Necessary data.
$this->load_csv_data();
// Track the final data state for validation.
$expectedassociations = array();
foreach ($associations as $key => $association) {
// Create student enrolment.
$record = new student($association);
$record->save();
if ($association['userid'] == 1) {
// Specific student will be set to failed.
$expectedassociations[] = $association;
$expectedassociations[$key]['completestatusid'] = STUSTATUS_FAILED;
// Hard to reliably test timestamps.
unset($expectedassociations[$key]['completetime']);
}
}
// Fail specific expired students.
$this->quiet_pm_update_student_enrolment(1);
// Validate count.
$this->assertEquals(count($expectedassociations), $DB->count_records(student::TABLE, array('userid' => 1)));
// Validate data specifically.
foreach ($expectedassociations as $expectedassociation) {
$exists = $DB->record_exists(student::TABLE, $expectedassociation);
$this->assertTrue($exists);
}
}
示例11: array
/**
* Updates resulting enrolments that are auto-created after users are
* assigned to user sets (specifically user-track assignments, user-program
* assignments, and class enrolments in a track's default class)
*
* Note: This is essentially equivalent to cluster_assigned_handler but
* runs a fixed number of queries for scalability reasons
*
* @param int $userid A specific PM user id to filter on for
* consideration, or all users if zero
* @param int $clusterid A specific cluster / user set id to filter
* on for consideration, or all users if zero
*/
static function update_enrolments($userid = 0, $clusterid = 0)
{
global $DB;
require_once elispm::lib('data/usermoodle.class.php');
// error_log("/local/elisprogram/lib/data/clusterassignment.class.php::update_enrolments({$userid}, {$clusterid})");
// ELIS-7582
@set_time_limit(0);
// convert provided parameters to SQL conditions
$extraconditions = array();
$extraparams = array();
if (!empty($userid)) {
$users = array($userid);
$extraconditions[] = 'u.id = ?';
$extraparams[] = $userid;
} else {
$users = clusterassignment::find(new field_filter('clusterid', $clusterid));
}
if (!empty($clusterid)) {
$extraconditions[] = 'clu.clusterid = ?';
$extraparams[] = $clusterid;
}
$extrawhere = '';
if (!empty($extraconditions)) {
$extrawhere = ' AND ' . implode(' AND ', $extraconditions);
}
//use the current time as the time created and modified for curriculum
//assignments
$timenow = time();
//assign to curricula based on user-cluster and cluster-curriculum
//associations
$sql = "INSERT INTO {" . curriculumstudent::TABLE . "}\n (userid, curriculumid, timecreated, timemodified)\n SELECT DISTINCT u.id, clucur.curriculumid, {$timenow}, {$timenow}\n FROM {" . clusterassignment::TABLE . "} clu\n JOIN {" . user::TABLE . "} u ON u.id = clu.userid\n JOIN {" . clustercurriculum::TABLE . "} clucur\n ON clucur.clusterid = clu.clusterid\n LEFT JOIN {" . curriculumstudent::TABLE . "} ca\n ON ca.userid = u.id\n AND ca.curriculumid = clucur.curriculumid\n WHERE ca.curriculumid IS NULL\n AND clucur.autoenrol = 1\n {$extrawhere}";
$DB->execute($sql, $extraparams);
//assign to curricula based on user-cluster and cluster-track
//associations (assigning a user to a track auto-assigns them to
//the track's curriculum, track assignment happens below)
$sql = "INSERT INTO {" . curriculumstudent::TABLE . "}\n (userid, curriculumid, timecreated, timemodified)\n SELECT DISTINCT u.id, trk.curid, {$timenow}, {$timenow}\n FROM {" . clusterassignment::TABLE . "} clu\n JOIN {" . user::TABLE . "} u\n ON u.id = clu.userid\n JOIN {" . clustertrack::TABLE . "} clutrk\n ON clutrk.clusterid = clu.clusterid\n JOIN {" . track::TABLE . "} trk\n ON clutrk.trackid = trk.id\n LEFT JOIN {" . curriculumstudent::TABLE . "} ca\n ON ca.userid = u.id\n AND ca.curriculumid = trk.curid\n WHERE ca.curriculumid IS NULL\n AND clutrk.autoenrol = 1\n {$extrawhere}";
$DB->execute($sql, $extraparams);
//this represents the tracks that users will be assigned to
//based on user-cluster and cluster-track associations
//(actual assignment happens below)
$exists = "EXISTS (SELECT DISTINCT u.id, clutrk.trackid\n FROM {" . clusterassignment::TABLE . "} clu\n JOIN {" . user::TABLE . "} u\n ON u.id = clu.userid\n JOIN {" . clustertrack::TABLE . "} clutrk\n ON clutrk.clusterid = clu.clusterid\n LEFT JOIN {" . usertrack::TABLE . "} ta\n ON ta.userid = u.id\n AND ta.trackid = clutrk.trackid\n WHERE ta.trackid IS NULL\n AND clutrk.autoenrol = 1\n AND outerta.trackid = clutrk.trackid\n\t {$extrawhere})";
/**
* 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
*/
// group the classes from the same course together
// only select the ones that are the only class for that course in
// the given track, and if the autoenrol flag is set
$sql = "SELECT outerta.classid, outerta.courseid, trk.curid\n FROM {" . trackassignment::TABLE . "} outerta\n JOIN {" . track::TABLE . "} trk ON trk.id = outerta.trackid\n WHERE {$exists}\n GROUP BY courseid\n HAVING COUNT(*) = 1 AND MAX(autoenrol) = 1";
//go through and assign user(s) to the autoenollable classes
$classes = $DB->get_records_sql($sql, $extraparams);
if (!empty($classes)) {
foreach ($users as $user) {
$userid = is_object($user) ? $user->userid : $user;
foreach ($classes as $class) {
// check pre-requisites
$curcrs = new curriculumcourse(array('courseid' => $class->courseid, 'curriculumid' => $class->curid));
if (!$curcrs->prerequisites_satisfied($userid)) {
continue;
}
$now = time();
// enrol user in each autoenrolable class
$stu_record = new object();
$stu_record->userid = $userid;
$stu_record->classid = $class->classid;
$stu_record->enrolmenttime = $now;
$enrolment = new student($stu_record);
// catch enrolment limits
try {
$enrolment->save();
} catch (pmclass_enrolment_limit_validation_exception $e) {
// autoenrol into waitlist
$wait_record = new object();
$wait_record->userid = $userid;
$wait_record->classid = $class->classid;
$wait_record->enrolmenttime = $now;
$wait_record->timecreated = $now;
$wait_record->position = 0;
$wait_list = new waitlist($wait_record);
$wait_list->save();
} catch (Exception $e) {
$param = array('message' => $e->getMessage());
if (in_cron()) {
mtrace(get_string('record_not_created_reason', 'local_elisprogram', $param));
} else {
//.........这里部分代码省略.........
示例12: date
$student->semester = '0';
$student->verband = 'I';
$student->gruppe = ' ';
$student->insertamum = date('Y-m-d H:i:s');
$student->insertvon = $user;
$lvb = new lehrverband();
if (!$lvb->exists($student->studiengang_kz, $student->semester, $student->verband, $student->gruppe)) {
$lvb->studiengang_kz = $student->studiengang_kz;
$lvb->semester = $student->semester;
$lvb->verband = $student->verband;
$lvb->gruppe = $student->gruppe;
$lvb->bezeichnung = 'Incoming';
$lvb->aktiv = true;
$lvb->save(true);
}
if ($student->save(true, false)) {
//StudentLehrverband anlegen
$studentlehrverband = new student();
$studentlehrverband->uid = $uid;
$studentlehrverband->studiensemester_kurzbz = $studiensemester_kurzbz;
$studentlehrverband->studiengang_kz = $studiengang_kz;
$studentlehrverband->semester = '0';
$studentlehrverband->verband = 'I';
$studentlehrverband->gruppe = ' ';
$studentlehrverband->insertamum = date('Y-m-d H:i:s');
$studentlehrverband->insertvon = $user;
if (!$studentlehrverband->save_studentlehrverband(true)) {
$error = true;
$errormsg = 'StudentLehrverband konnte nicht angelegt werden';
}
} else {
示例13: test_check_autoenrol_after_course_completion
/**
* Test the autoenrol after course completion function.
*/
public function test_check_autoenrol_after_course_completion()
{
$dataset = $this->createCsvDataSet(array(course::TABLE => elispm::file('tests/fixtures/pmcourse.csv'), pmclass::TABLE => elispm::file('tests/fixtures/pmclass.csv'), user::TABLE => elispm::file('tests/fixtures/pmuser.csv'), student::TABLE => elispm::file('tests/fixtures/student.csv'), waitlist::TABLE => elispm::file('tests/fixtures/waitlist2.csv')));
$this->loadDataSet($dataset);
$class = new pmclass(100);
$class->load();
$class->maxstudents = 2;
$class->enrol_from_waitlist = 1;
$class->save();
$student = new student(array('userid' => 103, 'classid' => 100));
$student->completestatusid = STUSTATUS_PASSED;
$student->save();
$return = waitlist::check_autoenrol_after_course_completion($student);
$this->assertTrue($return);
}
示例14: 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();
}
}
示例15: attempt_enrolment
/**
* Attempt initial enrolment.
*
* This performs an initial attempt at enroling the selected users. This has not yet taken into account the enrolment limit
* or permissions.
*
* @param array $elements An array of elements to perform the action on.
* @param int $classid The ID of the class we're enrolling into.
* @param string $enroldata A JSON string containing enrolment data for the users we want to overenrol.
* @param bool $bulkaction Whether this attempt is a bulk action or not.
* @return array An array consisting of "result", and optionally "users" and "total", explained below:
* result: Will be "success" if all users were enrolled successfully, or "waitlist", if we have users that
* need to be waitlisted.
* users: If some users need enrolment limit resolution, this will be present.
* This will either contain an array of arrays like array('userid' => $userid, 'name' => $label),
* or the string 'bulklist', if we're performing a bulk action.
* total: If we're performing a bulk action, and some users need enrolment limit resolution, this will be
* included, indicating the number of users needed resolution.
*/
protected function attempt_enrolment($elements, $classid, $enroldata, $bulkaction)
{
set_time_limit(0);
// Enrolment data.
$enroldata = $this->process_enrolment_data($classid, @json_decode($enroldata));
if (empty($enroldata)) {
throw new Exception('Did not receive valid enrolment data.');
}
// Attempt enrolment.
$waitlist = array();
foreach ($elements as $userid => $label) {
// Skip invalid userids or users which we dont have permission to modify.
if (!is_numeric($userid) || !student::can_manage_assoc($userid, $classid)) {
continue;
}
// Build student.
$sturecord = $enroldata;
$sturecord['userid'] = $userid;
$newstu = new student($sturecord);
$newstu->validation_overrides[] = 'prerequisites';
if ($newstu->completestatusid != STUSTATUS_NOTCOMPLETE) {
// User is set to completed, so don't worry about enrolment limit.
$newstu->validation_overrides[] = 'enrolment_limit';
}
// Attempt enrolment.
try {
$newstu->save();
unset($elements[$userid]);
$this->datatable->bulklist_modify(array(), array($userid));
} catch (pmclass_enrolment_limit_validation_exception $e) {
$waitlist[] = array('userid' => $userid, 'name' => $label);
} catch (Exception $e) {
$param = array('message' => $e->getMessage());
throw new Exception(get_string('record_not_created_reason', 'local_elisprogram', $param));
}
}
if ($bulkaction === true) {
if (!empty($waitlist)) {
list($bulklistdisplay, $totalusers) = $this->datatable->bulklist_get_display(1);
return array('result' => 'waitlist', 'users' => 'bulklist', 'total' => $totalusers);
} else {
return array('result' => 'success');
}
} else {
return !empty($waitlist) ? array('result' => 'waitlist', 'users' => $waitlist) : array('result' => 'success');
}
}