@windward/games 0.0.1

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 (68) hide show
  1. package/.editorconfig +13 -0
  2. package/.eslintrc.js +11 -0
  3. package/.prettierrc +4 -0
  4. package/README.md +43 -0
  5. package/babel.config.js +1 -0
  6. package/components/content/CrudTable.vue +295 -0
  7. package/components/content/DataTableRowHandler.vue +113 -0
  8. package/components/content/DatableEditor.vue +223 -0
  9. package/components/content/blocks/BaseContentBlock.vue +8 -0
  10. package/components/content/blocks/dragDrop/BucketGame.vue +520 -0
  11. package/components/content/blocks/dragDrop/SortingGame.vue +303 -0
  12. package/components/content/blocks/flashcards/CardFace.vue +112 -0
  13. package/components/content/blocks/flashcards/Flashcard.vue +150 -0
  14. package/components/content/blocks/flashcards/FlashcardSlides.vue +121 -0
  15. package/components/content/blocks/matchingGame/MatchingGame.vue +545 -0
  16. package/components/content/blocks/quizshowGame/AnswerPanel.vue +338 -0
  17. package/components/content/blocks/quizshowGame/Gridview.vue +260 -0
  18. package/components/content/blocks/quizshowGame/QuizShow.vue +516 -0
  19. package/components/content/blocks/quizshowGame/feedbackIcons.vue +41 -0
  20. package/components/content/blocks/slideshow/SlideShow.vue +175 -0
  21. package/components/settings/BucketGameSettingsManager.vue +683 -0
  22. package/components/settings/FlashCardSlidesManager.vue +489 -0
  23. package/components/settings/MatchingGameManager.vue +775 -0
  24. package/components/settings/QuizShowSettingsManager.vue +408 -0
  25. package/components/settings/SlideShowManager.vue +248 -0
  26. package/components/settings/SortingGameSettingsManager.vue +286 -0
  27. package/i18n/en-US/components/content/blocks/bucket_game.ts +39 -0
  28. package/i18n/en-US/components/content/blocks/flashcard.ts +5 -0
  29. package/i18n/en-US/components/content/blocks/index.ts +15 -0
  30. package/i18n/en-US/components/content/blocks/matching_game.ts +26 -0
  31. package/i18n/en-US/components/content/blocks/quizshow_game.ts +35 -0
  32. package/i18n/en-US/components/content/blocks/slideshow.ts +13 -0
  33. package/i18n/en-US/components/content/blocks/sorting_game.ts +5 -0
  34. package/i18n/en-US/components/content/crud_table.ts +6 -0
  35. package/i18n/en-US/components/content/index.ts +7 -0
  36. package/i18n/en-US/components/index.ts +9 -0
  37. package/i18n/en-US/components/navigation/index.ts +5 -0
  38. package/i18n/en-US/components/settings/bucket_game.ts +35 -0
  39. package/i18n/en-US/components/settings/flashcard.ts +26 -0
  40. package/i18n/en-US/components/settings/index.ts +13 -0
  41. package/i18n/en-US/components/settings/matching_game.ts +15 -0
  42. package/i18n/en-US/components/settings/quizshow_game.ts +14 -0
  43. package/i18n/en-US/components/settings/slideshow.ts +11 -0
  44. package/i18n/en-US/index.ts +15 -0
  45. package/i18n/en-US/modules/index.ts +5 -0
  46. package/i18n/en-US/pages/index.ts +5 -0
  47. package/i18n/en-US/shared/content_blocks.ts +14 -0
  48. package/i18n/en-US/shared/index.ts +7 -0
  49. package/i18n/en-US/shared/settings.ts +10 -0
  50. package/i18n/en-US.ts +5 -0
  51. package/jest.config.js +18 -0
  52. package/package.json +51 -0
  53. package/plugin.js +150 -0
  54. package/test/blocks/dragDrop/BucketGame.spec.js +26 -0
  55. package/test/blocks/dragDrop/SortingGame.spec.js +47 -0
  56. package/test/blocks/flashcards/CardFace.spec.js +21 -0
  57. package/test/blocks/flashcards/FlashCardSlides.spec.js +24 -0
  58. package/test/blocks/flashcards/Flashcard.spec.js +24 -0
  59. package/test/blocks/matchingGame/MatchingGame.spec.js +26 -0
  60. package/test/blocks/quizShow/quizShow.spec.js +31 -0
  61. package/test/blocks/slideshow/slideshow.spec.js +24 -0
  62. package/test/mocks.js +2 -0
  63. package/test/settings/BucketGameManager.spec.js +125 -0
  64. package/test/settings/FlashCardSlidesManager.spec.js +24 -0
  65. package/test/settings/MatchingGameManager.spec.js +30 -0
  66. package/test/settings/SlideShowManager.spec.js +30 -0
  67. package/test/settings/SortingGameManager.spec.js +71 -0
  68. package/tsconfig.json +20 -0
