@windward/core 0.0.9 → 0.1.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 (61) hide show
  1. package/components/Content/Blocks/Accordion.vue +7 -2
  2. package/components/Content/Blocks/BlockQuote.vue +191 -0
  3. package/components/Content/Blocks/Email.vue +248 -0
  4. package/components/Content/Blocks/FeedbackTemplates/FeedbackQuestionLikert.vue +25 -14
  5. package/components/Content/Blocks/FeedbackTemplates/FeedbackQuestionTrueFalse.vue +3 -7
  6. package/components/Content/Blocks/Image.vue +1 -1
  7. package/components/Content/Blocks/OpenResponse.vue +22 -16
  8. package/components/Content/Blocks/Tab.vue +7 -3
  9. package/components/Content/Blocks/UserUpload.vue +2 -2
  10. package/components/Settings/AccordionSettings.vue +9 -1
  11. package/components/Settings/BlockQuoteSettings.vue +143 -0
  12. package/components/Settings/EmailSettings.vue +216 -0
  13. package/components/Settings/ImageSettings.vue +1 -1
  14. package/components/Settings/OpenResponseCollateSettings.vue +1 -1
  15. package/components/Settings/OpenResponseSettings.vue +7 -9
  16. package/components/Settings/TabSettings.vue +14 -5
  17. package/components/Settings/TextEditorSettings.vue +1 -1
  18. package/components/Settings/UserUploadSettings.vue +1 -1
  19. package/components/utils/MathExpressionEditor.vue +30 -15
  20. package/components/utils/TinyMCEWrapper.vue +3 -1
  21. package/i18n/en-US/components/content/blocks/block_quote.ts +3 -0
  22. package/i18n/en-US/components/content/blocks/email.ts +12 -0
  23. package/i18n/en-US/components/content/blocks/index.ts +4 -0
  24. package/i18n/en-US/components/settings/block_quote.ts +9 -0
  25. package/i18n/en-US/components/settings/email.ts +9 -0
  26. package/i18n/en-US/components/settings/index.ts +4 -0
  27. package/i18n/en-US/components/utils/index.ts +2 -0
  28. package/i18n/en-US/components/utils/math_expression_editor.ts +3 -0
  29. package/i18n/en-US/shared/content_blocks.ts +2 -1
  30. package/i18n/en-US/shared/settings.ts +5 -0
  31. package/i18n/es-ES/components/content/blocks/block_quote.ts +3 -0
  32. package/i18n/es-ES/components/content/blocks/email.ts +12 -0
  33. package/i18n/es-ES/components/content/blocks/index.ts +4 -0
  34. package/i18n/es-ES/components/settings/block_quote.ts +9 -0
  35. package/i18n/es-ES/components/settings/email.ts +9 -0
  36. package/i18n/es-ES/components/settings/index.ts +4 -0
  37. package/i18n/es-ES/components/utils/index.ts +2 -1
  38. package/i18n/es-ES/components/utils/math_expression_editor.ts +3 -0
  39. package/i18n/es-ES/shared/content_blocks.ts +2 -1
  40. package/i18n/es-ES/shared/settings.ts +5 -0
  41. package/i18n/sv-SE/components/content/blocks/block_quote.ts +3 -0
  42. package/i18n/sv-SE/components/content/blocks/email.ts +12 -0
  43. package/i18n/sv-SE/components/content/blocks/index.ts +4 -0
  44. package/i18n/sv-SE/components/settings/block_quote.ts +9 -0
  45. package/i18n/sv-SE/components/settings/email.ts +9 -0
  46. package/i18n/sv-SE/components/settings/index.ts +4 -0
  47. package/i18n/sv-SE/components/utils/index.ts +2 -1
  48. package/i18n/sv-SE/components/utils/math_expression_editor.ts +3 -0
  49. package/i18n/sv-SE/shared/content_blocks.ts +2 -1
  50. package/i18n/sv-SE/shared/settings.ts +5 -0
  51. package/package.json +4 -4
  52. package/plugin.js +42 -0
  53. package/test/Components/Content/Blocks/Accordion.spec.js +2 -0
  54. package/test/Components/Content/Blocks/BlockQuote.spec.js +23 -0
  55. package/test/Components/Content/Blocks/Email.spec.js +23 -0
  56. package/test/Components/Content/Blocks/Feedback.spec.js +1 -0
  57. package/test/Components/Content/Blocks/Math.spec.js +1 -0
  58. package/test/Components/Content/Blocks/Tab.spec.js +1 -0
  59. package/test/Components/Settings/BlockQuoteSettings.spec.js +20 -0
  60. package/test/Components/Settings/EmailSettings.spec.js +45 -0
  61. package/test/__mocks__/componentsMock.js +6 -0
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <div>
3
3
  <v-expansion-panels
