本文整理汇总了PHP中student::get_students方法的典型用法代码示例。如果您正苦于以下问题:PHP student::get_students方法的具体用法?PHP student::get_students怎么用?PHP student::get_students使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类student
的用法示例。
在下文中一共展示了student::get_students方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: COUNT
function count_users_avail($namesearch = '', $alpha = '')
{
global $CFG, $CURMAN;
$LIKE = $CURMAN->db->sql_compare();
$FULLNAME = sql_concat('usr.firstname', "' '", 'usr.lastname');
$select = 'SELECT COUNT(usr.id) ';
$tables = 'FROM ' . $CURMAN->db->prefix_table(USRTABLE) . ' usr ';
$join = 'LEFT JOIN ' . $CURMAN->db->prefix_table(INSTABLE) . ' ins ';
$on = 'ON ins.userid = usr.id ';
/// If limiting returns to specific teams, set that up now.
if (!empty($CFG->curr_configteams)) {
$where = 'usr.team IN (' . $CFG->curr_configteams . ') ';
} else {
$where = '';
}
if (!empty($namesearch)) {
$namesearch = trim($namesearch);
$where .= (!empty($where) ? ' AND ' : '') . "({$FULLNAME} {$LIKE} '%{$namesearch}%') ";
}
if ($alpha) {
$where .= (!empty($where) ? ' AND ' : '') . "({$FULLNAME} {$LIKE} '{$alpha}%') ";
}
/*
switch ($type) {
case 'student':
$where .= (!empty($where) ? ' AND ' : '') . 'usr.type = \'Student\' ';
break;
case 'instructor':
$where .= (!empty($where) ? ' AND ' : '') . 'usr.type = \'Instructor\' ';
break;
case '':
$where .= (!empty($where) ? ' AND ' : '') . '(usr.type = \'Student\' OR usr.type = \'Instructor\') ';
break;
}
*/
$uids = array();
$stu = new student();
if ($users = $stu->get_students()) {
foreach ($users as $user) {
$uids[] = $user->id;
}
}
if ($users = $this->get_instructors()) {
foreach ($users as $user) {
$uids[] = $user->id;
}
}
if (!empty($uids)) {
$where .= (!empty($where) ? ' AND ' : '') . 'usr.id NOT IN ( ' . implode(', ', $uids) . ' ) ';
}
if (!empty($where)) {
$where = 'WHERE ' . $where . ' ';
}
$sql = $select . $tables . $join . $on . $where;
return $CURMAN->db->count_records_sql($sql);
}
示例2: array
function count_users_avail($namesearch = '', $alpha = '')
{
global $CFG;
$params = array();
$FULLNAME = $this->_db->sql_concat('usr.firstname', "' '", 'usr.lastname');
$FULLNAME_LIKE = $this->_db->sql_like($FULLNAME, ':name_like', FALSE);
$LASTNAME_STARTSWITH = $this->_db->sql_like('usr.lastname', ':lastname_startswith', FALSE);
$select = 'SELECT COUNT(usr.id) ';
$tables = 'FROM {' . user::TABLE . '} usr ';
$join = 'LEFT JOIN {' . instructor::TABLE . '} ins ';
$on = 'ON ins.userid = usr.id ';
/// If limiting returns to specific teams, set that up now.
if (!empty($CFG->curr_configteams)) {
$where = 'usr.team IN (' . $CFG->curr_configteams . ') ';
} else {
$where = '';
}
if (!empty($namesearch)) {
$namesearch = trim($namesearch);
$where .= (!empty($where) ? ' AND ' : ' ') . "{$FULLNAME_LIKE} ";
$params['name_like'] = "%{$namesearch}%";
}
if ($alpha) {
$where .= (!empty($where) ? ' AND ' : ' ') . "{$LASTNAME_STARTSWITH} ";
$params['lastname_startswith'] = "{$alpha}%";
}
/*
switch ($type) {
case 'student':
$where .= (!empty($where) ? ' AND ' : '') . 'usr.type = \'Student\' ';
break;
case 'instructor':
$where .= (!empty($where) ? ' AND ' : '') . 'usr.type = \'Instructor\' ';
break;
case '':
$where .= (!empty($where) ? ' AND ' : '') . '(usr.type = \'Student\' OR usr.type = \'Instructor\') ';
break;
}
*/
$uids = array();
$stu = new student();
if ($users = $stu->get_students($this->classid)) {
foreach ($users as $user) {
$uids[] = $user->id;
}
}
unset($users);
if ($users = $this->get_instructors()) {
foreach ($users as $user) {
$uids[] = $user->id;
}
}
unset($users);
if (!empty($uids)) {
$where .= (!empty($where) ? ' AND ' : '') . 'usr.id NOT IN ( ' . implode(', ', $uids) . ' ) ';
}
//if appropriate, limit selection to users belonging to clusters that
//the current user can manage instructor assignments for
// TODO: Ugly, this needs to be overhauled
$cpage = new pmclasspage();
if (!$cpage->_has_capability('local/elisprogram:assign_class_instructor', $this->classid)) {
//perform SQL filtering for the more "conditional" capability
$allowed_clusters = instructor::get_allowed_clusters($this->classid);
if (empty($allowed_clusters)) {
$where .= (!empty($where) ? ' AND ' : '') . '0=1 ';
} else {
$cluster_filter = implode(',', $allowed_clusters);
$where .= (!empty($where) ? ' AND ' : '') . 'usr.id IN (
SELECT userid FROM {' . clusterassignment::TABLE . "}\n WHERE clusterid IN ({$cluster_filter}))";
}
}
if (!empty($where)) {
$where = 'WHERE ' . $where . ' ';
}
$sql = $select . $tables . $join . $on . $where;
return $this->_db->count_records_sql($sql, $params);
}
示例3: student
/**
* Enrol the students associated with the class into the attached Moodle
* course.
*
* @param none
* @return bool True on success, False otherwise.
*/
function data_enrol_students()
{
if (empty($this->classid) || empty($this->moodlecourseid) || !empty($this->siteconfig) && !file_exists($this->siteconfig)) {
return false;
}
$stu = new student();
if ($students = $stu->get_students($this->classid)) {
/// At this point we must switch over the other Moodle site's DB config, if needed
if (!empty($this->siteconfig)) {
$cfgbak = moodle_load_config($this->siteconfig);
}
/// This has to be put here in case we have a site config reload.
$CFG = $GLOBALS['CFG'];
$CURMAN = $GLOBALS['CURMAN'];
$db = $GLOBALS['db'];
$role = get_default_course_role($this->moodlecourseid);
if (!($context = get_context_instance(CONTEXT_COURSE, $this->moodlecourseid))) {
return false;
}
foreach ($students as $student) {
/// Make sure that a Moodle account exists for this user already.
$user = new user($student->id);
if (!($muser = $CURMAN->db->get_record('user', 'idnumber', addslashes($user->idnumber)))) {
$muser = addslashes_recursive($muser);
/// Create a new record.
$muser = new stdClass();
$muser->idnumber = $user->idnumber;
$muser->username = $user->uname;
$muser->passwword = $user->passwd;
$muser->firstname = $user->firstname;
$muser->lastname = $user->lastname;
$muser->auth = 'manual';
$muser->timemodified = time();
$muser->id = $CURMAN->db->insert_record('user', $muser);
}
/// If we have a vald Moodle user account, apply the role.
if (!empty($muser->id)) {
role_assign($role->id, $muser->id, 0, $context->id, 0, 0, 0, 'manual');
}
}
/// Reset $CFG object.
if (!empty($this->siteconfig)) {
moodle_load_config($cfgbak->dirroot . '/config.php');
}
}
return true;
}
示例4: test_get_students
public function test_get_students()
{
// Fixture.
$dataset = $this->createCsvDataSet(array(user::TABLE => elispm::file('tests/fixtures/pmuser.csv'), student::TABLE => elispm::file('tests/fixtures/student.csv')));
$this->loadDataSet($dataset);
// Test.
$student = new student();
$student->classid = 100;
$students = $student->get_students();
$this->assertNotEmpty($students);
// Verify.
$found = false;
foreach ($students as $userrec) {
if ($userrec->id === '103') {
$found = true;
break;
}
}
$this->assertTrue($found);
}