This Drupal 7 CodeLet creates a link to the SCORM or HTML 5 course from the uploaded zip file. This associates an SCORM or HTML course to a node in Drupal.

CodeLet
<?php
/**
 * @file
 * Add a link to node page after a SCORM or HTML5 course has been uploaded
 *
 * @author DrupalD &lt;https://twitter.com/DrupalD&gt;
*/

function course_link_menu() {
 
$items = array();
 
$items['admin/config/content/course-link'] = array(
 
'type' =&gt; MENU_NORMAL_ITEM,
 
'title' =&gt; t('Course Link'),
 
'description' =&gt; t('Configure file upload fields for Course Link'),
 
'page callback' =&gt; 'drupal_get_form',
 
'page arguments' =&gt; array('course_link_admin_form'),
 
'access arguments' =&gt; array('administer site configuration '),
 
'file' =&gt; 'course_link_admin.inc',
 
'file path' =&gt; drupal_get_path('module', 'course_link'),
 );
 
return
$items;
}

/**
* Implementation of hook_node_insert
*
* @param object $node
* @author DrupalD &lt;https://twitter.com/DrupalD&gt;
*/
function course_link_node_insert($node) {
 
$file_upload_fields = array();
 
$file_field = array();
 
$file_upload_fields = variable_get('course_link_field');
 
//Default public directory path to extract zip files to
 
$destination = _file_directory_path();
 if (!empty(
$file_upload_fields)) {
 foreach(
$file_upload_fields as $key =&gt; $value) {
 
$file_field_info = field_info_field_by_id($value);
 
$file_field = array($file_field_info['field_name'] =&gt; $file_field_info['field_name']);
 }
 }

 if (!empty(
$file_field)) {
 foreach (
$file_field as $key =&gt; $value) {
 
//Get the correct field that is associated with existing node and exit the loop
 
if (array_key_exists($key, (array) $node)) {
 
$node_file_field = $key;
 break;
 }
 }
 
// Check if the node has one of those file fields. If it does, get the URI of the uploaded file.
 
$file_uri = _file_get_location($node-&gt;$node_file_field['und'][0]['fid']);
 if (!empty(
$file_uri)) {
 
// Insert data in course_link_node_file to retrieve it on node page
 
$data = array(
 
'nid' =&gt; $node-&gt;nid,
 
'fid' =&gt; $node-&gt;$node_file_field['und'][0]['fid'],
 );
 
drupal_write_record('course_link_node_file', $data);
 
//Unzip the file
 
$zip = new ZipArchive();
 if (
$zip-&gt;open($destination . basename($file_uri['uri'], '.zip') . '.zip') === TRUE) {
 
$zip-&gt;extractTo($destination . basename($file_uri['uri'], '.zip'));
 
$zip-&gt;close();
 }
 else {
 
drupal_set_message(t('Unable to open zip file'), 'error');
 }
 }
 }
}

/**
* Implemenation of hook_node_view
*
* @param object $node
* @param string $view_mode
* @param string $langcode
* @author DrupalD &lt;https://twitter.com/DrupalD&gt;
*/
function course_link_node_view($node, $view_mode, $langcode) {
 
$file_fid = array();
 
$file_filename = array();

 
//Get the fid from course_link_node_file table
 
$file_fid = db_select('course_link_node_file', 'cl')
 -&
gt;fields('cl', array('fid'))
 -&
gt;condition('nid', $node-&gt;nid, '=')
 -&
gt;execute()
 -&
gt;fetchAssoc();

 
//Get the filename using the FID
 
$file_filename = _file_get_location($file_fid['fid']);
 
$course_directory = basename($file_filename['uri'], '.zip');
 
$file_directory = _file_directory_path();
 
$course_link_index_directory = scandir($file_directory . $course_directory);
 
$course_link_index_file = array_search('index.html', $course_link_index_directory) ? '/index.html' : '/res/index.html';
 
//Add the link to node page
 
$course_link = l(t('Course Link'), $file_directory . $course_directory . $course_link_index_file, array('attributes' =&gt; array('target' =&gt; '_blank')));
 
$node-&gt;content['course_link'] = array(
 
'#markup' =&gt; $course_link,
 );
}

