Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add get_coursemodule_from_id/instance functions for compatability wit…

…h Moodles <1.7
  • Loading branch information...
commit 29f4a60ffe599c56b1fdf9d5a5a0d3647c7e07e4 1 parent 2a532aa
gbateson authored
Showing with 41 additions and 1 deletion.
  1. +41 −1 mod/hotpot/lib.php
View
42 mod/hotpot/lib.php
@@ -2134,7 +2134,7 @@ function hotpot_string_id($str) {
if (isset($str) && $str<>'') {
// get the id from the table if it is already there
- $md5key = md5($str);
+ $md5key = md5($str);
if (!$id = get_field('hotpot_strings', 'id', 'md5key', $md5key, 'string', $str)) {
// create a string record
@@ -2195,6 +2195,46 @@ function set_user_preference($name, $value, $otheruser=NULL) {
return false;
}
}
+if (!function_exists('get_coursemodule_from_id')) {
+ // add this function for Moodle < 1.5.4
+ function get_coursemodule_from_id($modulename, $cmid, $courseid=0) {
+ global $CFG;
+ return get_record_sql("
+ SELECT
+ cm.*, m.name, md.name as modname
+ FROM
+ {$CFG->prefix}course_modules cm,
+ {$CFG->prefix}modules md,
+ {$CFG->prefix}$modulename m
+ WHERE
+ ".($courseid ? "cm.course = '$courseid' AND " : '')."
+ cm.id = '$cmid' AND
+ cm.instance = m.id AND
+ md.name = '$modulename' AND
+ md.id = cm.module
+ ");
+ }
+}
+if (!function_exists('get_coursemodule_from_instance')) {
+ // add this function for Moodle < 1.5.4
+ function get_coursemodule_from_instance($modulename, $instance, $courseid=0) {
+ global $CFG;
+ return get_record_sql("
+ SELECT
+ cm.*, m.name, md.name as modname
+ FROM
+ {$CFG->prefix}course_modules cm,
+ {$CFG->prefix}modules md,
+ {$CFG->prefix}$modulename m
+ WHERE
+ ".($courseid ? "cm.course = '$courseid' AND" : '')."
+ cm.instance = m.id AND
+ md.name = '$modulename' AND
+ md.id = cm.module AND
+ m.id = '$instance'
+ ");
+ }
+}
function hotpot_utf8_to_html_entity($char) {
// http://www.zend.com/codex.php?id=835&single=1
Please sign in to comment.
Something went wrong with that request. Please try again.