2014-04-01 74 views
0

我正在與Adobe Captivate一起創建SCORM兼容包。要求是我只需要跟蹤用戶(學習者)正在觀看視頻的時間(total_time)。SCORM 1.2 Javascript函數

我已經在頁面上對媒體播放進行了分條並插入了兩個按鈕。一個開始播放視頻,另一個暫停播放。我現在正在尋找一個javascript函數,我可以打電話爲了開始時間,(在頁面加載和點擊PLAY按鈕並停止它在暫停。

這樣的命令是否存在,是這個要做到這一點的最好辦法

感謝

回答

2

雖然我沒有Captivate的過程中測試了這一點上,我使用了一些文件有關SCORM代碼Captivate的

我創建了四個功能? - 一個是電影開始時,一個是暫停時,一個是當課程即將關閉,需要計算時間和一個格式化scorm的時間,這是一個簡單的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 

參考:看herehere(滾動,直到看到cmi.core.session_time)

添加以下代碼的腳本標籤的末尾:

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 


正如我所說,我沒有迷人的課程代碼。如果你在某個地方發佈,我可以進一步幫助你。

+0

謝謝..我仍在與Captivate一起實施它,但我知道需要做些什麼才能使其發揮作用。 – sivilian