本文整理汇总了PHP中flexible_table::collapsible方法的典型用法代码示例。如果您正苦于以下问题:PHP flexible_table::collapsible方法的具体用法?PHP flexible_table::collapsible怎么用?PHP flexible_table::collapsible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flexible_table
的用法示例。
在下文中一共展示了flexible_table::collapsible方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run_table_test
protected function run_table_test($columns, $headers, $sortable, $collapsible, $suppress, $nosorting, $data, $pagesize)
{
$table = new flexible_table('tablelib_test');
$table->define_columns($columns);
$table->define_headers($headers);
$table->define_baseurl('/invalid.php');
$table->sortable($sortable);
$table->collapsible($collapsible);
foreach ($suppress as $column) {
$table->column_suppress($column);
}
foreach ($nosorting as $column) {
$table->no_sorting($column);
}
$table->setup();
$table->pagesize($pagesize, count($data));
foreach ($data as $row) {
$table->add_data_keyed($row);
}
$table->finish_output();
}
示例2: list_transactions
public function list_transactions($transactions)
{
global $CFG;
$table = new flexible_table('local-magentoconnector-transaction-list');
$table->define_columns(array('user', 'course', 'transactionid', 'timestamp'));
$table->define_headers(array(get_string('user'), get_string('course'), get_string('transactionid', 'local_magentoconnector'), get_string('timestamp', 'local_magentoconnector')));
$table->define_baseurl(new moodle_url('/local/magentoconnector/viewtransactions.php'));
$table->sortable(false);
$table->collapsible(false);
$table->column_class('user', 'user');
$table->column_class('course', 'course');
$table->column_class('transactionid', 'transactionid');
$table->column_class('timestamp', 'timestamp');
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'local-magentoconnector-transaction-list');
$table->set_attribute('class', 'local-magentoconnector-transaction-list generaltable');
$table->set_attribute('width', '100%');
$table->setup();
if ($transactions) {
$user = new stdClass();
foreach ($transactions as $transaction) {
$user->id = $transaction->userid;
$user->firstname = $transaction->firstname;
$user->lastname = $transaction->lastname;
$user->firstnamephonetic = $transaction->firstnamephonetic;
$user->lastnamephonetic = $transaction->lastnamephonetic;
$user->middlename = $transaction->middlename;
$user->alternatename = $transaction->alternatename;
$row = array();
$userurl = new moodle_url($CFG->wwwroot . '/user/profile.php', array('id' => $user->id));
$row[] = html_writer::link($userurl, fullname($user), array('title' => get_string('viewprofile')));
$courseurl = new moodle_url($CFG->wwwroot . '/course/view.php', array('id' => $transaction->courseid));
$row[] = html_writer::link($courseurl, $transaction->course, array('title' => $transaction->course));
$row[] = $transaction->ordernum;
$row[] = userdate($transaction->timestamp, get_string('strftimedatetime'));
$table->add_data($row);
}
}
$table->print_html();
}
示例3: display
//.........这里部分代码省略.........
$countsql .= $from . $where;
$nbmaincolumns = count($columns);
// Get number of main columns used.
$objectives = get_scorm_objectives($scorm->id);
$nosort = array();
foreach ($objectives as $scoid => $sco) {
foreach ($sco as $id => $objectivename) {
$colid = $scoid . 'objectivestatus' . $id;
$columns[] = $colid;
$nosort[] = $colid;
if (!$displayoptions['objectivescore']) {
// Display the objective name only.
$headers[] = $objectivename;
} else {
// Display the objective status header with a "status" suffix to avoid confusion.
$headers[] = $objectivename . ' ' . get_string('status', 'scormreport_objectives');
// Now print objective score headers.
$colid = $scoid . 'objectivescore' . $id;
$columns[] = $colid;
$nosort[] = $colid;
$headers[] = $objectivename . ' ' . get_string('score', 'scormreport_objectives');
}
}
}
$emptycell = '';
// Used when an empty cell is being printed - in html we add a space.
if (!$download) {
$emptycell = ' ';
$table = new \flexible_table('mod-scorm-report');
$table->define_columns($columns);
$table->define_headers($headers);
$table->define_baseurl($PAGE->url);
$table->sortable(true);
$table->collapsible(true);
// This is done to prevent redundant data, when a user has multiple attempts.
$table->column_suppress('picture');
$table->column_suppress('fullname');
foreach ($extrafields as $field) {
$table->column_suppress($field);
}
foreach ($nosort as $field) {
$table->no_sorting($field);
}
$table->no_sorting('start');
$table->no_sorting('finish');
$table->no_sorting('score');
$table->no_sorting('checkbox');
$table->no_sorting('picture');
foreach ($scoes as $sco) {
if ($sco->launch != '') {
$table->no_sorting('scograde' . $sco->id);
}
}
$table->column_class('picture', 'picture');
$table->column_class('fullname', 'bold');
$table->column_class('score', 'bold');
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'generaltable generalbox');
// Start working -- this is necessary as soon as the niceties are over.
$table->setup();
} else {
if ($download == 'ODS') {
require_once "{$CFG->libdir}/odslib.class.php";
$filename .= ".ods";
// Creating a workbook.
示例4: count
/**
* Prints a table with users and their attempts
*
* @return void
* @todo Add current grade to the table
* Finnish documenting
**/
function view_question($quiz, $question, $totalattempts, $ungraded)
{
global $CFG;
$usercount = count($this->users);
// set up table
$tablecolumns = array('picture', 'fullname', 'timefinish', 'grade');
$tableheaders = array('', get_string('name'), get_string("completedon", "quiz"), '');
$table = new flexible_table('mod-quiz-report-grading');
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$table->define_baseurl($this->viewurl->out());
$table->sortable(true);
$table->initialbars($usercount > 20);
// will show initialbars if there are more than 20 users
$table->pageable(true);
$table->collapsible(true);
$table->column_suppress('fullname');
$table->column_suppress('picture');
$table->column_suppress('grade');
$table->column_class('picture', 'picture');
// attributes in the table tag
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'generaltable generalbox');
$table->set_attribute('align', 'center');
//$table->set_attribute('width', '50%');
// get it ready!
$table->setup();
list($select, $from, $where) = $this->attempts_sql($quiz->id, true, $question->id);
if ($table->get_sql_where()) {
// forgot what this does
$where .= 'AND ' . $table->get_sql_where();
}
// sorting of the table
if ($sort = $table->get_sql_sort()) {
$sort = 'ORDER BY ' . $sort;
// seems like I would need to have u. or qa. infront of the ORDER BY attribues... but seems to work..
} else {
// my default sort rule
$sort = 'ORDER BY u.firstname, u.lastname, qa.timefinish ASC';
}
// set up the pagesize
$table->pagesize(QUIZ_REPORT_DEFAULT_PAGE_SIZE, $totalattempts);
// get the attempts and process them
if ($attempts = get_records_sql($select . $from . $where . $sort, $table->get_page_start(), $table->get_page_size())) {
// grade all link
$links = "<strong><a href=\"report.php?mode=grading&gradeall=1&q={$quiz->id}&questionid={$question->id}\">" . get_string('gradeall', 'quiz_grading', $totalattempts) . '</a></strong>';
if ($ungraded > 0) {
$links .= "<br /><strong><a href=\"report.php?mode=grading&gradeungraded=1&q={$quiz->id}&questionid={$question->id}\">" . get_string('gradeungraded', 'quiz_grading', $ungraded) . '</a></strong>';
if ($ungraded > QUIZ_REPORT_DEFAULT_GRADING_PAGE_SIZE) {
$links .= "<br /><strong><a href=\"report.php?mode=grading&gradenextungraded=1&q={$quiz->id}&questionid={$question->id}\">" . get_string('gradenextungraded', 'quiz_grading', QUIZ_REPORT_DEFAULT_GRADING_PAGE_SIZE) . '</a></strong>';
}
}
$table->add_data_keyed(array('grade' => $links));
$table->add_separator();
foreach ($attempts as $attempt) {
$picture = print_user_picture($attempt->userid, $quiz->course, $attempt->picture, false, true);
// link to student profile
$userlink = "<a href=\"{$CFG->wwwroot}/user/view.php?id={$attempt->userid}&course={$quiz->course}\">" . fullname($attempt, true) . '</a>';
$gradedclass = question_state_is_graded($attempt) ? ' class="highlightgraded" ' : '';
$gradedstring = question_state_is_graded($attempt) ? ' ' . get_string('graded', 'quiz_grading') : '';
// link for the attempt
$attemptlink = "<a {$gradedclass}href=\"report.php?mode=grading&q={$quiz->id}&questionid={$question->id}&attemptid={$attempt->attemptid}\">" . userdate($attempt->timefinish, get_string('strftimedatetime')) . $gradedstring . '</a>';
// grade all attempts for this user
$gradelink = "<a href=\"report.php?mode=grading&q={$quiz->id}&questionid={$question->id}&userid={$attempt->userid}\">" . get_string('grade') . '</a>';
$table->add_data(array($picture, $userlink, $attemptlink, $gradelink));
}
$table->add_separator();
$table->add_data_keyed(array('grade' => $links));
// print everything here
echo '<div id="tablecontainer">';
$table->print_html();
echo '</div>';
} else {
notify(get_string('noattemptstoshow', 'quiz'));
}
}
示例5: display
//.........这里部分代码省略.........
$columns[] = 'idnumber';
$headers[] = get_string('idnumber');
}
$columns[] = 'timestart';
$headers[] = get_string('startedon', 'quiz');
$columns[] = 'timefinish';
$headers[] = get_string('timecompleted', 'quiz');
$columns[] = 'duration';
$headers[] = get_string('attemptduration', 'quiz');
if ($showgrades) {
$columns[] = 'sumgrades';
$headers[] = get_string('grade', 'quiz') . '/' . $quiz->grade;
}
if ($detailedmarks) {
// we want to display marks for all questions
$questions = quiz_report_load_questions($quiz);
foreach ($questions as $id => $question) {
// Ignore questions of zero length
$columns[] = 'qsgrade' . $id;
$headers[] = '#' . $question->number;
}
}
if ($hasfeedback) {
$columns[] = 'feedbacktext';
$headers[] = get_string('feedback', 'quiz');
}
if (!$download) {
// Set up the table
$table = new flexible_table('mod-quiz-report-overview-report');
$table->define_columns($columns);
$table->define_headers($headers);
$table->define_baseurl($reporturlwithdisplayoptions->out());
$table->sortable(true);
$table->collapsible(true);
$table->column_suppress('picture');
$table->column_suppress('fullname');
$table->column_suppress('idnumber');
$table->no_sorting('feedbacktext');
$table->column_class('picture', 'picture');
$table->column_class('fullname', 'bold');
$table->column_class('sumgrades', 'bold');
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'generaltable generalbox');
// Start working -- this is necessary as soon as the niceties are over
$table->setup();
} else {
if ($download == 'ODS') {
require_once "{$CFG->libdir}/odslib.class.php";
$filename .= ".ods";
// Creating a workbook
$workbook = new MoodleODSWorkbook("-");
// Sending HTTP headers
$workbook->send($filename);
// Creating the first worksheet
$sheettitle = get_string('reportoverview', 'quiz');
$myxls =& $workbook->add_worksheet($sheettitle);
// format types
$format =& $workbook->add_format();
$format->set_bold(0);
$formatbc =& $workbook->add_format();
$formatbc->set_bold(1);
$formatbc->set_align('center');
$formatb =& $workbook->add_format();
$formatb->set_bold(1);
$formaty =& $workbook->add_format();
示例6: array
/**
* Display all the submissions ready for grading
*/
function display_submissions()
{
global $CFG, $db, $USER;
/* first we check to see if the form has just been submitted
* to request user_preference updates
*/
if (isset($_POST['updatepref'])) {
$perpage = optional_param('perpage', 10, PARAM_INT);
$perpage = $perpage <= 0 ? 10 : $perpage;
set_user_preference('webquestscorm_perpage', $perpage);
set_user_preference('webquestscorm_quickgrade', optional_param('quickgrade', 0, PARAM_BOOL));
}
/* next we get perpage and quickgrade (allow quick grade) params
* from database
*/
$perpage = get_user_preferences('webquestscorm_perpage', 10);
$quickgrade = get_user_preferences('webquestscorm_quickgrade', 0);
$teacherattempts = true;
/// Temporary measure
$page = optional_param('page', 0, PARAM_INT);
$strsaveallfeedback = get_string('saveallfeedback', 'webquestscorm');
/// Some shortcuts to make the code read better
$tabindex = 1;
//tabindex for quick grading tabbing; Not working for dropdowns yet
add_to_log($this->course->id, 'webquestscorm', 'view submission', 'editsubmissions.php?cmid=' . $this->cm->id . '&element=uploadedTasks&subelement=all', $this->wqid, $this->cm->id);
$strwebquestscorms = get_string('modulenameplural', 'webquestscorm');
$strwebquestscorm = get_string('modulename', 'webquestscorm');
///Position swapped
if ($groupmode = groupmode($this->course, $this->cm)) {
// Groups are being used
$currentgroup = setup_and_print_groups($this->course, $groupmode, 'editsubmissions.php?cmid=' . $this->cm->id . '&element=uploadedTasks&subelement=all');
} else {
$currentgroup = false;
}
/// Get all teachers and students
if ($currentgroup) {
$users = get_group_users($currentgroup);
} else {
//$users = get_users_by_capability($this->context, 'mod/webquestscorm:submit'); // everyone with this capability set to non-prohibit
$users = get_course_students($this->course->id);
}
$tablecolumns = array('picture', 'fullname', 'grade', 'submissioncomment', 'timemodified', 'timemarked', 'status');
$tableheaders = array('', get_string('fullname'), get_string('grade'), get_string('comment', 'webquestscorm'), get_string('lastmodified') . ' (' . $this->course->student . ')', get_string('lastmodified') . ' (' . $this->course->teacher . ')', get_string('status'));
require_once $CFG->libdir . '/tablelib.php';
$table = new flexible_table('mod-webquestscorm-submissions');
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$table->define_baseurl($CFG->wwwroot . '/mod/webquestscorm/editsubmissions.php?cmid=' . $this->cm->id . '&element=uploadedTasks&subelement=all&currentgroup=' . $currentgroup);
$table->define_baseurl($CFG->wwwroot . '/mod/webquestscorm/editsubmissions.php?cmid=' . $this->cm->id . '&currentgroup=' . $currentgroup . '&element=uploadedTasks&subelement=all');
$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');
$table->column_class('grade', 'grade');
$table->column_class('submissioncomment', 'comment');
$table->column_class('timemodified', 'timemodified');
$table->column_class('timemarked', 'timemarked');
$table->column_class('status', 'status');
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'submissions');
$table->set_attribute('width', '90%');
$table->set_attribute('align', 'center');
// Start working -- this is necessary as soon as the niceties are over
$table->setup();
/// Check to see if groups are being used in this webquestscorm
if (!$teacherattempts) {
$teachers = get_course_teachers($this->course->id);
if (!empty($teachers)) {
$keys = array_keys($teachers);
}
foreach ($keys as $key) {
unset($users[$key]);
}
}
if (empty($users)) {
print_heading(get_string('noattempts', 'webquestscorm'));
print_footer($this->course);
return true;
}
/// Construct the SQL
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,
s.id AS submissionid, s.grade, s.submissioncomment,
s.timemodified, s.timemarked ';
$sql = 'FROM ' . $CFG->prefix . 'user u ' . 'LEFT JOIN ' . $CFG->prefix . 'webquestscorm_submissions s ON u.id = s.userid
AND s.webquestscorm = ' . $this->wqid . ' ' . 'WHERE ' . $where . 'u.id IN (' . implode(',', array_keys($users)) . ') ';
$table->pagesize($perpage, count($users));
//.........这里部分代码省略.........
示例7: array
//.........这里部分代码省略.........
// 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));
}
}
$tablecolumns = array('picture', 'fullname', 'grade', 'submissioncomment', 'timemodified', 'timemarked', 'status', 'finalgrade');
if ($uses_outcomes) {
$tablecolumns[] = 'outcome'; // no sorting based on outcomes column
}
$tableheaders = array('',
get_string('fullname'),
get_string('grade'),
get_string('comment', 'assignment'),
get_string('lastmodified').' ('.get_string('submission', 'assignment').')',
get_string('lastmodified').' ('.get_string('grade').')',
get_string('status'),
get_string('finalgrade', 'grades'));
if ($uses_outcomes) {
$tableheaders[] = get_string('outcome', 'grades');
}
require_once($CFG->libdir.'/tablelib.php');
$table = new flexible_table('mod-assignment-submissions');
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$table->define_baseurl($CFG->wwwroot.'/mod/assignment/submissions.php?id='.$this->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');
$table->column_class('grade', 'grade');
$table->column_class('submissioncomment', 'comment');
$table->column_class('timemodified', 'timemodified');
$table->column_class('timemarked', 'timemarked');
$table->column_class('status', 'status');
$table->column_class('finalgrade', 'finalgrade');
if ($uses_outcomes) {
$table->column_class('outcome', 'outcome');
}
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'submissions');
$table->set_attribute('width', '100%');
//$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>';
示例8: dialogue_list_conversations
/**
* List conversations of either open or closed type for the current user
*
* Called when a user clicks the "Current Dialogues" or "Closed Dialogues" tabs
* rendering those out directly as HTML inside a print_table() showing who the
* conversation is with, what the subject is, how many entries there are,
* how many are un-read and what the most recent post date is
*
* @param object $dialogue
* @param int $groupid of the group to filter conversations by (default: 0)
* @param string $type 'open' (default) or 'closed'
* @todo remove the embedded style for 'th', make it a class driven thing in the theme
*/
function dialogue_list_conversations($dialogue, $groupid = 0, $type = 'open')
{
global $USER, $CFG;
$condition = $type == 'closed' ? " closed='1' " : " closed='0' ";
$tabid = $type == 'closed' ? 3 : 1;
if (!($course = get_record('course', 'id', $dialogue->course))) {
error('Course is misconfigured');
}
if (!($cm = get_coursemodule_from_instance('dialogue', $dialogue->id, $course->id))) {
error('Course Module ID was incorrect');
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$dialoguemanagers = array_keys(get_users_by_capability($context, 'mod/dialogue:manage'));
echo '<style>th.header { text-align: left; }</style>';
require_once $CFG->libdir . '/tablelib.php';
$tablecolumns = array('picture', 'subject', 'fullname', 'total', 'unread', 'lastentry');
$tableheaders = array('', get_string('subject', 'dialogue'), get_string('fullname', ''), get_string('numberofentries', 'dialogue'), get_string('unread', 'dialogue'), get_string('lastentry', 'dialogue'));
$table = new flexible_table('mod-dialogue-submissions');
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$table->define_baseurl($CFG->wwwroot . '/mod/dialogue/view.php?id=' . $cm->id . '&pane=' . $tabid);
$table->sortable(true, 'subject');
$table->collapsible(false);
//$table->column_suppress('picture'); // supress multiple subsequent row entries
//$table->column_suppress('fullname');
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'dialogue');
$table->set_attribute('class', 'conversations');
$table->set_attribute('width', '100%');
$table->setup();
$order = '';
// so we can filter the get_conversations() call later
$namesort = '';
// if we want to sort by other calculated fields, e.g. first/last name
if ($sort = $table->get_sql_sort('mod-dialogue-submissions')) {
$sortparts = explode(',', $sort);
$sqlsort = $sortparts[0];
if (strpos($sqlsort, 'subject') !== false) {
$order = $sqlsort;
}
if (strpos($sqlsort, 'total') !== false) {
$order = $sqlsort;
}
if (strpos($sqlsort, 'lastentry') !== false) {
$order = $sqlsort;
$order = str_replace('lastentry', 'c.timemodified', $order);
}
if (strpos($sqlsort, 'firstname') !== false) {
$namesort = $sqlsort;
}
if (strpos($sqlsort, 'lastname') !== false) {
$namesort = $sqlsort;
}
if (strpos($sqlsort, 'unread') !== false) {
$namesort = $sqlsort;
}
}
// list the conversations requiring a resonse from this user in full
if ($conversations = dialogue_get_conversations($dialogue, $USER, $condition, $order, $groupid)) {
foreach ($conversations as $conversation) {
if (in_array($USER->id, $dialoguemanagers)) {
if (!in_array($conversation->userid, $dialoguemanagers)) {
if (!($with = get_record('user', 'id', $conversation->userid))) {
error("User's record not found");
}
} else {
if (!($with = get_record('user', 'id', $conversation->recipientid))) {
error("User's record not found");
}
}
} else {
if ($USER->id != $conversation->userid) {
if (!($with = get_record('user', 'id', $conversation->userid))) {
error("User's record not found");
}
} else {
if (!($with = get_record('user', 'id', $conversation->recipientid))) {
error("User's record not found");
}
}
}
// save sortable field values for each conversation so can sort by them later
$names[$conversation->id] = fullname($with);
$unread[$conversation->id] = $conversation->total - $conversation->readings;
$names_firstlast[$conversation->id] = $with->firstname . ' ' . $with->lastname;
$names_lastfirst[$conversation->id] = $with->lastname . ' ' . $with->firstname;
$photos[$conversation->id] = print_user_picture($with, $course->id, true, 0, true);
//.........这里部分代码省略.........
示例9: foreach
if ($sco->launch != '') {
$columns[] = 'scograde' . $sco->id;
$headers[] = format_string($sco->title);
$table->head[] = format_string($sco->title);
}
}
} else {
$scoes = NULL;
}
if (!$download) {
$table = new flexible_table('mod-scorm-report');
$table->define_columns($columns);
$table->define_headers($headers);
$table->define_baseurl($reporturlwithdisplayoptions->out());
$table->sortable(true);
$table->collapsible(true);
$table->column_suppress('picture');
$table->column_suppress('fullname');
$table->column_suppress('idnumber');
$table->no_sorting('start');
$table->no_sorting('finish');
$table->no_sorting('score');
if ($scoes) {
foreach ($scoes as $sco) {
if ($sco->launch != '') {
$table->no_sorting('scograde' . $sco->id);
}
}
}
$table->column_class('picture', 'picture');
$table->column_class('fullname', 'bold');
示例10: display_allfilesform
//.........这里部分代码省略.........
$tablecolumns = array('selection', 'fullname');
$tableheaders = array($selectallnone, get_string('fullnameuser'));
$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))) {
$tablecolumns[] = $cur;
$tableheaders[] = $cur == 'phone1' ? get_string('phone') : get_string($cur);
}
}
$tableheaders[] = get_string('lastmodified');
$tablecolumns[] = 'timemodified';
if (has_capability('mod/publication:approve', $context)) {
// Not necessary in upload mode without studentapproval.
if ($this->get_instance()->mode == PUBLICATION_MODE_IMPORT && $this->get_instance()->obtainstudentapproval) {
$tablecolumns[] = 'studentapproval';
$tableheaders[] = get_string('studentapproval', 'publication') . ' ' . $OUTPUT->help_icon('studentapproval', 'publication');
}
$tablecolumns[] = 'teacherapproval';
if ($this->get_instance()->mode == PUBLICATION_MODE_IMPORT && $this->get_instance()->obtainstudentapproval) {
$tableheaders[] = get_string('obtainstudentapproval', 'publication');
} else {
$tableheaders[] = get_string('teacherapproval', 'publication');
}
$tablecolumns[] = 'visibleforstudents';
$tableheaders[] = get_string('visibleforstudents', 'publication');
}
require_once $CFG->libdir . '/tablelib.php';
$table = new flexible_table('mod-publication-allfiles');
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$table->define_baseurl($CFG->wwwroot . '/mod/publication/view.php?id=' . $cm->id . '&currentgroup=' . $currentgroup);
$table->sortable(true, 'lastname');
// 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());
示例11: 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;
//.........这里部分代码省略.........
示例12: create_and_setup_table
/**
* Create a table with properties as passed in params.
*
* @param string[] $columns
* @param string[] $headers
* @param bool $sortable
* @param bool $collapsible
* @param string[] $suppress
* @param string[] $nosorting
* @return flexible_table
*/
protected function create_and_setup_table($columns, $headers, $sortable, $collapsible, $suppress, $nosorting)
{
$table = new flexible_table('tablelib_test');
$table->define_columns($columns);
$table->define_headers($headers);
$table->define_baseurl('/invalid.php');
$table->sortable($sortable);
$table->collapsible($collapsible);
foreach ($suppress as $column) {
$table->column_suppress($column);
}
foreach ($nosorting as $column) {
$table->no_sorting($column);
}
$table->setup();
return $table;
}
示例13: test_persistent_table
public function test_persistent_table()
{
global $SESSION;
$data = $this->generate_data(5, 5);
$columns = $this->generate_columns(5);
$headers = $this->generate_headers(5);
// Testing without persistence first to verify that the results are different.
$table1 = new flexible_table('tablelib_test');
$table1->define_columns($columns);
$table1->define_headers($headers);
$table1->define_baseurl('/invalid.php');
$table1->sortable(true);
$table1->collapsible(true);
$table1->is_persistent(false);
$_GET['thide'] = 'column0';
$_GET['tsort'] = 'column1';
$_GET['tifirst'] = 'A';
$_GET['tilast'] = 'Z';
foreach ($data as $row) {
$table1->add_data_keyed($row);
}
$table1->setup();
// Clear session data between each new table.
unset($SESSION->flextable);
$table2 = new flexible_table('tablelib_test');
$table2->define_columns($columns);
$table2->define_headers($headers);
$table2->define_baseurl('/invalid.php');
$table2->sortable(true);
$table2->collapsible(true);
$table2->is_persistent(false);
unset($_GET);
foreach ($data as $row) {
$table2->add_data_keyed($row);
}
$table2->setup();
$this->assertNotEquals($table1, $table2);
unset($SESSION->flextable);
// Now testing with persistence to check that the tables are the same.
$table3 = new flexible_table('tablelib_test');
$table3->define_columns($columns);
$table3->define_headers($headers);
$table3->define_baseurl('/invalid.php');
$table3->sortable(true);
$table3->collapsible(true);
$table3->is_persistent(true);
$_GET['thide'] = 'column0';
$_GET['tsort'] = 'column1';
$_GET['tifirst'] = 'A';
$_GET['tilast'] = 'Z';
foreach ($data as $row) {
$table3->add_data_keyed($row);
}
$table3->setup();
unset($SESSION->flextable);
$table4 = new flexible_table('tablelib_test');
$table4->define_columns($columns);
$table4->define_headers($headers);
$table4->define_baseurl('/invalid.php');
$table4->sortable(true);
$table4->collapsible(true);
$table4->is_persistent(true);
unset($_GET);
foreach ($data as $row) {
$table4->add_data_keyed($row);
}
$table4->setup();
$this->assertEquals($table3, $table4);
unset($SESSION->flextable);
// Finally, another test with no persistence, but without clearing the session data.
$table5 = new flexible_table('tablelib_test');
$table5->define_columns($columns);
$table5->define_headers($headers);
$table5->define_baseurl('/invalid.php');
$table5->sortable(true);
$table5->collapsible(true);
$table5->is_persistent(true);
$_GET['thide'] = 'column0';
$_GET['tsort'] = 'column1';
$_GET['tifirst'] = 'A';
$_GET['tilast'] = 'Z';
foreach ($data as $row) {
$table5->add_data_keyed($row);
}
$table5->setup();
$table6 = new flexible_table('tablelib_test');
$table6->define_columns($columns);
$table6->define_headers($headers);
$table6->define_baseurl('/invalid.php');
$table6->sortable(true);
$table6->collapsible(true);
$table6->is_persistent(true);
unset($_GET);
foreach ($data as $row) {
$table6->add_data_keyed($row);
}
$table6->setup();
$this->assertEquals($table5, $table6);
}
示例14: display
//.........这里部分代码省略.........
// Start by getting all questions.
$questionlist = game_questions_in_game($game->questions);
$questionids = explode(',', $questionlist);
$sql = "SELECT q.*, i.score AS maxgrade, i.id AS instance" . " FROM {question} q," . " {game_queries} i" . " WHERE i.gameid = '{$game->id}' AND q.id = i.questionid" . " AND q.id IN ({$questionlist})";
if (!($questions = get_records_sql($sql))) {
print_error('No questions found');
}
$number = 1;
foreach ($questionids as $key => $id) {
if ($questions[$id]->length) {
// Only print questions of non-zero length.
$tablecolumns[] = '$' . $id;
$tableheaders[] = '#' . $number;
$questions[$id]->number = $number;
$number += $questions[$id]->length;
} else {
// Get rid of zero length questions.
unset($questions[$id]);
unset($questionids[$key]);
}
}
}
if ($hasfeedback) {
$tablecolumns[] = 'feedbacktext';
$tableheaders[] = get_string('feedback', 'game');
}
if (!$download) {
// Set up the table.
$table = new flexible_table('mod-game-report-overview-report');
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$table->define_baseurl($CFG->wwwroot . '/mod/game/report.php?mode=overview&id=' . $cm->id . '&noattempts=' . $noattempts . '&detailedmarks=' . $detailedmarks . '&pagesize=' . $pagesize);
$table->sortable(true);
$table->collapsible(true);
$table->column_suppress('picture');
$table->column_suppress('fullname');
$table->column_class('picture', 'picture');
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'generaltable generalbox');
// Start working -- this is necessary as soon as the niceties are over.
$table->setup();
} else {
if ($download == 'ODS') {
require_once "{$CFG->libdir}/odslib.class.php";
$filename .= ".ods";
// Creating a workbook.
$workbook = new MoodleODSWorkbook("-");
// Sending HTTP headers.
$workbook->send($filename);
// Creating the first worksheet.
$sheettitle = get_string('reportoverview', 'game');
$myxls =& $workbook->add_worksheet($sheettitle);
// Format types.
$format =& $workbook->add_format();
$format->set_bold(0);
$formatbc =& $workbook->add_format();
$formatbc->set_bold(1);
$formatbc->set_align('center');
$formatb =& $workbook->add_format();
$formatb->set_bold(1);
$formaty =& $workbook->add_format();
$formaty->set_bg_color('yellow');
$formatc =& $workbook->add_format();
$formatc->set_align('center');
$formatr =& $workbook->add_format();
示例15: array
if (isset($_POST['updatepref'])) {
$perpage = optional_param('perpage', STAMPCOLL_USERS_PER_PAGE, PARAM_INT);
$perpage = $perpage <= 0 ? STAMPCOLL_USERS_PER_PAGE : $perpage;
set_user_preference('stampcoll_perpage', $perpage);
}
/// Next we get perpage param from database
$perpage = get_user_preferences('stampcoll_perpage', STAMPCOLL_USERS_PER_PAGE);
$tablecolumns = array('picture', 'fullname', 'count', 'stamps');
$tableheaders = array('', get_string('fullname'), get_string('numberofstamps', 'stampcoll'), '');
require_once $CFG->libdir . '/tablelib.php';
$table = new flexible_table('mod-stampcoll-stamps');
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$table->define_baseurl($CFG->wwwroot . '/mod/stampcoll/view.php?id=' . $cm->id . '&currentgroup=' . $currentgroup);
$table->sortable(true);
$table->collapsible(false);
$table->initialbars(true);
$table->column_class('picture', 'picture');
$table->column_class('fullname', 'fullname');
$table->column_class('count', 'count');
$table->column_class('stamps', 'stamps');
$table->column_style('stamps', 'width', '50%');
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'stamps');
$table->set_attribute('class', 'stamps');
$table->set_attribute('width', '90%');
$table->set_attribute('align', 'center');
$table->setup();
if (empty($users)) {
print_heading(get_string('nousers', 'stampcoll'));
return true;