From: skodak Date: Tue, 8 Aug 2006 22:09:55 +0000 (+0000) Subject: new function get_coursemodule_from_id() is now used for obtaining of valid $cm from... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f9d5371b2835b84d988b05d9e02c1963af4eb81f;p=moodle.git new function get_coursemodule_from_id() is now used for obtaining of valid $cm from coursemodule id SC#283 --- diff --git a/lib/datalib.php b/lib/datalib.php index 18a3118e66..4f7a1c66df 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -2596,22 +2596,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 object - * @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 45981b6d0d..b8bd546502 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -53,7 +53,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 6b5693d98b..1256b29945 100644 --- a/mod/assignment/submissions.php +++ b/mod/assignment/submissions.php @@ -8,7 +8,7 @@ $mode = optional_param('mode', 'all', PARAM_ALPHA); // 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 af67bcf5e2..cc106618aa 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 cfb862753b..e866cdff02 100644 --- a/mod/assignment/upload.php +++ b/mod/assignment/upload.php @@ -7,7 +7,7 @@ $a = optional_param('a', 0, PARAM_INT); // 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 5966ec53c6..85ee874603 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 = 2006080800; -$module->requires = 2005031000; // Requires this Moodle version +$module->version = 2006080900; +$module->requires = 2006080900; // Requires this Moodle version $module->cron = 60; ?> diff --git a/mod/assignment/view.php b/mod/assignment/view.php index a773b77353..d38dcb8e34 100644 --- a/mod/assignment/view.php +++ b/mod/assignment/view.php @@ -7,7 +7,7 @@ $a = optional_param('a', 0, PARAM_INT); // 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/chat/report.php b/mod/chat/report.php index 4874c5281e..5bcf6a6116 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 fb90b69f22..5edab92c8d 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 = 2006080800; // The (date) version of this module -$module->requires = 2005031000; // Requires this Moodle version +$module->version = 2006080900; // The (date) version of this module +$module->requires = 2006080900; // 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 e2b0df89b1..5a125ed3b7 100644 --- a/mod/chat/view.php +++ b/mod/chat/view.php @@ -12,7 +12,7 @@ $edit = optional_param('edit', -1, PARAM_BOOL); 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 6f09637c44..c813d58e0e 100644 --- a/mod/choice/report.php +++ b/mod/choice/report.php @@ -8,7 +8,7 @@ $download = optional_param('download', '', PARAM_ALPHA); $action = optional_param('action', '', 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 8acd83c251..b9e78c1941 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 = 2006080800; -$module->requires = 2005021600; // Requires this Moodle version +$module->version = 2006080900; +$module->requires = 2006080900; // Requires this Moodle version $module->cron = 0; ?> diff --git a/mod/choice/view.php b/mod/choice/view.php index bcc54fca25..ff052f7ec3 100644 --- a/mod/choice/view.php +++ b/mod/choice/view.php @@ -7,7 +7,7 @@ $action = optional_param('action', '', PARAM_ALPHA); $attemptids = optional_param('attemptid', array(), PARAM_INT); // array of attempt ids for delete action - 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/data/edit.php b/mod/data/edit.php index 79a70545f0..a13ddaa562 100755 --- a/mod/data/edit.php +++ b/mod/data/edit.php @@ -33,7 +33,7 @@ $mode ='addtemplate'; //define the mode for this page, only 1 mode available if ($id) { - if (! $cm = get_record('course_modules', 'id', $id)) { + if (! $cm = get_coursemodule_from_id('data', $id)) { error('Course Module ID was incorrect'); } if (! $course = get_record('course', 'id', $cm->course)) { diff --git a/mod/data/import.php b/mod/data/import.php index 56fd75acdc..d29911500b 100755 --- a/mod/data/import.php +++ b/mod/data/import.php @@ -35,7 +35,7 @@ $fieldenclosure = optional_param('fieldenclosure', '', PARAM_CLEANHTML); // characters used as record delimiters for csv file import if ($id) { - if (! $cm = get_record('course_modules', 'id', $id)) { + if (! $cm = get_coursemodule_from_id('data', $id)) { error('Course Module ID was incorrect'); } if (! $course = get_record('course', 'id', $cm->course)) { diff --git a/mod/data/version.php b/mod/data/version.php index 770c3418eb..1e54d56e09 100644 --- a/mod/data/version.php +++ b/mod/data/version.php @@ -5,8 +5,8 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2006080800; -$module->requires = 2005060230; // Requires this Moodle version +$module->version = 2006080900; +$module->requires = 2006080900; // Requires this Moodle version $module->cron = 60; ?> diff --git a/mod/data/view.php b/mod/data/view.php index 6714592af9..9621ba24f7 100755 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -44,7 +44,7 @@ $delete = optional_param('delete', 0, PARAM_INT); //delete recordid if ($id) { - if (! $cm = get_record('course_modules', 'id', $id)) { + if (! $cm = get_coursemodule_from_id('data', $id)) { error('Course Module ID was incorrect'); } if (! $course = get_record('course', 'id', $cm->course)) { diff --git a/mod/exercise/assessments.php b/mod/exercise/assessments.php index 0feab86470..4ebeab3140 100644 --- a/mod/exercise/assessments.php +++ b/mod/exercise/assessments.php @@ -39,7 +39,7 @@ $userid = optional_param('userid', 0, PARAM_INT); // 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 9f2b57b5d8..de637461c2 100644 --- a/mod/exercise/submissions.php +++ b/mod/exercise/submissions.php @@ -31,7 +31,7 @@ $title = optional_param('title', '', PARAM_CLEAN); // 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 e894dbdd83..7f2e3d2c3e 100644 --- a/mod/exercise/upload.php +++ b/mod/exercise/upload.php @@ -10,7 +10,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 7921b82924..1e54d56e09 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 = 2006080800; -$module->requires = 2005031000; // Requires this Moodle version +$module->version = 2006080900; +$module->requires = 2006080900; // Requires this Moodle version $module->cron = 60; ?> diff --git a/mod/exercise/view.php b/mod/exercise/view.php index 32b0032eca..aa7a0afb3d 100644 --- a/mod/exercise/view.php +++ b/mod/exercise/view.php @@ -24,7 +24,7 @@ $changegroup = optional_param('group', -1, PARAM_INT); // 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 7921b82924..1e54d56e09 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 = 2006080800; -$module->requires = 2005031000; // Requires this Moodle version +$module->version = 2006080900; +$module->requires = 2006080900; // Requires this Moodle version $module->cron = 60; ?> diff --git a/mod/forum/view.php b/mod/forum/view.php index 94c1942248..123b8b0a60 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 426733b687..5448d92447 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 6c20a0d495..316143197c 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 8bf1851f50..38a54638d5 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 9265193e65..3d20b8124f 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 01f216b1e3..95e6623acc 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 77d106ff68..83d6dd55b8 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 9649a8d0e6..712cf758cb 100644 --- a/mod/glossary/export.php +++ b/mod/glossary/export.php @@ -10,7 +10,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 a50dd42d88..8619cc684f 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/exportfile.php b/mod/glossary/exportfile.php index d32b0344eb..e4f163de5b 100644 --- a/mod/glossary/exportfile.php +++ b/mod/glossary/exportfile.php @@ -8,7 +8,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/import.php b/mod/glossary/import.php index bb4db24505..0f1c029af5 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 0879237d4c..106017e6c4 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 0625d60479..b8fed5571d 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 = 2006080800; -$module->requires = 2005031000; // Requires this Moodle version +$module->version = 2006080900; +$module->requires = 2006080900; // Requires this Moodle version $module->cron = 0; // Period for cron to check this module (secs) ?> diff --git a/mod/glossary/view.php b/mod/glossary/view.php index 11376f1d58..d013974033 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/README.TXT b/mod/hotpot/README.TXT index 443046b787..83b3b16ff4 100644 --- a/mod/hotpot/README.TXT +++ b/mod/hotpot/README.TXT @@ -1,11 +1,11 @@ =============================================== -This is v2.1.21 of the HotPot module for Moodle +This is v2.2.0 of the HotPot module for Moodle =============================================== This module allows teachers to administer Hot Potatoes and TexToys quizzes via Moodle. It has been tested on: - Hot Potatoes 6 - - Moodle 1.1 thru 1.7 + - Moodle 1.7 - PHP 4.1 thru 5.1.2 - MySQL 4.x thru 5.0 - PostgreSQL 7.3 thru 8.2 diff --git a/mod/hotpot/report.php b/mod/hotpot/report.php index 58a229a45a..b800561879 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 b4fb712016..8d2b8fcad8 100644 --- a/mod/hotpot/review.php +++ b/mod/hotpot/review.php @@ -6,7 +6,7 @@ $hp = optional_param("hp"); // hotpot ID $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 ab4a8735fa..6a3e843a6c 100644 --- a/mod/hotpot/version.php +++ b/mod/hotpot/version.php @@ -3,8 +3,9 @@ /// Code fragment to define the version of hotpot /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2006080800; // release date of this version (see note below) -$module->release = 'v2.1.21'; // human-friendly version name (used in mod/hotpot/lib.php) +$module->version = 2006080900; // release date of this version (see note below) +$module->release = 'v2.2.0'; // human-friendly version name (used in mod/hotpot/lib.php) +$module->requires = 2006080900; // Requires this Moodle version $module->cron = 0; // period for cron to check this module (secs) // interpretation of YYYYMMDDXY version numbers // YYYY : year diff --git a/mod/hotpot/view.php b/mod/hotpot/view.php index 9d959d11fd..ab9c01324d 100644 --- a/mod/hotpot/view.php +++ b/mod/hotpot/view.php @@ -12,7 +12,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 0f3f247f41..7d2045c17b 100644 --- a/mod/journal/edit.php +++ b/mod/journal/edit.php @@ -4,7 +4,7 @@ $id = required_param('id', PARAM_INT); // 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 a80e75d837..b3477af947 100644 --- a/mod/journal/report.php +++ b/mod/journal/report.php @@ -5,7 +5,7 @@ $id = required_param('id', PARAM_INT); // 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 7921b82924..1e54d56e09 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 = 2006080800; -$module->requires = 2005031000; // Requires this Moodle version +$module->version = 2006080900; +$module->requires = 2006080900; // Requires this Moodle version $module->cron = 60; ?> diff --git a/mod/journal/view.php b/mod/journal/view.php index 5202c67634..43cccf8b7d 100644 --- a/mod/journal/view.php +++ b/mod/journal/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('journal', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/label/version.php b/mod/label/version.php index c5ea0af38e..f2373372f7 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 = 2006080800; // The current module version (Date: YYYYMMDDXX) -$module->requires = 2004052505; // Requires this Moodle version +$module->version = 2006080900; // The current module version (Date: YYYYMMDDXX) +$module->requires = 2006080900; // 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 95c6e5dd65..20575ece2b 100644 --- a/mod/label/view.php +++ b/mod/label/view.php @@ -6,7 +6,7 @@ $l = optional_param('l',0,PARAM_INT); // 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/lams/version.php b/mod/lams/version.php index 8d13175a8c..92dad72db9 100644 --- a/mod/lams/version.php +++ b/mod/lams/version.php @@ -5,7 +5,8 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2006080800; // The current module version (Date: YYYYMMDDXX) +$module->version = 2006080900; // The current module version (Date: YYYYMMDDXX) +$module->requires = 2006080900; // Requires this Moodle version $module->cron = 0; // Period for cron to check this module (secs) ?> diff --git a/mod/lams/view.php b/mod/lams/view.php index d47dd54ceb..1abfc78697 100644 --- a/mod/lams/view.php +++ b/mod/lams/view.php @@ -9,7 +9,7 @@ require_once("constants.php"); $id = optional_param('id', 0, PARAM_INT); // Course Module ID, or -if (! $cm = get_record("course_modules", "id", $id)) { +if (! $cm = get_coursemodule_from_id('lams', $id)) { error("Course Module ID was incorrect"); } diff --git a/mod/lesson/import.php b/mod/lesson/import.php index 96eb0a3ff7..5a22e7443e 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/importppt.php b/mod/lesson/importppt.php index 6c0f2e2159..f13b083a30 100644 --- a/mod/lesson/importppt.php +++ b/mod/lesson/importppt.php @@ -14,7 +14,7 @@ $pageid = optional_param('pageid', '', PARAM_INT); // Page ID global $matches; - 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 dac80ef47a..c5bd8fae5e 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/mediafile.php b/mod/lesson/mediafile.php index 484d5e2f6a..a7bcbf28d4 100644 --- a/mod/lesson/mediafile.php +++ b/mod/lesson/mediafile.php @@ -10,7 +10,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID $printclose = optional_param('printclose', 0, PARAM_INT); - if (! $cm = get_record('course_modules', 'id', $id)) { + if (! $cm = get_coursemodule_from_id('lesson', $id)) { error('Course Module ID was incorrect'); } @@ -91,7 +91,7 @@ echo "

