@sparkle-learning/core 0.0.52 → 0.0.54
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/dist/cjs/{PrivateRoute-074c584e.js → PrivateRoute-e2047db2.js} +18 -30
- package/dist/cjs/{feed.service-b4f09441.js → appdata.service-d28cf2d6.js} +4 -56
- package/dist/cjs/{assets.service-0c759d51.js → assets.service-bfa75092.js} +1 -1
- package/dist/cjs/{environment-config.service-0e02b049.js → environment-config.service-c8ff1f3d.js} +0 -1
- package/dist/cjs/{facilitator.service-9e990274.js → facilitator.service-0b9f6ac7.js} +1 -1
- package/dist/cjs/feed.service-6df9382f.js +57 -0
- package/dist/cjs/header-mobile-collapse_61.cjs.entry.js +289 -3279
- package/dist/cjs/{httpService-7211d93b.js → httpService-d8a5b474.js} +13 -11
- package/dist/cjs/index.cjs.js +5 -4
- package/dist/cjs/{ion-select_2.cjs.entry.js → ion-select_3.cjs.entry.js} +127 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/media.service-2bc73d37.js +40 -0
- package/dist/cjs/signalR.service-0d5da1d3.js +2985 -0
- package/dist/cjs/sparkle-animation-player.cjs.entry.js +2 -1
- package/dist/cjs/sparkle-assignment.cjs.entry.js +25 -0
- package/dist/cjs/sparkle-character-intro.cjs.entry.js +2 -2
- package/dist/cjs/sparkle-core.cjs.js +1 -1
- package/dist/cjs/sparkle-discussion-questions_2.cjs.entry.js +281 -0
- package/dist/cjs/sparkle-discussion.cjs.entry.js +42 -0
- package/dist/cjs/sparkle-facilitator-notes-form.cjs.entry.js +5 -3
- package/dist/cjs/sparkle-feedback.cjs.entry.js +5 -3
- package/dist/cjs/sparkle-goal-form.cjs.entry.js +11 -8
- package/dist/cjs/sparkle-quiz-container.cjs.entry.js +1 -1
- package/dist/cjs/sparkle-quiz-old.cjs.entry.js +120 -0
- package/dist/cjs/sparkle-quiz.cjs.entry.js +31 -48
- package/dist/cjs/{student.service-2e58f237.js → student.service-d8ec2551.js} +1 -1
- package/dist/cjs/token.service-bfb0089b.js +86 -0
- package/dist/cjs/{util-d383acb8.js → util-47e320b2.js} +2 -2
- package/dist/collection/PrivateRoute.js +2 -2
- package/dist/collection/collection-manifest.json +6 -2
- package/dist/collection/components/layout/facilitator/facilitator-page.js +2 -3
- package/dist/collection/components/layout/page/page.css +4 -0
- package/dist/collection/components/layout/page/page.js +39 -26
- package/dist/collection/components/sparkle-animation-player/sparkle-animation-player.js +1 -0
- package/dist/collection/components/sparkle-assignment/sparkle-assignment.css +3 -0
- package/dist/collection/components/sparkle-assignment/sparkle-assignment.js +25 -0
- package/dist/collection/components/sparkle-character-intro/sparkle-character-intro.css +8 -1
- package/dist/collection/components/sparkle-character-intro/sparkle-character-intro.js +10 -6
- package/dist/collection/components/sparkle-course-root/sparkle-course-root.js +12 -1
- package/dist/collection/components/sparkle-discussion/sparkle-discussion-questions/sparkle-discussion-questions.css +157 -0
- package/dist/collection/components/sparkle-discussion/sparkle-discussion-questions/sparkle-discussion-questions.js +232 -0
- package/dist/collection/components/sparkle-discussion/sparkle-discussion-results/sparkle-discussion-results.css +158 -0
- package/dist/collection/components/sparkle-discussion/sparkle-discussion-results/sparkle-discussion-results.js +274 -0
- package/dist/collection/components/sparkle-discussion/sparkle-discussion.css +5 -0
- package/dist/collection/components/sparkle-discussion/sparkle-discussion.js +112 -0
- package/dist/collection/components/sparkle-feed-post/sparkle-feed-post.js +54 -67
- package/dist/collection/components/sparkle-login/sparkle-login.js +2 -1
- package/dist/collection/components/sparkle-quiz/{sparkle-quiz/sparkle-quiz.css → sparkle-quiz-old/sparkle-quiz-old.css} +1 -1
- package/dist/collection/components/sparkle-quiz/{sparkle-quiz/sparkle-quiz.js → sparkle-quiz-old/sparkle-quiz-old.js} +4 -4
- package/dist/collection/components/sparkle-quiz/{sparkle-quiz-v1.js → sparkle-quiz.js} +23 -25
- package/dist/collection/components/sparkle-quiz-container/sparkle-quiz-container.js +1 -1
- package/dist/collection/components/sparkle-root/sparkle-root.js +12 -10
- package/dist/collection/services/assignment.service.js +14 -0
- package/dist/collection/services/auth/auth.service.js +15 -14
- package/dist/collection/services/environment/environment-config.js +1 -1
- package/dist/collection/services/environment/environment-config.service.js +0 -1
- package/dist/collection/services/httpService.js +12 -10
- package/dist/collection/services/signalR.service.js +17 -19
- package/dist/collection/services/token.service.js +68 -0
- package/dist/collection/util.js +5 -2
- package/dist/esm/{PrivateRoute-c5441f35.js → PrivateRoute-c6e80d5d.js} +17 -29
- package/dist/esm/{feed.service-8fbe4ce3.js → appdata.service-d1058e00.js} +5 -55
- package/dist/esm/{assets.service-66e848b8.js → assets.service-def1d63c.js} +1 -1
- package/dist/esm/{environment-config.service-2b5d692b.js → environment-config.service-b191f276.js} +0 -1
- package/dist/esm/{facilitator.service-b0292f7f.js → facilitator.service-53e05a01.js} +1 -1
- package/dist/esm/feed.service-8385ad7a.js +54 -0
- package/dist/esm/header-mobile-collapse_61.entry.js +278 -3268
- package/dist/esm/{httpService-7b75b095.js → httpService-db476835.js} +13 -11
- package/dist/esm/index.js +5 -4
- package/dist/esm/{ion-select_2.entry.js → ion-select_3.entry.js} +127 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/media.service-b68cbfff.js +37 -0
- package/dist/esm/signalR.service-4a2d5a92.js +2982 -0
- package/dist/esm/sparkle-animation-player.entry.js +2 -1
- package/dist/esm/sparkle-assignment.entry.js +21 -0
- package/dist/esm/sparkle-character-intro.entry.js +3 -3
- package/dist/esm/sparkle-core.js +1 -1
- package/dist/esm/sparkle-discussion-questions_2.entry.js +276 -0
- package/dist/esm/sparkle-discussion.entry.js +38 -0
- package/dist/esm/sparkle-facilitator-notes-form.entry.js +5 -3
- package/dist/esm/sparkle-feedback.entry.js +5 -3
- package/dist/esm/sparkle-goal-form.entry.js +8 -5
- package/dist/esm/sparkle-quiz-container.entry.js +1 -1
- package/dist/esm/sparkle-quiz-old.entry.js +116 -0
- package/dist/esm/sparkle-quiz.entry.js +31 -48
- package/dist/esm/{student.service-0746418b.js → student.service-6457aaa0.js} +1 -1
- package/dist/esm/token.service-20f1a256.js +83 -0
- package/dist/esm/{util-6ef753e9.js → util-57cc8006.js} +2 -2
- package/dist/sparkle-core/index.esm.js +1 -1
- package/dist/sparkle-core/p-11ac00b0.js +1 -0
- package/dist/sparkle-core/p-13ec39db.entry.js +1 -0
- package/dist/sparkle-core/{p-5efc6566.js → p-17b6b07e.js} +1 -1
- package/dist/sparkle-core/p-33a7151d.entry.js +1 -0
- package/dist/sparkle-core/{p-fbccd30c.js → p-38f707fb.js} +1 -1
- package/dist/sparkle-core/p-38fa5987.js +1 -0
- package/dist/sparkle-core/{p-9a443f51.js → p-408176ba.js} +1 -1
- package/dist/sparkle-core/p-630a4fa0.js +1 -0
- package/dist/sparkle-core/{p-0335c863.entry.js → p-6a1fc0af.entry.js} +26 -26
- package/dist/sparkle-core/p-6fab3a4b.js +1 -0
- package/dist/sparkle-core/p-71720d6e.entry.js +1 -0
- package/dist/sparkle-core/{p-162bff1a.entry.js → p-72053ae0.entry.js} +1 -1
- package/dist/sparkle-core/p-85d4cd5c.entry.js +1 -0
- package/dist/sparkle-core/p-967a2ed7.js +1 -0
- package/dist/sparkle-core/{p-ff0e0d4e.entry.js → p-98daeddb.entry.js} +1 -1
- package/dist/sparkle-core/p-98f7780c.entry.js +1 -0
- package/dist/sparkle-core/p-bd90903e.js +1 -0
- package/dist/sparkle-core/{p-a49ab4e8.entry.js → p-c64a34cd.entry.js} +1 -1
- package/dist/sparkle-core/{p-564e64fc.entry.js → p-ca907214.entry.js} +2 -2
- package/dist/sparkle-core/p-d51f30ca.js +1 -0
- package/dist/sparkle-core/p-dcff298d.entry.js +1 -0
- package/dist/sparkle-core/p-e50c8b04.entry.js +1 -0
- package/dist/sparkle-core/p-ed9de327.js +1 -0
- package/dist/sparkle-core/p-f891c79a.entry.js +1 -0
- package/dist/sparkle-core/sparkle-core.esm.js +1 -1
- package/dist/types/components/layout/page/page.d.ts +2 -0
- package/dist/types/components/sparkle-assignment/sparkle-assignment.d.ts +6 -0
- package/dist/types/components/sparkle-course-root/sparkle-course-root.d.ts +1 -0
- package/dist/types/components/sparkle-discussion/sparkle-discussion-questions/sparkle-discussion-questions.d.ts +28 -0
- package/dist/types/components/sparkle-discussion/sparkle-discussion-results/sparkle-discussion-results.d.ts +45 -0
- package/dist/types/components/sparkle-discussion/sparkle-discussion.d.ts +11 -0
- package/dist/types/components/sparkle-feed-post/sparkle-feed-post.d.ts +3 -2
- package/dist/types/components/sparkle-quiz/{sparkle-quiz/sparkle-quiz.d.ts → sparkle-quiz-old/sparkle-quiz-old.d.ts} +1 -1
- package/dist/types/components/sparkle-quiz/sparkle-quiz.d.ts +36 -36
- package/dist/types/components.d.ts +115 -37
- package/dist/types/models/class.model.d.ts +4 -0
- package/dist/types/services/assignment.service.d.ts +8 -0
- package/dist/types/services/auth/auth.service.d.ts +1 -1
- package/dist/types/services/environment/environment-config.d.ts +3 -0
- package/dist/types/services/token.service.d.ts +12 -0
- package/dist/types/util.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/sparkle-feed-post.cjs.entry.js +0 -124
- package/dist/cjs/sparkle-quiz-v1.cjs.entry.js +0 -105
- package/dist/esm/sparkle-feed-post.entry.js +0 -120
- package/dist/esm/sparkle-quiz-v1.entry.js +0 -101
- package/dist/sparkle-core/p-15403881.entry.js +0 -1
- package/dist/sparkle-core/p-1d4c7c11.js +0 -1
- package/dist/sparkle-core/p-370609ba.entry.js +0 -1
- package/dist/sparkle-core/p-41a9ece7.entry.js +0 -1
- package/dist/sparkle-core/p-462bffba.js +0 -1
- package/dist/sparkle-core/p-58e4bbe5.entry.js +0 -1
- package/dist/sparkle-core/p-600cf6a3.js +0 -1
- package/dist/sparkle-core/p-80d6b0e6.entry.js +0 -1
- package/dist/sparkle-core/p-af3cc111.entry.js +0 -1
- package/dist/sparkle-core/p-b226f54d.js +0 -1
- package/dist/types/components/sparkle-quiz/sparkle-quiz-v1.d.ts +0 -41
- /package/dist/collection/components/sparkle-quiz/{sparkle-quiz-v1.css → sparkle-quiz.css} +0 -0
- /package/dist/sparkle-core/{p-935e7cfc.js → p-8b56f734.js} +0 -0
@@ -1,5 +1,9 @@
|
|
1
1
|
import { Component, Element, State, Prop, Method, h, Host } from '@stencil/core';
|
2
|
-
import {
|
2
|
+
import { AssignmentService } from '../../services/assignment.service';
|
3
|
+
import { FeedService } from '../../services/feed.service';
|
4
|
+
import { MediaService } from '../../services/media.service';
|
5
|
+
import { TokenService } from '../../services/token.service';
|
6
|
+
import { SparkleGlobal } from '../../util';
|
3
7
|
export class SparkleFeedPost {
|
4
8
|
// @Prop({ connect: 'ion-toast-controller' })
|
5
9
|
// toastCtrl: HTMLIonToastControllerElement;
|
@@ -13,26 +17,10 @@ export class SparkleFeedPost {
|
|
13
17
|
setText(text) {
|
14
18
|
this.postText = text;
|
15
19
|
}
|
16
|
-
// async postToFeed() {
|
17
|
-
// const sparkleConfig: EnvironmentSparkleConfig = EnvironmentConfigService.getInstance().get('sparkle');
|
18
|
-
// const tocData = await AssetsService.getInstance().loadJsonFile<ICourse>(sparkleConfig.tocPath);
|
19
|
-
// var model = {
|
20
|
-
// CourseId: tocData.id,
|
21
|
-
// MiniAppId: SparkleGlobal.MY_GOALS_APP_ID,
|
22
|
-
// PostText: MyGoalTemplate(this.name.value, this.goalUpdateText.value, this.progress),
|
23
|
-
// PostTextJSON: MyGoalTemplateJSON(this.name.value, this.goalUpdateText.value, this.progress),
|
24
|
-
// IsPublic: this.public,
|
25
|
-
// ExternalResourceUrl: "",
|
26
|
-
// }
|
27
|
-
// const result = await FeedService.getInstance().createPost(model);
|
28
|
-
// if (result.Succeeded) {
|
29
|
-
// //show success toast
|
30
|
-
// }
|
31
|
-
// }
|
32
20
|
isAuthenticated() {
|
33
21
|
try {
|
34
|
-
|
35
|
-
if (!!
|
22
|
+
let token = TokenService.getInstance().getTokenSync();
|
23
|
+
if (!!token) {
|
36
24
|
return true;
|
37
25
|
}
|
38
26
|
}
|
@@ -40,7 +28,8 @@ export class SparkleFeedPost {
|
|
40
28
|
return false;
|
41
29
|
}
|
42
30
|
}
|
43
|
-
submitPost() {
|
31
|
+
async submitPost() {
|
32
|
+
this.postLoading = true;
|
44
33
|
this.errorMessage = '';
|
45
34
|
this.successMessage = '';
|
46
35
|
//let formData = new FormData(this.el.querySelector("form")) as any;
|
@@ -51,60 +40,56 @@ export class SparkleFeedPost {
|
|
51
40
|
PostText: this.postText,
|
52
41
|
IsPublic: isPublic.checked,
|
53
42
|
ExternalResourceUrl: postExternalUrl.value,
|
54
|
-
MiniAppId:
|
43
|
+
MiniAppId: SparkleGlobal.MY_GOALS_APP_ID,
|
55
44
|
AssignmentName: this.assignmentName,
|
56
45
|
AssignmentData: '',
|
46
|
+
PostTextJSON: null,
|
57
47
|
};
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
// // this.presentToast('There is an error');
|
79
|
-
// },
|
80
|
-
// );
|
81
|
-
// }
|
48
|
+
const result = await FeedService.getInstance().createPost(data);
|
49
|
+
if (result.Succeeded) {
|
50
|
+
this.postLoading = false;
|
51
|
+
//show success toast
|
52
|
+
this.successMessage = 'Posted Successfully.';
|
53
|
+
this.postText = '';
|
54
|
+
this.externalResourceUrl = '';
|
55
|
+
this.uploadedImage = '';
|
56
|
+
}
|
57
|
+
else {
|
58
|
+
this.postLoading = false;
|
59
|
+
this.errorMessage = 'There is an error while posting to feed.';
|
60
|
+
}
|
61
|
+
if (this.assignmentName) {
|
62
|
+
var assignmentModel = {
|
63
|
+
AssignmentData: JSON.stringify({ text: data.PostText, url: data.ExternalResourceUrl }),
|
64
|
+
AssignmentName: this.assignmentName,
|
65
|
+
};
|
66
|
+
await AssignmentService.getInstance().createAssignment(assignmentModel);
|
67
|
+
}
|
82
68
|
}
|
83
|
-
uploadImage(evt) {
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
// },
|
98
|
-
// );
|
69
|
+
async uploadImage(evt) {
|
70
|
+
this.uploadImageLoading = true;
|
71
|
+
var files = evt.target.files;
|
72
|
+
let result = await MediaService.getInstance().uploadImage(files);
|
73
|
+
if (result.Succeeded) {
|
74
|
+
console.log(result);
|
75
|
+
this.uploadImageLoading = false;
|
76
|
+
this.uploadedImage = result.Data.length > 0 ? result.Data[0].FullImageUrl : '';
|
77
|
+
this.externalResourceUrl = result.Data.length > 0 ? result.Data[0].FullImageUrl : '';
|
78
|
+
}
|
79
|
+
else {
|
80
|
+
this.uploadImageLoading = false;
|
81
|
+
this.errorMessage = 'There is an error while uploading an image.';
|
82
|
+
}
|
99
83
|
}
|
100
84
|
selectFile() {
|
101
85
|
var fileInput = document.getElementById('fileInput');
|
102
86
|
fileInput.click();
|
103
87
|
}
|
104
88
|
renderUserInfo() {
|
105
|
-
|
106
|
-
|
107
|
-
|
89
|
+
let authUser = TokenService.getInstance().getAuthUserSync();
|
90
|
+
//var tokenInfo = { Token: null, ProfileImageUrl: null };
|
91
|
+
if (authUser && authUser.JWToken) {
|
92
|
+
return (h("ion-avatar", { class: "header-avatar", slot: "end" }, authUser.PhotoUrl ? h("img", { src: authUser.PhotoUrl }) : h("img", { src: "/assets/img/user.png" })));
|
108
93
|
}
|
109
94
|
else {
|
110
95
|
return (h("ion-button", { slot: "end", href: "/login" }, "Login to Post"));
|
@@ -124,7 +109,7 @@ export class SparkleFeedPost {
|
|
124
109
|
h("ion-textarea", { class: "PostText", required: true, placeholder: "Post Text", name: "PostText", value: this.postText })),
|
125
110
|
h("ion-item", { class: "padding" },
|
126
111
|
h("ion-input", { class: "PostExternalUrl", required: true, type: "text", placeholder: "URL", name: "ExternalResourceUrl", value: this.externalResourceUrl })),
|
127
|
-
this.uploadedImage ? (h("ion-item", { class: "padding" },
|
112
|
+
this.uploadedImage ? (h("ion-item", { class: "ion-padding", lines: "none" },
|
128
113
|
h("img", { class: "uploaded-image", src: this.uploadedImage }))) : (''),
|
129
114
|
h("ion-item", { lines: "none" },
|
130
115
|
h("input", { type: "file", id: "fileInput", onChange: evt => this.uploadImage(evt), style: { display: 'none' }, accept: "image/*" }),
|
@@ -140,7 +125,8 @@ export class SparkleFeedPost {
|
|
140
125
|
h("div", null,
|
141
126
|
h("div", { class: "error" }, this.errorMessage),
|
142
127
|
h("div", { class: "success" }, this.successMessage)),
|
143
|
-
h("
|
128
|
+
h("div", null, this.postLoading ? h("ion-spinner", { color: "primary" }) : ''),
|
129
|
+
h("ion-button", { slot: "end", size: "default", onClick: evt => this.submitPost(), disabled: this.postLoading || !this.isAuthenticated() }, "Post")))))))));
|
144
130
|
}
|
145
131
|
static get is() { return "sparkle-feed-post"; }
|
146
132
|
static get originalStyleUrls() { return {
|
@@ -191,7 +177,8 @@ export class SparkleFeedPost {
|
|
191
177
|
"uploadedImage": {},
|
192
178
|
"successMessage": {},
|
193
179
|
"externalResourceUrl": {},
|
194
|
-
"uploadImageLoading": {}
|
180
|
+
"uploadImageLoading": {},
|
181
|
+
"postLoading": {}
|
195
182
|
}; }
|
196
183
|
static get methods() { return {
|
197
184
|
"setText": {
|
@@ -69,7 +69,8 @@ export class PageLogin {
|
|
69
69
|
Password: this.password.value,
|
70
70
|
RememberClient: this.rememberMe.value
|
71
71
|
});
|
72
|
-
|
72
|
+
console.log(result);
|
73
|
+
//sessionStorage.setItem('rememberMe', this.rememberMe.value == true ? '1' : '0');
|
73
74
|
this.userDidLogIn.emit({ loginStatus: true });
|
74
75
|
}
|
75
76
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Component, Prop, Listen, State, Event, Element, h } from '@stencil/core';
|
2
|
-
export class
|
2
|
+
export class SparkleQuizOld {
|
3
3
|
constructor() {
|
4
4
|
this.type = 'TEXT';
|
5
5
|
this.scale = 'FIVE-POINTS';
|
@@ -110,12 +110,12 @@ export class SparkleQuiz {
|
|
110
110
|
return h("p", null, "No question found.");
|
111
111
|
}
|
112
112
|
}
|
113
|
-
static get is() { return "sparkle-quiz"; }
|
113
|
+
static get is() { return "sparkle-quiz-old"; }
|
114
114
|
static get originalStyleUrls() { return {
|
115
|
-
"$": ["sparkle-quiz.scss"]
|
115
|
+
"$": ["sparkle-quiz-old.scss"]
|
116
116
|
}; }
|
117
117
|
static get styleUrls() { return {
|
118
|
-
"$": ["sparkle-quiz.css"]
|
118
|
+
"$": ["sparkle-quiz-old.css"]
|
119
119
|
}; }
|
120
120
|
static get properties() { return {
|
121
121
|
"questionId": {
|
@@ -1,53 +1,52 @@
|
|
1
1
|
import { Component, Prop, Watch, Listen, State, Event, Element, h } from '@stencil/core';
|
2
2
|
import { AssetsService } from '../../services/core/assets.service';
|
3
|
-
import { EnvironmentConfigService } from
|
4
|
-
export class
|
3
|
+
import { EnvironmentConfigService } from '../../services/environment/environment-config.service';
|
4
|
+
export class SparkleQuiz {
|
5
5
|
async loadQuestion() {
|
6
6
|
if (this.quizData) {
|
7
7
|
this.question = this.quizData[+this.questionId];
|
8
8
|
}
|
9
9
|
}
|
10
|
-
async componentWillLoad() {
|
11
|
-
}
|
10
|
+
async componentWillLoad() { }
|
12
11
|
async componentDidLoad() {
|
13
12
|
const config = EnvironmentConfigService.getInstance().get('sparkle');
|
14
13
|
this.quizData = await AssetsService.getInstance().loadJsonFile(config.quizPath);
|
15
14
|
await this.loadQuestion();
|
16
15
|
this.quizAnswerChanged.emit({
|
17
16
|
question: null,
|
18
|
-
answer:
|
17
|
+
answer: '1',
|
19
18
|
});
|
20
19
|
}
|
21
20
|
quizInputChangeHandler(event) {
|
22
21
|
this.quizAnswerChanged.emit({
|
23
22
|
question: event.detail.question,
|
24
|
-
answer: event.detail.value
|
23
|
+
answer: event.detail.value,
|
25
24
|
});
|
26
25
|
}
|
27
26
|
quizFeedbackChangeHandler(event) {
|
28
27
|
this.quizAnswerChanged.emit({
|
29
28
|
question: event.detail.question,
|
30
|
-
answer: event.detail.value
|
29
|
+
answer: event.detail.value,
|
31
30
|
});
|
32
31
|
}
|
33
32
|
quizSelectChangeHandler(event) {
|
34
33
|
this.quizAnswerChanged.emit({
|
35
34
|
question: event.detail.question,
|
36
|
-
answer: event.detail.value
|
35
|
+
answer: event.detail.value,
|
37
36
|
});
|
38
37
|
}
|
39
38
|
quizOpinionChangeHandler(event) {
|
40
39
|
this.quizAnswerChanged.emit({
|
41
40
|
question: event.detail.question,
|
42
|
-
answer: event.detail.value
|
41
|
+
answer: event.detail.value,
|
43
42
|
});
|
44
43
|
}
|
45
44
|
getQuestionFeedback() {
|
46
|
-
if (this.question.questionType ==
|
45
|
+
if (this.question.questionType == 'MULTIPLE-CHOICE') {
|
47
46
|
const feedbacks = this.question.options.filter(x => x.correct == true).map(x => x.feedback);
|
48
47
|
return feedbacks.length > 0 && feedbacks.map(feedback => h("small", null, feedback));
|
49
48
|
}
|
50
|
-
else if (this.question.questionType ==
|
49
|
+
else if (this.question.questionType == 'FEEDBACK' || this.question.questionType == 'TEXT') {
|
51
50
|
return this.question.feedback && h("small", null,
|
52
51
|
" ",
|
53
52
|
this.question.feedback);
|
@@ -57,43 +56,42 @@ export class SparkleQuizV1 {
|
|
57
56
|
return h("div", null, this.correct ? h("strong", null, "Good job!") : h("strong", null, "Incorrect answer, please try again."));
|
58
57
|
}
|
59
58
|
renderQuestion() {
|
60
|
-
if (this.question.questionType ==
|
59
|
+
if (this.question.questionType == 'MULTIPLE-CHOICE') {
|
61
60
|
return h("sparkle-quiz-select", { question: this.question, allowMultiple: true });
|
62
61
|
}
|
63
|
-
else if (this.question.questionType ==
|
62
|
+
else if (this.question.questionType == 'FEEDBACK') {
|
64
63
|
return h("sparkle-quiz-feedback", { question: this.question });
|
65
64
|
}
|
66
|
-
else if (this.question.questionType ==
|
65
|
+
else if (this.question.questionType == 'TEXT') {
|
67
66
|
return h("sparkle-quiz-input", { question: this.question });
|
68
67
|
}
|
69
|
-
else if (this.question.questionType ==
|
68
|
+
else if (this.question.questionType == 'OPINION') {
|
70
69
|
return h("sparkle-quiz-opinion", { question: this.question });
|
71
70
|
}
|
72
|
-
else if (this.question.questionType ==
|
71
|
+
else if (this.question.questionType == 'POLL') {
|
73
72
|
return h("sparkle-quiz-poll", { question: this.question });
|
74
73
|
}
|
75
74
|
}
|
76
75
|
render() {
|
77
76
|
if (this.question) {
|
78
77
|
let classes = {
|
79
|
-
|
80
|
-
|
78
|
+
correct: this.submitted && this.correct,
|
79
|
+
incorrect: this.submitted && !this.correct,
|
81
80
|
};
|
82
|
-
return h("div", { class: classes },
|
81
|
+
return (h("div", { class: classes },
|
83
82
|
this.renderQuestion(),
|
84
|
-
this.submitted && this.showInstantResult && h("div", { class: "feedback-container" }, [this.showAnswerStatus(),
|
85
|
-
this.getQuestionFeedback()]));
|
83
|
+
this.submitted && this.showInstantResult && h("div", { class: "feedback-container" }, [this.showAnswerStatus(), this.getQuestionFeedback()])));
|
86
84
|
}
|
87
85
|
else {
|
88
86
|
return h("p", null, "No question found.");
|
89
87
|
}
|
90
88
|
}
|
91
|
-
static get is() { return "sparkle-quiz
|
89
|
+
static get is() { return "sparkle-quiz"; }
|
92
90
|
static get originalStyleUrls() { return {
|
93
|
-
"$": ["sparkle-quiz
|
91
|
+
"$": ["sparkle-quiz.scss"]
|
94
92
|
}; }
|
95
93
|
static get styleUrls() { return {
|
96
|
-
"$": ["sparkle-quiz
|
94
|
+
"$": ["sparkle-quiz.css"]
|
97
95
|
}; }
|
98
96
|
static get properties() { return {
|
99
97
|
"questionId": {
|
@@ -180,7 +178,7 @@ export class SparkleQuizV1 {
|
|
180
178
|
"text": ""
|
181
179
|
},
|
182
180
|
"complexType": {
|
183
|
-
"original": "{ answer: any
|
181
|
+
"original": "{ answer: any; question: SparkleQuizQuestion }",
|
184
182
|
"resolved": "{ answer: any; question: SparkleQuizQuestion; }",
|
185
183
|
"references": {
|
186
184
|
"SparkleQuizQuestion": {
|
@@ -32,7 +32,7 @@ export class SparkleQuizContainer {
|
|
32
32
|
}
|
33
33
|
render() {
|
34
34
|
return (h(Host, null,
|
35
|
-
this.questionIds && this.questionIds.split(",").map((id => h("sparkle-quiz", { questionId: +id, submitted: this.submitted, showInstantResult: this.showInstantResult }))),
|
35
|
+
this.questionIds && this.questionIds.split(",").map((id => h("sparkle-quiz-v1", { questionId: +id, submitted: this.submitted, showInstantResult: this.showInstantResult }))),
|
36
36
|
h("ion-button", { slot: "end", onClick: () => this.submitQuiz() }, "Submit")));
|
37
37
|
}
|
38
38
|
static get is() { return "sparkle-quiz-container"; }
|
@@ -2,30 +2,32 @@ import { Component, Host, h, Prop } from '@stencil/core';
|
|
2
2
|
import { setupConfig as setupSparkleConfig } from '../../services/environment/environment-config';
|
3
3
|
import { HttpService } from '../../services/httpService';
|
4
4
|
import { StudentService } from '../../services/student.service';
|
5
|
-
import {
|
6
|
-
import { AuthStore } from "../../stores/auth.store";
|
5
|
+
import { AuthStore } from '../../stores/auth.store';
|
7
6
|
import { SignalRService } from '../../services/signalR.service';
|
8
7
|
import { injectHistory } from '@stencil/router';
|
8
|
+
import { get } from '../../services/core/localstorage.service';
|
9
|
+
import AppConsts from '../../appconst';
|
9
10
|
export class SparkleRoot {
|
10
11
|
constructor() {
|
11
12
|
this.history = null;
|
12
|
-
this.handleStudentNavigationChange =
|
13
|
+
this.handleStudentNavigationChange = url => {
|
13
14
|
this.history.replace(url, {});
|
14
15
|
};
|
15
16
|
}
|
16
17
|
async componentWillLoad() {
|
17
18
|
setupSparkleConfig({
|
18
|
-
sparkle: Object.assign(Object.assign({}, this.config), { prod: true })
|
19
|
+
sparkle: Object.assign(Object.assign({}, this.config), { prod: true }),
|
19
20
|
});
|
20
21
|
//return Promise.reject();
|
21
22
|
await HttpService.getInstance();
|
22
23
|
await HttpService.init();
|
23
|
-
|
24
|
-
|
24
|
+
let auth = await get(AppConsts.AUTH_USER_LOCALSTORAGE);
|
25
|
+
console.log(auth);
|
26
|
+
//TODO: check expiry as well
|
27
|
+
if (auth && auth.JWToken) {
|
25
28
|
AuthStore.state.isAuthenticated = true;
|
26
29
|
}
|
27
|
-
|
28
|
-
AuthStore.onChange("isAuthenticated", async (isAuthenticated) => {
|
30
|
+
AuthStore.onChange('isAuthenticated', async (isAuthenticated) => {
|
29
31
|
if (isAuthenticated) {
|
30
32
|
console.log('authenticated');
|
31
33
|
await StudentService.getInstance().fetchUserConfiguration();
|
@@ -37,8 +39,8 @@ export class SparkleRoot {
|
|
37
39
|
//SignalRAspNetCoreHelper.initSignalR();
|
38
40
|
}
|
39
41
|
componentDidLoad() {
|
40
|
-
SignalRService.getInstance().connection.on(
|
41
|
-
AuthStore.onChange(
|
42
|
+
SignalRService.getInstance().connection.on('NavigateStudentTo', this.handleStudentNavigationChange);
|
43
|
+
AuthStore.onChange('isAuthenticated', async (isAuthenticated) => {
|
42
44
|
if (isAuthenticated) {
|
43
45
|
SignalRService.getInstance().start();
|
44
46
|
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { HttpService } from './httpService';
|
2
|
+
export class AssignmentService {
|
3
|
+
constructor() { }
|
4
|
+
static getInstance() {
|
5
|
+
if (!AssignmentService.instance) {
|
6
|
+
AssignmentService.instance = new AssignmentService();
|
7
|
+
}
|
8
|
+
return AssignmentService.instance;
|
9
|
+
}
|
10
|
+
async createAssignment(payload) {
|
11
|
+
let result = await HttpService.http.post(`api/v1/Assignment/Create`, payload);
|
12
|
+
return result;
|
13
|
+
}
|
14
|
+
}
|
@@ -1,7 +1,8 @@
|
|
1
|
-
import { get,
|
1
|
+
import { get, remove } from '../core/localstorage.service';
|
2
2
|
import { HttpService } from '../httpService';
|
3
3
|
import AppConsts from '../../appconst';
|
4
|
-
import { AuthStore } from
|
4
|
+
import { AuthStore } from '../../stores/auth.store';
|
5
|
+
import { TokenService } from '../token.service';
|
5
6
|
export class AuthService {
|
6
7
|
constructor() { }
|
7
8
|
static getInstance() {
|
@@ -18,7 +19,7 @@ export class AuthService {
|
|
18
19
|
let result;
|
19
20
|
try {
|
20
21
|
result = await HttpService.http.post('api/Account/Authenticate', authenticationInput, {
|
21
|
-
headers: headers
|
22
|
+
headers: headers,
|
22
23
|
});
|
23
24
|
if (result) {
|
24
25
|
const authData = result.Data;
|
@@ -32,15 +33,17 @@ export class AuthService {
|
|
32
33
|
IssuedOn: authData.IssuedOn,
|
33
34
|
ExpiresOn: authData.ExpiresOn,
|
34
35
|
RefreshToken: authData.RefreshToken,
|
35
|
-
PhotoUrl:
|
36
|
-
IsFacilitator: authData.Roles.indexOf(
|
36
|
+
PhotoUrl: '',
|
37
|
+
IsFacilitator: authData.Roles.indexOf('Facilitator') > 0,
|
37
38
|
};
|
38
|
-
const expireDate = authenticationInput.RememberClient ? new Date(authUser.ExpiresOn) : undefined;
|
39
|
-
|
40
|
-
//
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
//const expireDate = authenticationInput.RememberClient ? new Date(authUser.ExpiresOn) : undefined;
|
40
|
+
// let authObj: EnvironmentAuthConfig = {
|
41
|
+
// token: authUser.JWToken,
|
42
|
+
// expiryDate: expireDate,
|
43
|
+
// };
|
44
|
+
// EnvironmentConfigService.getInstance().setupAuth(authObj);
|
45
|
+
//sparkle.utils.setCookieValue(AppConsts.authorization.encrptedAuthTokenName, authUser.JWToken, expireDate, sparkle.appPath);
|
46
|
+
await TokenService.getInstance().saveAuthUser(authUser);
|
44
47
|
AuthStore.state.loading = false;
|
45
48
|
return authUser;
|
46
49
|
}
|
@@ -52,10 +55,8 @@ export class AuthService {
|
|
52
55
|
}
|
53
56
|
async signOut() {
|
54
57
|
await remove(AppConsts.AUTH_USER_LOCALSTORAGE);
|
58
|
+
await TokenService.getInstance().removeAuthUser();
|
55
59
|
sessionStorage.clear();
|
56
|
-
sparkle.auth.clearToken();
|
57
|
-
AuthStore.state.authUser = null;
|
58
|
-
AuthStore.state.isAuthenticated = false;
|
59
60
|
}
|
60
61
|
async getLocalAuthUser() {
|
61
62
|
return get(AppConsts.AUTH_USER_LOCALSTORAGE);
|
@@ -3,6 +3,7 @@ import qs from 'qs';
|
|
3
3
|
import { toastController } from '@ionic/core';
|
4
4
|
import { TocStore } from '../stores/toc.store';
|
5
5
|
import { EnvironmentConfigService } from '.';
|
6
|
+
import { TokenService } from './token.service';
|
6
7
|
export class HttpService {
|
7
8
|
constructor() { }
|
8
9
|
static getInstance() {
|
@@ -16,7 +17,7 @@ export class HttpService {
|
|
16
17
|
this.http = axios.create({
|
17
18
|
baseURL: sparkleConfig.apiUrl,
|
18
19
|
headers: {
|
19
|
-
'Content-Type': 'application/json'
|
20
|
+
'Content-Type': 'application/json',
|
20
21
|
},
|
21
22
|
timeout: 30000,
|
22
23
|
paramsSerializer: function (params) {
|
@@ -25,9 +26,10 @@ export class HttpService {
|
|
25
26
|
});
|
26
27
|
},
|
27
28
|
});
|
28
|
-
this.http.interceptors.request.use(function (config) {
|
29
|
-
|
30
|
-
|
29
|
+
this.http.interceptors.request.use(async function (config) {
|
30
|
+
let token = await TokenService.getInstance().getToken();
|
31
|
+
if (token) {
|
32
|
+
config.headers.common['Authorization'] = 'Bearer ' + token;
|
31
33
|
}
|
32
34
|
// //config.headers.common['.AspNetCore.Culture'] = sparkle.utils.getCookieValue('Sparkle.Localization.CultureName');
|
33
35
|
config.headers.common['Sparkle.CourseId'] = sparkleConfig.courseId;
|
@@ -45,7 +47,7 @@ export class HttpService {
|
|
45
47
|
if (response.data.Message) {
|
46
48
|
const toast = await toastController.create({
|
47
49
|
message: response.data.Message,
|
48
|
-
duration: 3000
|
50
|
+
duration: 3000,
|
49
51
|
});
|
50
52
|
toast.present();
|
51
53
|
}
|
@@ -56,7 +58,7 @@ export class HttpService {
|
|
56
58
|
// that falls out of the range of 2xx
|
57
59
|
const toast = await toastController.create({
|
58
60
|
message: error.response.data.ErrorMessage,
|
59
|
-
duration: 3000
|
61
|
+
duration: 3000,
|
60
62
|
});
|
61
63
|
toast.present();
|
62
64
|
return Promise.reject(error);
|
@@ -66,7 +68,7 @@ export class HttpService {
|
|
66
68
|
// that falls out of the range of 2xx
|
67
69
|
const toast = await toastController.create({
|
68
70
|
message: error.response.data.Message,
|
69
|
-
duration: 3000
|
71
|
+
duration: 3000,
|
70
72
|
});
|
71
73
|
toast.present();
|
72
74
|
return Promise.reject(error.response.data);
|
@@ -76,7 +78,7 @@ export class HttpService {
|
|
76
78
|
// that falls out of the range of 2xx
|
77
79
|
const toast = await toastController.create({
|
78
80
|
message: error.response.data.Message,
|
79
|
-
duration: 3000
|
81
|
+
duration: 3000,
|
80
82
|
});
|
81
83
|
toast.present();
|
82
84
|
return Promise.reject(error);
|
@@ -89,8 +91,8 @@ export class HttpService {
|
|
89
91
|
}
|
90
92
|
else {
|
91
93
|
const toast = await toastController.create({
|
92
|
-
message:
|
93
|
-
duration: 3000
|
94
|
+
message: 'Unknown Error',
|
95
|
+
duration: 3000,
|
94
96
|
});
|
95
97
|
toast.present();
|
96
98
|
}
|