本文整理汇总了PHP中flexible_table::get_sql_where方法的典型用法代码示例。如果您正苦于以下问题:PHP flexible_table::get_sql_where方法的具体用法?PHP flexible_table::get_sql_where怎么用?PHP flexible_table::get_sql_where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flexible_table
的用法示例。
在下文中一共展示了flexible_table::get_sql_where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
//.........这里部分代码省略.........
$from = 'FROM {user} u JOIN {role_assignments} ra ON ra.userid = u.id ' . ' LEFT JOIN {game_attempts} qa ON u.id = qa.userid AND qa.gameid = ' . $game->id;
$where = " WHERE ra.contextid {$contextlists}";
if (empty($noattempts)) {
// Show ONLY students with attempts.
$where .= ' AND qa.userid IS NOT NULL AND qa.preview = 0';
} else {
if ($noattempts == 1) {
// The noattempts = 1 means only no attempts,.
// So make the left join ask for only records where the right is null (no attempts).
// Show ONLY students without attempts.
$where .= ' AND qa.userid IS NULL';
} else {
if ($noattempts == 3) {
// We want all attempts.
$from = 'FROM {user} u JOIN {game_attempts} qa ON u.id = qa.userid ';
$where = ' WHERE qa.gameid = ' . $game->id . ' AND qa.preview = 0';
}
}
}
// The noattempts = 2 means we want all students, with or without attempts.
}
}
}
$countsql = 'SELECT COUNT(DISTINCT(' . sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')) . ')) ' . $from . $where;
} else {
if (empty($noattempts)) {
$from = 'FROM {user} u JOIN {game_attempts} qa ON u.id = qa.userid ';
$where = ' WHERE qa.gameid = ' . $game->id . ' AND qa.preview = 0';
$countsql = 'SELECT COUNT(DISTINCT(' . sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')) . ')) ' . $from . $where;
}
}
if (!$download) {
// Add extra limits due to initials bar.
if ($table->get_sql_where()) {
$where .= ' AND ' . $table->get_sql_where();
}
// Count the records NOW, before funky question grade sorting messes up $from.
if (!empty($countsql)) {
$totalinitials = count_records_sql($countsql);
if ($table->get_sql_where()) {
$countsql .= ' AND ' . $table->get_sql_where();
}
$total = count_records_sql($countsql);
}
// Add extra limits due to sorting by question grade.
if ($sort = $table->get_sql_sort()) {
$sortparts = explode(',', $sort);
$newsort = array();
$questionsort = false;
foreach ($sortparts as $sortpart) {
$sortpart = trim($sortpart);
if (substr($sortpart, 0, 1) == '$') {
if (!$questionsort) {
$qid = intval(substr($sortpart, 1));
$select .= ', grade ';
$from .= ' LEFT JOIN {question_sessions} qns ON qns.attemptid = qa.id ' . 'LEFT JOIN {question_states} qs ON qs.id = qns.newgraded ';
$where .= ' AND (' . sql_isnull('qns.questionid') . ' OR qns.questionid = ' . $qid . ')';
$newsort[] = 'grade ' . (strpos($sortpart, 'ASC') ? 'ASC' : 'DESC');
$questionsort = true;
}
} else {
$newsort[] = $sortpart;
}
}
// Reconstruct the sort string.
$sort = ' ORDER BY ' . implode(', ', $newsort);
示例2: list
$table = new flexible_table('feedback-showentry-list-' . $course->id);
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$table->define_baseurl($baseurl);
$table->sortable(true, 'lastname', SORT_DESC);
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'showentrytable');
$table->set_attribute('class', 'generaltable generalbox');
$table->set_control_variables(array(TABLE_VAR_SORT => 'ssort', TABLE_VAR_IFIRST => 'sifirst', TABLE_VAR_ILAST => 'silast', TABLE_VAR_PAGE => 'spage'));
$table->setup();
if ($table->get_sql_sort()) {
$sort = $table->get_sql_sort();
} else {
$sort = '';
}
list($where, $params) = $table->get_sql_where();
if ($where) {
$where .= ' AND';
}
//get students in conjunction with groupmode
if ($groupmode > 0) {
if ($mygroupid > 0) {
$usedgroupid = $mygroupid;
} else {
$usedgroupid = false;
}
} else {
$usedgroupid = false;
}
$matchcount = feedback_count_complete_users($cm, $usedgroupid);
$table->initialbars(true);
示例3: 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'));
}
}
示例4: display
//.........这里部分代码省略.........
$formatr->set_align('center');
$formatg = $workbook->add_format();
$formatg->set_bold(1);
$formatg->set_color('green');
$formatg->set_align('center');
$colnum = 0;
foreach ($headers as $item) {
$myxls->write(0, $colnum, $item, $formatbc);
$colnum++;
}
$rownum = 1;
} else {
if ($download == 'CSV') {
$csvexport = new \csv_export_writer("tab");
$csvexport->set_filename($filename, ".txt");
$csvexport->add_data($headers);
}
}
}
}
if (!$download) {
$sort = $table->get_sql_sort();
} else {
$sort = '';
}
// Fix some wired sorting.
if (empty($sort)) {
$sort = ' ORDER BY uniqueid';
} else {
$sort = ' ORDER BY ' . $sort;
}
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) {
示例5: array
//.........这里部分代码省略.........
$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>';
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');
示例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: COUNT
$baseurl = $CFG->wwwroot . '/tag/manage.php?perpage=' . $perpage;
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$table->define_baseurl($baseurl);
$table->sortable(true, 'flag', SORT_DESC);
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'tag-management-list');
$table->set_attribute('class', 'generaltable generalbox');
$table->set_control_variables(array(TABLE_VAR_SORT => 'ssort', TABLE_VAR_HIDE => 'shide', TABLE_VAR_SHOW => 'sshow', TABLE_VAR_IFIRST => 'sifirst', TABLE_VAR_ILAST => 'silast', TABLE_VAR_PAGE => 'spage'));
$table->setup();
if ($table->get_sql_sort()) {
$sort = 'ORDER BY ' . $table->get_sql_sort();
} else {
$sort = '';
}
if ($table->get_sql_where()) {
$where = 'WHERE ' . $table->get_sql_where();
} else {
$where = '';
}
$query = 'SELECT tg.id, tg.name, tg.rawname, tg.tagtype, COUNT(ti.id) AS count, u.id AS owner, tg.flag, tg.timemodified, u.firstname, u.lastname ' . 'FROM ' . $CFG->prefix . 'tag_instance ti RIGHT JOIN ' . $CFG->prefix . 'tag tg ON tg.id = ti.tagid LEFT JOIN ' . $CFG->prefix . 'user u ON tg.userid = u.id ' . $where . ' ' . 'GROUP BY tg.id, tg.name, tg.rawname, tg.tagtype, u.id, tg.flag, tg.timemodified, u.firstname, u.lastname ' . $sort;
$totalcount = count_records_sql('SELECT COUNT(DISTINCT(tg.id)) FROM ' . $CFG->prefix . 'tag tg LEFT JOIN ' . $CFG->prefix . 'user u ON u.id = tg.userid ' . $where);
$table->initialbars(true);
// always initial bars
$table->pagesize($perpage, $totalcount);
echo '<form class="tag-management-form" method="post" action="' . $CFG->wwwroot . '/tag/manage.php"><div>';
//retrieve tags from DB
if ($tagrecords = get_records_sql($query, $table->get_page_start(), $table->get_page_size())) {
$taglist = array_values($tagrecords);
//print_tag_cloud(array_values(get_records_sql($query)), false);
//populate table with data
示例8: navmenu
//.........这里部分代码省略.........
$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'));
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, u.imagealt,
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) . ') ';
$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 = $DB->get_records_sql($select . $sql . $sort, null, $table->get_page_start(), $table->get_page_size())) !== false) {
$grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array_keys($ausers));
foreach ($ausers as $auser) {
$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(moodle_user_picture::make($auser, $course->id));
if (empty($auser->submissionid)) {
$auser->grade = -1;
示例9: switch
$table->set_control_variables(array(TABLE_VAR_SORT => 'ssort', TABLE_VAR_HIDE => 'shide', TABLE_VAR_SHOW => 'sshow', TABLE_VAR_IFIRST => 'sifirst', TABLE_VAR_ILAST => 'silast', TABLE_VAR_PAGE => 'spage'));
$table->setup();
switch ($action) {
case 'view':
$actionsql = 'action IN (\'' . implode('\',\'', $viewnames) . '\' )';
break;
case 'post':
$actionsql = 'action IN (\'' . implode('\',\'', $postnames) . '\' )';
break;
default:
// some modules have stuff we want to hide, ie mail blocked etc so do actually need to limit here.
$actionsql = 'action IN (\'' . implode('\',\'', array_merge($viewnames, $postnames)) . '\' )';
}
$relatedcontexts = get_related_contexts_string($context);
$sql = "SELECT ra.userid, u.firstname, u.lastname, u.idnumber, l.actioncount AS count\n FROM (SELECT * FROM {$CFG->prefix}role_assignments WHERE contextid {$relatedcontexts} AND roleid = {$roleid} ) ra\n JOIN {$CFG->prefix}user u ON u.id = ra.userid\n LEFT JOIN (\n SELECT userid, COUNT(action) AS actioncount FROM {$CFG->prefix}log WHERE cmid = {$instanceid} AND time > {$timefrom} AND {$actionsql} GROUP BY userid\n ) l ON (l.userid = ra.userid)";
if ($table->get_sql_where()) {
$sql .= ' WHERE ' . $table->get_sql_where();
//initial bar
}
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";
示例10: navmenu
//.........这里部分代码省略.........
$table->column_class('picture', 'picture');
$table->column_class('fullname', 'fullname');
$table->column_class('submitted', 'submitted');
$table->column_class('reviews', 'reviews');
$table->column_class('moderations', 'moderations');
$table->column_class('status', 'status');
$table->column_class('seedoreviews', 'seedoreviews');
$table->column_class('suggestedmark', 'suggestedmark');
$table->column_class('finalgrade', 'finalgrade');
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'submissions');
$table->set_attribute('width', '99%');
$table->set_attribute('align', 'center');
$table->column_style('submitted', 'text-align', $alignment);
$table->column_style('finalgrade', 'text-align', 'center');
/*
$table->no_sorting('picture');
$table->no_sorting('fullname');
$table->no_sorting('submitted');
$table->no_sorting('reviews');
$table->no_sorting('moderations');
$table->no_sorting('status');
$table->no_sorting('seedoreviews');
$table->no_sorting('suggestedmark');
$table->no_sorting('finalgrade');
*/
$table->setup();
if (empty($users)) {
print_heading(get_string('nosubmitusers', 'assignment'));
return true;
}
// Construct the SQL
if ($where = $table->get_sql_where()) {
$where .= ' AND ';
}
$select = 'SELECT u.id, u.firstname, u.lastname, u.picture, u.imagealt,
s.id AS submissionid, s.grade,
s.timecreated as submitted, s.timemarked ';
$sql = 'FROM ' . $CFG->prefix . 'user u ' . 'LEFT JOIN ' . $CFG->prefix . 'assignment_submissions s ON u.id=s.userid AND s.assignment=' . $this->assignment->id . ' ' . 'WHERE ' . $where . 'u.id IN (' . implode(',', $users) . ') ';
$sort = 'ORDER BY COALESCE(submitted,2147483647) ASC, submissionid ASC, u.lastname ASC';
// if ($sort = $table->get_sql_sort()) {
// $sort = ' ORDER BY '.$sort;
// }
$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);
// Get the criteria
$criteriaList = get_records_list('assignment_criteria', 'assignment', $this->assignment->id, 'ordernumber');
$numberOfCriteria = 0;
if (is_array($criteriaList)) {
$criteriaList = array_values($criteriaList);
$numberOfCriteria = count($criteriaList);
}
if (($ausers = get_records_sql($select . $sql . $sort, $table->get_page_start(), $table->get_page_size())) !== false) {
// $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array_keys($ausers));
foreach ($ausers as $auser) {
// $final_grade = $grading_info->items[0]->grades[$auser->id];
// Calculate user status
$auser->status = $auser->timemarked > 0;
$picture = print_user_picture($auser, $course->id, $auser->picture, false, true);
$studentName = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $auser->id . '&course=' . $this->course->id . '">' . fullname($auser) . '</a>';
// If submission has been made
示例11: list
break;
case 'post':
$actions = $postnames;
break;
default:
// some modules have stuff we want to hide, ie mail blocked etc so do actually need to limit here.
$actions = array_merge($viewnames, $postnames);
}
list($actionsql, $params) = $DB->get_in_or_equal($actions, SQL_PARAMS_NAMED, 'action0');
$actionsql = "l.action {$actionsql}";
$relatedcontexts = get_related_contexts_string($context);
$sql = "SELECT ra.userid, u.firstname, u.lastname, u.idnumber, COUNT(l.action) AS count\n FROM {role_assignments} ra\n JOIN {user} u ON u.id = ra.userid\n LEFT JOIN {log} l ON (l.userid = ra.userid AND l.cmid = :instanceid AND l.time > :timefrom AND {$actionsql})\n WHERE ra.contextid {$relatedcontexts} AND ra.roleid = :roleid";
$params['roleid'] = $roleid;
$params['instanceid'] = $instanceid;
$params['timefrom'] = $timefrom;
if ($table->get_sql_where()) {
$sql .= ' AND ' . $table->get_sql_where();
//initial bar
}
$sql .= " GROUP BY ra.userid, u.firstname, u.lastname, u.idnumber";
if ($table->get_sql_sort()) {
$sql .= ' ORDER BY ' . $table->get_sql_sort();
}
$countsql = "SELECT COUNT(DISTINCT(ra.userid))\n FROM {role_assignments} ra\n JOIN {user} u ON u.id = ra.userid\n LEFT OUTER JOIN {log} l ON (l.userid = ra.userid AND l.cmid = :instanceid AND l.time > :timefrom AND {$actionsql})\n WHERE ra.contextid {$relatedcontexts} AND ra.roleid = :roleid";
$totalcount = $DB->count_records_sql($countsql, $params);
if ($table->get_sql_where()) {
$matchcount = $DB->count_records_sql($countsql . ' AND ' . $table->get_sql_where(), $params);
} else {
$matchcount = $totalcount;
}
echo '<div id="participationreport">' . "\n";
示例12: display_allfilesform
//.........这里部分代码省略.........
$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());
$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) {
示例13: geogebra_view_userid_results
function geogebra_view_userid_results($geogebra, $userid, $cm, $context, $action, $attempt = null)
{
global $CFG, $DB, $OUTPUT, $PAGE, $USER;
require_once $CFG->libdir . '/tablelib.php';
$table = new flexible_table('mod-geogebra-results');
$user = $DB->get_record('user', array('id' => $userid));
$tablecolumns = geogebra_get_results_table_columns($action == 'view' ? null : $cm);
$table->define_columns($tablecolumns['tablecolumns']);
$table->define_headers($tablecolumns['tableheaders']);
$table->define_baseurl($CFG->wwwroot . '/mod/geogebra/view.php?id=' . $cm->id);
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'results generaltable generalbox');
$table->set_attribute('width', '100%');
// 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 ';
}
// $sort = ' ORDER BY attemptid';
// Show results only for specified user
if (!empty($attempt)) {
// Show only results of specified attempt
$table = new html_table();
$table->size = array('10%', '90%');
parse_str($attempt->vars, $parsedvars);
$numattempt = $parsedvars['attempts'];
if (!$attempt->finished) {
$numattempt .= ' (' . get_string('unfinished', 'geogebra') . ')';
}
$duration = geogebra_time2str($parsedvars['duration']);
$grade = $parsedvars['grade'];
if ($grade < 0) {
$grade = '';
}
if (is_siteadmin() || has_capability('moodle/grade:viewall', $context, $USER->id, false)) {
// Show form to grade and comment this attempt
require_once 'gradeform.php';
$data = new stdClass();
$data->id = $cm->id;
$data->student = $user->id;
$data->attemptid = $attempt->id;
$data->attempt = $numattempt;
$data->duration = $duration;
$data->grade = $grade;
$data->comment_editor['text'] = $attempt->gradecomment;
$data->comment_editor['format'] = FORMAT_HTML;
// Create form
$mform = new mod_geogebra_grade_form(null, array($geogebra, $data, null), 'post', '', array('class' => 'gradeform'));
} else {
if ($geogebra->grade < 0) {
// Get scale name
$grademenu = make_grades_menu($geogebra->grade);
if (!empty($grade)) {
$grade = $grademenu[$grade];
}
}
// Show attempt
geogebra_add_table_row_tuple($table, get_string('attempt', 'geogebra'), $numattempt);
geogebra_add_table_row_tuple($table, get_string('duration', 'geogebra'), $duration);
geogebra_add_table_row_tuple($table, get_string('grade'), $grade);
geogebra_add_table_row_tuple($table, get_string('comment', 'geogebra'), $attempt->gradecomment);
}
// Print attempt information with grade and comment form if user can grade
if (!empty($mform)) {
// Print user information
$picture = $OUTPUT->user_picture($user);
$userlink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $geogebra->course . '">' . fullname($user, has_capability('moodle/site:viewfullnames', $context)) . '</a>';
echo $picture . ' ' . $userlink . ' (' . $user->email . ')';
// Print form
$mform->display();
} else {
echo html_writer::table($table);
}
} else {
// Show all attempts information
$attempts = geogebra_get_user_attempts($geogebra->id, $user->id);
foreach ($attempts as $attempt) {
$row = geogebra_get_attempt_row($geogebra, $attempt, $user, $cm, $context);
$rowclass = '';
$table->add_data($row, $rowclass);
}
$table->print_html();
// Print the whole table
}
}
示例14: display
//.........这里部分代码省略.........
$formatg->set_color('green');
$formatg->set_align('center');
$colnum = 0;
foreach ($headers as $item) {
$myxls->write(0, $colnum, $item, $formatbc);
$colnum++;
}
$rownum = 1;
} else if ($download == 'CSV') {
$filename .= ".txt";
header("Content-Type: application/download\n");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Expires: 0");
header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
header("Pragma: public");
echo implode("\t", $headers)." \n";
}
if (!$download) {
$sort = $table->get_sql_sort();
} else {
$sort = '';
}
// Fix some wired sorting
if (empty($sort)) {
$sort = ' ORDER BY uniqueid';
} else {
$sort = ' ORDER BY '.$sort;
}
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 '<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());
示例15: implode
/**
* Prints a table with users and their attempts
*
* @return void
* @todo Add current grade to the table
* Finnish documenting
**/
function view_question($quiz, $question)
{
global $CFG, $db;
$users = get_course_students($quiz->course);
$userids = implode(',', array_keys($users));
$usercount = count($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($CFG->wwwroot . '/mod/quiz/report.php?mode=grading&q=' . $quiz->id . '&action=viewquestion&questionid=' . $question->id);
$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();
// this sql is a join of the attempts table and the user table. I do this so I can sort by user name and attempt number (not id)
$select = 'SELECT ' . sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')) . ' AS userattemptid, qa.id AS attemptid, qa.uniqueid, qa.attempt, qa.timefinish, u.id AS userid, u.firstname, u.lastname, u.picture ';
$from = 'FROM ' . $CFG->prefix . 'user u LEFT JOIN ' . $CFG->prefix . 'quiz_attempts qa ON (u.id = qa.userid AND qa.quiz = ' . $quiz->id . ') ';
$where = 'WHERE u.id IN (' . $userids . ') ';
$where .= 'AND ' . $db->IfNull('qa.attempt', '0') . ' != 0 ';
$where .= 'AND ' . $db->IfNull('qa.timefinish', '0') . ' != 0 ';
$where .= 'AND preview = 0 ';
// ignore previews
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
$total = count_records_sql('SELECT COUNT(DISTINCT(' . sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')) . ')) ' . $from . $where);
$table->pagesize(10, $total);
// get the attempts and process them
if ($attempts = get_records_sql($select . $from . $where . $sort, $table->get_page_start(), $table->get_page_size())) {
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>';
if (!$this->is_graded($question, $attempt)) {
$style = 'class="manual-ungraded"';
} else {
$style = 'class="manual-graded"';
}
// link for the attempt
$attemptlink = "<a {$style} href=\"report.php?mode=grading&action=grade&q={$quiz->id}&questionid={$question->id}&attemptid={$attempt->attemptid}\">" . userdate($attempt->timefinish, get_string('strftimedatetime')) . '</a>';
// grade all attempts for this user
$gradelink = "<a href=\"report.php?mode=grading&action=grade&q={$quiz->id}&questionid={$question->id}&userid={$attempt->userid}\">" . get_string('grade') . '</a>';
$table->add_data(array($picture, $userlink, $attemptlink, $gradelink));
}
}
// grade all and "back" links
$links = "<div class=\"boxaligncenter\"><a href=\"report.php?mode=grading&action=grade&q={$quiz->id}&questionid={$question->id}&gradeall=1\">" . get_string('gradeall', 'quiz') . '</a> | ' . "<a href=\"report.php?mode=grading&q={$quiz->id}&action=viewquestions\">" . get_string('backtoquestionlist', 'quiz') . '</a></div>' . print_heading($question->name);
echo $links;
echo '<div id="tablecontainer">';
$table->print_html();
echo '</div>';
echo $links;
}