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

批改试卷接口对接

上级 39721f96
......@@ -25,14 +25,14 @@ export function getPaperStuDetail(params?: { id: string }) {
return httpRequest.get('/api/resource/v1/teaching/paper/view', { params })
}
// 评分
export function updateComment(params?: {
export function updateComment(data: {
id: string
index: string
child_index?: string
user_score: 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>
import { ElMessage } from 'element-plus'
import { updateComment } from '../api'
const showComment = ref(false)
const props = defineProps({
......@@ -8,30 +10,43 @@ const props = defineProps({
return {}
}
},
question_item_id: {
currentIndex: {
type: Number
},
childIndex: {
type: Number
},
// 试卷id
questionId: {
type: String
}
})
const questionData = Object.assign({}, props.question)
const reviews = ref('')
let questionData: any = $ref({})
questionData = Object.assign({}, props.question)
const questionType = computed(() => {
// 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)
} else {
return parseInt(props.question.questionType)
return parseInt(props.question.question_type)
}
})
const fetchComment = () => {
const params = {
id: '',
index: '',
child_index: '',
user_score: '',
reviews: ''
const params: any = {
id: props.questionId,
index: props.currentIndex,
child_index: props.childIndex,
user_score: questionData.user_score,
reviews: reviews.value
}
updateComment(params).then(() => {
console.log('000')
ElMessage.success('点评成功')
questionData.is_reviewed = true
})
}
</script>
......@@ -40,7 +55,7 @@ const fetchComment = () => {
<div class="question-item-title" v-html="props.question.question_content"></div>
<template v-if="questionType === 1 || questionType === 6">
<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>
</div>
</el-radio-group>
......@@ -60,7 +75,7 @@ const fetchComment = () => {
size="small"
plain
@click="showComment = !showComment"
v-permission="'admin_exam_exam_submit_sheet'"
v-if="props.question.is_reviewed !== true"
>点击评分</el-button
>
</div>
......@@ -69,11 +84,11 @@ const fetchComment = () => {
<p>本题{{ props.question.score }}</p>
<div class="get-score">
学生得分:<el-input-number
:disabled="questionData.checked_flag"
:disabled="questionData.is_reviewed"
v-model="questionData.user_score"
controls-position="right"
:min="0"
:max="props.question.score"
:max="questionData.score"
size="small"
></el-input-number>
</div>
......@@ -81,18 +96,18 @@ const fetchComment = () => {
<el-input
type="textarea"
placeholder="请输入评语"
v-model="questionData.reviews"
v-model="reviews"
rows="3"
:disabled="questionData.checked_flag"
:disabled="questionData.is_reviewed"
/>
<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
>
</div>
</div>
</template>
<div class="question-item-score">得分:{{ props.question.user_score }}分</div>
<div class="question-item-score">得分:{{ questionData.user_score }}分</div>
</div>
</template>
......
interface IQuestionptions {
interface IQuestionptions {
option: string
checked_option: string
checked: boolean
......@@ -24,5 +24,8 @@ export interface IQuestionList {
is_parent: number
child_question_type: number
score: number
user_answer: any
user_answer_status: boolean
user_score: number
children?: IQuestionList[]
}
\ No newline at end of file
}
......@@ -67,6 +67,7 @@ const listOptions = $computed(() => {
const handleCheckPaper = (row: any) => {
router.push({ path: '/teach/view', query: { id: row.id } })
}
onMounted(() => {
checkPermission('v1-teaching-paper-search-list') && handleGetClassList()
})
......
<script lang="ts" setup>
import type { IQuestionList } from '../type'
import { getPaperStuDetail } from '../api'
import PaperQuestion from '../components/PaperQuestion.vue'
import QuestionItem from '../components/QuestionItem.vue'
const route = useRoute()
const questionList: any = ref<IQuestionList[]>([])
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
questionList.value = questionData.value.score_details
questionList.value.forEach((item: any) => {
if (item.children) {
item.user_answer = [item.user_answer].forEach(it => item.question_options[it.id])
} else {
item.user_answer = item.question_options[item.id]
questionList.value = JSON.parse(JSON.stringify(questionData.value.score_details))
questionList.value.map((item: any) => {
if (item.user_answer.indexOf(',') !== -1) {
item.user_answer = item.user_answer.split(',')
}
return item
})
})
</script>
<template>
<div>
<paper-question
:everyQuestion="item"
:key="item.question_item_id"
:questionList="questionList"
v-for="item in questionList"
/>
</div>
<el-card class="container">
<div class="content">
<template v-for="(item, index) in questionList" :key="index">
<div class="sub-content" v-if="item?.children && item?.children.length > 0">
<div class="title" v-html="item.common_content"></div>
<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 v-else>
<QuestionItem :question="item" :currentIndex="index" :questionId="paper_id" />
</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>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论