4
+ v-model="block.metadata.config.currentAccordion"
4
5
  flat
5
6
  accordion
6
7
  focusable
@@ -43,8 +44,8 @@
43
44
  <script>
44
45
  import _ from 'lodash'
45
46
  import Crypto from '~/helpers/Crypto'
46
- import TextEditor from '~/components/Text/TextEditor.vue'
47
- import TextViewer from '~/components/Text/TextViewer.vue'
47
+ import TextEditor from '~/components/Text/TextEditor'
48
+ import TextViewer from '~/components/Text/TextViewer'
48
49
  import BaseContentBlock from '~/components/Content/Blocks/BaseContentBlock'
49
50
 
50
51
  export default {
@@ -73,6 +74,9 @@ export default {
73
74
  this.block.metadata.config.items = []
74
75
  this.block.metadata.config.items.push(defaultObject)
75
76
  }
77
+ if (_.isEmpty(this.block.metadata.config.currentAccordion)) {
78
+ this.block.metadata.config.currentAccordion = 0
79
+ }
76
80
  this.block.body = 'accordion'
77
81
  },
78
82
  data() {
@@ -114,6 +118,7 @@ export default {
114
118
  this.block.metadata.config.items.forEach((element) => {
115
119
  element.expand = false
116
120
  })
121
+ this.block.metadata.config.currentAccordion = null
117
122
  },
118
123
  },
119
124
  }
