@vived/app 4.28.1 → 4.28.2

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.
Files changed (25) hide show
  1. package/lib/Components/Question/Adapters/index.d.ts +2 -0
  2. package/lib/Components/Question/Adapters/index.js +14 -0
  3. package/lib/Components/Question/Adapters/questionAnswerAdapter.d.ts +3 -0
  4. package/lib/Components/Question/Adapters/questionAnswerAdapter.js +27 -0
  5. package/lib/Components/Question/Adapters/questionChallengeAdapter.d.ts +3 -0
  6. package/lib/Components/Question/Adapters/questionChallengeAdapter.js +23 -0
  7. package/lib/Components/Question/Factories/index.d.ts +2 -0
  8. package/lib/Components/Question/Factories/index.js +14 -0
  9. package/lib/Components/Question/Factories/setupQuestionAnswer.d.ts +3 -0
  10. package/lib/Components/Question/Factories/setupQuestionAnswer.js +18 -0
  11. package/lib/Components/Question/Factories/setupQuestionChallenge.d.ts +3 -0
  12. package/lib/Components/Question/Factories/setupQuestionChallenge.js +20 -0
  13. package/lib/Components/Question/Mocks/QuestionAnswerPmMock.d.ts +7 -0
  14. package/lib/Components/Question/Mocks/QuestionAnswerPmMock.js +11 -0
  15. package/lib/Components/Question/Mocks/QuestionChallengePmMock.d.ts +8 -0
  16. package/lib/Components/Question/Mocks/QuestionChallengePmMock.js +15 -0
  17. package/lib/Components/Question/Mocks/index.d.ts +2 -0
  18. package/lib/Components/Question/Mocks/index.js +2 -0
  19. package/lib/Components/Question/PM/QuestionAnswerPM.d.ts +4 -6
  20. package/lib/Components/Question/PM/QuestionAnswerPM.js +20 -7
  21. package/lib/Components/Question/PM/QuestionChallengePM.d.ts +2 -7
  22. package/lib/Components/Question/PM/QuestionChallengePM.js +18 -8
  23. package/lib/Components/Question/index.d.ts +2 -0
  24. package/lib/Components/Question/index.js +2 -0
  25. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ export * from "./questionAnswerAdapter";
