Skip to content

Commit

Permalink
Fixed #1158 - Video not playing in offline exports as reported on forums
Browse files Browse the repository at this point in the history
 - Missing a plugin
 - Models did not check for offline mode yet
  • Loading branch information
torinfo committed Sep 14, 2022
1 parent e511db7 commit 3110854
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 60 deletions.
36 changes: 31 additions & 5 deletions modules/xerte/export.php
Expand Up @@ -225,7 +225,7 @@ function create_offline_file($varname, $sourcefile, $destfile)
// Extra include files normally loaded dynamically
$offline_includes .= " <!-- extra files, normally loaded dynamically -->\n";
$offline_includes .= " <script type=\"text/javascript\" src=\"common_html5/js/script.js\"></script>\n";
$offline_includes .= " <script type=\"text/javascript\" src=\"common_html5/js/popcorn/popcorn-complete.min.js\"></script>\n";
$offline_includes .= " <script type=\"text/javascript\" src=\"common_html5/js/popcorn/popcorn-complete.js\"></script>\n";
$offline_includes .= " <script type=\"text/javascript\" src=\"common_html5/js/popcorn/plugins/popcorn.textplus.js\"></script>\n";
$offline_includes .= " <script type=\"text/javascript\" src=\"common_html5/js/popcorn/plugins/popcorn.subtitleplus.js\"></script>\n";
$offline_includes .= " <script type=\"text/javascript\" src=\"common_html5/js/popcorn/plugins/popcorn.xot.js\"></script>\n";
Expand All @@ -235,6 +235,9 @@ function create_offline_file($varname, $sourcefile, $destfile)
$offline_includes .= " <script type=\"text/javascript\" src=\"common_html5/js/popcorn/plugins/MediasitePlayerControls.js\"></script>\n";
$offline_includes .= " <script type=\"text/javascript\" src=\"common_html5/js/popcorn/plugins/popcorn.slides.js\"></script>\n";
$offline_includes .= " <script type=\"text/javascript\" src=\"common_html5/js/popcorn/plugins/popcorn.sortholder.js\"></script>\n";
$offline_includes .= " <script type=\"text/javascript\" src=\"common_html5/js/popcorn/plugins/popcorn.mediaconstructor.js\"></script>\n";
$offline_includes .= " <script type=\"text/javascript\" src=\"common_html5/js/timeline/timeline3.js\"></script>\n";


// Offline theme js file
$offline_includes .= " <!-- theme file, normally loaded dynamically -->\n";
Expand Down Expand Up @@ -440,6 +443,29 @@ function create_offline_file($varname, $sourcefile, $destfile)
*/
$lo_name = $xml->getName();


// Get plugins
$pluginfiles = scandir($parent_template_path . "plugins/");
$plugins = array();
foreach($pluginfiles as $pluginfile) {
// get base name of plugin
$plugininfo = pathinfo($pluginfile);
if ($plugininfo['basename'] == '.' || $plugininfo['basename'] == '..') {
continue;
}
if (!isset($plugins[$plugininfo['filename']]))
{
$plugins[$plugininfo['filename']] = new stdClass();
}
if ($plugininfo['extension'] == 'js') {
$plugins[$plugininfo['filename']]->script = file_get_contents($parent_template_path . "plugins/" . $pluginfile);
}
if ($plugininfo['extension'] == 'css') {
$plugins[$plugininfo['filename']]->css = file_get_contents($parent_template_path . "plugins/" . $pluginfile);
}
}


