@sparkle-learning/core 0.0.51 → 0.0.53

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 (46) hide show
  1. package/dist/cjs/header-mobile-collapse_61.cjs.entry.js +16 -2995
  2. package/dist/cjs/{ion-select_2.cjs.entry.js → ion-select_3.cjs.entry.js} +118 -0
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/signalR.service-5672eebc.js +2987 -0
  5. package/dist/cjs/sparkle-animation-player.cjs.entry.js +1 -0
  6. package/dist/cjs/sparkle-core.cjs.js +1 -1
  7. package/dist/cjs/sparkle-discussion-questions_2.cjs.entry.js +272 -0
  8. package/dist/cjs/sparkle-discussion.cjs.entry.js +40 -0
  9. package/dist/collection/collection-manifest.json +3 -0
  10. package/dist/collection/components/sparkle-animation-player/sparkle-animation-player.js +1 -0
  11. package/dist/collection/components/sparkle-course-root/sparkle-course-root.js +1 -1
  12. package/dist/collection/components/sparkle-discussion/sparkle-discussion-questions/sparkle-discussion-questions.css +157 -0
  13. package/dist/collection/components/sparkle-discussion/sparkle-discussion-questions/sparkle-discussion-questions.js +230 -0
  14. package/dist/collection/components/sparkle-discussion/sparkle-discussion-results/sparkle-discussion-results.css +158 -0
  15. package/dist/collection/components/sparkle-discussion/sparkle-discussion-results/sparkle-discussion-results.js +268 -0
  16. package/dist/collection/components/sparkle-discussion/sparkle-discussion.css +0 -0
  17. package/dist/collection/components/sparkle-discussion/sparkle-discussion.js +110 -0
  18. package/dist/collection/components/sparkle-feed-post/sparkle-feed-post.css +16 -0
  19. package/dist/collection/components/sparkle-feed-post/sparkle-feed-post.js +17 -13
  20. package/dist/esm/header-mobile-collapse_61.entry.js +4 -2983
  21. package/dist/esm/{ion-select_2.entry.js → ion-select_3.entry.js} +118 -1
  22. package/dist/esm/loader.js +1 -1
  23. package/dist/esm/signalR.service-9d5b9f36.js +2984 -0
  24. package/dist/esm/sparkle-animation-player.entry.js +1 -0
  25. package/dist/esm/sparkle-core.js +1 -1
  26. package/dist/esm/sparkle-discussion-questions_2.entry.js +267 -0
  27. package/dist/esm/sparkle-discussion.entry.js +36 -0
  28. package/dist/node_modules/@sparkle-learning/components/dist/collection/components/page-footer/page-footer.css +7 -0
  29. package/dist/sparkle-core/{p-31be4dc4.entry.js → p-0a5d7c4f.entry.js} +26 -26
  30. package/dist/sparkle-core/p-18cdd458.entry.js +1 -0
  31. package/dist/sparkle-core/p-30767c1c.entry.js +1 -0
  32. package/dist/sparkle-core/p-3265ed87.entry.js +1 -0
  33. package/dist/sparkle-core/{p-564e64fc.entry.js → p-44334ef3.entry.js} +2 -2
  34. package/dist/sparkle-core/p-4c9f994f.js +1 -0
  35. package/dist/sparkle-core/sparkle-core.esm.js +1 -1
  36. package/dist/types/components/sparkle-discussion/sparkle-discussion-questions/sparkle-discussion-questions.d.ts +28 -0
  37. package/dist/types/components/sparkle-discussion/sparkle-discussion-results/sparkle-discussion-results.d.ts +45 -0
  38. package/dist/types/components/sparkle-discussion/sparkle-discussion.d.ts +11 -0
  39. package/dist/types/components/sparkle-feed-post/sparkle-feed-post.d.ts +1 -0
  40. package/dist/types/components.d.ts +66 -1
  41. package/package.json +6 -6
  42. package/dist/cjs/sparkle-feed-post.cjs.entry.js +0 -120
  43. package/dist/esm/sparkle-feed-post.entry.js +0 -116
  44. package/dist/sparkle-core/p-41a9ece7.entry.js +0 -1
  45. package/dist/sparkle-core/p-e77d982d.entry.js +0 -1
  46. package/dist/types/components/sparkle-quiz/sparkle-quiz.d.ts +0 -41
