[英]SCORM 1.2 Javascript functions
我正在與Adobe Captivate合作創建一個簡單的SCORM兼容軟件包。 要求是我只需要跟蹤用戶(學習者)正在觀看視頻的時間(total_time)。
我在頁面上划分了媒體播放的條紋,並插入了兩個按鈕。 一個開始播放視頻,另一個開始暫停視頻。 我現在正在尋找一個可以調用以啟動時間的javascript函數(在頁面加載和PLAY按鈕上單擊,然后在PAUSE上停止它)。
是否存在這樣的命令,這是執行此命令的最佳方法嗎?
謝謝
雖然我沒有Captivate課程來進行測試,但是我使用了一些有關SCORM代碼的文檔來進行Captivate
我創建了四個功能-一個功能是在電影開始時,一個功能在暫停時,一個功能在課程即將關閉並且需要計算時間時使用,另一個功能是格式化時間,這是一個簡單的HH:MM:SS。 S. 格式。
Note: that you mentioned total_time or cmi.core.total_time, this is a read only
attribute, a course should send the session time and the LMS computes the
cmi.core.total_time
參考:請在此處或此處 (滾動直到看到cmi.core.session_time)
在script標記的末尾添加以下代碼:
var mod_elapsedSeconds = 0;
var mod_startTime;
function sco_start(){
if ( mod_startTime != 0 )
{
var currentDate = new Date().getTime();
mod_elapsedSeconds += ( (currentDate - mod_startTime) / 1000 );
}
mod_startTime = new Date().getTime();
}
function sco_pause(){
if ( mod_startTime != 0 )
{
var currentDate = new Date().getTime();
mod_elapsedSeconds += ( (currentDate - mod_startTime) / 1000 );
}
mod_startTime = 0;
}
function onB4LMSFinish(){
if ( mod_startTime != 0 )
{
var currentDate = new Date().getTime();
mod_elapsedSeconds += ( (currentDate - mod_startTime) / 1000 );
var formattedTime = convertTotalSeconds( mod_elapsedSeconds );
}
else
{
formattedTime = "00:00:00.0";
}
Captivate_DoFSCommand( "cmi.core.session_time", formattedTime );
}
function convertTotalSeconds(ts)
{
var sec = (ts % 60);
ts -= sec;
var tmp = (ts % 3600); //# of seconds in the total # of minutes
ts -= tmp; //# of seconds in the total # of hours
// convert seconds to conform to CMITimespan type (e.g. SS.00)
sec = Math.round(sec*100)/100;
var strSec = new String(sec);
var strWholeSec = strSec;
var strFractionSec = "";
if (strSec.indexOf(".") != -1)
{
strWholeSec = strSec.substring(0, strSec.indexOf("."));
strFractionSec = strSec.substring(strSec.indexOf(".")+1, strSec.length);
}
if (strWholeSec.length < 2)
{
strWholeSec = "0" + strWholeSec;
}
strSec = strWholeSec;
if (strFractionSec.length)
{
strSec = strSec+ "." + strFractionSec;
}
if ((ts % 3600) != 0 )
var hour = 0;
else var hour = (ts / 3600);
if ( (tmp % 60) != 0 )
var min = 0;
else var min = (tmp / 60);
if ((new String(hour)).length < 2)
hour = "0"+hour;
if ((new String(min)).length < 2)
min = "0"+min;
var rtnVal = hour+":"+min+":"+strSec;
return rtnVal;
}
更改看起來像這樣的標簽:
<body bgcolor="#f5f4f1" onunload="Finish();">
至:
<body bgcolor="#f5f4f1" onunload="onB4LMSFinish();Finish();">
將這些功能添加到開始和暫停按鈕:
sco_start(); // for starting the video
sco_pause(); // for pausing
正如我提到的,我沒有迷人的課程代碼。 如果您將其發布在某個地方,我可以為您提供進一步的幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.