提交 d1673c75 authored 作者: matian's avatar matian

批改试卷接口对接

上级 39721f96
...@@ -25,14 +25,14 @@ export function getPaperStuDetail(params?: { id: string }) { ...@@ -25,14 +25,14 @@ export function getPaperStuDetail(params?: { id: string }) {
return httpRequest.get('/api/resource/v1/teaching/paper/view', { params }) return httpRequest.get('/api/resource/v1/teaching/paper/view', { params })
} }
// 评分 // 评分
export function updateComment(params?: { export function updateComment(data: {
id: string id: string
index: string index: string
child_index?: string child_index?: string
user_score: string user_score: string
reviews: string reviews: string
}) { }) {
return httpRequest.get('/api/resource/v1/teaching/paper/update ', { params }) return httpRequest.post('/api/resource/v1/teaching/paper/update ', data)
} }
// /** // /**
// * 获取试卷详情 // * 获取试卷详情
......
<script lang="ts" setup>
import type { IQuestionList } from '../type'
import QuestionItem from './QuestionItem.vue'
interface Props {
everyQuestion: any
questionList: IQuestionList[]
}
const props = defineProps<Props>()
</script>
<template>
<el-card class="container">
<template #header>
<span>{{ everyQuestion?.question_content }}</span>
</template>
<div class="content">
<template v-for="item in props.questionList">
<div class="sub-content" v-if="item?.children" :key="item.id">
<div class="title" v-html="item.common_content"></div>
<div class="sub-container">
<QuestionItem v-for="subItem in item.children" :key="subItem.id" :question="subItem" />
</div>
</div>
<div v-else :key="item.id">
<QuestionItem :question="item" />
</div>
</template>
</div>
</el-card>
</template>
<style lang="scss" scoped>
.container {
background: #fff;
border: 1px solid #f3f3f3;
margin-bottom: 20px;
border-radius: 6px;
::v-deep .el-card__body {
padding: 10px 20px;
}
.content {
// border:1px solid #f3f3f3;
padding: 10px;
.title {
line-height: 40px;
font-size: 16px;
}
.sub-container {
border: 1px solid #e3e3e3;
padding: 15px 15px 0;
border-radius: 4px;
}
.sub-content {
margin-bottom: 20px;
}
.question-item:last-child {
border: none;
}
}
}
</style>
<script lang="ts" setup> <script lang="ts" setup>
import { ElMessage } from 'element-plus'
import { updateComment } from '../api' import { updateComment } from '../api'
const showComment = ref(false) const showComment = ref(false)
const props = defineProps({ const props = defineProps({
...@@ -8,30 +10,43 @@ const props = defineProps({ ...@@ -8,30 +10,43 @@ const props = defineProps({
return {} return {}
} }
}, },
question_item_id: {
currentIndex: {
type: Number
},
childIndex: {
type: Number
},
// 试卷id
questionId: {
type: String type: String
} }
}) })
const questionData = Object.assign({}, props.question)
const reviews = ref('')
let questionData: any = $ref({})
questionData = Object.assign({}, props.question)
const questionType = computed(() => { const questionType = computed(() => {
// 1单选,2多选,3简答,5案例题, 6判断, 7实操,8情景 // 1单选,2多选,3简答,5案例题, 6判断, 7实操,8情景
if (props.question.child_question_type) { console.log(props.question.child_question_type, props.question.child_question_type)
if (props.question.child_question_type !== 0) {
return parseInt(props.question.child_question_type) return parseInt(props.question.child_question_type)
} else { } else {
return parseInt(props.question.questionType) return parseInt(props.question.question_type)
} }
}) })
const fetchComment = () => { const fetchComment = () => {
const params = { const params: any = {
id: '', id: props.questionId,
index: '', index: props.currentIndex,
child_index: '', child_index: props.childIndex,
user_score: '', user_score: questionData.user_score,
reviews: '' reviews: reviews.value
} }
updateComment(params).then(() => { updateComment(params).then(() => {
console.log('000') ElMessage.success('点评成功')
questionData.is_reviewed = true
}) })
} }
</script> </script>
...@@ -40,7 +55,7 @@ const fetchComment = () => { ...@@ -40,7 +55,7 @@ const fetchComment = () => {
<div class="question-item-title" v-html="props.question.question_content"></div> <div class="question-item-title" v-html="props.question.question_content"></div>
<template v-if="questionType === 1 || questionType === 6"> <template v-if="questionType === 1 || questionType === 6">
<el-radio-group v-model="questionData.user_answer" :disabled="true" class="question-item-content"> <el-radio-group v-model="questionData.user_answer" :disabled="true" class="question-item-content">
<div class="question-item-option" v-for="subItem in props.question.question_options" :key="subItem.id"> <div class="question-item-option" v-for="subItem in questionData.question_options" :key="subItem.id">
<el-radio :label="subItem.id">{{ subItem.option }}</el-radio> <el-radio :label="subItem.id">{{ subItem.option }}</el-radio>
</div> </div>
</el-radio-group> </el-radio-group>
...@@ -60,7 +75,7 @@ const fetchComment = () => { ...@@ -60,7 +75,7 @@ const fetchComment = () => {
size="small" size="small"
plain plain
@click="showComment = !showComment" @click="showComment = !showComment"
v-permission="'admin_exam_exam_submit_sheet'" v-if="props.question.is_reviewed !== true"
>点击评分</el-button >点击评分</el-button
> >
</div> </div>
...@@ -69,11 +84,11 @@ const fetchComment = () => { ...@@ -69,11 +84,11 @@ const fetchComment = () => {
<p>本题{{ props.question.score }}</p> <p>本题{{ props.question.score }}</p>
<div class="get-score"> <div class="get-score">
学生得分:<el-input-number 学生得分:<el-input-number
:disabled="questionData.checked_flag" :disabled="questionData.is_reviewed"
v-model="questionData.user_score" v-model="questionData.user_score"
controls-position="right" controls-position="right"
:min="0" :min="0"
:max="props.question.score" :max="questionData.score"
size="small" size="small"
></el-input-number> ></el-input-number>
</div> </div>
...@@ -81,18 +96,18 @@ const fetchComment = () => { ...@@ -81,18 +96,18 @@ const fetchComment = () => {
<el-input <el-input
type="textarea" type="textarea"
placeholder="请输入评语" placeholder="请输入评语"
v-model="questionData.reviews" v-model="reviews"
rows="3" rows="3"
:disabled="questionData.checked_flag" :disabled="questionData.is_reviewed"
/> />
<div style="text-align: center; padding-top: 10px"> <div style="text-align: center; padding-top: 10px">
<el-button type="primary" size="small" @click="fetchComment" :disabled="props.question.checked_flag" <el-button type="primary" size="small" @click="fetchComment" :disabled="questionData.is_reviewed"
>提交点评</el-button >提交点评</el-button
> >
</div> </div>
</div> </div>
</template> </template>
<div class="question-item-score">得分:{{ props.question.user_score }}分</div> <div class="question-item-score">得分:{{ questionData.user_score }}分</div>
</div> </div>
</template> </template>
......
interface IQuestionptions { interface IQuestionptions {
option: string option: string
checked_option: string checked_option: string
checked: boolean checked: boolean
...@@ -24,5 +24,8 @@ export interface IQuestionList { ...@@ -24,5 +24,8 @@ export interface IQuestionList {
is_parent: number is_parent: number
child_question_type: number child_question_type: number
score: number score: number
user_answer: any
user_answer_status: boolean
user_score: number
children?: IQuestionList[] children?: IQuestionList[]
} }
...@@ -67,6 +67,7 @@ const listOptions = $computed(() => { ...@@ -67,6 +67,7 @@ const listOptions = $computed(() => {
const handleCheckPaper = (row: any) => { const handleCheckPaper = (row: any) => {
router.push({ path: '/teach/view', query: { id: row.id } }) router.push({ path: '/teach/view', query: { id: row.id } })
} }
onMounted(() => { onMounted(() => {
checkPermission('v1-teaching-paper-search-list') && handleGetClassList() checkPermission('v1-teaching-paper-search-list') && handleGetClassList()
}) })
......
<script lang="ts" setup> <script lang="ts" setup>
import type { IQuestionList } from '../type' import type { IQuestionList } from '../type'
import { getPaperStuDetail } from '../api' import { getPaperStuDetail } from '../api'
import PaperQuestion from '../components/PaperQuestion.vue' import QuestionItem from '../components/QuestionItem.vue'
const route = useRoute() const route = useRoute()
const questionList: any = ref<IQuestionList[]>([]) const questionList: any = ref<IQuestionList[]>([])
const questionData: any = ref({}) const questionData: any = ref({})
const paper_id = route.query.id as string
// 获取试卷详情 // 获取试卷详情
getPaperStuDetail({ id: route.query.id as string }).then(res => { getPaperStuDetail({ id: paper_id }).then(res => {
questionData.value = res.data questionData.value = res.data
questionList.value = questionData.value.score_details questionList.value = JSON.parse(JSON.stringify(questionData.value.score_details))
questionList.value.forEach((item: any) => { questionList.value.map((item: any) => {
if (item.children) { if (item.user_answer.indexOf(',') !== -1) {
item.user_answer = [item.user_answer].forEach(it => item.question_options[it.id]) item.user_answer = item.user_answer.split(',')
} else {
item.user_answer = item.question_options[item.id]
} }
return item
}) })
}) })
</script> </script>
<template> <template>
<div> <el-card class="container">
<paper-question <div class="content">
:everyQuestion="item" <template v-for="(item, index) in questionList" :key="index">
:key="item.question_item_id" <div class="sub-content" v-if="item?.children && item?.children.length > 0">
:questionList="questionList" <div class="title" v-html="item.common_content"></div>
v-for="item in questionList" <div class="sub-container">
<QuestionItem
v-for="(subItem, itemIndex) in item.children"
:key="subItem.id"
:question="subItem"
:currentIndex="index"
:childIndex="itemIndex"
:questionId="paper_id"
/> />
</div> </div>
</div>
<div v-else>
<QuestionItem :question="item" :currentIndex="index" :questionId="paper_id" />
</div>
</template>
</div>
</el-card>
</template> </template>
<style lang="scss" scoped>
.container {
background: #fff;
border: 1px solid #f3f3f3;
margin-bottom: 20px;
border-radius: 6px;
::v-deep .el-card__body {
padding: 10px 20px;
}
.content {
// border:1px solid #f3f3f3;
padding: 10px;
.title {
line-height: 40px;
font-size: 16px;
}
.sub-container {
border: 1px solid #e3e3e3;
padding: 15px 15px 0;
border-radius: 4px;
}
.sub-content {
margin-bottom: 20px;
}
.question-item:last-child {
border: none;
}
}
}
</style>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论