瀏覽代碼

fixed #325

ali 2 年之前
父節點
當前提交
697dacafb6

+ 7 - 1
src/components/Widgets/Test/TestParticipation/TestParticipation.vue

@@ -127,9 +127,15 @@ export default {
     this.mounted = true
 
     this.$bus.on('test-participate-single-question-sent-success', () => {
-      this.onAllQuestionsSentSuccess()
+      this.onSingleQuestionsSentSuccess()
     })
     this.$bus.on('test-participate-single-question-sent-failed', () => {
+      this.onSingleQuestionsSentFailed()
+    })
+    this.$bus.on('test-participate-all-question-sent-success', () => {
+      this.onAllQuestionsSentSuccess()
+    })
+    this.$bus.on('test-participate-all-question-sent-failed', () => {
       this.onAllQuestionsSentFailed()
     })
   },

+ 7 - 1
src/components/Widgets/Test/TestParticipation/components/AllQuestions.vue

@@ -85,11 +85,17 @@ export default {
 
       this.$emit('sending')
       this.$refs.entityCreate.createEntity(false)
-        .then(() => {
+        .then((response) => {
+          const answerBook = new AnswerBook(response.data)
+          this.$store.commit('Test/updateAnswerBook', answerBook)
+          FormBuilderAssist.setAttributeByName(this.inputs, 'answer_text', 'value', answerBook.overall_answer_text)
+          FormBuilderAssist.setAttributeByName(this.inputs, 'answer_attachment', 'value', answerBook.overall_answer_attachment)
           this.$emit('sentsuccess')
+          this.$bus.emit('test-participate-all-question-sent-success')
         })
         .catch((error) => {
           this.$emit('sentfailed')
+          this.$bus.emit('test-participate-all-question-sent-failed')
           if (error.response && error.response.status === 422) {
             this.$router.push({ name: 'UserPanel.Profile.AllClassrooms' })
           }