@sparkle-learning/core 0.0.53 → 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.
Files changed (140) hide show
  1. package/dist/cjs/{PrivateRoute-074c584e.js → PrivateRoute-e2047db2.js} +18 -30
  2. package/dist/cjs/{feed.service-b4f09441.js → appdata.service-d28cf2d6.js} +4 -56
  3. package/dist/cjs/{assets.service-0c759d51.js → assets.service-bfa75092.js} +1 -1
  4. package/dist/cjs/{environment-config.service-0e02b049.js → environment-config.service-c8ff1f3d.js} +0 -1
  5. package/dist/cjs/{facilitator.service-9e990274.js → facilitator.service-0b9f6ac7.js} +1 -1
  6. package/dist/cjs/feed.service-6df9382f.js +57 -0
  7. package/dist/cjs/header-mobile-collapse_61.cjs.entry.js +76 -87
  8. package/dist/cjs/{httpService-7211d93b.js → httpService-d8a5b474.js} +13 -11
  9. package/dist/cjs/index.cjs.js +5 -4
  10. package/dist/cjs/ion-select_3.cjs.entry.js +77 -68
  11. package/dist/cjs/loader.cjs.js +1 -1
  12. package/dist/cjs/media.service-2bc73d37.js +40 -0
  13. package/dist/cjs/{signalR.service-5672eebc.js → signalR.service-0d5da1d3.js} +18 -20
  14. package/dist/cjs/sparkle-animation-player.cjs.entry.js +1 -1
  15. package/dist/cjs/sparkle-assignment.cjs.entry.js +25 -0
  16. package/dist/cjs/sparkle-character-intro.cjs.entry.js +2 -2
  17. package/dist/cjs/sparkle-core.cjs.js +1 -1
  18. package/dist/cjs/sparkle-discussion-questions_2.cjs.entry.js +20 -11
  19. package/dist/cjs/sparkle-discussion.cjs.entry.js +6 -4
  20. package/dist/cjs/sparkle-facilitator-notes-form.cjs.entry.js +5 -3
  21. package/dist/cjs/sparkle-feedback.cjs.entry.js +5 -3
  22. package/dist/cjs/sparkle-goal-form.cjs.entry.js +11 -8
  23. package/dist/cjs/sparkle-quiz-container.cjs.entry.js +1 -1
  24. package/dist/cjs/sparkle-quiz-old.cjs.entry.js +120 -0
  25. package/dist/cjs/sparkle-quiz.cjs.entry.js +31 -48
  26. package/dist/cjs/{student.service-2e58f237.js → student.service-d8ec2551.js} +1 -1
  27. package/dist/cjs/token.service-bfb0089b.js +86 -0
  28. package/dist/cjs/{util-d383acb8.js → util-47e320b2.js} +2 -2
  29. package/dist/collection/PrivateRoute.js +2 -2
  30. package/dist/collection/collection-manifest.json +3 -2
  31. package/dist/collection/components/layout/facilitator/facilitator-page.js +2 -3
  32. package/dist/collection/components/layout/page/page.css +4 -0
  33. package/dist/collection/components/layout/page/page.js +39 -26
  34. package/dist/collection/components/sparkle-assignment/sparkle-assignment.css +3 -0
  35. package/dist/collection/components/sparkle-assignment/sparkle-assignment.js +25 -0
  36. package/dist/collection/components/sparkle-character-intro/sparkle-character-intro.css +8 -1
  37. package/dist/collection/components/sparkle-character-intro/sparkle-character-intro.js +10 -6
  38. package/dist/collection/components/sparkle-course-root/sparkle-course-root.js +13 -2
  39. package/dist/collection/components/sparkle-discussion/sparkle-discussion-questions/sparkle-discussion-questions.js +4 -2
  40. package/dist/collection/components/sparkle-discussion/sparkle-discussion-results/sparkle-discussion-results.js +15 -9
  41. package/dist/collection/components/sparkle-discussion/sparkle-discussion.css +5 -0
  42. package/dist/collection/components/sparkle-discussion/sparkle-discussion.js +5 -3
  43. package/dist/collection/components/sparkle-feed-post/sparkle-feed-post.js +54 -67
  44. package/dist/collection/components/sparkle-login/sparkle-login.js +2 -1
  45. package/dist/collection/components/sparkle-quiz/{sparkle-quiz/sparkle-quiz.css → sparkle-quiz-old/sparkle-quiz-old.css} +1 -1
  46. package/dist/collection/components/sparkle-quiz/{sparkle-quiz/sparkle-quiz.js → sparkle-quiz-old/sparkle-quiz-old.js} +4 -4
  47. package/dist/collection/components/sparkle-quiz/{sparkle-quiz-v1.js → sparkle-quiz.js} +23 -25
  48. package/dist/collection/components/sparkle-quiz-container/sparkle-quiz-container.js +1 -1
  49. package/dist/collection/components/sparkle-root/sparkle-root.js +12 -10
  50. package/dist/collection/services/assignment.service.js +14 -0
  51. package/dist/collection/services/auth/auth.service.js +15 -14
  52. package/dist/collection/services/environment/environment-config.js +1 -1
  53. package/dist/collection/services/environment/environment-config.service.js +0 -1
  54. package/dist/collection/services/httpService.js +12 -10
  55. package/dist/collection/services/signalR.service.js +17 -19
  56. package/dist/collection/services/token.service.js +68 -0
  57. package/dist/collection/util.js +5 -2
  58. package/dist/esm/{PrivateRoute-c5441f35.js → PrivateRoute-c6e80d5d.js} +17 -29
  59. package/dist/esm/{feed.service-8fbe4ce3.js → appdata.service-d1058e00.js} +5 -55
  60. package/dist/esm/{assets.service-66e848b8.js → assets.service-def1d63c.js} +1 -1
  61. package/dist/esm/{environment-config.service-2b5d692b.js → environment-config.service-b191f276.js} +0 -1
  62. package/dist/esm/{facilitator.service-b0292f7f.js → facilitator.service-53e05a01.js} +1 -1
  63. package/dist/esm/feed.service-8385ad7a.js +54 -0
  64. package/dist/esm/header-mobile-collapse_61.entry.js +70 -81
  65. package/dist/esm/{httpService-7b75b095.js → httpService-db476835.js} +13 -11
  66. package/dist/esm/index.js +5 -4
  67. package/dist/esm/ion-select_3.entry.js +77 -68
  68. package/dist/esm/loader.js +1 -1
  69. package/dist/esm/media.service-b68cbfff.js +37 -0
  70. package/dist/esm/{signalR.service-9d5b9f36.js → signalR.service-4a2d5a92.js} +18 -20
  71. package/dist/esm/sparkle-animation-player.entry.js +1 -1
  72. package/dist/esm/sparkle-assignment.entry.js +21 -0
  73. package/dist/esm/sparkle-character-intro.entry.js +3 -3
  74. package/dist/esm/sparkle-core.js +1 -1
  75. package/dist/esm/sparkle-discussion-questions_2.entry.js +20 -11
  76. package/dist/esm/sparkle-discussion.entry.js +6 -4
  77. package/dist/esm/sparkle-facilitator-notes-form.entry.js +5 -3
  78. package/dist/esm/sparkle-feedback.entry.js +5 -3
  79. package/dist/esm/sparkle-goal-form.entry.js +8 -5
  80. package/dist/esm/sparkle-quiz-container.entry.js +1 -1
  81. package/dist/esm/sparkle-quiz-old.entry.js +116 -0
  82. package/dist/esm/sparkle-quiz.entry.js +31 -48
  83. package/dist/esm/{student.service-0746418b.js → student.service-6457aaa0.js} +1 -1
  84. package/dist/esm/token.service-20f1a256.js +83 -0
  85. package/dist/esm/{util-6ef753e9.js → util-57cc8006.js} +2 -2
  86. package/dist/sparkle-core/index.esm.js +1 -1
  87. package/dist/sparkle-core/p-11ac00b0.js +1 -0
  88. package/dist/sparkle-core/p-13ec39db.entry.js +1 -0
  89. package/dist/sparkle-core/{p-5efc6566.js → p-17b6b07e.js} +1 -1
  90. package/dist/sparkle-core/p-33a7151d.entry.js +1 -0
  91. package/dist/sparkle-core/{p-fbccd30c.js → p-38f707fb.js} +1 -1
  92. package/dist/sparkle-core/p-38fa5987.js +1 -0
  93. package/dist/sparkle-core/{p-9a443f51.js → p-408176ba.js} +1 -1
  94. package/dist/sparkle-core/p-630a4fa0.js +1 -0
  95. package/dist/sparkle-core/{p-0a5d7c4f.entry.js → p-6a1fc0af.entry.js} +26 -26
  96. package/dist/sparkle-core/p-6fab3a4b.js +1 -0
  97. package/dist/sparkle-core/p-71720d6e.entry.js +1 -0
  98. package/dist/sparkle-core/{p-162bff1a.entry.js → p-72053ae0.entry.js} +1 -1
  99. package/dist/sparkle-core/{p-18cdd458.entry.js → p-85d4cd5c.entry.js} +1 -1
  100. package/dist/sparkle-core/p-967a2ed7.js +1 -0
  101. package/dist/sparkle-core/{p-ff0e0d4e.entry.js → p-98daeddb.entry.js} +1 -1
  102. package/dist/sparkle-core/p-98f7780c.entry.js +1 -0
  103. package/dist/sparkle-core/p-bd90903e.js +1 -0
  104. package/dist/sparkle-core/{p-a49ab4e8.entry.js → p-c64a34cd.entry.js} +1 -1
  105. package/dist/sparkle-core/{p-44334ef3.entry.js → p-ca907214.entry.js} +2 -2
  106. package/dist/sparkle-core/p-d51f30ca.js +1 -0
  107. package/dist/sparkle-core/p-dcff298d.entry.js +1 -0
  108. package/dist/sparkle-core/p-e50c8b04.entry.js +1 -0
  109. package/dist/sparkle-core/p-ed9de327.js +1 -0
  110. package/dist/sparkle-core/p-f891c79a.entry.js +1 -0
  111. package/dist/sparkle-core/sparkle-core.esm.js +1 -1
  112. package/dist/types/components/layout/page/page.d.ts +2 -0
  113. package/dist/types/components/sparkle-assignment/sparkle-assignment.d.ts +6 -0
  114. package/dist/types/components/sparkle-course-root/sparkle-course-root.d.ts +1 -0
  115. package/dist/types/components/sparkle-feed-post/sparkle-feed-post.d.ts +3 -2
  116. package/dist/types/components/sparkle-quiz/{sparkle-quiz/sparkle-quiz.d.ts → sparkle-quiz-old/sparkle-quiz-old.d.ts} +1 -1
  117. package/dist/types/components/sparkle-quiz/{sparkle-quiz-v1.d.ts → sparkle-quiz.d.ts} +1 -1
  118. package/dist/types/components.d.ts +49 -36
  119. package/dist/types/models/class.model.d.ts +4 -0
  120. package/dist/types/services/assignment.service.d.ts +8 -0
  121. package/dist/types/services/auth/auth.service.d.ts +1 -1
  122. package/dist/types/services/environment/environment-config.d.ts +3 -0
  123. package/dist/types/services/token.service.d.ts +12 -0
  124. package/dist/types/util.d.ts +1 -0
  125. package/package.json +1 -1
  126. package/dist/cjs/sparkle-quiz-v1.cjs.entry.js +0 -105
  127. package/dist/esm/sparkle-quiz-v1.entry.js +0 -101
  128. package/dist/sparkle-core/p-1d4c7c11.js +0 -1
  129. package/dist/sparkle-core/p-30767c1c.entry.js +0 -1
  130. package/dist/sparkle-core/p-3265ed87.entry.js +0 -1
  131. package/dist/sparkle-core/p-370609ba.entry.js +0 -1
  132. package/dist/sparkle-core/p-462bffba.js +0 -1
  133. package/dist/sparkle-core/p-4c9f994f.js +0 -1
  134. package/dist/sparkle-core/p-58e4bbe5.entry.js +0 -1
  135. package/dist/sparkle-core/p-600cf6a3.js +0 -1
  136. package/dist/sparkle-core/p-80d6b0e6.entry.js +0 -1
  137. package/dist/sparkle-core/p-af3cc111.entry.js +0 -1
  138. package/dist/sparkle-core/p-b226f54d.js +0 -1
  139. /package/dist/collection/components/sparkle-quiz/{sparkle-quiz-v1.css → sparkle-quiz.css} +0 -0
  140. /package/dist/sparkle-core/{p-935e7cfc.js → p-8b56f734.js} +0 -0