@@ -0,0 +1,268 @@
1
+ import { Component, Element, State, Prop, Listen, h, Watch } from '@stencil/core';
2
+ import { SignalRService } from '../../../services/signalR.service';
3
+ export class SparkleDiscussionResults {
4
+ constructor() {
5
+ this.allowPostToFeed = false;
6
+ this.feedStartingText = 'My suggestions are:';
7
+ this.isTeacherMode = false;
8
+ this.questions = [];
9
+ this.error = '';
10
+ this.modelChange = '';
11
+ this.responses = [];
12
+ this.tempResponses = [];
13
+ this.suggestionList = [];
14
+ }
15
+ questionsChaged(newValue, _oldValue) {
16
+ this.setupData(newValue);
17
+ }
18
+ //Any child component can liste for server events like
19
+ gotServerUpdate(evt) {
20
+ if (this.isTeacherMode) {
21
+ var detail = evt.detail;
22
+ if (detail.type == 'list') {
23
+ detail.data.forEach(element => {
24
+ if (element.responseType == 3) {
25
+ this.addToWordCloud(element);
26
+ }
27
+ else if (element.responseType == 1) {
28
+ this.addToBarChart(element);
29
+ }
30
+ });
31
+ }
32
+ else if (detail.type == 'removed') {
33
+ this.responses = [...this.tempResponses];
34
+ }
35
+ else {
36
+ detail = detail.data;
37
+ if (detail.responseType == 3) {
38
+ this.addToWordCloud(detail);
39
+ }
40
+ else if (detail.responseType == 1) {
41
+ this.addToBarChart(detail);
42
+ }
43
+ }
44
+ }
45
+ }
46
+ addToWordCloud(q) {
47
+ var isExistObj = this.responses.find(x => x.question == q.question);
48
+ if (isExistObj) {
49
+ this.responses = this.responses.map(resp => {
50
+ if (resp.question == q.question) {
51
+ return q;
52
+ }
53
+ return resp;
54
+ });
55
+ }
56
+ else {
57
+ this.responses = [...this.responses, q];
58
+ }
59
+ console.log(this.responses);
60
+ }
61
+ addToBarChart(q) {
62
+ var isExistObj = this.responses.find(x => x.question == q.question);
63
+ if (isExistObj) {
64
+ isExistObj.responses = isExistObj.responses.map(resp => {
65
+ var correctData = q.responses.find(x => x.response == resp.response);
66
+ if (correctData) {
67
+ return correctData;
68
+ }
69
+ return resp;
70
+ });
71
+ isExistObj.total = q.total;
72
+ this.responses = this.responses.map(resp => {
73
+ if (resp.question == isExistObj.question) {
74
+ return isExistObj;
75
+ }
76
+ return resp;
77
+ });
78
+ }
79
+ else {
80
+ this.responses = [...this.responses, q];
81
+ }
82
+ }
83
+ componentDidLoad() {
84
+ if (this.questions) {
85
+ this.setupData(this.questions);
86
+ }
87
+ }
88
+ setupData(questions) {
89
+ this.setupResponseGraph(questions);
90
+ if (this.isTeacherMode) {
91
+ SignalRService.getInstance().callSignalR('GetPollSubmission', {});
92
+ }
93
+ }
94
+ resetPollData() {
95
+ SignalRService.getInstance().callSignalR('ResetPollData', {});
96
+ }
97
+ setupResponseGraph(questions) {
98
+ this.responses = [];
99
+ questions.forEach(q => {
100
+ if (q.questionType == 'TEXT') {
101
+ this.responses = [
102
+ ...this.responses,
103
+ {
104
+ question: q.questionText,
105
+ responseType: q.questionType,
106
+ responses: [],
107
+ total: 0,
108
+ },
109
+ ];
110
+ this.tempResponses = this.responses.slice();
111
+ }
112
+ else if (q.questionType == 'MULTIPLE-CHOICE') {
113
+ var answer = [];
114
+ Object.keys(q.options).map((o) => {
115
+ answer.push({ count: 0, response: q.options[o].option });
116
+ });
117
+ this.responses = [...this.responses, { question: q.questionText, responseType: q.questionType, responses: answer, total: 0 }];
118
+ this.tempResponses = this.responses.slice();
119
+ }
120
+ });
121
+ console.log(this.responses);
122
+ }
123
+ columnHeight(responseCount, totalResponseCount) {
124
+ let maxScale = 100;
125
+ let scaleUnit = 0;
126
+ if (totalResponseCount != 0) {
127
+ scaleUnit = maxScale / totalResponseCount;
128
+ }
129
+ var size = scaleUnit * responseCount;
130
+ return { height: `${size}px` };
131
+ }
132
+ getRandomColorAndFontSize(count) {
133
+ const h = Math.floor(Math.random() * 360), s = Math.floor(Math.random() * 100) + '%', l = Math.floor(Math.random() * 60) + '%';
134
+ let fontSize = 1;
135
+ if (count > 0) {
136
+ fontSize = fontSize + (count - 1) * 0.25;
137
+ }
138
+ return { 'color': `hsl(${h},${s},${l})`, 'font-size': `${fontSize}em` };
139
+ }
140
+ renderResults() {
141
+ console.log('Responsed', this.responses);
142
+ var barResponses = this.responses.filter(x => x.responseType == 'MULTIPLE-CHOICE');
143
+ var cloudResponses = this.responses.filter(x => x.responseType == 'TEXT');
144
+ return [
145
+ // <ion-button size="default" slot="end" color="primary" onClick={(evt) => this.resetPollData()} >Reset</ion-button>,
146
+ barResponses.map((q) => (h("div", null,
147
+ ' ',
148
+ h("h3", { class: "line" }, q.question),
149
+ h("div", { class: "graph-container" },
150
+ h("div", { class: "bar-graph-column" }, q.responses.map(r => (h("div", { class: "answer-column", style: this.columnHeight(r.count, q.total) }, r.count)))),
151
+ h("div", { class: "bar-graph-questions" }, q.responses.map(r => (h("div", { class: 'question' },
152
+ h("p", null, r.response))))))))),
153
+ cloudResponses.map(q => [
154
+ h("p", null,
155
+ h("h3", { class: "line" }, q.question)),
156
+ h("div", { class: "cloud" }, q.responses.map(r => (h("div", { style: this.getRandomColorAndFontSize(r.count) }, r.response)))),
157
+ ]),
158
+ ];
159
+ }
160
+ render() {
161
+ return this.renderResults();
162
+ }
163
+ static get is() { return "sparkle-discussion-results"; }
164
+ static get originalStyleUrls() { return {
165
+ "$": ["sparkle-discussion-results.css"]
166
+ }; }
167
+ static get styleUrls() { return {
168
+ "$": ["sparkle-discussion-results.css"]
169
+ }; }
170
+ static get properties() { return {
171
+ "allowPostToFeed": {
172
+ "type": "boolean",
173
+ "mutable": false,
174
+ "complexType": {
175
+ "original": "boolean",
176
+ "resolved": "boolean",
177
+ "references": {}
178
+ },
179
+ "required": false,
180
+ "optional": false,
181
+ "docs": {
182
+ "tags": [],
183
+ "text": ""
184
+ },
185
+ "attribute": "allow-post-to-feed",
186
+ "reflect": false,
187
+ "defaultValue": "false"
188
+ },
189
+ "feedStartingText": {
190
+ "type": "string",
191
+ "mutable": false,
192
+ "complexType": {
193
+ "original": "string",
194
+ "resolved": "string",
195
+ "references": {}
196
+ },
197
+ "required": false,
198
+ "optional": false,
199
+ "docs": {
200
+ "tags": [],
201
+ "text": ""
202
+ },
203
+ "attribute": "feed-starting-text",
204
+ "reflect": false,
205
+ "defaultValue": "'My suggestions are:'"
206
+ },
207
+ "isTeacherMode": {
208
+ "type": "boolean",
209
+ "mutable": false,
210
+ "complexType": {
211
+ "original": "boolean",
212
+ "resolved": "boolean",
213
+ "references": {}
214
+ },
215
+ "required": false,
216
+ "optional": false,
217
+ "docs": {
218
+ "tags": [],
219
+ "text": ""
220
+ },
221
+ "attribute": "is-teacher-mode",
222
+ "reflect": false,
223
+ "defaultValue": "false"
224
+ },
225
+ "questions": {
226
+ "type": "unknown",
227
+ "mutable": false,
228
+ "complexType": {
229
+ "original": "Array<SparkleQuizQuestion>",
230
+ "resolved": "SparkleQuizQuestion[]",
231
+ "references": {
232
+ "Array": {
233
+ "location": "global"
234
+ },
235
+ "SparkleQuizQuestion": {
236
+ "location": "import",
237
+ "path": "../../../models/quiz.model"
238
+ }
239
+ }
240
+ },
241
+ "required": false,
242
+ "optional": false,
243
+ "docs": {
244
+ "tags": [],
245
+ "text": ""
246
+ },
247
+ "defaultValue": "[]"
248
+ }
249
+ }; }
250
+ static get states() { return {
251
+ "error": {},
252
+ "modelChange": {},
253
+ "responses": {},
254
+ "suggestionList": {}
255
+ }; }
256
+ static get elementRef() { return "el"; }
257
+ static get watchers() { return [{
258
+ "propName": "questions",
259
+ "methodName": "questionsChaged"
260
+ }]; }
261
+ static get listeners() { return [{
262
+ "name": "body:receivedPollSubmissionSignalREvent",
263
+ "method": "gotServerUpdate",
264
+ "target": undefined,
265
+ "capture": false,
266
+ "passive": false
267
+ }]; }
268
+ }
@@ -0,0 +1,110 @@
1
+ import { Component, Element, State, Prop, h } from '@stencil/core';
2
+ import { AssetsService, EnvironmentConfigService } from '../../services';
3
+ export class SparkleDiscussion {
4
+ constructor() {
5
+ this.allowPostToFeed = false;
6
+ this.feedStartingText = 'My suggestions are:';
7
+ this.isTeacherMode = true;
8
+ this.quizData = [];
9
+ }
10
+ async componentDidLoad() {
11
+ const config = EnvironmentConfigService.getInstance().get('sparkle');
12
+ let allQuizData = await AssetsService.getInstance().loadJsonFile(config.quizPath);
13
+ if (allQuizData) {
14
+ if (this.questionIds) {
15
+ let questionIds = this.questionIds.split(',');
16
+ this.quizData = [];
17
+ questionIds.forEach(id => {
18
+ this.quizData = [...this.quizData, allQuizData[+id]];
19
+ });
20
+ }
21
+ }
22
+ }
23
+ render() {
24
+ return this.isTeacherMode ? (h("sparkle-discussion-results", { allowPostToFeed: this.allowPostToFeed, feedStartingText: this.feedStartingText, isTeacherMode: this.isTeacherMode, questions: this.quizData })) : (h("sparkle-discussion-questions", { allowPostToFeed: this.allowPostToFeed, feedStartingText: this.feedStartingText, isTeacherMode: this.isTeacherMode, questions: this.quizData }));
25
+ }
26
+ static get is() { return "sparkle-discussion"; }
27
+ static get originalStyleUrls() { return {
28
+ "$": ["sparkle-discussion.css"]
29
+ }; }
30
+ static get styleUrls() { return {
31
+ "$": ["sparkle-discussion.css"]
32
+ }; }
33
+ static get properties() { return {
34
+ "allowPostToFeed": {
35
+ "type": "boolean",
36
+ "mutable": false,
37
+ "complexType": {
38
+ "original": "boolean",
39
+ "resolved": "boolean",
40
+ "references": {}
41
+ },
42
+ "required": false,
43
+ "optional": false,
44
+ "docs": {
45
+ "tags": [],
46
+ "text": ""
47
+ },
48
+ "attribute": "allow-post-to-feed",
49
+ "reflect": false,
50
+ "defaultValue": "false"
51
+ },
52
+ "feedStartingText": {
53
+ "type": "string",
54
+ "mutable": false,
55
+ "complexType": {
56
+ "original": "string",
57
+ "resolved": "string",
58
+ "references": {}
59
+ },
60
+ "required": false,
61
+ "optional": false,
62
+ "docs": {
63
+ "tags": [],
64
+ "text": ""
65
+ },
66
+ "attribute": "feed-starting-text",
67
+ "reflect": false,
68
+ "defaultValue": "'My suggestions are:'"
69
+ },
70
+ "isTeacherMode": {
71
+ "type": "boolean",
72
+ "mutable": false,
73
+ "complexType": {
74
+ "original": "boolean",
75
+ "resolved": "boolean",
76
+ "references": {}
77
+ },
78
+ "required": false,
79
+ "optional": false,
80
+ "docs": {
81
+ "tags": [],
82
+ "text": ""
83
+ },
84
+ "attribute": "is-teacher-mode",
85
+ "reflect": false,
86
+ "defaultValue": "true"
87
+ },
88
+ "questionIds": {
89
+ "type": "string",
90
+ "mutable": false,
91
+ "complexType": {
92
+ "original": "string",
93
+ "resolved": "string",
94
+ "references": {}
95
+ },
96
+ "required": false,
97
+ "optional": false,
98
+ "docs": {
99
+ "tags": [],
100
+ "text": ""
101
+ },
102
+ "attribute": "question-ids",
103
+ "reflect": false
104
+ }
105
+ }; }
106
+ static get states() { return {
107
+ "quizData": {}
108
+ }; }
109
+ static get elementRef() { return "el"; }
110
+ }
@@ -2,18 +2,34 @@
2
2
  display: block;
