Merge branch 'master_MDL-27036' of git://github.com/danmarsden/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 9 Nov 2011 01:03:25 +0000 (02:03 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 9 Nov 2011 01:03:25 +0000 (02:03 +0100)
mod/scorm/aicc.php
mod/scorm/datamodels/aicclib.php
mod/scorm/db/install.xml
mod/scorm/db/upgrade.php
mod/scorm/lang/en/scorm.php
mod/scorm/lib.php
mod/scorm/loadSCO.php
mod/scorm/player.php
mod/scorm/settings.php
mod/scorm/version.php
mod/scorm/view.php

index 40ce4a8..ea61f39 100644 (file)
@@ -33,32 +33,47 @@ $command = required_param('command', PARAM_ALPHA);
 $sessionid = required_param('session_id', PARAM_ALPHANUM);
 $aiccdata = optional_param('aicc_data', '', PARAM_RAW);
 
+$cfg_scorm = get_config('scorm');
+
 $url = new moodle_url('/mod/scorm/aicc.php', array('command'=>$command, 'session_id'=>$sessionid));
 if ($aiccdata !== 0) {
     $url->param('aicc_data', $aiccdata);
 }
 $PAGE->set_url($url);
 
-require_login();
+if (empty($cfg_scorm->allowaicchacp)) {
+    require_login();
+    if (!confirm_sesskey($sessionid)) {
+        print_error('invalidsesskey');
+    }
+    $aiccuser = $USER;
+    $scormsession = $SESSION->scorm;
+} else {
+    $scormsession = scorm_aicc_confirm_hacp_session($sessionid);
+    if (empty($scormsession)) {
+        print_error('invalidhacpsession', 'scorm');
+    }
+    $aiccuser = $DB->get_record('user', array('id'=>$scormsession->userid), 'id,username,lastname,firstname', MUST_EXIST);
+}
 
