本文整理汇总了PHP中flexible_table::get_page_size方法的典型用法代码示例。如果您正苦于以下问题:PHP flexible_table::get_page_size方法的具体用法?PHP flexible_table::get_page_size怎么用?PHP flexible_table::get_page_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flexible_table
的用法示例。
在下文中一共展示了flexible_table::get_page_size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: geogebra_view_results
function geogebra_view_results($geogebra, $context, $cm, $course, $action)
{
global $CFG, $DB, $OUTPUT, $PAGE, $USER;
if ($action == 'submitgrade') {
// Upgrade submitted grade
$grade = optional_param('grade', '', PARAM_INT);
$gradecomment = optional_param_array('comment_editor', '', PARAM_RAW);
$attemptid = optional_param('attemptid', '', PARAM_INT);
$attempt = geogebra_get_attempt($attemptid);
parse_str($attempt->vars, $parsedvars);
$parsedvars['grade'] = $grade;
$attempt->vars = http_build_query($parsedvars, '', '&');
geogebra_update_attempt($attemptid, $attempt->vars, GEOGEBRA_UPDATE_TEACHER, $gradecomment['text']);
}
// Show students list with their results
require_once $CFG->libdir . '/gradelib.php';
$perpage = optional_param('perpage', 10, PARAM_INT);
$perpage = $perpage <= 0 ? 10 : $perpage;
$page = optional_param('page', 0, PARAM_INT);
// Find out current groups mode
$groupmode = groups_get_activity_groupmode($cm);
$currentgroup = groups_get_activity_group($cm, true);
// Get all ppl that are allowed to submit geogebra
list($esql, $params) = get_enrolled_sql($context, 'mod/geogebra:submit', $currentgroup);
$sql = "SELECT u.id FROM {user} u " . "LEFT JOIN ({$esql}) eu ON eu.id=u.id " . "WHERE u.deleted = 0 AND eu.id=u.id ";
$users = $DB->get_records_sql($sql, $params);
if (!empty($users)) {
$users = array_keys($users);
}
// If groupmembersonly used, remove users who are not in any group
if ($users and !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));
}
}
// TODO: Review to show all users information
if (!empty($users)) {
// Create results table
$extrafields = get_extra_user_fields($context);
$tablecolumns = array_merge(array('picture', 'fullname'), $extrafields, array('attempts', 'duration', 'grade', 'comment', 'datestudent', 'dateteacher', 'status'));
$extrafieldnames = array();
foreach ($extrafields as $field) {
$extrafieldnames[] = get_user_field_name($field);
}
$tableheaders = array_merge(array('', get_string('fullnameuser')), $extrafieldnames, array(get_string('attempts', 'geogebra'), get_string('duration', 'geogebra'), get_string('grade'), get_string('comment', 'geogebra'), get_string('lastmodifiedsubmission', 'geogebra'), get_string('lastmodifiedgrade', 'geogebra'), get_string('status', 'geogebra')));
require_once $CFG->libdir . '/tablelib.php';
$table = new flexible_table('mod-geogebra-results');
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$table->define_baseurl($CFG->wwwroot . '/mod/geogebra/report.php?id=' . $cm->id . '&currentgroup=' . $currentgroup);
$table->sortable(true, 'lastname');
// Sorted by lastname by default
$table->collapsible(true);
$table->initialbars(true);
$table->column_suppress('picture');
$table->column_suppress('fullname');
$table->column_class('picture', 'picture');
$table->column_class('fullname', 'fullname');
foreach ($extrafields as $field) {
$table->column_class($field, $field);
}
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'results generaltable generalbox');
$table->set_attribute('width', '100%');
$table->no_sorting('attempts');
$table->no_sorting('duration');
$table->no_sorting('grade');
$table->no_sorting('comment');
$table->no_sorting('datestudent');
$table->no_sorting('dateteacher');
$table->no_sorting('status');
// Start working -- this is necessary as soon as the niceties are over
$table->setup();
// Construct the SQL
list($where, $params) = $table->get_sql_where();
if ($where) {
$where .= ' AND ';
}
if ($sort = $table->get_sql_sort()) {
$sort = ' ORDER BY ' . $sort;
}
$ufields = user_picture::fields('u', $extrafields);
$select = "SELECT {$ufields} ";
$sql = 'FROM {user} u 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 = $page * $perpage;
// Offset used to calculate index of student in that particular query, needed for the pop up to know who's next
if ($ausers !== false) {
// $grading_info = grade_get_grades($course->id, 'mod', 'geogebra', $geogebra->id, array_keys($ausers));
foreach ($ausers as $auser) {
$picture = $OUTPUT->user_picture($auser);
$userlink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $auser->id . '&course=' . $course->id . '">' . fullname($auser, has_capability('moodle/site:viewfullnames', $context)) . '</a>';
$row = array($picture, $userlink);
$extradata = array();
foreach ($extrafields as $field) {
$extradata[] = $auser->{$field};
}
$row += $extradata;
//.........这里部分代码省略.........
示例2: FROM
// If using legacy log then get users from old table.
if ($uselegacyreader || $onlyuselegacyreader) {
$limittime = '';
if ($uselegacyreader && !empty($minloginternalreader)) {
$limittime = ' AND time < :tilltime ';
$params['tilltime'] = $minloginternalreader;
}
$sql = "SELECT ra.userid, {$usernamefields}, u.idnumber, l.actioncount AS count\n FROM (SELECT DISTINCT userid FROM {role_assignments} WHERE contextid {$relatedctxsql} AND roleid = :roleid ) ra\n JOIN {user} u ON u.id = ra.userid\n {$groupsql}\n LEFT JOIN (\n SELECT userid, COUNT(action) AS actioncount\n FROM {log}\n WHERE cmid = :instanceid\n AND time > :timefrom " . $limittime . $actionsql . " GROUP BY userid) l ON (l.userid = ra.userid)";
if ($twhere) {
$sql .= ' WHERE ' . $twhere;
// Initial bar.
}
if ($table->get_sql_sort()) {
$sql .= ' ORDER BY ' . $table->get_sql_sort();
}
if (!($users = $DB->get_records_sql($sql, $params, $table->get_page_start(), $table->get_page_size()))) {
$users = array();
// Tablelib will handle saying 'Nothing to display' for us.
}
}
// Get record from sql_internal_reader and merge with records got from legacy log (if needed).
if (!$onlyuselegacyreader) {
$sql = "SELECT ra.userid, {$usernamefields}, u.idnumber, COUNT(l.actioncount) AS count\n FROM (SELECT DISTINCT userid FROM {role_assignments} WHERE contextid {$relatedctxsql} AND roleid = :roleid ) ra\n JOIN {user} u ON u.id = ra.userid\n {$groupsql}\n LEFT JOIN (\n SELECT userid, COUNT(crud) AS actioncount\n FROM {" . $logtable . "}\n WHERE contextinstanceid = :instanceid\n AND timecreated > :timefrom" . $crudsql . "\n AND edulevel = :edulevel\n AND anonymous = 0\n AND contextlevel = :contextlevel\n AND (origin = 'web' OR origin = 'ws')\n GROUP BY userid,timecreated) l ON (l.userid = ra.userid)";
// We add this after the WHERE statement that may come below.
$groupbysql = " GROUP BY ra.userid, {$usernamefields}, u.idnumber";
$params['edulevel'] = core\event\base::LEVEL_PARTICIPATING;
$params['contextlevel'] = CONTEXT_MODULE;
if ($twhere) {
$sql .= ' WHERE ' . $twhere;
// Initial bar.
}
示例3: array
//.........这里部分代码省略.........
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';
}
/// Calculate user status
$auser->status = ($auser->timemarked > 0) && ($auser->timemarked >= $auser->timemodified);
$picture = $OUTPUT->user_picture($auser);
if (empty($auser->submissionid)) {
$auser->grade = -1; //no submission yet
}
if (!empty($auser->submissionid)) {
示例4: display
//.........这里部分代码省略.........
// Add extra limits due to initials bar
list($twhere, $tparams) = $table->get_sql_where();
if ($twhere) {
$where .= ' AND '.$twhere; //initial bar
$params = array_merge($params, $tparams);
}
if (!empty($countsql)) {
$count = $DB->get_record_sql($countsql,$params);
$totalinitials = $count->nbresults;
if ($twhere) {
$countsql .= ' AND '.$twhere;
}
$count = $DB->get_record_sql($countsql, $params);
$total = $count->nbresults;
}
$table->pagesize($pagesize, $total);
echo '<div class="quizattemptcounts">';
if ( $count->nbresults == $count->nbattempts ) {
echo get_string('reportcountattempts', 'scorm', $count);
} else if ( $count->nbattempts>0 ) {
echo get_string('reportcountallattempts', 'scorm', $count);
} else {
echo $count->nbusers.' '.get_string('users');
}
echo '</div>';
}
// Fetch the attempts
if (!$download) {
$attempts = $DB->get_records_sql($select.$from.$where.$sort, $params,
$table->get_page_start(), $table->get_page_size());
echo '<div id="scormtablecontainer">';
if ($candelete) {
// Start form
$strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm'));
echo '<form id="attemptsform" method="post" action="' . $PAGE->url->out(false) .
'" onsubmit="return confirm(\''.$strreallydel.'\');">';
echo '<input type="hidden" name="action" value="delete"/>';
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo '<div style="display: none;">';
echo html_writer::input_hidden_params($PAGE->url);
echo '</div>';
echo '<div>';
}
$table->initialbars($totalinitials>20); // Build table rows
} else {
$attempts = $DB->get_records_sql($select.$from.$where.$sort, $params);
}
if ($attempts) {
foreach ($attempts as $scouser) {
$row = array();
if (!empty($scouser->attempt)) {
$timetracks = scorm_get_sco_runtime($scorm->id, false, $scouser->userid, $scouser->attempt);
} else {
$timetracks = '';
}
if (in_array('checkbox', $columns)) {
if ($candelete && !empty($timetracks->start)) {
$row[] = '<input type="checkbox" name="attemptid[]" value="'. $scouser->userid . ':' . $scouser->attempt . '" />';
} else if ($candelete) {
$row[] = '';
}
}
示例5: COUNT
/// because it retrieves ALL users (without role checking) - MDL-14034
if ($table->get_sql_sort()) {
$sort = ' ORDER BY ' . $table->get_sql_sort();
if ($context->id != $frontpagectx->id or $roleid >= 0) {
$sort .= ', r.hidden DESC';
}
} else {
$sort = '';
if ($context->id != $frontpagectx->id or $roleid >= 0) {
$sort .= ' ORDER BY r.hidden DESC';
}
}
$matchcount = $DB->count_records_sql("SELECT COUNT(distinct u.id) {$from} {$where} {$wheresearch}", $params);
$table->initialbars(true);
$table->pagesize($perpage, $matchcount);
$userlist = $DB->get_recordset_sql("{$select} {$from} {$where} {$wheresearch} {$sort}", $params, $table->get_page_start(), $table->get_page_size());
//
// The SELECT behind get_participants_extra() is cheaper if we pass an array
// if IDs. We could pass the SELECT we did before (with the limit bits - tricky!)
// but this is much cheaper. And in any case, it is only doable with limited numbers
// of rows anyway. On a large course it will explode badly...
//
if ($mode === MODE_ENROLDETAILS) {
if ($context->id != $frontpagectx->id) {
$userids = $DB->get_fieldset_sql("SELECT DISTINCT u.id {$from} {$where} {$wheresearch}", $params, $table->get_page_start(), $table->get_page_size());
} else {
$userids = $DB->get_fieldset_sql("SELECT u.id {$from} {$where} {$wheresearch}", $params, $table->get_page_start(), $table->get_page_size());
}
$userlist_extra = get_participants_extra($userids, $avoidroles, $course, $context);
}
if ($context->id == $frontpagectx->id) {
示例6: COUNT
$where = "";
}
if ($table->get_sql_sort()) {
$sort = ' ORDER BY '.$table->get_sql_sort();
} else {
$sort = '';
}
$matchcount = $DB->count_records_sql("SELECT COUNT(u.id) $from $where", $params);
$table->initialbars(true);
$table->pagesize($perpage, $matchcount);
// list of users at the current visible page - paging makes it relatively short
$userlist = $DB->get_recordset_sql("$select $from $where $sort", $params, $table->get_page_start(), $table->get_page_size());
/// If there are multiple Roles in the course, then show a drop down menu for switching
if (count($rolenames) > 1) {
echo '<div class="rolesform">';
echo '<label for="rolesform_jump">'.get_string('currentrole', 'role').' </label>';
echo $OUTPUT->single_select($rolenamesurl, 'roleid', $rolenames, $roleid, null, 'rolesform');
echo '</div>';
} else if (count($rolenames) == 1) {
// when all users with the same role - print its name
echo '<div class="rolesform">';
echo get_string('role').get_string('labelsep', 'langconfig');
$rolename = reset($rolenames);
echo $rolename;
echo '</div>';
示例7: array
$usedgroupid = $mygroupid;
} else {
$usedgroupid = false;
}
} else {
$usedgroupid = false;
}
$matchcount = feedback_count_complete_users($cm, $usedgroupid);
$table->initialbars(true);
if ($showall) {
$startpage = false;
$pagecount = false;
} else {
$table->pagesize($perpage, $matchcount);
$startpage = $table->get_page_start();
$pagecount = $table->get_page_size();
}
$students = feedback_get_complete_users($cm, $usedgroupid, $where, $params, $sort, $startpage, $pagecount);
$completedFeedbackCount = feedback_get_completeds_group_count($feedback, $mygroupid);
if ($feedback->course == SITEID) {
$analysisurl = new moodle_url('/mod/feedback/analysis_course.php', array('id' => $id, 'courseid' => $courseid));
echo $OUTPUT->box_start('mdl-align');
echo '<a href="' . $analysisurl->out() . '">' . get_string('course') . ' ' . get_string('analysis', 'feedback') . ' (' . get_string('completed_feedbacks', 'feedback') . ': ' . intval($completedFeedbackCount) . ')</a>';
echo $OUTPUT->help_icon('viewcompleted', 'feedback');
echo $OUTPUT->box_end();
} else {
$analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id' => $id, 'courseid' => $courseid));
echo $OUTPUT->box_start('mdl-align');
echo '<a href="' . $analysisurl->out() . '">' . get_string('analysis', 'feedback') . ' (' . get_string('completed_feedbacks', 'feedback') . ': ' . intval($completedFeedbackCount) . ')</a>';
echo $OUTPUT->box_end();
}
示例8: IN
$table->no_sorting('grade');
// Start working -- this is necessary as soon as the niceties are over
$table->setup();
/// Construct the SQL
list($where, $params) = $table->get_sql_where();
if ($where) {
$where .= ' AND ';
}
if ($sort = $table->get_sql_sort()) {
$sort = ' ORDER BY ' . $sort;
}
$ufields = user_picture::fields('u', $extrafields);
if (!empty($users)) {
$select = "SELECT {$ufields} ";
$sql = 'FROM {user} u ' . 'WHERE ' . $where . 'u.id IN (' . implode(',', $users) . ') ';
$ausers = $DB->get_records_sql($select . $sql . $sort, $params, $table->get_page_start(), $table->get_page_size());
if ($ausers !== false) {
//$grading_info = grade_get_grades($course->id, 'mod', 'jclic', $jclic->id, array_keys($ausers));
$countusers = 0;
foreach ($ausers as $auser) {
$sessions_summary = jclic_get_sessions_summary($jclic->id, $auser->id);
if ($sessions_summary->attempts <= 0) {
continue;
}
$countusers++;
$picture = $OUTPUT->user_picture($auser);
$userlink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $auser->id . '&course=' . $course->id . '">' . fullname($auser, has_capability('moodle/site:viewfullnames', $context)) . '</a>';
$extradata = array();
foreach ($extrafields as $field) {
$extradata[] = $auser->{$field};
}
示例9: checksubmit
}
if ($table->get_sql_sort()) {
$sql .= ' ORDER BY ' . $table->get_sql_sort();
}
$countsql = "SELECT COUNT(DISTINCT(ra.userid))\n FROM {$CFG->prefix}role_assignments ra\n WHERE ra.contextid {$relatedcontexts} AND ra.roleid = {$roleid}";
$totalcount = count_records_sql($countsql);
if ($table->get_sql_where()) {
$matchcount = count_records_sql($countsql . ' AND ' . $table->get_sql_where());
} else {
$matchcount = $totalcount;
}
echo '<div id="participationreport">' . "\n";
echo '<p class="modulename">' . $modulename . ' ' . $strviews . ': ' . implode(', ', $viewnames) . '<br />' . "\n" . $modulename . ' ' . $strposts . ': ' . implode(', ', $postnames) . '</p>' . "\n";
$table->initialbars($totalcount > $perpage);
$table->pagesize($perpage, $matchcount);
if (!($users = get_records_sql($sql, $table->get_page_start(), $table->get_page_size()))) {
$users = array();
// tablelib will handle saying 'Nothing to display' for us.
}
$data = array();
$a->count = $totalcount;
$a->items = $role->name;
if ($matchcount != $totalcount) {
$a->count = $matchcount . '/' . $a->count;
}
echo '<h2>' . get_string('counteditems', '', $a) . '</h2>' . "\n";
echo '
<script type="text/javascript">
//<![CDATA[
function checksubmit(form) {
var destination = form.formaction.options[form.formaction.selectedIndex].value;
示例10: array
case 'time':
$databaseOrder = 'o.timesent %DIR%';
break;
}
if ($direction == SORT_ASC) {
$databaseOrder = str_replace('%DIR%', 'ASC', $databaseOrder);
} else {
$databaseOrder = str_replace('%DIR%', 'DESC', $databaseOrder);
}
if ($orderBy != '') {
$databaseOrder = ', ' . $databaseOrder;
}
$orderBy .= $databaseOrder;
}
// All parameters *MUST* be sorted out by here - getting messages
$sentMessages = $sentMessagesDAO->getSentMessagesForUser($userToView, $orderBy, 0, 0, $table->get_page_start(), $table->get_page_size(), $includeEvents);
// Populate table
foreach ($sentMessages as $message) {
if ($table->is_downloading()) {
$messageContent = $message->getMessageText();
} else {
$messageContent = html_writer::tag('a', $message->getMessageText(), array('href' => 'status.php?message=' . $message->getId() . '&course=' . $courseId . '&instance=' . $instanceId));
}
$rowData = array($message->getUser()->getFullNameForDisplay(!$table->is_downloading()), $message->getTxttoolsAccount()->getUsername(), $messageContent, $message->getTimeSent('%H:%M:%S, %d %B %Y'));
if ($includeEvents == TxttoolsSentMessageDAO::$EVENT_QUERY_INCLUDE || $includeEvents == TxttoolsSentMessageDAO::$EVENT_QUERY_EXCLUSIVE) {
$eventStr = $message->isEventCreated() ? get_string('fragsystem', 'block_moodletxt') : get_string('fraguser', 'block_moodletxt');
array_push($rowData, $eventStr);
}
$table->add_data($rowData);
}
$table->finish_output();
示例11: COUNT
if ($where = $table->get_sql_where()) {
$where .= ' AND ';
}
if ($sort = $table->get_sql_sort()) {
$sort = ' ORDER BY ' . $sort;
}
$select = 'SELECT u.id, u.firstname, u.lastname, u.picture, COUNT(s.id) AS count ';
$sql = 'FROM ' . $CFG->prefix . 'user AS u ' . 'LEFT JOIN ' . $CFG->prefix . 'stampcoll_stamps s ON u.id = s.userid AND s.stampcollid = ' . $stampcoll->id . ' ' . 'WHERE ' . $where . 'u.id IN (' . implode(',', array_keys($users)) . ') ' . 'GROUP BY u.id, u.firstname, u.lastname, u.picture ';
if (!$stampcoll->displayzero) {
$sql .= 'HAVING COUNT(s.id) > 0 ';
}
// First query with not limits to get the number of returned rows
if (($ausers = get_records_sql($select . $sql . $sort)) !== false) {
$table->pagesize($perpage, count($ausers));
// Second query with pagination limits
if (($ausers = get_records_sql($select . $sql . $sort, $table->get_page_start(), $table->get_page_size())) !== false) {
foreach ($ausers as $auser) {
$picture = print_user_picture($auser->id, $course->id, $auser->picture, false, true);
$fullname = fullname($auser);
$count = $auser->count;
$stamps = '';
if (isset($userstamps[$auser->id])) {
foreach ($userstamps[$auser->id] as $s) {
$stamps .= stampcoll_stamp($s, $stampcoll->image);
}
unset($s);
}
$row = array($picture, $fullname, $count, $stamps);
$table->add_data($row);
}
}
示例12: array
$table->setup();
if ($sort = $table->get_sql_sort()) {
$sort = ' ORDER BY ' . $sort;
}
$sql = 'SELECT * FROM {facetoface_room} WHERE custom = 0';
$perpage = 25;
$totalcount = $DB->count_records_select('facetoface_room', 'custom = 0');
$table->initialbars($totalcount > $perpage);
$table->pagesize($perpage, $totalcount);
$rooms = $DB->get_records_sql($sql.$sort, array(), $table->get_page_start(), $table->get_page_size());
$rooms_in_use = array_keys($DB->get_records_sql('SELECT DISTINCT(roomid) FROM {facetoface_sessions}'));
foreach ($rooms as $room) {
$row = array();
$buttons = array();
$row[] = $room->name;
$row[] = $room->building;
$row[] = $room->address;
$row[] = $room->capacity;
$editbutton = '';
$deletebutton = '';
/*commented by hameed on 21 dec reg: bug fix*/
示例13: display_allfilesform
//.........这里部分代码省略.........
// Sorted by lastname by default.
$table->collapsible(false);
$table->initialbars(true);
$table->column_class('fullname', 'fullname');
$table->column_class('timemodified', 'timemodified');
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'publications');
$table->set_attribute('width', '100%');
$table->no_sorting('studentapproval');
$table->no_sorting('selection');
$table->no_sorting('teacherapproval');
$table->no_sorting('visibleforstudents');
// Start working -- this is necessary as soon as the niceties are over.
$table->setup();
// Construct the SQL.
list($where, $params) = $table->get_sql_where();
if ($where) {
$where .= ' AND ';
}
if ($sort = $table->get_sql_sort()) {
$sort = ' ORDER BY ' . $sort;
}
$ufields = user_picture::fields('u');
$useridentityfields = $CFG->showuseridentity != '' ? 'u.' . str_replace(', ', ', u.', $CFG->showuseridentity) . ', ' : '';
$totalfiles = 0;
if (!empty($users)) {
$select = 'SELECT ' . $ufields . ', ' . $useridentityfields . ' username,
COUNT(*) filecount,
SUM(files.studentapproval) as status,
MAX(files.timecreated) timemodified ';
$sql = 'FROM {user} u ' . 'LEFT JOIN {publication_file} files ON u.id = files.userid
AND files.publication = ' . $this->get_instance()->id . ' ' . 'WHERE ' . $where . 'u.id IN (' . implode(', ', $users) . ') ' . 'GROUP BY ' . $ufields . ', ' . $useridentityfields . ' username ';
$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');
if ($ausers !== false) {
$endposition = $offset + $perpage;
$currentposition = 0;
$valid = $OUTPUT->pix_icon('i/valid', get_string('student_approved', 'publication'));
$questionmark = $OUTPUT->pix_icon('questionmark', get_string('student_pending', 'publication'), 'mod_publication');
$invalid = $OUTPUT->pix_icon('i/invalid', get_string('student_rejected', 'publication'));
$visibleforstundetsyes = $OUTPUT->pix_icon('i/valid', get_string('visibleforstudents_yes', 'publication'));
$visibleforstundetsno = $OUTPUT->pix_icon('i/invalid', get_string('visibleforstudents_no', 'publication'));
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->context);
foreach ($ausers as $auser) {
if ($currentposition >= $offset && $currentposition < $endposition) {
// Calculate user status.
$selecteduser = html_writer::checkbox('selectedeuser[' . $auser->id . ']', 'selected', false, null, array('class' => 'userselection'));
$useridentity = $CFG->showuseridentity != '' ? explode(',', $CFG->showuseridentity) : array();
foreach ($useridentity as $cur) {
if (!(get_config('publication', 'hideidnumberfromstudents') && $cur == "idnumber" && !has_capability('mod/publication:approve', $context)) && !($cur != "idnumber" && !has_capability('mod/publication:approve', $context))) {
if (!empty($auser->{$cur})) {
${$cur} = html_writer::tag('div', $auser->{$cur}, array('id' => 'u' . $cur . $auser->id));
} else {
${$cur} = html_writer::tag('div', '-', array('id' => 'u' . $cur . $auser->id));
}
}
}
$userlink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $auser->id . '&course=' . $course->id . '">' . fullname($auser, $viewfullnames) . '</a>';
$extension = $this->user_extensionduedate($auser->id);
if ($extension) {
if (has_capability('mod/publication:grantextension', $context) || has_capability('mod/publication:approve', $context)) {
$userlink .= '<br/>' . get_string('extensionto', 'publication') . ': ' . userdate($extension);
示例14: switch
/**
* Helper method, displays a table
* of users with checkboxes next to them.
* Also includes a submit button to take
* action on those users.
*
* @param string $hook The calling hook
* @return string
* @todo Not in love with this method, but it works
**/
function display_user_table($hook)
{
global $CFG;
global $DB, $OUTPUT;
require_once $CFG->libdir . '/tablelib.php';
ob_start();
$pagesize = optional_param('pagesize', 50, PARAM_INT);
print "<form class=\"userform\" id=\"userformid\" action=\"{$CFG->wwwroot}/blocks/gdata/index.php\" method=\"post\">";
$table = new flexible_table("blocks-gdata-{$hook}");
$filter = $this->create_filter($hook, $pagesize);
// Define columns based on hook
switch ($hook) {
case 'users':
$table->define_columns(array('username', 'fullname', 'email', 'lastsync', 'status'));
$table->define_headers(array(get_string('username'), get_string('fullname'), get_string('email'), get_string('lastsync', 'block_gdata'), get_string('status')));
break;
case 'addusers':
$table->define_columns(array('username', 'fullname', 'email'));
$table->define_headers(array(get_string('username'), get_string('fullname'), get_string('email')));
break;
}
$table->define_baseurl("{$CFG->wwwroot}/blocks/gdata/index.php?hook={$hook}&pagesize={$pagesize}");
$table->pageable(true);
$table->sortable(true, 'username', SORT_DESC);
$table->set_attribute('width', '100%');
$table->set_attribute('class', 'flexible generaltable generalbox');
$table->column_style('action', 'text-align', 'center');
$table->setup();
list($select, $from, $where, $params) = $this->get_sql($hook, $filter);
$total = $DB->count_records_sql("SELECT COUNT(*) {$from} {$where}", $params);
$table->pagesize($pagesize, $total);
if ($users = $DB->get_records_sql("{$select} {$from} {$where} ORDER BY " . $table->get_sql_sort(), array(), $table->get_page_start(), $table->get_page_size())) {
foreach ($users as $user) {
$username = print_checkbox("userids[]", $user->id, false, s($user->username), s($user->username), '', true);
// Define table contents based on hook
switch ($hook) {
case 'users':
if ($user->lastsync > 0) {
$lastsync = userdate($user->lastsync);
} else {
$lastsync = get_string('never');
}
$table->add_data(array($username, fullname($user), $user->email, $lastsync, get_string("status{$user->status}", 'block_gdata')));
break;
case 'addusers':
$table->add_data(array($username, fullname($user), $user->email));
break;
}
}
}
print $OUTPUT->box_start('boxaligncenter boxwidthwide', '', array());
print $filter->display_add();
print $filter->display_active();
if (empty($table->totalrows)) {
// Avoid printing the form on empty tables
print $table->finish_output();
} else {
$allstr = get_string('selectall', 'block_gdata');
$nonestr = get_string('selectnone', 'block_gdata');
$submitstr = get_string("submitbutton{$hook}", 'block_gdata');
$submitallstr = get_string("submitbuttonall{$hook}", 'block_gdata', $total);
$confirmstr = get_string("confirm{$hook}", 'block_gdata', $total);
$confirmstr = addslashes_js($confirmstr);
$options = array(50 => 50, 100 => 100, 250 => 250, 500 => 500, 1000 => 1000);
print '<input type="hidden" name="hook" value="' . $hook . '" />';
print '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
print $table->finish_output();
print "<p><a href=\"#\" title=\"{$allstr}\" onclick=\"select_all_in('FORM', 'userform', 'userformid'); return false;\">{$allstr}</a> / ";
print "<a href=\"#\" title=\"{$nonestr}\" onclick=\"deselect_all_in('FORM', 'userform', 'userformid'); return false;\">{$nonestr}</a></p>";
print "<input type=\"submit\" name=\"users\" value=\"{$submitstr}\" /> ";
print "<input type=\"submit\" name=\"allusers\" value=\"{$submitallstr}\" onclick=\"return confirm('{$confirmstr}');\" />";
print '</form><br />';
print $OUTPUT->single_select("{$CFG->wwwroot}/blocks/gdata/index.php?hook={$hook}&pagesize=", 'changepagesize', $options, $pagesize);
}
print $OUTPUT->box_end(true);
$tablehtml = ob_get_contents();
ob_end_clean();
return $tablehtml;
}
示例15: display
//.........这里部分代码省略.........
}
if (!$download) {
// Add extra limits due to initials bar.
list($twhere, $tparams) = $table->get_sql_where();
if ($twhere) {
$where .= ' AND ' . $twhere;
// Initial bar.
$params = array_merge($params, $tparams);
}
if (!empty($countsql)) {
$count = $DB->get_record_sql($countsql, $params);
$totalinitials = $count->nbresults;
if ($twhere) {
$countsql .= ' AND ' . $twhere;
}
$count = $DB->get_record_sql($countsql, $params);
$total = $count->nbresults;
}
$table->pagesize($pagesize, $total);
echo \html_writer::start_div('scormattemptcounts');
if ($count->nbresults == $count->nbattempts) {
echo get_string('reportcountattempts', 'scorm', $count);
} else {
if ($count->nbattempts > 0) {
echo get_string('reportcountallattempts', 'scorm', $count);
} else {
echo $count->nbusers . ' ' . get_string('users');
}
}
echo \html_writer::end_div();
}
// Fetch the attempts.
if (!$download) {
$attempts = $DB->get_records_sql($select . $from . $where . $sort, $params, $table->get_page_start(), $table->get_page_size());
echo \html_writer::start_div('', array('id' => 'scormtablecontainer'));
if ($candelete) {
// Start form.
$strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm'));
echo \html_writer::start_tag('form', array('id' => 'attemptsform', 'method' => 'post', 'action' => $PAGE->url->out(false), 'onsubmit' => 'return confirm("' . $strreallydel . '");'));
echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'delete'));
echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
echo \html_writer::start_div('', array('style' => 'display: none;'));
echo \html_writer::input_hidden_params($PAGE->url);
echo \html_writer::end_div();
echo \html_writer::start_div();
}
$table->initialbars($totalinitials > 20);
// Build table rows.
} else {
$attempts = $DB->get_records_sql($select . $from . $where . $sort, $params);
}
if ($attempts) {
foreach ($attempts as $scouser) {
$row = array();
if (!empty($scouser->attempt)) {
$timetracks = scorm_get_sco_runtime($scorm->id, false, $scouser->userid, $scouser->attempt);
} else {
$timetracks = '';
}
if (in_array('checkbox', $columns)) {
if ($candelete && !empty($timetracks->start)) {
$row[] = \html_writer::checkbox('attemptid[]', $scouser->userid . ':' . $scouser->attempt, false);
} else {
if ($candelete) {
$row[] = '';
}