56
56
</template >
57
57
<v-select
58
58
v-else
59
- v-model =" question.question_type"
59
+ :value =" question.question_type"
60
+ @change =" onChangeQuestionType(question, $event)"
60
61
:items =" questionTypes"
61
62
hide-details
62
63
outlined
76
77
hide-details
77
78
outlined
78
79
dense
79
- >
80
- <template #prepend-item >
81
- <v-list >
82
- <v-subheader >
83
- Common choices
84
- </v-subheader >
85
- <v-list-item
86
- v-for =" (value, key) in commonChoices"
87
- :key =" key"
88
- @click =" question.choices = value"
89
- >
90
- <v-list-item-title >
91
- {{ key }}
92
- </v-list-item-title >
93
- </v-list-item >
94
- </v-list >
95
- </template >
96
- </v-select >
80
+ ></v-select >
97
81
</template >
98
82
</td >
99
83
<td >
100
84
<template v-if =" ! question .editing " >
101
- {{ formatList(question.answers, ' / ') }}
85
+ <span v-if =" question.question_type === 'true_false' || question.question_type === 'yes_no'" >
86
+ {{ toTitleCase(question.answers[0], '_') }}
87
+ </span >
88
+ <span v-else >
89
+ {{ formatList(question.answers, ' / ') }}
90
+ </span >
102
91
</template >
92
+ <v-select
93
+ v-else-if =" question.question_type === 'multiple_choice'"
94
+ v-model =" question.answers"
95
+ :items =" getChoicesItems(question)"
96
+ multiple
97
+ hide-details
98
+ outlined
99
+ dense
100
+ ></v-select >
101
+ <v-select
102
+ v-else-if =" question.question_type === 'true_false' || question.question_type === 'yes_no'"
103
+ :value =" question.answers[0]"
104
+ @input =" question.answers = [$event]"
105
+ :items =" getChoicesItems(question)"
106
+ hide-details
107
+ outlined
108
+ dense
109
+ ></v-select >
103
110
<v-text-field
104
111
v-else
112
+ v-model =" question.answers"
105
113
:value =" formatList(question.answers, ' / ')"
106
114
@input =" question.answers = parseList($event, ' / ')"
107
115
hide-details
@@ -188,7 +196,7 @@ import { Mixins, Component } from 'vue-property-decorator'
188
196
import { ReadingExerciseMixin } from ' @/mixins/reading-exercise-mixin'
189
197
import { ReadingQuestion } from ' @/interfaces/reading-question'
190
198
import { ReadingQuestionCreateReq , ReadingQuestionUpdateReq } from ' @/interfaces/api/reading-question'
191
- import { unexpectedExc } from ' @/utils'
199
+ import { toTitleCase , unexpectedExc } from ' @/utils'
192
200
193
201
declare interface LocalQuestion extends ReadingQuestion {
194
202
editing: boolean ;
@@ -312,7 +320,7 @@ export default class ReadingExerciseEditAnswers extends Mixins(ReadingExerciseMi
312
320
313
321
allNextPassageIsEmpty (passage : LocalQuestion [' passage' ]): boolean {
314
322
if (passage === 3 ) return true
315
- for (let i = passage ; i <= 3 ; i ++ ) {
323
+ for (let i = passage + 1 ; i <= 3 ; i ++ ) {
316
324
const questions = (this [` passage${i }Questions ` ] as LocalQuestion [])
317
325
if (questions .length > 0 ) {
318
326
return false
@@ -321,6 +329,32 @@ export default class ReadingExerciseEditAnswers extends Mixins(ReadingExerciseMi
321
329
return true
322
330
}
323
331
332
+ getChoicesItems (question : LocalQuestion ): { text: string ; value: string }[] | string [] {
333
+ if (question .question_type === ' true_false' ) {
334
+ return [
335
+ { text: ' True' , value: ' TRUE' },
336
+ { text: ' False' , value: ' FALSE' },
337
+ { text: ' Not Given' , value: ' NOT_GIVEN' }
338
+ ]
339
+ } else if (question .question_type === ' yes_no' ) {
340
+ return [
341
+ { text: ' Yes' , value: ' YES' },
342
+ { text: ' No' , value: ' NO' },
343
+ { text: ' Not Given' , value: ' NOT_GIVEN' }
344
+ ]
345
+ } else {
346
+ return question .choices
347
+ }
348
+ }
349
+
350
+ toTitleCase = toTitleCase
351
+
352
+ onChangeQuestionType (question : LocalQuestion , value : LocalQuestion [' question_type' ]): void {
353
+ question .question_type = value
354
+ question .choices = []
355
+ question .answers = []
356
+ }
357
+
324
358
/**
325
359
* Call API
326
360
*/
0 commit comments