/**
* _file_get_location
* Get the location of the uploaded zip file
*
* @param int $fid: Id of the file
* @param bool $uri: Whether to fetch uri or not
* @author DrupalD &lt;https://twitter.com/DrupalD&gt;
*/
function _file_get_location($fid) {
 
//Get the URI of the uploaded file using the FID
 
$result = db_select('file_managed', 'fm')
 -&
gt;fields('fm', array('uri'))
 -&
gt;condition('fid', $fid, '=')
 -&
gt;execute()
 -&
gt;fetchAssoc();
 return
$result;
}

/**
* _file_directory_path
*
* Path to files directory
*
* @author DrupalD &lt;https://twitter.com/DrupalD&gt;
*/
function _file_directory_path() {
 return
variable_get('file_public_path', conf_path() . '/files/');
}

?&
gt;





<
h2>course_link_admin.inc</h2>

&
lt;?php
/**
* @file
*
* Admin configuration form for course link
*
* @author DrupalD &lt;https://twitter.com/DrupalD&gt;
*
*/

/**
* course_link_admin_form
*
* Admin configuration for course link
*
* @author DrupalD &lt;https://twitter.com/DrupalD&gt;
*/
function course_link_admin_form() {
 
$form= array();
 
$course_link_field = array();
 
$course_link_field =variable_get('course_link_field');
 
$course_field_values = _course_link_get_upload_field();
 
$form['course_link_field'] = array(
 
'#type' =&gt; 'select',
 
'#title' =&gt; t('File upload fields'),
 
'#description' =&gt; t('Select one or more file upload field to be processed by Course Link'),
 
'#multiple' =&gt; TRUE,
 
'#size' =&gt; 5,
 
'#options' =&gt; $course_field_values,
 
'#default_value' =&gt; $course_link_field,
 );
 return
system_settings_form($form);
}


/**
* _course_link_get_upload_field
*
* Helper function to get a list of all the file field which allows zip upload
*
* @author DrupalD &lt;https://twitter.com/DrupalD&gt;
*/
function _course_link_get_upload_field() {
 
$file_upload_fields = array();
 
$file_field = array();
 
$file_upload = array();
 
$file_upload_fields = field_info_fields();
 foreach (
$file_upload_fields as $file_field) {
 if (
$file_field['type'] == 'file') {
 
$file_upload['Course fields'] = array($file_field['id'] =&gt; $file_field['field_name']);
 }
 }
 return
$file_upload;
}
?>
Info file details
name = Course Link
description = Add a course link to node after a SCORM or HTML5 course has been uploaded. Developed by &lt;a href="http://jos.cx/jcs" target='_blank'&gt;JCS&lt;/a&gt;
dependencies[] = file
configure = admin/config/content/course-link
core = 7.x
package = Course
Install file details
<?php
>

/**
 *
 * @file
 *
 * Schema for storing node and file association details
 *
 * @author DrupalD &lt;https://twitter.com/DrupalD&gt;
 *
*/

/**
* Implementation of hook_schema
*
* @author DrupalD &lt;https://twitter.com/DrupalD&gt;
*/
function course_link_schema() {
 
$schema = array();
 
$schema['course_link_node_file'] = array(
 
'description' =&gt; t('Store node and uploaded zip file association details'),
 
'fields' =&gt; array(
 
'id' =&gt; array(
 
'type' =&gt; 'serial',
 
'length' =&gt; 11,
 
'not null' =&gt; TRUE,
 ),
 
'nid' =&gt; array(
 
'type' =&gt; 'int',
 
'length' =&gt; 11,
 
'not null' =&gt; TRUE,
 ),
 
'fid' =&gt; array(
 
'type' =&gt; 'int',
 
'length' =&gt; 11,
 
'not null' =&gt; TRUE,
 ),
 ),
 
'primary key' =&gt; array('id'),
 );
 return
$schema;
}
?>
Compatibility
Submitted by DrupalD on