|
@@ -44,6 +44,7 @@
|
|
|
:accessory-list="accessory_list"
|
|
|
:homework-list="homework_list"
|
|
|
:add-homework="curry(taskAddHomework)(taskIndex)"
|
|
|
+ :delete-homework="curry(deleteTaskHomework)(taskIndex)"
|
|
|
/>
|
|
|
|
|
|
<MessageView
|
|
@@ -66,6 +67,7 @@
|
|
|
:add-exam-answer="curry(addSubtaskAnswer)(taskIndex)(i)"
|
|
|
:add-message-item="curry(addSubtaskMessageItem)(taskIndex)(i)"
|
|
|
:delete-message-item="curry(deleteSubtaskMessageItem)(taskIndex)(i)"
|
|
|
+ :delete-homework="curry(deleteSubtaskHomework)(taskIndex)(i)"
|
|
|
/>
|
|
|
</template>
|
|
|
</div>
|
|
@@ -86,6 +88,14 @@ import { useShowFile } from '@/common/show_file/index';
|
|
|
import { previewDateTransform } from '@/utils/course';
|
|
|
import { taskClassify } from '@/views/teacher/create_course/step_three/components/data/constant';
|
|
|
import { curry } from '@/utils/common';
|
|
|
+import {
|
|
|
+ SubmitTask_MaterialFinish_Student,
|
|
|
+ SubmitTask_HomeworkFile_Student,
|
|
|
+ SubmitTask_MessageReply_Student,
|
|
|
+ DeleteTask_HomeworkFile,
|
|
|
+ DeleteTask_MessageReply
|
|
|
+} from '@/api/course';
|
|
|
+import { MessageBox } from 'element-ui';
|
|
|
|
|
|
import ShowFile from '@/common/show_file/index.vue';
|
|
|
import FileView from '../common/FileView.vue';
|
|
@@ -98,41 +108,227 @@ let { visible, curFileId, curFileName, dialogShowFileClose } = useShowFile();
|
|
|
let taskList = inject('taskList');
|
|
|
let taskType = inject('taskType');
|
|
|
|
|
|
-// 添加作业
|
|
|
+/**
|
|
|
+ * 添加任务作业
|
|
|
+ * @param {Number} index 任务索引
|
|
|
+ * @param {Object} file 文件数据
|
|
|
+ */
|
|
|
function taskAddHomework(index, file) {
|
|
|
- taskList.value[index].homework_list.push(file);
|
|
|
+ SubmitTask_HomeworkFile_Student({
|
|
|
+ task_id: taskList.value[index].id,
|
|
|
+ info_block_id: '',
|
|
|
+ file_id: file.file_id
|
|
|
+ }).then(({ status }) => {
|
|
|
+ if (status === 1) {
|
|
|
+ taskList.value[index].homework_list.push(file);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 添加子任务作业
|
|
|
+ * @param {Number} index 任务索引
|
|
|
+ * @param {Number} subIndex 子任务索引
|
|
|
+ * @param {Number} infoIndex 信息块索引
|
|
|
+ * @param {Object} file 文件数据
|
|
|
+ */
|
|
|
function subtaskAddHomework(index, subIndex, infoIndex, file) {
|
|
|
- taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex].homework_list.push(file);
|
|
|
+ const infoBlockItem = taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex];
|
|
|
+ SubmitTask_HomeworkFile_Student({
|
|
|
+ task_id: taskList.value[index].id,
|
|
|
+ info_block_id: infoBlockItem.id,
|
|
|
+ file_id: file.file_id
|
|
|
+ }).then(({ status }) => {
|
|
|
+ if (status === 1) {
|
|
|
+ infoBlockItem.homework_list.push(file);
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 删除任务作业
|
|
|
+ * @param {Number} index 任务索引
|
|
|
+ * @param {String} file_id 文件id
|
|
|
+ */
|
|
|
+function deleteTaskHomework(index, file_id) {
|
|
|
+ MessageBox.confirm('您确定要删除该作业吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ DeleteTask_HomeworkFile({
|
|
|
+ task_id: taskList.value[index].id,
|
|
|
+ info_block_id: '',
|
|
|
+ file_id
|
|
|
+ }).then(({ status }) => {
|
|
|
+ if (status === 1) {
|
|
|
+ taskList.value[index].homework_list = taskList.value[index].homework_list.filter(
|
|
|
+ (item) => item.file_id !== file_id
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 删除子任务作业
|
|
|
+ * @param {Number} index 任务索引
|
|
|
+ * @param {Number} subIndex 子任务索引
|
|
|
+ * @param {Number} infoIndex 信息块索引
|
|
|
+ * @param {String} file_id 文件id
|
|
|
+ */
|
|
|
+function deleteSubtaskHomework(index, subIndex, infoIndex, file_id) {
|
|
|
+ MessageBox.confirm('您确定要删除该作业吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ const infoBlockItem = taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex];
|
|
|
+ DeleteTask_HomeworkFile({
|
|
|
+ task_id: taskList.value[index].id,
|
|
|
+ info_block_id: infoBlockItem.id,
|
|
|
+ file_id
|
|
|
+ }).then(({ status }) => {
|
|
|
+ if (status === 1) {
|
|
|
+ infoBlockItem.homework_list = infoBlockItem.homework_list.filter((item) => item.file_id !== file_id);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-// 课件添加答案
|
|
|
-function addExamAnswer(index, courseIndex, answer) {
|
|
|
- taskList.value[index].courseware_list[courseIndex].exam_answer = answer;
|
|
|
+/**
|
|
|
+ * 课件添加答案
|
|
|
+ * @param {Number} index 任务索引
|
|
|
+ * @param {Number} courseIndex 课件索引
|
|
|
+ * @param {Object} exam_answer 答案
|
|
|
+ */
|
|
|
+function addExamAnswer(index, courseIndex, exam_answer) {
|
|
|
+ const coursewareItem = taskList.value[index].courseware_list[courseIndex];
|
|
|
+ SubmitTask_MaterialFinish_Student({
|
|
|
+ task_id: taskList.value[index].id,
|
|
|
+ info_block_id: '',
|
|
|
+ material_id: coursewareItem.courseware_id,
|
|
|
+ material_type: 'COURSEWARE',
|
|
|
+ exam_answer
|
|
|
+ }).then(({ status }) => {
|
|
|
+ if (status === 1) {
|
|
|
+ coursewareItem.exam_answer = exam_answer;
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-function addSubtaskAnswer(index, subIndex, infoIndex, courseIndex, answer) {
|
|
|
- taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex].courseware_list[courseIndex].exam_answer =
|
|
|
- answer;
|
|
|
+/**
|
|
|
+ * 子任务课件添加答案
|
|
|
+ * @param {Number} index 任务索引
|
|
|
+ * @param {Number} subIndex 子任务索引
|
|
|
+ * @param {Number} infoIndex 信息块索引
|
|
|
+ * @param {Number} courseIndex 课件索引
|
|
|
+ * @param {Object} exam_answer 答案
|
|
|
+ */
|
|
|
+function addSubtaskAnswer(index, subIndex, infoIndex, courseIndex, exam_answer) {
|
|
|
+ const infoBlockItem = taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex];
|
|
|
+ SubmitTask_MaterialFinish_Student({
|
|
|
+ task_id: taskList.value[index].id,
|
|
|
+ info_block_id: infoBlockItem.id,
|
|
|
+ material_id: infoBlockItem.courseware_list[courseIndex].courseware_id,
|
|
|
+ material_type: 'COURSEWARE',
|
|
|
+ exam_answer
|
|
|
+ }).then(({ status }) => {
|
|
|
+ if (status === 1) {
|
|
|
+ infoBlockItem.courseware_list[courseIndex].exam_answer = exam_answer;
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-// 添加消息列表项
|
|
|
+/**
|
|
|
+ * 添加消息列表项
|
|
|
+ * @param {Number} index 任务索引
|
|
|
+ * @param {Object} data 消息数据
|
|
|
+ */
|
|
|
function addMessageItem(index, data) {
|
|
|
- taskList.value[index].message_list.push(data);
|
|
|
+ SubmitTask_MessageReply_Student({
|
|
|
+ task_id: taskList.value[index].id,
|
|
|
+ is_task_remark: false,
|
|
|
+ info_block_id: '',
|
|
|
+ text: data.text,
|
|
|
+ file_id: data.file_id,
|
|
|
+ message_type: data.message_type
|
|
|
+ }).then(({ status, id }) => {
|
|
|
+ if (status === 1) {
|
|
|
+ taskList.value[index].message_list.push({ id, ...data });
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 添加子任务消息列表项
|
|
|
+ * @param {Number} index 任务索引
|
|
|
+ * @param {Number} subIndex 子任务索引
|
|
|
+ * @param {Number} infoIndex 信息块索引
|
|
|
+ * @param {Object} data 消息数据
|
|
|
+ */
|
|
|
function addSubtaskMessageItem(index, subIndex, infoIndex, data) {
|
|
|
- taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex].message_list.push(data);
|
|
|
+ const infoBlockItem = taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex];
|
|
|
+ SubmitTask_MessageReply_Student({
|
|
|
+ task_id: taskList.value[index].id,
|
|
|
+ is_task_remark: false,
|
|
|
+ info_block_id: infoBlockItem.id,
|
|
|
+ text: data.text,
|
|
|
+ file_id: data.file_id,
|
|
|
+ message_type: data.message_type
|
|
|
+ }).then(({ status, id }) => {
|
|
|
+ if (status === 1) {
|
|
|
+ infoBlockItem.message_list.push({ id, ...data });
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-// 删除消息列表项
|
|
|
+/**
|
|
|
+ * 删除消息列表项
|
|
|
+ * @param {Number} index 任务索引
|
|
|
+ * @param {Number} i 消息索引
|
|
|
+ */
|
|
|
function deleteMessageItem(index, i) {
|
|
|
- taskList.value[index].message_list.splice(i, 1);
|
|
|
+ MessageBox.confirm('您确定要删除该消息吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ const messageList = taskList.value[index].message_list;
|
|
|
+ DeleteTask_MessageReply({
|
|
|
+ task_id: taskList.value[index].id,
|
|
|
+ message_id: messageList[i].id
|
|
|
+ }).then(({ status }) => {
|
|
|
+ if (status === 1) {
|
|
|
+ messageList.splice(i, 1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 删除子任务消息列表项
|
|
|
+ * @param {Number} index 任务索引
|
|
|
+ * @param {Number} subIndex 子任务索引
|
|
|
+ * @param {Number} infoIndex 信息块索引
|
|
|
+ * @param {Number} i 消息索引
|
|
|
+ */
|
|
|
function deleteSubtaskMessageItem(index, subIndex, infoIndex, i) {
|
|
|
- taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex].message_list.splice(i, 1);
|
|
|
+ MessageBox.confirm('您确定要删除该消息吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ const subtaskMessageList = taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex].message_list;
|
|
|
+ DeleteTask_MessageReply({
|
|
|
+ task_id: taskList.value[index].id,
|
|
|
+ message_id: subtaskMessageList[i].id
|
|
|
+ }).then(({ status }) => {
|
|
|
+ if (status === 1) {
|
|
|
+ subtaskMessageList.splice(i, 1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
</script>
|
|
|
|