Permalink
Browse files

SCORM MDL-30146 AICC - add ability to link direct to a simple AICC url

  • Loading branch information...
1 parent ba0e91a commit 4388bd45b273e4688e601504dedb85fc217ab063 @danmarsden danmarsden committed Nov 5, 2011
@@ -110,6 +110,9 @@ function scorm_forge_cols_regexp($columns, $remodule='(".*")?,') {
function scorm_parse_aicc($scorm) {
global $DB;
+ if ($scorm->scormtype == SCORM_TYPE_AICCURL) {
+ return scorm_aicc_generate_simple_sco($scorm);
+ }
if (!isset($scorm->cmid)) {
$cm = get_coursemodule_from_instance('scorm', $scorm->id);
$scorm->cmid = $cm->id;
@@ -388,4 +391,48 @@ function scorm_aicc_confirm_hacp_session($hacpsession) {
$DB->update_record('scorm_aicc_session', $hacpsession);
}
return $hacpsession;
+}
+
+/**
+ * generate a simple single activity AICC object
+ * structure to wrap around and externally linked
+ * AICC package URL
+ *
+ * @param object $scorm package record
+ */
+function scorm_aicc_generate_simple_sco($scorm) {
+ global $DB;
+ // find the old one
+ $scos = $DB->get_records('scorm_scoes', array('scorm'=>$scorm->id));
+ if (!empty($scos)) {
+ $sco = array_shift($scos);
+ } else {
+ $sco = new object();
+ }
+ // get rid of old ones
+ foreach($scos as $oldsco) {
+ $DB->delete_records('scorm_scoes', array('id'=>$oldsco->id));
+ $DB->delete_records('scorm_scoes_track', array('scoid'=>$oldsco->id));
+ }
+
+ $sco->identifier = 'A1';
+ $sco->scorm = $scorm->id;
+ $sco->organization = '';
+ $sco->title = $scorm->name;
+ $sco->parent = '/';
+ // add the HACP signal to the activity launcher
+ if (preg_match('/\?/', $scorm->reference)) {
+ $sco->launch = $scorm->reference.'&CMI=HACP';
+ }
+ else {
+ $sco->launch = $scorm->reference.'?CMI=HACP';
+ }
+ $sco->scormtype = 'sco';
+ if (isset($sco->id)) {
+ $DB->update_record('scorm_scoes', $sco);
+ $id = $sco->id;
+ } else {
+ $id = $DB->insert_record('scorm_scoes', $sco);
+ }
+ return $id;
}
@@ -34,6 +34,8 @@
$string['advanced'] = 'Parameters';
$string['allowapidebug'] = 'Activate API debug and tracing (set the capture mask with apidebugmask)';
$string['allowtypeexternal'] = 'Enable external package type';
+$string['allowtypeexternalaicc'] = 'Enable direct AICC url';
+$string['allowtypeexternalaicc_desc'] = 'If enabled this allows a direct url to a simple AICC package';
$string['allowtypeimsrepository'] = 'Enable IMS package type';
$string['allowtypelocalsync'] = 'Enable downloaded package type';
$string['allowtypeaicchacp'] = 'Enable AICC HACP';
@@ -166,6 +168,7 @@
$string['interactionsweight'] = 'Weight assigned to the element';
$string['interactionslearnerresponse'] = 'Learner\'s Response';
$string['invalidactivity'] = 'Scorm activity is incorrect';
+$string['invalidurl'] = 'Invalid URL specified';
$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';
@@ -265,7 +268,8 @@
* Uploaded package - Enables a SCORM package to be chosen via the file picker
* External SCORM manifest - Enables an imsmanifest.xml URL to be specified. Note: If the URL has a different domain name than your site, then "Downloaded package" is a better option, since otherwise grades are not saved.
* Downloaded package - Enables a package URL to be specified. The package will be unzipped and saved locally, and updated when the external SCORM package is updated.
-* Local IMS content repository - Enables a package to be selected from within an IMS repository';
+* Local IMS content repository - Enables a package to be selected from within an IMS repository
+* External AICC URL - this URL is the launch URL for a single AICC Activity. A psuedo package will be constructed around this.';
$string['scorm:viewreport'] = 'View reports';
$string['scorm:viewscores'] = 'View scores';
$string['scrollbars'] = 'Allow the window to be scrolled';
@@ -297,6 +301,7 @@
$string['totaltime'] = 'Time';
$string['trackingloose'] = 'WARNING: The tracking data of this package will be lost!';
$string['type'] = 'Type';
+$string['typeaiccurl'] = 'External AICC URL';
$string['typeexternal'] = 'External SCORM manifest';
$string['typeimsrepository'] = 'Local IMS content repository';
$string['typelocal'] = 'Uploaded package';
View
@@ -28,6 +28,8 @@
define('SCORM_TYPE_EXTERNAL', 'external');
/** SCORM_TYPE_IMSREPOSITORY = imsrepository */
define('SCORM_TYPE_IMSREPOSITORY', 'imsrepository');
+/** SCORM_TYPE_AICCURL = external AICC url */
+define('SCORM_TYPE_AICCURL', 'aiccurl');
define('SCORM_TOC_SIDE', 0);
define('SCORM_TOC_HIDDEN', 1);
@@ -103,13 +105,12 @@ function scorm_add_instance($scorm, $mform=null) {
} else if ($record->scormtype === SCORM_TYPE_LOCALSYNC) {
$record->reference = $scorm->packageurl;
-
} else if ($record->scormtype === SCORM_TYPE_EXTERNAL) {
$record->reference = $scorm->packageurl;
-
} else if ($record->scormtype === SCORM_TYPE_IMSREPOSITORY) {
$record->reference = $scorm->packageurl;
-
+ } else if ($record->scormtype === SCORM_TYPE_AICCURL) {
+ $record->reference = $scorm->packageurl;
} else {
return false;
}
View
@@ -244,6 +244,7 @@ function scorm_parse($scorm, $full) {
if (!scorm_parse_aicc($scorm)) {
$scorm->version = 'ERROR';
}
+ $scorm->version = 'AICC';
}
} else if ($scorm->scormtype === SCORM_TYPE_EXTERNAL and $cfg_scorm->allowtypeexternal) {
@@ -266,7 +267,13 @@ function scorm_parse($scorm, $full) {
$scorm->version = 'ERROR';
}
$newhash = sha1($scorm->reference);
-
+ } else if ($scorm->scormtype === SCORM_TYPE_AICCURL and $cfg_scorm->allowtypeexternalaicc) {
+ require_once("$CFG->dirroot/mod/scorm/datamodels/aicclib.php");
+ // AICC
+ if (!scorm_parse_aicc($scorm)) {
+ $scorm->version = 'ERROR';
+ }
+ $scorm->version = 'AICC';
} else {
// sorry, disabled type
return;
View
@@ -62,6 +62,10 @@ function definition() {
$options[SCORM_TYPE_IMSREPOSITORY] = get_string('typeimsrepository', 'scorm');
}
+ if ($cfg_scorm->allowtypeexternalaicc) {
+ $options[SCORM_TYPE_AICCURL] = get_string('typeaiccurl', 'scorm');
+ }
+
// Reference
if (count($options) > 1) {
$mform->addElement('select', 'scormtype', get_string('scormtype', 'scorm'), $options);
@@ -360,19 +364,24 @@ function validation($data, $files) {
} else if ($type === SCORM_TYPE_EXTERNAL) {
$reference = $data['packageurl'];
if (!preg_match('/(http:\/\/|https:\/\/|www).*\/imsmanifest.xml$/i', $reference)) {
- $errors['packageurl'] = get_string('required'); // TODO: improve help
+ $errors['packageurl'] = get_string('invalidurl', 'scorm');
}
} else if ($type === 'packageurl') {
$reference = $data['reference'];
if (!preg_match('/(http:\/\/|https:\/\/|www).*(\.zip|\.pif)$/i', $reference)) {
- $errors['packageurl'] = get_string('required'); // TODO: improve help
+ $errors['packageurl'] = get_string('invalidurl', 'scorm');
}
} else if ($type === SCORM_TYPE_IMSREPOSITORY) {
$reference = $data['packageurl'];
if (stripos($reference, '#') !== 0) {
- $errors['packageurl'] = get_string('required');
+ $errors['packageurl'] = get_string('invalidurl', 'scorm');
+ }
+ } else if ($type === SCORM_TYPE_AICCURL) {
+ $reference = $data['packageurl'];
+ if (!preg_match('/(http:\/\/|https:\/\/|www).*/', $reference)) {
+ $errors['packageurl'] = get_string('invalidurl', 'scorm');
}
}
View
@@ -123,6 +123,8 @@
$settings->add(new admin_setting_configcheckbox('scorm/allowtypeimsrepository', get_string('allowtypeimsrepository', 'scorm'), '', 0));
+ $settings->add(new admin_setting_configcheckbox('scorm/allowtypeexternalaicc', get_string('allowtypeexternalaicc', 'scorm'), get_string('allowtypeexternalaicc_desc', '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',

0 comments on commit 4388bd4

Please sign in to comment.