]> git.mjollnir.org Git - moodle.git/commitdiff
new function get_coursemodule_from_id() is now used for obtaining of valid $cm from...
authorskodak <skodak>
Tue, 8 Aug 2006 22:09:55 +0000 (22:09 +0000)
committerskodak <skodak>
Tue, 8 Aug 2006 22:09:55 +0000 (22:09 +0000)
85 files changed:
lib/datalib.php
mod/assignment/lib.php
mod/assignment/submissions.php
mod/assignment/type/online/file.php
mod/assignment/upload.php
mod/assignment/version.php
mod/assignment/view.php
mod/chat/report.php
mod/chat/version.php
mod/chat/view.php
mod/choice/report.php
mod/choice/version.php
mod/choice/view.php
mod/data/edit.php
mod/data/import.php
mod/data/version.php
mod/data/view.php
mod/exercise/assessments.php
mod/exercise/submissions.php
mod/exercise/upload.php
mod/exercise/version.php
mod/exercise/view.php
mod/forum/version.php
mod/forum/view.php
mod/glossary/approve.php
mod/glossary/comment.php
mod/glossary/comments.php
mod/glossary/deleteentry.php
mod/glossary/edit.php
mod/glossary/editcategories.php
mod/glossary/export.php
mod/glossary/exportentry.php
mod/glossary/exportfile.php
mod/glossary/import.php
mod/glossary/print.php
mod/glossary/version.php
mod/glossary/view.php
mod/hotpot/README.TXT
mod/hotpot/report.php
mod/hotpot/review.php
mod/hotpot/version.php
mod/hotpot/view.php
mod/journal/edit.php
mod/journal/report.php
mod/journal/version.php
mod/journal/view.php
mod/label/version.php
mod/label/view.php
mod/lams/version.php
mod/lams/view.php
mod/lesson/import.php
mod/lesson/importppt.php
mod/lesson/lesson.php
mod/lesson/mediafile.php
mod/lesson/report.php
mod/lesson/version.php
mod/lesson/view.php
mod/quiz/attempt.php
mod/quiz/report.php
mod/quiz/version.php
mod/quiz/view.php
mod/resource/fetch.php
mod/resource/lib.php
mod/resource/type/ims/deploy.php
mod/resource/version.php
mod/resource/view.php
mod/scorm/api.php
mod/scorm/loadSCO.php
mod/scorm/player.php
mod/scorm/report.php
mod/scorm/version.php
mod/scorm/view.php
mod/survey/graph.php
mod/survey/report.php
mod/survey/save.php
mod/survey/version.php
mod/survey/view.php
mod/wiki/admin.php
mod/wiki/version.php
mod/wiki/view.php
mod/workshop/assessments.php
mod/workshop/submissions.php
mod/workshop/version.php
mod/workshop/view.php
version.php

index 18a3118e66d617635ac0de1dd7bbc5d1cb7017e8..4f7a1c66df9c428f4138d3b4d7fb9603c5b6268f 100644 (file)
@@ -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
index 45981b6d0d55691ef85456fe5f2a3411d3a1940a..b8bd546502146ee5f7e3931f445083173e14ddad 100644 (file)
@@ -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');
             }
 
index 6b5693d98bdd7ac790f9349b92234473f5ed559a..1256b29945fabda88acf701b43fd17ab934a1728 100644 (file)
@@ -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");
         }
 
index af67bcf5e27b7cb2b9e4416393067e4df38ae309..cc106618aae80055e20f25c325f7e0f9cf51880c 100644 (file)
@@ -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");
     }
 
index cfb862753b13ed96a574c64bf2bd2b865a289b2e..e866cdff02381e0783fa55a14179bfad24fb0c28 100644 (file)
@@ -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");
         }
 
index 5966ec53c65938f5d9f9e9f890d1114a703ea27c..85ee874603e79f4727f1195aa4bccff2073b1c23 100644 (file)
@@ -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;
 
 ?>
index a773b77353309c50650c91818f66023e6ff30fb4..d38dcb8e34c70b02eb01579fa6b6dc42a0103360 100644 (file)
@@ -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");
         }
 
index 4874c5281ed97784833f6d9233023f810f8e1656..5bcf6a6116109ed199b2458327f7304c441e3229 100644 (file)
@@ -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)) {
index fb90b69f2243cc6a1f3402874cc4989b9321611f..5edab92c8dcb935dc55d482cd63aff47f52317be 100644 (file)
@@ -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)?
 
 ?>
index e2b0df89b11a831791d4fe439b2062dc25a6dbac..5a125ed3b7633cdb5072606d4ad16213ef4a2cd6 100644 (file)
@@ -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');
         }
 
index 6f09637c44ffeddce6a572370e988358cb5e4877..c813d58e0eddda4387c11aee93a8bea6e6fa5d49 100644 (file)
@@ -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");
     }
 
index 8acd83c251458f076461de8b7979bf40cb224428..b9e78c19415bf192402c452274eef693c8e534fb 100644 (file)
@@ -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;
 
 ?>
index bcc54fca2582361e42f823c8b64d587d24daf3b8..ff052f7ec3c9e7c06a2254e74b18e319c40e78cb 100644 (file)
@@ -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");
     }
 
index 79a70545f005bd724cc703cc1add4cca1fa28775..a13ddaa562ad7458688e22f62c382b7794886b62 100755 (executable)
@@ -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)) {
index 56fd75acdc3eca122f12073fae567c0d7932cf66..d29911500bbfba37780c8dc28ed34240f3fc5969 100755 (executable)
@@ -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)) {
index 770c3418eb1c12d191a793d7811eab5a207363e9..1e54d56e09ae0d82770352ceaf1f42a1737581a4 100644 (file)
@@ -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;
 
 ?>
index 6714592af97e08775405d5649ca5a98cdb85bded..9621ba24f7709410a283079b1a716a042bdce5a8 100755 (executable)
@@ -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)) {
index 0feab86470360a2ff6c827960e35ef75fe1f4c8b..4ebeab314064391d62f8a5d7c0ebe021f701e3e2 100644 (file)
@@ -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");
     }
 
index 9f2b57b5d872b56844a2a6337efde05901788f82..de637461c2cc9790aeebe3ab27dae04383308cfd 100644 (file)
@@ -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");
     }
 
index e894dbdd83f73faee421ea4930c1b4850990074c..7f2e3d2c3ec5e07997393c144076f9d828e36d91 100644 (file)
@@ -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");
     }
 
index 7921b8292430d619b7ee81e8655748e9a4b8bb4e..1e54d56e09ae0d82770352ceaf1f42a1737581a4 100644 (file)
@@ -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;
 
 ?>
index 32b0032eca4eace1ab9fb5f555a9e52fea9ba3f7..aa7a0afb3d16fbdfe448c82ec102ebdb9771fa71 100644 (file)
@@ -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");
     }
 
index 7921b8292430d619b7ee81e8655748e9a4b8bb4e..1e54d56e09ae0d82770352ceaf1f42a1737581a4 100644 (file)
@@ -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;
 
 ?>
index 94c1942248c648daa22352983731fcd43fe1c91b..123b8b0a607431b4a9c41e8681cf06fb6b615582 100644 (file)
@@ -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)) {
index 426733b687009f85f582c8ac8afabca890c28284..5448d92447b40e4d1e572077de6d4ee7f6f496cf 100644 (file)
@@ -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");
     }
     
index 6c20a0d4954a3e4b64bab4aff4a10bca4232d50d..316143197c5fef3bc3f5552bdab74bfb579b6aa0 100644 (file)
@@ -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');
     }
 
index 8bf1851f5091c248ac857ffeba5f0f9d3a853bc5..38a54638d5d939cb16cac79eea85c8cd3dd80117 100644 (file)
@@ -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");
     }
 
index 9265193e65d85108c47d49155629df9b7d49e355..3d20b8124f199f8932d9397cbb13cee66a0932b6 100644 (file)
@@ -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");
     }
 
index 01f216b1e305fc9a72ef9eec19589fb0b664ea1a..95e6623acc0bb8081b7006d9bc58db9d92085c73 100644 (file)
@@ -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");
 }
 
index 77d106ff6869d97e556c4baa7eebe90d734d2685..83d6dd55b8def278add635d9c74ceb6835a2e980 100644 (file)
@@ -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");
     }
     
index 9649a8d0e67ee34f567a4745b6cbac935269e7a6..712cf758cb1f68eb4d9f74022d37274704a87c65 100644 (file)
@@ -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");
     }
 
index a50dd42d8843de24c1c7e30680141381956d55f5..8619cc684fe503aeba065b722470209449aacb67 100644 (file)
@@ -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 {
index d32b0344eb02fbb103f964f6866399d32a1690f3..e4f163de5b44d3741e11002f6a98b2be0e074a34 100644 (file)
@@ -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");
     }
 
index bb4db2450587a8ed3d37c1ff49f09ad6787df628..0f1c029af53fe6ae79b512648b5a8aa2df481194 100644 (file)
@@ -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");
     }
        
index 0879237d4cbd46aae0d3559735a95c3076808c24..106017e6c47ef3131b3b5cbab015bf69435ab124 100644 (file)
@@ -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");
     }
 
index 0625d60479a43d88a68d3095d5c990ca10b28b0f..b8fed5571d10b5651faf9aa69fb8a3c7acaf621e 100644 (file)
@@ -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)
 
 ?>
