本文整理汇总了PHP中get_records_sql_menu函数的典型用法代码示例。如果您正苦于以下问题:PHP get_records_sql_menu函数的具体用法?PHP get_records_sql_menu怎么用?PHP get_records_sql_menu使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_records_sql_menu函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: question_cwqpfs_to_update
function question_cwqpfs_to_update($categories = null)
{
global $CFG;
$tofix = array();
$result = true;
//any cats with questions picking from subcats?
if (!($cwqpfs = get_records_sql_menu("SELECT DISTINCT qc.id, 1 " . "FROM {$CFG->prefix}question q, {$CFG->prefix}question_categories qc " . "WHERE q.qtype='random' AND qc.id = q.category AND " . sql_compare_text('q.questiontext') . " = '1'"))) {
return array();
} else {
if ($categories === null) {
$categories = get_records('question_categories');
}
$categorychildparents = array();
foreach ($categories as $id => $category) {
$categorychildparents[$category->course][$id] = $category->parent;
}
foreach ($categories as $id => $category) {
if (FALSE !== array_key_exists($category->parent, $categorychildparents[$category->course])) {
//this is not a top level cat
continue;
//go to next category
} else {
$tofix += question_cwqpfs_check_children($id, $categories, $categorychildparents[$category->course], $cwqpfs);
}
}
}
return $tofix;
}
示例2: otags_select_setup
/**
* This function sets up options of otag select element. This is called from definition and also
* after adding new official tags with the add tag button.
*
*/
function otags_select_setup()
{
global $CFG;
$mform =& $this->_form;
$otagsselect =& $mform->getElement('otags');
$otagsselect->removeOptions();
if ($otags = get_records_sql_menu('SELECT id, text from ' . $CFG->prefix . 'tags WHERE type=\'official\' ORDER by text ASC')) {
$otagsselect->loadArray($otags);
}
}
示例3: handle_individual
function handle_individual($usersid)
{
global $CFG;
$sql = "SELECT id, path FROM {$CFG->prefix}block_student_person\n WHERE (path != 'NA' OR path != 0)\n AND usersid = {$usersid}";
$assignments = get_records_sql_menu($sql);
if ($assignments) {
return handle_person($assignments);
}
return '';
}
示例4: otags_select_setup
/**
* This function sets up options of otag select element. This is called from definition and also
* after adding new official tags with the add tag button.
*
*/
function otags_select_setup()
{
global $CFG;
$mform =& $this->_form;
if ($otagsselect =& $mform->getElement('otags')) {
$otagsselect->removeOptions();
}
$namefield = empty($CFG->keeptagnamecase) ? 'name' : 'rawname';
if ($otags = get_records_sql_menu('SELECT id, ' . $namefield . ' from ' . $CFG->prefix . 'tag WHERE tagtype=\'official\' ORDER by name ASC')) {
$otagsselect->loadArray($otags);
}
}
示例5: display_search_field
function display_search_field($value = '')
{
global $CFG;
$temp = get_records_sql_menu('SELECT id, content from ' . $CFG->prefix . 'data_content WHERE fieldid=' . $this->field->id . ' GROUP BY content ORDER BY content');
$options = array();
if (!empty($temp)) {
$options[''] = '';
//Make first index blank.
foreach ($temp as $key) {
$options[$key] = $key;
//Build following indicies from the sql.
}
}
return choose_from_menu($options, 'f_' . $this->field->id, $value, 'choose', '', 0, true);
}
示例6: display_search_field
function display_search_field($value = '')
{
global $CFG;
$lats = get_records_sql_menu('SELECT id, content from ' . $CFG->prefix . 'data_content WHERE fieldid=' . $this->field->id . ' GROUP BY content ORDER BY content');
$longs = get_records_sql_menu('SELECT id, content1 from ' . $CFG->prefix . 'data_content WHERE fieldid=' . $this->field->id . ' GROUP BY content ORDER BY content');
$options = array();
if (!empty($lats) && !empty($longs)) {
$options[''] = '';
// Make first index blank.
foreach ($lats as $key => $temp) {
$options[$temp . ',' . $longs[$key]] = $temp . ',' . $longs[$key];
}
}
return choose_from_menu($options, 'f_' . $this->field->id, $value, 'choose', '', 0, true);
}
示例7: init
function init()
{
global $CFG;
// All the years to choose from
// All the colleges to choose from
// All the majors to choose from
$fields = array('years' => 'year', 'colleges' => 'college', 'majors' => 'classification');
$fields = array_map('special_sql', $fields);
$this->fields = $fields;
// All the current assignments in this category
$sql = "SELECT id, path\n FROM {$CFG->prefix}block_student_academics\n WHERE path != 'NA'\n Group By path";
$inter = get_records_sql_menu($sql);
$assignments = array_values(array(0 => 'NA') + (!$inter ? array() : $inter));
$assignments = array_combine($assignments, $assignments);
$assignments['NA'] = 'NA/NA/NA';
$this->current_assignments = $assignments;
}
示例8: init
function init()
{
global $CFG;
// Get user capabilities
$cap_sql = "SELECT rc.id, rc.capability\n FROM {$CFG->prefix}role_assignments ra,\n {$CFG->prefix}role_capabilities rc\n WHERE ra.userid = {$this->userid}\n AND ra.roleid = rc.roleid\n AND rc.capability IN ('" . implode("','", $this->user_caps) . "')";
$capabilities = get_records_sql_menu($cap_sql);
// Get all the internal assignments
$map = create_function('$field', '
return "SELECT DISTINCT(u.id), u.firstname, u.lastname
FROM ' . $CFG->prefix . 'user u,
' . $CFG->prefix . 'block_student_{$field} a,
' . $CFG->prefix . 'role_assignments ra,
' . $CFG->prefix . 'role_capabilities rc
WHERE u.id = a.usersid
AND ra.userid = u.id
AND ra.roleid = rc.roleid
AND rc.capability IN (\'' . implode("','", array_values($capabilities)) . '\')
GROUP BY u.id";');
$sql = implode(') UNION (', array_map($map, array('sports', 'academics', 'person')));
$this->mentors = array_map('flatten_mentors', get_records_sql('(' . $sql . ') ORDER BY lastname'));
}
示例9: question_insert_c_and_q_ids_for_module
function question_insert_c_and_q_ids_for_module($backup_unique_code, $course, $modulename, $instances)
{
global $CFG;
$status = true;
// using 'dummykeyname' in sql because otherwise get_records_sql_menu returns an error
// if two key names are the same.
$cmcontexts = array();
if (!empty($instances)) {
$cmcontexts = get_records_sql_menu("SELECT c.id, c.id AS dummykeyname FROM {$CFG->prefix}modules m,\n {$CFG->prefix}course_modules cm,\n {$CFG->prefix}context c\n WHERE m.name = '{$modulename}' AND m.id = cm.module AND cm.id = c.instanceid\n AND c.contextlevel = " . CONTEXT_MODULE . " AND cm.course = {$course}\n AND cm.instance IN (" . implode(',', array_keys($instances)) . ")");
}
if ($cmcontexts) {
$status = $status && execute_sql("INSERT INTO {$CFG->prefix}backup_ids\n (backup_code, table_name, old_id, info)\n SELECT '{$backup_unique_code}', 'question_categories', qc.id, '{$modulename}'\n FROM {$CFG->prefix}question_categories qc\n WHERE qc.contextid IN (" . join(array_keys($cmcontexts), ', ') . ")", false);
}
$status = $status && question_insert_q_ids($backup_unique_code, $modulename);
return $status;
}
示例10: set_data_attempt
function set_data_attempt(&$attempt, &$strftimedate, &$strftimetime, &$blank)
{
global $CFG;
$records = get_records_sql_menu("\n\t\t\tSELECT userid, MAX(time) AS logintime\n\t\t\tFROM {$CFG->prefix}log\n\t\t\tWHERE userid={$attempt->userid} AND action='login' AND time<{$attempt->timestart}\n\t\t\tGROUP BY userid\n\t\t");
if (empty($records)) {
$logindate = $blank;
$logintime = $blank;
} else {
$logintime = $records[$attempt->userid];
$logindate = trim(userdate($logintime, $strftimedate));
$logintime = trim(userdate($logintime, $strftimetime));
}
$records = get_records_sql_menu("\n\t\t\tSELECT userid, MIN(time) AS logouttime\n\t\t\tFROM {$CFG->prefix}log\n\t\t\tWHERE userid={$attempt->userid} AND action='logout' AND time>{$attempt->cr_timefinish}\n\t\t\tGROUP BY userid\n\t\t");
if (empty($records)) {
$logouttime = $blank;
} else {
$logouttime = $records[$attempt->userid];
$logouttime = trim(userdate($logouttime, $strftimetime));
}
$this->data['attempt'] = array('logindate' => $logindate, 'logintime' => $logintime, 'logouttime' => $logouttime, 'number' => $attempt->attempt, 'start' => trim(userdate($attempt->timestart, $strftimetime)), 'finish' => trim(userdate($attempt->cr_timefinish, $strftimetime)));
}
示例11: display
function display($quiz, $cm, $course)
{
/// This function just displays the report
global $CFG, $SESSION, $db, $QTYPES;
$strnoquiz = get_string('noquiz', 'quiz');
$strnoattempts = get_string('noattempts', 'quiz');
/// Only print headers if not asked to download data
$download = optional_param('download', NULL);
if (!$download) {
$this->print_header_and_tabs($cm, $course, $quiz, $reportmode = "analysis");
}
/// Construct the table for this particular report
if (!$quiz->questions) {
print_heading($strnoattempts);
return true;
}
/// Check to see if groups are being used in this quiz
if ($groupmode = groupmode($course, $cm)) {
// Groups are being used
if (!$download) {
$currentgroup = setup_and_print_groups($course, $groupmode, "report.php?id={$cm->id}&mode=analysis");
} else {
$currentgroup = get_and_set_current_group($course, $groupmode);
}
} else {
$currentgroup = get_and_set_current_group($course, $groupmode);
}
// set Table and Analysis stats options
if (!isset($SESSION->quiz_analysis_table)) {
$SESSION->quiz_analysis_table = array('attemptselection' => 0, 'lowmarklimit' => 0, 'pagesize' => 10);
}
foreach ($SESSION->quiz_analysis_table as $option => $value) {
$urlparam = optional_param($option, NULL);
if ($urlparam === NULL) {
${$option} = $value;
} else {
${$option} = $SESSION->quiz_analysis_table[$option] = $urlparam;
}
}
$scorelimit = $quiz->sumgrades * $lowmarklimit / 100;
// ULPGC ecastro DEBUG this is here to allow for different SQL to select attempts
switch ($attemptselection) {
case QUIZ_ALLATTEMPTS:
$limit = '';
$group = '';
break;
case QUIZ_HIGHESTATTEMPT:
$limit = ', max(qa.sumgrades) ';
$group = ' GROUP BY qa.userid ';
break;
case QUIZ_FIRSTATTEMPT:
$limit = ', min(qa.timemodified) ';
$group = ' GROUP BY qa.userid ';
break;
case QUIZ_LASTATTEMPT:
$limit = ', max(qa.timemodified) ';
$group = ' GROUP BY qa.userid ';
break;
}
if ($attemptselection != QUIZ_ALLATTEMPTS) {
$sql = 'SELECT qa.userid ' . $limit . 'FROM ' . $CFG->prefix . 'user u LEFT JOIN ' . $CFG->prefix . 'quiz_attempts qa ON u.id = qa.userid ' . 'WHERE qa.quiz = ' . $quiz->id . ' AND qa.preview = 0 ' . $group;
$usermax = get_records_sql_menu($sql);
}
$groupmembers = '';
$groupwhere = '';
//Add this to the SQL to show only group users
if ($currentgroup) {
$groupmembers = ', ' . groups_members_from_sql();
$groupwhere = ' AND ' . groups_members_where_sql($currentgroup, 'u.id');
}
$sql = 'SELECT qa.* FROM ' . $CFG->prefix . 'quiz_attempts qa, ' . $CFG->prefix . 'user u ' . $groupmembers . 'WHERE u.id = qa.userid AND qa.quiz = ' . $quiz->id . ' AND qa.preview = 0 AND ( qa.sumgrades >= ' . $scorelimit . ' ) ' . $groupwhere;
// ^^^^^^ es posible seleccionar aqu TODOS los quizzes, como quiere Jussi,
// pero habra que llevar la cuenta ed cada quiz para restaura las preguntas (quizquestions, states)
/// Fetch the attempts
$attempts = get_records_sql($sql);
if (empty($attempts)) {
print_heading(get_string('nothingtodisplay'));
$this->print_options_form($quiz, $cm, $attemptselection, $lowmarklimit, $pagesize);
return true;
}
/// Here we rewiew all attempts and record data to construct the table
$questions = array();
$statstable = array();
$questionarray = array();
foreach ($attempts as $attempt) {
$questionarray[] = quiz_questions_in_quiz($attempt->layout);
}
$questionlist = quiz_questions_in_quiz(implode(",", $questionarray));
$questionarray = array_unique(explode(",", $questionlist));
$questionlist = implode(",", $questionarray);
unset($questionarray);
foreach ($attempts as $attempt) {
switch ($attemptselection) {
case QUIZ_ALLATTEMPTS:
$userscore = 0;
// can be anything, not used
break;
case QUIZ_HIGHESTATTEMPT:
$userscore = $attempt->sumgrades;
break;
//.........这里部分代码省略.........
示例12: feedback_send_email
/**
* sends an email to the teachers of the course where the given feedback is placed.
* @param object $cm the coursemodule-record
* @param $feedback
* @param $course
* @param $userid
* @return void
*/
function feedback_send_email($cm, $feedback, $course, $userid)
{
global $CFG;
if ($feedback->email_notification == 0) {
// No need to do anything
return;
}
$user = get_record('user', 'id', $userid);
if (groupmode($course, $cm) == SEPARATEGROUPS) {
// Separate groups are being used
$groups = get_records_sql_menu("SELECT g.name, g.id\n FROM {$CFG->prefix}groups g,\n {$CFG->prefix}groups_members m\n WHERE g.courseid = '{$course->id}'\n AND g.id = m.groupid\n AND m.userid = '{$userid}'\n ORDER BY name ASC");
$groups = array_values($groups);
$teachers = feedback_get_receivemail_users($cm->id, $groups);
} else {
$teachers = feedback_get_receivemail_users($cm->id);
}
if ($teachers) {
$strfeedbacks = get_string('modulenameplural', 'feedback');
$strfeedback = get_string('modulename', 'feedback');
$strcompleted = get_string('completed', 'feedback');
$printusername = $feedback->anonymous == FEEDBACK_ANONYMOUS_NO ? fullname($user) : get_string('anonymous_user', 'feedback');
foreach ($teachers as $teacher) {
unset($info);
$info->username = $printusername;
$info->feedback = format_string($feedback->name, true);
$info->url = $CFG->wwwroot . '/mod/feedback/show_entries.php?id=' . $cm->id . '&userid=' . $userid . '&do_show=showentries';
$postsubject = $strcompleted . ': ' . $info->username . ' -> ' . $feedback->name;
$posttext = feedback_send_email_text($info, $course);
$posthtml = $teacher->mailformat == 1 ? feedback_send_email_html($info, $course, $cm) : '';
if ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO) {
@email_to_user($teacher, $user, $postsubject, $posttext, $posthtml);
} else {
@email_to_user($teacher, $teacher, $postsubject, $posttext, $posthtml);
}
}
}
}
示例13: quiz_report_grade_bands
function quiz_report_grade_bands($bandwidth, $bands, $quizid, $useridlist = '')
{
global $CFG;
$sql = "SELECT\n FLOOR(qg.grade/{$bandwidth}) AS band,\n COUNT(1) AS num\n FROM\n {$CFG->prefix}quiz_grades qg, \n {$CFG->prefix}quiz q\n WHERE qg.quiz = q.id AND qg.quiz = {$quizid} \n " . ($useridlist ? "AND qg.userid IN ({$useridlist}) " : '') . "\n GROUP BY FLOOR(qg.grade/{$bandwidth})\n ORDER BY band";
if (!($data = get_records_sql_menu($sql))) {
$data = array();
}
//need to create array elements with values 0 at indexes where there is no element
$data = $data + array_fill(0, $bands + 1, 0);
ksort($data);
//place the maximum (prefect grade) into the last band i.e. make last
//band for example 9 <= g <=10 (where 10 is the perfect grade) rather than
//just 9 <= g <10.
$data[$bands - 1] += $data[$bands];
unset($data[$bands]);
return $data;
}
示例14: get_string
}
$post->id = $existing->id;
$post->subject = $existing->subject;
$post->summary = $existing->summary;
$post->publishstate = $existing->publishstate;
$post->format = $existing->format;
$post->action = $action;
$strformheading = get_string('updateentrywithid', 'blog');
if ($ptags = get_records_sql_menu("SELECT t.id, t.text FROM\n {$CFG->prefix}tags t,\n {$CFG->prefix}blog_tag_instance bti\n WHERE t.id = bti.tagid\n AND t.type = 'personal'\n AND bti.entryid = {$post->id}")) {
$post->ptags = implode(', ', $ptags);
} else {
//$idsql = " AND bti.entryid = 0";
//was used but seems redundant.
$post->ptags = '';
}
if ($otags = get_records_sql_menu("SELECT t.id, t.text FROM\n {$CFG->prefix}tags t,\n {$CFG->prefix}blog_tag_instance bti\n WHERE t.id = bti.tagid\n AND t.type = 'official'\n AND bti.entryid = {$post->id}")) {
$post->otags = array_keys($otags);
}
break;
default:
error('Unknown action!');
}
// done here in order to allow deleting of posts with wrong user id above
if (!($user = get_record('user', 'id', $userid))) {
error('Incorrect user id');
}
print_header("{$SITE->shortname}: {$strblogs}", $SITE->fullname, '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $userid . '">' . fullname($user) . '</a> ->
<a href="' . $CFG->wwwroot . '/blog/index.php?userid=' . $userid . '">' . $strblogs . '</a> -> ' . $strformheading, '', '', true);
$blogeditform->set_data($post);
$blogeditform->display();
print_footer();
示例15: lesson_grades
function lesson_grades($lessonid)
{
/// Must return an array of grades for a given instance of this module,
/// indexed by user. It also returns a maximum allowed grade.
global $CFG;
if (!($lesson = get_record("lesson", "id", $lessonid))) {
return NULL;
}
if ($lesson->retake) {
if ($lesson->usemaxgrade) {
$grades = get_records_sql_menu("SELECT userid,MAX(grade) FROM {$CFG->prefix}lesson_grades WHERE\n lessonid = {$lessonid} GROUP BY userid");
} else {
$grades = get_records_sql_menu("SELECT userid,AVG(grade) FROM {$CFG->prefix}lesson_grades WHERE\n lessonid = {$lessonid} GROUP BY userid");
}
} else {
// Retakes is turned Off; only count first attempt
$firstgrades = get_records_sql("SELECT userid, MIN(completed), grade FROM {$CFG->prefix}lesson_grades WHERE lessonid = {$lessonid} GROUP BY userid");
$grades = array();
if (!empty($firstgrades)) {
foreach ($firstgrades as $userid => $info) {
$grades[$userid] = $info->grade;
}
}
}
// convert grades from percentages and tidy the numbers
if (!$lesson->practice) {
// dont display practice lessons
if ($grades) {
foreach ($grades as $userid => $grade) {
$return->grades[$userid] = number_format($grade * $lesson->grade / 100.0, 1);
}
}
$return->maxgrade = $lesson->grade;
return $return;
} else {
return NULL;
}
}