3
3
  }
4
4
 
5
+ .post-footer-container{
6
+ display: flex;
7
+ justify-content: flex-end;
8
+ }
5
9
  .post-footer{
6
10
  display: flex;
7
11
  justify-content: space-between;
12
+ align-items: center;
13
+
8
14
  }
9
15
  .error{
10
16
  color:red;
17
+ margin-right: 10px;
11
18
  }
12
19
  .success{
13
20
  color:green;
21
+ margin-right: 10px;
14
22
  }
15
23
  .uploaded-image{
16
24
  display: block;
17
25
  max-height: 140px;
18
26
  width : auto !important
27
+ }
28
+ .public-post-toggle{
29
+ display: flex;
30
+ justify-content: flex-end;
31
+ align-items: center;
32
+ }
33
+ .assignment-name{
34
+ display: none;
19
35
  }
@@ -5,6 +5,10 @@ export class SparkleFeedPost {
5
5
  // toastCtrl: HTMLIonToastControllerElement;
6
6
  componentDidLoad() {
7
7
  this.postText = this.textValue;
8
+ if (this.ref && this.ref.innerText) {
9
+ this.assignmentName = this.ref.innerText;
10
+ console.log(this.assignmentName);
11
+ }
8
12
  }
9
13
  setText(text) {
10
14
  this.postText = text;
@@ -109,17 +113,13 @@ export class SparkleFeedPost {
109
113
  render() {
110
114
  const userInfo = this.renderUserInfo();
111
115
  return (h(Host, null,
112
- h("slot", null),
116
+ h("div", { class: "assignment-name", ref: el => (this.ref = el) },
117
+ h("slot", null)),
113
118
  h("ion-card", null,
114
- h("ion-item", { class: "header" },
115
- h("ion-card-title", null, "Community Wall"),
116
- userInfo),
119
+ h("ion-item", { class: "header", lines: "full" }, userInfo),
117
120
  h("ion-card-content", null,
118
121
  h("form", null,
119
122
  h("ion-list", null,
120
- h("ion-item", { lines: "none" },
121
- h("ion-label", null, "Public"),
122
- h("ion-toggle", { class: "IsPublic", slot: "end", color: "primary", name: "IsPublic" })),
123
123
  h("ion-item", { class: "padding" },
124
124
  h("ion-textarea", { class: "PostText", required: true, placeholder: "Post Text", name: "PostText", value: this.postText })),
125
125
  h("ion-item", { class: "padding" },
@@ -132,11 +132,15 @@ export class SparkleFeedPost {
132
132
  h("ion-button", { slot: "start", onClick: evt => this.selectFile() },
133
133
  h("ion-icon", { name: "add" }),
134
134
  "Upload Image")),
135
- h("ion-item", { class: "post-footer", lines: "none" },
136
- h("div", null,
137
- h("div", { class: "error" }, this.errorMessage),
138
- h("div", { class: "success" }, this.successMessage)),
139
- h("ion-button", { slot: "end", size: "default", onClick: evt => this.submitPost(), disabled: !this.isAuthenticated() }, "Post"))))))));
135
+ h("div", { class: "public-post-toggle" },
136
+ h("ion-toggle", { class: "IsPublic", color: "primary", name: "IsPublic" }),
137
+ h("div", null, "Public Post")),
138
+ h("div", { class: "post-footer-container" },
139
+ h("div", { class: "post-footer" },
140
+ h("div", null,
141
+ h("div", { class: "error" }, this.errorMessage),
142
+ h("div", { class: "success" }, this.successMessage)),
143
+ h("ion-button", { slot: "end", size: "default", onClick: evt => this.submitPost(), disabled: !this.isAuthenticated() }, "Post")))))))));
140
144
  }
141
145
  static get is() { return "sparkle-feed-post"; }
142
146
  static get originalStyleUrls() { return {
@@ -148,7 +152,7 @@ export class SparkleFeedPost {
148
152
  static get properties() { return {
149
153
  "assignmentName": {
150
154
  "type": "string",
151
- "mutable": false,
155
+ "mutable": true,
152
156
  "complexType": {
153
157
  "original": "string",
154
158
  "resolved": "string",