index 11376f1d58617f61cba04ced974efcd459c51a74..d013974033de079ecce57f82781cc2542b0ef357 100644 (file)
@@ -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)) {
index 443046b787d48c40730b33b7426537f2719a2604..83b3b16ff40c59010b9e42f194799f781329f46b 100644 (file)
@@ -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
index 58a229a45a73441e6e2d53d7e02927084942200a..b80056187987c95169ae6a655ce0f8dfdb67359c 100644 (file)
@@ -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)) {
index b4fb712016200c06dbdfad9597d242f296b51fc4..8d2b8fcad89ea8a7b1dfd5adb3c2b173ff895812 100644 (file)
@@ -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)) {
index ab4a8735faa9b20ed4bd863b67b134098f21a77c..6a3e843a6cc54e008a15d9b705b4e1acba399176 100644 (file)
@@ -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
index 9d959d11fd633923a0c7c8e45a91d84119836f9a..ab9c01324dd9558e1c4dde97ab7a7751d6aec153 100644 (file)
@@ -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)) {
index 0f3f247f41b2b180171782cafe91cbb72f55f30a..7d2045c17bf47b30ddd228e070ea28886c6bc1af 100644 (file)
@@ -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");
     }
 
index a80e75d837ace01b56517e6bd3704231ffd58b31..b3477af9476a304d806d91894df9ec87f633ee58 100644 (file)
@@ -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");
     }
 
index 7921b8292430d619b7ee81e8655748e9a4b8bb4e..1e54d56e09ae0d82770352ceaf1f42a1737581a4 100644 (file)
@@ -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;
 
 ?>
index 5202c67634e88c757bd35f673cac62ffa2c2413a..43cccf8b7dd8794d8596cc0925c0198c45b16c64 100644 (file)
@@ -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");
     }
 
index c5ea0af38e5b82fc00b31e5439e936f0d1e08668..f2373372f7b7245135559d37f26a8948e5af8423 100644 (file)
@@ -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)
 
 ?>
index 95c6e5dd65ecf79ec134a3cbe33761655767ad41..20575ece2b8d534921bdcca6d37c4a2401abf0d5 100644 (file)
@@ -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");
         }
     
index 8d13175a8c6b35f7b83f9d083ea92e13af1fc49e..92dad72db96ae67bdb80237128e8a8cff3790069 100644 (file)
@@ -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)
 
 ?>
index d47dd54ceb71a59c072175145aee7f5a61248a52..1abfc78697567a413825fd6bbe2fb2932d5ed631 100644 (file)
@@ -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");
 }
 
index 96eb0a3ff73e12c2f06147a9b48934e78097776a..5a22e7443e99279d54d4f2c6eefae775523112eb 100644 (file)
@@ -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");
     }
 
index 6c0f2e2159a2ceffc01e08e3d6102fc35b2e24fa..f13b083a30544108b1ccb6813ef0e567e23d4324 100644 (file)
@@ -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");
     }
 
index dac80ef47af951bf3a3e75616f4d5cd803874d66..c5bd8fae5e7cfd6ca15ddda821b64a8feb4d23c0 100644 (file)
@@ -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");
     }
 
index 484d5e2f6aadd9897f16ea40c71e8669ae5f63cf..a7bcbf28d42214171f2c8df2bc98bbfb4f09378c 100644 (file)
@@ -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 "<center><p>";
         echo '<object classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95"';
         echo '        codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ';
-        echo '        standby="Loading Microsoft® Windows® Media Player components..." ';
+        echo '        standby="Loading Microsoft(R) Windows(R) Media Player components..." ';
         echo '        id="msplayer" align="" type="application/x-oleobject">';
         echo "<param name=\"Filename\" value=\"$fullurl\">";
         echo '<param name="ShowControls" value="true" />';
index 7c8969531fcc042deeb13abcbd8452c612184cf9..845140c062304207a8e9a8b6f4e5e2d4cf163c50 100644 (file)
@@ -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');
     }
 
index 83a330225b4a0e048b09280e08dc01d3f4686053..a03a8c1b37939d2845da4d82af47412814411102 100644 (file)
@@ -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)
 
 ?>
index e826a47c153458ac346f4c0f960ecd520edc472e..5da2ef78996da09d58c29b363923e416e8908f57 100644 (file)
@@ -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');
     }
 
index 6260229fe6cec137ce8ca65e488e91a5f12b42c9..23ece40c210f1b9a2a4e7911458ce781e32c5780 100644 (file)
@@ -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");
         }
 
index 0728f79732a43854377751149a382c7f8eb3e243..80e7d8ac056ffe526208432eb7dbdaf0b0c847f4 100644 (file)
@@ -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");
         }
 
index d3e08f595846c6dfb7d2252e89bf270250d70a86..3791e7b2c798df7eb29befcb04026bb8c8d2cd07 100644 (file)
@@ -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)?
 
 ?>
index 8e99ba1b9198234132eab39fb27f42022e9078b2..2219f4c4af2db582e3141c1dcf2bd2fb3feaa4c1 100644 (file)
@@ -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");
         }
 
index 4cb9f82b20cbe9c7a43966c7431b4cb93efb4056..7c85b14dcfba8e986a40ab1448443b642adbcc04 100644 (file)
@@ -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");
     }
 
index f12727b055bf7bb78d95371058a9c9c8103d72ff..071209f4145bf779cf45aacc3e1ec483d347dcaf 100644 (file)
@@ -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");
         }
 
index d449c13f394185c7ad250a32a80dab46e0e25576..1beb7172cf9720930565508671bcb59edf246ba4 100644 (file)
@@ -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
index 8acd83c251458f076461de8b7979bf40cb224428..b9e78c19415bf192402c452274eef693c8e534fb 100644 (file)
@@ -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;
 
 ?>
index 227cd0f612905f816e82e0816baaecb4c8432362..fb14875315a660f496ac40013ecd1fde929b7a51 100644 (file)
@@ -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');
         }
 
