gpt4 book ai didi

javascript - SCORM 1.2 JavaScript 函数

转载 作者:行者123 更新时间:2023-11-28 19:54:42 36 4
gpt4 key购买 nike

我正在与 Adob​​e Captivate 合作创建简单的 SCORM 兼容包。要求是我只需要跟踪用户(学习者)观看视频的时间(total_time)。

我在页面上对媒体播放进行了 strip 化​​,并插入了两个按钮。一个用于开始播放视频,另一个用于暂停视频。我现在正在寻找一个 JavaScript 函数,我可以调用它来启动时间(在页面加载和单击“播放”按钮上并在“暂停”时停止它。

这样的命令是否存在,这是执行此操作的最佳方法吗?

谢谢

最佳答案

虽然我没有 Captivate 类(class)来测试这一点,但我使用了一些有关 captivate SCORM 代码的文档

我创建了四个函数 - 一个是电影开始时的函数,一个是暂停时的函数,一个是类(class)即将结束且需要计算时间的函数,还有一个用于格式化 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

引用文献:参见here或者 here (滚动直到看到 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


正如我所提到的,我没有 captivate 类(class)代码。如果您将其发布到某个地方,我可以进一步帮助您。

关于javascript - SCORM 1.2 JavaScript 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22791526/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com