@vived/app 2.14.0 → 2.15.3
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.
- package/lib/Entities/Babylon.js +1 -1
- package/lib/Entities/FocusCamera.js +9 -9
- package/lib/Entities/MemoizedBoolean.d.ts +1 -0
- package/lib/Entities/MemoizedBoolean.js +3 -0
- package/lib/Entities/MemoizedNumber.d.ts +1 -0
- package/lib/Entities/MemoizedNumber.js +3 -0
- package/lib/Entities/MemoizedString.d.ts +1 -0
- package/lib/Entities/MemoizedString.js +3 -0
- package/lib/Entities/MemoizedVector2.d.ts +1 -0
- package/lib/Entities/MemoizedVector2.js +4 -1
- package/lib/Entities/MemoizedVector3.d.ts +1 -0
- package/lib/Entities/MemoizedVector3.js +4 -1
- package/lib/Entities/QuestionChallenge.d.ts +21 -0
- package/lib/Entities/QuestionChallenge.js +103 -0
- package/lib/Entities/QuestionChallengeAnswer.d.ts +32 -0
- package/lib/Entities/QuestionChallengeAnswer.js +51 -0
- package/lib/Entities/index.d.ts +2 -0
- package/lib/Entities/index.js +2 -0
- package/lib/PresentationManagers/QuestionChallenge/AuthorQuestionChallengeAnswerPM.d.ts +24 -0
- package/lib/PresentationManagers/QuestionChallenge/AuthorQuestionChallengeAnswerPM.js +65 -0
- package/lib/PresentationManagers/QuestionChallenge/AuthorQuestionChallengePM.d.ts +17 -0
- package/lib/PresentationManagers/QuestionChallenge/AuthorQuestionChallengePM.js +46 -0
- package/lib/PresentationManagers/QuestionChallenge/QuestionChallengeAnswerPM.d.ts +17 -0
- package/lib/PresentationManagers/QuestionChallenge/QuestionChallengeAnswerPM.js +51 -0
- package/lib/PresentationManagers/QuestionChallenge/QuestionChallengePM.d.ts +15 -0
- package/lib/PresentationManagers/QuestionChallenge/QuestionChallengePM.js +34 -0
- package/lib/PresentationManagers/QuestionChallenge/index.d.ts +4 -0
- package/lib/PresentationManagers/QuestionChallenge/index.js +16 -0
- package/lib/PresentationManagers/index.d.ts +1 -0
- package/lib/PresentationManagers/index.js +1 -0
- package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.js +3 -3
- package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.js +3 -3
- package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.js +3 -3
- package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.js +1 -1
- package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.js +1 -1
- package/lib/UseCases/QuestionChallenge/SerializeQuestionChallenge.d.ts +25 -0
- package/lib/UseCases/QuestionChallenge/SerializeQuestionChallenge.js +70 -0
- package/lib/UseCases/QuestionChallenge/index.d.ts +4 -0
- package/lib/UseCases/QuestionChallenge/index.js +16 -0
- package/lib/UseCases/QuestionChallenge/setQuesionChallengeAnswerFeedback.d.ts +2 -0
- package/lib/UseCases/QuestionChallenge/setQuesionChallengeAnswerFeedback.js +16 -0
- package/lib/UseCases/QuestionChallenge/setQuesionChallengeAnswerText.d.ts +2 -0
- package/lib/UseCases/QuestionChallenge/setQuesionChallengeAnswerText.js +16 -0
- package/lib/UseCases/QuestionChallenge/toggleQuesionChallengeAnswerIsCorrect.d.ts +2 -0
- package/lib/UseCases/QuestionChallenge/toggleQuesionChallengeAnswerIsCorrect.js +16 -0
- package/lib/UseCases/index.d.ts +1 -0
- package/lib/UseCases/index.js +1 -0
- package/lib/ValueObjects/Angle.d.ts +2 -2
- package/lib/ValueObjects/Angle.js +2 -2
- package/lib/ValueObjects/Color.d.ts +4 -8
- package/lib/ValueObjects/Color.js +9 -21
- package/lib/ValueObjects/LineSegment2D.d.ts +5 -6
- package/lib/ValueObjects/LineSegment2D.js +46 -30
- package/lib/ValueObjects/ParametricLine.d.ts +1 -1
- package/lib/ValueObjects/ParametricLine.js +8 -8
- package/lib/ValueObjects/ParametricPlane.d.ts +1 -1
- package/lib/ValueObjects/ParametricPlane.js +10 -10
- package/lib/ValueObjects/Vector2.d.ts +11 -11
- package/lib/ValueObjects/Vector2.js +14 -14
- package/lib/ValueObjects/Vector3.d.ts +16 -16
- package/lib/ValueObjects/Vector3.js +18 -18
- package/package.json +1 -1
package/lib/Entities/Babylon.js
CHANGED
|
@@ -78,7 +78,7 @@ class BabylonImp {
|
|
|
78
78
|
this.sceneRay = rayer;
|
|
79
79
|
};
|
|
80
80
|
this.memoizedShowInspector = new MemoizedBoolean_1.MemoizedBoolean(false, this.observers.notify);
|
|
81
|
-
this.memoizedCanvasSize = new MemoizedVector2_1.MemoizedVector2(ValueObjects_1.Vector2.
|
|
81
|
+
this.memoizedCanvasSize = new MemoizedVector2_1.MemoizedVector2(ValueObjects_1.Vector2.One(), this.observers.notify);
|
|
82
82
|
}
|
|
83
83
|
get showInspector() {
|
|
84
84
|
return this.memoizedShowInspector.val;
|
|
@@ -14,7 +14,7 @@ class FocusCameraImp {
|
|
|
14
14
|
this.defaultAlpha = 0;
|
|
15
15
|
this.defaultBeta = 30;
|
|
16
16
|
this.defaultRadius = 8;
|
|
17
|
-
this.defaultTarget = ValueObjects_1.Vector3.
|
|
17
|
+
this.defaultTarget = ValueObjects_1.Vector3.Zero();
|
|
18
18
|
this.limitRadius = false;
|
|
19
19
|
this.minRadius = 0;
|
|
20
20
|
this.maxRadius = 0;
|
|
@@ -25,13 +25,13 @@ class FocusCameraImp {
|
|
|
25
25
|
this.minBeta = 0;
|
|
26
26
|
this.maxBeta = 0;
|
|
27
27
|
this.limitTarget = false;
|
|
28
|
-
this.maxTargetPosition = ValueObjects_1.Vector3.
|
|
29
|
-
this.minTargetPosition = ValueObjects_1.Vector3.
|
|
28
|
+
this.maxTargetPosition = ValueObjects_1.Vector3.Zero();
|
|
29
|
+
this.minTargetPosition = ValueObjects_1.Vector3.Zero();
|
|
30
30
|
this.observers = new _1.ObserverList();
|
|
31
31
|
this.memoizedAlpha = new _1.MemoizedNumber(0, this.observers.notify);
|
|
32
32
|
this.memoizedBeta = new _1.MemoizedNumber(0, this.observers.notify);
|
|
33
33
|
this.memoizedRadius = new _1.MemoizedNumber(1, this.observers.notify);
|
|
34
|
-
this.memoizedTarget = new _1.MemoizedVector3(ValueObjects_1.Vector3.
|
|
34
|
+
this.memoizedTarget = new _1.MemoizedVector3(ValueObjects_1.Vector3.Zero(), this.observers.notify);
|
|
35
35
|
this.setRadiusLimits = (min, max) => {
|
|
36
36
|
if (min < 0) {
|
|
37
37
|
throw new Error("[Orbit Camera] Mininum Radius must be greater >= 0");
|
|
@@ -103,8 +103,8 @@ class FocusCameraImp {
|
|
|
103
103
|
this.target = this.target;
|
|
104
104
|
};
|
|
105
105
|
this.clearTargetLimits = () => {
|
|
106
|
-
this.maxTargetPosition = ValueObjects_1.Vector3.
|
|
107
|
-
this.minTargetPosition = ValueObjects_1.Vector3.
|
|
106
|
+
this.maxTargetPosition = ValueObjects_1.Vector3.Zero();
|
|
107
|
+
this.minTargetPosition = ValueObjects_1.Vector3.Zero();
|
|
108
108
|
this.limitTarget = false;
|
|
109
109
|
};
|
|
110
110
|
this.registerLerp = (lerper) => {
|
|
@@ -210,7 +210,7 @@ class FocusCameraImp {
|
|
|
210
210
|
targetVals[i] = v;
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
|
-
this.memoizedTarget.val = ValueObjects_1.Vector3.
|
|
213
|
+
this.memoizedTarget.val = ValueObjects_1.Vector3.FromArray(targetVals);
|
|
214
214
|
}
|
|
215
215
|
get direction() {
|
|
216
216
|
const yLength = -Math.sin(this.degToRad(this.beta));
|
|
@@ -221,8 +221,8 @@ class FocusCameraImp {
|
|
|
221
221
|
return new ValueObjects_1.Vector3(xLength, yLength, zLength);
|
|
222
222
|
}
|
|
223
223
|
get cameraPosition() {
|
|
224
|
-
const localOffset = ValueObjects_1.Vector3.
|
|
225
|
-
return ValueObjects_1.Vector3.
|
|
224
|
+
const localOffset = ValueObjects_1.Vector3.NewVectorOfLength(this.direction, -this.radius);
|
|
225
|
+
return ValueObjects_1.Vector3.Add(this.target, localOffset);
|
|
226
226
|
}
|
|
227
227
|
degToRad(degrees) {
|
|
228
228
|
return (degrees * Math.PI) / 180;
|
|
@@ -11,10 +11,13 @@ class MemoizedVector2 {
|
|
|
11
11
|
return this._val;
|
|
12
12
|
}
|
|
13
13
|
set val(v) {
|
|
14
|
-
if (ValueObjects_1.Vector2.
|
|
14
|
+
if (ValueObjects_1.Vector2.Equal(v, this._val))
|
|
15
15
|
return;
|
|
16
16
|
this._val = v;
|
|
17
17
|
this.onChangeCallback();
|
|
18
18
|
}
|
|
19
|
+
setValQuietly(val) {
|
|
20
|
+
this._val = val;
|
|
21
|
+
}
|
|
19
22
|
}
|
|
20
23
|
exports.MemoizedVector2 = MemoizedVector2;
|
|
@@ -11,10 +11,13 @@ class MemoizedVector3 {
|
|
|
11
11
|
return this._val;
|
|
12
12
|
}
|
|
13
13
|
set val(v) {
|
|
14
|
-
if (Vector3_1.Vector3.
|
|
14
|
+
if (Vector3_1.Vector3.Equal(v, this._val))
|
|
15
15
|
return;
|
|
16
16
|
this._val = v;
|
|
17
17
|
this.onChangeCallback();
|
|
18
18
|
}
|
|
19
|
+
setValQuietly(val) {
|
|
20
|
+
this._val = val;
|
|
21
|
+
}
|
|
19
22
|
}
|
|
20
23
|
exports.MemoizedVector3 = MemoizedVector3;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { QuestionChallengeAnswer } from "./QuestionChallengeAnswer";
|
|
2
|
+
export declare type OnQuestionChallengeChange = () => void;
|
|
3
|
+
export interface QuestionChallenge {
|
|
4
|
+
gotItRight: boolean;
|
|
5
|
+
tries: number;
|
|
6
|
+
text: string;
|
|
7
|
+
addAnswer: (answer: QuestionChallengeAnswer) => void;
|
|
8
|
+
removeAnswer: (id: string) => void;
|
|
9
|
+
getAnswer: (id: string) => QuestionChallengeAnswer | undefined;
|
|
10
|
+
getAllAnswers: () => QuestionChallengeAnswer[];
|
|
11
|
+
hasAnswer: (id: string) => boolean;
|
|
12
|
+
createAnswer: (text: string) => QuestionChallengeAnswer;
|
|
13
|
+
removeAllAnswers: () => void;
|
|
14
|
+
setDefaultState: () => void;
|
|
15
|
+
reset: () => void;
|
|
16
|
+
submitAnswer: (id: string) => void;
|
|
17
|
+
setIDGenerator: (generator: () => string) => void;
|
|
18
|
+
addObserver: (observer: OnQuestionChallengeChange) => void;
|
|
19
|
+
removeObserver: (observer: OnQuestionChallengeChange) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare function makeQuestionChallenge(): QuestionChallenge;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeQuestionChallenge = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const QuestionChallengeAnswer_1 = require("./QuestionChallengeAnswer");
|
|
6
|
+
function makeQuestionChallenge() {
|
|
7
|
+
return new QuestionChallengeImp();
|
|
8
|
+
}
|
|
9
|
+
exports.makeQuestionChallenge = makeQuestionChallenge;
|
|
10
|
+
class QuestionChallengeImp {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.answerLookup = new Map();
|
|
13
|
+
this.observers = new _1.ObserverList();
|
|
14
|
+
this._tries = 0;
|
|
15
|
+
this._gotItRight = false;
|
|
16
|
+
this.memoizedText = new _1.MemoizedString("", this.observers.notify);
|
|
17
|
+
this.generateID = () => {
|
|
18
|
+
const randomNumber = Math.random() * Date.now();
|
|
19
|
+
return `${randomNumber}`;
|
|
20
|
+
};
|
|
21
|
+
this.setIDGenerator = (generator) => {
|
|
22
|
+
this.generateID = generator;
|
|
23
|
+
};
|
|
24
|
+
this.getAllAnswers = () => {
|
|
25
|
+
return Array.from(this.answerLookup.values());
|
|
26
|
+
};
|
|
27
|
+
this.addAnswer = (answer) => {
|
|
28
|
+
if (this.answerLookup.has(answer.id)) {
|
|
29
|
+
throw new Error(`Answer with ID ${answer.id} already exists`);
|
|
30
|
+
}
|
|
31
|
+
this.answerLookup.set(answer.id, answer);
|
|
32
|
+
this.reset();
|
|
33
|
+
};
|
|
34
|
+
this.removeAnswer = (id) => {
|
|
35
|
+
const answer = this.answerLookup.get(id);
|
|
36
|
+
if (!answer)
|
|
37
|
+
return;
|
|
38
|
+
this.answerLookup.delete(id);
|
|
39
|
+
this.reset();
|
|
40
|
+
};
|
|
41
|
+
this.getAnswer = (id) => {
|
|
42
|
+
return this.answerLookup.get(id);
|
|
43
|
+
};
|
|
44
|
+
this.hasAnswer = (id) => {
|
|
45
|
+
return this.answerLookup.has(id);
|
|
46
|
+
};
|
|
47
|
+
this.reset = () => {
|
|
48
|
+
this._gotItRight = false;
|
|
49
|
+
this._tries = 0;
|
|
50
|
+
this.answerLookup.forEach((ans) => (ans.showFeedback = false));
|
|
51
|
+
this.observers.notify();
|
|
52
|
+
};
|
|
53
|
+
this.submitAnswer = (id) => {
|
|
54
|
+
const ans = this.getAnswer(id);
|
|
55
|
+
if (!ans) {
|
|
56
|
+
console.warn(`[Question Challenge] Unable to find answer by ID: ${id}`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this._tries++;
|
|
60
|
+
ans.showFeedback = true;
|
|
61
|
+
this._gotItRight = ans.isCorrect;
|
|
62
|
+
this.observers.notify();
|
|
63
|
+
};
|
|
64
|
+
this.createAnswer = (text) => {
|
|
65
|
+
const id = this.generateID();
|
|
66
|
+
const answer = QuestionChallengeAnswer_1.makeQuestionChallengeAnswer(id);
|
|
67
|
+
answer.text = text;
|
|
68
|
+
this.addAnswer(answer);
|
|
69
|
+
return answer;
|
|
70
|
+
};
|
|
71
|
+
this.removeAllAnswers = () => {
|
|
72
|
+
const allAnswers = Array.from(this.answerLookup.keys());
|
|
73
|
+
allAnswers.forEach((id) => this.removeAnswer(id));
|
|
74
|
+
this.reset();
|
|
75
|
+
};
|
|
76
|
+
this.setDefaultState = () => {
|
|
77
|
+
this.removeAllAnswers();
|
|
78
|
+
const trueAnswer = this.createAnswer("True");
|
|
79
|
+
trueAnswer.isCorrect = true;
|
|
80
|
+
this.createAnswer("False");
|
|
81
|
+
this.memoizedText.setValQuietly("True / False question text");
|
|
82
|
+
this.reset();
|
|
83
|
+
};
|
|
84
|
+
this.addObserver = (observer) => {
|
|
85
|
+
this.observers.add(observer);
|
|
86
|
+
};
|
|
87
|
+
this.removeObserver = (observer) => {
|
|
88
|
+
this.observers.remove(observer);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
get tries() {
|
|
92
|
+
return this._tries;
|
|
93
|
+
}
|
|
94
|
+
get gotItRight() {
|
|
95
|
+
return this._gotItRight;
|
|
96
|
+
}
|
|
97
|
+
get text() {
|
|
98
|
+
return this.memoizedText.val;
|
|
99
|
+
}
|
|
100
|
+
set text(val) {
|
|
101
|
+
this.memoizedText.val = val;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare type OnQuestionAnswerChange = () => void;
|
|
2
|
+
export interface QuestionChallengeAnswer {
|
|
3
|
+
id: string;
|
|
4
|
+
text: string;
|
|
5
|
+
isCorrect: boolean;
|
|
6
|
+
feedbackText: string;
|
|
7
|
+
showFeedback: boolean;
|
|
8
|
+
addObserver(observer: OnQuestionAnswerChange): void;
|
|
9
|
+
removeObserver(observer: OnQuestionAnswerChange): void;
|
|
10
|
+
}
|
|
11
|
+
export declare function makeQuestionChallengeAnswer(id: string): QuestionChallengeAnswerImp;
|
|
12
|
+
declare class QuestionChallengeAnswerImp implements QuestionChallengeAnswer {
|
|
13
|
+
private observers;
|
|
14
|
+
private _id;
|
|
15
|
+
get id(): string;
|
|
16
|
+
private memoizedText;
|
|
17
|
+
get text(): string;
|
|
18
|
+
set text(val: string);
|
|
19
|
+
private memoizedFeedback;
|
|
20
|
+
get feedbackText(): string;
|
|
21
|
+
set feedbackText(val: string);
|
|
22
|
+
private memoizedIsCorrect;
|
|
23
|
+
get isCorrect(): boolean;
|
|
24
|
+
set isCorrect(val: boolean);
|
|
25
|
+
private memoizedShowFeedback;
|
|
26
|
+
get showFeedback(): boolean;
|
|
27
|
+
set showFeedback(val: boolean);
|
|
28
|
+
addObserver(observer: OnQuestionAnswerChange): void;
|
|
29
|
+
removeObserver(observer: OnQuestionAnswerChange): void;
|
|
30
|
+
constructor(id: string);
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeQuestionChallengeAnswer = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
function makeQuestionChallengeAnswer(id) {
|
|
6
|
+
return new QuestionChallengeAnswerImp(id);
|
|
7
|
+
}
|
|
8
|
+
exports.makeQuestionChallengeAnswer = makeQuestionChallengeAnswer;
|
|
9
|
+
class QuestionChallengeAnswerImp {
|
|
10
|
+
constructor(id) {
|
|
11
|
+
this.observers = new _1.ObserverList();
|
|
12
|
+
this.memoizedText = new _1.MemoizedString("Answer", this.observers.notify);
|
|
13
|
+
this.memoizedFeedback = new _1.MemoizedString("", this.observers.notify);
|
|
14
|
+
this.memoizedIsCorrect = new _1.MemoizedBoolean(false, this.observers.notify);
|
|
15
|
+
this.memoizedShowFeedback = new _1.MemoizedBoolean(false, this.observers.notify);
|
|
16
|
+
this._id = id;
|
|
17
|
+
}
|
|
18
|
+
get id() {
|
|
19
|
+
return this._id;
|
|
20
|
+
}
|
|
21
|
+
get text() {
|
|
22
|
+
return this.memoizedText.val;
|
|
23
|
+
}
|
|
24
|
+
set text(val) {
|
|
25
|
+
this.memoizedText.val = val;
|
|
26
|
+
}
|
|
27
|
+
get feedbackText() {
|
|
28
|
+
return this.memoizedFeedback.val;
|
|
29
|
+
}
|
|
30
|
+
set feedbackText(val) {
|
|
31
|
+
this.memoizedFeedback.val = val;
|
|
32
|
+
}
|
|
33
|
+
get isCorrect() {
|
|
34
|
+
return this.memoizedIsCorrect.val;
|
|
35
|
+
}
|
|
36
|
+
set isCorrect(val) {
|
|
37
|
+
this.memoizedIsCorrect.val = val;
|
|
38
|
+
}
|
|
39
|
+
get showFeedback() {
|
|
40
|
+
return this.memoizedShowFeedback.val;
|
|
41
|
+
}
|
|
42
|
+
set showFeedback(val) {
|
|
43
|
+
this.memoizedShowFeedback.val = val;
|
|
44
|
+
}
|
|
45
|
+
addObserver(observer) {
|
|
46
|
+
this.observers.add(observer);
|
|
47
|
+
}
|
|
48
|
+
removeObserver(observer) {
|
|
49
|
+
this.observers.remove(observer);
|
|
50
|
+
}
|
|
51
|
+
}
|
package/lib/Entities/index.d.ts
CHANGED
package/lib/Entities/index.js
CHANGED
|
@@ -25,3 +25,5 @@ __exportStar(require("./StateMachine"), exports);
|
|
|
25
25
|
__exportStar(require("./UndoRedo"), exports);
|
|
26
26
|
__exportStar(require("./MouseInput"), exports);
|
|
27
27
|
__exportStar(require("./TouchInput"), exports);
|
|
28
|
+
__exportStar(require("./QuestionChallengeAnswer"), exports);
|
|
29
|
+
__exportStar(require("./QuestionChallenge"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { QuestionChallenge } from "../../Entities";
|
|
2
|
+
export declare const defaultAuthorQuestionChallengeAnswerVM: AuthorQuestionChallengeAnswerVM;
|
|
3
|
+
export interface AuthorQuestionChallengeAnswerVM {
|
|
4
|
+
answerText: string;
|
|
5
|
+
feedbackText: string;
|
|
6
|
+
isCorrect: boolean;
|
|
7
|
+
allowDelete: boolean;
|
|
8
|
+
setAnswerText: (text: string) => void;
|
|
9
|
+
setFeedbackText: (text: string) => void;
|
|
10
|
+
toggleIsCorrect: () => void;
|
|
11
|
+
deleteAnswer: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare class AuthorQuestionChallengeAnswerPM {
|
|
14
|
+
private answerID;
|
|
15
|
+
private questionChallengeEntity;
|
|
16
|
+
private updateView;
|
|
17
|
+
private answer?;
|
|
18
|
+
setTextUC: (text: string) => void;
|
|
19
|
+
setFeedbackUC: (text: string) => void;
|
|
20
|
+
toggleIsCorrectUC: () => void;
|
|
21
|
+
dispose: () => void;
|
|
22
|
+
private doUpdateView;
|
|
23
|
+
constructor(answerID: string, questionChallengeEntity: QuestionChallenge, updateView: (vm: AuthorQuestionChallengeAnswerVM) => void);
|
|
24
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthorQuestionChallengeAnswerPM = exports.defaultAuthorQuestionChallengeAnswerVM = void 0;
|
|
4
|
+
const setQuesionChallengeAnswerFeedback_1 = require("../../UseCases/QuestionChallenge/setQuesionChallengeAnswerFeedback");
|
|
5
|
+
const setQuesionChallengeAnswerText_1 = require("../../UseCases/QuestionChallenge/setQuesionChallengeAnswerText");
|
|
6
|
+
const toggleQuesionChallengeAnswerIsCorrect_1 = require("../../UseCases/QuestionChallenge/toggleQuesionChallengeAnswerIsCorrect");
|
|
7
|
+
exports.defaultAuthorQuestionChallengeAnswerVM = {
|
|
8
|
+
answerText: "",
|
|
9
|
+
feedbackText: "",
|
|
10
|
+
isCorrect: false,
|
|
11
|
+
allowDelete: false,
|
|
12
|
+
setAnswerText: (text) => {
|
|
13
|
+
console.log("Default setAnswerText: " + text);
|
|
14
|
+
},
|
|
15
|
+
setFeedbackText: (text) => {
|
|
16
|
+
console.log("Default setFeedbackText: " + text);
|
|
17
|
+
},
|
|
18
|
+
toggleIsCorrect: () => {
|
|
19
|
+
console.log("Default toggleIsCorrect");
|
|
20
|
+
},
|
|
21
|
+
deleteAnswer: () => {
|
|
22
|
+
console.log("Default deleteAnswer");
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
class AuthorQuestionChallengeAnswerPM {
|
|
26
|
+
constructor(answerID, questionChallengeEntity, updateView) {
|
|
27
|
+
this.answerID = answerID;
|
|
28
|
+
this.questionChallengeEntity = questionChallengeEntity;
|
|
29
|
+
this.updateView = updateView;
|
|
30
|
+
this.dispose = () => {
|
|
31
|
+
var _a;
|
|
32
|
+
(_a = this.answer) === null || _a === void 0 ? void 0 : _a.removeObserver(this.doUpdateView);
|
|
33
|
+
this.questionChallengeEntity.removeObserver(this.doUpdateView);
|
|
34
|
+
};
|
|
35
|
+
this.doUpdateView = () => {
|
|
36
|
+
if (this.answer === undefined)
|
|
37
|
+
return;
|
|
38
|
+
const { feedbackText, text, isCorrect } = this.answer;
|
|
39
|
+
const allowDelete = this.questionChallengeEntity.getAllAnswers().length > 2 ? true : false;
|
|
40
|
+
const vm = {
|
|
41
|
+
answerText: text,
|
|
42
|
+
isCorrect,
|
|
43
|
+
feedbackText,
|
|
44
|
+
allowDelete,
|
|
45
|
+
setAnswerText: this.setTextUC,
|
|
46
|
+
setFeedbackText: this.setFeedbackUC,
|
|
47
|
+
toggleIsCorrect: this.toggleIsCorrectUC,
|
|
48
|
+
deleteAnswer: () => {
|
|
49
|
+
this.questionChallengeEntity.removeAnswer(this.answerID);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
this.updateView(vm);
|
|
53
|
+
};
|
|
54
|
+
this.answer = questionChallengeEntity.getAnswer(answerID);
|
|
55
|
+
this.setTextUC = setQuesionChallengeAnswerText_1.makeSetQuestionChallengeAnswerText(answerID, questionChallengeEntity);
|
|
56
|
+
this.setFeedbackUC = setQuesionChallengeAnswerFeedback_1.makeSetQuestionChallengeAnswerFeedback(answerID, questionChallengeEntity);
|
|
57
|
+
this.toggleIsCorrectUC = toggleQuesionChallengeAnswerIsCorrect_1.makeToggleQuesionChallengeAnswerIsCorrect(answerID, questionChallengeEntity);
|
|
58
|
+
if (this.answer) {
|
|
59
|
+
this.doUpdateView();
|
|
60
|
+
this.answer.addObserver(this.doUpdateView);
|
|
61
|
+
this.questionChallengeEntity.addObserver(this.doUpdateView);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.AuthorQuestionChallengeAnswerPM = AuthorQuestionChallengeAnswerPM;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { QuestionChallenge } from "../../Entities";
|
|
2
|
+
export declare const defaultAuthorQuestionChallengeVM: AuthorQuestionChallengeVM;
|
|
3
|
+
export interface AuthorQuestionChallengeVM {
|
|
4
|
+
text: string;
|
|
5
|
+
answers: string[];
|
|
6
|
+
enableResetButton: boolean;
|
|
7
|
+
setQuestionText: (text: string) => void;
|
|
8
|
+
reset: () => void;
|
|
9
|
+
createAnswer: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare class AuthorQuestionChallengePM {
|
|
12
|
+
private questionChallengeEntity;
|
|
13
|
+
private updateView;
|
|
14
|
+
dispose: () => void;
|
|
15
|
+
private doUpdateView;
|
|
16
|
+
constructor(questionChallengeEntity: QuestionChallenge, updateView: (vm: AuthorQuestionChallengeVM) => void);
|
|
17
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthorQuestionChallengePM = exports.defaultAuthorQuestionChallengeVM = void 0;
|
|
4
|
+
exports.defaultAuthorQuestionChallengeVM = {
|
|
5
|
+
text: "",
|
|
6
|
+
answers: [],
|
|
7
|
+
enableResetButton: false,
|
|
8
|
+
setQuestionText: (text) => {
|
|
9
|
+
console.log("Default setQuestionText: " + text);
|
|
10
|
+
},
|
|
11
|
+
reset: () => {
|
|
12
|
+
console.log("Default reset");
|
|
13
|
+
},
|
|
14
|
+
createAnswer: () => {
|
|
15
|
+
console.log("Default reset");
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
class AuthorQuestionChallengePM {
|
|
19
|
+
constructor(questionChallengeEntity, updateView) {
|
|
20
|
+
this.questionChallengeEntity = questionChallengeEntity;
|
|
21
|
+
this.updateView = updateView;
|
|
22
|
+
this.dispose = () => {
|
|
23
|
+
this.questionChallengeEntity.removeObserver(this.doUpdateView);
|
|
24
|
+
};
|
|
25
|
+
this.doUpdateView = () => {
|
|
26
|
+
const { text, tries } = this.questionChallengeEntity;
|
|
27
|
+
const answers = this.questionChallengeEntity
|
|
28
|
+
.getAllAnswers()
|
|
29
|
+
.map((ans) => ans.id);
|
|
30
|
+
const vm = {
|
|
31
|
+
text,
|
|
32
|
+
answers,
|
|
33
|
+
enableResetButton: tries > 0,
|
|
34
|
+
setQuestionText: (txt) => {
|
|
35
|
+
this.questionChallengeEntity.text = txt;
|
|
36
|
+
},
|
|
37
|
+
reset: () => this.questionChallengeEntity.reset(),
|
|
38
|
+
createAnswer: () => this.questionChallengeEntity.createAnswer(""),
|
|
39
|
+
};
|
|
40
|
+
this.updateView(vm);
|
|
41
|
+
};
|
|
42
|
+
this.doUpdateView();
|
|
43
|
+
this.questionChallengeEntity.addObserver(this.doUpdateView);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.AuthorQuestionChallengePM = AuthorQuestionChallengePM;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { QuestionChallenge } from "../../Entities";
|
|
2
|
+
export declare const defaultQestionChallengeAnswerVM: QuestionChallengeAnswerVM;
|
|
3
|
+
export interface QuestionChallengeAnswerVM {
|
|
4
|
+
displayText: string;
|
|
5
|
+
isShowingFeedback: boolean;
|
|
6
|
+
isCorrect: boolean;
|
|
7
|
+
submitAnswer: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare class QuestionChallengeAnswerPM {
|
|
10
|
+
private answerID;
|
|
11
|
+
private questionChallengeEntity;
|
|
12
|
+
private updateView;
|
|
13
|
+
private answer?;
|
|
14
|
+
dispose: () => void;
|
|
15
|
+
private doUpdateView;
|
|
16
|
+
constructor(answerID: string, questionChallengeEntity: QuestionChallenge, updateView: (vm: QuestionChallengeAnswerVM) => void);
|
|
17
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuestionChallengeAnswerPM = exports.defaultQestionChallengeAnswerVM = void 0;
|
|
4
|
+
exports.defaultQestionChallengeAnswerVM = {
|
|
5
|
+
displayText: "",
|
|
6
|
+
isShowingFeedback: false,
|
|
7
|
+
isCorrect: false,
|
|
8
|
+
submitAnswer: () => {
|
|
9
|
+
console.log("Default submitAnswer");
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
class QuestionChallengeAnswerPM {
|
|
13
|
+
constructor(answerID, questionChallengeEntity, updateView) {
|
|
14
|
+
this.answerID = answerID;
|
|
15
|
+
this.questionChallengeEntity = questionChallengeEntity;
|
|
16
|
+
this.updateView = updateView;
|
|
17
|
+
this.dispose = () => {
|
|
18
|
+
var _a;
|
|
19
|
+
(_a = this.answer) === null || _a === void 0 ? void 0 : _a.removeObserver(this.doUpdateView);
|
|
20
|
+
};
|
|
21
|
+
this.doUpdateView = () => {
|
|
22
|
+
if (!this.answer)
|
|
23
|
+
return;
|
|
24
|
+
const { feedbackText, showFeedback, text, isCorrect } = this.answer;
|
|
25
|
+
let displayText = text ? text : `Answer`;
|
|
26
|
+
if (showFeedback) {
|
|
27
|
+
if (feedbackText) {
|
|
28
|
+
displayText = feedbackText;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
displayText = isCorrect ? "Correct" : "Incorrect";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const vm = {
|
|
35
|
+
displayText,
|
|
36
|
+
isCorrect,
|
|
37
|
+
isShowingFeedback: showFeedback,
|
|
38
|
+
submitAnswer: () => {
|
|
39
|
+
this.questionChallengeEntity.submitAnswer(this.answerID);
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
this.updateView(vm);
|
|
43
|
+
};
|
|
44
|
+
this.answer = questionChallengeEntity.getAnswer(answerID);
|
|
45
|
+
if (this.answer) {
|
|
46
|
+
this.doUpdateView();
|
|
47
|
+
this.answer.addObserver(this.doUpdateView);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.QuestionChallengeAnswerPM = QuestionChallengeAnswerPM;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { QuestionChallenge } from "../../Entities";
|
|
2
|
+
export declare const defaultQuestionChallengeVM: QuestionChallengeVM;
|
|
3
|
+
export interface QuestionChallengeVM {
|
|
4
|
+
text: string;
|
|
5
|
+
tries: number;
|
|
6
|
+
gotItRight: boolean;
|
|
7
|
+
answers: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare class QuestionChallengePM {
|
|
10
|
+
private questionChallengeEntity;
|
|
11
|
+
private updateView;
|
|
12
|
+
dispose: () => void;
|
|
13
|
+
private doUpdateView;
|
|
14
|
+
constructor(questionChallengeEntity: QuestionChallenge, updateView: (vm: QuestionChallengeVM) => void);
|
|
15
|
+
}
|