index 4016ec0ae7304a737e017becc897c1550e9a979e..7bad6ae47dac3c16b5c740d9352fd2bc0ed1b29d 100644 (file)
@@ -10,7 +10,7 @@
     $attempt = required_param('attempt', PARAM_INT); // new attempt\r
 \r
     if (!empty($id)) {\r
-        if (! $cm = get_record("course_modules", "id", $id)) {\r
+        if (! $cm = get_coursemodule_from_id('scorm', $id)) {\r
             error("Course Module ID was incorrect");\r
         }\r
         if (! $course = get_record("course", "id", $cm->course)) {\r
index b822f36a66a0c3736c867b807be4c195a58e6b4d..ea33994c99e9aab10e0a462ac3e051b47b245945 100755 (executable)
@@ -7,7 +7,7 @@
     $scoid = required_param('scoid', PARAM_INT); // sco ID\r
 \r
     if (!empty($id)) {\r
-        if (! $cm = get_record("course_modules", "id", $id)) {\r
+        if (! $cm = get_coursemodule_from_id('scorm', $id)) {\r
             error("Course Module ID was incorrect");\r
         }\r
         if (! $course = get_record("course", "id", $cm->course)) {\r
index d92e43dd6887d2699ffee00674adabde69e11756..b295a9e2e6fc6bdcc6be77c15fd5faa91345fa6d 100755 (executable)
-<?PHP  // $Id$\r
-\r
-/// This page prints a particular instance of aicc/scorm package\r
-\r
-    require_once('../../config.php');\r
-    require_once('locallib.php');\r
-    require_once('sequencinglib.php');\r
-    \r
-    //\r
-    // Checkin' script parameters\r
-    //\r
-    $id = optional_param('id', '', PARAM_INT);       // Course Module ID, or\r
-    $a = optional_param('a', '', PARAM_INT);         // scorm ID\r
-    $scoid = required_param('scoid', PARAM_INT);  // sco ID\r
-    $mode = optional_param('mode', 'normal', PARAM_ALPHA); // navigation mode\r
-    $currentorg = optional_param('currentorg', '', PARAM_RAW); // selected organization\r
-    $newattempt = optional_param('newattempt', 'off', PARAM_ALPHA); // the user request to start a new attempt\r
-\r
-    if (!empty($id)) {\r
-        if (! $cm = get_record("course_modules", "id", $id)) {\r
-            error("Course Module ID was incorrect");\r
-        }\r
-        if (! $course = get_record("course", "id", $cm->course)) {\r
-            error("Course is misconfigured");\r
-        }\r
-        if (! $scorm = get_record("scorm", "id", $cm->instance)) {\r
-            error("Course module is incorrect");\r
-        }\r
-    } else if (!empty($a)) {\r
-        if (! $scorm = get_record("scorm", "id", $a)) {\r
-            error("Course module is incorrect");\r
-        }\r
-        if (! $course = get_record("course", "id", $scorm->course)) {\r
-            error("Course is misconfigured");\r
-        }\r
-        if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {\r
-            error("Course Module ID was incorrect");\r
-        }\r
-    } else {\r
-        error('A required parameter is missing');\r
-    }\r
-\r
-    require_login($course->id, false, $cm);\r
-\r
-    //$f = "D:\\test.txt";\r
-    //@$ft = fopen($f,"a");\r
-    //fwrite($ft,"\n ++ Thong tin quyen set attempt ".$USER->setAttempt);\r
-    $strscorms = get_string('modulenameplural', 'scorm');\r
-    $strscorm  = get_string('modulename', 'scorm');\r
-    $strpopup = get_string('popup','scorm');\r
-\r
-    $attempt = scorm_get_last_attempt($scorm->id,$USER->id);    \r
-    \r
-    //Kiem tra xem co phai la tiep tuc khong \r
-    if ($mode=='continue') {\r
-        $scoid = scorm_get_suspendscoid($scorm->id,$USER->id);\r
-        $USER->setAttempt = 'set';\r
-        $mode = 'normal';\r
-    }\r
-    if (($mode == 'normal') && ($USER->setAttempt == 'notset')) {\r
-        $attempt++;\r
-        $USER->setAttempt = 'set';\r
-    }\r
-    //Thuc hien Sequencing\r
-\r
-    if ($mode!='review') {\r
-        $sequencingResult = scorm_sequecingrule_implement($scorm->id,$scoid,$USER->id);\r
-        //echo "<script language='JavaScript'>";\r
-        //    echo "alert('Sequencing');";\r
-        //echo "<script>";\r
-        if (($sequencingResult->rule == 'pre') && ($sequencingResult->action == 'disabled')){\r
-            echo "<script language='JavaScript'>";\r
-            echo "alert('Disabling');";\r
-            echo "</script>";        \r
-        }\r
-        if (($sequencingResult->rule == 'exit') && ($sequencingResult->action == 'exit')){\r
-            $exitscoid = get_sco_after_exit($scoid,$scorm->id);\r
-            //fwrite($ft,"\n ++ Thong tin exit sco la ".$exitscoid);\r
-            $orgstr = '&currentorg='.$currentorg;\r
-            $modepop = '&mode='.$mode;\r
-            $scostr = '&scoid='.$exitscoid;\r
-            echo "<script language='JavaScript'>";\r
-            echo "alert('Exiting');";\r
-            echo "location.href='".$CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr."';";\r
-            echo "</script>";                \r
-        }        \r
-    }    \r
-\r
-    //Thiet lap attempt_status cho scoid\r
-    scorm_set_attempt($scoid,$USER->id);\r
-    //Ket thuc thiet lap attemp_status\r
-    if ($mode!='review') {\r
-        //Update trang thai\r
-        scorm_rollup_updatestatus($scorm->id,$scoid,$USER->id);\r
-        //------------------------------\r
-    }    \r
-    //Thiet lap thong tin lien quan truy xuat Scorm\r
-    $statistic = get_record('scorm_statistic',"scormid",$scorm->id,"userid",$USER->id);\r
-    if (empty($statistic)) {\r
-        $statisticInput->accesstime = time();\r
-        $statisticInput->durationtime = 0;\r
-        $statisticInput->status = 'during';\r
-        $statisticInput->attemptnumber = $attempt;\r
-        $statisticInput->scormid = $scorm->id;\r
-        $statisticInput->userid = $USER->id;\r
-        $statisticid = scorm_insert_statistic($statisticInput);\r
-    } else {\r
-        if ($statistic->status=='suspend') {\r
-            $statisticInput->accesstime = time();\r
-            $statisticInput->durationtime = $statistic->durationtime;\r
-            $statisticInput->status = 'during';\r
-            $statisticInput->attemptnumber = $attempt;\r
-            $statisticInput->scormid = $scorm->id;\r
-            $statisticInput->userid = $USER->id;\r
-        }\r
-    }    \r
-\r
-    //---------------------Ket thuc thiet lap thoi gian ---------------\r
-\r
-    //Lay thoi gian toi da cho phep\r
-    $absoluteTimeLimit = scorm_get_AbsoluteTimeLimit($scoid);\r
-    if ($absoluteTimeLimit > 0) {    \r
-        echo "<script type='text/javascript'>"; \r
-        echo "alert('Bai nay co thoi gian lam la: ".$absoluteTimeLimit."');";\r
-        echo "function remind(msg1) {"; \r
-        echo "var msg = 'Da het gio lam bai ' + msg1 +' Secs.Lua chon bai khac de tiep tuc';";\r
-        echo "alert(msg);"; \r
-        echo "window.location.href = 'view.php?id=".$scorm->id."';";\r
-        echo "}";\r
-        echo "setTimeout('remind(".$absoluteTimeLimit.")',".$absoluteTimeLimit.");";\r
-        echo "</script>";\r
-    }\r
-    //--------------------------------\r
-\r
-    \r
-    if ($course->category != 0) {\r
-        $navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";\r
-        if ($scorms = get_all_instances_in_course('scorm', $course)) {\r
-            // The module SCORM activity with the least id is the course  \r
-            $firstscorm = current($scorms);\r
-            if (!(($course->format == 'scorm') && ($firstscorm->id == $scorm->id))) {\r
-                $navigation .= "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";\r
-            }\r
-        }\r
-    } else {\r
-        $navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";\r
-    }\r
-\r
-    $pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name));\r
-\r
-    if (!$cm->visible and !isteacher($course->id)) {\r
-        print_header($pagetitle, "$course->fullname",\r
-                 "$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",\r
-                 '', '', true, update_module_button($cm->id, $course->id, $strscorm), '', false);\r
-        notice(get_string("activityiscurrentlyhidden"));\r
-    }\r
-\r
-    //\r
-    // TOC processing\r
-    //\r
-    //$attempt = scorm_get_last_attempt($scorm->id, $USER->id);\r
-    //$f = "D:\\test.txt";\r
-    //@$ft = fopen($f,"a");\r
-    ////fwrite($ft,"\n ++ ++ + ++ Gia tri $attempt lay duoc la ".$attempt);\r
-\r
-    //if ($mode=='normal'){\r
-    //    $newattempt = 'on';\r
-    //}\r
-    if (($newattempt=='on') && (($attempt < $scorm->maxattempt) || ($scorm->maxattempt == 0))) {\r
-        $attempt++;\r
-        //$f = "D:\\test.txt";\r
-        //@$ft = fopen($f,"a");\r
-        //fwrite($ft,"\n ----New attempt------- ".$attempt);\r
-\r
-    }\r
-    $attemptstr = '&amp;attempt=' . $attempt;\r
-\r
-    //fwrite($ft,"\n ----Gia tri attempt bay gio la------- ".$attempt);\r
-    $result = scorm_get_toc($USER,$scorm,'structurelist',$currentorg,$scoid,$mode,$attempt,true);\r
-    $sco = $result->sco;\r
-\r
-    if (($mode == 'browse') && ($scorm->hidebrowse == 1)) {\r
-       $mode = 'normal';\r
-    }\r
-    if ($mode != 'browse') {\r
-        ////fwrite($ft,"\n ++ ++ + ++ Gia tri $mode khac browser ".$mode);\r
-        if ($trackdata = scorm_get_tracks($sco->id,$USER->id,$attempt)) {\r
-            if (($trackdata->status == 'completed') || ($trackdata->status == 'passed') || ($trackdata->status == 'failed')) {\r
-                $mode = 'review';\r
-                ////fwrite($ft,"\n ++ ++ + ++ Gia tri $mode ".$mode);\r
-            } else {\r
-                $mode = 'normal';\r
-                ////fwrite($ft,"\n ++ ++ + ++ Gia tri $mode ".$mode);\r
-            }\r
-        }\r
-    }\r
-\r
-    add_to_log($course->id, 'scorm', 'view', "player.php?id=$cm->id&scoid=$sco->id", "$scorm->id");\r
-\r
-    $scoidstr = '&amp;scoid='.$sco->id;\r
-    $scoidpop = '&scoid='.$sco->id;\r
-    $modestr = '&amp;mode='.$mode;\r
-    if ($mode == 'browse') {\r
-        $modepop = '&mode='.$mode;\r
-    } else {\r
-        $modepop = '';\r
-    }\r
-    $orgstr = '&currentorg='.$currentorg;\r
-\r
-    $SESSION->scorm_scoid = $sco->id;\r
-    $SESSION->scorm_status = 'Not Initialized';\r
-    $SESSION->scorm_mode = $mode;\r
-    $SESSION->attempt = $attempt;\r
-\r
-    //    Doan code them\r
-    ////fwrite($ft,"\n ++ ++ + ++ Gia tri attempt duoc gan cho user la ".$attempt);\r
-    $USER->attempt = $attempt;\r
-    //------------Ket thuc doan them\r
-\r
-    //\r
-    // Print the page header\r
-    //\r
-    $bodyscript = '';\r
-    if ($scorm->popup == 1) {\r
-        $bodyscript = 'onunload="main.close();"';\r
-    }\r
-\r
-    // Kiem tra xem co duoc exit khong\r
-    if (scorm_isChoiceexit($sco->scorm,$sco->id)) {\r
-        $exitlink = '(<a href="'.$CFG->wwwroot.'/course/view.php?id='.$cm->course.'">'.get_string('exit','scorm').'</a>)&nbsp;';\r
-    } else {\r
-        $exitlink = get_string('exitisnotallowed','scorm');\r
-    }\r
-\r
-    //Luu giu khoa hoc thoat ra\r
-    $suspend = '(<a href="suspend.php?scorm='.$sco->scorm.'&sco='.$sco->id.'&userid='.$USER->id.'&id='.$cm->course.'">'.get_string('suspend','scorm').'</a>)&nbsp;';\r
-\r
-    print_header($pagetitle, "$course->fullname",\r
-                 "$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",\r
-                 '', '', true, $exitlink.$suspend.update_module_button($cm->id, $course->id, $strscorm), '', false, $bodyscript);\r
-    if ($sco->scormtype == 'sco') {\r
-?>\r
-    <script language="JavaScript" type="text/javascript" src="request.js"></script>\r
-    <script language="JavaScript" type="text/javascript" src="api.php?id=<?php echo $cm->id.$scoidstr.$modestr.$attemptstr ?>"></script>\r
-<?php\r
-    }\r
-    if (($sco->previd != 0) && ($sco->previous == 0)) {\r
-        $scostr = '&scoid='.$sco->previd;\r
-        echo '    <script language="javascript">var prev="'.$CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr."\";</script>\n";\r
-    } else {\r
-        echo '    <script language="javascript">var prev="'.$CFG->wwwroot.'/mod/scorm/view.php?id='.$cm->id."\";</script>\n";\r
-    }\r
-    if (($sco->nextid != 0) && ($sco->next == 0)) {\r
-        $scostr = '&scoid='.$sco->nextid;\r
-        echo '    <script language="javascript">var next="'.$CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr."\";</script>\n";\r
-    } else {\r
-        echo '    <script language="javascript">var next="'.$CFG->wwwroot.'/mod/scorm/view.php?id='.$cm->id."\";</script>\n";\r
-    }\r
-?>\r
-    <div id="scormpage">\r
-<?php  \r
-    if ($scorm->hidetoc == 0) {\r
-?>\r
-        <div id="tocbox" class="generalbox">\r
-            <div id="tochead" class="header"><?php print_string('coursestruct','scorm') ?></div>\r
-            <div id="toctree">\r
-            <?php echo $result->toc; ?>\r
-            </div>\r
-        </div>\r
-<?php\r
-        $class = ' class="toc"';\r
-    } else {\r
-        $class = ' class="no-toc"';\r
-    }\r
-?>\r
-        <div id="scormbox"<?php echo $class ?>>\r
-<?php\r
-    // This very big test check if is necessary the "scormtop" div\r
-    if (\r
-           ($mode != 'normal') ||  // We are not in normal mode so review or browse text will displayed\r
-           (\r
-               ($scorm->hidenav == 0) &&  // Teacher want to display navigation links\r
-               (\r
-                   (\r
-                       ($sco->previd != 0) &&  // This is not the first learning object of the package\r
-                       ($sco->previous == 0)   // Moodle must manage the previous link\r
-                   ) || \r
-                   (\r
-                       ($sco->nextid != 0) &&  // This is not the last learning object of the package\r
-                       ($sco->next == 0)       // Moodle must manage the next link\r
-                   ) \r
-               )\r
-           ) || ($scorm->hidetoc == 2)      // Teacher want to display toc in a small dropdown menu \r
-       ) {\r
-?>\r
-            <div id="scormtop">\r
-        <?php echo $mode == 'browse' ? '<div id="scormmode" class="left">'.get_string('browsemode','scorm')."</div>\n" : ''; ?>\r
-        <?php echo $mode == 'review' ? '<div id="scormmode" class="left">'.get_string('reviewmode','scorm')."</div>\n" : ''; ?>\r
-<?php\r
-        if (($scorm->hidenav == 0) || ($scorm->hidetoc == 2)) {\r
-?>\r
-                <div id="scormnav" class="right">\r
-        <?php\r
-            $orgstr = '&amp;currentorg='.$currentorg;\r
-            if (($scorm->hidenav == 0) && ($sco->previd != 0) && ($sco->previous == 0)) {\r
-                /// Print the prev LO link\r
-                $scostr = '&amp;scoid='.$sco->previd;\r
-                $url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr;\r
-                echo '<a href="'.$url.'">&lt; '.get_string('prev','scorm').'</a>';\r
-            }\r
-            if ($scorm->hidetoc == 2) {\r
-                echo $result->tocmenu;\r
-            }\r
-            if (($scorm->hidenav == 0) && ($sco->nextid != 0) && ($sco->next == 0)) {\r
-                /// Print the next LO link\r
-                $scostr = '&amp;scoid='.$sco->nextid;\r
-                $url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr;\r
-                echo '            &nbsp;<a href="'.$url.'">'.get_string('next','scorm').' &gt;</a>';\r
-            }\r
-        ?>\r
-\r
-                </div>\r
-<?php\r
-        } \r
-?>\r
-            </div>\r
-<?php\r
-    } // The end of the very big test\r
-?>\r
-            <div id="scormobject" class="right">\r
-                <noscript>\r
-                    <div id="noscript">\r
-                        <?php print_string('noscriptnoscorm','scorm'); // No Martin(i), No Party ;-) ?>\r
-\r
-                    </div>\r
-                </noscript>\r
-<?php\r
-    if ($result->prerequisites) {\r
-        if ($scorm->popup == 0) {\r
-            if (strpos('MSIE',$_SERVER['HTTP_USER_AGENT']) === false) { \r
-                /// Internet Explorer does not has full support to objects\r
-?>\r
-                <iframe id="main" \r
-                        class="scoframe"\r
-                        width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>" \r
-                        height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>" \r
-                        src="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>">\r
-                </iframe>\r
-<?php\r
-            } else {\r
-?>\r
-                <object id="main" \r
-                        class="scoframe" \r
-                        width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>" \r
-                        height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>" \r
-                        data="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>"\r
-                        type="text/html">\r
-                     <?php print_string('noobjectsupport', 'scorm'); ?>\r
-                </object>\r
-<?php\r
-            }\r
-        } else {\r
-?>\r
-                    <script lanuguage="javascript">\r
-                        function openpopup(url,name,options,width,height) {\r
-                            fullurl = "<?php echo $CFG->wwwroot.'/mod/scorm/' ?>" + url;\r
-                            windowobj = window.open(fullurl,name,options);\r
-                            if ((width==100) && (height==100)) {\r
-                                // Fullscreen\r
-                                windowobj.moveTo(0,0);\r
-                            } \r
-                            if (width<=100) {\r
-                                width = Math.round(screen.availWidth * width / 100);\r
-                            }\r
-                            if (height<=100) {\r
-                                height = Math.round(screen.availHeight * height / 100);\r
-                            }\r
-                            windowobj.resizeTo(width,height);\r
-                            windowobj.focus();\r
-                            return windowobj;\r
-                        }\r
-\r
-                        url = "loadSCO.php?id=<?php echo $cm->id.$scoidpop ?>";\r
-                        width = <?php p($scorm->width) ?>;\r
-                        height = <?php p($scorm->height) ?>;\r
-                        var main = openpopup(url, "<?php p($scorm->name) ?>", "<?php p($scorm->options) ?>", width, height);\r
-                    </script>\r
-                    <noscript>\r
-<?php\r
-            if (strpos('MSIE',$_SERVER['HTTP_USER_AGENT']) === false) { \r
-                /// Internet Explorer does not has full support to objects\r
-?>\r
-                    <iframe id="main"\r
-                            class="scoframe"\r
-                            width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>" \r
-                            height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>" \r
-                            src="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>">\r
-                    </iframe>\r
-<?php\r
-            } else {\r
-?>\r
-                    <object id="main" \r
-                            class="scoframe" \r
-                            width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>" \r
-                            height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>" \r
-                            data="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>"\r
-                            type="text/html">\r
-                         <?php print_string('noobjectsupport', 'scorm'); ?>\r
-                    </object>\r
-<?php\r
-            }\r
-?>\r
-                    </noscript>\r
-<?php            \r
-        }\r
-    } else {\r
-        print_simple_box(get_string('noprerequisites','scorm'),'center');\r
-    }\r
-?>\r
-            </div> <!-- SCORM object -->\r
-        </div> <!-- SCORM box  -->\r
-    </div> <!-- SCORM content -->\r
-    </div> <!-- Content -->\r
-    </div> <!-- Page -->\r
-\r
-</body>\r
-</html>\r
-\r
+<?PHP  // $Id$
+
+/// This page prints a particular instance of aicc/scorm package
+
+    require_once('../../config.php');
+    require_once('locallib.php');
+    require_once('sequencinglib.php');
+    
+    //
+    // Checkin' script parameters
+    //
+    $id = optional_param('id', '', PARAM_INT);       // Course Module ID, or
+    $a = optional_param('a', '', PARAM_INT);         // scorm ID
+    $scoid = required_param('scoid', PARAM_INT);  // sco ID
+    $mode = optional_param('mode', 'normal', PARAM_ALPHA); // navigation mode
+    $currentorg = optional_param('currentorg', '', PARAM_RAW); // selected organization
+    $newattempt = optional_param('newattempt', 'off', PARAM_ALPHA); // the user request to start a new attempt
+
+    if (!empty($id)) {
+        if (! $cm = get_coursemodule_from_id('scorm', $id)) {
+            error("Course Module ID was incorrect");
+        }
+        if (! $course = get_record("course", "id", $cm->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 "<script language='JavaScript'>";
+        //    echo "alert('Sequencing');";
+        //echo "<script>";
+        if (($sequencingResult->rule == 'pre') && ($sequencingResult->action == 'disabled')){
+            echo "<script language='JavaScript'>";
+            echo "alert('Disabling');";
+            echo "</script>";        
+        }
+        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 = '&currentorg='.$currentorg;
+            $modepop = '&mode='.$mode;
+            $scostr = '&scoid='.$exitscoid;
+            echo "<script language='JavaScript'>";
+            echo "alert('Exiting');";
+            echo "location.href='".$CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr."';";
+            echo "</script>";                
+        }        
+    }    
+
+    //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 "<script type='text/javascript'>"; 
+        echo "alert('Bai nay co thoi gian lam la: ".$absoluteTimeLimit."');";
+        echo "function remind(msg1) {"; 
+        echo "var msg = 'Da het gio lam bai ' + msg1 +' Secs.Lua chon bai khac de tiep tuc';";
+        echo "alert(msg);"; 
+        echo "window.location.href = 'view.php?id=".$scorm->id."';";
+        echo "}";
+        echo "setTimeout('remind(".$absoluteTimeLimit.")',".$absoluteTimeLimit.");";
+        echo "</script>";
+    }
+    //--------------------------------
+
+    
+    if ($course->category != 0) {
+        $navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
+        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 .= "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
+            }
+        }
+    } else {
+        $navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
+    }
+
+    $pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name));
+
+    if (!$cm->visible and !isteacher($course->id)) {
+        print_header($pagetitle, "$course->fullname",
+                 "$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
+                 '', '', 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 = '&amp;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 = '&amp;scoid='.$sco->id;
+    $scoidpop = '&scoid='.$sco->id;
+    $modestr = '&amp;mode='.$mode;
+    if ($mode == 'browse') {
+        $modepop = '&mode='.$mode;
+    } else {
+        $modepop = '';
+    }
+    $orgstr = '&currentorg='.$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 = '(<a href="'.$CFG->wwwroot.'/course/view.php?id='.$cm->course.'">'.get_string('exit','scorm').'</a>)&nbsp;';
+    } else {
+        $exitlink = get_string('exitisnotallowed','scorm');
+    }
+
+    //Luu giu khoa hoc thoat ra
+    $suspend = '(<a href="suspend.php?scorm='.$sco->scorm.'&sco='.$sco->id.'&userid='.$USER->id.'&id='.$cm->course.'">'.get_string('suspend','scorm').'</a>)&nbsp;';
+
+    print_header($pagetitle, "$course->fullname",
+                 "$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
+                 '', '', true, $exitlink.$suspend.update_module_button($cm->id, $course->id, $strscorm), '', false, $bodyscript);
+    if ($sco->scormtype == 'sco') {
+?>
+    <script language="JavaScript" type="text/javascript" src="request.js"></script>
+    <script language="JavaScript" type="text/javascript" src="api.php?id=<?php echo $cm->id.$scoidstr.$modestr.$attemptstr ?>"></script>
+<?php
+    }
+    if (($sco->previd != 0) && ($sco->previous == 0)) {
+        $scostr = '&scoid='.$sco->previd;
+        echo '    <script language="javascript">var prev="'.$CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr."\";</script>\n";
+    } else {
+        echo '    <script language="javascript">var prev="'.$CFG->wwwroot.'/mod/scorm/view.php?id='.$cm->id."\";</script>\n";
+    }
+    if (($sco->nextid != 0) && ($sco->next == 0)) {
+        $scostr = '&scoid='.$sco->nextid;
+        echo '    <script language="javascript">var next="'.$CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr."\";</script>\n";
+    } else {
+        echo '    <script language="javascript">var next="'.$CFG->wwwroot.'/mod/scorm/view.php?id='.$cm->id."\";</script>\n";
+    }
+?>
+    <div id="scormpage">
+<?php  
+    if ($scorm->hidetoc == 0) {
+?>
+        <div id="tocbox" class="generalbox">
+            <div id="tochead" class="header"><?php print_string('coursestruct','scorm') ?></div>
+            <div id="toctree">
+            <?php echo $result->toc; ?>
+            </div>
+        </div>
+<?php
+        $class = ' class="toc"';
+    } else {
+        $class = ' class="no-toc"';
+    }
+?>
+        <div id="scormbox"<?php echo $class ?>>
+<?php
+    // This very big test check if is necessary the "scormtop" div
+    if (
+           ($mode != 'normal') ||  // We are not in normal mode so review or browse text will displayed
+           (
+               ($scorm->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 
+       ) {
+?>
+            <div id="scormtop">
+        <?php echo $mode == 'browse' ? '<div id="scormmode" class="left">'.get_string('browsemode','scorm')."</div>\n" : ''; ?>
+        <?php echo $mode == 'review' ? '<div id="scormmode" class="left">'.get_string('reviewmode','scorm')."</div>\n" : ''; ?>
+<?php
+        if (($scorm->hidenav == 0) || ($scorm->hidetoc == 2)) {
+?>
+                <div id="scormnav" class="right">
+        <?php
+            $orgstr = '&amp;currentorg='.$currentorg;
+            if (($scorm->hidenav == 0) && ($sco->previd != 0) && ($sco->previous == 0)) {
+                /// Print the prev LO link
+                $scostr = '&amp;scoid='.$sco->previd;
+                $url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr;
+                echo '<a href="'.$url.'">&lt; '.get_string('prev','scorm').'</a>';
+            }
+            if ($scorm->hidetoc == 2) {
+                echo $result->tocmenu;
+            }
+            if (($scorm->hidenav == 0) && ($sco->nextid != 0) && ($sco->next == 0)) {
+                /// Print the next LO link
+                $scostr = '&amp;scoid='.$sco->nextid;
+                $url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr;
+                echo '            &nbsp;<a href="'.$url.'">'.get_string('next','scorm').' &gt;</a>';
+            }
+        ?>
+
+                </div>
+<?php
+        } 
+?>
+            </div>
+<?php
+    } // The end of the very big test
+?>
+            <div id="scormobject" class="right">
+                <noscript>
+                    <div id="noscript">
+                        <?php print_string('noscriptnoscorm','scorm'); // No Martin(i), No Party ;-) ?>
+
+                    </div>
+                </noscript>
+<?php
+    if ($result->prerequisites) {
+        if ($scorm->popup == 0) {
+            if (strpos('MSIE',$_SERVER['HTTP_USER_AGENT']) === false) { 
+                /// Internet Explorer does not has full support to objects
+?>
+                <iframe id="main" 
+                        class="scoframe"
+                        width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>" 
+                        height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>" 
+                        src="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>">
+                </iframe>
+<?php
+            } else {
+?>
+                <object id="main" 
+                        class="scoframe" 
+                        width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>" 
+                        height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>" 
+                        data="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>"
+                        type="text/html">
+                     <?php print_string('noobjectsupport', 'scorm'); ?>
+                </object>
+<?php
+            }
+        } else {
+?>
+                    <script lanuguage="javascript">
+                        function openpopup(url,name,options,width,height) {
+                            fullurl = "<?php echo $CFG->wwwroot.'/mod/scorm/' ?>" + url;
+                            windowobj = window.open(fullurl,name,options);
+                            if ((width==100) && (height==100)) {
+                                // Fullscreen
+                                windowobj.moveTo(0,0);
+                            } 
+                            if (width<=100) {
+                                width = Math.round(screen.availWidth * width / 100);
+                            }
+                            if (height<=100) {
+                                height = Math.round(screen.availHeight * height / 100);
+                            }
+                            windowobj.resizeTo(width,height);
+                            windowobj.focus();
+                            return windowobj;
+                        }
+
+                        url = "loadSCO.php?id=<?php echo $cm->id.$scoidpop ?>";
+                        width = <?php p($scorm->width) ?>;
+                        height = <?php p($scorm->height) ?>;
+                        var main = openpopup(url, "<?php p($scorm->name) ?>", "<?php p($scorm->options) ?>", width, height);
+                    </script>
+                    <noscript>
+<?php
+            if (strpos('MSIE',$_SERVER['HTTP_USER_AGENT']) === false) { 
+                /// Internet Explorer does not has full support to objects
+?>
+                    <iframe id="main"
+                            class="scoframe"
+                            width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>" 
+                            height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>" 
+                            src="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>">
+                    </iframe>
+<?php
+            } else {
+?>
+                    <object id="main" 
+                            class="scoframe" 
+                            width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>" 
+                            height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>" 
+                            data="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>"
+                            type="text/html">
+                         <?php print_string('noobjectsupport', 'scorm'); ?>
+                    </object>
+<?php
+            }
+?>
+                    </noscript>
+<?php            
+        }
+    } else {
+        print_simple_box(get_string('noprerequisites','scorm'),'center');
+    }
+?>
+            </div> <!-- SCORM object -->
+        </div> <!-- SCORM box  -->
+    </div> <!-- SCORM content -->
+    </div> <!-- Content -->
+    </div> <!-- Page -->
+
+</body>
+</html>
+
index 43ca58300114feed39e028eb68db8570b9a886ca..1935a3bba926dff5b422cd47f3299313e75b910e 100755 (executable)
-<?php  // $Id$\r
-\r
-// This script uses installed report plugins to print quiz reports\r
-\r
-    require_once("../../config.php");\r
-    require_once('locallib.php');\r
-       \r
-    $id = optional_param('id', '', PARAM_INT);    // Course Module ID, or\r
-    $a = optional_param('a', '', PARAM_INT);     // SCORM ID\r
-    $b = optional_param('b', '', PARAM_INT);     // SCO ID\r
-    $user = optional_param('user', '', PARAM_INT);  // User ID\r
-\r
-    if (!empty($id)) {\r
-        if (! $cm = get_record("course_modules", "id", $id)) {\r
-            error("Course Module ID was incorrect");\r
-        }\r
-        if (! $course = get_record("course", "id", $cm->course)) {\r
-            error("Course is misconfigured");\r
-        }\r
-        if (! $scorm = get_record("scorm", "id", $cm->instance)) {\r
-            error("Course module is incorrect");\r
-        }\r
-    } else {\r
-        if (!empty($b)) {\r
-            if (! $sco = get_record("scorm_scoes", "id", $b)) {\r
-                error("Scorm activity is incorrect");\r
-            }\r
-            $a = $sco->scorm;\r
-        }\r
-        if (!empty($a)) {\r
-            if (! $scorm = get_record("scorm", "id", $a)) {\r
-                error("Course module is incorrect");\r
-            }\r
-            if (! $course = get_record("course", "id", $scorm->course)) {\r
-                error("Course is misconfigured");\r
-            }\r
-            if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {\r
-                error("Course Module ID was incorrect");\r
-            }\r
-        }\r
-    }\r
-\r
-    require_login($course->id, false, $cm);\r
-\r
-    if (!isteacher($course->id)) {\r
-        error("You are not allowed to use this script");\r
-    }\r
-\r
-    add_to_log($course->id, "scorm", "report", "report.php?id=$cm->id", "$scorm->id");\r
-\r
-/// Print the page header\r
-    if (empty($noheader)) {\r
-        if ($course->category) {\r
-            $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";\r
-        } else {\r
-            $navigation = '';\r
-        }\r
-\r
-        $strscorms = get_string("modulenameplural", "scorm");\r
-        $strscorm  = get_string("modulename", "scorm");\r
-        $strreport  = get_string("report", "scorm");\r
-        $strname  = get_string('name');\r
-        if (empty($b)) {\r
-            print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",\r
-                     "$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>\r
-                      -> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a> -> $strreport",\r
-                     "", "", true);\r
-        } else {\r
-            print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",\r
-                     "$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>\r
-                      -> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>\r
-              -> <a href=\"report.php?id=$cm->id\">$strreport</a> -> $sco->title",\r
-                     "", "", true);\r
-        }\r
-        print_heading(format_string($scorm->name));\r
-    }\r
-\r
-    $scormpixdir = $CFG->modpixpath.'/scorm/pix';\r
-\r
-    if (empty($b) ) {\r
-        if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' ORDER BY id")) {\r
-            if ($scousers=get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid")) {\r
-                $table = new stdClass();\r
-                $table->head = array('&nbsp;', $strname);\r
-                $table->align = array('center', 'left');\r
-                $table->wrap = array('nowrap', 'nowrap');\r
-                $table->width = '100%';\r
-                $table->size = array(10, '*');\r
-                foreach ($scoes as $sco) {\r
-                    if ($sco->launch!='') {\r
-                        $table->head[]=scorm_string_wrap($sco->title);\r
-                        //$table->head[]=$sco->title;\r
-                        $table->align[] = 'center';\r
-                        $table->wrap[] = 'nowrap';\r
-                        $table->size[] = '*';\r
-                    }\r
-                }\r
-\r
-                foreach ($scousers as $scouser) {\r
-                    if ($userdata = scorm_get_user_data($scouser->userid)) {\r
-                        $row = array();\r
-                        $row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true);\r
-                        $row[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">".\r
-                                 "$userdata->firstname $userdata->lastname</a>";\r
-                        foreach ($scoes as $sco) {\r
-                            if ($sco->launch!='') {\r
-                                $anchorstart = '';\r
-                                $anchorend = '';\r
-                                $scoreview = '';\r
-                                if ($trackdata = scorm_get_tracks($sco->id,$scouser->userid)) {\r
-                                    if ($trackdata->score_raw != '') {\r
-                                        $scoreview = '<br />'.get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;\r
-                                    }\r
-                                    if ($trackdata->status == '') {\r
-                                        $trackdata->status = 'notattempted';\r
-                                    } else {\r
-                                        $anchorstart = '<a href="report.php?b='.$sco->id.'&user='.$scouser->userid.'" title="'.\r
-                                                       get_string('details','scorm').'">';\r
-                                        $anchorend = '</a>';\r
-                                    }\r
-                                } else {\r
-                                    $trackdata->status = 'notattempted';\r
-                                    $trackdata->total_time = '';\r
-                                }\r
-                                $strstatus = get_string($trackdata->status,'scorm');\r
-                                $row[] = $anchorstart.'<img src="'.$scormpixdir.'/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.\r
-                                         $strstatus.'">&nbsp;'.$trackdata->total_time.$scoreview.$anchorend;\r
-                            }\r
-                        }\r
-                        $table->data[] = $row;\r
-                    }\r
-                }\r
-                print_table($table);\r
-            } else {\r
-                notice('No users to report');\r
-            }\r
-        }\r
-    } else {\r
-        if (!empty($user)) {\r
-            if ($userdata = scorm_get_user_data($user)) {\r
-                print_simple_box_start('center');\r
-                print_heading(format_string($sco->title));\r
-                echo '<div align="center">'."\n";\r
-                print_user_picture($user, $course->id, $userdata->picture, false, false);\r
-                echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user&course=$course->id\">".\r
-                     "$userdata->firstname $userdata->lastname</a><br />";\r
-                $scoreview = '';\r
-                if ($trackdata = scorm_get_tracks($sco->id,$user)) {\r
-                    if ($trackdata->score_raw != '') {\r
-                        $scoreview = get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;\r
-                    }\r
-                    if ($trackdata->status == '') {\r
-                        $trackdata->status = 'notattempted';\r
-                    }\r
-                } else {\r
-                    $trackdata->status = 'notattempted';\r
-                    $trackdata->total_time = '';\r
-                }\r
-                $strstatus = get_string($trackdata->status,'scorm');\r
-                echo '<img src="'.$scormpixdir.'/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.\r
-                $strstatus.'">&nbsp;'.$trackdata->total_time.'<br />'.$scoreview.'<br />';\r
-                echo '</div>'."\n";\r
-                echo '<hr /><h2>'.get_string('details','scorm').'</h2>';\r
-                \r
-                // Print general score data\r
-                $table = new stdClass();\r
-                $table->head = array(get_string('element','scorm'), get_string('value','scorm'));\r
-                $table->align = array('left', 'left');\r
-                $table->wrap = array('nowrap', 'nowrap');\r
-                $table->width = '100%';\r
-                $table->size = array('*', '*');\r
-                \r
-                $existelements = false;\r
-                if ($scorm->version == 'SCORM_1.3') {\r
-                    $elements = array('raw' => 'cmi.score.raw',\r
-                                      'min' => 'cmi.score.min',\r
-                                      'max' => 'cmi.score.max',\r
-                                      'status' => 'cmi.completition_status',\r
-                                      'time' => 'cmi.total_time');\r
-                } else {\r
-                    $elements = array('raw' => 'cmi.core.score.raw',\r
-                                      'min' => 'cmi.core.score.min',\r
-                                      'max' => 'cmi.core.score.max',\r
-                                      'status' => 'cmi.core.lesson_status',\r
-                                      'time' => 'cmi.core.total_time');\r
-                }\r
-                foreach ($elements as $key => $element) {\r
-                    if (isset($trackdata->$element)) {\r
-                        $existelements = true;\r
-                        $printedelements[]=$element;\r
-                        $row = array();\r
-                        $row[] = get_string($key,'scorm');\r
-                        $row[] = $trackdata->$element;\r
-                        $table->data[] = $row;\r
-                    }\r
-                }\r
-                if ($existelements) {\r
-                    echo '<h3>'.get_string('general','scorm').'</h3>';\r
-                    print_table($table);\r
-                }                \r
-                \r
-                // Print Interactions data\r
-                $table = new stdClass();\r
-                $table->head = array(get_string('identifier','scorm'),\r
-                                     get_string('type','scorm'),\r
-                                     get_string('result','scorm'),\r
-                                     get_string('student_response','scorm'));\r
-                $table->align = array('center', 'center', 'center', 'center');\r
-                $table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap');\r
-                $table->width = '100%';\r
-                $table->size = array('*', '*', '*', '*', '*');\r
-                \r
-                $existinteraction = false;\r
-                \r
-                $i = 0;\r
-                $interactionid = 'cmi.interactions.'.$i.'.id';\r
-                \r
-                while (isset($trackdata->$interactionid)) {\r
-                    $existinteraction = true;\r
-                    $printedelements[]=$interactionid;\r
-                    $elements = array($interactionid,\r
-                                      'cmi.interactions.'.$i.'.type',\r
-                                      'cmi.interactions.'.$i.'.result',\r
-                                      'cmi.interactions.'.$i.'.student_response');\r
-                    $row = array();\r
-                    foreach ($elements as $element) {\r
-                        if (isset($trackdata->$element)) {\r
-                            $row[] = $trackdata->$element;\r
-                            $printedelements[]=$element;\r
-                        } else {\r
-                            $row[] = '&nbsp;';\r
-                        }\r
-                    }\r
-                    $table->data[] = $row;\r
-                    \r
-                    $i++;\r
-                    $interactionid = 'cmi.interactions.'.$i.'.id';\r
-                }\r
-                if ($existinteraction) {\r
-                    echo '<h3>'.get_string('interactions','scorm').'</h3>';\r
-                    print_table($table);\r
-                }\r
-                \r
-                // Print Objectives data\r
-                $table = new stdClass();\r
-                $table->head = array(get_string('identifier','scorm'),\r
-                                     get_string('status','scorm'),\r
-                                     get_string('raw','scorm'),\r
-                                     get_string('min','scorm'),\r
-                                     get_string('max','scorm'));\r
-                $table->align = array('center', 'center', 'center', 'center', 'center');\r
-                $table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap');\r
-                $table->width = '100%';\r
-                $table->size = array('*', '*', '*', '*', '*');\r
-                \r
-                $existobjective = false;\r
-                \r
-                $i = 0;\r
-                $objectiveid = 'cmi.objectives.'.$i.'.id';\r
-                \r
-                while (isset($trackdata->$objectiveid)) {\r
-                    $existobjective = true;\r
-                    $printedelements[]=$objectiveid;\r
-                    $elements = array($objectiveid,\r
-                                      'cmi.objectives.'.$i.'.status',\r
-                                      'cmi.objectives.'.$i.'.score.raw',\r
-                                      'cmi.objectives.'.$i.'.score.min',\r
-                                      'cmi.objectives.'.$i.'.score.max');\r
-                    $row = array();\r
-                    foreach ($elements as $element) {\r
-                        if (isset($trackdata->$element)) {\r
-                            $row[] = $trackdata->$element;\r
-                            $printedelements[]=$element;\r
-                        } else {\r
-                            $row[] = '&nbsp;';\r
-                        }\r
-                    }\r
-                    $table->data[] = $row;\r
-                    \r
-                    $i++;\r
-                    $objectiveid = 'cmi.objectives.'.$i.'.id';\r
-                }\r
-                if ($existobjective) {\r
-                    echo '<h3>'.get_string('objectives','scorm').'</h3>';\r
-                    print_table($table);\r
-                }\r
-                $table = new stdClass();\r
-                $table->head = array(get_string('element','scorm'), get_string('value','scorm'));\r
-                $table->align = array('left', 'left');\r
-                $table->wrap = array('nowrap', 'wrap');\r
-                $table->width = '100%';\r
-                $table->size = array('*', '*');\r
-                \r
-                $existelements = false;\r
-                \r
-                foreach($trackdata as $element => $value) {\r
-                    if (substr($element,0,3) == 'cmi') { \r
-                        if (!(in_array ($element, $printedelements))) {\r
-                            $existelements = true;\r
-                            $row = array();\r
-                            $row[] = get_string($element,'scorm') != '[['.$element.']]' ? get_string($element,'scorm') : $element;\r
-                            $row[] = $value;\r
-                            $table->data[] = $row;\r
-                        }\r
-                    }\r
-                }\r
-                if ($existelements) {\r
-                    echo '<h3>'.get_string('othertracks','scorm').'</h3>';\r
-                    print_table($table);\r
-                }                \r
-                print_simple_box_end();\r
-            }\r
-        } else {\r
-            error('Missing script parameter');\r
-        }\r
-    }\r
-       \r
-    print_heading(format_string(get_string('timestatistic','scorm')));\r
-       $scousers=get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid");        \r
-    $attempt = scorm_get_last_attempt($scorm->id,$USER->id);   \r
-       \r
-       foreach($scousers as $scouser){\r
-               $str = 'scormid ='.($scorm->id).' and userid = '.$scouser->userid.' and attempt = '.$attempt.' ORDER BY timemodified asc';\r
-               $endtrack       = get_record_select("scorm_scoes_track", $str,'max(timemodified) as maxtimemodified');\r
-\r
-       }\r
-\r
-//Phan trinh bay thong ke theo thoi gian\r
-               $table = new stdClass();\r
-               $table->head = array('&nbsp;', get_string('name','scorm'));\r
-               $table->align = array('center', 'left');\r
-               $table->wrap = array('nowrap', 'nowrap');\r
-               $table->width = '100%';\r
-               $table->size = array(10, '*');\r
-\r
-               $table->head[]=scorm_string_wrap(get_string('beginTime','scorm'));\r
-               $table->align[] = 'center';\r
-               $table->wrap[] = 'nowrap';\r
-               $table->size[] = '*';\r
-\r
-               $table->head[]=scorm_string_wrap(get_string('endTime','scorm'));\r
-               $table->align[] = 'center';\r
-               $table->wrap[] = 'nowrap';\r
-               $table->size[] = '*';\r
-\r
-               $row = array();\r
-               $row[] = "";\r
-               $row[] = "(".get_string('coefficient','scorm').")";\r
-       foreach($scousers as $scouser){\r
-               $userdata = scorm_get_user_data($scouser->userid);\r
-               $row = array();\r
-               $row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true);\r
-               $row[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">".\r
-                                                "$userdata->firstname $userdata->lastname</a>";        \r
-               $str = 'scormid ='.($scorm->id).' and userid = '.$scouser->userid.' and attempt = '.$attempt.' ORDER BY timemodified asc';\r
-               $begintrack     = get_record_select("scorm_scoes_track", $str,'min(timemodified) as mintimemodified');          \r
-               $row[] = strftime( "%H h -%M ' - %S s - %d -%m-%Y", $begintrack->mintimemodified);              \r
-               $endtrack       = get_record_select("scorm_scoes_track", $str,'max(timemodified) as maxtimemodified');\r
-               $row[] = strftime( "%H h -%M ' - %S s - %d -%m-%Y", $endtrack->maxtimemodified);\r
-        $table->data[] = $row;\r
-               }\r
-               print_table($table);\r
-       \r
-       echo "<br><a href='viewScore.php?a=$scorm->id'>".format_string(get_string('viewscore','scorm'))."</a>";\r
-    if (empty($noheader)) {\r
-        print_footer($course);\r
-    }\r
-?>\r
+<?php  // $Id$
+
+// This script uses installed report plugins to print quiz reports
+
+    require_once("../../config.php");
+    require_once('locallib.php');
+       
+    $id = optional_param('id', '', PARAM_INT);    // Course Module ID, or
+    $a = optional_param('a', '', PARAM_INT);     // SCORM ID
+    $b = optional_param('b', '', PARAM_INT);     // SCO ID
+    $user = optional_param('user', '', PARAM_INT);  // User ID
+
+    if (!empty($id)) {
+        if (! $cm = get_coursemodule_from_id('scorm', $id)) {
+            error("Course Module ID was incorrect");
+        }
+        if (! $course = get_record("course", "id", $cm->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 = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
+        } 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 <a href=\"index.php?id=$course->id\">$strscorms</a>
+                      -> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a> -> $strreport",
+                     "", "", true);
+        } else {
+            print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
+                     "$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
+                      -> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>
+              -> <a href=\"report.php?id=$cm->id\">$strreport</a> -> $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('&nbsp;', $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[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">".
+                                 "$userdata->firstname $userdata->lastname</a>";
+                        foreach ($scoes as $sco) {
+                            if ($sco->launch!='') {
+                                $anchorstart = '';
+                                $anchorend = '';
+                                $scoreview = '';
+                                if ($trackdata = scorm_get_tracks($sco->id,$scouser->userid)) {
+                                    if ($trackdata->score_raw != '') {
+                                        $scoreview = '<br />'.get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
+                                    }
+                                    if ($trackdata->status == '') {
+                                        $trackdata->status = 'notattempted';
+                                    } else {
+                                        $anchorstart = '<a href="report.php?b='.$sco->id.'&user='.$scouser->userid.'" title="'.
+                                                       get_string('details','scorm').'">';
+                                        $anchorend = '</a>';
+                                    }
+                                } else {
+                                    $trackdata->status = 'notattempted';
+                                    $trackdata->total_time = '';
+                                }
+                                $strstatus = get_string($trackdata->status,'scorm');
+                                $row[] = $anchorstart.'<img src="'.$scormpixdir.'/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
+                                         $strstatus.'">&nbsp;'.$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 '<div align="center">'."\n";
+                print_user_picture($user, $course->id, $userdata->picture, false, false);
+                echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user&course=$course->id\">".
+                     "$userdata->firstname $userdata->lastname</a><br />";
+                $scoreview = '';
+                if ($trackdata = scorm_get_tracks($sco->id,$user)) {
+                    if ($trackdata->score_raw != '') {
+                        $scoreview = get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
+                    }
+                    if ($trackdata->status == '') {
+                        $trackdata->status = 'notattempted';
+                    }
+                } else {
+                    $trackdata->status = 'notattempted';
+                    $trackdata->total_time = '';
+                }
+                $strstatus = get_string($trackdata->status,'scorm');
+                echo '<img src="'.$scormpixdir.'/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
+                $strstatus.'">&nbsp;'.$trackdata->total_time.'<br />'.$scoreview.'<br />';
+                echo '</div>'."\n";
+                echo '<hr /><h2>'.get_string('details','scorm').'</h2>';
+                
+                // 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 '<h3>'.get_string('general','scorm').'</h3>';
+                    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[] = '&nbsp;';
+                        }
+                    }
+                    $table->data[] = $row;
+                    
+                    $i++;
+                    $interactionid = 'cmi.interactions.'.$i.'.id';
+                }
+                if ($existinteraction) {
+                    echo '<h3>'.get_string('interactions','scorm').'</h3>';
+                    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[] = '&nbsp;';
+                        }
+                    }
+                    $table->data[] = $row;
+                    
+                    $i++;
+                    $objectiveid = 'cmi.objectives.'.$i.'.id';
+                }
+                if ($existobjective) {
+                    echo '<h3>'.get_string('objectives','scorm').'</h3>';
+                    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 '<h3>'.get_string('othertracks','scorm').'</h3>';
+                    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('&nbsp;', 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[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">".
+                                                "$userdata->firstname $userdata->lastname</a>";        
+               $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 "<br><a href='viewScore.php?a=$scorm->id'>".format_string(get_string('viewscore','scorm'))."</a>";
+    if (empty($noheader)) {
+        print_footer($course);
+    }
+?>
index e3a6718b984ee7acb40e1b76b3d4ac6d5ccf6e1b..c31c6528374588ea3f48f7235f85b73bddccf990 100755 (executable)
@@ -1,12 +1,12 @@
-<?php // $Id$\r
-\r
-/////////////////////////////////////////////////////////////////////////////////\r
-///  Code fragment to define the version of scorm\r
-///  This fragment is called by moodle_needs_upgrading() and /admin/index.php\r
-/////////////////////////////////////////////////////////////////////////////////\r
-\r
-$module->version  = 2006080800;   // The (date) version of this module\r
-$module->requires = 2005060200;   // The version of Moodle that is required\r
-$module->cron     = 0;            // How often should cron check this module (seconds)?\r
-\r
-?>\r
+<?php // $Id$
+
+/////////////////////////////////////////////////////////////////////////////////
+///  Code fragment to define the version of scorm
+///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
+/////////////////////////////////////////////////////////////////////////////////
+
+$module->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)?
+
+?>
index 427e4f066e14daae59e9dc2ff09121934d936bd1..f97bf11d8962086be157baaa6ddcadf4b5113f68 100755 (executable)
@@ -1,97 +1,97 @@
-<?php  // $Id$\r
-\r
-    require_once("../../config.php");\r
-    require_once('locallib.php');\r
-    \r
-    $id = optional_param('id', '', PARAM_INT);       // Course Module ID, or\r
-    $a = optional_param('a', '', PARAM_INT);         // scorm ID\r
-    //$organization = optional_param('organization', '', PARAM_INT); // organization ID\r
-\r
-    if (!empty($id)) {\r
-        if (! $cm = get_record("course_modules", "id", $id)) {\r
-            error("Course Module ID was incorrect");\r
-        }\r
-        if (! $course = get_record("course", "id", $cm->course)) {\r
-            error("Course is misconfigured");\r
-        }\r
-        if (! $scorm = get_record("scorm", "id", $cm->instance)) {\r
-            error("Course module is incorrect");\r
-        }\r
-    } else if (!empty($a)) {\r
-        if (! $scorm = get_record("scorm", "id", $a)) {\r
-            error("Course module is incorrect");\r
-        }\r
-        if (! $course = get_record("course", "id", $scorm->course)) {\r
-            error("Course is misconfigured");\r
-        }\r
-        if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {\r
-            error("Course Module ID was incorrect");\r
-        }\r
-    } else {\r
-        error('A required parameter is missing');\r
-    }\r
-\r
-    require_login($course->id, false, $cm);\r
-\r
-    if (isset($SESSION->scorm_scoid)) {\r
-        unset($SESSION->scorm_scoid);\r
-    }\r
-\r
-    $strscorms = get_string("modulenameplural", "scorm");\r
-    $strscorm  = get_string("modulename", "scorm");\r
-\r
-    if ($course->category != 0) { \r
-        $navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";\r
-        if ($scorms = get_all_instances_in_course('scorm', $course)) {\r
-            // The module SCORM activity with the least id is the course  \r
-            $firstscorm = current($scorms);\r
-            if (!(($course->format == 'scorm') && ($firstscorm->id == $scorm->id))) {\r
-                $navigation .= "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";\r
-            }       \r
-        }\r
-    } else {\r
-        $navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";\r
-    }\r
-\r
-    $pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name));\r
-\r
-    add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id");\r
-\r
-    //\r
-    // Print the page header\r
-    //\r
-    if (!$cm->visible and !isteacher($course->id)) {\r
-        print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name), '', '', true,\r
-                     update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));\r
-        notice(get_string('activityiscurrentlyhidden'));\r
-    } else {\r
-        print_header($pagetitle, "$course->fullname",\r
-                     "$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>",\r
-                     '', '', true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));\r
-\r
-        if (isteacher($course->id)) {\r
-\r
-        //Phan thiet lap he so diem\r
-            $examNumber = get_record_select('scorm_scoes', 'scorm ='.($scorm->id).' and minnormalizedmeasure > -1','count(id) as examCount');\r
-            //fwrite($ft,"\n So bai kiem tra la ".($examNumber->examCount));    \r
-            if ($examNumber->examCount > 0){\r
-                echo "<div class=\"reportlink\"><img src='pix\SuaHeSoDiem.png' /><a target=\"{$CFG->framename}\" href=\"coefficientSetting.php?id=$cm->id\"> ".get_string('scorecoefficientsetting','scorm',$examNumber->examCount).'</a></div>';\r
-            }\r
-\r
-        //-----------------------\r
-            $trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');\r
-            if ($trackedusers->c > 0) {\r
-                echo "<div class=\"reportlink\"><img src='pix\ThongKe.png' /><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\"> ".get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';\r
-            } else {\r
-                echo '<div class="reportlink">'.get_string('noreports','scorm').'</div>';\r
-            }\r
-        }\r
-\r
-        $USER->setAttempt = 'notset';\r
-        // Print the main part of the page\r
-        print_heading(format_string($scorm->name));\r
-        print_simple_box(format_text($scorm->summary), 'center', '70%', '', 5, 'generalbox', 'intro');\r
-        scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);\r
-        print_footer($course);\r
-    }\r
-?>\r
+<?php  // $Id$
+
+    require_once("../../config.php");
+    require_once('locallib.php');
+    
+    $id = optional_param('id', '', PARAM_INT);       // Course Module ID, or
+    $a = optional_param('a', '', PARAM_INT);         // scorm ID
+    //$organization = optional_param('organization', '', PARAM_INT); // organization ID
+
+    if (!empty($id)) {
+        if (! $cm = $cm = get_coursemodule_from_id('scorm', $id)) {
+            error("Course Module ID was incorrect");
+        }
+        if (! $course = get_record("course", "id", $cm->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 = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
+        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 .= "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
+            }       
+        }
+    } else {
+        $navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
+    }
+
+    $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 <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>",
+                     '', '', 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 "<div class=\"reportlink\"><img src='pix\SuaHeSoDiem.png' /><a target=\"{$CFG->framename}\" href=\"coefficientSetting.php?id=$cm->id\"> ".get_string('scorecoefficientsetting','scorm',$examNumber->examCount).'</a></div>';
+            }
+
+        //-----------------------
+            $trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
+            if ($trackedusers->c > 0) {
+                echo "<div class=\"reportlink\"><img src='pix\ThongKe.png' /><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\"> ".get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
+            } else {
+                echo '<div class="reportlink">'.get_string('noreports','scorm').'</div>';
+            }
+        }
+
+        $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);
+    }
+?>
index 420ec18324ea589fa790e42d1e114c90ad8521e0..019261873c2fc5135e43640e8e614c03caf67378 100644 (file)
@@ -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");
     }
 