-if (!empty($command) && confirm_sesskey($sessionid)) {
+if (!empty($command)) {
     $command = strtolower($command);
 
-    if (isset($SESSION->scorm_scoid)) {
-        $scoid = $SESSION->scorm_scoid;
+    if (isset($scormsession->scoid)) {
+        $scoid = $scormsession->scoid;
     } else {
         print_error('cannotcallscript');
     }
     $mode = 'normal';
-    if (isset($SESSION->scorm_mode)) {
-        $mode = $SESSION->scorm_mode;
+    if (isset($scormsession->scormmode)) {
+        $mode = $scormsession->scormmode;
     }
     $status = 'Not Initialized';
-    if (isset($SESSION->scorm_status)) {
-        $status = $SESSION->scorm_status;
+    if (isset($scormsession->scormstatus)) {
+        $status = $scormsession->scormstatus;
     }
-    if (isset($SESSION->scorm_attempt)) {
-        $attempt = $SESSION->scorm_attempt;
+    if (isset($scormsession->attempt)) {
+        $attempt = $scormsession->attempt;
     } else {
         $attempt = 1;
     }
@@ -84,20 +99,20 @@ if (!empty($command) && confirm_sesskey($sessionid)) {
         switch ($command) {
             case 'getparam':
                 if ($status == 'Not Initialized') {
-                    $SESSION->scorm_status = 'Running';
+                    $scormsession->scormstatus = 'Running';
                     $status = 'Running';
                 }
                 if ($status != 'Running') {
                     echo "error=101\r\nerror_text=Terminated\r\n";
                 } else {
-                    if ($usertrack=scorm_get_tracks($scoid, $USER->id, $attempt)) {
+                    if ($usertrack=scorm_get_tracks($scoid, $aiccuser->id, $attempt)) {
                         $userdata = $usertrack;
                     } else {
                         $userdata->status = '';
                         $userdata->score_raw = '';
                     }
-                    $userdata->student_id = $USER->username;
-                    $userdata->student_name = $USER->lastname .', '. $USER->firstname;
+                    $userdata->student_id = $aiccuser->username;
+                    $userdata->student_name = $aiccuser->lastname .', '. $aiccuser->firstname;
                     $userdata->mode = $mode;
                     if ($userdata->mode == 'normal') {
                         $userdata->credit = 'credit';
@@ -135,10 +150,10 @@ if (!empty($command) && confirm_sesskey($sessionid)) {
                         }
                         if (isset($userdata->{'cmi.core.lesson_status'})) {
                             echo 'Lesson_Status='.$userdata->{'cmi.core.lesson_status'}.$userdata->entry."\r\n";
-                            $SESSION->scorm_lessonstatus = $userdata->{'cmi.core.lesson_status'};
+                            $scormsession->scorm_lessonstatus = $userdata->{'cmi.core.lesson_status'};
                         } else {
                             echo 'Lesson_Status=not attempted'.$userdata->entry."\r\n";
-                            $SESSION->scorm_lessonstatus = 'not attempted';
+                            $scormsession->scorm_lessonstatus = 'not attempted';
                         }
                         if (isset($userdata->{'cmi.core.score.raw'})) {
                             $max = '';
@@ -183,8 +198,8 @@ if (!empty($command) && confirm_sesskey($sessionid)) {
                     if (!empty($aiccdata) && has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE, $cm->id))) {
                         $initlessonstatus = 'not attempted';
                         $lessonstatus = 'not attempted';
-                        if (isset($SESSION->scorm_lessonstatus)) {
-                            $initlessonstatus = $SESSION->scorm_lessonstatus;
+                        if (isset($scormsession->scorm_lessonstatus)) {
+                            $initlessonstatus = $scormsession->scorm_lessonstatus;
                         }
                         $score = '';
                         $datamodel['lesson_location'] = 'cmi.core.lesson_location';
@@ -203,7 +218,7 @@ if (!empty($command) && confirm_sesskey($sessionid)) {
                                     $element = $datamodel[$element];
                                     switch ($element) {
                                         case 'cmi.core.lesson_location':
-                                            $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
+                                            $id = scorm_insert_track($aiccuser->id, $scorm->id, $sco->id, $attempt, $element, $value);
                                         break;
                                         case 'cmi.core.lesson_status':
                                             $statuses = array(
@@ -239,13 +254,13 @@ if (!empty($command) && confirm_sesskey($sessionid)) {
                                             }
                                             if (empty($value) || isset($exites[$value])) {
                                                 $subelement = 'cmi.core.exit';
-                                                $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
+                                                $id = scorm_insert_track($aiccuser->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
                                             }
                                             $value = trim(strtolower($values[0]));
                                             $value = $value[0];
                                             if (isset($statuses[$value]) && ($mode == 'normal')) {
                                                 $value = $statuses[$value];
-                                                $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
+                                                $id = scorm_insert_track($aiccuser->id, $scorm->id, $sco->id, $attempt, $element, $value);
                                             }
                                             $lessonstatus = $value;
                                         break;
@@ -254,23 +269,23 @@ if (!empty($command) && confirm_sesskey($sessionid)) {
                                             if ((count($values) > 1) && ($values[1] >= $values[0]) && is_numeric($values[1])) {
                                                 $subelement = 'cmi.core.score.max';
                                                 $value = trim($values[1]);
-                                                $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
+                                                $id = scorm_insert_track($aiccuser->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
                                                 if ((count($values) == 3) && ($values[2] <= $values[0]) && is_numeric($values[2])) {
                                                     $subelement = 'cmi.core.score.min';
                                                     $value = trim($values[2]);
-                                                    $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
+                                                    $id = scorm_insert_track($aiccuser->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
                                                 }
                                             }
 
                                             $value = '';
                                             if (is_numeric($values[0])) {
                                                 $value = trim($values[0]);
-                                                $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
+                                                $id = scorm_insert_track($aiccuser->id, $scorm->id, $sco->id, $attempt, $element, $value);
                                             }
                                             $score = $value;
                                         break;
                                         case 'cmi.core.session_time':
-                                             $SESSION->scorm_session_time = $value;
+                                             $scormsession->sessiontime = $value;
                                         break;
                                     }
                                 }
@@ -283,13 +298,13 @@ if (!empty($command) && confirm_sesskey($sessionid)) {
                                         next($datarows);
                                     }
                                     $value = rawurlencode($value);
-                                    $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
+                                    $id = scorm_insert_track($aiccuser->id, $scorm->id, $sco->id, $attempt, $element, $value);
                                 }
                             }
                         }
                         if (($mode == 'browse') && ($initlessonstatus == 'not attempted')) {
                             $lessonstatus = 'browsed';
-                            $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, 'cmi.core.lesson_status', 'browsed');
+                            $id = scorm_insert_track($aiccuser->id, $scorm->id, $sco->id, $attempt, 'cmi.core.lesson_status', 'browsed');
                         }
                         if ($mode == 'normal') {
                             if ($sco = scorm_get_sco($scoid)) {
@@ -302,7 +317,7 @@ if (!empty($command) && confirm_sesskey($sessionid)) {
                                         }
                                     }
                                 }
-                                $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, 'cmi.core.lesson_status', $lessonstatus);
+                                $id = scorm_insert_track($aiccuser->id, $scorm->id, $sco->id, $attempt, 'cmi.core.lesson_status', $lessonstatus);
                             }
                         }
                     }
@@ -360,32 +375,32 @@ if (!empty($command) && confirm_sesskey($sessionid)) {
             break;
             case 'exitau':
                 if ($status == 'Running') {
-                    if (isset($SESSION->scorm_session_time) && ($SESSION->scorm_session_time != '')) {
-                        if ($track = $DB->get_record('scorm_scoes_track', array("userid"=>$USER->id,
+                    if (isset($scormsession->sessiontime) && ($scormsession->sessiontime != '')) {
+                        if ($track = $DB->get_record('scorm_scoes_track', array("userid"=>$aiccuser->id,
                                                                                 "scormid"=>$scorm->id,
                                                                                 "scoid"=>$sco->id,
                                                                                 "attempt"=>$attempt,
                                                                                 "element"=>'cmi.core.total_time'))) {
                             // Add session_time to total_time
-                            $value = scorm_add_time($track->value, $SESSION->scorm_session_time);
+                            $value = scorm_add_time($track->value, $scormsession->sessiontime);
                             $track->value = $value;
                             $track->timemodified = time();
                             $DB->update_record('scorm_scoes_track', $track);
                         } else {
                             $track = new stdClass();
-                            $track->userid = $USER->id;
+                            $track->userid = $aiccuser->id;
                             $track->scormid = $scorm->id;
                             $track->scoid = $sco->id;
                             $track->element = 'cmi.core.total_time';
-                            $track->value = $SESSION->scorm_session_time;
+                            $track->value = $scormsession->sessiontime;
                             $track->attempt = $attempt;
                             $track->timemodified = time();
                             $id = $DB->insert_record('scorm_scoes_track', $track);
                         }
-                        scorm_update_grades($scorm, $USER->id);
+                        scorm_update_grades($scorm, $aiccuser->id);
                     }
-                    $SESSION->scorm_status = 'Terminated';
-                    $SESSION->scorm_session_time = '';
+                    $scormsession->scormstatus = 'Terminated';
+                    $scormsession->session_time = '';
                     echo "error=0\r\nerror_text=Successful\r\n";
                 } else if ($status == 'Terminated') {
                     echo "error=1\r\nerror_text=Terminated\r\n";
@@ -405,6 +420,13 @@ if (!empty($command) && confirm_sesskey($sessionid)) {
         echo "error=3\r\nerror_text=Invalid Session ID\r\n";
     }
 }
+if (empty($cfg_scorm->allowaicchacp)) {
+    $SESSION->scorm = $scormsession;
+} else {
+    $scormsession->timemodified = time();
+    $DB->update_record('scorm_aicc_session', $scormsession);
+}
+
 $aiccresponse = ob_get_contents();
 scorm_debug_log_write("aicc", "HACP Response:\r\n$aiccresponse", $scoid);
 ob_end_flush();
\ No newline at end of file
index 016a55a..b902a67 100644 (file)
@@ -341,3 +341,51 @@ function scorm_parse_aicc($scorm) {
 
     return true;
 }
+
+/**
+ * Given a scormid creates an AICC Session record to allow HACP
+ *
+ * @param int $scormid - id from scorm table
+ * @return string hacpsession
+ */
+function scorm_aicc_get_hacp_session($scormid) {
+    global $USER, $DB, $SESSION;
+    $cfg_scorm = get_config('scorm');
+    if (empty($cfg_scorm->allowaicchacp)) {
+        return false;
+    }
+    $now = time();
+
+    $hacpsession = $SESSION->scorm;
+    $hacpsession->scormid = $scormid;
+    $hacpsession->hacpsession = random_string(20);
+    $hacpsession->userid      = $USER->id;
+    $hacpsession->timecreated = $now;
+    $hacpsession->timemodified = $now;
+    $DB->insert_record('scorm_aicc_session', $hacpsession);
+
+    return $hacpsession->hacpsession;
+}
+
+/**
+ * Check the hacp_session for whether it is valid.
+ *
+ * @param string $hacpsession The hacpsession value to check (optional). Normally leave this blank
+ *      and this function will do required_param('sesskey', ...).
+ * @return mixed - false if invalid, otherwise returns record from scorm_aicc_session table.
+ */
+function scorm_aicc_confirm_hacp_session($hacpsession) {
+    global $DB;
+    $cfg_scorm = get_config('scorm');
+    if (empty($cfg_scorm->allowaicchacp)) {
+        return false;
+    }
+    $time = time()-($cfg_scorm->aicchacptimeout * 60);
+    $sql = "hacpsession = ? AND timemodified > ?";
+    $hacpsession = $DB->get_record_select('scorm_aicc_session', $sql, array($hacpsession, $time));
+    if (!empty($hacpsession)) { //update timemodified as this is still an active session - resets the timeout.
+        $hacpsession->timemodified = time();
+        $DB->update_record('scorm_aicc_session', $hacpsession);
+    }
+    return $hacpsession;
+}
\ No newline at end of file
index ca356ba..fefbb5f 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/scorm/db" VERSION="20110731" COMMENT="XMLDB file for Moodle mod/scorm"
+<XMLDB PATH="mod/scorm/db" VERSION="20111105" COMMENT="XMLDB file for Moodle mod/scorm"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
 >
         <KEY NAME="scorm_rolluprule_scoid" TYPE="foreign" FIELDS="scoid" REFTABLE="scorm_scoes" REFFIELDS="id" COMMENT="The relative sco" PREVIOUS="scorm_rolluprule_uniq"/>
       </KEYS>
     </TABLE>
-    <TABLE NAME="scorm_seq_rolluprulecond" COMMENT="SCORM2004 sequencing rule" PREVIOUS="scorm_seq_rolluprule">
+    <TABLE NAME="scorm_seq_rolluprulecond" COMMENT="SCORM2004 sequencing rule" PREVIOUS="scorm_seq_rolluprule" NEXT="scorm_aicc_session">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="scoid"/>
         <FIELD NAME="scoid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="rollupruleid"/>
         <KEY NAME="scorm_rolluprulecond_rolluprule" TYPE="foreign" FIELDS="rollupruleid" REFTABLE="scorm_seq_rolluprule" REFFIELDS="id" COMMENT="The relative rolluprule" PREVIOUS="scorm_rolluprulecond_scoid"/>
       </KEYS>
     </TABLE>
+      <TABLE NAME="scorm_aicc_session" COMMENT="Used by AICC HACP to store session information" PREVIOUS="scorm_seq_rolluprulecond">
+        <FIELDS>
+          <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="userid"/>
+          <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="id from user table" PREVIOUS="id" NEXT="scormid"/>
+          <FIELD NAME="scormid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="id from scorm table" PREVIOUS="userid" NEXT="hacpsession"/>
+          <FIELD NAME="hacpsession" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="sessionid used to authenticate AICC HACP communication" PREVIOUS="scormid" NEXT="scoid"/>
+          <FIELD NAME="scoid" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="id from scorm_scoes table" PREVIOUS="hacpsession" NEXT="scormmode"/>
+          <FIELD NAME="scormmode" TYPE="char" LENGTH="50" NOTNULL="false" SEQUENCE="false" PREVIOUS="scoid" NEXT="scormstatus"/>
+          <FIELD NAME="scormstatus" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="scormmode" NEXT="attempt"/>
+          <FIELD NAME="attempt" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" PREVIOUS="scormstatus" NEXT="lessonstatus"/>
+          <FIELD NAME="lessonstatus" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="attempt" NEXT="sessiontime"/>
+          <FIELD NAME="sessiontime" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="lessonstatus" NEXT="timecreated"/>
+          <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="time this session was created" PREVIOUS="sessiontime" NEXT="timemodified"/>
+          <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="time this session was last used" PREVIOUS="timecreated"/>
+        </FIELDS>
+        <KEYS>
+          <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="scormid"/>
+          <KEY NAME="scormid" TYPE="foreign" FIELDS="scormid" REFTABLE="scorm" REFFIELDS="id" PREVIOUS="primary" NEXT="userid"/>
+          <KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" PREVIOUS="scormid"/>
+        </KEYS>
+      </TABLE>
+
   </TABLES>
 </XMLDB>
\ No newline at end of file
index 2335654..32396c9 100644 (file)
@@ -571,6 +571,39 @@ function xmldb_scorm_upgrade($oldversion) {
 
         upgrade_mod_savepoint(true, 2011080100, 'scorm');
     }
+    if ($oldversion < 2011110502) {
+
+        // Define table scorm_aicc_session to be created
+        $table = new xmldb_table('scorm_aicc_session');
+
+        // Adding fields to table scorm_aicc_session
+        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+        $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+        $table->add_field('scormid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+        $table->add_field('hacpsession', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
+        $table->add_field('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, '0');
+        $table->add_field('scormmode', XMLDB_TYPE_CHAR, '50', null, null, null, null);
+        $table->add_field('scormstatus', XMLDB_TYPE_CHAR, '255', null, null, null, null);
+        $table->add_field('attempt', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
+        $table->add_field('lessonstatus', XMLDB_TYPE_CHAR, '255', null, null, null, null);
+        $table->add_field('sessiontime', XMLDB_TYPE_CHAR, '255', null, null, null, null);
+        $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+        $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+
+        // Adding keys to table scorm_aicc_session
+        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+        $table->add_key('scormid', XMLDB_KEY_FOREIGN, array('scormid'), 'scorm', array('id'));
+        $table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
+
+        // Conditionally launch create table for scorm_aicc_session
+        if (!$dbman->table_exists($table)) {
+            $dbman->create_table($table);
+        }
+
+        // scorm savepoint reached
+        upgrade_mod_savepoint(true, 2011110502, 'scorm');
+    }
+
     return true;
 }
 
index 7d1c1e1..7566a2e 100644 (file)
  */
 $string['toc'] = 'TOC';
 $string['navigation'] = 'Navigation';
-
+$string['aicchacptimeout'] = 'AICC HACP Timeout';
+$string['aicchacptimeout_desc'] = 'Length of time in minutes that an external AICC HACP session can remain open';
+$string['aicchacpkeepsessiondata'] = 'AICC HACP session data';
+$string['aicchacpkeepsessiondata_desc'] = 'Length of time in days to keep the external AICC HACP session data (a high setting will fill up the table with old data but may be useful when debugging)';
 $string['activation'] = 'Activation';
 $string['activityloading'] = 'You will be automatically redirected to the activity in';
 $string['activitypleasewait'] = 'Activity loading, please wait ...';
@@ -33,6 +36,8 @@ $string['allowapidebug'] = 'Activate API debug and tracing (set the capture mask
 $string['allowtypeexternal'] = 'Enable external package type';
 $string['allowtypeimsrepository'] = 'Enable IMS package type';
 $string['allowtypelocalsync'] = 'Enable downloaded package type';
+$string['allowtypeaicchacp'] = 'Enable external AICC HACP';
+$string['allowtypeaicchacp_desc'] = 'If enabled this allows AICC HACP external communication without requiring user login for post requests from the external AICC package';
 $string['apidebugmask'] = 'API debug capture mask  - use a simple regex on &lt;username&gt;:&lt;activityname&gt; e.g. admin:.* will debug for admin user only';
 $string['areacontent'] = 'Content files';
 $string['areapackage'] = 'Package file';
@@ -161,6 +166,7 @@ $string['interactionstype'] = 'Type of question';
 $string['interactionsweight'] = 'Weight assigned to the element';
 $string['interactionslearnerresponse'] = 'Learner\'s Response';
 $string['invalidactivity'] = 'Scorm activity is incorrect';
+$string['invalidhacpsession'] = 'Invalid HACP Session';
 $string['invalidmanifestresource'] = 'WARNING: The following resources were referenced in your manifest but couldn\'t be found:';
 $string['last'] = 'Last accessed on';
 $string['lastaccess'] = 'Last access';
index 16fcb32..2728889 100644 (file)
@@ -504,6 +504,13 @@ function scorm_cron () {
         foreach ($scormsupdate as $scormupdate) {
             scorm_parse($scormupdate, true);
         }
+
+        //now clear out AICC session table with old session data
+        $cfg_scorm = get_config('scorm');
+        if (!empty($cfg_scorm->allowaicchacp)) {
+            $expiretime = time() - ($cfg_scorm->aicchacpkeepsessiondata*24*60*60);
+            $DB->delete_records_select('scorm_aicc_session', 'WHERE timemodified < ?', array($expiretime));
+        }
     }
 
     return true;
index 057ea84..d7988f5 100644 (file)
@@ -108,11 +108,16 @@ if ((isset($sco->parameters) && (!empty($sco->parameters))) || ($version == 'AIC
 }
 
 if ($version == 'AICC') {
+    require_once("$CFG->dirroot/mod/scorm/datamodels/aicclib.php");
+    $aicc_sid = scorm_aicc_get_hacp_session($scorm->id);
+    if (empty($aicc_sid)) {
+        $aicc_sid = sesskey();
+    }
     $sco_params = '';
     if (isset($sco->parameters) && (!empty($sco->parameters))) {
         $sco_params = '&'. $sco->parameters;
     }
-    $launcher = $sco->launch.$connector.'aicc_sid='.sesskey().'&aicc_url='.$CFG->wwwroot.'/mod/scorm/aicc.php'.$sco_params;
+    $launcher = $sco->launch.$connector.'aicc_sid='.$aicc_sid.'&aicc_url='.$CFG->wwwroot.'/mod/scorm/aicc.php'.$sco_params;
 } else {
     if (isset($sco->parameters) && (!empty($sco->parameters))) {
         $launcher = $sco->launch.$connector.$sco->parameters;
index 4399d23..0b9a806 100644 (file)
@@ -170,10 +170,10 @@ if ($mode == 'browse') {
 }
 $orgstr = '&currentorg='.$currentorg;
 
-$SESSION->scorm_scoid = $sco->id;
-$SESSION->scorm_status = 'Not Initialized';
-$SESSION->scorm_mode = $mode;
-$SESSION->scorm_attempt = $attempt;
+$SESSION->scorm->scoid = $sco->id;
+$SESSION->scorm->scormstatus = 'Not Initialized';
+$SESSION->scorm->scormmode = $mode;
+$SESSION->scorm->attempt = $attempt;
 
 // Mark module viewed
 $completion = new completion_info($course);
index 90463b1..06de0aa 100644 (file)
@@ -123,6 +123,16 @@ if ($ADMIN->fulltree) {
 
     $settings->add(new admin_setting_configcheckbox('scorm/allowtypeimsrepository', get_string('allowtypeimsrepository', 'scorm'), '', 0));
 
+    $settings->add(new admin_setting_configcheckbox('scorm/allowaicchacp', get_string('allowtypeaicchacp', 'scorm'), get_string('allowtypeaicchacp_desc', 'scorm'), 0));
+
+    $settings->add(new admin_setting_configtext('scorm/aicchacptimeout',
+        get_string('aicchacptimeout', 'scorm'), get_string('aicchacptimeout_desc', 'scorm'),
+        30, PARAM_INT));
+
+    $settings->add(new admin_setting_configtext('scorm/aicchacpkeepsessiondata',
+        get_string('aicchacpkeepsessiondata', 'scorm'), get_string('aicchacpkeepsessiondata_desc', 'scorm'),
+        1, PARAM_INT));
+
     $settings->add(new admin_setting_configcheckbox('scorm/forcejavascript', get_string('forcejavascript', 'scorm'), get_string('forcejavascript_desc', 'scorm'), 1));
 
     $settings->add(new admin_setting_configcheckbox('scorm/allowapidebug', get_string('allowapidebug', 'scorm'), '', 0));
index 59dfec0..52a0c19 100644 (file)
@@ -23,6 +23,6 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-$module->version  = 2011080100;   // The (date) version of this module
+$module->version  = 2011110502;   // The (date) version of this module
 $module->requires = 2010080300;   // The version of Moodle that is required
 $module->cron     = 300;            // How often should cron check this module (seconds)?
index 43b80f0..2b7775d 100644 (file)
@@ -60,8 +60,8 @@ require_login($course->id, false, $cm);
 $context = get_context_instance(CONTEXT_COURSE, $course->id);
 $contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
 
-if (isset($SESSION->scorm_scoid)) {
-    unset($SESSION->scorm_scoid);
+if (isset($SESSION->scorm)) {
+    unset($SESSION->scorm);
 }
 
 $strscorms = get_string("modulenameplural", "scorm");