使用 SCORM 1.2 注册和检索 'interactions'
Registering and retrieving 'interactions' with SCORM 1.2
我们在之前的电子学习中一直使用 SCORM 'engine',但我们想要更改托管学习环境 (MLE) 跟踪的元素,即电子学习模块中的每个可完成组件。
在运行时,我们运行使用以下代码来设置我们的 SCORM 连接:
var vault = {}; //vault 'namespace' helps ensure no conflicts with possible other "SCORM" variables
vault.UTILS = {}; //For holding UTILS functions
vault.debug = { isActive: true }; //Enable (true) or disable (false) for debug mode
vault.SCORM = { //Define the SCORM object
version: null, //Store SCORM version.
handleCompletionStatus: true, //Whether or not the wrapper should automatically handle the initial completion status
handleExitMode: true, //Whether or not the wrapper should automatically handle the exit mode
API:{handle: null, isFound: false}, //Create API child object
connection: { isActive: false }, //Create connection child object
data: { completionStatus: null, exitStatus: null}, //Create data child object
debug:{} //Create debug child object
};
vault.SCORM.API.find('win');
vault.SCORM.connection.initialize();
if (vault.SCORM.data.get("cmi.core.lesson_status")=="not attempted") {
vault.SCORM.data.set("cmi.core.lesson_status" , "incomplete");
vault.SCORM.data.save();
}
SCORM.js 文件中还有很多函数,但关键是这些都可以用;当模块加载到我们的 MLE 中时,以下代码触发课程完成:
vault.SCORM.data.set("cmi.core.lesson_status" , "completed");
那么我们如何向 SCORM 注册一个可完成的组件呢? (我们 'engine' 中的组件是 jQuery 通常称为 'element' 的对象)。像下面这样的事情是否可行,或者 SCORM 中的自定义调用是不可能的?
vault.SCORM.data.set("cmi.interactions.n."+element.componentId() , "incomplete");
但是如果我通过指定id注册一个交互,如下...
vault.SCORM.data.set("cmi.interactions.n.id", element.componentId());
...我该如何设置或访问该组件上的 'completion'?
我一直在阅读来自各个站点的帖子和 pdf 规格,但充其量解释也很少。
我知道这里没有很多 SCORM 追随者,但如果您有任何信息,我很想听听。
FWIW,这是我的 pipwerks SCORM 包装器,但变量 pipwerks
更改为 ncalt
。
http://pipwerks.com (search for "scorm wrapper" in the search field). The original source code can be found at https://github.com/pipwerks/scorm-api-wrapper.
上有关于如何使用我的包装器的文档
请注意,您的示例代码并未按照预期的方式使用包装器。例如,这个:
ncalt.SCORM.data.set("cmi.core.lesson_status" , "completed");
应该是这样的(data
是内部帮手,不是必须的):
ncalt.SCORM.set("cmi.core.lesson_status" , "completed");
您可以通过参考变量进一步缩短它,如下所示:
var scorm = ncalt.SCORM;
scorm.set("cmi.core.lesson_status" , "completed");
scorm.save();
scorm.get("cmi.core.lesson_status"); //returns "completed"
至于您的 'components',如果您想使用 SCORM 的 cmi.interactions
模型,请确保您使用的是正确的语法。 SCORM 文档 (cmi.interactions.n.id
) 中的 "n" 用于表示数字,而不是文字 "n".
scorm.set("cmi.interactions.0.id", "myfirstinteraction");
scorm.save();
要从该交互中检索数据,您需要指定数字来代替 n:
scorm.get("cmi.interactions.0.id"); //returns "myfirstinteraction"
请注意,CMI 数据模型不为 cmi.interactions
提供 'status' 字段。您需要使用 cmi.objectives
.
scorm.set("cmi.objectives.0.status", "completed");
scorm.save();
scorm.get("cmi.objectives.0.status"); // returns "completed"
CMI 数据模型(在 SCORM 中可用)在此处详细说明:http://scorm.com/scorm-explained/technical-scorm/run-time/run-time-reference/
我们在之前的电子学习中一直使用 SCORM 'engine',但我们想要更改托管学习环境 (MLE) 跟踪的元素,即电子学习模块中的每个可完成组件。
在运行时,我们运行使用以下代码来设置我们的 SCORM 连接:
var vault = {}; //vault 'namespace' helps ensure no conflicts with possible other "SCORM" variables
vault.UTILS = {}; //For holding UTILS functions
vault.debug = { isActive: true }; //Enable (true) or disable (false) for debug mode
vault.SCORM = { //Define the SCORM object
version: null, //Store SCORM version.
handleCompletionStatus: true, //Whether or not the wrapper should automatically handle the initial completion status
handleExitMode: true, //Whether or not the wrapper should automatically handle the exit mode
API:{handle: null, isFound: false}, //Create API child object
connection: { isActive: false }, //Create connection child object
data: { completionStatus: null, exitStatus: null}, //Create data child object
debug:{} //Create debug child object
};
vault.SCORM.API.find('win');
vault.SCORM.connection.initialize();
if (vault.SCORM.data.get("cmi.core.lesson_status")=="not attempted") {
vault.SCORM.data.set("cmi.core.lesson_status" , "incomplete");
vault.SCORM.data.save();
}
SCORM.js 文件中还有很多函数,但关键是这些都可以用;当模块加载到我们的 MLE 中时,以下代码触发课程完成:
vault.SCORM.data.set("cmi.core.lesson_status" , "completed");
那么我们如何向 SCORM 注册一个可完成的组件呢? (我们 'engine' 中的组件是 jQuery 通常称为 'element' 的对象)。像下面这样的事情是否可行,或者 SCORM 中的自定义调用是不可能的?
vault.SCORM.data.set("cmi.interactions.n."+element.componentId() , "incomplete");
但是如果我通过指定id注册一个交互,如下...
vault.SCORM.data.set("cmi.interactions.n.id", element.componentId());
...我该如何设置或访问该组件上的 'completion'?
我一直在阅读来自各个站点的帖子和 pdf 规格,但充其量解释也很少。
我知道这里没有很多 SCORM 追随者,但如果您有任何信息,我很想听听。
FWIW,这是我的 pipwerks SCORM 包装器,但变量 pipwerks
更改为 ncalt
。
http://pipwerks.com (search for "scorm wrapper" in the search field). The original source code can be found at https://github.com/pipwerks/scorm-api-wrapper.
上有关于如何使用我的包装器的文档请注意,您的示例代码并未按照预期的方式使用包装器。例如,这个:
ncalt.SCORM.data.set("cmi.core.lesson_status" , "completed");
应该是这样的(data
是内部帮手,不是必须的):
ncalt.SCORM.set("cmi.core.lesson_status" , "completed");
您可以通过参考变量进一步缩短它,如下所示:
var scorm = ncalt.SCORM;
scorm.set("cmi.core.lesson_status" , "completed");
scorm.save();
scorm.get("cmi.core.lesson_status"); //returns "completed"
至于您的 'components',如果您想使用 SCORM 的 cmi.interactions
模型,请确保您使用的是正确的语法。 SCORM 文档 (cmi.interactions.n.id
) 中的 "n" 用于表示数字,而不是文字 "n".
scorm.set("cmi.interactions.0.id", "myfirstinteraction");
scorm.save();
要从该交互中检索数据,您需要指定数字来代替 n:
scorm.get("cmi.interactions.0.id"); //returns "myfirstinteraction"
请注意,CMI 数据模型不为 cmi.interactions
提供 'status' 字段。您需要使用 cmi.objectives
.
scorm.set("cmi.objectives.0.status", "completed");
scorm.save();
scorm.get("cmi.objectives.0.status"); // returns "completed"
CMI 数据模型(在 SCORM 中可用)在此处详细说明:http://scorm.com/scorm-explained/technical-scorm/run-time/run-time-reference/