index 84bb9e7c539c25d3e3fc63962f0c611c84147bb6..36ef53383426f6ddd73889b3b1c655e8bc3ef8c2 100644 (file)
@@ -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");
     }
 
index 98300507154251158cb1a81df32e16ddcf0d1119..e8a3944fd030d2c0e258b1412ad97598e03dab50 100644 (file)
@@ -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");
     }
 
index 95592497c25ea8c182518a5c20a3a33e1dbff61e..b9e78c19415bf192402c452274eef693c8e534fb 100644 (file)
@@ -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;
 
 ?>
index 2477e00686a4b71a255ee835f9ad99dca625f9c3..0ea2d35007a031e553c9f6f907887dd8c70e0a6c 100644 (file)
@@ -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");
     }
 
index 7d22e5578fcf0373f431843d557953a4c561b6a6..de78172d865e004b3931ff88593cef929567e8b8 100644 (file)
@@ -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");
         }
 
index c3fc6647632118221c53d01b6ecd7db6117f54be..9b9ea472e8799f76d3cc00fcb986d032d07b389e 100644 (file)
@@ -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)
 
 ?>
index fb73310061ef433168f95ec67f0030f80afc6754..2c91799df167e46b5b8aad30fc1d7319cafbc075 100644 (file)
@@ -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");
         }
 
index 407da1c643947382b31ea4e8e626bcda67c046f9..7435c91fb70c7344b209cf70b53d995453593639 100644 (file)
@@ -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)) {
index a2d32a0e1ee7a7a98add0ee1ccc5d4501de9f7b2..fa806b90599a58ae03d40d7af387d146315f40d2 100644 (file)
@@ -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)) {
index 7921b8292430d619b7ee81e8655748e9a4b8bb4e..1e54d56e09ae0d82770352ceaf1f42a1737581a4 100644 (file)
@@ -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;
 
 ?>
index 9ec708cbc9ebe39ed52a2dd9992e1395e4bc4c9e..a5acc0514d347ca51ba32a707f56df3372ac1734 100644 (file)
@@ -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)) {
index 4b98b8ce9b34b0ebc3f892e19ca532ce1181f8b7..a01bdcabadf619a045a11d547dc2f0ebb0e6a0a7 100644 (file)
@@ -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