@sparkle-learning/core 0.0.52 → 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.
- package/dist/cjs/header-mobile-collapse_61.cjs.entry.js +15 -2994
- package/dist/cjs/{ion-select_2.cjs.entry.js → ion-select_3.cjs.entry.js} +118 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/signalR.service-5672eebc.js +2987 -0
- package/dist/cjs/sparkle-animation-player.cjs.entry.js +1 -0
- package/dist/cjs/sparkle-core.cjs.js +1 -1
- package/dist/cjs/sparkle-discussion-questions_2.cjs.entry.js +272 -0
- package/dist/cjs/sparkle-discussion.cjs.entry.js +40 -0
- package/dist/collection/collection-manifest.json +3 -0
- package/dist/collection/components/sparkle-animation-player/sparkle-animation-player.js +1 -0
- package/dist/collection/components/sparkle-course-root/sparkle-course-root.js +1 -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 +230 -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 +268 -0
- package/dist/collection/components/sparkle-discussion/sparkle-discussion.css +0 -0
- package/dist/collection/components/sparkle-discussion/sparkle-discussion.js +110 -0
- package/dist/esm/header-mobile-collapse_61.entry.js +3 -2982
- package/dist/esm/{ion-select_2.entry.js → ion-select_3.entry.js} +118 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/signalR.service-9d5b9f36.js +2984 -0
- package/dist/esm/sparkle-animation-player.entry.js +1 -0
- package/dist/esm/sparkle-core.js +1 -1
- package/dist/esm/sparkle-discussion-questions_2.entry.js +267 -0
- package/dist/esm/sparkle-discussion.entry.js +36 -0
- package/dist/sparkle-core/{p-0335c863.entry.js → p-0a5d7c4f.entry.js} +26 -26
- package/dist/sparkle-core/p-18cdd458.entry.js +1 -0
- package/dist/sparkle-core/p-30767c1c.entry.js +1 -0
- package/dist/sparkle-core/p-3265ed87.entry.js +1 -0
- package/dist/sparkle-core/{p-564e64fc.entry.js → p-44334ef3.entry.js} +2 -2
- package/dist/sparkle-core/p-4c9f994f.js +1 -0
- package/dist/sparkle-core/sparkle-core.esm.js +1 -1
- 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.d.ts +66 -1
- package/package.json +1 -1
- package/dist/cjs/sparkle-feed-post.cjs.entry.js +0 -124
- package/dist/esm/sparkle-feed-post.entry.js +0 -120
- package/dist/sparkle-core/p-15403881.entry.js +0 -1
- package/dist/sparkle-core/p-41a9ece7.entry.js +0 -1
- 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
|
+
}
|
File without changes
|
@@ -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
|
+
}
|