/*
* Create scorm manifests or a basic HTML page
*/
Expand Down Expand Up @@ -467,26 +493,26 @@ function create_offline_file($varname, $sourcefile, $destfile)
if ($useflash) {
scorm_html_page_create($_GET['template_id'], $row['template_name'], $row['template_framework'], $rlo_file, $lo_name, $xml->getLanguage());
} else {
scorm_html5_page_create($_GET['template_id'], $row['template_framework'], $row['parent_template'], $lo_name, $xml->getLanguage(), $row['date_modified'], $row['date_created'], $need_download_url, $export_logo);
scorm_html5_page_create($_GET['template_id'], $row['template_framework'], $row['parent_template'], $lo_name, $xml->getLanguage(), $row['date_modified'], $row['date_created'], $need_download_url, $export_logo, $plugins);
}
} else if ($scorm == "2004") {
$useflash = ($export_flash && !$export_html5);
lmsmanifest_2004_create($row['zipname'], $useflash, $lo_name);
if ($export_flash && !$export_html5) {
scorm2004_html_page_create($_GET['template_id'], $row['template_name'], $row['template_framework'], $rlo_file, $lo_name, $xml->getLanguage());
} else {
scorm2004_html5_page_create($_GET['template_id'], $row['template_framework'], $row['parent_template'], $lo_name, $xml->getLanguage(), $row['date_modified'], $row['date_created'], $need_download_url, $export_logo);
scorm2004_html5_page_create($_GET['template_id'], $row['template_framework'], $row['parent_template'], $lo_name, $xml->getLanguage(), $row['date_modified'], $row['date_created'], $need_download_url, $export_logo, $plugins);
}
} else if($xAPI)
{
xAPI_html_page_create($_GET['template_id'], $row['template_name'], $row['template_framework'], $lo_name, $xml->getLanguage(), $row['date_modified'], false, false, '', false, $export_logo);
xAPI_html_page_create($_GET['template_id'], $row['template_name'], $row['template_framework'], $lo_name, $xml->getLanguage(), $row['date_modified'], false, false, '', false, $export_logo, $plugins);
}
else {
if ($export_flash) {
basic_html_page_create($_GET['template_id'], $row['template_name'], $row['template_framework'], $rlo_file, $lo_name);
}
if ($export_html5) {
basic_html5_page_create($_GET['template_id'], $row['template_framework'], $row['parent_template'],$lo_name, $row['date_modified'], $row['date_created'], $tsugi, $export_offline, $offline_includes, $need_download_url, $export_logo);
basic_html5_page_create($_GET['template_id'], $row['template_framework'], $row['parent_template'],$lo_name, $row['date_modified'], $row['date_created'], $tsugi, $export_offline, $offline_includes, $need_download_url, $export_logo, $plugins);
}
}

Expand Down
Expand Up @@ -45,9 +45,12 @@
href: x_templateLocation + 'common_html5/js/timeline/timeline3.css'
}).appendTo('head');
}

var popLocation = "common_html5/js/popcorn/"
var scriptsToLoad = ["common_html5/js/timeline/timeline3.js", popLocation + "popcorn-complete.js", popLocation + "plugins/popcorn.mediaconstructor.js"];
if (xot_offline)
{
numLoaded = scriptsToLoad.length;
}
if (numLoaded < scriptsToLoad.length) {
var fileToLoad = x_templateLocation + scriptsToLoad[numLoaded];
$.getScript(fileToLoad)
Expand Down
Expand Up @@ -654,6 +654,7 @@
}

} else {
debugger;
$holder = $('<div class="listHolder"></div>').appendTo($grid);
$ul = $('<ul/>').appendTo($holder);
labelData.push([]);
Expand Down
25 changes: 15 additions & 10 deletions modules/xerte/parent_templates/Nottingham/models_html5/nav.html
Expand Up @@ -122,16 +122,21 @@
var popLocation = "common_html5/js/popcorn/"
var scriptsToLoad = ["popcorn-complete", "plugins/popcorn.mediaconstructor"];
var i = 0;
scriptsToLoad.forEach(function(file){
$.getScript(x_templateLocation + popLocation + file + ".js")
.done(function(){
if (++i >= scriptsToLoad.length)
nav.setUp();
})
.fail(function( jqxhr, settings, exception ) {
console.log("Failed to load plugin:" + exception);
});
});
if (!xot_offline) {
scriptsToLoad.forEach(function (file) {
$.getScript(x_templateLocation + popLocation + file + ".js")
.done(function () {
if (++i >= scriptsToLoad.length)
nav.setUp();
})
.fail(function (jqxhr, settings, exception) {
console.log("Failed to load plugin:" + exception);
});
});
}
else {
nav.setUp();
}
}

this.setUp = function() {
Expand Down
Expand Up @@ -84,16 +84,21 @@
var popLocation = "common_html5/js/popcorn/"
var scriptsToLoad = ["popcorn-complete", "plugins/popcorn.mediaconstructor"];
var i = 0;
scriptsToLoad.forEach(function(file){
$.getScript(x_templateLocation + popLocation + file + ".js")
.done(function(){
if (++i >= scriptsToLoad.length)
perspectives.setUp();
})
.fail(function( jqxhr, settings, exception ) {
console.log("Failed to load plugin:" + exception);
});
});
if (!xot_offline) {
scriptsToLoad.forEach(function (file) {
$.getScript(x_templateLocation + popLocation + file + ".js")
.done(function () {
if (++i >= scriptsToLoad.length)
perspectives.setUp();
})
.fail(function (jqxhr, settings, exception) {
console.log("Failed to load plugin:" + exception);
});
});
}
else {
perspectives.setUp();
}
}