@@ -0,0 +1,191 @@
1
+ <template>
2
+ <v-container class="container-left-border">
3
+ <v-row
4
+ v-if="
5
+ block.metadata.config.title ||
6
+ block.metadata.config.instructions
7
+ "
8
+ >
9
+ <v-col cols="12" class="pb-0">
10
+ <h3 v-if="block.metadata.config.title">
11
+ {{ block.metadata.config.title }}
12
+ </h3>
13
+ <p v-if="block.metadata.config.instructions" class="pb-0 mb-0">
14
+ {{ block.metadata.config.instructions }}
15
+ </p>
16
+ </v-col>
17
+ </v-row>
18
+ <v-row>
19
+ <v-col cols="1">
20
+ <v-icon color="primary">mdi-format-quote-open</v-icon>
21
+ </v-col>
22
+ <v-col cols="11" class="pl-0">
23
+ <p class="pt-2">
24
+ {{ block.metadata.config.block_quote.quote }}
25
+ </p>
26
+ </v-col>
27
+ </v-row>
28
+ <v-row>
29
+ <v-col cols="12">
30
+ <p v-if="render">
31
+ {{ finalcitation
32
+ }}<span :class="classCitation">{{ finalsource }}</span>
33
+ </p>
34
+ <p v-if="!render">Citation Here</p>
35
+ </v-col>
36
+ </v-row>
37
+ </v-container>
38
+ </template>
39
+
40
+ <script>
41
+ import _ from 'lodash'
42
+ import BaseContentBlock from '~/components/Content/Blocks/BaseContentBlock'
43
+
44
+ export default {
45
+ name: 'ContentBlockTab',
46
+ extends: BaseContentBlock,
47
+ beforeMount() {
48
+ if (_.isEmpty(this.block)) {
49
+ this.block = {}
50
+ }
51
+ if (_.isEmpty(this.block.metadata)) {
52
+ this.block.metadata = {}
53
+ }
54
+ if (_.isEmpty(this.block.metadata.config)) {
55
+ this.block.metadata.config = {}
56
+ }
57
+ if (_.isEmpty(this.block.metadata.config.title)) {
58
+ this.block.metadata.config.title = ''
59
+ }
60
+ if (_.isEmpty(this.block.metadata.config.instructions)) {
61
+ this.block.metadata.config.instructions = ''
62
+ }
63
+ if (_.isEmpty(this.block.metadata.config.block_quote)) {
64
+ this.block.metadata.config.block_quote = {
65
+ quote: '',
66
+ author: '',
67
+ author_title: '',
68
+ organization: '',
69
+ source_title: '',
70
+ source_type: '',
71
+ }
72
+ }
73
+ this.block.body = 'block quote'
74
+ },
75
+ data() {
76
+ return {
77
+ finalcitation: '',
78
+ finalsource: '',
79
+ classCitation: '',
80
+ }
81
+ },
82
+ watch: {
83
+ render(newValue) {
84
+ if (newValue) {
85
+ this.createCitation()
86
+ }
87
+ },
88
+ },
89
+ mounted() {
90
+ this.createCitation()
91
+ },
92
+ methods: {
93
+ createCitation() {
94
+ this.finalcitation = ''
95
+ this.finalsource = ''
96
+ let counter = 0
97
+ for (const property in this.block.metadata.config.block_quote) {
98
+ // author details processed here counter added to see if a comma is needed before key
99
+ if (
100
+ property !== 'quote' &&
101
+ property !== 'source_type' &&
102
+ property !== 'source_title' &&
103
+ this.block.metadata.config.block_quote[property] !== null &&
104
+ this.block.metadata.config.block_quote[property] !== ''
105
+ ) {
106
+ if (counter > 0) {
107
+ //not first hit so a comma is needed before key
108
+ counter = counter + 1
109
+ this.finalcitation =
110
+ this.finalcitation +
111
+ ', ' +
112
+ this.block.metadata.config.block_quote[property]
113
+ } else {
114
+ //first hit, no comma needed
115
+ counter = counter + 1
116
+ this.finalcitation =
117
+ '—' +
118
+ this.finalcitation +
119
+ this.block.metadata.config.block_quote[property]
120
+ }
121
+ // checks that source_type isn't none and there is a source title
122
+ } else if (
123
+ property === 'source_title' &&
124
+ this.block.metadata.config.block_quote['source_type'] !==
125
+ 'None' &&
126
+ this.block.metadata.config.block_quote[property] !== null &&
127
+ this.block.metadata.config.block_quote[property] !== ''
128
+ ) {
129
+ // filters out source types book. Adds class to italicize books
130
+ if (
131
+ this.block.metadata.config.block_quote[
132
+ 'source_type'
133
+ ] === 'Book'
134
+ ) {
135
+ // checks if comma needed or not
136
+ if (counter > 0) {
137
+ this.finalsource =
138
+ ', ' +
139
+ this.block.metadata.config.block_quote[property]
140
+ this.classCitation = 'span-title'
141
+ } else {
142
+ this.finalsource =
143
+ '—' +
144
+ this.block.metadata.config.block_quote[property]
145
+ this.classCitation = 'span-title'
146
+ }
147
+ //checks if online journal
148
+ } else if (
149
+ this.block.metadata.config.block_quote[
150
+ 'source_type'
151
+ ] === 'Online Journal'
152
+ ) {
153
+ // checks if comma needed or not. Not Italicized
154
+ if (counter > 0) {
155
+ this.finalsource =
156
+ ', ' +
157
+ '"' +
158
+ this.block.metadata.config.block_quote[
159
+ property
160
+ ] +
161
+ '"'
162
+ this.classCitation = ''
163
+ } else {
164
+ this.finalsource =
165
+ '—' +
166
+ '"' +
167
+ this.block.metadata.config.block_quote[
168
+ property
169
+ ] +
170
+ '"'
171
+ this.classCitation = ''
172
+ }
173
+ }
174
+ }
175
+ }
176
+ },
177
+ },
178
+ }
179
+ </script>
180
+
181
+ <style scoped>
182
+ .container-left-border {
183
+ border-style: solid;
184
+ border-color: var(--v-secondary-base);
185
+ border-width: 2px 2px 2px 16px;
186
+ border-radius: 4px;
187
+ }
188
+ .span-title {
189
+ font-style: italic;
190
+ }
191
+ </style>
@@ -0,0 +1,248 @@
1
+ <template>
2
+ <v-container class="container-left-border">
3
+ <v-row
4
+ v-if="
5
+ block.metadata.config.title ||
6
+ block.metadata.config.instructions
7
+ "
8
+ >
9
+ <v-col cols="12" class="pa-0">
10
+ <h3 v-if="block.metadata.config.title">
11
+ {{ block.metadata.config.title }}
12
+ </h3>
13
+ <p v-if="block.metadata.config.instructions" class="pb-0 mb-0">
14
+ {{ block.metadata.config.instructions }}
15
+ </p>
16
+ </v-col>
17
+ </v-row>
18
+ <v-row>
19
+ <v-expansion-panels v-model="selectedPanels" accordion>
20
+ <v-container
21
+ class="pa-0 primary container-subject d-flex justify-center align-center"
22
+ >
23
+ <v-row class="d-flex pa-5">
24
+ <v-col cols="6">
25
+ {{
26
+ block.metadata.config.subject
27
+ ? block.metadata.config.subject
28
+ : 'Subject'
29
+ }}
30
+ </v-col>
31
+ <v-col
32
+ cols="6"
33
+ class="d-flex justify-end column-simulation"
34
+ >
35
+ {{
36
+ $t(
37
+ 'windward.core.components.content.blocks.email.simulation'
38
+ )
39
+ }}
40
+ </v-col>
41
+ </v-row>
42
+ </v-container>
43
+ <v-expansion-panel
44
+ v-for="(item, index) in block.metadata.config.emails"
45
+ :key="index"
46
+ elevation="0"
47
+ >
48
+ <v-expansion-panel-header>
49
+ <v-row>
50
+ <v-col class="pa-0 d-flex align-center">
51
+ <v-btn fab x-small class="primary" elevation="0"
52
+ >{{ item.initials ? item.initials : '' }}
53
+ </v-btn>
54
+ <v-icon
55
+ v-if="
56
+ block.metadata.config.emails.length !==
57
+ index + 1
58
+ "
59
+ >mdi-circle-medium</v-icon
60
+ >
61
+ <v-icon
62
+ v-if="
63
+ block.metadata.config.emails.length ===
64
+ index + 1
65
+ "
66
+ color="secondary"
67
+ >mdi-circle-medium</v-icon
68
+ >
69
+ <span class="span-details"
70
+ >{{ item.from ? item.from : 'From' }}
71
+ </span>
72
+ </v-col>
73
+ <v-col> </v-col>
74
+ </v-row>
75
+ </v-expansion-panel-header>
76
+ <v-expansion-panel-content>
77
+ <v-container class="pa-0 container-details">
78
+ <v-row>
79
+ <v-col cols="1"></v-col>
80
+ <v-col class="pa-0 div-details">
81
+ <div class="div-details-to pl-4">
82
+ {{
83
+ $t(
84
+ 'windward.core.components.content.blocks.email.to'
85
+ )
86
+ }}: {{ item.to }}
87
+ </div>
88
+ <div class="div-details-cc pl-4">
89
+ {{
90
+ $t(
91
+ 'windward.core.components.content.blocks.email.cc'
92
+ )
93
+ }}: {{ item.cc }}
94
+ </div>
95
+ </v-col>
96
+ </v-row>
97
+ <v-row>
98
+ <v-col cols="1"></v-col>
99
+ <v-col class="pl-4">
100
+ <TextViewer
101
+ v-if="!item.expand"
102
+ v-model="item.body"
103
+ text-viewer
104
+ ></TextViewer>
105
+ <TextEditor
106
+ v-if="!render && item.expand"
107
+ v-model="
108
+ block.metadata.config.emails[index]
109
+ .body
110
+ "
111
+ ></TextEditor>
112
+ </v-col>
113
+ </v-row>
114
+ </v-container>
115
+ <v-container
116
+ v-if="
117
+ block.metadata.config.emails.length ===
118
+ index + 1
119
+ "
120
+ >
121
+ <v-row class="pt-4">
122
+ <v-col cols="10" class="pa-0">
123
+ <v-btn color="primary" outlined>
124
+ <v-icon>mdi-reply</v-icon>
125
+ {{
126
+ $t(
127
+ 'windward.core.components.content.blocks.email.reply'
128
+ )
129
+ }}</v-btn
130
+ >
131
+ <v-btn color="primary" outlined>
132
+ <v-icon>mdi-reply-all</v-icon>
133
+ {{
134
+ $t(
135
+ 'windward.core.components.content.blocks.email.reply_all'
136
+ )
137
+ }}</v-btn
138
+ >
139
+ <v-btn color="primary" outlined>
140
+ <v-icon>mdi-share</v-icon>
141
+ {{
142
+ $t(
143
+ 'windward.core.components.content.blocks.email.forward'
144
+ )
145
+ }}</v-btn
146
+ >
147
+ </v-col>
148
+ <v-col cols="2" class="pa-0 d-flex justify-end">
149
+ <v-btn color="primary" outlined>
150
+ {{
151
+ $t(
152
+ 'windward.core.components.content.blocks.email.reset'
153
+ )
154
+ }}
155
+ </v-btn>
156
+ </v-col>
157
+ </v-row>
158
+ </v-container>
159
+ </v-expansion-panel-content>
160
+ </v-expansion-panel>
161
+ </v-expansion-panels>
162
+ </v-row>
163
+ </v-container>
164
+ </template>
165
+ <script>
166
+ import _ from 'lodash'
167
+ import TextEditor from '~/components/Text/TextEditor'
168
+ import TextViewer from '~/components/Text/TextViewer'
169
+ import BaseContentBlock from '~/components/Content/Blocks/BaseContentBlock'
170
+ export default {
171
+ name: 'ContentBlockEmail',
172
+ extends: BaseContentBlock,
173
+ components: {
174
+ TextEditor,
175
+ TextViewer,
176
+ },
177
+ beforeMount() {
178
+ if (_.isEmpty(this.block)) {
179
+ this.block = {}
180
+ }
181
+ if (_.isEmpty(this.block.metadata)) {
182
+ this.block.metadata = {}
183
+ }
184
+ if (_.isEmpty(this.block.metadata.config)) {
185
+ this.block.metadata.config = {}
186
+ }
187
+ if (_.isEmpty(this.block.metadata.config.title)) {
188
+ this.block.metadata.config.title = ''
189
+ }
190
+ if (_.isEmpty(this.block.metadata.config.instructions)) {
191
+ this.block.metadata.config.instructions = ''
192
+ }
193
+ if (_.isEmpty(this.block.metadata.config.emails)) {
194
+ this.block.metadata.config.emails = []
195
+ }
196
+ if (_.isEmpty(this.block.metadata.config.activeEmail)) {
197
+ this.block.metadata.config.activeEmail = 0
198
+ }
199
+ this.block.body = 'emails'
200
+ },
201
+ data() {
202
+ return {
203
+ expansionPanelKey: 0,
204
+ selectedPanels: 0,
205
+ }
206
+ },
207
+ watch: {
208
+ render() {
209
+ if (this.render) {
210
+ this.block.metadata.config.emails.forEach((element) => {
211
+ element.expand = false
212
+ })
213
+ this.selectedPanels =
214
+ this.block.metadata.config.emails.length - 1
215
+ }
216
+ },
217
+ },
218
+ mounted() {
219
+ this.selectedPanels = this.block.metadata.config.emails.length - 1
220
+ },
221
+ methods: {},
222
+ }
223
+ </script>
224
+ <style scoped>
225
+ .container-subject {
226
+ height: 40px;
227
+ }
228
+ .column-simulation {
229
+ font-size: 12px;
230
+ }
231
+ .container-details {
232
+ font-size: 10px;
233
+ margin-top: -26px;
234
+ }
235
+ .div-details {
236
+ color: grey;
237
+ }
238
+ .div-details-cc {
239
+ margin-top: -9px;
240
+ }
241
+ .span-details {
242
+ font-weight: bold;
243
+ font-size: 14px;
244
+ }
245
+ .v-expansion-panel {
246
+ border: 1px solid var(--v-primary-base);
247
+ }
248
+ </style>
@@ -3,7 +3,7 @@
3
3
  <p class="question">