@@ -0,0 +1,338 @@
1
+ <template>
2
+ <v-container>
3
+ <v-row
4
+ align="center"
5
+ justify="center"
6
+ class="font-weight-bold text-capitalize"
7
+ v-if="result !== null"
8
+ >
9
+ <div v-if="result">
10
+ {{
11
+ $t(
12
+ 'plugin.games.components.content.blocks.quizshow_game.feedback.correct'
13
+ )
14
+ }}
15
+ </div>
16
+ <div v-if="!result">
17
+ {{
18
+ $t(
19
+ 'plugin.games.components.content.blocks.quizshow_game.feedback.incorrect'
20
+ )
21
+ }}
22
+ </div>
23
+ </v-row>
24
+ <br />
25
+ <v-row
26
+ align="center"
27
+ justify="center"
28
+ class="pa-4 mb-4 font-weight-bold text-capitalize"
29
+ >
30
+ <v-textarea
31
+ v-if="editMode"
32
+ v-model="question.text"
33
+ :counter="255"
34
+ maxlength="255"
35
+ :label="
36
+ $t(
37
+ 'plugin.games.components.content.blocks.quizshow_game.form.question'
38
+ )
39
+ "
40
+ @input=""
41
+ ></v-textarea>
42
+ <v-card flat v-if="!editMode" v-html="question.text"></v-card>
43
+ </v-row>
44
+ <v-row
45
+ align="center"
46
+ justify="center"
47
+ class="pa-4 mb-4 font-weight-bold text-capitalize"
48
+ >
49
+ <v-text-field
50
+ v-if="editMode"
51
+ v-model="question.feedback"
52
+ :counter="255"
53
+ maxlength="255"
54
+ :label="
55
+ $t(
56
+ 'plugin.games.components.content.blocks.quizshow_game.feedback.feedback'
57
+ )
58
+ "
59
+ ></v-text-field>
60
+ </v-row>
61
+
62
+ <div class="d-flex flex-column">
63
+ <v-row
64
+ v-for="(choice, choice_index) in question.choices"
65
+ :key="choice_index"
66
+ >
67
+ <v-card
68
+ v-ripple
69
+ v-if="!editMode"
70
+ @click="getUserInput(choice_index)"
71
+ class="ma-1 pa-5 justify-start flex-fill"
72
+ :class="generateButtonColor(choice_index)"
73
+ :outlined="generateButtonOutline(choice_index)"
74
+ >
75
+ <v-icon
76
+ color="success"
77
+ v-if="
78
+ !editMode &&
79
+ userInput !== null &&
80
+ userInput === question.answer &&
81
+ choice_index === userInput
82
+ "
83
+ >
84
+ mdi-check-circle-outline</v-icon
85
+ >
86
+ <v-icon
87
+ color="error"
88
+ v-if="
89
+ !editMode &&
90
+ userInput !== null &&
91
+ choice_index !== question.answer &&
92
+ choice_index === userInput
93
+ "
94
+ >
95
+ mdi-close-circle-outline</v-icon
96
+ >
97
+ <span v-html="mathToHtml(choice.text)"></span>
98
+ <v-icon
99
+ class="info-icon"
100
+ v-if="generateButtonColor(choice_index) === 'success'"
101
+ @click="onFeedback"
102
+ >mdi-information</v-icon
103
+ >
104
+ </v-card>
105
+ <v-text-field
106
+ v-if="editMode"
107
+ v-model="question.choices[choice_index].text"
108
+ :counter="255"
109
+ maxlength="255"
110
+ :label="
111
+ $t(
112
+ 'plugin.games.components.content.blocks.quizshow_game.form.choice'
113
+ )
114
+ "
115
+ outlined
116
+ @input=""
117
+ ></v-text-field>
118
+ <v-switch
119
+ v-if="editMode"
120
+ :disabled="
121
+ !question.choices[choice_index].is_answer &&
122
+ question.answer !== null
123
+ "
124
+ v-model="question.choices[choice_index].is_answer"
125
+ :label="`is answer`"
126
+ @click="setAnswer(choice_index)"
127
+ ></v-switch>
128
+ <v-icon v-if="editMode" @click="deleteItem(choice)">
129
+ mdi-delete
130
+ </v-icon>
131
+ </v-row>
132
+ </div>
133
+ <v-row
134
+ align="center"
135
+ justify="center"
136
+ class="pt-10 font-weight-bold text-capitalize"
137
+ >
138
+ <v-btn
139
+ v-if="editMode"
140
+ @click="addChoice"
141
+ class="ma-1 pa-5 justify-start"
142
+ color="secondary"
143
+ outlined
144
+ >
145
+ {{
146
+ $tc(
147
+ 'plugin.games.components.content.blocks.quizshow_game.add_choice'
148
+ )
149
+ }}
150
+ </v-btn>
151
+ </v-row>
152
+ <v-row
153
+ align="center"
154
+ justify="center"
155
+ class="pt-10 font-weight-bold text-capitalize"
156
+ >
157
+ {{
158
+ $tc(
159
+ 'plugin.games.components.content.blocks.quizshow_game.form.for_points',
160
+ Number(points),
161
+ {
162
+ points: Number(points),
163
+ }
164
+ )
165
+ }}</v-row
166
+ >
167
+ <Dialog
168
+ v-model="feedbackModal"
169
+ :trigger="false"
170
+ @click:outside="close"
171
+ @click:close="close"
172
+ @keydown.esc="close"
173
+ >
174
+ <template #title>
175
+ {{
176
+ $t(
177
+ 'plugin.games.components.content.blocks.quizshow_game.feedback.answer_description'
178
+ )
179
+ }}
180
+ </template>
181
+ <template #form="{ on, attrs }">
182
+ <div v-bind="attrs" v-on="on">
183
+ {{
184
+ question.feedback
185
+ ? question.feedback
186
+ : $t(
187
+ 'plugin.games.components.content.blocks.quizshow_game.feedback.placeholder'
188
+ )
189
+ }}
190
+ </div>
191
+ </template>
192
+ </Dialog>
193
+ </v-container>
194
+ </template>
195
+
196
+ <script>
197
+ import Dialog from '~/components/Dialog.vue'
198
+ import { MathHelper } from '@windward/core/utils'
199
+
200
+ export default {
201
+ name: 'AnswerPanel',
202
+ components: { Dialog },
203
+ props: {
204
+ editMode: { type: Boolean, required: false, default: false },
205
+ value: { type: Object, required: true, default: () => {} },
206
+ state: { type: Object, required: false, default: () => {} },
207
+ points: { type: Number, required: true, default: 0 },
208
+ },
209
+ data() {
210
+ return {
211
+ question: {
212
+ text: '',
213
+ feedback: '',
214
+ answer: null,
215
+ choices: [],
216
+ },
217
+ userInput: null,
218
+ result: null,
219
+ feedbackModal: false,
220
+ }
221
+ },
222
+ watch: {
223
+ question: {
224
+ handler(newValue) {
225
+ this.$emit('input', newValue)
226
+ },
227
+ deep: true,
228
+ },
229
+ },
230
+ mounted() {
231
+ if (!_.isEmpty(this.value)) {
232
+ this.question = _.cloneDeep(this.value)
233
+ }
234
+ if (!_.isEmpty(this.state)) {
235
+ this.userInput = this.state.userInput
236
+ this.result = this.state.result
237
+ }
238
+ },
239
+ computed: {},
240
+ methods: {
241
+ mathToHtml(text) {
242
+ return MathHelper.convertMathContentToHtml(text)
243
+ },
244
+ emitUserInput() {
245
+ this.$emit('click-answer', {
246
+ result: this.result,
247
+ userInput: this.userInput,
248
+ })
249
+ },
250
+ generateButtonOutline(index) {
251
+ if (this.userInput === null) {
252
+ return true
253
+ }
254
+ if (this.question.choices[index].is_answer) {
255
+ return false
256
+ }
257
+ if (
258
+ this.userInput !== this.question.answer &&
259
+ index === this.userInput
260
+ ) {
261
+ return false
262
+ } else {
263
+ return true
264
+ }
265
+ },
266
+ generateButtonColor(index) {
267
+ if (this.userInput === null) {
268
+ return 'answer_display'
269
+ }
270
+ if (this.question.choices[index].is_answer) {
271
+ return 'success'
272
+ }
273
+ if (
274
+ this.userInput !== this.question.answer &&
275
+ index === this.userInput
276
+ ) {
277
+ return 'error'
278
+ } else {
279
+ return 'answer_display'
280
+ }
281
+ },
282
+ click() {
283
+ this.$emit('input', true)
284
+ },
285
+ getUserInput(answer) {
286
+ if (this.userInput === null) {
287
+ this.userInput = answer
288
+ if (answer === this.question.answer) {
289
+ this.result = true
290
+ } else {
291
+ this.result = false
292
+ }
293
+
294
+ this.emitUserInput()
295
+ }
296
+ },
297
+ setAnswer(index) {
298
+ if (this.question.answer === null) {
299
+ this.question.answer = index
300
+ } else if (this.question.answer === index) {
301
+ this.question.answer = null
302
+ }
303
+ },
304
+ addChoice() {
305
+ this.question.choices.push({ text: '', is_answer: false })
306
+ },
307
+ deleteItem(item) {
308
+ const editedIndex = this.question.choices.indexOf(item)
309
+ this.question.choices.splice(editedIndex, 1)
310
+ },
311
+ onFeedback(index) {
312
+ this.feedbackModal = true
313
+ },
314
+ close() {
315
+ this.feedbackModal = false
316
+ },
317
+ },
318
+ }
319
+ </script>
320
+
321
+ <style scoped>
322
+ .bucket {
323
+ box-shadow: 0px 2px 3px #0000004a;
324
+ color: black;
325
+ cursor: pointer;
326
+ padding: 0.3em;
327
+ margin: 0.3em;
328
+ vertical-align: middle;
329
+ display: inline-block;
330
+ }
331
+ .answer_display {
332
+ outline: var(--v-secondary-base) solid 2px;
333
+ }
334
+ .info-icon {
335
+ position: relative;
336
+ float: right;
337
+ }
338
+ </style>
@@ -0,0 +1,260 @@
1
+ <template>
2
+ <div>
3
+ <v-toolbar flat tile>
4
+ <v-app-bar-nav-icon></v-app-bar-nav-icon>
5
+ <v-toolbar-title class="text-capitalize">{{
6
+ $t(
7
+ 'plugin.games.components.content.blocks.quizshow_game.spreadsheet_mode'
8
+ )
9
+ }}</v-toolbar-title>
10
+ <v-spacer></v-spacer>
11
+ <v-btn
12
+ icon
13
+ :aria-label="
14
+ $t(
15
+ 'plugin.games.components.content.blocks.quizshow_game.expand_button'
16
+ )
17
+ "
18
+ @click="expand"
19
+ >
20
+ <v-icon>mdi-arrow-expand-all</v-icon>
21
+ </v-btn>
22
+ </v-toolbar>
23
+ <vue-excel-editor
24
+ v-model="jsondata"
25
+ @update="emitData"
26
+ filter-row
27
+ >
28
+ <vue-excel-column
29
+ field="category"
30
+ :label="
31
+ $t(
32
+ 'plugin.games.components.content.blocks.quizshow_game.category'
33
+ )
34
+ "
35
+ type="string"
36
+ autoFillWidth
37
+ readonly
38
+ />
39
+ <vue-excel-column
40
+ field="points"
41
+ :label="
42
+ $t(
43
+ 'plugin.games.components.content.blocks.quizshow_game.points'
44
+ )
45
+ "
46
+ width="60px"
47
+ readonly
48
+ />
49
+ <vue-excel-column
50
+ field="question"
51
+ :label="
52
+ $t(
53
+ 'plugin.games.components.content.blocks.quizshow_game.question'
54
+ )
55
+ "
56
+ type="string"
57
+ autoFillWidth
58
+ />
59
+ <vue-excel-column
60
+ field="answer"
61
+ :label="
62
+ $t(
63
+ 'plugin.games.components.content.blocks.quizshow_game.answer'
64
+ )
65
+ "
66
+ width="60px"
67
+ type="number"
68
+ :options="['1', '2', '3', '4']"
69
+ />
70
+ <vue-excel-column
71
+ field="choice_1"
72
+ :label="
73
+ $t(
74
+ 'plugin.games.components.content.blocks.quizshow_game.choice_1'
75
+ )
76
+ "
77
+ type="string"
78
+ autoFillWidth
79
+ />
80
+ <vue-excel-column
81
+ field="choice_2"
82
+ :label="
83
+ $t(
84
+ 'plugin.games.components.content.blocks.quizshow_game.choice_2'
85
+ )
86
+ "
87
+ type="string"
88
+ autoFillWidth
89
+ />
90
+ <vue-excel-column
91
+ field="choice_3"
92
+ :label="
93
+ $t(
94
+ 'plugin.games.components.content.blocks.quizshow_game.choice_3'
95
+ )
96
+ "
97
+ type="string"
98
+ autoFillWidth
99
+ />
100
+ <vue-excel-column
101
+ field="choice_4"
102
+ :label="
103
+ $t(
104
+ 'plugin.games.components.content.blocks.quizshow_game.choice_4'
105
+ )
106
+ "
107
+ type="string"
108
+ autoFillWidth
109
+ />
110
+ </vue-excel-editor>
111
+ <Dialog
112
+ v-model="dialog"
113
+ :trigger="false"
114
+ fullscreen
115
+ @click:outside="close"
116
+ @click:close="close"
117
+ @keydown.esc="close"
118
+ >
119
+ <template #title
120
+ ><span class="text-capitalize">{{
121
+ $t(
122
+ 'plugin.games.components.content.blocks.quizshow_game.spreadsheet_mode'
123
+ )
124
+ }}</span></template
125
+ >
126
+
127
+ <template #form="{ on, attrs }">
128
+ <vue-excel-editor
129
+ v-model="jsondata"
130
+ @update="emitData"
131
+ filter-row
132
+ v-bind="attrs"
133
+ v-on="on"
134
+ >
135
+ <vue-excel-column
136
+ field="category"
137
+ :label="
138
+ $t(
139
+ 'plugin.games.components.content.blocks.quizshow_game.category'
140
+ )
141
+ "
142
+ type="string"
143
+ autoFillWidth
144
+ readonly
145
+ />
146
+ <vue-excel-column
147
+ field="points"
148
+ :label="
149
+ $t(
150
+ 'plugin.games.components.content.blocks.quizshow_game.points'
151
+ )
152
+ "
153
+ width="60px"
154
+ readonly
155
+ />
156
+ <vue-excel-column
157
+ field="question"
158
+ :label="
159
+ $t(
160
+ 'plugin.games.components.content.blocks.quizshow_game.question'
161
+ )
162
+ "
163
+ type="string"
164
+ autoFillWidth
165
+ />
166
+ <vue-excel-column
167
+ field="answer"
168
+ :label="
169
+ $t(
170
+ 'plugin.games.components.content.blocks.quizshow_game.answer'
171
+ )
172
+ "
173
+ width="60px"
174
+ type="number"
175
+ :options="['1', '2', '3', '4']"
176
+ />
177
+ <vue-excel-column
178
+ field="choice_1"
179
+ :label="
180
+ $t(
181
+ 'plugin.games.components.content.blocks.quizshow_game.choice_1'
182
+ )
183
+ "
184
+ type="string"
185
+ autoFillWidth
186
+ />
187
+ <vue-excel-column
188
+ field="choice_2"
189
+ :label="
190
+ $t(
191
+ 'plugin.games.components.content.blocks.quizshow_game.choice_2'
192
+ )
193
+ "
194
+ type="string"
195
+ autoFillWidth
196
+ />
197
+ <vue-excel-column
198
+ field="choice_3"
199
+ :label="
200
+ $t(
201
+ 'plugin.games.components.content.blocks.quizshow_game.choice_3'
202
+ )
203
+ "
204
+ type="string"
205
+ autoFillWidth
206
+ />
207
+ <vue-excel-column
208
+ field="choice_4"
209
+ :label="
210
+ $t(
211
+ 'plugin.games.components.content.blocks.quizshow_game.choice_4'
212
+ )
213
+ "
214
+ type="string"
215
+ autoFillWidth
216
+ />
217
+ </vue-excel-editor>
218
+ </template>
219
+ </Dialog>
220
+ </div>
221
+ </template>
222
+
223
+ <script>
224
+ import Dialog from '~/components/Dialog.vue'
225
+ import VueExcelEditor from 'vue-excel-editor/src/VueExcelEditor'
226
+ import VueExcelColumn from 'vue-excel-editor/src/VueExcelColumn'
227
+ import _ from 'lodash'
228
+
229
+ export default {
230
+ name: 'Gridview',
231
+ components: { Dialog, VueExcelEditor, VueExcelColumn },
232
+ props: {
233
+ value: { type: Array, required: true, default: [] },
234
+ },
235
+ data() {
236
+ return {
237
+ jsondata: [],
238
+ dialog: false,
239
+ }
240
+ },
241
+ beforeMount() {
242
+ if (!_.isEmpty(this.value)) {
243
+ this.jsondata = _.cloneDeep(this.value)
244
+ }
245
+ },
246
+ methods: {
247
+ expand() {
248
+ this.dialog = true
249
+ },
250
+ emitData() {
251
+ this.$emit('input', this.jsondata)
252
+ },
253
+ close() {
254
+ this.dialog = false
255
+ },
256
+ },
257
+ }
258
+ </script>
259
+
260
+ <style scoped></style>