@didask/scol-r 2.0.0 → 2.1.1

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;
@@ -20,6 +20,16 @@ var SCORMAdapter = /** @class */ (function () {
20
20
  enumerable: false,
21
21
  configurable: true
22
22
  });
23
+ SCORMAdapter.prototype._initialize = function () {
24
+ if (this._isSCORM2004) {
25
+ this.LMSSetValue("cmi.score.min", 0);
26
+ this.LMSSetValue("cmi.score.max", 100);
27
+ }
28
+ else {
29
+ this.LMSSetValue("cmi.core.score.min", 0);
30
+ this.LMSSetValue("cmi.core.score.max", 100);
31
+ }
32
+ };
23
33
  SCORMAdapter.prototype._findAndSetAPI = function () {
24
34
  var _this = this;
25
35
  if (typeof window === "undefined") {
@@ -116,6 +126,9 @@ var SCORMAdapter = /** @class */ (function () {
116
126
  (this._isSCORM2004
117
127
  ? lastErrorCode === 103 // 103 in 2004.* = already initialized
118
128
  : lastErrorCode === 101); // 101 in 1.2 = already initialized
129
+ if (success) {
130
+ this._initialize();
131
+ }
119
132
  return success || this._handleError(functionName);
120
133
  };
121
134
  SCORMAdapter.prototype.LMSTerminate = function () {
@@ -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.1",
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",