"; echo ''; echo ""; echo ''; diff --git a/mod/lesson/report.php b/mod/lesson/report.php index 7c8969531f..845140c062 100644 --- a/mod/lesson/report.php +++ b/mod/lesson/report.php @@ -12,7 +12,7 @@ $action = optional_param('action', 'view', PARAM_ALPHA); // action to take $nothingtodisplay = false; - 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 83a330225b..a03a8c1b37 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 = 2006080800; // The current module version (Date: YYYYMMDDXX) -$module->requires = 2005021600; // Requires this Moodle version +$module->version = 2006080900; // The current module version (Date: YYYYMMDDXX) +$module->requires = 2006080900; // 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 e826a47c15..5da2ef7899 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -14,7 +14,7 @@ $mode = optional_param('mode', '', PARAM_ALPHA); // for eacherview action todo use user pref - 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 6260229fe6..23ece40c21 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 0728f79732..80e7d8ac05 100644 --- a/mod/quiz/report.php +++ b/mod/quiz/report.php @@ -11,7 +11,7 @@ $mode = optional_param('mode', 'overview', PARAM_ALPHA); // 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 d3e08f5958..3791e7b2c7 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 = 2006080800; // The (date) version of this module -$module->requires = 2006022400; // Requires this Moodle version +$module->version = 2006080900; // The (date) version of this module +$module->requires = 2006080900; // 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 8e99ba1b91..2219f4c4af 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -12,7 +12,7 @@ $edit = optional_param('edit', -1, PARAM_BOOL); 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 4cb9f82b20..7c85b14dcf 100644 --- a/mod/resource/fetch.php +++ b/mod/resource/fetch.php @@ -9,7 +9,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID $url = required_param('url', PARAM_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 f12727b055..071209f414 100644 --- a/mod/resource/lib.php +++ b/mod/resource/lib.php @@ -86,7 +86,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/type/ims/deploy.php b/mod/resource/type/ims/deploy.php index d449c13f39..1beb7172cf 100644 --- a/mod/resource/type/ims/deploy.php +++ b/mod/resource/type/ims/deploy.php @@ -46,7 +46,7 @@ /// Fetch some records from DB $course = get_record ('course', 'id', $courseid); - $cm = get_record ('course_modules', 'id', $cmid); + $cm = get_coursemodule_from_id('resource', $cmid); $resource = get_record ('resource', 'id', $cm->instance); /// Get some needed strings diff --git a/mod/resource/version.php b/mod/resource/version.php index 8acd83c251..b9e78c1941 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 = 2006080800; -$module->requires = 2005021600; // Requires this Moodle version +$module->version = 2006080900; +$module->requires = 2006080900; // Requires this Moodle version $module->cron = 0; ?> diff --git a/mod/resource/view.php b/mod/resource/view.php index 227cd0f612..fb14875315 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 4016ec0ae7..7bad6ae47d 100644 --- a/mod/scorm/api.php +++ b/mod/scorm/api.php @@ -10,7 +10,7 @@ $attempt = required_param('attempt', PARAM_INT); // new attempt if (!empty($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 b822f36a66..ea33994c99 100755 --- a/mod/scorm/loadSCO.php +++ b/mod/scorm/loadSCO.php @@ -7,7 +7,7 @@ $scoid = required_param('scoid', PARAM_INT); // sco ID if (!empty($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/player.php b/mod/scorm/player.php index d92e43dd68..b295a9e2e6 100755 --- a/mod/scorm/player.php +++ b/mod/scorm/player.php @@ -1,428 +1,428 @@ -course)) { - error("Course is misconfigured"); - } - if (! $scorm = get_record("scorm", "id", $cm->instance)) { - error("Course module is incorrect"); - } - } else if (!empty($a)) { - if (! $scorm = get_record("scorm", "id", $a)) { - error("Course module is incorrect"); - } - if (! $course = get_record("course", "id", $scorm->course)) { - error("Course is misconfigured"); - } - if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { - error("Course Module ID was incorrect"); - } - } else { - error('A required parameter is missing'); - } - - require_login($course->id, false, $cm); - - //$f = "D:\\test.txt"; - //@$ft = fopen($f,"a"); - //fwrite($ft,"\n ++ Thong tin quyen set attempt ".$USER->setAttempt); - $strscorms = get_string('modulenameplural', 'scorm'); - $strscorm = get_string('modulename', 'scorm'); - $strpopup = get_string('popup','scorm'); - - $attempt = scorm_get_last_attempt($scorm->id,$USER->id); - - //Kiem tra xem co phai la tiep tuc khong - if ($mode=='continue') { - $scoid = scorm_get_suspendscoid($scorm->id,$USER->id); - $USER->setAttempt = 'set'; - $mode = 'normal'; - } - if (($mode == 'normal') && ($USER->setAttempt == 'notset')) { - $attempt++; - $USER->setAttempt = 'set'; - } - //Thuc hien Sequencing - - if ($mode!='review') { - $sequencingResult = scorm_sequecingrule_implement($scorm->id,$scoid,$USER->id); - //echo ""; - } - if (($sequencingResult->rule == 'exit') && ($sequencingResult->action == 'exit')){ - $exitscoid = get_sco_after_exit($scoid,$scorm->id); - //fwrite($ft,"\n ++ Thong tin exit sco la ".$exitscoid); - $orgstr = '¤torg='.$currentorg; - $modepop = '&mode='.$mode; - $scostr = '&scoid='.$exitscoid; - echo ""; - } - } - - //Thiet lap attempt_status cho scoid - scorm_set_attempt($scoid,$USER->id); - //Ket thuc thiet lap attemp_status - if ($mode!='review') { - //Update trang thai - scorm_rollup_updatestatus($scorm->id,$scoid,$USER->id); - //------------------------------ - } - //Thiet lap thong tin lien quan truy xuat Scorm - $statistic = get_record('scorm_statistic',"scormid",$scorm->id,"userid",$USER->id); - if (empty($statistic)) { - $statisticInput->accesstime = time(); - $statisticInput->durationtime = 0; - $statisticInput->status = 'during'; - $statisticInput->attemptnumber = $attempt; - $statisticInput->scormid = $scorm->id; - $statisticInput->userid = $USER->id; - $statisticid = scorm_insert_statistic($statisticInput); - } else { - if ($statistic->status=='suspend') { - $statisticInput->accesstime = time(); - $statisticInput->durationtime = $statistic->durationtime; - $statisticInput->status = 'during'; - $statisticInput->attemptnumber = $attempt; - $statisticInput->scormid = $scorm->id; - $statisticInput->userid = $USER->id; - } - } - - //---------------------Ket thuc thiet lap thoi gian --------------- - - //Lay thoi gian toi da cho phep - $absoluteTimeLimit = scorm_get_AbsoluteTimeLimit($scoid); - if ($absoluteTimeLimit > 0) { - echo ""; - } - //-------------------------------- - - - if ($course->category != 0) { - $navigation = "framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname ->"; - if ($scorms = get_all_instances_in_course('scorm', $course)) { - // The module SCORM activity with the least id is the course - $firstscorm = current($scorms); - if (!(($course->format == 'scorm') && ($firstscorm->id == $scorm->id))) { - $navigation .= "framename}\" href=\"index.php?id=$course->id\">$strscorms ->"; - } - } - } else { - $navigation = "framename}\" href=\"index.php?id=$course->id\">$strscorms ->"; - } - - $pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name)); - - if (!$cm->visible and !isteacher($course->id)) { - print_header($pagetitle, "$course->fullname", - "$navigation ".format_string($scorm->name,true)."", - '', '', true, update_module_button($cm->id, $course->id, $strscorm), '', false); - notice(get_string("activityiscurrentlyhidden")); - } - - // - // TOC processing - // - //$attempt = scorm_get_last_attempt($scorm->id, $USER->id); - //$f = "D:\\test.txt"; - //@$ft = fopen($f,"a"); - ////fwrite($ft,"\n ++ ++ + ++ Gia tri $attempt lay duoc la ".$attempt); - - //if ($mode=='normal'){ - // $newattempt = 'on'; - //} - if (($newattempt=='on') && (($attempt < $scorm->maxattempt) || ($scorm->maxattempt == 0))) { - $attempt++; - //$f = "D:\\test.txt"; - //@$ft = fopen($f,"a"); - //fwrite($ft,"\n ----New attempt------- ".$attempt); - - } - $attemptstr = '&attempt=' . $attempt; - - //fwrite($ft,"\n ----Gia tri attempt bay gio la------- ".$attempt); - $result = scorm_get_toc($USER,$scorm,'structurelist',$currentorg,$scoid,$mode,$attempt,true); - $sco = $result->sco; - - if (($mode == 'browse') && ($scorm->hidebrowse == 1)) { - $mode = 'normal'; - } - if ($mode != 'browse') { - ////fwrite($ft,"\n ++ ++ + ++ Gia tri $mode khac browser ".$mode); - if ($trackdata = scorm_get_tracks($sco->id,$USER->id,$attempt)) { - if (($trackdata->status == 'completed') || ($trackdata->status == 'passed') || ($trackdata->status == 'failed')) { - $mode = 'review'; - ////fwrite($ft,"\n ++ ++ + ++ Gia tri $mode ".$mode); - } else { - $mode = 'normal'; - ////fwrite($ft,"\n ++ ++ + ++ Gia tri $mode ".$mode); - } - } - } - - add_to_log($course->id, 'scorm', 'view', "player.php?id=$cm->id&scoid=$sco->id", "$scorm->id"); - - $scoidstr = '&scoid='.$sco->id; - $scoidpop = '&scoid='.$sco->id; - $modestr = '&mode='.$mode; - if ($mode == 'browse') { - $modepop = '&mode='.$mode; - } else { - $modepop = ''; - } - $orgstr = '¤torg='.$currentorg; - - $SESSION->scorm_scoid = $sco->id; - $SESSION->scorm_status = 'Not Initialized'; - $SESSION->scorm_mode = $mode; - $SESSION->attempt = $attempt; - - // Doan code them - ////fwrite($ft,"\n ++ ++ + ++ Gia tri attempt duoc gan cho user la ".$attempt); - $USER->attempt = $attempt; - //------------Ket thuc doan them - - // - // Print the page header - // - $bodyscript = ''; - if ($scorm->popup == 1) { - $bodyscript = 'onunload="main.close();"'; - } - - // Kiem tra xem co duoc exit khong - if (scorm_isChoiceexit($sco->scorm,$sco->id)) { - $exitlink = '('.get_string('exit','scorm').') '; - } else { - $exitlink = get_string('exitisnotallowed','scorm'); - } - - //Luu giu khoa hoc thoat ra - $suspend = '('.get_string('suspend','scorm').') '; - - print_header($pagetitle, "$course->fullname", - "$navigation ".format_string($scorm->name,true)."", - '', '', true, $exitlink.$suspend.update_module_button($cm->id, $course->id, $strscorm), '', false, $bodyscript); - if ($sco->scormtype == 'sco') { -?> - - -previd != 0) && ($sco->previous == 0)) { - $scostr = '&scoid='.$sco->previd; - echo ' \n"; - } else { - echo ' \n"; - } - if (($sco->nextid != 0) && ($sco->next == 0)) { - $scostr = '&scoid='.$sco->nextid; - echo ' \n"; - } else { - echo ' \n"; - } -?> -
-hidetoc == 0) { -?> -
-
-
- toc; ?> -
-
- -
> -hidenav == 0) && // Teacher want to display navigation links - ( - ( - ($sco->previd != 0) && // This is not the first learning object of the package - ($sco->previous == 0) // Moodle must manage the previous link - ) || - ( - ($sco->nextid != 0) && // This is not the last learning object of the package - ($sco->next == 0) // Moodle must manage the next link - ) - ) - ) || ($scorm->hidetoc == 2) // Teacher want to display toc in a small dropdown menu - ) { -?> -
- '.get_string('browsemode','scorm')."
\n" : ''; ?> - '.get_string('reviewmode','scorm')."
\n" : ''; ?> -hidenav == 0) || ($scorm->hidetoc == 2)) { -?> -
- hidenav == 0) && ($sco->previd != 0) && ($sco->previous == 0)) { - /// Print the prev LO link - $scostr = '&scoid='.$sco->previd; - $url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr; - echo '< '.get_string('prev','scorm').''; - } - if ($scorm->hidetoc == 2) { - echo $result->tocmenu; - } - if (($scorm->hidenav == 0) && ($sco->nextid != 0) && ($sco->next == 0)) { - /// Print the next LO link - $scostr = '&scoid='.$sco->nextid; - $url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr; - echo '  '.get_string('next','scorm').' >'; - } - ?> - -
- -
- -
- -prerequisites) { - if ($scorm->popup == 0) { - if (strpos('MSIE',$_SERVER['HTTP_USER_AGENT']) === false) { - /// Internet Explorer does not has full support to objects -?> - - - - - - - - - -
- - - - - - - - +course)) { + error("Course is misconfigured"); + } + if (! $scorm = get_record("scorm", "id", $cm->instance)) { + error("Course module is incorrect"); + } + } else if (!empty($a)) { + if (! $scorm = get_record("scorm", "id", $a)) { + error("Course module is incorrect"); + } + if (! $course = get_record("course", "id", $scorm->course)) { + error("Course is misconfigured"); + } + if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { + error("Course Module ID was incorrect"); + } + } else { + error('A required parameter is missing'); + } + + require_login($course->id, false, $cm); + + //$f = "D:\\test.txt"; + //@$ft = fopen($f,"a"); + //fwrite($ft,"\n ++ Thong tin quyen set attempt ".$USER->setAttempt); + $strscorms = get_string('modulenameplural', 'scorm'); + $strscorm = get_string('modulename', 'scorm'); + $strpopup = get_string('popup','scorm'); + + $attempt = scorm_get_last_attempt($scorm->id,$USER->id); + + //Kiem tra xem co phai la tiep tuc khong + if ($mode=='continue') { + $scoid = scorm_get_suspendscoid($scorm->id,$USER->id); + $USER->setAttempt = 'set'; + $mode = 'normal'; + } + if (($mode == 'normal') && ($USER->setAttempt == 'notset')) { + $attempt++; + $USER->setAttempt = 'set'; + } + //Thuc hien Sequencing + + if ($mode!='review') { + $sequencingResult = scorm_sequecingrule_implement($scorm->id,$scoid,$USER->id); + //echo ""; + } + if (($sequencingResult->rule == 'exit') && ($sequencingResult->action == 'exit')){ + $exitscoid = get_sco_after_exit($scoid,$scorm->id); + //fwrite($ft,"\n ++ Thong tin exit sco la ".$exitscoid); + $orgstr = '¤torg='.$currentorg; + $modepop = '&mode='.$mode; + $scostr = '&scoid='.$exitscoid; + echo ""; + } + } + + //Thiet lap attempt_status cho scoid + scorm_set_attempt($scoid,$USER->id); + //Ket thuc thiet lap attemp_status + if ($mode!='review') { + //Update trang thai + scorm_rollup_updatestatus($scorm->id,$scoid,$USER->id); + //------------------------------ + } + //Thiet lap thong tin lien quan truy xuat Scorm + $statistic = get_record('scorm_statistic',"scormid",$scorm->id,"userid",$USER->id); + if (empty($statistic)) { + $statisticInput->accesstime = time(); + $statisticInput->durationtime = 0; + $statisticInput->status = 'during'; + $statisticInput->attemptnumber = $attempt; + $statisticInput->scormid = $scorm->id; + $statisticInput->userid = $USER->id; + $statisticid = scorm_insert_statistic($statisticInput); + } else { + if ($statistic->status=='suspend') { + $statisticInput->accesstime = time(); + $statisticInput->durationtime = $statistic->durationtime; + $statisticInput->status = 'during'; + $statisticInput->attemptnumber = $attempt; + $statisticInput->scormid = $scorm->id; + $statisticInput->userid = $USER->id; + } + } + + //---------------------Ket thuc thiet lap thoi gian --------------- + + //Lay thoi gian toi da cho phep + $absoluteTimeLimit = scorm_get_AbsoluteTimeLimit($scoid); + if ($absoluteTimeLimit > 0) { + echo ""; + } + //-------------------------------- + + + if ($course->category != 0) { + $navigation = "framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname ->"; + if ($scorms = get_all_instances_in_course('scorm', $course)) { + // The module SCORM activity with the least id is the course + $firstscorm = current($scorms); + if (!(($course->format == 'scorm') && ($firstscorm->id == $scorm->id))) { + $navigation .= "framename}\" href=\"index.php?id=$course->id\">$strscorms ->"; + } + } + } else { + $navigation = "framename}\" href=\"index.php?id=$course->id\">$strscorms ->"; + } + + $pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name)); + + if (!$cm->visible and !isteacher($course->id)) { + print_header($pagetitle, "$course->fullname", + "$navigation ".format_string($scorm->name,true)."", + '', '', true, update_module_button($cm->id, $course->id, $strscorm), '', false); + notice(get_string("activityiscurrentlyhidden")); + } + + // + // TOC processing + // + //$attempt = scorm_get_last_attempt($scorm->id, $USER->id); + //$f = "D:\\test.txt"; + //@$ft = fopen($f,"a"); + ////fwrite($ft,"\n ++ ++ + ++ Gia tri $attempt lay duoc la ".$attempt); + + //if ($mode=='normal'){ + // $newattempt = 'on'; + //} + if (($newattempt=='on') && (($attempt < $scorm->maxattempt) || ($scorm->maxattempt == 0))) { + $attempt++; + //$f = "D:\\test.txt"; + //@$ft = fopen($f,"a"); + //fwrite($ft,"\n ----New attempt------- ".$attempt); + + } + $attemptstr = '&attempt=' . $attempt; + + //fwrite($ft,"\n ----Gia tri attempt bay gio la------- ".$attempt); + $result = scorm_get_toc($USER,$scorm,'structurelist',$currentorg,$scoid,$mode,$attempt,true); + $sco = $result->sco; + + if (($mode == 'browse') && ($scorm->hidebrowse == 1)) { + $mode = 'normal'; + } + if ($mode != 'browse') { + ////fwrite($ft,"\n ++ ++ + ++ Gia tri $mode khac browser ".$mode); + if ($trackdata = scorm_get_tracks($sco->id,$USER->id,$attempt)) { + if (($trackdata->status == 'completed') || ($trackdata->status == 'passed') || ($trackdata->status == 'failed')) { + $mode = 'review'; + ////fwrite($ft,"\n ++ ++ + ++ Gia tri $mode ".$mode); + } else { + $mode = 'normal'; + ////fwrite($ft,"\n ++ ++ + ++ Gia tri $mode ".$mode); + } + } + } + + add_to_log($course->id, 'scorm', 'view', "player.php?id=$cm->id&scoid=$sco->id", "$scorm->id"); + + $scoidstr = '&scoid='.$sco->id; + $scoidpop = '&scoid='.$sco->id; + $modestr = '&mode='.$mode; + if ($mode == 'browse') { + $modepop = '&mode='.$mode; + } else { + $modepop = ''; + } + $orgstr = '¤torg='.$currentorg; + + $SESSION->scorm_scoid = $sco->id; + $SESSION->scorm_status = 'Not Initialized'; + $SESSION->scorm_mode = $mode; + $SESSION->attempt = $attempt; + + // Doan code them + ////fwrite($ft,"\n ++ ++ + ++ Gia tri attempt duoc gan cho user la ".$attempt); + $USER->attempt = $attempt; + //------------Ket thuc doan them + + // + // Print the page header + // + $bodyscript = ''; + if ($scorm->popup == 1) { + $bodyscript = 'onunload="main.close();"'; + } + + // Kiem tra xem co duoc exit khong + if (scorm_isChoiceexit($sco->scorm,$sco->id)) { + $exitlink = '('.get_string('exit','scorm').') '; + } else { + $exitlink = get_string('exitisnotallowed','scorm'); + } + + //Luu giu khoa hoc thoat ra + $suspend = '('.get_string('suspend','scorm').') '; + + print_header($pagetitle, "$course->fullname", + "$navigation ".format_string($scorm->name,true)."", + '', '', true, $exitlink.$suspend.update_module_button($cm->id, $course->id, $strscorm), '', false, $bodyscript); + if ($sco->scormtype == 'sco') { +?> + + +previd != 0) && ($sco->previous == 0)) { + $scostr = '&scoid='.$sco->previd; + echo ' \n"; + } else { + echo ' \n"; + } + if (($sco->nextid != 0) && ($sco->next == 0)) { + $scostr = '&scoid='.$sco->nextid; + echo ' \n"; + } else { + echo ' \n"; + } +?> +
+hidetoc == 0) { +?> +
+
+
+ toc; ?> +
+
+ +
> +hidenav == 0) && // Teacher want to display navigation links + ( + ( + ($sco->previd != 0) && // This is not the first learning object of the package + ($sco->previous == 0) // Moodle must manage the previous link + ) || + ( + ($sco->nextid != 0) && // This is not the last learning object of the package + ($sco->next == 0) // Moodle must manage the next link + ) + ) + ) || ($scorm->hidetoc == 2) // Teacher want to display toc in a small dropdown menu + ) { +?> +
+ '.get_string('browsemode','scorm')."
\n" : ''; ?> + '.get_string('reviewmode','scorm')."
\n" : ''; ?> +hidenav == 0) || ($scorm->hidetoc == 2)) { +?> +
+ hidenav == 0) && ($sco->previd != 0) && ($sco->previous == 0)) { + /// Print the prev LO link + $scostr = '&scoid='.$sco->previd; + $url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr; + echo '< '.get_string('prev','scorm').''; + } + if ($scorm->hidetoc == 2) { + echo $result->tocmenu; + } + if (($scorm->hidenav == 0) && ($sco->nextid != 0) && ($sco->next == 0)) { + /// Print the next LO link + $scostr = '&scoid='.$sco->nextid; + $url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr; + echo '  '.get_string('next','scorm').' >'; + } + ?> + +
+ +
+ +
+ +prerequisites) { + if ($scorm->popup == 0) { + if (strpos('MSIE',$_SERVER['HTTP_USER_AGENT']) === false) { + /// Internet Explorer does not has full support to objects +?> + + + + + + + + + +
+ + + + + + + + diff --git a/mod/scorm/report.php b/mod/scorm/report.php index 43ca583001..1935a3bba9 100755 --- a/mod/scorm/report.php +++ b/mod/scorm/report.php @@ -1,368 +1,368 @@ -course)) { - error("Course is misconfigured"); - } - if (! $scorm = get_record("scorm", "id", $cm->instance)) { - error("Course module is incorrect"); - } - } else { - if (!empty($b)) { - if (! $sco = get_record("scorm_scoes", "id", $b)) { - error("Scorm activity is incorrect"); - } - $a = $sco->scorm; - } - if (!empty($a)) { - if (! $scorm = get_record("scorm", "id", $a)) { - error("Course module is incorrect"); - } - if (! $course = get_record("course", "id", $scorm->course)) { - error("Course is misconfigured"); - } - if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { - error("Course Module ID was incorrect"); - } - } - } - - require_login($course->id, false, $cm); - - if (!isteacher($course->id)) { - error("You are not allowed to use this script"); - } - - add_to_log($course->id, "scorm", "report", "report.php?id=$cm->id", "$scorm->id"); - -/// Print the page header - if (empty($noheader)) { - if ($course->category) { - $navigation = "id\">$course->shortname ->"; - } else { - $navigation = ''; - } - - $strscorms = get_string("modulenameplural", "scorm"); - $strscorm = get_string("modulename", "scorm"); - $strreport = get_string("report", "scorm"); - $strname = get_string('name'); - if (empty($b)) { - print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname", - "$navigation id\">$strscorms - -> id\">".format_string($scorm->name,true)." -> $strreport", - "", "", true); - } else { - print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname", - "$navigation id\">$strscorms - -> id\">".format_string($scorm->name,true)." - -> id\">$strreport -> $sco->title", - "", "", true); - } - print_heading(format_string($scorm->name)); - } - - $scormpixdir = $CFG->modpixpath.'/scorm/pix'; - - if (empty($b) ) { - if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' ORDER BY id")) { - if ($scousers=get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid")) { - $table = new stdClass(); - $table->head = array(' ', $strname); - $table->align = array('center', 'left'); - $table->wrap = array('nowrap', 'nowrap'); - $table->width = '100%'; - $table->size = array(10, '*'); - foreach ($scoes as $sco) { - if ($sco->launch!='') { - $table->head[]=scorm_string_wrap($sco->title); - //$table->head[]=$sco->title; - $table->align[] = 'center'; - $table->wrap[] = 'nowrap'; - $table->size[] = '*'; - } - } - - foreach ($scousers as $scouser) { - if ($userdata = scorm_get_user_data($scouser->userid)) { - $row = array(); - $row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true); - $row[] = "wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">". - "$userdata->firstname $userdata->lastname"; - foreach ($scoes as $sco) { - if ($sco->launch!='') { - $anchorstart = ''; - $anchorend = ''; - $scoreview = ''; - if ($trackdata = scorm_get_tracks($sco->id,$scouser->userid)) { - if ($trackdata->score_raw != '') { - $scoreview = '
'.get_string('score','scorm').': '.$trackdata->score_raw; - } - if ($trackdata->status == '') { - $trackdata->status = 'notattempted'; - } else { - $anchorstart = ''; - $anchorend = ''; - } - } else { - $trackdata->status = 'notattempted'; - $trackdata->total_time = ''; - } - $strstatus = get_string($trackdata->status,'scorm'); - $row[] = $anchorstart.''.$strstatus.' '.$trackdata->total_time.$scoreview.$anchorend; - } - } - $table->data[] = $row; - } - } - print_table($table); - } else { - notice('No users to report'); - } - } - } else { - if (!empty($user)) { - if ($userdata = scorm_get_user_data($user)) { - print_simple_box_start('center'); - print_heading(format_string($sco->title)); - echo '
'."\n"; - print_user_picture($user, $course->id, $userdata->picture, false, false); - echo "wwwroot/user/view.php?id=$user&course=$course->id\">". - "$userdata->firstname $userdata->lastname
"; - $scoreview = ''; - if ($trackdata = scorm_get_tracks($sco->id,$user)) { - if ($trackdata->score_raw != '') { - $scoreview = get_string('score','scorm').': '.$trackdata->score_raw; - } - if ($trackdata->status == '') { - $trackdata->status = 'notattempted'; - } - } else { - $trackdata->status = 'notattempted'; - $trackdata->total_time = ''; - } - $strstatus = get_string($trackdata->status,'scorm'); - echo ''.$strstatus.' '.$trackdata->total_time.'
'.$scoreview.'
'; - echo '
'."\n"; - echo '

