本文整理汇总了PHP中flexible_table::get_sort_for_table方法的典型用法代码示例。如果您正苦于以下问题:PHP flexible_table::get_sort_for_table方法的具体用法?PHP flexible_table::get_sort_for_table怎么用?PHP flexible_table::get_sort_for_table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flexible_table
的用法示例。
在下文中一共展示了flexible_table::get_sort_for_table方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display_submission
/**
* Display a single submission, ready for grading on a popup window
*
* This default method prints the teacher info and submissioncomment box at the top and
* the student info and submission at the bottom.
* This method also fetches the necessary data in order to be able to
* provide a "Next submission" button.
* Calls preprocess_submission() to give assignment type plug-ins a chance
* to process submissions before they are graded
* This method gets its arguments from the page parameters userid and offset
*
* @global object
* @global object
* @param string $extra_javascript
*/
function display_submission($offset=-1,$userid =-1, $display=true) {
global $CFG, $DB, $PAGE, $OUTPUT;
require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->libdir.'/tablelib.php');
require_once("$CFG->dirroot/repository/lib.php");
if ($userid==-1) {
$userid = required_param('userid', PARAM_INT);
}
if ($offset==-1) {
$offset = required_param('offset', PARAM_INT);//offset for where to start looking for student.
}
$filter = optional_param('filter', 0, PARAM_INT);
if (!$user = $DB->get_record('user', array('id'=>$userid))) {
print_error('nousers');
}
if (!$submission = $this->get_submission($user->id)) {
$submission = $this->prepare_new_submission($userid);
}
if ($submission->timemodified > $submission->timemarked) {
$subtype = 'assignmentnew';
} else {
$subtype = 'assignmentold';
}
$grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array($user->id));
$gradingdisabled = $grading_info->items[0]->grades[$userid]->locked || $grading_info->items[0]->grades[$userid]->overridden;
/// construct SQL, using current offset to find the data of the next student
$course = $this->course;
$assignment = $this->assignment;
$cm = $this->cm;
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
/// Get all ppl that can submit assignments
$currentgroup = groups_get_activity_group($cm);
$users = get_enrolled_users($context, 'mod/assignment:view', $currentgroup, 'u.id');
if ($users) {
$users = array_keys($users);
// if groupmembersonly used, remove users who are not in any group
if (!empty($CFG->enablegroupmembersonly) and $cm->groupmembersonly) {
if ($groupingusers = groups_get_grouping_members($cm->groupingid, 'u.id', 'u.id')) {
$users = array_intersect($users, array_keys($groupingusers));
}
}
}
$nextid = 0;
$where = '';
if($filter == 'submitted') {
$where .= 's.timemodified > 0 AND ';
} else if($filter == 'requiregrading') {
$where .= 's.timemarked < s.timemodified AND ';
}
if ($users) {
$userfields = user_picture::fields('u', array('lastaccess'));
$select = "SELECT $userfields,
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).') ';
if ($sort = flexible_table::get_sort_for_table('mod-assignment-submissions')) {
$sort = 'ORDER BY '.$sort.' ';
}
$auser = $DB->get_records_sql($select.$sql.$sort, null, $offset, 2);
if (is_array($auser) && count($auser)>1) {
$nextuser = next($auser);
/// Calculate user status
$nextuser->status = ($nextuser->timemarked > 0) && ($nextuser->timemarked >= $nextuser->timemodified);
$nextid = $nextuser->id;
}
}
if ($submission->teacher) {
$teacher = $DB->get_record('user', array('id'=>$submission->teacher));
} else {
global $USER;
//.........这里部分代码省略.........
示例2: array
}
echo html_writer::start_tag('p', array('class' => 'oublog_import_step1_from'));
echo get_string('import_step1_from', 'oublog') . '<br />' . html_writer::tag('span', $boublogname);
echo html_writer::end_tag('p');
// Setup table early so sort can be determined (needs setup to be called first).
$table = new flexible_table($cm->id * $bid);
$url = new moodle_url('/mod/oublog/import.php', $params + $stepinfo);
$table->define_baseurl($url);
$table->define_columns(array('title', 'timeposted', 'tags', 'include'));
$table->column_style('include', 'text-align', 'center');
$table->sortable(true, 'timeposted', SORT_DESC);
$table->maxsortkeys = 1;
$table->no_sorting('tags');
$table->no_sorting('include');
$table->setup();
$sort = flexible_table::get_sort_for_table($cm->id * $bid);
if (empty($sort)) {
$sort = 'timeposted DESC';
}
if ($tags = optional_param('tags', null, PARAM_SEQUENCE)) {
// Filter by joining tag instances.
$stepinfo['tags'] = $tags;
}
$perpage = 100;
// Must match value in oublog_import_getallposts.
$page = optional_param('page', 0, PARAM_INT);
$stepinfo['page'] = $page;
$preselected = optional_param('preselected', '', PARAM_SEQUENCE);
$stepinfo['preselected'] = $preselected;
$preselected = array_filter(array_unique(explode(',', $preselected)));
if ($remote) {
示例3: display_submission
/**
* Display a single submission, ready for grading on a popup window
*
* This default method prints the teacher info and submissioncomment box at the top and
* the student info and submission at the bottom.
* This method also fetches the necessary data in order to be able to
* provide a "Next submission" button.
* Calls preprocess_submission() to give assignment type plug-ins a chance
* to process submissions before they are graded
* This method gets its arguments from the page parameters userid and offset
*
* @global object
* @global object
* @param string $extra_javascript
*/
function display_submission($offset = -1, $userid = -1, $display = true)
{
global $CFG, $DB, $PAGE, $OUTPUT, $USER;
require_once $CFG->libdir . '/gradelib.php';
require_once $CFG->libdir . '/tablelib.php';
require_once "{$CFG->dirroot}/repository/lib.php";
require_once "{$CFG->dirroot}/grade/grading/lib.php";
if ($userid == -1) {
$userid = required_param('userid', PARAM_INT);
}
if ($offset == -1) {
$offset = required_param('offset', PARAM_INT);
//offset for where to start looking for student.
}
$filter = optional_param('filter', 0, PARAM_INT);
if (!($user = $DB->get_record('user', array('id' => $userid)))) {
print_error('nousers');
}
if (!($submission = $this->get_submission($user->id))) {
$submission = $this->prepare_new_submission($userid);
}
if ($submission->timemodified > $submission->timemarked) {
$subtype = 'assignmentnew';
} else {
$subtype = 'assignmentold';
}
$grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array($user->id));
$gradingdisabled = $grading_info->items[0]->grades[$userid]->locked || $grading_info->items[0]->grades[$userid]->overridden;
/// construct SQL, using current offset to find the data of the next student
$course = $this->course;
$assignment = $this->assignment;
$cm = $this->cm;
$context = context_module::instance($cm->id);
//reset filter to all for offline assignment
if ($assignment->assignmenttype == 'offline' && $filter == self::FILTER_SUBMITTED) {
$filter = self::FILTER_ALL;
}
/// Get all ppl that can submit assignments
$currentgroup = groups_get_activity_group($cm);
$users = get_enrolled_users($context, 'mod/assignment:submit', $currentgroup, 'u.id');
if ($users) {
$users = array_keys($users);
// if groupmembersonly used, remove users who are not in any group
if (!empty($CFG->enablegroupmembersonly) and $cm->groupmembersonly) {
if ($groupingusers = groups_get_grouping_members($cm->groupingid, 'u.id', 'u.id')) {
$users = array_intersect($users, array_keys($groupingusers));
}
}
}
$nextid = 0;
$where = '';
if ($filter == self::FILTER_SUBMITTED) {
$where .= 's.timemodified > 0 AND ';
} else {
if ($filter == self::FILTER_REQUIRE_GRADING) {
$where .= 's.timemarked < s.timemodified AND ';
}
}
if ($users) {
$userfields = user_picture::fields('u', array('lastaccess'));
$select = "SELECT {$userfields},\n s.id AS submissionid, s.grade, s.submissioncomment,\n s.timemodified, s.timemarked,\n CASE WHEN s.timemarked > 0 AND s.timemarked >= s.timemodified THEN 1\n ELSE 0 END 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) . ') ';
if ($sort = flexible_table::get_sort_for_table('mod-assignment-submissions')) {
$sort = 'ORDER BY ' . $sort . ' ';
}
$auser = $DB->get_records_sql($select . $sql . $sort, null, $offset, 2);
if (is_array($auser) && count($auser) > 1) {
$nextuser = next($auser);
$nextid = $nextuser->id;
}
}
if ($submission->teacher) {
$teacher = $DB->get_record('user', array('id' => $submission->teacher));
} else {
global $USER;
$teacher = $USER;
}
$this->preprocess_submission($submission);
$mformdata = new stdClass();
$mformdata->context = $this->context;
$mformdata->maxbytes = $this->course->maxbytes;
$mformdata->courseid = $this->course->id;
$mformdata->teacher = $teacher;
$mformdata->assignment = $assignment;
//.........这里部分代码省略.........
示例4: array
if ($newheader == '') {
$columnsarray = array('c1', 'numdiscussions', 'numposts', 'c4', $c5value);
$headersarray = array($userstr, $discussions, $replies, $action, $grade);
} else {
$columnsarray = array('c1', 'numdiscussions', 'numposts', 'c4', $c5value, 'ratingcol');
$headersarray = array($userstr, $discussions, $replies, $action, $grade, $newheader);
}
$ptable->define_columns($columnsarray);
$ptable->define_headers($headersarray);
$ptable->define_baseurl($thisurl);
$ptable->sortable(true);
$ptable->maxsortkeys = 1;
$ptable->no_sorting('c4');
$ptable->no_sorting('c5');
$ptable->setup();
$sort = flexible_table::get_sort_for_table('mod-forumng-participation');
if (empty($sort)) {
$sort = 'c1 ASC';
}
// Need to check whether sort refers to column 'c1' and if it does get correct sql sort statement.
$orderbyuser = stristr($sort, 'c1');
$filename = "{$course->shortname}-" . format_string($forum->get_name(), true);
if ($groupid != -1 && !empty($download)) {
$groupname = $DB->get_field('groups', 'name', array('id' => $groupid));
$filename .= '-' . format_string($groupname, true);
}
$ptable->is_downloading($download, $filename, get_string('userposts', 'forumngfeature_userposts'));
if (!$ptable->is_downloading()) {
$offset = $page * $perpage;
} else {
// Always export all users.