this.setUp = function() {
Expand Down
Expand Up @@ -74,16 +74,22 @@
var popLocation = "common_html5/js/popcorn/"
var scriptsToLoad = ["popcorn-complete", "plugins/popcorn.mediaconstructor"];
var i = 0;
scriptsToLoad.forEach(function(file){
$.getScript(x_templateLocation + popLocation + file + ".js")
.done(function(){
if (++i >= scriptsToLoad.length)
textVideo.setUp();
})
.fail(function( jqxhr, settings, exception ) {
console.log("Failed to load plugin:" + exception);
});
});
if(!xot_offline) {
scriptsToLoad.forEach(function (file) {
$.getScript(x_templateLocation + popLocation + file + ".js")
.done(function () {
if (++i >= scriptsToLoad.length)
textVideo.setUp();
})
.fail(function (jqxhr, settings, exception) {
console.log("Failed to load plugin:" + exception);
});
});
}
else
{
textVideo.setUp();
}
}

this.setUp = function() {
Expand Down
Expand Up @@ -55,16 +55,18 @@
var popLocation = "common_html5/js/popcorn/"
var scriptsToLoad = ["popcorn-complete", "plugins/popcorn.mediaconstructor"];
var i = 0;
scriptsToLoad.forEach(function(file){
$.getScript(x_templateLocation + popLocation + file + ".js")
.done(function(){
if (++i >= scriptsToLoad.length)
videoSynch.setUp();
})
.fail(function( jqxhr, settings, exception ) {
console.log("Failed to load plugin:" + exception);
});
});
if(!xot_offline) {
scriptsToLoad.forEach(function (file) {
$.getScript(x_templateLocation + popLocation + file + ".js")
.done(function () {
if (++i >= scriptsToLoad.length)
videoSynch.setUp();
})
.fail(function (jqxhr, settings, exception) {
console.log("Failed to load plugin:" + exception);
});
});
}
}

this.setUp = function() {
Expand Down
25 changes: 15 additions & 10 deletions modules/xerte/parent_templates/Nottingham/models_html5/youtube.html
Expand Up @@ -37,16 +37,21 @@
var popLocation = "common_html5/js/popcorn/"
var scriptsToLoad = ["popcorn-complete", "plugins/popcorn.mediaconstructor"];
var i = 0;
scriptsToLoad.forEach(function(file){
$.getScript(x_templateLocation + popLocation + file + ".js")
.done(function(){
if (++i >= scriptsToLoad.length)
youtube.setUp();
})
.fail(function( jqxhr, settings, exception ) {
console.log("Failed to load plugin:" + exception);
});
});
if(!xot_offline) {
scriptsToLoad.forEach(function (file) {
$.getScript(x_templateLocation + popLocation + file + ".js")
.done(function () {
if (++i >= scriptsToLoad.length)
youtube.setUp();
})
.fail(function (jqxhr, settings, exception) {
console.log("Failed to load plugin:" + exception);
});
});
}
else {
youtube.setUp();
}
}