@@ -1,5 +1,6 @@
1
1
  import { Component, Element, State, Prop, Listen, h, Watch } from '@stencil/core';
2
2
  import { SignalRService } from '../../../services/signalR.service';
3
+ import signalRStore from '../../../stores/signalR.store';
3
4
  export class SparkleDiscussionResults {
4
5
  constructor() {
5
6
  this.allowPostToFeed = false;
@@ -21,10 +22,10 @@ export class SparkleDiscussionResults {
21
22
  var detail = evt.detail;
22
23
  if (detail.type == 'list') {
23
24
  detail.data.forEach(element => {
24
- if (element.responseType == 3) {
25
+ if (element.responseType == 'TEXT') {
25
26
  this.addToWordCloud(element);
26
27
  }
27
- else if (element.responseType == 1) {
28
+ else if (element.responseType == 'MULTIPLE-CHOICE') {
28
29
  this.addToBarChart(element);
29
30
  }
30
31
  });
@@ -34,10 +35,10 @@ export class SparkleDiscussionResults {
34
35
  }
35
36
  else {
36
37
  detail = detail.data;
37
- if (detail.responseType == 3) {
38
+ if (detail.responseType == 'TEXT') {
38
39
  this.addToWordCloud(detail);
39
40
  }
40
- else if (detail.responseType == 1) {
41
+ else if (detail.responseType == 'MULTIPLE-CHOICE') {
41
42
  this.addToBarChart(detail);
42
43
  }
43
44
  }
@@ -83,13 +84,18 @@ export class SparkleDiscussionResults {
83
84
  componentDidLoad() {
84
85
  if (this.questions) {
85
86
  this.setupData(this.questions);
87
+ signalRStore.onChange('connected', connected => {
88
+ if (connected && this.isTeacherMode) {
89
+ SignalRService.getInstance().callSignalR('GetPollSubmission', { pageUrl: window.location.href });
90
+ }
91
+ });
86
92
  }
87
93
  }
88
94
  setupData(questions) {
89
95
  this.setupResponseGraph(questions);
90
- if (this.isTeacherMode) {
91
- SignalRService.getInstance().callSignalR('GetPollSubmission', {});
92
- }
96
+ // if (this.isTeacherMode) {
97
+ // SignalRService.getInstance().callSignalR('GetPollSubmission', {});
98
+ // }
93
99
  }
94
100
  resetPollData() {
95
101
  SignalRService.getInstance().callSignalR('ResetPollData', {});
@@ -259,9 +265,9 @@ export class SparkleDiscussionResults {
259
265
  "methodName": "questionsChaged"
260
266
  }]; }
261
267
  static get listeners() { return [{
262
- "name": "body:receivedPollSubmissionSignalREvent",
268
+ "name": "receivedPollSubmissionSignalREvent",
263
269
  "method": "gotServerUpdate",
264
- "target": undefined,
270
+ "target": "body",
265
271
  "capture": false,
266
272
  "passive": false
267
273
  }]; }
@@ -0,0 +1,5 @@
1
+ sparkle-discussion{
2
+ border: 1px solid var(--line-rule-color);
3
+ display: block;
4
+ padding: 12px;
5
+ }
@@ -4,10 +4,11 @@ export class SparkleDiscussion {
4
4
  constructor() {
5
5
  this.allowPostToFeed = false;
6
6
  this.feedStartingText = 'My suggestions are:';
7
- this.isTeacherMode = true;
7
+ this.isTeacherMode = false;
8
8
  this.quizData = [];
9
9
  }
10
10
  async componentDidLoad() {
11
+ this.isTeacherMode = this.isTeacherMode == false ? window.location.href.indexOf('/presentation/course') > -1 : this.isTeacherMode;
11
12
  const config = EnvironmentConfigService.getInstance().get('sparkle');
12
13
  let allQuizData = await AssetsService.getInstance().loadJsonFile(config.quizPath);
13
14
  if (allQuizData) {
@@ -17,6 +18,7 @@ export class SparkleDiscussion {
17
18
  questionIds.forEach(id => {
18
19
  this.quizData = [...this.quizData, allQuizData[+id]];
19
20
  });
21
+ console.log('QUIZ Data', this.quizData);
20
22
  }
21
23
  }
22
24
  }
@@ -69,7 +71,7 @@ export class SparkleDiscussion {
69
71
  },
70
72
  "isTeacherMode": {
71
73
  "type": "boolean",
72
- "mutable": false,
74
+ "mutable": true,
73
75
  "complexType": {
74
76
  "original": "boolean",
75
77
  "resolved": "boolean",
@@ -83,7 +85,7 @@ export class SparkleDiscussion {
83
85
  },
84
86
  "attribute": "is-teacher-mode",
85
87
  "reflect": false,
86
- "defaultValue": "true"
88
+ "defaultValue": "false"
87
89
  },
88
90
  "questionIds": {
89
91
  "type": "string",
@@ -1,5 +1,9 @@
1
1
  import { Component, Element, State, Prop, Method, h, Host } from '@stencil/core';
2
- import { EnvironmentConfigService } from '../../services';
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
- var sparkleConfig = EnvironmentConfigService.getInstance().get('sparkle');
35
- if (!!sparkleConfig && !!sparkleConfig.auth && !!sparkleConfig.auth.getToken()) {
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: 1,
43
+ MiniAppId: SparkleGlobal.MY_GOALS_APP_ID,
55
44
  AssignmentName: this.assignmentName,
56
45
  AssignmentData: '',
46
+ PostTextJSON: null,
57
47
  };
58
- // this.dataSvc.saveData(data, '/api/class/feed').subscribe(
59
- // x => {
60
- // this.successMessage = 'Posted Successfully.';
61
- // // this.presentToast('Success');
62
- // },
63
- // error => {
64
- // this.errorMessage = 'There is an error while posting.';
65
- // // this.presentToast('There is an error');
66
- // },
67
- // );
68
- //TODO can we return data from the dataSvc so we know if it's successful and can update the form? (Perhaps replace it with the post itself?)
69
- // if (this.assignmentName) {
70
- // data.AssignmentData = JSON.stringify({ text: data.PostText, url: data.ExternalResourceUrl });
71
- // this.dataSvc.saveData(data, '/api/student/assignment-response').subscribe(
72
- // x => {
73
- // this.successMessage = 'Posted Successfully.';
74
- // // this.presentToast('Success');
75
- // },
76
- // error => {
77
- // this.errorMessage = 'There is an error while posting.';
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
- // this.uploadImageLoading = true;
85
- // var files = evt.target.files;
86
- // this.dataSvc.uploadImage(files, '/api/mediaitems/upload').subscribe(
87
- // x => {
88
- // this.uploadImageLoading = false;
89
- // this.uploadedImage = x.length > 0 ? x[0].FullImageUrl : '';
90
- // this.externalResourceUrl = x.length > 0 ? x[0].FullImageUrl : '';
91
- // //this.successMessage = 'Posted Successfully.'
92
- // // this.presentToast('Success');
93
- // },
94
- // error => {
95
- // this.uploadImageLoading = false;
96
- // this.errorMessage = 'There is an error while uploading an image.';
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
- var tokenInfo = { Token: null, ProfileImageUrl: null };
106
- if (tokenInfo != null && tokenInfo.Token) {
107
- return (h("ion-avatar", { class: "header-avatar", slot: "end" }, tokenInfo.ProfileImageUrl ? h("img", { src: tokenInfo.ProfileImageUrl }) : h("img", { src: "/assets/img/avatar.png" })));
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("ion-button", { slot: "end", size: "default", onClick: evt => this.submitPost(), disabled: !this.isAuthenticated() }, "Post")))))))));
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
- sessionStorage.setItem('rememberMe', this.rememberMe.value == true ? '1' : '0');
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,4 +1,4 @@
1
- sparkle-quiz {
1
+ sparkle-quiz-old {
2
2
  display: block;
3
3
  font-family: var(--font-family);
4
4
  --sparkle-quiz-question-container-padding: 10px 0px;
@@ -1,5 +1,5 @@
1
1
  import { Component, Prop, Listen, State, Event, Element, h } from '@stencil/core';
2
- export class SparkleQuiz {
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 "../../services/environment/environment-config.service";
4
- export class SparkleQuizV1 {
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: "1"
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 == "MULTIPLE-CHOICE") {
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 == "FEEDBACK" || this.question.questionType == "TEXT") {
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 == "MULTIPLE-CHOICE") {
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 == "FEEDBACK") {
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 == "TEXT") {
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 == "OPINION") {
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 == "POLL") {
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
- 'correct': this.submitted && this.correct,
80
- 'incorrect': this.submitted && !this.correct
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-v1"; }
89
+ static get is() { return "sparkle-quiz"; }
92
90
  static get originalStyleUrls() { return {
93
- "$": ["sparkle-quiz-v1.scss"]
91
+ "$": ["sparkle-quiz.scss"]
94
92
  }; }
95
93
  static get styleUrls() { return {
96
- "$": ["sparkle-quiz-v1.css"]
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, question: SparkleQuizQuestion }",
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 { EnvironmentConfigService } from '../../services/environment/environment-config.service';
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 = (url) => {
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
- var sparkleConfig = EnvironmentConfigService.getInstance().get('sparkle');
24
- if (sparkleConfig && sparkleConfig.auth && sparkleConfig.auth.getToken()) {
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("NavigateStudentTo", this.handleStudentNavigationChange);
41
- AuthStore.onChange("isAuthenticated", async (isAuthenticated) => {
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, set, remove } from '../core/localstorage.service';
1
+ import { get, remove } from '../core/localstorage.service';
2
2
  import { HttpService } from '../httpService';
3
3
  import AppConsts from '../../appconst';
4
- import { AuthStore } from "../../stores/auth.store";
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("Facilitator") > 0
36
+ PhotoUrl: '',
37
+ IsFacilitator: authData.Roles.indexOf('Facilitator') > 0,
37
38
  };
38
- const expireDate = authenticationInput.RememberClient ? new Date(authUser.ExpiresOn) : undefined;
39
- sparkle.auth.setToken(authUser.JWToken, expireDate);
40
- //TODO: change authUser.JWToken to encrypted
41
- sparkle.utils.setCookieValue(AppConsts.authorization.encrptedAuthTokenName, authUser.JWToken, expireDate, sparkle.appPath);
42
- await set(AppConsts.AUTH_USER_LOCALSTORAGE, authUser);
43
- AuthStore.state.authUser = Object.assign({}, authUser);
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);
@@ -1,5 +1,5 @@
1
1
  import Util from '../../utils';
2
- import { getAssetPath } from "@stencil/core";
2
+ import { getAssetPath } from '@stencil/core';
3
3
  //declare var sparkle: any;
4
4
  export async function setupConfig(config) {
5
5
  if (!window) {
@@ -15,7 +15,6 @@ export class EnvironmentConfigService {
15
15
  }
16
16
  const win = window;
17
17
  const Sparkle = win.Sparkle;
18
- console.log('getting info');
19
18
  this.m = new Map(Object.entries(Sparkle.config));
20
19
  }
21
20
  get(key, fallback) {