}
function instance_config_print() {
- global $CFG;
+ global $CFG, $DB;
if (!isset($this->config)) {
// ... teacher has not yet configured the block, let's put some default values here to explain things
}
// select glossaries to put in dropdown box ...
- $glossaries = get_records_select_menu('glossary', 'course='.$this->course->id,'name','id,name');
+ $glossaries = $DB->get_records_menu('glossary', array('course'=>$this->course->id),'name','id,name');
//format menu texts to avoid html and to filter multilang values
if(!empty($glossaries)) {
function get_records_menu($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
error('get_records_menu() removed');
}
+
+function get_records_select_menu($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
+ error('get_records_select_menu() removed');
+}
}
}
-/**
- * Get the first two columns from a number of records as an associative array.
- *
- * Arguments as for @see function get_recordset_select.
- * Return value as for @see function get_records_menu.
- *
- * @param string $table The database table to be checked against.
- * @param string $select A fragment of SQL to be used in a where clause in the SQL call.
- * @param string $sort Sort order (optional) - a valid SQL order parameter
- * @param string $fields A comma separated list of fields to be returned from the chosen table.
- * @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_select_menu($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
- $rs = get_recordset_select($table, $select, $sort, $fields, $limitfrom, $limitnum);
- return recordset_to_menu($rs);
-}
-
/**
* Get the first two columns from a number of records as an associative array.
*
* @return boolean
*/
function question_delete_course_category($category, $newcategory, $feedback=true) {
+ global $DB;
+
$context = get_context_instance(CONTEXT_COURSECAT, $category->id);
if (empty($newcategory)) {
$feedbackdata = array(); // To store feedback to be showed at the end of the process
// still in use somehow, even though quizzes in courses in this category will
// already have been deteted. This could happen, for example, if questions are
// added to a course, and then that course is moved to another category (MDL-14802).
- $questionids = get_records_select_menu('question', 'category = ' . $category->id, '', 'id,1');
+ $questionids = $DB->get_records_menu('question', array('category'=>$category->id), '', 'id,1');
if (!empty($questionids)) {
if (!$rescueqcategory = question_save_from_deletion(implode(',', array_keys($questionids)),
get_parent_contextid($context), print_context_name($context), $rescueqcategory)) {
* @return array all ordered pagebreak positions
*/
function feedback_get_all_break_positions($feedbackid) {
- if(!$allbreaks = get_records_select_menu('feedback_item', "typ = 'pagebreak' AND feedback = ".$feedbackid, 'position', 'id, position')) return false;
+ global $DB;
+
+ if(!$allbreaks = $DB->get_records_menu('feedback_item', array('typ'=>'pagebreak', 'feedback'=>$feedbackid), 'position', 'id, position')) return false;
return array_values($allbreaks);
}
* @return boolean true if the feedback already is submitted otherwise false
*/
function feedback_is_already_submitted($feedbackid, $courseid = false) {
- global $USER;
+ global $USER, $DB;
- $select = 'userid = '.$USER->id.' AND feedback = '.$feedbackid;
- if(!$trackings = get_records_select_menu('feedback_tracking', $select, '', 'id, completed')) {
+ if (!$trackings = $DB->get_records_menu('feedback_tracking', array('userid'=>$USER->id, 'feedback'=>$feedbackid), '', 'id, completed')) {
return false;
}
if($courseid) {
- $select = 'completed IN ('.implode(',',$trackings).') AND course_id = '.$courseid;
- if(!$values = get_records_select('feedback_value', $select)) {
+ $select = 'completed IN ('.implode(',',$trackings).') AND course_id = ?';
+ if(!$values = $DB->get_records_select('feedback_value', $select, array($courseid))) {
return false;
}
}
}
function scorm_view_display ($user, $scorm, $action, $cm, $boxwidth='') {
- global $CFG;
+ global $CFG, $DB;
if ($scorm->updatefreq == UPDATE_EVERYTIME){
require_once($CFG->dirroot.'/mod/scorm/lib.php');
if (empty($organization)) {
$organization = $scorm->launch;
}
- if ($orgs = get_records_select_menu('scorm_scoes',"scorm='$scorm->id' AND organization='' AND launch=''",'id','id,title')) {
+ if ($orgs = $DB->get_records_select_menu('scorm_scoes', array('scorm'=>$scorm->id, 'organization'=>'', 'launch'=>''), 'id', 'id,title')) {
if (count($orgs) > 1) {
?>
<div class='center'>
}
function move_questions($oldcat, $newcat){
- $questionids = get_records_select_menu('question', "category = $oldcat AND (parent = 0 OR parent = id)", '', 'id,1');
+ global $DB;
+ $questionids = $DB->get_records_select_menu('question', "category = ? AND (parent = 0 OR parent = id)", array($oldcat), '', 'id,1');
if (!question_move_questions_to_category(implode(',', array_keys($questionids)), $newcat)) {
print_error('errormovingquestions', 'question', $returnurl, $ids);
}
}
//adjust sortorder before we make the cat a peer of it's new peers
- $peers = get_records_select_menu('question_categories', "contextid = {$toparent->contextid} AND ".
- "parent = {$toparent->id}", "sortorder ASC",
- "id, id");
+ $peers = $DB->get_records_select_menu('question_categories', "contextid = ? AND parent = ?", array($toparent->contextid, $toparent->id),
+ "sortorder ASC", "id, id");
$peers = array_keys($peers);
if ($totop){
array_unshift($peers, $cattomove->id);