|
@@ -32,7 +32,15 @@ export default {
|
|
|
modal: false,
|
|
modal: false,
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
- inject: ['getCoursewareId'],
|
|
|
|
|
|
|
+ inject: {
|
|
|
|
|
+ bookStatus: {
|
|
|
|
|
+ default: 'online',
|
|
|
|
|
+ },
|
|
|
|
|
+ tempDir: {
|
|
|
|
|
+ default: '',
|
|
|
|
|
+ },
|
|
|
|
|
+ getCoursewareId: {},
|
|
|
|
|
+ },
|
|
|
props: ['exercise_id', 'feed_back'],
|
|
props: ['exercise_id', 'feed_back'],
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
@@ -90,27 +98,46 @@ export default {
|
|
|
this.permissionControl.can_show_answer = true;
|
|
this.permissionControl.can_show_answer = true;
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- handleData() {
|
|
|
|
|
|
|
+ async handleData() {
|
|
|
this.loading = true;
|
|
this.loading = true;
|
|
|
- let data = {
|
|
|
|
|
- exercise_id: this.exercise_id,
|
|
|
|
|
- courseware_id: this.getCoursewareId(),
|
|
|
|
|
- };
|
|
|
|
|
- GetCoursewareExerciseView(data)
|
|
|
|
|
- .then((res) => {
|
|
|
|
|
- this.loading = false;
|
|
|
|
|
- if (res.status === 1) {
|
|
|
|
|
|
|
+ if (this.bookStatus() === 'offline') {
|
|
|
|
|
+ this.loading = false;
|
|
|
|
|
+ if (this.readFileContent()) {
|
|
|
|
|
+ const content = await window.fileAPI.readZipFilesync(
|
|
|
|
|
+ `${this.tempDir}/courseware`,
|
|
|
|
|
+ `EX_${this.getCoursewareId()}/${this.exercise_id}`,
|
|
|
|
|
+ );
|
|
|
|
|
+ const text = new TextDecoder().decode(content);
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = JSON.parse(text);
|
|
|
this.content = res.content_exercise;
|
|
this.content = res.content_exercise;
|
|
|
this.title = res.content_title;
|
|
this.title = res.content_title;
|
|
|
this.typeValue = res.content_exercise ? JSON.parse(res.content_exercise).type : '';
|
|
this.typeValue = res.content_exercise ? JSON.parse(res.content_exercise).type : '';
|
|
|
- // setTimeout(() => {
|
|
|
|
|
- // this.$refs.preview.showAnswer(true, false, this.$refs.preview.answer, true);
|
|
|
|
|
- // }, 100);
|
|
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ this.$message.warning('获取练习题数据失败');
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
- .catch(() => {
|
|
|
|
|
- this.loading = false;
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ let data = {
|
|
|
|
|
+ exercise_id: this.exercise_id,
|
|
|
|
|
+ courseware_id: this.getCoursewareId(),
|
|
|
|
|
+ };
|
|
|
|
|
+ GetCoursewareExerciseView(data)
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ this.loading = false;
|
|
|
|
|
+ if (res.status === 1) {
|
|
|
|
|
+ this.content = res.content_exercise;
|
|
|
|
|
+ this.title = res.content_title;
|
|
|
|
|
+ this.typeValue = res.content_exercise ? JSON.parse(res.content_exercise).type : '';
|
|
|
|
|
+ // setTimeout(() => {
|
|
|
|
|
+ // this.$refs.preview.showAnswer(true, false, this.$refs.preview.answer, true);
|
|
|
|
|
+ // }, 100);
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(() => {
|
|
|
|
|
+ this.loading = false;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|