diff --git a/lib/datalib.php b/lib/datalib.php index 1b95a9f4361..8c65ed73420 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -2585,22 +2585,45 @@ function get_course_mods($courseid) { /** - * Given an instance of a module, finds the coursemodule description + * Given an id of a course module, finds the coursemodule description * - * @uses $CFG - * @param string $modulename ? - * @param string $instance ? - * @param int $courseid The id of the course as found in the 'course' table. - * @return array - * @todo Finish documenting this function + * @param string $modulename name of module type, eg. resource, assignment,... + * @param int $cmid course module id (id in course_modules table) + * @param int $courseid optional course id for extra validation + * @return object course module instance with instance and module name + */ +function get_coursemodule_from_id($modulename, $cmid, $courseid=0) { + + global $CFG; + + $courseselect = ($courseid) ? "cm.course = '$courseid' AND " : ''; + + 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 $courseselect + cm.id = '$cmid' AND + cm.instance = m.id AND + md.name = '$modulename' AND + md.id = cm.module"); +} + +/** + * Given an instance number of a module, finds the coursemodule description + * + * @param string $modulename name of module type, eg. resource, assignment,... + * @param int $instance module instance number (id in resource, assignment etc. table) + * @param int $courseid optional course id for extra validation + * @return object course module instance with instance and module name */ function get_coursemodule_from_instance($modulename, $instance, $courseid=0) { global $CFG; - + $courseselect = ($courseid) ? "cm.course = '$courseid' AND " : ''; - return get_record_sql("SELECT cm.*, m.name + 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 diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index b9ab652c094..ff39549df80 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -37,7 +37,7 @@ class assignment_base { if ($cmid) { if ($cm) { $this->cm = $cm; - } else if (! $this->cm = get_record('course_modules', 'id', $cmid)) { + } else if (! $this->cm = get_coursemodule_from_id('assignment', $cmid)) { error('Course Module ID was incorrect'); } diff --git a/mod/assignment/submissions.php b/mod/assignment/submissions.php index 5e3c40abd4d..399d1f20e68 100644 --- a/mod/assignment/submissions.php +++ b/mod/assignment/submissions.php @@ -8,7 +8,7 @@ $mode = optional_param('mode', 'all'); // What mode are we in? if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('assignment', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/assignment/type/online/file.php b/mod/assignment/type/online/file.php index acbd89d38ec..9bdedf15925 100644 --- a/mod/assignment/type/online/file.php +++ b/mod/assignment/type/online/file.php @@ -7,7 +7,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID $userid = required_param('userid', PARAM_INT); // User ID - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('assignment', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/assignment/upload.php b/mod/assignment/upload.php index 231048d5dc6..048cdd3fe22 100644 --- a/mod/assignment/upload.php +++ b/mod/assignment/upload.php @@ -7,7 +7,7 @@ $a = optional_param('a'); // Assignment ID if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('assignment', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/assignment/version.php b/mod/assignment/version.php index 7ea94f4c790..0c865cfbe34 100644 --- a/mod/assignment/version.php +++ b/mod/assignment/version.php @@ -5,8 +5,8 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2005060100; -$module->requires = 2005031000; // Requires this Moodle version +$module->version = 2005060101; +$module->requires = 2005060241; // Requires this Moodle version $module->cron = 60; ?> diff --git a/mod/assignment/view.php b/mod/assignment/view.php index 437922c0a32..e135f40ab07 100644 --- a/mod/assignment/view.php +++ b/mod/assignment/view.php @@ -8,7 +8,7 @@ if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('assignment', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/chat/report.php b/mod/chat/report.php index 720bf3ac976..9ab8a205756 100644 --- a/mod/chat/report.php +++ b/mod/chat/report.php @@ -11,7 +11,7 @@ $deletesession = optional_param('deletesession', 0, PARAM_BOOL); $confirmdelete = optional_param('confirmdelete', 0, PARAM_BOOL); - if (! $cm = get_record('course_modules', 'id', $id)) { + if (! $cm = get_coursemodule_from_id('chat', $id)) { error('Course Module ID was incorrect'); } if (! $chat = get_record('chat', 'id', $cm->instance)) { diff --git a/mod/chat/version.php b/mod/chat/version.php index 7dcc3ebce16..0f932308337 100644 --- a/mod/chat/version.php +++ b/mod/chat/version.php @@ -5,8 +5,8 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2005031000; // The (date) version of this module -$module->requires = 2005031000; // Requires this Moodle version +$module->version = 2005031001; // The (date) version of this module +$module->requires = 2005060241; // Requires this Moodle version $module->cron = 300; // How often should cron check this module (seconds)? ?> diff --git a/mod/chat/view.php b/mod/chat/view.php index 80f51bfc68e..df158944241 100644 --- a/mod/chat/view.php +++ b/mod/chat/view.php @@ -12,7 +12,7 @@ $edit = optional_param('edit', ''); if ($id) { - if (! $cm = get_record('course_modules', 'id', $id)) { + if (! $cm = get_coursemodule_from_id('chat', $id)) { error('Course Module ID was incorrect'); } diff --git a/mod/choice/report.php b/mod/choice/report.php index ec8cad8c657..b7c797580cd 100644 --- a/mod/choice/report.php +++ b/mod/choice/report.php @@ -8,7 +8,7 @@ $format = optional_param('format', CHOICE_PUBLISH_NAMES, PARAM_INT); $download = optional_param('download', '', PARAM_ALPHA); - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('choice', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/choice/version.php b/mod/choice/version.php index 7298d916fdf..8c52ee0321c 100644 --- a/mod/choice/version.php +++ b/mod/choice/version.php @@ -5,8 +5,8 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2005041500; -$module->requires = 2005021600; // Requires this Moodle version +$module->version = 2005041501; +$module->requires = 2005060241; // Requires this Moodle version $module->cron = 0; ?> diff --git a/mod/choice/view.php b/mod/choice/view.php index 96ed1b9ca35..b30d92e6db2 100644 --- a/mod/choice/view.php +++ b/mod/choice/view.php @@ -5,7 +5,7 @@ require_variable($id); // Course Module ID - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('choice', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/exercise/assessments.php b/mod/exercise/assessments.php index 52490efb816..a5a4abec5ad 100644 --- a/mod/exercise/assessments.php +++ b/mod/exercise/assessments.php @@ -35,7 +35,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID // get some esential stuff... - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('exercise', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/exercise/submissions.php b/mod/exercise/submissions.php index 2e5d536fef4..8e238d920b5 100644 --- a/mod/exercise/submissions.php +++ b/mod/exercise/submissions.php @@ -27,7 +27,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID // get some essential stuff... - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('exercise', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/exercise/upload.php b/mod/exercise/upload.php index 9dacfa8ea0c..341df6c9d2d 100644 --- a/mod/exercise/upload.php +++ b/mod/exercise/upload.php @@ -8,7 +8,7 @@ $timenow = time(); // get some esential stuff... - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('exercise', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/exercise/version.php b/mod/exercise/version.php index c821728e701..a04b3290d30 100644 --- a/mod/exercise/version.php +++ b/mod/exercise/version.php @@ -5,8 +5,8 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2005031000; -$module->requires = 2005031000; // Requires this Moodle version +$module->version = 2005031001; +$module->requires = 2005060241; // Requires this Moodle version $module->cron = 60; ?> diff --git a/mod/exercise/view.php b/mod/exercise/view.php index 9359112c947..0f38f2d89b6 100644 --- a/mod/exercise/view.php +++ b/mod/exercise/view.php @@ -22,7 +22,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID // get some esential stuff... - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('exercise', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/forum/version.php b/mod/forum/version.php index 279fa087039..e97e1b70fe8 100644 --- a/mod/forum/version.php +++ b/mod/forum/version.php @@ -5,8 +5,8 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2005042600; -$module->requires = 2005031000; // Requires this Moodle version +$module->version = 2005042601; +$module->requires = 2005060241; // Requires this Moodle version $module->cron = 60; ?> diff --git a/mod/forum/view.php b/mod/forum/view.php index 928af8e2b9b..44101503c77 100644 --- a/mod/forum/view.php +++ b/mod/forum/view.php @@ -13,7 +13,7 @@ $search = optional_param('search', ''); // search string if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('forum', $id)) { error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { diff --git a/mod/glossary/approve.php b/mod/glossary/approve.php index 34df476b213..4e16a8ed357 100644 --- a/mod/glossary/approve.php +++ b/mod/glossary/approve.php @@ -9,7 +9,7 @@ $mode = optional_param('mode','approval', PARAM_ALPHA); $hook = optional_param('hook','ALL', PARAM_CLEAN); - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('glossary', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/glossary/comment.php b/mod/glossary/comment.php index ee646b13d9e..0671aeb42d8 100644 --- a/mod/glossary/comment.php +++ b/mod/glossary/comment.php @@ -14,7 +14,7 @@ global $USER, $CFG; - if (! $cm = get_record('course_modules', 'id', $id)) { + if (! $cm = get_coursemodule_from_id('glossary', $id)) { error('Course Module ID was incorrect'); } diff --git a/mod/glossary/comments.php b/mod/glossary/comments.php index 646e32b4233..f0bd9898bc5 100644 --- a/mod/glossary/comments.php +++ b/mod/glossary/comments.php @@ -9,7 +9,7 @@ global $USER, $CFG; - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('glossary', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/glossary/deleteentry.php b/mod/glossary/deleteentry.php index 8eba0c0354d..bf59d7bde4a 100644 --- a/mod/glossary/deleteentry.php +++ b/mod/glossary/deleteentry.php @@ -16,7 +16,7 @@ $entrydeleted = get_string("entrydeleted","glossary"); - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('glossary', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index aeadee0f9f8..0d061e84cb2 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -12,7 +12,7 @@ $confirm = optional_param('confirm',0, PARAM_INT); // proceed. Edit the edtry $mode = optional_param('mode', '', PARAM_ALPHA); // categories if by category? $hook = optional_param('hook', '', PARAM_ALPHANUM); // CategoryID -if (! $cm = get_record("course_modules", "id", $id)) { +if (! $cm = get_coursemodule_from_id('glossary', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/glossary/editcategories.php b/mod/glossary/editcategories.php index 222a82e43f4..cd6d933deda 100644 --- a/mod/glossary/editcategories.php +++ b/mod/glossary/editcategories.php @@ -16,7 +16,7 @@ $action = strtolower($action); - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('glossary', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/glossary/export.php b/mod/glossary/export.php index 6b480a5105c..85c04742f7b 100644 --- a/mod/glossary/export.php +++ b/mod/glossary/export.php @@ -9,7 +9,7 @@ $l = optional_param('l','', PARAM_ALPHANUM); $cat = optional_param('cat',0, PARAM_ALPHANUM); - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('glossary', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/glossary/exportentry.php b/mod/glossary/exportentry.php index 06ab91def2b..51c759e3e77 100644 --- a/mod/glossary/exportentry.php +++ b/mod/glossary/exportentry.php @@ -13,7 +13,7 @@ $PermissionGranted = 1; - $cm = get_record('course_modules','id',$id); + $cm = get_coursemodule_from_id('glossary', $id); if ( ! $cm ) { $PermissionGranted = 0; } else { diff --git a/mod/glossary/import.php b/mod/glossary/import.php index 585bed78017..b9276c951b0 100644 --- a/mod/glossary/import.php +++ b/mod/glossary/import.php @@ -15,7 +15,7 @@ $mode = optional_param('mode', 'letter', PARAM_ALPHA ); $hook = optional_param('hook', 'ALL', PARAM_ALPHANUM); - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('glossary', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/glossary/print.php b/mod/glossary/print.php index fff3987554a..cfe32d5295b 100644 --- a/mod/glossary/print.php +++ b/mod/glossary/print.php @@ -14,7 +14,7 @@ $hook = optional_param('hook','ALL', PARAM_ALPHANUM); // what to show $sortkey = optional_param('sortkey','UPDATE', PARAM_ALPHA); // Sorting key - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('glossary', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/glossary/version.php b/mod/glossary/version.php index 8ca41bdad86..44e4c964482 100644 --- a/mod/glossary/version.php +++ b/mod/glossary/version.php @@ -5,8 +5,8 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2005041900; -$module->requires = 2005031000; // Requires this Moodle version +$module->version = 2005041901; +$module->requires = 2005060241; // Requires this Moodle version $module->cron = 0; // Period for cron to check this module (secs) $release = "1.5 development"; // User-friendly version number diff --git a/mod/glossary/view.php b/mod/glossary/view.php index d8ff828ea85..2956a7018c2 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -20,7 +20,7 @@ $show = optional_param('show', '', PARAM_ALPHA); // [ concept | alias ] => mode=term hook=$show if (!empty($id)) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('glossary', $id)) { error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { diff --git a/mod/hotpot/report.php b/mod/hotpot/report.php index de889d622d9..879aee42533 100644 --- a/mod/hotpot/report.php +++ b/mod/hotpot/report.php @@ -9,7 +9,7 @@ $hp = optional_param("hp"); // hotpot ID if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('hotpot', $id)) { error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { diff --git a/mod/hotpot/review.php b/mod/hotpot/review.php index ee2a61862d9..dbf5f0b0b5d 100644 --- a/mod/hotpot/review.php +++ b/mod/hotpot/review.php @@ -11,7 +11,7 @@ $attempt = required_param("attempt"); // A particular attempt ID for review if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('hotpot', $id)) { error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { diff --git a/mod/hotpot/version.php b/mod/hotpot/version.php index ff7d4278ea7..fca69a1cdc6 100644 --- a/mod/hotpot/version.php +++ b/mod/hotpot/version.php @@ -5,9 +5,9 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2005031420; // release date of this version (see note below) -$module->release = 'v2.0.10'; // human-friendly version name (used in mod/hotpot/lib.php) -$module->requires = 2003091111; // Requires at least Moodle version 1.1.1 +$module->version = 2005031421; // release date of this version (see note below) +$module->release = 'v2.0.11'; // human-friendly version name (used in mod/hotpot/lib.php) +$module->requires = 2005060241; // Requires at least Moodle version 1.5.4+ $module->cron = 0; // period for cron to check this module (secs) // interpretation of YYYYMMDDXY version numbers diff --git a/mod/hotpot/view.php b/mod/hotpot/view.php index d20722de4a6..5a5e21fc896 100644 --- a/mod/hotpot/view.php +++ b/mod/hotpot/view.php @@ -9,7 +9,7 @@ $hp = optional_param("hp"); // hotpot ID if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('hotpot', $id)) { error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { diff --git a/mod/journal/edit.php b/mod/journal/edit.php index 6c710d98d7f..653f3b0b45b 100644 --- a/mod/journal/edit.php +++ b/mod/journal/edit.php @@ -4,7 +4,7 @@ require_variable($id); // Course Module ID - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('journal', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/journal/report.php b/mod/journal/report.php index e3bfaf182fa..a3679ade640 100644 --- a/mod/journal/report.php +++ b/mod/journal/report.php @@ -5,7 +5,7 @@ require_variable($id); // course module - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('journal', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/journal/version.php b/mod/journal/version.php index e85d4d8164c..11d3d12848f 100644 --- a/mod/journal/version.php +++ b/mod/journal/version.php @@ -5,8 +5,8 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2005041100; -$module->requires = 2005031000; // Requires this Moodle version +$module->version = 2005041101; +$module->requires = 2005060241; // Requires this Moodle version $module->cron = 60; ?> diff --git a/mod/journal/view.php b/mod/journal/view.php index d9308697582..a4f88e90772 100644 --- a/mod/journal/view.php +++ b/mod/journal/view.php @@ -5,7 +5,7 @@ require_variable($id); // Course Module ID - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('journal', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/label/version.php b/mod/label/version.php index 00b8102e040..8bf97c8edf5 100644 --- a/mod/label/version.php +++ b/mod/label/version.php @@ -5,8 +5,8 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2004111200; // The current module version (Date: YYYYMMDDXX) -$module->requires = 2004052505; // Requires this Moodle version +$module->version = 2004111201; // The current module version (Date: YYYYMMDDXX) +$module->requires = 2005060241; // Requires this Moodle version $module->cron = 0; // Period for cron to check this module (secs) ?> diff --git a/mod/label/view.php b/mod/label/view.php index 683275aee2e..41233116e28 100644 --- a/mod/label/view.php +++ b/mod/label/view.php @@ -6,7 +6,7 @@ optional_variable($l); // Label ID if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('label', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/lesson/import.php b/mod/lesson/import.php index d811883e702..055f82fbdd6 100644 --- a/mod/lesson/import.php +++ b/mod/lesson/import.php @@ -8,7 +8,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID $pageid = optional_param('pageid', '', PARAM_INT); // Page ID - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('lesson', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/lesson/lesson.php b/mod/lesson/lesson.php index 8b0a228c446..82a2ca225ba 100644 --- a/mod/lesson/lesson.php +++ b/mod/lesson/lesson.php @@ -26,7 +26,7 @@ $action = required_param('action', PARAM_ALPHA); // Action // get some esential stuff... - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('lesson', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/lesson/report.php b/mod/lesson/report.php index f16e5d9f8bb..123baa8a421 100644 --- a/mod/lesson/report.php +++ b/mod/lesson/report.php @@ -11,7 +11,7 @@ $pageid = optional_param('pageid', NULL, PARAM_INT); // Lesson Page ID $action = optional_param('action'); // action to take - if (! $cm = get_record('course_modules', 'id', $id)) { + if (! $cm = get_coursemodule_from_id('lesson', $id)) { error('Course Module ID was incorrect'); } diff --git a/mod/lesson/version.php b/mod/lesson/version.php index 46b1e85284d..f17858bf6e3 100644 --- a/mod/lesson/version.php +++ b/mod/lesson/version.php @@ -5,8 +5,8 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2005060900; // The current module version (Date: YYYYMMDDXX) -$module->requires = 2005021600; // Requires this Moodle version +$module->version = 2005060901; // The current module version (Date: YYYYMMDDXX) +$module->requires = 2005060241; // Requires this Moodle version $module->cron = 0; // Period for cron to check this module (secs) ?> diff --git a/mod/lesson/view.php b/mod/lesson/view.php index 759ca65c5c7..ddfdb72c8ae 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -10,7 +10,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID $pageid = optional_param('pageid', NULL, PARAM_INT); // Lesson Page ID - if (! $cm = get_record('course_modules', 'id', $id)) { + if (! $cm = get_coursemodule_from_id('lesson', $id)) { error('Course Module ID was incorrect'); } diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php index ade5465e5d1..2af1799de36 100644 --- a/mod/quiz/attempt.php +++ b/mod/quiz/attempt.php @@ -32,7 +32,7 @@ } if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('quiz', $id)) { error("There is no coursemodule with id $id"); } diff --git a/mod/quiz/report.php b/mod/quiz/report.php index 90b4c070860..fa6dd9dbf39 100644 --- a/mod/quiz/report.php +++ b/mod/quiz/report.php @@ -11,7 +11,7 @@ optional_variable($mode, "overview"); // Report mode if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('quiz', $id)) { error("There is no coursemodule with id $id"); } diff --git a/mod/quiz/version.php b/mod/quiz/version.php index db4e7d7c989..bcfdd220755 100644 --- a/mod/quiz/version.php +++ b/mod/quiz/version.php @@ -5,8 +5,8 @@ // This fragment is called by moodle_needs_upgrading() and /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2005060302; // The (date) version of this module -$module->requires = 2005021600; // Requires this Moodle version +$module->version = 2005060303; // The (date) version of this module +$module->requires = 2005060241; // Requires this Moodle version $module->cron = 0; // How often should cron check this module (seconds)? ?> diff --git a/mod/quiz/view.php b/mod/quiz/view.php index fe16bb8cd3c..2331c7936d7 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -13,7 +13,7 @@ if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('quiz', $id)) { error("There is no coursemodule with id $id"); } diff --git a/mod/resource/fetch.php b/mod/resource/fetch.php index 50b7dc8fc3b..90e16cd862a 100644 --- a/mod/resource/fetch.php +++ b/mod/resource/fetch.php @@ -9,7 +9,7 @@ require_variable($id); // Course Module ID require_variable($url); // url to fetch - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('resource', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/resource/lib.php b/mod/resource/lib.php index 0116c98c407..7cd9564b12a 100644 --- a/mod/resource/lib.php +++ b/mod/resource/lib.php @@ -82,7 +82,7 @@ function resource_base($cmid=0) { global $course; // Ugly hack, needed for course language ugly hack if ($cmid) { - if (! $this->cm = get_record("course_modules", "id", $cmid)) { + if (! $this->cm = get_coursemodule_from_id('resource', $cmid)) { error("Course Module ID was incorrect"); } diff --git a/mod/resource/version.php b/mod/resource/version.php index 64b68692608..7df2657962c 100644 --- a/mod/resource/version.php +++ b/mod/resource/version.php @@ -5,8 +5,8 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2005041100; -$module->requires = 2005021600; // Requires this Moodle version +$module->version = 2005041101; +$module->requires = 2005060241; // Requires this Moodle version $module->cron = 0; ?> diff --git a/mod/resource/view.php b/mod/resource/view.php index 227cd0f6129..fb14875315a 100644 --- a/mod/resource/view.php +++ b/mod/resource/view.php @@ -20,7 +20,7 @@ } } else if ($id) { - if (! $cm = get_record('course_modules', 'id', $id)) { + if (! $cm = get_coursemodule_from_id('resource', $id)) { error('Course Module ID was incorrect'); } diff --git a/mod/scorm/api.php b/mod/scorm/api.php index b605f82935a..7883e578b0a 100644 --- a/mod/scorm/api.php +++ b/mod/scorm/api.php @@ -9,7 +9,7 @@ optional_variable($mode); // navigation mode if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('scorm', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/scorm/datamodel.php b/mod/scorm/datamodel.php index 8a1f70b2e9f..ffe2be22575 100755 --- a/mod/scorm/datamodel.php +++ b/mod/scorm/datamodel.php @@ -6,7 +6,7 @@ optional_variable($a); // scorm IDa if ($id) { - if (! $cm = get_record('course_modules', 'id', $id)) { + if (! $cm = get_coursemodule_from_id('scorm', $id)) { error('Course Module ID was incorrect'); } if (! $course = get_record('course', 'id', $cm->course)) { diff --git a/mod/scorm/loadSCO.php b/mod/scorm/loadSCO.php index 2ab8dbcc865..948893c95fc 100755 --- a/mod/scorm/loadSCO.php +++ b/mod/scorm/loadSCO.php @@ -8,7 +8,7 @@ optional_variable($mode); // lesson mode if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('scorm', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/scorm/playscorm.php b/mod/scorm/playscorm.php index 6b5ca8a4f42..0e2f9727c73 100755 --- a/mod/scorm/playscorm.php +++ b/mod/scorm/playscorm.php @@ -9,7 +9,7 @@ optional_variable($a); // scorm ID if ($id) { - if (! $cm = get_record('course_modules', 'id', $id)) { + if (! $cm = get_coursemodule_from_id('scorm', $id)) { error('Course Module ID was incorrect'); } diff --git a/mod/scorm/report.php b/mod/scorm/report.php index b6b6054e076..3888d52ebab 100755 --- a/mod/scorm/report.php +++ b/mod/scorm/report.php @@ -10,7 +10,7 @@ optional_variable($user); // User ID if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('scorm', $id)) { error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { diff --git a/mod/scorm/version.php b/mod/scorm/version.php index 2622ed6e150..3fb0fb96aa8 100755 --- a/mod/scorm/version.php +++ b/mod/scorm/version.php @@ -5,8 +5,8 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2005070600; // The (date) version of this module -$module->requires = 2005021600; // The version of Moodle that is required +$module->version = 2005070601; // The (date) version of this module +$module->requires = 2005060241; // The version of Moodle that is required $module->cron = 0; // How often should cron check this module (seconds)? ?> diff --git a/mod/scorm/view.php b/mod/scorm/view.php index adceba8013e..9b9a879ad67 100755 --- a/mod/scorm/view.php +++ b/mod/scorm/view.php @@ -10,7 +10,7 @@ $a = optional_param('a'); // scorm ID if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('scorm', $id)) { error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { diff --git a/mod/survey/download.php b/mod/survey/download.php index 1bee0c8b386..24dfd9d7d3a 100644 --- a/mod/survey/download.php +++ b/mod/survey/download.php @@ -8,7 +8,7 @@ $type = optional_param('type', 'xls', PARAM_ALPHA); $group = optional_param('group', 0, PARAM_INT); - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('survey', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/survey/graph.php b/mod/survey/graph.php index 420ec18324e..019261873c2 100644 --- a/mod/survey/graph.php +++ b/mod/survey/graph.php @@ -10,7 +10,7 @@ $sid = optional_param('sid', false, PARAM_INT); // Student ID $qid = optional_param('qid', 0, PARAM_INT); // Group ID - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('survey', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/survey/save.php b/mod/survey/save.php index ac10167912a..e55acf1abfb 100644 --- a/mod/survey/save.php +++ b/mod/survey/save.php @@ -16,7 +16,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('survey', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/survey/version.php b/mod/survey/version.php index 7cdea8ed4eb..4ea019d101a 100644 --- a/mod/survey/version.php +++ b/mod/survey/version.php @@ -5,8 +5,8 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2005031600; -$module->requires = 2005031000; // Requires this Moodle version +$module->version = 2005031601; +$module->requires = 2005060241; // Requires this Moodle version $module->cron = 0; ?> diff --git a/mod/survey/view.php b/mod/survey/view.php index dcecf8f6ca5..ba384aa9cd9 100644 --- a/mod/survey/view.php +++ b/mod/survey/view.php @@ -5,7 +5,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('survey', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/wiki/admin.php b/mod/wiki/admin.php index 7d22e5578fc..de78172d865 100644 --- a/mod/wiki/admin.php +++ b/mod/wiki/admin.php @@ -13,7 +13,7 @@ $groupid = optional_param('groupid', 0, PARAM_INT); // Group wiki. if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('wiki', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/wiki/version.php b/mod/wiki/version.php index 3b4fb86c036..0cf09dee659 100644 --- a/mod/wiki/version.php +++ b/mod/wiki/version.php @@ -5,8 +5,8 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2005031000; // The current module version (Date: YYYYMMDDXX) -$module->requires = 2005031000; // The current module version (Date: YYYYMMDDXX) +$module->version = 2005031001; // The current module version (Date: YYYYMMDDXX) +$module->requires = 2005060241; // The current module version (Date: YYYYMMDDXX) $module->cron = 0; // Period for cron to check this module (secs) ?> diff --git a/mod/wiki/view.php b/mod/wiki/view.php index ab6ac063e76..189109da70d 100644 --- a/mod/wiki/view.php +++ b/mod/wiki/view.php @@ -23,7 +23,7 @@ if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('wiki', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/workshop/assessments.php b/mod/workshop/assessments.php index 794e5fc1ca1..d1793e04ec5 100644 --- a/mod/workshop/assessments.php +++ b/mod/workshop/assessments.php @@ -35,7 +35,7 @@ // get some useful stuff... if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('workshop', $id)) { error("Course Module ID was incorrect"); } if (! $workshop = get_record("workshop", "id", $cm->instance)) { diff --git a/mod/workshop/submissions.php b/mod/workshop/submissions.php index b7fc394539c..28ac1f6e834 100644 --- a/mod/workshop/submissions.php +++ b/mod/workshop/submissions.php @@ -26,7 +26,7 @@ $timenow = time(); // get some useful stuff... - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('workshop', $id)) { error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { diff --git a/mod/workshop/upload.php b/mod/workshop/upload.php index 50588c14863..5aeddd11c86 100644 --- a/mod/workshop/upload.php +++ b/mod/workshop/upload.php @@ -7,7 +7,7 @@ require_variable($id); // CM ID - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('workshop', $id)) { error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { diff --git a/mod/workshop/version.php b/mod/workshop/version.php index 77073ddea37..06d29c399ff 100644 --- a/mod/workshop/version.php +++ b/mod/workshop/version.php @@ -5,8 +5,8 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2005041200; -$module->requires = 2005031000; // Requires this Moodle version +$module->version = 2005041201; +$module->requires = 2005060241; // Requires this Moodle version $module->cron = 60; ?> diff --git a/mod/workshop/view.php b/mod/workshop/view.php index fafbee68412..456f67b53c8 100644 --- a/mod/workshop/view.php +++ b/mod/workshop/view.php @@ -25,7 +25,7 @@ $timenow = time(); // get some useful stuff... - if (! $cm = get_record("course_modules", "id", $id)) { + if (! $cm = get_coursemodule_from_id('workshop', $id)) { error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { diff --git a/version.php b/version.php index 0a5233aa82d..08ddbe42c74 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2005060240; // YYYYMMDD = Moodle 1.5 Date + $version = 2005060241; // YYYYMMDD = Moodle 1.5 Date // X = Moodle 1.5 Point release (0,1,2...) // Y = Interim incrementer