本文整理汇总了PHP中user_picture::fields方法的典型用法代码示例。如果您正苦于以下问题:PHP user_picture::fields方法的具体用法?PHP user_picture::fields怎么用?PHP user_picture::fields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user_picture
的用法示例。
在下文中一共展示了user_picture::fields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: block_ranking_get_students_by_date
/**
* Get the students points based on a time interval
*
* @param int
* @param int
* @param int
* @return mixed
*/
function block_ranking_get_students_by_date($limit = null, $datestart, $dateend)
{
global $COURSE, $DB, $PAGE;
// Get block ranking configuration.
$cfgranking = get_config('block_ranking');
// Get limit from default configuration or instance configuration.
if (!$limit) {
if (isset($cfgranking->rankingsize) && trim($cfgranking->rankingsize) != '') {
$limit = $cfgranking->rankingsize;
} else {
$limit = 10;
}
}
$context = $PAGE->context;
$userfields = user_picture::fields('u', array('username'));
$sql = "SELECT\n DISTINCT {$userfields},\n sum(rl.points) as points\n FROM\n {user} u\n INNER JOIN {role_assignments} a ON a.userid = u.id\n INNER JOIN {ranking_points} r ON r.userid = u.id AND r.courseid = :r_courseid\n INNER JOIN {ranking_logs} rl ON rl.rankingid = r.id\n INNER JOIN {context} c ON c.id = a.contextid\n WHERE a.contextid = :contextid\n AND a.userid = u.id\n AND a.roleid = :roleid\n AND c.instanceid = :courseid\n AND r.courseid = :crsid\n AND rl.timecreated BETWEEN :weekstart AND :weekend\n GROUP BY u.id\n ORDER BY points DESC, u.firstname ASC\n LIMIT " . $limit;
$params['contextid'] = $context->id;
$params['roleid'] = 5;
$params['courseid'] = $COURSE->id;
$params['r_courseid'] = $COURSE->id;
$params['crsid'] = $COURSE->id;
$params['weekstart'] = $datestart;
$params['weekend'] = $dateend;
$users = array_values($DB->get_records_sql($sql, $params));
return $users;
}
示例2: get_user_picture
function get_user_picture($userid)
{
global $DB;
$extrafields[] = 'lastaccess';
$ufields = user_picture::fields('u', $extrafields);
$sql = "SELECT DISTINCT {$ufields} FROM {user} u where u.id={$userid}";
$user = $DB->get_record_sql($sql);
return new user_picture($user);
}
示例3: scheduler_get_attendants
/**
* get list of attendants for slot form
* @param int $cmid the course module
* @param mixed $groupid id number of the group to select from, 0 or '' if all groups
* @return array of moodle user records
*/
function scheduler_get_attendants($cmid, $groupid = '')
{
$context = context_module::instance($cmid);
if (!$groupid) {
$groupkeys = '';
} else {
$groupkeys = array($groupid);
}
$attendants = get_users_by_capability($context, 'mod/scheduler:attend', user_picture::fields('u'), 'u.lastname, u.firstname', '', '', $groupkeys, '', false, false, false);
return $attendants;
}
示例4: get_content
function get_content()
{
global $USER, $CFG, $DB, $OUTPUT;
if (!$CFG->messaging) {
$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
if ($this->page->user_is_editing()) {
$this->content->text = get_string('disabled', 'message');
}
return $this->content;
}
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
if (empty($this->instance) or !isloggedin() or isguestuser() or empty($CFG->messaging)) {
return $this->content;
}
$link = '/message/index.php';
$action = null;
//this was using popup_action() but popping up a fullsize window seems wrong
$this->content->footer = $OUTPUT->action_link($link, get_string('messages', 'message'), $action);
$ufields = user_picture::fields('u', array('lastaccess'));
$users = $DB->get_records_sql("SELECT {$ufields}, COUNT(m.useridfrom) AS count\n FROM {user} u, {message} m\n WHERE m.useridto = ? AND u.id = m.useridfrom AND m.notification = 0\n GROUP BY {$ufields}", array($USER->id));
//Now, we have in users, the list of users to show
//Because they are online
if (!empty($users)) {
$this->content->text .= '<ul class="list">';
foreach ($users as $user) {
$timeago = format_time(time() - $user->lastaccess);
$this->content->text .= '<li class="listentry"><div class="user"><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . SITEID . '" title="' . $timeago . '">';
$this->content->text .= $OUTPUT->user_picture($user, array('courseid' => SITEID));
//TODO: user might not have capability to view frontpage profile :-(
$this->content->text .= fullname($user) . '</a></div>';
$link = '/message/index.php?usergroup=unread&id=' . $user->id;
$anchortagcontents = '<img class="iconsmall" src="' . $OUTPUT->pix_url('t/message') . '" alt="" /> ' . $user->count;
$action = null;
// popup is gone now
$anchortag = $OUTPUT->action_link($link, $anchortagcontents, $action);
$this->content->text .= '<div class="message">' . $anchortag . '</div></li>';
}
$this->content->text .= '</ul>';
} else {
$this->content->text .= '<div class="info">';
$this->content->text .= get_string('nomessages', 'message');
$this->content->text .= '</div>';
}
return $this->content;
}
示例5: definition
public function definition()
{
global $USER, $OUTPUT, $CFG;
$mform = $this->_form;
$instance = $this->_customdata;
$this->instance = $instance;
$plugin = enrol_get_plugin('boleto');
$heading = $plugin->get_instance_name($instance);
$mform->addElement('header', 'boletoheader', $heading);
if ($instance->password) {
// Change the id of boleto enrolment key input as there can be multiple boleto enrolment methods.
$mform->addElement('passwordunmask', 'enrolpassword', get_string('password', 'enrol_boleto'), array('id' => 'enrolpassword_' . $instance->id));
$context = context_course::instance($this->instance->courseid);
$keyholders = get_users_by_capability($context, 'enrol/boleto:holdkey', user_picture::fields('u'));
$keyholdercount = 0;
foreach ($keyholders as $keyholder) {
$keyholdercount++;
if ($keyholdercount === 1) {
$mform->addElement('static', 'keyholder', '', get_string('keyholder', 'enrol_boleto'));
}
$keyholdercontext = context_user::instance($keyholder->id);
if ($USER->id == $keyholder->id || has_capability('moodle/user:viewdetails', context_system::instance()) || has_coursecontact_role($keyholder->id)) {
$profilelink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $keyholder->id . '&course=' . $this->instance->courseid . '">' . fullname($keyholder) . '</a>';
} else {
$profilelink = fullname($keyholder);
}
$profilepic = $OUTPUT->user_picture($keyholder, array('size' => 35, 'courseid' => $this->instance->courseid));
$mform->addElement('static', 'keyholder' . $keyholdercount, '', $profilepic . $profilelink);
}
}
$boletourl = new moodle_url('/enrol/boleto/boleto.php', array('instanceid' => $this->instance->id));
$mform->addElement('static', 'info', '', get_string('boletoprintandpayinfo', 'enrol_boleto'));
// customint8 == avista.
if ($this->instance->customint8) {
$mform->addElement('static', 'info', '', get_string('boletoprintandpayinfodirectlinks', 'enrol_boleto', $boletourl->out(false)));
} else {
$mform->addElement('static', 'info', '', get_string('boletoprintandpayinfoparceladolink0', 'enrol_boleto', $boletourl->out(false)));
$boletourl->param('parcela', 1);
$mform->addElement('static', 'info', '', get_string('boletoprintandpayinfoparceladolink1', 'enrol_boleto', $boletourl->out(false)));
$boletourl->param('parcela', 2);
$mform->addElement('static', 'info', '', get_string('boletoprintandpayinfoparceladolink2', 'enrol_boleto', $boletourl->out(false)));
}
$this->add_action_buttons(false, get_string('enrolme', 'enrol_boleto'));
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->setDefault('id', $instance->courseid);
$mform->addElement('hidden', 'instance');
$mform->setType('instance', PARAM_INT);
$mform->setDefault('instance', $instance->id);
}
示例6: init
/**
* Initialises table
*/
protected function init()
{
$tablecolumns = array('userpic', 'fullname');
$tableheaders = array(get_string('userpic'), get_string('fullnameuser'));
$extrafields = get_extra_user_fields($this->get_context());
$ufields = user_picture::fields('u', $extrafields, $this->useridfield);
$fields = 'c.id, c.timemodified as completed_timemodified, c.courseid, ' . $ufields;
$from = '{feedback_completed} c ' . 'JOIN {user} u ON u.id = c.userid AND u.deleted = :notdeleted';
$where = 'c.anonymous_response = :anon
AND c.feedback = :instance';
if ($this->feedbackstructure->get_courseid()) {
$where .= ' AND c.courseid = :courseid';
}
if ($this->is_downloading()) {
// When downloading data:
// Remove 'userpic' from downloaded data.
array_shift($tablecolumns);
array_shift($tableheaders);
// Add all identity fields as separate columns.
foreach ($extrafields as $field) {
$fields .= ", u.{$field}";
$tablecolumns[] = $field;
$tableheaders[] = get_user_field_name($field);
}
}
if ($this->feedbackstructure->get_feedback()->course == SITEID && !$this->feedbackstructure->get_courseid()) {
$tablecolumns[] = 'courseid';
$tableheaders[] = get_string('course');
}
$tablecolumns[] = 'completed_timemodified';
$tableheaders[] = get_string('date');
$this->define_columns($tablecolumns);
$this->define_headers($tableheaders);
$this->sortable(true, 'lastname', SORT_ASC);
$this->collapsible(true);
$this->set_attribute('id', 'showentrytable');
$params = array();
$params['anon'] = FEEDBACK_ANONYMOUS_NO;
$params['instance'] = $this->feedbackstructure->get_feedback()->id;
$params['notdeleted'] = 0;
$params['courseid'] = $this->feedbackstructure->get_courseid();
$group = groups_get_activity_group($this->feedbackstructure->get_cm(), true);
if ($group) {
$where .= ' AND c.userid IN (SELECT g.userid FROM {groups_members} g WHERE g.groupid = :group)';
$params['group'] = $group;
}
$this->set_sql($fields, $from, $where, $params);
$this->set_count_sql("SELECT COUNT(c.id) FROM {$from} WHERE {$where}", $params);
}
示例7: __construct
public function __construct($uniqueid)
{
global $PAGE, $USER;
parent::__construct($uniqueid);
$this->define_columns(array('userpic', 'fullname', 'total', 'posts', 'replies', 'substantive'));
$this->define_headers(array('', get_string('fullnameuser'), get_string('totalposts', 'hsuforum'), get_string('posts', 'hsuforum'), get_string('replies', 'hsuforum'), get_string('substantive', 'hsuforum')));
$fields = user_picture::fields('u', null, 'id');
$params = array('forumid' => $PAGE->activityrecord->id);
if (!has_capability('mod/hsuforum:viewposters', $PAGE->context)) {
$params['userid'] = $USER->id;
$usersql = ' AND u.id = :userid ';
} else {
$usersql = '';
}
$this->set_sql("{$fields},\n COUNT(*) AS total,\n SUM(CASE WHEN p.parent = 0 THEN 1 ELSE 0 END) AS posts,\n SUM(CASE WHEN p.parent != 0 THEN 1 ELSE 0 END) AS replies,\n SUM(CASE WHEN p.flags LIKE '%substantive%' THEN 1 ELSE 0 END) AS substantive", '{hsuforum_posts} p, {hsuforum_discussions} d, {hsuforum} f, {user} u', "u.id = p.userid AND p.discussion = d.id AND d.forum = f.id AND f.id = :forumid{$usersql} GROUP BY p.userid", $params);
$this->set_count_sql("\n SELECT COUNT(DISTINCT p.userid)\n FROM {hsuforum_posts} p\n JOIN {user} u ON u.id = p.userid\n JOIN {hsuforum_discussions} d ON d.id = p.discussion\n JOIN {hsuforum} f ON f.id = d.forum\n WHERE f.id = :forumid{$usersql}\n ", $params);
}
示例8: getUserList
function getUserList($currentgroup = '', $courseId, $contextlevel, $context, $limitUsers = 15)
{
global $USER, $CFG, $DB, $OUTPUT;
$groupmembers = "";
$groupselect = "";
$params = array();
//Add this to the SQL to show only group users
if ($currentgroup !== NULL) {
$groupmembers = ", {groups_members} gm";
$groupselect = "AND u.id = gm.userid AND gm.groupid = :currentgroup";
$params['currentgroup'] = $currentgroup;
}
$userfields = user_picture::fields('u', array('username'));
if ($courseId == SITEID or $contextlevel < CONTEXT_COURSE) {
// Site-level
//Only show if is admin
if (!checkIfUserIsAdmin()) {
return '';
}
$sql = "SELECT {$userfields}, ul.lastip, MAX(ul.timemodified) AS lastaccess\n FROM {user} u {$groupmembers} ,{sessions} ul\n WHERE u.id = ul.userid AND u.deleted = 0\n {$groupselect}\n GROUP BY {$userfields}\n ORDER BY ul.timemodified DESC ";
} else {
// Course level - show only enrolled users for now
//Only show if is teacher or admin
if (!checkIfUserIsTeacher($courseId)) {
return '';
}
list($esqljoin, $eparams) = get_enrolled_sql($context);
$params = array_merge($params, $eparams);
$sql = "SELECT {$userfields}, ul.lastip, MAX(ul.timemodified) AS lastaccess\n FROM {sessions} ul {$groupmembers}, {user} u\n JOIN ({$esqljoin}) euj ON euj.id = u.id\n WHERE u.id = ul.userid\n AND u.deleted = 0\n {$groupselect}\n GROUP BY {$userfields}\n ORDER BY lastaccess DESC";
$params['courseid'] = $courseId;
}
if ($users = $DB->get_records_sql($sql, $params, 0, $limitUsers)) {
// We'll just take the most recent 50 maximum
foreach ($users as $user) {
$users[$user->id]->fullname = fullname($user);
}
} else {
$users = array();
}
return $users;
}
示例9: __construct
/**
* Constructor.
*
* @param string $uniqueid Unique ID.
*/
public function __construct($uniqueid, $courseid)
{
global $PAGE;
parent::__construct($uniqueid);
// Block XP stuff.
$this->xpmanager = block_xp_manager::get($courseid);
$this->xpoutput = $PAGE->get_renderer('block_xp');
// Define columns.
$this->define_columns(array('rank', 'userpic', 'fullname', 'lvl', 'xp', 'progress'));
$this->define_headers(array(get_string('rank', 'block_xp'), '', get_string('fullname'), get_string('level', 'block_xp'), get_string('xp', 'block_xp'), get_string('progress', 'block_xp')));
// Define SQL.
$this->sql = new stdClass();
$this->sql->fields = 'x.*, ' . user_picture::fields('u');
$this->sql->from = '{block_xp} x LEFT JOIN {user} u ON x.userid = u.id';
$this->sql->where = 'courseid = :courseid';
$this->sql->params = array('courseid' => $courseid);
// Define various table settings.
$this->sortable(false);
$this->no_sorting('userpic');
$this->no_sorting('progress');
$this->collapsible(false);
}
示例10: get_authors
protected function get_authors() {
global $DB;
$rslt = $this->workshop->get_submissions_grouped();
//now we have to do some magic to turn these back into "authors"
$ret = array();
$users = array();
//loop 1: get user ids
foreach ($rslt as $r) {
$users[] = $r->authorid;
}
$fields = user_picture::fields();
$users = $DB->get_records_list('user','id',$users,'',$fields);
//loop 2: apply users to submissions
$ret[0] = array();
foreach ($rslt as $r){
$ret[$r->group->id] = array( $r->authorid => $users[$r->authorid] );
$ret[0][$r->authorid] = $users[$r->authorid];
}
return $ret;
}
示例11: set_sql
/**
* Store the SQL queries & params for listing online users
*
* @param int $currentgroup The group (if any) to filter on
* @param int $now Time now
* @param int $timetoshowusers Number of seconds to show online users
* @param context $context Context object used to generate the sql for users enrolled in a specific course
* @param bool $sitelevel Whether to check online users at site level.
* @param int $courseid The course id to check
*/
protected function set_sql($currentgroup, $now, $timetoshowusers, $context, $sitelevel, $courseid)
{
$timefrom = 100 * floor(($now - $timetoshowusers) / 100);
// Round to nearest 100 seconds for better query cache.
$groupmembers = "";
$groupselect = "";
$groupby = "";
$lastaccess = ", lastaccess";
$timeaccess = ", ul.timeaccess AS lastaccess";
$params = array();
$userfields = \user_picture::fields('u', array('username'));
// Add this to the SQL to show only group users.
if ($currentgroup !== null) {
$groupmembers = ", {groups_members} gm";
$groupselect = "AND u.id = gm.userid AND gm.groupid = :currentgroup";
$groupby = "GROUP BY {$userfields}";
$lastaccess = ", MAX(u.lastaccess) AS lastaccess";
$timeaccess = ", MAX(ul.timeaccess) AS lastaccess";
$params['currentgroup'] = $currentgroup;
}
$params['now'] = $now;
$params['timefrom'] = $timefrom;
if ($sitelevel) {
$sql = "SELECT {$userfields} {$lastaccess}\n FROM {user} u {$groupmembers}\n WHERE u.lastaccess > :timefrom\n AND u.lastaccess <= :now\n AND u.deleted = 0\n {$groupselect} {$groupby}\n ORDER BY lastaccess DESC ";
$csql = "SELECT COUNT(u.id)\n FROM {user} u {$groupmembers}\n WHERE u.lastaccess > :timefrom\n AND u.lastaccess <= :now\n AND u.deleted = 0\n {$groupselect}";
} else {
// Course level - show only enrolled users for now.
// TODO: add a new capability for viewing of all users (guests+enrolled+viewing).
list($esqljoin, $eparams) = get_enrolled_sql($context);
$params = array_merge($params, $eparams);
$sql = "SELECT {$userfields} {$timeaccess}\n FROM {user_lastaccess} ul {$groupmembers}, {user} u\n JOIN ({$esqljoin}) euj ON euj.id = u.id\n WHERE ul.timeaccess > :timefrom\n AND u.id = ul.userid\n AND ul.courseid = :courseid\n AND ul.timeaccess <= :now\n AND u.deleted = 0\n {$groupselect} {$groupby}\n ORDER BY lastaccess DESC";
$csql = "SELECT COUNT(u.id)\n FROM {user_lastaccess} ul {$groupmembers}, {user} u\n JOIN ({$esqljoin}) euj ON euj.id = u.id\n WHERE ul.timeaccess > :timefrom\n AND u.id = ul.userid\n AND ul.courseid = :courseid\n AND ul.timeaccess <= :now\n AND u.deleted = 0\n {$groupselect}";
$params['courseid'] = $courseid;
}
$this->sql = $sql;
$this->csql = $csql;
$this->params = $params;
}
示例12: test_user_picture_fields_unaliasing_null
public function test_user_picture_fields_unaliasing_null()
{
$fields = user_picture::fields();
$fields = array_map('trim', explode(',', $fields));
$fakerecord = new stdClass();
$fakerecord->aliasedid = 42;
foreach ($fields as $field) {
if ($field !== 'id') {
$fakerecord->{'prefix' . $field} = "Value of {$field}";
}
}
$fakerecord->prefixcustom1 = 'Value of custom1';
$fakerecord->prefiximagealt = null;
$returned = user_picture::unalias($fakerecord, array('custom1'), 'aliasedid', 'prefix');
$this->assertEqual($returned->id, 42);
$this->assertEqual($returned->imagealt, null);
foreach ($fields as $field) {
if ($field !== 'id' and $field !== 'imagealt') {
$this->assertEqual($returned->{$field}, "Value of {$field}");
}
}
$this->assertEqual($returned->custom1, 'Value of custom1');
}
示例13: __construct
/**
* Constructor.
*
* @param string $uniqueid Unique ID.
*/
public function __construct($uniqueid, $courseid)
{
global $DB, $PAGE;
parent::__construct($uniqueid);
// Block XP stuff.
$this->xpmanager = block_xp_manager::get($courseid);
$this->xpoutput = $PAGE->get_renderer('block_xp');
$context = context_course::instance($courseid);
// Define columns.
$this->define_columns(array('userpic', 'fullname', 'lvl', 'xp', 'progress', 'actions'));
$this->define_headers(array('', get_string('fullname'), get_string('level', 'block_xp'), get_string('xp', 'block_xp'), get_string('progress', 'block_xp'), ''));
// Get the relevant user IDs, users enrolled or users with XP.
// This might be a performance issue at some point.
$ids = array();
$users = get_enrolled_users($context, 'block/xp:earnxp');
foreach ($users as $user) {
$ids[$user->id] = $user->id;
}
unset($users);
$entries = $DB->get_recordset_sql('SELECT userid FROM {block_xp} WHERE courseid = :courseid', array('courseid' => $courseid));
foreach ($entries as $entry) {
$ids[$entry->userid] = $entry->userid;
}
$entries->close();
list($insql, $inparams) = $DB->get_in_or_equal($ids, SQL_PARAMS_NAMED, 'param', true, null);
// Define SQL.
$this->sql = new stdClass();
$this->sql->fields = user_picture::fields('u') . ', x.lvl, x.xp';
$this->sql->from = "{user} u LEFT JOIN {block_xp} x ON (x.userid = u.id AND x.courseid = :courseid)";
$this->sql->where = "u.id {$insql}";
$this->sql->params = array_merge($inparams, array('courseid' => $courseid));
// Define various table settings.
$this->sortable(true, 'lvl', SORT_DESC);
$this->no_sorting('userpic');
$this->no_sorting('progress');
$this->collapsible(false);
}
示例14: display_submissions
//.........这里部分代码省略.........
//$table->set_attribute('align', 'center');
$table->no_sorting('finalgrade');
$table->no_sorting('outcome');
// Start working -- this is necessary as soon as the niceties are over
$table->setup();
if (empty($users)) {
echo $OUTPUT->heading(get_string('nosubmitusers','assignment'));
echo '</div>';
return true;
}
if ($this->assignment->assignmenttype=='upload' || $this->assignment->assignmenttype=='online' || $this->assignment->assignmenttype=='uploadsingle') { //TODO: this is an ugly hack, where is the plugin spirit? (skodak)
echo '<div style="text-align:right"><a href="submissions.php?id='.$this->cm->id.'&download=zip">'.get_string('downloadall', 'assignment').'</a></div>';
}
/// Construct the SQL
list($where, $params) = $table->get_sql_where();
if ($where) {
$where .= ' AND ';
}
if ($filter == self::FILTER_SUBMITTED) {
$where .= 's.timemodified > 0 AND ';
} else if($filter == self::FILTER_REQUIRE_GRADING) {
$where .= 's.timemarked < s.timemodified AND ';
}
if ($sort = $table->get_sql_sort()) {
$sort = ' ORDER BY '.$sort;
}
$ufields = user_picture::fields('u');
$select = "SELECT $ufields,
s.id AS submissionid, s.grade, s.submissioncomment,
s.timemodified, s.timemarked,
COALESCE(SIGN(SIGN(s.timemarked) + SIGN(s.timemarked - s.timemodified)), 0) AS status ";
$sql = 'FROM {user} u '.
'LEFT JOIN {assignment_submissions} s ON u.id = s.userid
AND s.assignment = '.$this->assignment->id.' '.
'WHERE '.$where.'u.id IN ('.implode(',',$users).') ';
$ausers = $DB->get_records_sql($select.$sql.$sort, $params, $table->get_page_start(), $table->get_page_size());
$table->pagesize($perpage, count($users));
///offset used to calculate index of student in that particular query, needed for the pop up to know who's next
$offset = $page * $perpage;
$strupdate = get_string('update');
$strgrade = get_string('grade');
$grademenu = make_grades_menu($this->assignment->grade);
if ($ausers !== false) {
$grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array_keys($ausers));
$endposition = $offset + $perpage;
$currentposition = 0;
foreach ($ausers as $auser) {
if ($currentposition == $offset && $offset < $endposition) {
$final_grade = $grading_info->items[0]->grades[$auser->id];
$grademax = $grading_info->items[0]->grademax;
$final_grade->formatted_grade = round($final_grade->grade,2) .' / ' . round($grademax,2);
$locked_overridden = 'locked';
if ($final_grade->overridden) {
$locked_overridden = 'overridden';
示例15: get_users
/**
* MDL-27591 made this method obsolete.
*/
public function get_users($groupid = 0, $page = 1)
{
global $DB, $CFG;
// Fields we need from the user table.
$userfields = user_picture::fields('u', array('username', 'idnumber', 'institution', 'department'));
if (isset($this->pageparams->sort) and $this->pageparams->sort == ATT_SORT_FIRSTNAME) {
$orderby = "u.firstname ASC, u.lastname ASC, u.idnumber ASC, u.institution ASC, u.department ASC";
} else {
$orderby = "u.lastname ASC, u.firstname ASC, u.idnumber ASC, u.institution ASC, u.department ASC";
}
if ($page) {
$usersperpage = $this->pageparams->perpage;
if (!empty($CFG->enablegroupmembersonly) and $this->cm->groupmembersonly) {
$startusers = ($page - 1) * $usersperpage;
if ($groupid == 0) {
$groups = array_keys(groups_get_all_groups($this->cm->course, 0, $this->cm->groupingid, 'g.id'));
} else {
$groups = $groupid;
}
$users = get_users_by_capability($this->context, 'mod/attendance:canbelisted', $userfields . ',u.id, u.firstname, u.lastname, u.email', $orderby, $startusers, $usersperpage, $groups, '', false, true);
} else {
$startusers = ($page - 1) * $usersperpage;
$users = get_enrolled_users($this->context, 'mod/attendance:canbelisted', $groupid, $userfields, $orderby, $startusers, $usersperpage);
}
} else {
if (!empty($CFG->enablegroupmembersonly) and $this->cm->groupmembersonly) {
if ($groupid == 0) {
$groups = array_keys(groups_get_all_groups($this->cm->course, 0, $this->cm->groupingid, 'g.id'));
} else {
$groups = $groupid;
}
$users = get_users_by_capability($this->context, 'mod/attendance:canbelisted', $userfields . ',u.id, u.firstname, u.lastname, u.email', $orderby, '', '', $groups, '', false, true);
} else {
$users = get_enrolled_users($this->context, 'mod/attendance:canbelisted', $groupid, $userfields, $orderby);
}
}
// Add a flag to each user indicating whether their enrolment is active.
if (!empty($users)) {
list($sql, $params) = $DB->get_in_or_equal(array_keys($users), SQL_PARAMS_NAMED, 'usid0');
// See CONTRIB-4868.
$mintime = 'MIN(CASE WHEN (ue.timestart > :zerotime) THEN ue.timestart ELSE ue.timecreated END)';
$maxtime = 'CASE WHEN MIN(ue.timeend) = 0 THEN 0 ELSE MAX(ue.timeend) END';
// See CONTRIB-3549.
$sql = "SELECT ue.userid, MIN(ue.status) as status,\n {$mintime} AS mintime,\n {$maxtime} AS maxtime\n FROM {user_enrolments} ue\n JOIN {enrol} e ON e.id = ue.enrolid\n WHERE ue.userid {$sql}\n AND e.status = :estatus\n AND e.courseid = :courseid\n GROUP BY ue.userid";
$params += array('zerotime' => 0, 'estatus' => ENROL_INSTANCE_ENABLED, 'courseid' => $this->course->id);
$enrolments = $DB->get_records_sql($sql, $params);
foreach ($users as $user) {
$users[$user->id]->enrolmentstatus = $enrolments[$user->id]->status;
$users[$user->id]->enrolmentstart = $enrolments[$user->id]->mintime;
$users[$user->id]->enrolmentend = $enrolments[$user->id]->maxtime;
$users[$user->id]->type = 'standard';
// Mark as a standard (not a temporary) user.
}
}
// Add the 'temporary' users to this list.
$tempusers = $DB->get_records('attendance_tempusers', array('courseid' => $this->course->id));
foreach ($tempusers as $tempuser) {
$users[] = self::tempuser_to_user($tempuser);
}
return $users;
}