'.get_string('details','scorm').'

'; - - // Print general score data - $table = new stdClass(); - $table->head = array(get_string('element','scorm'), get_string('value','scorm')); - $table->align = array('left', 'left'); - $table->wrap = array('nowrap', 'nowrap'); - $table->width = '100%'; - $table->size = array('*', '*'); - - $existelements = false; - if ($scorm->version == 'SCORM_1.3') { - $elements = array('raw' => 'cmi.score.raw', - 'min' => 'cmi.score.min', - 'max' => 'cmi.score.max', - 'status' => 'cmi.completition_status', - 'time' => 'cmi.total_time'); - } else { - $elements = array('raw' => 'cmi.core.score.raw', - 'min' => 'cmi.core.score.min', - 'max' => 'cmi.core.score.max', - 'status' => 'cmi.core.lesson_status', - 'time' => 'cmi.core.total_time'); - } - foreach ($elements as $key => $element) { - if (isset($trackdata->$element)) { - $existelements = true; - $printedelements[]=$element; - $row = array(); - $row[] = get_string($key,'scorm'); - $row[] = $trackdata->$element; - $table->data[] = $row; - } - } - if ($existelements) { - echo '

'.get_string('general','scorm').'

'; - print_table($table); - } - - // Print Interactions data - $table = new stdClass(); - $table->head = array(get_string('identifier','scorm'), - get_string('type','scorm'), - get_string('result','scorm'), - get_string('student_response','scorm')); - $table->align = array('center', 'center', 'center', 'center'); - $table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap'); - $table->width = '100%'; - $table->size = array('*', '*', '*', '*', '*'); - - $existinteraction = false; - - $i = 0; - $interactionid = 'cmi.interactions.'.$i.'.id'; - - while (isset($trackdata->$interactionid)) { - $existinteraction = true; - $printedelements[]=$interactionid; - $elements = array($interactionid, - 'cmi.interactions.'.$i.'.type', - 'cmi.interactions.'.$i.'.result', - 'cmi.interactions.'.$i.'.student_response'); - $row = array(); - foreach ($elements as $element) { - if (isset($trackdata->$element)) { - $row[] = $trackdata->$element; - $printedelements[]=$element; - } else { - $row[] = ' '; - } - } - $table->data[] = $row; - - $i++; - $interactionid = 'cmi.interactions.'.$i.'.id'; - } - if ($existinteraction) { - echo '

'.get_string('interactions','scorm').'

'; - print_table($table); - } - - // Print Objectives data - $table = new stdClass(); - $table->head = array(get_string('identifier','scorm'), - get_string('status','scorm'), - get_string('raw','scorm'), - get_string('min','scorm'), - get_string('max','scorm')); - $table->align = array('center', 'center', 'center', 'center', 'center'); - $table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap'); - $table->width = '100%'; - $table->size = array('*', '*', '*', '*', '*'); - - $existobjective = false; - - $i = 0; - $objectiveid = 'cmi.objectives.'.$i.'.id'; - - while (isset($trackdata->$objectiveid)) { - $existobjective = true; - $printedelements[]=$objectiveid; - $elements = array($objectiveid, - 'cmi.objectives.'.$i.'.status', - 'cmi.objectives.'.$i.'.score.raw', - 'cmi.objectives.'.$i.'.score.min', - 'cmi.objectives.'.$i.'.score.max'); - $row = array(); - foreach ($elements as $element) { - if (isset($trackdata->$element)) { - $row[] = $trackdata->$element; - $printedelements[]=$element; - } else { - $row[] = ' '; - } - } - $table->data[] = $row; - - $i++; - $objectiveid = 'cmi.objectives.'.$i.'.id'; - } - if ($existobjective) { - echo '

'.get_string('objectives','scorm').'

'; - print_table($table); - } - $table = new stdClass(); - $table->head = array(get_string('element','scorm'), get_string('value','scorm')); - $table->align = array('left', 'left'); - $table->wrap = array('nowrap', 'wrap'); - $table->width = '100%'; - $table->size = array('*', '*'); - - $existelements = false; - - foreach($trackdata as $element => $value) { - if (substr($element,0,3) == 'cmi') { - if (!(in_array ($element, $printedelements))) { - $existelements = true; - $row = array(); - $row[] = get_string($element,'scorm') != '[['.$element.']]' ? get_string($element,'scorm') : $element; - $row[] = $value; - $table->data[] = $row; - } - } - } - if ($existelements) { - echo '

'.get_string('othertracks','scorm').'

'; - print_table($table); - } - print_simple_box_end(); - } - } else { - error('Missing script parameter'); - } - } - - print_heading(format_string(get_string('timestatistic','scorm'))); - $scousers=get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid"); - $attempt = scorm_get_last_attempt($scorm->id,$USER->id); - - foreach($scousers as $scouser){ - $str = 'scormid ='.($scorm->id).' and userid = '.$scouser->userid.' and attempt = '.$attempt.' ORDER BY timemodified asc'; - $endtrack = get_record_select("scorm_scoes_track", $str,'max(timemodified) as maxtimemodified'); - - } - -//Phan trinh bay thong ke theo thoi gian - $table = new stdClass(); - $table->head = array(' ', get_string('name','scorm')); - $table->align = array('center', 'left'); - $table->wrap = array('nowrap', 'nowrap'); - $table->width = '100%'; - $table->size = array(10, '*'); - - $table->head[]=scorm_string_wrap(get_string('beginTime','scorm')); - $table->align[] = 'center'; - $table->wrap[] = 'nowrap'; - $table->size[] = '*'; - - $table->head[]=scorm_string_wrap(get_string('endTime','scorm')); - $table->align[] = 'center'; - $table->wrap[] = 'nowrap'; - $table->size[] = '*'; - - $row = array(); - $row[] = ""; - $row[] = "(".get_string('coefficient','scorm').")"; - foreach($scousers as $scouser){ - $userdata = scorm_get_user_data($scouser->userid); - $row = array(); - $row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true); - $row[] = "wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">". - "$userdata->firstname $userdata->lastname"; - $str = 'scormid ='.($scorm->id).' and userid = '.$scouser->userid.' and attempt = '.$attempt.' ORDER BY timemodified asc'; - $begintrack = get_record_select("scorm_scoes_track", $str,'min(timemodified) as mintimemodified'); - $row[] = strftime( "%H h -%M ' - %S s - %d -%m-%Y", $begintrack->mintimemodified); - $endtrack = get_record_select("scorm_scoes_track", $str,'max(timemodified) as maxtimemodified'); - $row[] = strftime( "%H h -%M ' - %S s - %d -%m-%Y", $endtrack->maxtimemodified); - $table->data[] = $row; - } - print_table($table); - - echo "
".format_string(get_string('viewscore','scorm')).""; - if (empty($noheader)) { - print_footer($course); - } -?> +course)) { + error("Course is misconfigured"); + } + if (! $scorm = get_record("scorm", "id", $cm->instance)) { + error("Course module is incorrect"); + } + } else { + if (!empty($b)) { + if (! $sco = get_record("scorm_scoes", "id", $b)) { + error("Scorm activity is incorrect"); + } + $a = $sco->scorm; + } + if (!empty($a)) { + if (! $scorm = get_record("scorm", "id", $a)) { + error("Course module is incorrect"); + } + if (! $course = get_record("course", "id", $scorm->course)) { + error("Course is misconfigured"); + } + if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { + error("Course Module ID was incorrect"); + } + } + } + + require_login($course->id, false, $cm); + + if (!isteacher($course->id)) { + error("You are not allowed to use this script"); + } + + add_to_log($course->id, "scorm", "report", "report.php?id=$cm->id", "$scorm->id"); + +/// Print the page header + if (empty($noheader)) { + if ($course->category) { + $navigation = "id\">$course->shortname ->"; + } else { + $navigation = ''; + } + + $strscorms = get_string("modulenameplural", "scorm"); + $strscorm = get_string("modulename", "scorm"); + $strreport = get_string("report", "scorm"); + $strname = get_string('name'); + if (empty($b)) { + print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname", + "$navigation id\">$strscorms + -> id\">".format_string($scorm->name,true)." -> $strreport", + "", "", true); + } else { + print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname", + "$navigation id\">$strscorms + -> id\">".format_string($scorm->name,true)." + -> id\">$strreport -> $sco->title", + "", "", true); + } + print_heading(format_string($scorm->name)); + } + + $scormpixdir = $CFG->modpixpath.'/scorm/pix'; + + if (empty($b) ) { + if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' ORDER BY id")) { + if ($scousers=get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid")) { + $table = new stdClass(); + $table->head = array(' ', $strname); + $table->align = array('center', 'left'); + $table->wrap = array('nowrap', 'nowrap'); + $table->width = '100%'; + $table->size = array(10, '*'); + foreach ($scoes as $sco) { + if ($sco->launch!='') { + $table->head[]=scorm_string_wrap($sco->title); + //$table->head[]=$sco->title; + $table->align[] = 'center'; + $table->wrap[] = 'nowrap'; + $table->size[] = '*'; + } + } + + foreach ($scousers as $scouser) { + if ($userdata = scorm_get_user_data($scouser->userid)) { + $row = array(); + $row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true); + $row[] = "wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">". + "$userdata->firstname $userdata->lastname"; + foreach ($scoes as $sco) { + if ($sco->launch!='') { + $anchorstart = ''; + $anchorend = ''; + $scoreview = ''; + if ($trackdata = scorm_get_tracks($sco->id,$scouser->userid)) { + if ($trackdata->score_raw != '') { + $scoreview = '
'.get_string('score','scorm').': '.$trackdata->score_raw; + } + if ($trackdata->status == '') { + $trackdata->status = 'notattempted'; + } else { + $anchorstart = ''; + $anchorend = ''; + } + } else { + $trackdata->status = 'notattempted'; + $trackdata->total_time = ''; + } + $strstatus = get_string($trackdata->status,'scorm'); + $row[] = $anchorstart.''.$strstatus.' '.$trackdata->total_time.$scoreview.$anchorend; + } + } + $table->data[] = $row; + } + } + print_table($table); + } else { + notice('No users to report'); + } + } + } else { + if (!empty($user)) { + if ($userdata = scorm_get_user_data($user)) { + print_simple_box_start('center'); + print_heading(format_string($sco->title)); + echo '
'."\n"; + print_user_picture($user, $course->id, $userdata->picture, false, false); + echo "wwwroot/user/view.php?id=$user&course=$course->id\">". + "$userdata->firstname $userdata->lastname
"; + $scoreview = ''; + if ($trackdata = scorm_get_tracks($sco->id,$user)) { + if ($trackdata->score_raw != '') { + $scoreview = get_string('score','scorm').': '.$trackdata->score_raw; + } + if ($trackdata->status == '') { + $trackdata->status = 'notattempted'; + } + } else { + $trackdata->status = 'notattempted'; + $trackdata->total_time = ''; + } + $strstatus = get_string($trackdata->status,'scorm'); + echo ''.$strstatus.' '.$trackdata->total_time.'
'.$scoreview.'
'; + echo '
'."\n"; + echo '

'.get_string('details','scorm').'

'; + + // Print general score data + $table = new stdClass(); + $table->head = array(get_string('element','scorm'), get_string('value','scorm')); + $table->align = array('left', 'left'); + $table->wrap = array('nowrap', 'nowrap'); + $table->width = '100%'; + $table->size = array('*', '*'); + + $existelements = false; + if ($scorm->version == 'SCORM_1.3') { + $elements = array('raw' => 'cmi.score.raw', + 'min' => 'cmi.score.min', + 'max' => 'cmi.score.max', + 'status' => 'cmi.completition_status', + 'time' => 'cmi.total_time'); + } else { + $elements = array('raw' => 'cmi.core.score.raw', + 'min' => 'cmi.core.score.min', + 'max' => 'cmi.core.score.max', + 'status' => 'cmi.core.lesson_status', + 'time' => 'cmi.core.total_time'); + } + foreach ($elements as $key => $element) { + if (isset($trackdata->$element)) { + $existelements = true; + $printedelements[]=$element; + $row = array(); + $row[] = get_string($key,'scorm'); + $row[] = $trackdata->$element; + $table->data[] = $row; + } + } + if ($existelements) { + echo '

'.get_string('general','scorm').'

'; + print_table($table); + } + + // Print Interactions data + $table = new stdClass(); + $table->head = array(get_string('identifier','scorm'), + get_string('type','scorm'), + get_string('result','scorm'), + get_string('student_response','scorm')); + $table->align = array('center', 'center', 'center', 'center'); + $table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap'); + $table->width = '100%'; + $table->size = array('*', '*', '*', '*', '*'); + + $existinteraction = false; + + $i = 0; + $interactionid = 'cmi.interactions.'.$i.'.id'; + + while (isset($trackdata->$interactionid)) { + $existinteraction = true; + $printedelements[]=$interactionid; + $elements = array($interactionid, + 'cmi.interactions.'.$i.'.type', + 'cmi.interactions.'.$i.'.result', + 'cmi.interactions.'.$i.'.student_response'); + $row = array(); + foreach ($elements as $element) { + if (isset($trackdata->$element)) { + $row[] = $trackdata->$element; + $printedelements[]=$element; + } else { + $row[] = ' '; + } + } + $table->data[] = $row; + + $i++; + $interactionid = 'cmi.interactions.'.$i.'.id'; + } + if ($existinteraction) { + echo '

'.get_string('interactions','scorm').'

'; + print_table($table); + } + + // Print Objectives data + $table = new stdClass(); + $table->head = array(get_string('identifier','scorm'), + get_string('status','scorm'), + get_string('raw','scorm'), + get_string('min','scorm'), + get_string('max','scorm')); + $table->align = array('center', 'center', 'center', 'center', 'center'); + $table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap'); + $table->width = '100%'; + $table->size = array('*', '*', '*', '*', '*'); + + $existobjective = false; + + $i = 0; + $objectiveid = 'cmi.objectives.'.$i.'.id'; + + while (isset($trackdata->$objectiveid)) { + $existobjective = true; + $printedelements[]=$objectiveid; + $elements = array($objectiveid, + 'cmi.objectives.'.$i.'.status', + 'cmi.objectives.'.$i.'.score.raw', + 'cmi.objectives.'.$i.'.score.min', + 'cmi.objectives.'.$i.'.score.max'); + $row = array(); + foreach ($elements as $element) { + if (isset($trackdata->$element)) { + $row[] = $trackdata->$element; + $printedelements[]=$element; + } else { + $row[] = ' '; + } + } + $table->data[] = $row; + + $i++; + $objectiveid = 'cmi.objectives.'.$i.'.id'; + } + if ($existobjective) { + echo '

'.get_string('objectives','scorm').'

'; + print_table($table); + } + $table = new stdClass(); + $table->head = array(get_string('element','scorm'), get_string('value','scorm')); + $table->align = array('left', 'left'); + $table->wrap = array('nowrap', 'wrap'); + $table->width = '100%'; + $table->size = array('*', '*'); + + $existelements = false; + + foreach($trackdata as $element => $value) { + if (substr($element,0,3) == 'cmi') { + if (!(in_array ($element, $printedelements))) { + $existelements = true; + $row = array(); + $row[] = get_string($element,'scorm') != '[['.$element.']]' ? get_string($element,'scorm') : $element; + $row[] = $value; + $table->data[] = $row; + } + } + } + if ($existelements) { + echo '

'.get_string('othertracks','scorm').'

'; + print_table($table); + } + print_simple_box_end(); + } + } else { + error('Missing script parameter'); + } + } + + print_heading(format_string(get_string('timestatistic','scorm'))); + $scousers=get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid"); + $attempt = scorm_get_last_attempt($scorm->id,$USER->id); + + foreach($scousers as $scouser){ + $str = 'scormid ='.($scorm->id).' and userid = '.$scouser->userid.' and attempt = '.$attempt.' ORDER BY timemodified asc'; + $endtrack = get_record_select("scorm_scoes_track", $str,'max(timemodified) as maxtimemodified'); + + } + +//Phan trinh bay thong ke theo thoi gian + $table = new stdClass(); + $table->head = array(' ', get_string('name','scorm')); + $table->align = array('center', 'left'); + $table->wrap = array('nowrap', 'nowrap'); + $table->width = '100%'; + $table->size = array(10, '*'); + + $table->head[]=scorm_string_wrap(get_string('beginTime','scorm')); + $table->align[] = 'center'; + $table->wrap[] = 'nowrap'; + $table->size[] = '*'; + + $table->head[]=scorm_string_wrap(get_string('endTime','scorm')); + $table->align[] = 'center'; + $table->wrap[] = 'nowrap'; + $table->size[] = '*'; + + $row = array(); + $row[] = ""; + $row[] = "(".get_string('coefficient','scorm').")"; + foreach($scousers as $scouser){ + $userdata = scorm_get_user_data($scouser->userid); + $row = array(); + $row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true); + $row[] = "wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">". + "$userdata->firstname $userdata->lastname"; + $str = 'scormid ='.($scorm->id).' and userid = '.$scouser->userid.' and attempt = '.$attempt.' ORDER BY timemodified asc'; + $begintrack = get_record_select("scorm_scoes_track", $str,'min(timemodified) as mintimemodified'); + $row[] = strftime( "%H h -%M ' - %S s - %d -%m-%Y", $begintrack->mintimemodified); + $endtrack = get_record_select("scorm_scoes_track", $str,'max(timemodified) as maxtimemodified'); + $row[] = strftime( "%H h -%M ' - %S s - %d -%m-%Y", $endtrack->maxtimemodified); + $table->data[] = $row; + } + print_table($table); + + echo "
".format_string(get_string('viewscore','scorm')).""; + if (empty($noheader)) { + print_footer($course); + } +?> diff --git a/mod/scorm/version.php b/mod/scorm/version.php index e3a6718b98..c31c652837 100755 --- a/mod/scorm/version.php +++ b/mod/scorm/version.php @@ -1,12 +1,12 @@ -version = 2006080800; // The (date) version of this module -$module->requires = 2005060200; // The version of Moodle that is required -$module->cron = 0; // How often should cron check this module (seconds)? - -?> +version = 2006080900; // The (date) version of this module +$module->requires = 2006080900; // 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 427e4f066e..f97bf11d89 100755 --- a/mod/scorm/view.php +++ b/mod/scorm/view.php @@ -1,97 +1,97 @@ -course)) { - error("Course is misconfigured"); - } - if (! $scorm = get_record("scorm", "id", $cm->instance)) { - error("Course module is incorrect"); - } - } else if (!empty($a)) { - if (! $scorm = get_record("scorm", "id", $a)) { - error("Course module is incorrect"); - } - if (! $course = get_record("course", "id", $scorm->course)) { - error("Course is misconfigured"); - } - if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { - error("Course Module ID was incorrect"); - } - } else { - error('A required parameter is missing'); - } - - require_login($course->id, false, $cm); - - if (isset($SESSION->scorm_scoid)) { - unset($SESSION->scorm_scoid); - } - - $strscorms = get_string("modulenameplural", "scorm"); - $strscorm = get_string("modulename", "scorm"); - - if ($course->category != 0) { - $navigation = "framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname ->"; - if ($scorms = get_all_instances_in_course('scorm', $course)) { - // The module SCORM activity with the least id is the course - $firstscorm = current($scorms); - if (!(($course->format == 'scorm') && ($firstscorm->id == $scorm->id))) { - $navigation .= "framename}\" href=\"index.php?id=$course->id\">$strscorms ->"; - } - } - } else { - $navigation = "framename}\" href=\"index.php?id=$course->id\">$strscorms ->"; - } - - $pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name)); - - add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id"); - - // - // Print the page header - // - if (!$cm->visible and !isteacher($course->id)) { - print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name), '', '', true, - update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm)); - notice(get_string('activityiscurrentlyhidden')); - } else { - print_header($pagetitle, "$course->fullname", - "$navigation framename}\" href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."", - '', '', true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm)); - - if (isteacher($course->id)) { - - //Phan thiet lap he so diem - $examNumber = get_record_select('scorm_scoes', 'scorm ='.($scorm->id).' and minnormalizedmeasure > -1','count(id) as examCount'); - //fwrite($ft,"\n So bai kiem tra la ".($examNumber->examCount)); - if ($examNumber->examCount > 0){ - echo "'; - } - - //----------------------- - $trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c'); - if ($trackedusers->c > 0) { - echo "'; - } else { - echo ''; - } - } - - $USER->setAttempt = 'notset'; - // Print the main part of the page - print_heading(format_string($scorm->name)); - print_simple_box(format_text($scorm->summary), 'center', '70%', '', 5, 'generalbox', 'intro'); - scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm); - print_footer($course); - } -?> +course)) { + error("Course is misconfigured"); + } + if (! $scorm = get_record("scorm", "id", $cm->instance)) { + error("Course module is incorrect"); + } + } else if (!empty($a)) { + if (! $scorm = get_record("scorm", "id", $a)) { + error("Course module is incorrect"); + } + if (! $course = get_record("course", "id", $scorm->course)) { + error("Course is misconfigured"); + } + if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { + error("Course Module ID was incorrect"); + } + } else { + error('A required parameter is missing'); + } + + require_login($course->id, false, $cm); + + if (isset($SESSION->scorm_scoid)) { + unset($SESSION->scorm_scoid); + } + + $strscorms = get_string("modulenameplural", "scorm"); + $strscorm = get_string("modulename", "scorm"); + + if ($course->category != 0) { + $navigation = "framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname ->"; + if ($scorms = get_all_instances_in_course('scorm', $course)) { + // The module SCORM activity with the least id is the course + $firstscorm = current($scorms); + if (!(($course->format == 'scorm') && ($firstscorm->id == $scorm->id))) { + $navigation .= "framename}\" href=\"index.php?id=$course->id\">$strscorms ->"; + } + } + } else { + $navigation = "framename}\" href=\"index.php?id=$course->id\">$strscorms ->"; + } + + $pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name)); + + add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id"); + + // + // Print the page header + // + if (!$cm->visible and !isteacher($course->id)) { + print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name), '', '', true, + update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm)); + notice(get_string('activityiscurrentlyhidden')); + } else { + print_header($pagetitle, "$course->fullname", + "$navigation framename}\" href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."", + '', '', true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm)); + + if (isteacher($course->id)) { + + //Phan thiet lap he so diem + $examNumber = get_record_select('scorm_scoes', 'scorm ='.($scorm->id).' and minnormalizedmeasure > -1','count(id) as examCount'); + //fwrite($ft,"\n So bai kiem tra la ".($examNumber->examCount)); + if ($examNumber->examCount > 0){ + echo "'; + } + + //----------------------- + $trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c'); + if ($trackedusers->c > 0) { + echo "'; + } else { + echo ''; + } + } + + $USER->setAttempt = 'notset'; + // Print the main part of the page + print_heading(format_string($scorm->name)); + print_simple_box(format_text($scorm->summary), 'center', '70%', '', 5, 'generalbox', 'intro'); + scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm); + print_footer($course); + } +?> diff --git a/mod/survey/graph.php b/mod/survey/graph.php index 420ec18324..019261873c 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/report.php b/mod/survey/report.php index 84bb9e7c53..36ef533834 100644 --- a/mod/survey/report.php +++ b/mod/survey/report.php @@ -11,7 +11,7 @@ $student = optional_param('student', 0, PARAM_INT); // Student ID $notes = optional_param('notes', '', PARAM_RAW); // Save teachers notes - 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 9830050715..e8a3944fd0 100644 --- a/mod/survey/save.php +++ b/mod/survey/save.php @@ -12,7 +12,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 95592497c2..b9e78c1941 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 = 2006080800; -$module->requires = 2005031000; // Requires this Moodle version +$module->version = 2006080900; +$module->requires = 2006080900; // Requires this Moodle version $module->cron = 0; ?> diff --git a/mod/survey/view.php b/mod/survey/view.php index 2477e00686..0ea2d35007 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 7d22e5578f..de78172d86 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 c3fc664763..9b9ea472e8 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 = 2006080800; // The current module version (Date: YYYYMMDDXX) -$module->requires = 2005031000; // The current module version (Date: YYYYMMDDXX) +$module->version = 2006080900; // The current module version (Date: YYYYMMDDXX) +$module->requires = 2006080900; // 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 fb73310061..2c91799df1 100644 --- a/mod/wiki/view.php +++ b/mod/wiki/view.php @@ -22,7 +22,7 @@ $editsave = optional_param('thankyou', ''); 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 407da1c643..7435c91fb7 100644 --- a/mod/workshop/assessments.php +++ b/mod/workshop/assessments.php @@ -42,7 +42,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 a2d32a0e1e..fa806b9059 100644 --- a/mod/workshop/submissions.php +++ b/mod/workshop/submissions.php @@ -33,7 +33,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/version.php b/mod/workshop/version.php index 7921b82924..1e54d56e09 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 = 2006080800; -$module->requires = 2005031000; // Requires this Moodle version +$module->version = 2006080900; +$module->requires = 2006080900; // Requires this Moodle version $module->cron = 60; ?> diff --git a/mod/workshop/view.php b/mod/workshop/view.php index 9ec708cbc9..a5acc0514d 100644 --- a/mod/workshop/view.php +++ b/mod/workshop/view.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/version.php b/version.php index 4b98b8ce9b..a01bdcabad 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 = 2006080400; // YYYYMMDD = date + $version = 2006080900; // YYYYMMDD = date // XY = increments within a single day $release = '1.7 dev'; // Human-friendly version name