基本完成学生作业查询界面(剩俩控件),创建新模型用于存储submitreport表数据。

This commit is contained in:
musteven 2025-03-18 20:57:29 +08:00
parent a4ca782ccc
commit 1f72287756
8 changed files with 136 additions and 18 deletions

View File

@ -127,16 +127,13 @@ const columns = [
title: '状态',
width: '116',
align: 'center',
render: (row, idx) => {
if (countdownControllers[row.id]) {
const { leftTime, minute, second } = countdownControllers[row.id]
if (leftTime.value <= 0) {
examList.value[idx].status = '考试进行中'
return '考试进行中'
}
return `还有${minute.value}分${second.value}秒`
}
return row.status
render: (row) => {
const statusText = row.status; // 假设分数存储在row.status
const isPlagiarized = row.plagiarismStatus === "2";//疑似抄袭
// 使用内联样式标红
const style = isPlagiarized ? { color: 'red' } : {};
// 如果使用内联样式
return h('span', { style }, statusText);
},
},

View File

@ -17,6 +17,7 @@ import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@RestController
@ -65,9 +66,13 @@ public class ProblemController {
//提取所有的classstudentslist中的classid并存放到新的classids表里面用作后续处理
classIds.add(classstudent.getClassId());
}
//根据班级id查询所有作业
List<PMProblem> pMproblems = problemServiceI.getProblemsByClassIds(classIds);
List<PMProblem> pMproblems = problemServiceI.getProblemsByClassIds(classIds);//根据班级id查询所有作业
//分页处理,左为已有的作业列表,右为从前端获取的作业类,包含分页信息
// 根据学生ID和作业列表查询提交报告的状态,分为提交状态和查重状态,并更新到pmproblem中
problemServiceI.findStatusByStudentIdAndProblems(Integer.parseInt(userId), pMproblems);
//分页处理
DataGrid dataGrid = problemServiceI.dataGrid(pMproblems,pMproblem);
if (dataGrid != null) {

View File

@ -4,6 +4,7 @@ package com.example.aes.problem.dao;
import com.example.aes.problem.model.PMProblem;
import com.example.aes.problem.model.PMScoringRubric;
import com.example.aes.problem.model.Problem;
import com.example.aes.problem.model.ReportSubmitted;
import com.example.aes.user.dao.BaseDaoI;
import com.example.aes.user.model.Classstudents;
@ -15,6 +16,7 @@ public interface ProblemDaoI extends BaseDaoI<Problem> {
List<PMProblem> findProblemsByClassIds(List<Integer> classIds);
List<ReportSubmitted> findPMProblemStatusesByStudentIdAndProblemsIds(List<Integer> problemIds, Integer studentId);
}

View File

@ -4,16 +4,22 @@ import com.example.aes.problem.dao.ProblemDaoI;
import com.example.aes.problem.model.PMProblem;
import com.example.aes.problem.model.PMScoringRubric;
import com.example.aes.problem.model.Problem;
import com.example.aes.problem.model.ReportSubmitted;
import com.example.aes.user.dao.BaseDaoI;
import com.example.aes.user.dao.impl.BaseDaoImpl;
import com.example.aes.user.model.Classstudents;
import com.ibm.jvm.trace.format.api.TraceContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Repository("ProblemDao")
public class ProblemDaoImpl extends BaseDaoImpl<Problem> implements ProblemDaoI{
@ -50,6 +56,44 @@ public class ProblemDaoImpl extends BaseDaoImpl<Problem> implements ProblemDaoI{
return problems;
}
@Override
// 根据学生ID和作业ID列表查询提交报告状态
public List<ReportSubmitted> findPMProblemStatusesByStudentIdAndProblemsIds(List<Integer> problemIds, Integer studentId) {
if (problemIds == null || problemIds.isEmpty() || studentId == null) {
return Collections.emptyList(); // 返回空列表而不是null
}
// 构建SQL查询语句,使用问号(?)作为参数占位符
String sql = "SELECT * FROM submitreport WHERE studentId = ? AND problemId IN (";
StringBuilder inClause = new StringBuilder();
for (int i = 0; i < problemIds.size(); i++) {
inClause.append("?");
if (i < problemIds.size() - 1) {
inClause.append(","); // 在参数之间添加逗号,除了最后一个
}
}
inClause.append(")"); // 完成IN子句
sql += inClause.toString();
// 创建参数数组,包含学生ID和问题ID列表
Object[] params = new Object[problemIds.size() + 1];
params[0] = studentId; // 学生ID是第一个参数
for (int i = 0; i < problemIds.size(); i++) {
params[i + 1] = problemIds.get(i); // 问题ID列表是后续参数
}
// 执行查询并存储结果
List<ReportSubmitted> queryResults = jdbcTemplate.query(
sql,
params,
new BeanPropertyRowMapper<>(ReportSubmitted.class) // 使用ReportSubmitted类来映射结果
);
// 返回查询结果
return queryResults;
}
public void addScoringRubric(PMScoringRubric pmScoringRubric){
};

View File

@ -26,9 +26,9 @@ public class PMProblem extends Problem implements java.io.Serializable{//继承P
// (作业列表)页面上其他需要的属性
private Date startTime;//开始时间,来自postproblem
private Date endTime;//结束时间
private String submissonStatus;//提交状态,来自submitproblem
private String submissionStatus;//提交状态,来自submitproblem
private String plagiarismStatus;//查重状态
private float score;//最终分数
private Float score;//最终分数
private String status;//最后在页面显示的状态,取决于上面三个参数。
//(作业列表)页面需要的后台数据
@ -36,4 +36,5 @@ public class PMProblem extends Problem implements java.io.Serializable{//继承P
private int classId;//班级id
}

View File

@ -0,0 +1,27 @@
package com.example.aes.problem.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Table;
import java.util.Date;
@Data //存放submitreport表的属性
public class ReportSubmitted implements java.io.Serializable{
int Id;
int problemId;
int studentId;
int adminuserId;
Date readTime;
Date submissionTime;
Date addTime;
String submissionStatus;
String plagiarismStatus;
String attachment;
Float autoscore;
Float score;
String autocomment;
String comment;
}

View File

@ -2,10 +2,7 @@ package com.example.aes.problem.service.Impl;
import com.example.aes.problem.dao.ProblemDaoI;
import com.example.aes.problem.dao.ScoringRubricDaoI;
import com.example.aes.problem.model.PMProblem;
import com.example.aes.problem.model.PMScoringRubric;
import com.example.aes.problem.model.ScoringRubric;
import com.example.aes.problem.model.UScoringRubric;
import com.example.aes.problem.model.*;
import com.example.aes.problem.service.ProblemServiceI;
import com.example.aes.user.model.Classstudents;
import com.example.aes.user.model.Course;
@ -18,6 +15,9 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class ProblemServiceImpl implements ProblemServiceI {
@ -104,6 +104,46 @@ public class ProblemServiceImpl implements ProblemServiceI {
}
}
@Override
public void findStatusByStudentIdAndProblems(Integer studentId, List<PMProblem> pMproblems) {
// 提取问题ID列表
List<Integer> problemIds = pMproblems.stream()
.map(PMProblem::getId)
.collect(Collectors.toList());
// 调用DAO层方法获取状态信息
List<ReportSubmitted> reportStatuses = problemDao.findPMProblemStatusesByStudentIdAndProblemsIds(problemIds, studentId);
// 使用Map来根据problemId快速查找对应的ReportSubmitted对象
Map<Integer, ReportSubmitted> reportStatusMap = reportStatuses.stream()
.collect(Collectors.toMap(ReportSubmitted::getProblemId, report -> report));
// 更新PMProblem列表中的状态
for (PMProblem pmProblem : pMproblems) {
// 从Map中获取对应的ReportSubmitted对象
ReportSubmitted reportStatus = reportStatusMap.get(pmProblem.getId());
// 确保reportStatus不为null并且studentId匹配
if (reportStatus != null && studentId.equals(reportStatus.getStudentId())) {
pmProblem.setSubmissionStatus(reportStatus.getSubmissionStatus());
pmProblem.setPlagiarismStatus(reportStatus.getPlagiarismStatus());
pmProblem.setScore(reportStatus.getScore());
// 根据submissionStatus设置status
if ("0".equals(reportStatus.getSubmissionStatus())) {
pmProblem.setStatus("未提交");
} else if ("1".equals(reportStatus.getSubmissionStatus())) {
pmProblem.setStatus("已提交");
}
// 如果score不为空,则将status设置为score的具体值
if (reportStatus.getScore() != null) {
pmProblem.setStatus(String.format("%.2f", reportStatus.getScore()));
}
}
}
}
;
private void changeModel1(List<ScoringRubric> l,
List<PMScoringRubric> nl) {

View File

@ -15,4 +15,6 @@ public interface ProblemServiceI {
public List<UScoringRubric> findScoringRubricNoStandardId();
DataGrid dataGrid(List<PMProblem> pMproblems, PMProblem pMproblem);
public void findStatusByStudentIdAndProblems(Integer studentId, List<PMProblem> pMproblems);
}