2
+ export * from "./questionChallengeAdapter";
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./questionAnswerAdapter"), exports);
14
+ __exportStar(require("./questionChallengeAdapter"), exports);
@@ -0,0 +1,3 @@
1
+ import { PmAdapter } from "../../../Types";
2
+ import { QuestionAnswerVM } from "../PM/QuestionAnswerPM";
3
+ export declare const questionAnswerAdapter: PmAdapter<QuestionAnswerVM>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.questionAnswerAdapter = void 0;
4
+ const QuestionAnswerPM_1 = require("../PM/QuestionAnswerPM");
5
+ exports.questionAnswerAdapter = {
6
+ defaultVM: QuestionAnswerPM_1.defaultQuestionChallengeAnswerVM,
7
+ subscribe: (id, appObjects, setVM) => {
8
+ if (!id)
9
+ return;
10
+ const pm = QuestionAnswerPM_1.QuestionAnswerPM.getByID(id, appObjects);
11
+ if (!pm) {
12
+ appObjects.submitError("questionAnswerAdapter", "Unable to find QuestionAnswerPM");
13
+ return;
14
+ }
15
+ pm.addView(setVM);
16
+ },
17
+ unsubscribe: (id, appObjects, setVM) => {
18
+ if (!id)
19
+ return;
20
+ const pm = QuestionAnswerPM_1.QuestionAnswerPM.getByID(id, appObjects);
21
+ if (!pm) {
22
+ appObjects.submitError("questionAnswerAdapter", "Unable to find QuestionAnswerPM");
23
+ return;
24
+ }
25
+ pm.removeView(setVM);
26
+ },
27
+ };
@@ -0,0 +1,3 @@
1
+ import { SingletonPmAdapter } from "../../../Types";
2
+ import { QuestionChallengeVM } from "../PM/QuestionChallengePM";
3
+ export declare const questionChallengeAdapter: SingletonPmAdapter<QuestionChallengeVM>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.questionChallengeAdapter = void 0;
4
+ const QuestionChallengePM_1 = require("../PM/QuestionChallengePM");
5
+ exports.questionChallengeAdapter = {
6
+ defaultVM: QuestionChallengePM_1.defaultQuestionChallengeVM,
7
+ subscribe: (appObjects, setVM) => {
8
+ const pm = QuestionChallengePM_1.QuestionChallengePM.get(appObjects);
9
+ if (!pm) {
10
+ appObjects.submitError("questionChallengeAdapter", "Unable to find QuestionChallengePM");
11
+ return;
12
+ }
13
+ pm.addView(setVM);
14
+ },
15
+ unsubscribe: (appObjects, setVM) => {
16
+ const pm = QuestionChallengePM_1.QuestionChallengePM.get(appObjects);
17
+ if (!pm) {
18
+ appObjects.submitError("questionChallengeAdapter", "Unable to find QuestionChallengePM");
19
+ return;
20
+ }
21
+ pm.removeView(setVM);
22
+ },
23
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./setupQuestionAnswer";
2
+ export * from "./setupQuestionChallenge";
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./setupQuestionAnswer"), exports);
14
+ __exportStar(require("./setupQuestionChallenge"), exports);
@@ -0,0 +1,3 @@
1
+ import { AppObjectRepo } from "../../../AppObject";
2
+ import { QuestionAnswerEntity } from "../Entities";
3
+ export declare function setupQuestionAnswer(appObjects: AppObjectRepo, id?: string): QuestionAnswerEntity;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupQuestionAnswer = void 0;
4
+ const Utilities_1 = require("../../../Utilities");
5
+ const Entities_1 = require("../Entities");
6
+ const PM_1 = require("../PM");
7
+ const UC_1 = require("../UC");
8
+ function setupQuestionAnswer(appObjects, id) {
9
+ const idToUse = id !== null && id !== void 0 ? id : Utilities_1.generateUniqueID();
10
+ const ao = appObjects.getOrCreate(idToUse);
11
+ const answerEntity = Entities_1.makeQuestionAnswerEntity(ao);
12
+ UC_1.makeSetAnswerFeedbackUC(ao);
13
+ UC_1.makeSetAnswerTextUC(ao);
14
+ UC_1.makeToggleQuestionChallengeAnswerIsCorrectUC(ao);
15
+ PM_1.makeQuestionAnswerPM(ao);
16
+ return answerEntity;
17
+ }
18
+ exports.setupQuestionAnswer = setupQuestionAnswer;
@@ -0,0 +1,3 @@
1
+ import { AppObjectRepo } from "../../../AppObject";
2
+ import { QuestionEntity } from "../Entities";
3
+ export declare function setupQuestionChallenge(appObjects: AppObjectRepo): QuestionEntity;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupQuestionChallenge = void 0;
4
+ const Entities_1 = require("../Entities");
5
+ const PM_1 = require("../PM");
6
+ const UC_1 = require("../UC");
7
+ const setupQuestionAnswer_1 = require("./setupQuestionAnswer");
8
+ function setupQuestionChallenge(appObjects) {
9
+ const ao = appObjects.getOrCreate("QuestionChallenge");
10
+ const questionEntity = Entities_1.makeQuestionEntity(ao);
11
+ UC_1.makeAddQuestionAnswerUC(ao);
12
+ UC_1.makeDeleteQuestionAnswerUC(ao);
13
+ UC_1.makeSubmitQuestionAnswerUC(ao);
14
+ new UC_1.SerializeQuestionChallenge(ao);
15
+ UC_1.makeValidateQuestionChallengeStateUC(ao);
16
+ PM_1.makeQuestionChallengePM(ao);
17
+ questionEntity.answerFactory = (id) => setupQuestionAnswer_1.setupQuestionAnswer(appObjects, id);
18
+ return questionEntity;
19
+ }
20
+ exports.setupQuestionChallenge = setupQuestionChallenge;
@@ -0,0 +1,7 @@
1
+ /// <reference types="jest" />
2
+ import { AppObject } from "../../../AppObject";
3
+ import { QuestionAnswerPM } from "../PM/QuestionAnswerPM";
4
+ export declare class QuestionAnswerPmMock extends QuestionAnswerPM {
5
+ vmsAreEqual: jest.Mock<any, any>;
6
+ constructor(appObject: AppObject);
7
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuestionAnswerPmMock = void 0;
4
+ const QuestionAnswerPM_1 = require("../PM/QuestionAnswerPM");
5
+ class QuestionAnswerPmMock extends QuestionAnswerPM_1.QuestionAnswerPM {
6
+ constructor(appObject) {
7
+ super(appObject, QuestionAnswerPM_1.QuestionAnswerPM.type);
8
+ this.vmsAreEqual = jest.fn();
9
+ }
10
+ }
11
+ exports.QuestionAnswerPmMock = QuestionAnswerPmMock;
@@ -0,0 +1,8 @@
1
+ /// <reference types="jest" />
2
+ import { AppObject, AppObjectRepo } from "../../../AppObject";
3
+ import { QuestionChallengePM } from "../PM/QuestionChallengePM";
4
+ export declare class QuestionChallengePmMock extends QuestionChallengePM {
5
+ vmsAreEqual: jest.Mock<any, any>;
6
+ constructor(appObject: AppObject);
7
+ }
8
+ export declare function makeQuestionChallengePmMock(appObjects: AppObjectRepo): QuestionChallengePmMock;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeQuestionChallengePmMock = exports.QuestionChallengePmMock = void 0;
4
+ const QuestionChallengePM_1 = require("../PM/QuestionChallengePM");
5
+ class QuestionChallengePmMock extends QuestionChallengePM_1.QuestionChallengePM {
6
+ constructor(appObject) {
7
+ super(appObject, QuestionChallengePM_1.QuestionChallengePM.type);
8
+ this.vmsAreEqual = jest.fn();
9
+ }
10
+ }
11
+ exports.QuestionChallengePmMock = QuestionChallengePmMock;
12
+ function makeQuestionChallengePmMock(appObjects) {
13
+ return new QuestionChallengePmMock(appObjects.getOrCreate("QuestionChallengePmMock"));
14
+ }
15
+ exports.makeQuestionChallengePmMock = makeQuestionChallengePmMock;
@@ -1,2 +1,4 @@
1
1
  export * from "./MockQuestionAnswerEntity";
2
2
  export * from "./MockValidateQuestion";
3
+ export * from "./QuestionAnswerPmMock";
4
+ export * from "./QuestionChallengePmMock";
@@ -12,3 +12,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./MockQuestionAnswerEntity"), exports);
14
14
  __exportStar(require("./MockValidateQuestion"), exports);
15
+ __exportStar(require("./QuestionAnswerPmMock"), exports);
16
+ __exportStar(require("./QuestionChallengePmMock"), exports);
@@ -1,3 +1,4 @@
1
+ import { AppObjectRepo } from "../../../AppObject";
1
2
  import { AppObject } from "../../../AppObject/AppObject";
2
3
  import { AppObjectPM } from "../../../AppObject/AppObjectPM";
3
4
  export declare const defaultQuestionChallengeAnswerVM: QuestionAnswerVM;
@@ -8,12 +9,9 @@ export interface QuestionAnswerVM {
8
9
  textValidation?: string;
9
10
  feedbackValidation?: string;
10
11
  }
11
- export declare class QuestionAnswerPM extends AppObjectPM<QuestionAnswerVM> {
12
+ export declare abstract class QuestionAnswerPM extends AppObjectPM<QuestionAnswerVM> {
12
13
  static readonly type = "QuestionAnswerPM";
13
14
  static get(appObject: AppObject): QuestionAnswerPM | undefined;
14
- private answer?;
15
- vmsAreEqual(a: QuestionAnswerVM, b: QuestionAnswerVM): boolean;
16
- dispose: () => void;
17
- private onAnswerChange;
18
- constructor(appObject: AppObject);
15
+ static getByID(id: string, appObjects: AppObjectRepo): QuestionAnswerPM | undefined;
19
16
  }
17
+ export declare function makeQuestionAnswerPM(appObject: AppObject): QuestionAnswerPM;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QuestionAnswerPM = exports.defaultQuestionChallengeAnswerVM = void 0;
3
+ exports.makeQuestionAnswerPM = exports.QuestionAnswerPM = exports.defaultQuestionChallengeAnswerVM = void 0;
4
4
  const AppObjectPM_1 = require("../../../AppObject/AppObjectPM");
5
5
  const QuestionAnswerEntity_1 = require("../Entities/QuestionAnswerEntity");
6
6
  exports.defaultQuestionChallengeAnswerVM = {
@@ -9,6 +9,22 @@ exports.defaultQuestionChallengeAnswerVM = {
9
9
  isCorrect: false,
10
10
  };
11
11
  class QuestionAnswerPM extends AppObjectPM_1.AppObjectPM {
12
+ static get(appObject) {
13
+ return appObject.getComponent(QuestionAnswerPM.type);
14
+ }
15
+ static getByID(id, appObjects) {
16
+ var _a;
17
+ return (_a = appObjects
18
+ .get(id)) === null || _a === void 0 ? void 0 : _a.getComponent(QuestionAnswerPM.type);
19
+ }
20
+ }
21
+ exports.QuestionAnswerPM = QuestionAnswerPM;
22
+ QuestionAnswerPM.type = "QuestionAnswerPM";
23
+ function makeQuestionAnswerPM(appObject) {
24
+ return new QuestionAnswerPMImp(appObject);
25
+ }
26
+ exports.makeQuestionAnswerPM = makeQuestionAnswerPM;
27
+ class QuestionAnswerPMImp extends QuestionAnswerPM {
12
28
  constructor(appObject) {
13
29
  super(appObject, QuestionAnswerPM.type);
14
30
  this.dispose = () => {
@@ -29,17 +45,16 @@ class QuestionAnswerPM extends AppObjectPM_1.AppObjectPM {
29
45
  };
30
46
  this.doUpdateView(vm);
31
47
  };
32
- this.answer = appObject.getComponent(QuestionAnswerEntity_1.QuestionAnswerEntity.type);
33
48
  if (this.answer) {
34
49
  this.answer.addChangeObserver(this.onAnswerChange);
35
50
  this.onAnswerChange();
36
51
  }
37
52
  else {
38
- this.warn("QuestionAnswerPM has been added to an app object that does not have QuestionAnswerEntity");
53
+ this.error("QuestionAnswerPM has been added to an app object that does not have QuestionAnswerEntity");
39
54
  }
40
55
  }
41
- static get(appObject) {
42
- return appObject.getComponent(QuestionAnswerPM.type);
56
+ get answer() {
57
+ return this.getCachedLocalComponent(QuestionAnswerEntity_1.QuestionAnswerEntity.type);
43
58
  }
44
59
  vmsAreEqual(a, b) {
45
60
  if (a.answerText !== b.answerText)
@@ -55,5 +70,3 @@ class QuestionAnswerPM extends AppObjectPM_1.AppObjectPM {
55
70
  return true;
56
71
  }
57
72
  }
58
- exports.QuestionAnswerPM = QuestionAnswerPM;
59
- QuestionAnswerPM.type = "QuestionAnswerPM";
@@ -9,13 +9,8 @@ export interface QuestionChallengeVM {
9
9
  reviewFeedback: string;
10
10
  validationMessage?: string;
11
11
  }
12
- export declare class QuestionChallengePM extends AppObjectPM<QuestionChallengeVM> {
12
+ export declare abstract class QuestionChallengePM extends AppObjectPM<QuestionChallengeVM> {
13
13
  static readonly type = "QuestionChallengePM";
14
14
  static get: (appObjects: AppObjectRepo) => QuestionChallengePM | undefined;
15
- private questionEntity?;
16
- private baseAppState?;
17
- private onEntityChange;
18
- vmsAreEqual(a: QuestionChallengeVM, b: QuestionChallengeVM): boolean;
19
- dispose: () => void;
20
- constructor(appObject: AppObject);
21
15
  }
16
+ export declare function makeQuestionChallengePM(appObject: AppObject): QuestionChallengePM;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QuestionChallengePM = exports.defaultQuestionChallengeVM = exports.SLIDE_TEXT_CANNOT_BE_FALSY = void 0;
3
+ exports.makeQuestionChallengePM = exports.QuestionChallengePM = exports.defaultQuestionChallengeVM = exports.SLIDE_TEXT_CANNOT_BE_FALSY = void 0;
4
4
  const AppObject_1 = require("../../../AppObject");
5
5
  const AppObjectPM_1 = require("../../../AppObject/AppObjectPM");
6
6
  const BaseApp_1 = require("../../BaseApp");
@@ -12,6 +12,15 @@ exports.defaultQuestionChallengeVM = {
12
12
  reviewFeedback: "",
13
13
  };
14
14
  class QuestionChallengePM extends AppObjectPM_1.AppObjectPM {
15
+ }
16
+ exports.QuestionChallengePM = QuestionChallengePM;
17
+ QuestionChallengePM.type = "QuestionChallengePM";
18
+ QuestionChallengePM.get = (appObjects) => AppObject_1.getSingletonComponent(QuestionChallengePM.type, appObjects);
19
+ function makeQuestionChallengePM(appObject) {
20
+ return new QuestionChallengePMImp(appObject);
21
+ }
22
+ exports.makeQuestionChallengePM = makeQuestionChallengePM;
23
+ class QuestionChallengePMImp extends QuestionChallengePM {
15
24
  constructor(appObject) {
16
25
  super(appObject, QuestionChallengePM.type);
17
26
  this.onEntityChange = () => {
@@ -39,24 +48,28 @@ class QuestionChallengePM extends AppObjectPM_1.AppObjectPM {
39
48
  (_a = this.questionEntity) === null || _a === void 0 ? void 0 : _a.removeChangeObserver(this.onEntityChange);
40
49
  (_b = this.baseAppState) === null || _b === void 0 ? void 0 : _b.removeChangeObserver(this.onEntityChange);
41
50
  };
42
- this.baseAppState = BaseApp_1.BaseAppState.get(this.appObjects);
43
51
  if (!this.baseAppState) {
44
- this.warn("QuestionChallengePM has been added to an app object that does not have BaseAppStateEntity");
52
+ this.error("Unable to find BaseAppStateEntity");
45
53
  return;
46
54
  }
47
55
  else {
48
56
  this.baseAppState.addChangeObserver(this.onEntityChange);
49
57
  this.onEntityChange();
50
58
  }
51
- this.questionEntity = appObject.getComponent(QuestionEntity_1.QuestionEntity.type);
52
59
  if (this.questionEntity) {
53
60
  this.questionEntity.addChangeObserver(this.onEntityChange);
54
61
  this.onEntityChange();
55
62
  }
56
63
  else {
57
- this.warn("QuestionChallengePM has been added to an app object that does not have QuestionEntity");
64
+ this.error("Unable to find QuestionEntity");
58
65
  }
59
66
  }
67
+ get questionEntity() {
68
+ return this.getCachedSingleton(QuestionEntity_1.QuestionEntity.type);
69
+ }
70
+ get baseAppState() {
71
+ return this.getCachedSingleton(BaseApp_1.BaseAppState.type);
72
+ }
60
73
  vmsAreEqual(a, b) {
61
74
  if (a.gotItRight !== b.gotItRight)
62
75
  return false;
@@ -74,6 +87,3 @@ class QuestionChallengePM extends AppObjectPM_1.AppObjectPM {
74
87
  return idsMatch;
75
88
  }
76
89
  }
77
- exports.QuestionChallengePM = QuestionChallengePM;
78
- QuestionChallengePM.type = "QuestionChallengePM";
79
- QuestionChallengePM.get = (appObjects) => AppObject_1.getSingletonComponent(QuestionChallengePM.type, appObjects);
@@ -1,5 +1,7 @@
1
+ export * from "./Adapters";
1
2
  export * from "./Controllers";
2
3
  export * from "./Entities";
4
+ export * from "./Factories";
3
5
  export * from "./Mocks";
4
6
  export * from "./PM";
5
7
  export * from "./UC";
@@ -10,8 +10,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./Adapters"), exports);
13
14
  __exportStar(require("./Controllers"), exports);
14
15
  __exportStar(require("./Entities"), exports);
16
+ __exportStar(require("./Factories"), exports);
15
17
  __exportStar(require("./Mocks"), exports);
16
18
  __exportStar(require("./PM"), exports);
17
19
  __exportStar(require("./UC"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vived/app",
3
- "version": "4.28.1",
3
+ "version": "4.28.2",
4
4
  "description": "Public package for the VIVED Learning App system",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",