this.setUp = function() {
Expand Down
6 changes: 4 additions & 2 deletions website_code/php/scorm/scorm2004_library.php
Expand Up @@ -208,7 +208,7 @@ function scorm2004_html_page_create($id, $name, $type, $rlo_file, $lo_name, $lan

}

function scorm2004_html5_page_create($id, $type, $parent_name, $lo_name, $language, $date_modified, $date_created, $need_download_url=false, $logo=''){
function scorm2004_html5_page_create($id, $type, $parent_name, $lo_name, $language, $date_modified, $date_created, $need_download_url=false, $logo='', $plugins=''){

global $xerte_toolkits_site, $dir_path, $delete_file_array, $zipfile, $youtube_api_key;

Expand Down Expand Up @@ -237,8 +237,10 @@ function scorm2004_html5_page_create($id, $type, $parent_name, $lo_name, $langua
$scorm_html_page_content = str_replace("%USE_URL%", "var use_url=true;", $scorm_html_page_content);
$scorm_html_page_content = str_replace("%GLOBALHIDESOCIAL%", $xerte_toolkits_site->globalhidesocial, $scorm_html_page_content);
$scorm_html_page_content = str_replace("%GLOBALSOCIALAUTH%", $xerte_toolkits_site->globalsocialauth, $scorm_html_page_content);
$scorm_html_page_content = str_replace("%PLUGINS%", 'var plugins=' . json_encode($plugins), $scorm_html_page_content);

$tracking = "<script type=\"text/javascript\" src=\"apiwrapper_2004.3rd.js?version=" . $version . "\"></script>\n";

$tracking = "<script type=\"text/javascript\" src=\"apiwrapper_2004.3rd.js?version=" . $version . "\"></script>\n";
$tracking .= "<script type=\"text/javascript\" src=\"xttracking_scorm2004.3rd.js?version=" . $version . "\"></script>\n";
$tracking .= "<script type=\"text/javascript\" src=\"languages/js/en-GB/xttracking_scorm2004.3rd.js?version=" . $version . "\"></script>\n";
if (file_exists($dir_path . "languages/js/" . $language . "/xttracking_scorm2004.3rd.js"))
Expand Down
8 changes: 6 additions & 2 deletions website_code/php/scorm/scorm_library.php
Expand Up @@ -208,14 +208,16 @@ function scorm_html_page_create($id, $name, $type, $rlo_file, $lo_name, $languag
* @version 1.0
* @author Patrick Lockley
*/
function basic_html5_page_create($id, $type, $parent_name, $lo_name, $date_modified, $date_created, $tsugi=false, $offline=false, $offline_includes="", $need_download_url=false, $logo='', $logo_r='') {
function basic_html5_page_create($id, $type, $parent_name, $lo_name, $date_modified, $date_created, $tsugi=false, $offline=false, $offline_includes="", $need_download_url=false, $logo='', $logo_r='', $plugins='') {

global $xerte_toolkits_site, $dir_path, $delete_file_array, $zipfile;

$version = getVersion();
$language = $_SESSION['toolkits_language'];
$language_ISO639_1code = substr($language, 0, 2);



$buffer = file_get_contents($xerte_toolkits_site->basic_template_path . $type . "/player_html5/rloObject.htm");

$buffer = str_replace("%TWITTERCARD%", "",$buffer);
Expand Down Expand Up @@ -255,6 +257,7 @@ function basic_html5_page_create($id, $type, $parent_name, $lo_name, $date_modif
$buffer = str_replace("%USE_URL%", "var use_url=true;", $buffer);
$buffer = str_replace("%GLOBALHIDESOCIAL%", $xerte_toolkits_site->globalhidesocial, $buffer);
$buffer = str_replace("%GLOBALSOCIALAUTH%", $xerte_toolkits_site->globalsocialauth, $buffer);
$buffer = str_replace("%PLUGINS%", 'var plugins=' . json_encode($plugins), $buffer);

$index = "index.htm";

Expand All @@ -279,7 +282,7 @@ function basic_html5_page_create($id, $type, $parent_name, $lo_name, $date_modif
* @version 1.0
* @author Patrick Lockley
*/
function scorm_html5_page_create($id, $type, $parent_name, $lo_name, $language, $date_modified, $date_created, $need_download_url=false, $logo='') {
function scorm_html5_page_create($id, $type, $parent_name, $lo_name, $language, $date_modified, $date_created, $need_download_url=false, $logo='', $plugins='') {

global $xerte_toolkits_site, $dir_path, $delete_file_array, $zipfile, $youtube_api_key;

Expand Down Expand Up @@ -307,6 +310,7 @@ function scorm_html5_page_create($id, $type, $parent_name, $lo_name, $language,
$scorm_html_page_content = str_replace("%USE_URL%", "var use_url=true;", $scorm_html_page_content);
$scorm_html_page_content = str_replace("%GLOBALHIDESOCIAL%", $xerte_toolkits_site->globalhidesocial, $scorm_html_page_content);
$scorm_html_page_content = str_replace("%GLOBALSOCIALAUTH%", $xerte_toolkits_site->globalsocialauth, $scorm_html_page_content);
$scorm_html_page_content = str_replace("%PLUGINS%", 'var plugins=' . json_encode($plugins), $scorm_html_page_content);


$tracking = "<script type=\"text/javascript\" src=\"apiwrapper_1.2.js\"></script>\n";
Expand Down

0 comments on commit 3110854

Please sign in to comment.