Selaa lähdekoodia

扫描学生的图片答案回显

dengshaobo 1 kuukausi sitten
vanhempi
commit
0e2a7a2100

+ 6 - 1
src/components/ActionImage.vue

@@ -491,11 +491,16 @@ const DrawImage = () => {
               context.fillStyle = 'rgba(255,0,0,0.3)'
               context.strokeStyle = props.currentId == item.id ? 'blue' : 'red'
             }
-            
+            console.log("打印画框的地方answerItem"+'当前的题目'+topicItem.topicName+"当前答案:"+answerItem.title+'当前check:'+ answerItem.isCheck)
             if (answerItem?.isCheck) {
+              context.fillStyle = 'rgba(255,0,0,0.4)'; // 红色背景
+              context.strokeStyle = 'red';//红色边框
+              
               context.fillRect(obj.x, obj.y, obj.width, obj.height)
               context.strokeRect(obj.x, obj.y, obj.width, obj.height)
             } else {
+              context.fillStyle = 'rgba(0,0,255,0.3)'
+              context.strokeStyle = 'blue'
               context.strokeRect(obj.x, obj.y, obj.width, obj.height)
             }
           }

+ 1 - 1
src/views/exam/abnormal/abnormal.vue

@@ -633,7 +633,7 @@ const ObjectDataChange = () => {
                 w: position.w,
                 h: position.h,
                 position: item.position,
-                blockArea: item.blockArea,
+                blockArea: 8,
                 page: 1,//选择题就一页 默认1
                 blockName: item.name,
                 id: item.groupId,

+ 49 - 77
src/views/exam/components/PaperPreview.vue

@@ -291,17 +291,24 @@ const RotateClockwise90 = () => {
 
 // 加载绘图数据
 const LoadDrawData = () => {
+
+  console.log("加载模板绘图数据");
   try {
+
+    
     const templateDataStr = localStorage.getItem('templateData')
-    const usedCardTypeStr = localStorage.getItem('usedCardType')
+    
+    // const usedCardTypeStr = localStorage.getItem('usedCardType')
     
     if (!templateDataStr) return
     
-    const templateData = JSON.parse(templateDataStr)
-    const usedCardType = usedCardTypeStr ? parseInt(usedCardTypeStr) : null
+    const templateData = JSON.parse(templateDataStr);
+
+    const usedCardType = 2;//默认三方卡
     
     console.log('打印templateData模板信息', templateData)
-    
+    console.log('打印currentPageNo', currentPageNo)
+    console.log('打印answerData', props.answerData)
     const currentTemplateItem = templateData.find(
       (item) => item.pageNum == currentPageNo.value
     )
@@ -323,17 +330,19 @@ const LoadDrawData = () => {
       console.error('解析 paperInfo 失败', e)
     }
 
-    if (usedCardType == 1) {
-      currentPageInfo.value = {
-        width: paperInfo.width - 30,
-        height: paperInfo.height - 25,
-      }
-    }
+    //选择题判分暂时没有系统卡 注释掉
+    // if (usedCardType == 1) {
+    //   currentPageInfo.value = {
+    //     width: paperInfo.width - 30,
+    //     height: paperInfo.height - 25,
+    //   }
+    // }
 
     if (currentTemplateItem.examCardGroupVOS) {
-      const list = currentTemplateItem.examCardGroupVOS.filter(
-        (item) => item.blockArea == 8
-      )
+      // const list = currentTemplateItem.examCardGroupVOS.filter(
+      //   (item) => item.blockArea == 8
+      // )
+      const list = currentTemplateItem.examCardGroupVOS;//无需过滤 都是客观题的数据
       
       list.forEach((item) => {
         if (item.position) {
@@ -350,77 +359,42 @@ const LoadDrawData = () => {
           
           if (item.groupTopicList) {
             item.groupTopicList.forEach((topic) => {
-              const answerValue = props.answerData[topic.topicName]
-              
+              const answerValue = props.answerData[topic.topicName];//答案
+              console.log('answerValue',answerValue)
+              // 关键修改:使用深拷贝确保是纯JavaScript对象
+              let answerList = JSON.parse(JSON.stringify(JSON.parse(topic.optionJsons)));
+             
+              // 为每个答案项显式添加 isCheck 属性
+              answerList.forEach(answer => {
+                answer.isCheck = false;
+              });
+              console.log("打印answerList",answerList);
               if (answerValue) {
                 const answerLetters = answerValue.match(/[A-Za-z]/g) || []
-                
+                console.log('answerLetters',answerLetters)
                 answerLetters.forEach((letter) => {
                   let answerIndex = GetAnswerIndexToLetter(letter)
-
-                  if (topic.topicType == 3) {
-                    answerIndex = GetAnswerIndexToLetterTF(letter)
+                
+                  if (answerIndex !== -1 && answerList[answerIndex]) {
+                    answerList[answerIndex].isCheck = true;
+                   
+                  } else {
+                    console.log("❌ 设置失败! answerIndex:", answerIndex, "answerList长度:", answerList.length);
                   }
+                
+                 
                   
-                  if (answerIndex !== -1 && topic.answerList[answerIndex]) {
-                    topic.answerList[answerIndex].isCheck = true
-                  }
                 })
               }
+              let topiclistObj={
+                answerList:answerList,
+                index:topic.index,
+                topicName:topic.topicName,
+                topicType:1,//1单选 2多选 3判断
+              };
+              topiclist.push(topiclistObj);
             })
-            topiclist = item.groupTopicList
-          }
-
-          const obj = {
-            x: position.x,
-            y: position.y,
-            w: position.w,
-            h: position.h,
-            position: item.position,
-            blockArea: item.blockArea,
-            page: currentPageNo.value,
-            blockName: item.name,
-            id: item.groupId,
-            unit: unit,
-            usedCardType: usedCardType,
-            areaOption: item.groupConfig,
-            topiclist: topiclist,
-          }
-          drawList.push(obj)
-        }
-      })
-
-      const list2 = currentTemplateItem.examCardGroupVOS.filter(
-        (item) => item.blockArea == 9
-      )
-      
-      list2.forEach((item) => {
-        if (item.position) {
-          let position = {}
-          try {
-            position = JSON.parse(item.position)
-          } catch (e) {
-            console.error('解析 position 失败', e)
-            return
-          }
-          
-          const unit = 'px'
-          let topiclist = []
-          
-          if (item.groupTopicList) {
-            item.groupTopicList.forEach((topic) => {
-              const answerValue = props.answerData[topic.topicName]
-              
-              if (answerValue !== undefined && answerValue !== null) {
-                if (!isNaN(answerValue) && answerValue !== '') {
-                  const answerIndex = answerValue - 1
-                  if (answerIndex >= 0 && topic.answerList[answerIndex]) {
-                    topic.answerList[answerIndex].isCheck = true
-                  }
-                }
-              }
-            })
-            topiclist = item.groupTopicList
+            
           }
 
           const obj = {
@@ -441,8 +415,6 @@ const LoadDrawData = () => {
           drawList.push(obj)
         }
       })
-      
-      console.log('打印选做题drawList', drawList)
     }
     
     currentDrawData.value = drawList

+ 0 - 1
src/views/exam/components/addStudent.vue

@@ -279,7 +279,6 @@ const EditorStudent = (studentData: any) => {
     registrationTypeName: studentData.registrationTypeName || '',
   })
   
-  GetClassListData()
   showDialog.value = true
 }
 

+ 31 - 60
src/views/exam/examList.vue

@@ -114,14 +114,14 @@
     <div class="page_jg_20"></div>
     <div class="page_bottom">
         <div class="bottom_left">
-            <span>班级数:15个</span>
-            <span>学生总数:15个</span>
-            <span>缺考人数:15个</span>
-            <span>已扫描学生:<span class="span_red">15个</span></span>
-            <span>扫描进度:<span class="span_red">15个</span></span>
+            <span>班级数:{{examInfo.classCount}}个</span>
+            <span>学生总数:{{examInfo.totalStudentCount}}个</span>
+            <span>缺考人数:{{examInfo.missCount}}个</span>
+            <span>已扫描学生:<span class="span_red">{{examInfo.uploadedCount}}个</span></span>
+            <span>扫描进度:<span class="span_red">{{examInfo.scanRate}}%</span></span>
         </div>
         <div class="bottom_right">
-            当前选中班级:{{selectExamRoomName}}  学生数: {{examStudentList.length }}人
+            当前选中班级:{{selectExamRoomName}}  学生数:{{examStudentList.length }}人
         </div>
     </div>
     <AddStudent ref="addStudentRef"  v-model="showAddStudent" :selectSchoolId="selectSchoolId" @success="HandleSuccess" />
@@ -176,7 +176,7 @@ const schoolId = computed(() => {
 const Refresh = () => {
     examRoomList.value=[];
     examStudentList.value=[];
-  GetExamRoomList();
+  GetExamRoomList();//获取考场列表
 }
 // 返回到扫描界面
 const BackToScan = () => {
@@ -216,6 +216,17 @@ const GoSearch=()=>{
     GetExamRoomStudentList();
 }
 
+//重新导入名单
+const BackToTemplate =() =>
+{
+
+}
+
+//导出学生名单
+const ExportExamStudentList=()=>
+{
+
+}
 
 //新增学生
 const OpenAddStudent=()=>{
@@ -224,60 +235,10 @@ const OpenAddStudent=()=>{
 
 //编辑学生
 const EditorStudent=async (row:any)=>{
-    console.log('编辑',row);
-
-     // 获取班级列表数据
-    await GetClassListData();
-    
-    // 准备编辑数据
-    let teachingClassSort = null;
-    let adminClassSort = null;
-    
-    console.log("打印学生信息", row);
-    console.log("打印教学班列表", teachingClassList.value);
-    console.log("打印行政班列表", adminClassList.value);
-
-    const teachingclassItem = teachingClassList.value.find(
-        (classItem: any) => classItem.classIdCode == row.teachingClassIdCode
-    );
-    const adminClassItem = adminClassList.value.find(
-        (classItem: any) => classItem.classIdCode == row.adminClassIdCode
-    );
-    
-    console.log("打印教学班匹配项", teachingclassItem);
-    if (teachingclassItem) {
-        teachingClassSort = teachingclassItem.sort;
-    }
-    
-    console.log("打印行政班匹配项", adminClassItem);
-    if (adminClassItem) {
-        adminClassSort = adminClassItem.classCode;
-    }
-
-    // 设置当前编辑的数据
-    currentEditItem.value = {
-        id: row.id, //主键id
-        schoolId: row.schoolId, //学校id
-        studentName: row.studentName, //姓名
-        studentRegistrationCode: row.studentRegistrationCode, //账号
-        studentCode: row.studentCode, //学号
-        examCode: row.examCode, //考号
-        examRoomCode: row.examRoomCode, //考场编号
-        adminClassIdCode: row.adminClassIdCode, //行政班code
-        adminClassName: row.adminClassName, //行政班名称
-        adminClassSort: adminClassSort, //行政班排序
-        teachingClassIdCode: row.teachingClassIdCode, //教学班code
-        teachingClassName: row.teachingClassName, //教学班名称
-        teachingClassSort: teachingClassSort, //教学班排序
-        registrationTypeCode: row.registrationTypeCode,
-        registrationTypeName: row.registrationTypeName
-    };
-    
-    console.log("打印编辑学生信息", currentEditItem.value);
+    console.log("打印编辑学生信息", row);
     if (addStudentRef.value) {
-        addStudentRef.value.EditorStudent(currentEditItem.value);
+        addStudentRef.value.EditorStudent(row);
     }
-    
     // 打开弹窗并传递编辑数据
     showAddStudent.value = true;
 }
@@ -311,7 +272,8 @@ const ConfirmDelete=(row:any)=>{
     ElMessageBox.confirm('确认删除该学生吗?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
-        type: 'warning'
+        type: 'warning',
+        customClass:'page_dialog'
     }).then(async () => {
         console.log('删除学生')
         const param={
@@ -341,6 +303,15 @@ const GetExamRoomList = async () => {
         if (res.code === 200) {
             examRoomList.value = res.data.examRoomTblVOS;
             selectExamRoomCode.value = examRoomList.value[0]?.examRoomCode;
+
+            examInfo.value={
+                classCount:res.data.examRoomNum,//班级数
+                totalStudentCount:res.data.totalStudentNum,//学生总数
+                missCount:res.data.totalMissExamNum,//缺考人数
+                uploadedCount:res.data.totalUploadedNum,//已上传学生数
+                abnormalCount:0,//异常数
+                scanRate:res.data.totalUploadRate,//扫描进度
+            };
             GetExamRoomStudentList();
         }
         console.log('考场列表', res);

+ 33 - 1
src/views/exam/scanDetail.vue

@@ -136,7 +136,7 @@ import { useRouter,useRoute  } from 'vue-router'
 import { onMounted ,ref,computed,nextTick,onUnmounted} from 'vue';
 import { ElMessageBox, ElMessage } from 'element-plus'
 
-import { getBatchDetailList,getBatchDetailImage } from '@/api/exam'
+import { getBatchDetailList,getBatchDetailImage,getTemplateDetail} from '@/api/exam'
 import PaperPreview from './components/PaperPreview.vue'
 
 // 定义选项接口类型
@@ -175,6 +175,8 @@ const tableData=ref<any[]>([]);//列表数据
 const imageData=ref<any[]>([]);//图片数据
 const loading=ref(false); //加载状态
 
+const currentTemplateList=ref<any[]>([]);//当前模板数据
+
 
 const tableHeight=ref(500);
 const imageHeight=ref(500);
@@ -275,6 +277,35 @@ const LoadData = () => {
     
 }
 
+//获取模板详情
+const GetTemplateDetail = async () => { 
+    const params={
+        examSubjectId: examSubjectId.value,//考试id
+    };
+    const res = await getTemplateDetail(params);
+    console.log("打印模板数据",res);
+    if(res.code == 200)
+    {
+       currentTemplateList.value=[];
+       res.data.forEach((item:any)=>{ 
+        let obj={
+            examCardGroupVOS: item.examCardGroupVOS,
+            pageNo: item.pageNo,
+            paperInfo: item.paperInfo,
+            templateUrl: item.templateUrl,
+            pageNum: item.pageNo,
+
+        };
+        currentTemplateList.value.push(obj);
+        localStorage.setItem("templateData",JSON.stringify(currentTemplateList.value));//保存模板数据到本地
+       })
+    }
+    else
+    {
+        console.log("获取模板列表失败");
+    }
+}
+
 
 
 
@@ -417,6 +448,7 @@ onMounted(() => {
     
     LoadData();//加载数据
     CalculateTableHeight();//初始化计算表格高度
+    GetTemplateDetail();//获取模板数据
     // 监听窗口大小变化
     window.addEventListener('resize', CalculateTableHeight);
 })

+ 2 - 2
src/views/exam/scanList.vue

@@ -34,8 +34,8 @@
             
             <!-- <el-button class="delete_item" type="text" @click="OpenDeleteAllDialog"  v-if="tableData.length>0">删除所有</el-button> -->
             <el-button @click="OpenReIdentify" >重新识别</el-button>
-            <el-button @click="OpenEditExamList()" type="primary" v-if="isImportStudent">编辑考场名单</el-button>
-            <el-button @click="OpenImportStudent()" type="primary" v-else>导入考场名单</el-button>
+            <el-button @click="OpenEditExamList()" type="primary">编辑考场名单</el-button>
+            <!-- <el-button @click="OpenImportStudent()" type="primary" v-else>导入考场名单</el-button> -->
         </div>
     </div>
     <div class="page_jg_20"></div>