4
4
  {{ value.body }}
5
5
  </p>
6
- <div class="d-flex justify-space-around">
6
+ <div class="d-flex">
7
7
  <v-radio-group
8
8
  :rules="[
9
9
  (v) =>
@@ -12,12 +12,12 @@
12
12
  'windward.core.components.content.blocks.feedback.required'
13
13
  ),
14
14
  ]"
15
- row
16
15
  class="radio-group"
16
+ :row="row"
17
+ :column="column"
17
18
  v-model="value.response"
18
19
  >
19
20
  <v-radio
20
- class="likert-radio"
21
21
  color="green"
22
22
  :label="
23
23
  $t(
@@ -27,7 +27,6 @@
27
27
  value="5"
28
28
  ></v-radio>
29
29
  <v-radio
30
- class="likert-radio"
31
30
  color="light-green"
32
31
  :label="
33
32
  $t(
@@ -37,7 +36,6 @@
37
36
  value="4"
38
37
  ></v-radio>
39
38
  <v-radio
40
- class="likert-radio"
41
39
  color="amber"
42
40
  :label="
43
41
  $t(
@@ -47,7 +45,6 @@
47
45
  value="3"
48
46
  ></v-radio>
49
47
  <v-radio
50
- class="likert-radio"
51
48
  color="orange"
52
49
  :label="
53
50
  $t(
@@ -57,7 +54,6 @@
57
54
  value="2"
58
55
  ></v-radio>
59
56
  <v-radio
60
- class="likert-radio"
61
57
  color="red"
62
58
  :label="
63
59
  $t(
@@ -78,7 +74,28 @@ export default {
78
74
  value: { type: Object, required: true, default: '' },
79
75
  },
80
76
  data() {
81
- return {}
77
+ return {
78
+ windowWidth: window.innerWidth,
79
+ row: true,
80
+ column: false,
81
+ }
82
+ },
83
+ mounted() {
84
+ this.$nextTick(() => {
85
+ window.addEventListener('resize', this.onResize)
86
+ })
87
+ },
88
+ methods: {
89
+ onResize() {
90
+ this.windowWidth = window.innerWidth
91
+ if (this.windowWidth <= 760) {
92
+ this.row = false
93
+ this.column = true
94
+ } else {
95
+ this.row = true
96
+ this.column = false
97
+ }
98
+ },
82
99
  },
83
100
  }
84
101
  </script>
@@ -86,10 +103,4 @@ export default {
86
103
  .question {
87
104
  font-weight: bold;
88
105
  }
89
- .radio-group {
90
- width: 100% !important;
91
- }
92
- .likert-radio {
93
- margin-left: 55px;
94
- }
95
106
  </style>
@@ -24,7 +24,9 @@
24
24
  ></v-radio>
25
25
  <v-radio
26
26
  class="likert-radio"
27
- :label="$t('windward.core.components.content.blocks.feedback.no')"
27
+ :label="
28
+ $t('windward.core.components.content.blocks.feedback.no')
29
+ "
28
30
  value="false"
29
31
  ></v-radio>
30
32
  </v-radio-group>
@@ -46,10 +48,4 @@ export default {
46
48
  .question {
47
49
  font-weight: bold;
48
50
  }
49
- .radio-group {
50
- width: 100% !important;
51
- }
52
- .likert-radio {
53
- margin-left: 55px;
54
- }
55
51
  </style>
@@ -45,7 +45,7 @@
45
45
 
46
46
  <script>
47
47
  import _ from 'lodash'
48
- import TextViewer from '~/components/Text/TextViewer.vue'
48
+ import TextViewer from '~/components/Text/TextViewer'
49
49
  import Crypto from '~/helpers/Crypto'
50
50
  import BaseContentBlock from '~/components/Content/Blocks/BaseContentBlock'
51
51
 
@@ -76,8 +76,8 @@
76
76
  <script>
77
77
  import _ from 'lodash'
78
78
  import { mapGetters } from 'vuex'
79
- import TextViewer from '~/components/Text/TextViewer.vue'
80
- import TextEditor from '~/components/Text/TextEditor.vue'
79
+ import TextViewer from '~/components/Text/TextViewer'
80
+ import TextEditor from '~/components/Text/TextEditor'
81
81
  import BaseContentBlock from '~/components/Content/Blocks/BaseContentBlock'
82
82
  import UserContentBlockState from '~/models/UserContentBlockState'
83
83
 
@@ -128,22 +128,28 @@ export default {
128
128
  // Check to see if we have a state already for this block with the same block_id
129
129
  // States are loaded via the ContentBlock.id but in this particular case we want to
130
130
  // maintain the state ACROSS different ContentBlock.ids but with the same linked Block.id
131
- const userState = await UserContentBlockState.where({
132
- 'metadata->block->tag': 'plugin-core-open-response',
133
- course_user_id: this.enrollment.id,
134
- })
135
- .where('metadata->block->block_id', this.block.block_id)
136
- .first()
131
+ if (this.block.block_id) {
132
+ const userState = await UserContentBlockState.where({
133
+ 'metadata->block->tag': 'plugin-core-open-response',
134
+ course_user_id: this.enrollment.id,
135
+ })
136
+ .where('metadata->block->block_id', this.block.block_id)
137
+ .first()
137
138
 
138
- // Apply the "True" state
139
- if (!_.isEmpty(userState)) {
140
- this.response = _.get(userState, 'metadata.response', '')
141
- this.submitted = _.get(userState, 'metadata.submitted', false)
142
- }
139
+ // Apply the "True" state
140
+ if (!_.isEmpty(userState)) {
141
+ this.response = _.get(userState, 'metadata.response', '')
142
+ this.submitted = _.get(
143
+ userState,
144
+ 'metadata.submitted',
145
+ false
146
+ )
147
+ }
143
148
 
144
- // If after the state is applied the response is still empty then apply the default response
145
- if (this.response === '') {
146
- this.response = this.block.metadata.config.starting_text
149
+ // If after the state is applied the response is still empty then apply the default response
150
+ if (this.response === '') {
151
+ this.response = this.block.metadata.config.starting_text
152
+ }
147
153
  }
148
154
 
149
155
  this.stateLoaded = true