@didask/scol-r 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,7 @@ export declare class SCORMAdapter {
5
5
  private _ignorableErrorCodes;
6
6
  constructor(errorCallback?: Function);
7
7
  get foundAPI(): boolean;
8
+ private _initialize;
8
9
  private _findAndSetAPI;
9
10
  private _findAPIInWindow;
10
11
  private _callAPIFunction;
@@ -12,6 +12,9 @@ var SCORMAdapter = /** @class */ (function () {
12
12
  this._isSCORM2004 = false;
13
13
  this._errorCallback = errorCallback;
14
14
  this._findAndSetAPI();
15
+ if (this._API) {
16
+ this._initialize();
17
+ }
15
18
  }
16
19
  Object.defineProperty(SCORMAdapter.prototype, "foundAPI", {
17
20
  get: function () {
@@ -20,6 +23,16 @@ var SCORMAdapter = /** @class */ (function () {
20
23
  enumerable: false,
21
24
  configurable: true
22
25
  });
26
+ SCORMAdapter.prototype._initialize = function () {
27
+ if (this._isSCORM2004) {
28
+ this.LMSSetValue("cmi.score.min", 0);
29
+ this.LMSSetValue("cmi.score.max", 100);
30
+ }
31
+ else {
32
+ this.LMSSetValue("cmi.core.score.min", 0);
33
+ this.LMSSetValue("cmi.core.score.max", 100);
34
+ }
35
+ };
23
36
  SCORMAdapter.prototype._findAndSetAPI = function () {
24
37
  var _this = this;
25
38
  if (typeof window === "undefined") {
@@ -160,10 +173,13 @@ var SCORMAdapter = /** @class */ (function () {
160
173
  return this.LMSGetValue(CMIVariableName);
161
174
  };
162
175
  SCORMAdapter.prototype.setScore = function (score) {
163
- var CMIVariableName = this._isSCORM2004
164
- ? "cmi.score.raw"
165
- : "cmi.core.score.raw";
166
- this.LMSSetValue(CMIVariableName, score);
176
+ if (this._isSCORM2004) {
177
+ this.LMSSetValue("cmi.score.raw", score);
178
+ this.LMSSetValue("cmi.score.scaled", score / 100);
179
+ }
180
+ else {
181
+ this.LMSSetValue("cmi.core.score.raw", score);
182
+ }
167
183
  };
168
184
  SCORMAdapter.prototype.getScore = function () {
169
185
  var CMIVariableName = this._isSCORM2004
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@didask/scol-r",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Shareable Cross-Origin Learning Resources",
5
5
  "main": "index.html",
6
6
  "types": "lib/index.d.ts",
@@ -8,7 +8,8 @@
8
8
  "lib/"
9
9
  ],
10
10
  "scripts": {
11
- "build": "tsc"
11
+ "build": "tsc",
12
+ "clean": "rm -rf node_modules lib"
12
13
  },
13
14
  "repository": {
14
15
  "type": "git",