mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-14679 removed all instances of get_records_sql_menu()
This commit is contained in:
parent
534792cd82
commit
c6307ef24d
@ -44,10 +44,11 @@ function authorize_print_orders($courseid, $userid)
|
||||
|
||||
$baseurl = $CFG->wwwroot.'/enrol/authorize/index.php?user='.$userid;
|
||||
|
||||
$sql = "SELECT c.id, c.fullname FROM {$CFG->prefix}course c INNER JOIN {$CFG->prefix}enrol_authorize e ON c.id = e.courseid ";
|
||||
$sql .= ($userid > 0) ? "WHERE (e.userid='$userid') " : '';
|
||||
$params = array('userid'=>$userid);
|
||||
$sql = "SELECT c.id, c.fullname FROM {course} c JOIN {enrol_authorize} e ON c.id = e.courseid ";
|
||||
$sql .= ($userid > 0) ? "WHERE (e.userid=:userid) " : '';
|
||||
$sql .= "ORDER BY c.sortorder, c.fullname";
|
||||
if (($popupcrs = get_records_sql_menu($sql))) {
|
||||
if (($popupcrs = $DB->get_records_sql_menu($sql, $params))) {
|
||||
$popupcrs = array($SITE->id => $SITE->fullname) + $popupcrs;
|
||||
}
|
||||
$popupmenu = empty($popupcrs) ? '' : popup_form($baseurl.'&status='.$status.'&course=',$popupcrs,'coursesmenu',$courseid,'','','',true);
|
||||
|
@ -435,3 +435,7 @@ function get_records_menu($table, $field='', $value='', $sort='', $fields='*', $
|
||||
function get_records_select_menu($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
|
||||
error('get_records_select_menu() removed');
|
||||
}
|
||||
|
||||
function get_records_sql_menu($sql, $limitfrom='', $limitnum='') {
|
||||
error('get_records_sql_menu() removed');
|
||||
}
|
||||
|
@ -664,22 +664,6 @@ function records_to_menu($records, $field1, $field2) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first two columns from a number of records as an associative array.
|
||||
*
|
||||
* Arguments as for @see function get_recordset_sql.
|
||||
* Return value as for @see function get_records_menu.
|
||||
*
|
||||
* @param string $sql The SQL string you wish to be executed.
|
||||
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
|
||||
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
|
||||
* @return mixed an associative array, or false if no records were found or an error occured.
|
||||
*/
|
||||
function get_records_sql_menu($sql, $limitfrom='', $limitnum='') {
|
||||
$rs = get_recordset_sql($sql, $limitfrom, $limitnum);
|
||||
return recordset_to_menu($rs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single value from a table row where a particular select clause is true.
|
||||
*
|
||||
|
@ -66,8 +66,8 @@ class data_field_checkbox extends data_field_base {
|
||||
}
|
||||
|
||||
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');
|
||||
global $CFG, $DB;
|
||||
$temp = $DB->get_records_sql_menu('SELECT id, content FROM {data_content} WHERE fieldid=? GROUP BY content ORDER BY content', array($this->field->id));
|
||||
$options = array();
|
||||
if(!empty($temp)) {
|
||||
$options[''] = ''; //Make first index blank.
|
||||
|
@ -69,9 +69,9 @@ class data_field_latlong extends data_field_base {
|
||||
}
|
||||
|
||||
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');
|
||||
global $CFG, $DB;
|
||||
$lats = $DB->get_records_sql_menu('SELECT id, content FROM {data_content} WHERE fieldid=? GROUP BY content ORDER BY content', array($this->field->id));
|
||||
$longs = $DB->get_records_sql_menu('SELECT id, content1 FROM {data_content} WHERE fieldid=? GROUP BY content ORDER BY content', array($this->field->id));
|
||||
$options = array();
|
||||
if(!empty($lats) && !empty($longs)) {
|
||||
$options[''] = '';
|
||||
|
@ -68,8 +68,8 @@ class data_field_radiobutton extends data_field_base {
|
||||
}
|
||||
|
||||
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');
|
||||
global $CFG, $DB;
|
||||
$temp = $DB->get_records_sql_menu('SELECT id, content FROM {data_content} WHERE fieldid=? GROUP BY content ORDER BY content', array($this->field->id));
|
||||
$options = array();
|
||||
if(!empty($temp)) {
|
||||
$options[''] = ''; //Make first index blank.
|
||||
|
@ -145,15 +145,16 @@
|
||||
</script>';
|
||||
|
||||
|
||||
$sql = 'select c.id, c.shortname from '.$CFG->prefix.'course c, '.
|
||||
$CFG->prefix.'feedback_value fv, '.$CFG->prefix.'feedback_item fi '.
|
||||
$sql = 'select c.id, c.shortname from {course} c, '.
|
||||
'{feedback_value} fv, {feedback_item} fi '.
|
||||
'where c.id = fv.course_id and fv.item = fi.id '.
|
||||
'and fi.feedback = '.$feedback->id.' '.
|
||||
'and fi.feedback = ?'.
|
||||
'and
|
||||
(c.shortname '.sql_ilike().' \'%'.$searchcourse.'%\'
|
||||
OR c.fullname '.sql_ilike().' \'%'.$searchcourse.'%\')';
|
||||
(c.shortname '.$DB->sql_ilike().' ?
|
||||
OR c.fullname '.$DB->sql_ilike().' ?)';
|
||||
$params = array($feedback->id, "%$searchcourse%", "%$searchcourse%");
|
||||
|
||||
if ($courses = get_records_sql_menu($sql)) {
|
||||
if ($courses = $DB->get_records_sql_menu($sql, $params)) {
|
||||
|
||||
echo ' ' . get_string('filter_by_course', 'feedback') . ': ';
|
||||
choose_from_menu ($courses, 'coursefilter', $coursefilter, 'choose', 'this.form.submit()');
|
||||
|
@ -1670,8 +1670,7 @@ function feedback_print_numeric_option_list($startval, $endval, $selectval = '',
|
||||
* @return void
|
||||
*/
|
||||
function feedback_send_email($cm, $feedback, $course, $userid) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($feedback->email_notification == 0) { // No need to do anything
|
||||
return;
|
||||
@ -1680,13 +1679,12 @@ function feedback_send_email($cm, $feedback, $course, $userid) {
|
||||
$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
|
||||
FROM {$CFG->prefix}groups g,
|
||||
{$CFG->prefix}groups_members m
|
||||
WHERE g.courseid = '$course->id'
|
||||
AND g.id = m.groupid
|
||||
AND m.userid = '$userid'
|
||||
ORDER BY name ASC");
|
||||
$groups = $DB->get_records_sql_menu("SELECT g.name, g.id
|
||||
FROM {groups} g, {groups_members} m
|
||||
WHERE g.courseid = ?
|
||||
AND g.id = m.groupid
|
||||
AND m.userid = ?
|
||||
ORDER BY name ASC", array($course->id, $userid));
|
||||
$groups = array_values($groups);
|
||||
|
||||
$teachers = feedback_get_receivemail_users($cm->id, $groups);
|
||||
|
@ -96,12 +96,13 @@
|
||||
echo '<input type="hidden" name="id" value="'.$id.'" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
|
||||
$sql = "select c.id, c.shortname from {$CFG->prefix}course c
|
||||
where
|
||||
c.shortname ".sql_ilike()." '%{$searchcourse}%'
|
||||
OR c.fullname ".sql_ilike()." '%{$searchcourse}%'";
|
||||
$sql = "select c.id, c.shortname
|
||||
from {course} c
|
||||
where c.shortname ".$DB->sql_ilike()." ?
|
||||
OR c.fullname ".$DB->sql_ilike()." ?";
|
||||
$params = array("%{$searchcourse}%", "%{$searchcourse}%");
|
||||
|
||||
if (($courses = get_records_sql_menu($sql)) && !empty($searchcourse)) {
|
||||
if (($courses = $DB->get_records_sql_menu($sql, $params)) && !empty($searchcourse)) {
|
||||
echo ' ' . get_string('courses') . ': ';
|
||||
choose_from_menu ($courses, 'coursefilter', $coursefilter, 'choose');
|
||||
echo '<input type="submit" value="'.get_string('mapcourse', 'feedback').'"/>';
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php // $Id$
|
||||
|
||||
function glossary_filter($courseid, $text) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
// Trivial-cache - keyed on $cachedcourseid
|
||||
static $nothingtodo;
|
||||
@ -28,17 +28,15 @@ function glossary_filter($courseid, $text) {
|
||||
if (empty($conceptlist)) {
|
||||
|
||||
/// Find all the glossaries we need to examine
|
||||
if (!$glossaries = get_records_sql_menu ('SELECT g.id, g.name
|
||||
FROM '.$CFG->prefix.'glossary g,
|
||||
'.$CFG->prefix.'course_modules cm,
|
||||
'.$CFG->prefix.'modules m
|
||||
if (!$glossaries = $DB->get_records_sql_menu('SELECT g.id, g.name
|
||||
FROM {glossary} g, {course_modules} cm, {modules} m
|
||||
WHERE m.name = \'glossary\' AND
|
||||
cm.module = m.id AND
|
||||
cm.visible = 1 AND
|
||||
g.id = cm.instance AND
|
||||
g.usedynalink != 0 AND
|
||||
(g.course = \''.$courseid.'\' OR g.globalglossary = 1)
|
||||
ORDER BY g.globalglossary, g.id')) {
|
||||
g.usedynalink <> 0 AND
|
||||
(g.course = ? OR g.globalglossary = 1)
|
||||
ORDER BY g.globalglossary, g.id', array($courseid))) {
|
||||
$nothingtodo = true;
|
||||
return $text;
|
||||
}
|
||||
|
@ -1170,7 +1170,7 @@ function hotpot_grades($hotpotid) {
|
||||
return $return;
|
||||
}
|
||||
function hotpot_get_grades($hotpot, $user_ids='') {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$grades = array();
|
||||
|
||||
@ -1201,12 +1201,12 @@ function hotpot_get_grades($hotpot, $user_ids='') {
|
||||
|
||||
if ($grade) {
|
||||
$userid_condition = empty($user_ids) ? '' : "AND userid IN ($user_ids) ";
|
||||
$grades = get_records_sql_menu("
|
||||
$grades = $DB->get_records_sql_menu("
|
||||
SELECT userid, $grade
|
||||
FROM {$CFG->prefix}hotpot_attempts
|
||||
WHERE timefinish>0 AND hotpot='$hotpot->id' $userid_condition
|
||||
FROM {hotpot_attempts}
|
||||
WHERE timefinish>0 AND hotpot=:hid $userid_condition
|
||||
GROUP BY userid
|
||||
");
|
||||
", array('hid'=>$hotpot->id));
|
||||
if ($grades) {
|
||||
if ($hotpot->grademethod==HOTPOT_GRADEMETHOD_FIRST || $hotpot->grademethod==HOTPOT_GRADEMETHOD_LAST) {
|
||||
// remove left hand characters in $grade (up to and including the underscore)
|
||||
|
@ -406,13 +406,13 @@ class hotpot_report extends hotpot_default_report {
|
||||
);
|
||||
}
|
||||
function set_data_attempt(&$attempt, &$strftimedate, &$strftimetime, &$blank) {
|
||||
global $CFG;
|
||||
$records = get_records_sql_menu("
|
||||
global $CFG, $DB;
|
||||
$records = $DB->get_records_sql_menu("
|
||||
SELECT userid, MAX(time) AS logintime
|
||||
FROM {$CFG->prefix}log
|
||||
WHERE userid=$attempt->userid AND action='login' AND time<$attempt->timestart
|
||||
FROM {log}
|
||||
WHERE userid=? AND action='login' AND time<?
|
||||
GROUP BY userid
|
||||
");
|
||||
", array($attempt->userid, $attempt->timestart));
|
||||
if (empty($records)) {
|
||||
$logindate = $blank;
|
||||
$logintime = $blank;
|
||||
@ -421,12 +421,12 @@ class hotpot_report extends hotpot_default_report {
|
||||
$logindate = trim(userdate($logintime, $strftimedate));
|
||||
$logintime = trim(userdate($logintime, $strftimetime));
|
||||
}
|
||||
$records = get_records_sql_menu("
|
||||
$records = $DB->get_records_sql_menu("
|
||||
SELECT userid, MIN(time) AS logouttime
|
||||
FROM {$CFG->prefix}log
|
||||
WHERE userid=$attempt->userid AND action='logout' AND time>$attempt->cr_timefinish
|
||||
FROM {log}
|
||||
WHERE userid=? AND action='logout' AND time>?
|
||||
GROUP BY userid
|
||||
");
|
||||
", array($attempt->userid, $attempt->cr_timefinish));
|
||||
if (empty($records)) {
|
||||
$logouttime = $blank;
|
||||
} else {
|
||||
|
@ -931,19 +931,17 @@ function quiz_get_post_actions() {
|
||||
* @return array of strings
|
||||
*/
|
||||
function quiz_question_list_instances($questionid) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
// TODO: we should also consider other questions that are used by
|
||||
// random questions in this quiz, but that is very hard.
|
||||
|
||||
$sql = "SELECT q.id, q.name
|
||||
FROM {$CFG->prefix}quiz q
|
||||
INNER JOIN
|
||||
{$CFG->prefix}quiz_question_instances qqi
|
||||
ON q.id = qqi.quiz
|
||||
WHERE qqi.question = '$questionid'";
|
||||
FROM {quiz} q
|
||||
JOIN {quiz_question_instances} qqi ON q.id = qqi.quiz
|
||||
WHERE qqi.question = ?";
|
||||
|
||||
if ($instances = get_records_sql_menu($sql)) {
|
||||
if ($instances = $DB->get_records_sql_menu($sql, array($questionid))) {
|
||||
return $instances;
|
||||
}
|
||||
return array();
|
||||
|
@ -6,7 +6,7 @@
|
||||
class quiz_report extends quiz_default_report {
|
||||
|
||||
function display($quiz, $cm, $course) { /// This function just displays the report
|
||||
global $CFG, $SESSION, $QTYPES;
|
||||
global $CFG, $SESSION, $QTYPES, $DB;
|
||||
$strnoattempts = get_string('noattempts','quiz');
|
||||
/// Only print headers if not asked to download data
|
||||
$download = optional_param('download', NULL);
|
||||
@ -72,10 +72,10 @@ class quiz_report extends quiz_default_report {
|
||||
|
||||
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 '.
|
||||
'FROM {user} u LEFT JOIN {quiz_attempts} qa ON u.id = qa.userid '.
|
||||
'WHERE qa.quiz = ? AND qa.preview = 0 '.
|
||||
$group;
|
||||
$usermax = get_records_sql_menu($sql);
|
||||
$usermax = $DB->get_records_sql_menu($sql, array($quiz->id));
|
||||
}else {
|
||||
$usermax = '';
|
||||
}
|
||||
|
@ -39,19 +39,19 @@ function quiz_get_newgraded_states($attemptids, $idxattemptq = true){
|
||||
}
|
||||
|
||||
function quiz_get_average_grade_for_questions($quiz, $userids){
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
$qmfilter = quiz_report_qm_filter_subselect($quiz, 'qa.userid');
|
||||
$questionavgssql = "SELECT qs.question, AVG(qs.grade) FROM " .
|
||||
"{$CFG->prefix}question_sessions qns, " .
|
||||
"{$CFG->prefix}quiz_attempts qa, " .
|
||||
"{$CFG->prefix}question_states qs " .
|
||||
"WHERE qns.attemptid = qa.uniqueid AND " .
|
||||
"qa.quiz = {$quiz->id} AND " .
|
||||
"qa.quiz = ? AND " .
|
||||
($qmfilter?$qmfilter.' AND ':'').
|
||||
"qa.userid IN ({$userids}) AND " .
|
||||
"qs.event IN (".QUESTION_EVENTS_GRADED.") AND ".
|
||||
"qns.newgraded = qs.id GROUP BY qs.question";
|
||||
return get_records_sql_menu($questionavgssql);
|
||||
return $DB->get_records_sql_menu($questionavgssql, array($quiz->id));
|
||||
}
|
||||
|
||||
function quiz_get_total_qas_graded_and_ungraded($quiz, $questionids, $userids){
|
||||
@ -164,17 +164,16 @@ function quiz_report_qm_filter_subselect($quiz, $useridsql = 'u.id'){
|
||||
}
|
||||
|
||||
function quiz_report_grade_bands($bandwidth, $bands, $quizid, $useridlist){
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
$sql = "SELECT
|
||||
FLOOR(qg.grade/$bandwidth) AS band,
|
||||
COUNT(1) AS num
|
||||
FROM
|
||||
{$CFG->prefix}quiz_grades qg,
|
||||
{$CFG->prefix}quiz q
|
||||
WHERE qg.quiz = q.id AND qg.quiz = $quizid AND qg.userid IN ($useridlist)
|
||||
{quiz_grades} qg, {quiz} q
|
||||
WHERE qg.quiz = q.id AND qg.quiz = ? AND qg.userid IN ($useridlist)
|
||||
GROUP BY band
|
||||
ORDER BY band";
|
||||
$data = get_records_sql_menu($sql);
|
||||
$data = $DB->get_records_sql_menu($sql, array($quizid));
|
||||
//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);
|
||||
|
@ -457,18 +457,17 @@
|
||||
}
|
||||
|
||||
function question_insert_c_and_q_ids_for_module($backup_unique_code, $course, $modulename, $instances){
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
$status = true;
|
||||
// using 'dummykeyname' in sql because otherwise get_records_sql_menu returns an error
|
||||
// using 'dummykeyname' in sql because otherwise $DB->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,
|
||||
{$CFG->prefix}course_modules cm,
|
||||
{$CFG->prefix}context c
|
||||
WHERE m.name = '$modulename' AND m.id = cm.module AND cm.id = c.instanceid
|
||||
AND c.contextlevel = ".CONTEXT_MODULE." AND cm.course = $course
|
||||
AND cm.instance IN (".implode(',',array_keys($instances)).")");
|
||||
$cmcontexts = $DB->get_records_sql_menu("SELECT c.id, c.id AS dummykeyname FROM {modules} m,
|
||||
{course_modules} cm, {context} c
|
||||
WHERE m.name = ? AND m.id = cm.module AND cm.id = c.instanceid
|
||||
AND c.contextlevel = ".CONTEXT_MODULE." AND cm.course = ?
|
||||
AND cm.instance IN (".implode(',',array_keys($instances)).")", array($modulename, $course));
|
||||
}
|
||||
|
||||
if ($cmcontexts){
|
||||
|
@ -90,10 +90,10 @@
|
||||
FROM
|
||||
{$CFG->prefix}{$table}
|
||||
WHERE
|
||||
doctype = '{$mod->name}'
|
||||
doctype = ?
|
||||
$itemtypes
|
||||
";
|
||||
$docIds = get_records_sql_menu($query);
|
||||
$docIds = $DB->get_records_sql_menu($query, array($mod->name));
|
||||
$docIdList = ($docIds) ? implode("','", array_keys($docIds)) : '' ;
|
||||
|
||||
$query = "
|
||||
|
@ -85,10 +85,10 @@
|
||||
FROM
|
||||
{$CFG->prefix}{$table}
|
||||
WHERE
|
||||
doctype = '{$mod->name}'
|
||||
doctype = ?
|
||||
$itemtypes
|
||||
";
|
||||
$docIds = get_records_sql_menu($query);
|
||||
$docIds = $DB->get_records_sql_menu($query, array($mod->name));
|
||||
$docIdList = ($docIds) ? implode("','", array_keys($docIds)) : '' ;
|
||||
|
||||
$query = "
|
||||
|
Loading…
x
Reference in New Issue
Block a user