Iframe中的SCORM课程可以'找不到API
SCORM Course in Iframe can't find API
(我是SCORM和Web开发的新手,如果我没有很好地解释,请原谅。)
我正在尝试运行一些SCORM课程,并一直在遵循本教程:http://www.vsscorm.net/2009/05/31/getting-started-the-rte-frameset/
然而,在本教程中,他们使用框架集和框架来建立从课程到API实现的连接。我需要在iframe中运行我的课程,并且不知道在哪里/如何放置我的API文档,这样我的SCORM课程就可以找到它并连接到它,有人知道怎么做吗?
在典型的SCORM课程中,当课程内容加载到子框架(iframe)中时,API连接在父框架中保持。iframe中的内容可以随意加载和卸载;iframe中的内容往往包含您希望在课程的整个生命周期内进行的重要SCORM调用,例如分数和完成状态,但它们将通过将信息中继到拥有与LMS通信的父框架来实现。
以下是使用SCORM 1.2的快速示例(未在LMS中测试,需要充实)
index.html(父帧)
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Course Title</title>
<style>
/* Use CSS to make the iframe fill the parent frame,
giving impression no frames are being used */
body { padding: 0; margin: 0; overflow: hidden; }
iframe { position: absolute; top: 0; right: 0; bottom: 0; left: 0; overflow: auto; }
</style>
</head>
<body>
<iframe src="" id="course-content" frameborder="0"></iframe>
<script>
//Place initialization routine here.
//Connect to SCORM API, run API.LMSInitialize()
var SCORM_API = window.API; //shortcut reference
function setScore(score){
SCORM_API.LMSSetValue("cmi.core.score.raw", score);
}
function setStatus(status){
SCORM_API.LMSSetValue("cmi.core.lesson_status", status);
}
function endCourse(){
SCORM_API.LMSCommit();//Save, just in case
SCORM_API.LMSFinish();//Close API connection
}
SCORM_API.LMSInitialize();
//Load child frame once SCORM_API is ready
document.getElementById("course-content").setAttribute("src", "content.html");
</script>
</body>
</html>
content.html(子帧)
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Course Content</title>
</head>
<body>
<p>This is the content of the course. Add scripts to make it do something.</p>
<script>
//Place course functionality here, such as setting a bookmark or score.
//'parent' is the parent frame.
//This is a very arbitrary example of what you can do when a course loads
parent.setScore("100");
parent.setStatus("completed");
parent.endCourse();
</script>
</body>
</html>
您通常希望使用SCORM包装来处理一些繁重的工作,并且希望使用抽象层来提高代码可维护性,并将SCORM命令集中在父框架中。endCourse()
函数是抽象层的一个非常简单的例子。不是直接在子框架中调用API,而是调用一个函数。
相关文章:
- 气质的“nestRemoting()”有时可以'找不到关系
- 错误405:向Java控制器(Ajax)发送JSON时找不到POST方法
- 找不到模块捆绑包
- for循环中的javascript if语句找不到==
- 为什么JavaScript可以'找不到给定的InnerHTML并返回Cannot set property
- 失败:等待Protractor与页面同步时出错:“”;在窗口上找不到角度”;
- Babel编译错误:找不到模块核心js/library/fn/get迭代器
- [Vue warn]:找不到元素
- ngRoute找不到模板
- 未能加载,因为找不到支持的源.当播放HTML5音频元素时
- 因果报应-找不到模块:错误:无法解析模块'scs'
- Angular 2:在本地.json文件上找不到文件
- 找不到Intel XDK cordova文件api 1.3.3文件
- 设置快速路由,找不到API调用返回404
- Iframe中的SCORM课程可以'找不到API
- Web API:找不到方法和不允许的方法
- Google嵌入式分析API-找不到OAuth客户端
- 这看起来很简单,但是我在jquery API中找不到所需的函数
- Web API路由404:在匹配的控制器上找不到任何操作
- 找不到OAuth客户端.谷歌登录api