完成作业提交界面剩余所有内容,三个控件等,修复了当成绩为空时查询作业列表方法空指针问题。
剩余接入算法和一些细节调整。
This commit is contained in:
parent
1c7695c067
commit
a30ecee6a5
|
|
@ -51,4 +51,13 @@ export default {
|
|||
url: `/downloadFile/downloadFile/${fileName}`,
|
||||
method: 'get',
|
||||
}), // 文件下载
|
||||
|
||||
//保存文件名到数据库
|
||||
saveInfoToProps: (data) => request.post('/problem/saveInfoToProps', data),
|
||||
|
||||
submitInfoToProps: (data) => request.post('/problem/submitInfoToProps', data),
|
||||
|
||||
withdrawInfoToProps: (data) => request.post('/problem/withdrawInfoToProps', data),
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,18 @@
|
|||
<div slot="header" class="clearfix card-header">
|
||||
<span class="subtitle">实验提交</span>
|
||||
</div>
|
||||
<div v-if="attachment" class="file-list">
|
||||
<span class="file-list-title">已保存的文件:</span>
|
||||
<ul>
|
||||
<li>
|
||||
{{ attachment }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<br>
|
||||
<el-button size="small" type="success" @click="showUploadDialog">上传附件</el-button>
|
||||
<div v-if="fileUrls.length > 0" class="file-list">
|
||||
<span class="file-list-title">已上传文件:</span>
|
||||
<span class="file-list-title">已上传文件(保存过的文件将被覆盖保存):</span>
|
||||
<ul>
|
||||
<li v-for="(file, index) in fileUrls" :key="index">
|
||||
{{ file.name }}
|
||||
|
|
@ -35,6 +43,8 @@
|
|||
v-model:file-list="fileList"
|
||||
drag
|
||||
accept=".txt,.doc,.docx,.pdf"
|
||||
:limit="1"
|
||||
:on-exceed="handleExceed"
|
||||
>
|
||||
<i class="el-icon-upload"></i>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
|
|
@ -44,7 +54,15 @@
|
|||
<el-button type="primary" @click="uploadFile">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<ReportActions class="bottom" />
|
||||
<ReportActions
|
||||
:fileUrls="fileUrls"
|
||||
:ProblemId="ProblemId"
|
||||
:adminuserId="adminuserId"
|
||||
:attachment="attachment"
|
||||
:disabled="isReportActionsDisabled"
|
||||
@refreshAttachment="refreshAttachmentInfo"
|
||||
class="bottom"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
|
@ -59,11 +77,15 @@ import ReportActions from "@/views/user/report-submit/components/report-actions.
|
|||
|
||||
const route = useRoute();
|
||||
const ProblemId = route.params.examId;
|
||||
const examId = route.params.examId;
|
||||
const description = ref(""); // 实验描述
|
||||
const adminuserId = ref(""); //布置实验的教师id
|
||||
const reportText = ref(""); // 实验报告文本
|
||||
const uploadDialogVisible = ref(false); // 控制上传弹窗的显示
|
||||
const fileList = ref([]); // 上传的文件列表
|
||||
const fileUrls = ref([]); // 文件的URL列表
|
||||
const attachment = ref(null);//已保存的文件信息
|
||||
const isReportActionsDisabled = ref(false); // 控制ReportActions组件的禁用状态
|
||||
const uploadComponent = ref(null); // 用于引用el-upload组件
|
||||
|
||||
const getProblemInfo = async () => {
|
||||
|
|
@ -71,6 +93,7 @@ const getProblemInfo = async () => {
|
|||
try {
|
||||
const res = await api.findProblemById1({ params: { ProblemId } });
|
||||
description.value = res.data.description; // 更新作业名称
|
||||
adminuserId.value = res.data.adminuserId.toString(); // 更新教师id
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch problem info:", error);
|
||||
}
|
||||
|
|
@ -78,6 +101,10 @@ const getProblemInfo = async () => {
|
|||
|
||||
// 显示上传弹窗
|
||||
const showUploadDialog = () => {
|
||||
if (fileUrls.value.length > 0) {
|
||||
ElMessage.warning('您已经上传了文件,不能再次上传。');
|
||||
return;
|
||||
}
|
||||
uploadDialogVisible.value = true;
|
||||
};
|
||||
|
||||
|
|
@ -89,11 +116,11 @@ const handleFileChange = (file, fileList) => {
|
|||
// 处理文件上传成功
|
||||
const handleUploadSuccess = (response, file, fileList) => {
|
||||
if (response.success) {
|
||||
ElMessage.success('文件上传成功');
|
||||
// 更新文件URL列表
|
||||
fileUrls.value.push({ url: response.urls, name: response.data });
|
||||
uploadDialogVisible.value = false;
|
||||
fileList.value = [];
|
||||
ElMessage.success('文件上传成功');
|
||||
} else {
|
||||
ElMessage.error('文件上传失败');
|
||||
}
|
||||
|
|
@ -105,6 +132,11 @@ const handleUploadError = (err, file, fileList) => {
|
|||
ElMessage.error('文件上传失败');
|
||||
};
|
||||
|
||||
// 处理文件数量超出限制
|
||||
const handleExceed = (files, fileList) => {
|
||||
ElMessage.error('只能上传一个附件');
|
||||
};
|
||||
|
||||
// 上传文件
|
||||
const uploadFile = async () => {
|
||||
if (fileList.value.length === 0) {
|
||||
|
|
@ -119,38 +151,53 @@ const uploadFile = async () => {
|
|||
try {
|
||||
const response = await api.uploadFiles(formData); // 调用上传文件的方法
|
||||
console.log('Response from server:', response); // 打印响应内容
|
||||
if (response.code === 0) {
|
||||
ElMessage.success('文件上传成功');
|
||||
// 更新文件URL列表
|
||||
fileUrls.value.push({ url: response.urls, name: response.data });
|
||||
uploadDialogVisible.value = false;
|
||||
fileList.value = [];
|
||||
} else {
|
||||
ElMessage.error('文件上传失败1');
|
||||
}
|
||||
|
||||
}catch (error) {
|
||||
console.error("Failed to upload files:", error);
|
||||
ElMessage.error('文件上传失败2');
|
||||
}
|
||||
};
|
||||
|
||||
// 下载文件
|
||||
const downloadFile = (url) => {
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.target = '_blank';
|
||||
link.download = url.split('/').pop(); // 提取文件名
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
|
||||
const getSubmitReportInfo = async () => {
|
||||
// 查询已保存的文件信息
|
||||
try {
|
||||
const res = await api.getSubmitReport({ params: { examId } });
|
||||
if (res.data.attachment) {
|
||||
attachment.value = res.data.attachment; // 更新附件信息
|
||||
} else {
|
||||
attachment.value = null;
|
||||
}
|
||||
if (res.data.score !== null && res.data.score !== undefined) {
|
||||
isReportActionsDisabled.value = true; // 禁用ReportActions组件
|
||||
} else {
|
||||
isReportActionsDisabled.value = false; // 启用ReportActions组件
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const refreshAttachmentInfo = async () => {
|
||||
//更新已上传的文件信息
|
||||
await getSubmitReportInfo();
|
||||
};
|
||||
|
||||
// 生命周期钩子
|
||||
onMounted(() => {
|
||||
getProblemInfo(); // 挂载时查询作业信息
|
||||
getSubmitReportInfo();//查询已保存的文件信息
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<style scoped>
|
||||
.card-header {
|
||||
background-color: #f5f5f5; /* 加深灰色背景 */
|
||||
|
|
@ -187,7 +234,7 @@ onMounted(() => {
|
|||
}
|
||||
|
||||
.file-list {
|
||||
margin-top: 20px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.file-list-title {
|
||||
|
|
|
|||
|
|
@ -1,31 +1,130 @@
|
|||
<template>
|
||||
<div class="button-container">
|
||||
<n-button type="primary" size="small" @click="onSave">保存</n-button>
|
||||
<n-button type="success" size="small" @click="onSaveAndSubmit">保存并提交</n-button>
|
||||
<n-button type="warning" size="small" @click="onWithdraw">申请撤回</n-button>
|
||||
<n-button type="primary" size="small" @click="onSave" :disabled="props.disabled">保存</n-button>
|
||||
<n-button type="success" size="small" @click="onSaveAndSubmit" :disabled="props.disabled">保存并提交</n-button>
|
||||
<n-button type="warning" size="small" @click="onWithdraw" :disabled="props.disabled">撤回提交</n-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import api from '@/api/user';
|
||||
import {ElMessage, ElMessageBox} from "element-plus";
|
||||
|
||||
const route = useRoute();
|
||||
const isClicked = ref(false);
|
||||
const ProblemId = route.params.examId;
|
||||
|
||||
const emit = defineEmits(['clickSave', 'clickSaveAndSubmit', 'clickWithdraw']);
|
||||
const props = defineProps({
|
||||
fileUrls: Array,
|
||||
adminuserId: [String],
|
||||
attachment: [String],
|
||||
disabled:Boolean
|
||||
});
|
||||
|
||||
const onSave = () => {
|
||||
// TODO: 实现保存逻辑
|
||||
const emit = defineEmits(['clickSave', 'clickSaveAndSubmit', 'clickWithdraw', 'refreshAttachment']);
|
||||
|
||||
const onSave = async () => { //保存
|
||||
// 检查是否有文件信息且数组不为空
|
||||
if (props.fileUrls && props.fileUrls.length > 0) {
|
||||
|
||||
|
||||
// 调用 API 保存提交信息到数据库,包括文件名、题目id,学生id,老师id,
|
||||
try {
|
||||
const attachment = props.fileUrls[0].name;
|
||||
const adminuserId =props.adminuserId;
|
||||
const problemId = ProblemId;
|
||||
const submitReport = {
|
||||
attachment,
|
||||
problemId,
|
||||
adminuserId,
|
||||
};
|
||||
const res = await api.saveInfoToProps(submitReport);
|
||||
// 处理成功逻辑
|
||||
emit('clickSave');
|
||||
emit('refreshAttachment');
|
||||
ElMessage.success('保存成功!');
|
||||
} catch (error) {
|
||||
// 处理错误逻辑
|
||||
console.error("Failed to save Files:", error);
|
||||
ElMessage.error('保存文件时发生错误!');
|
||||
}
|
||||
} else {
|
||||
// 如果没有文件信息,在这里处理
|
||||
ElMessage.error('尚未上传新的文件!');
|
||||
}
|
||||
};
|
||||
|
||||
const onSaveAndSubmit = () => {
|
||||
// TODO: 实现保存并提交逻辑
|
||||
const onSaveAndSubmit = async () => {//保存并提交
|
||||
let shouldSubmit = false;
|
||||
|
||||
// 检查是否有新上传的文件
|
||||
const hasNewFiles = props.fileUrls && props.fileUrls.length > 0;
|
||||
|
||||
if (props.attachment && !hasNewFiles) {
|
||||
// 如果attachment不为空且没有新文件,准备提交
|
||||
shouldSubmit = true;
|
||||
} else if (hasNewFiles) {
|
||||
// 如果有新上传的文件,无论attachment是否为空,都先保存新文件
|
||||
await onSave(); // 先调用保存逻辑
|
||||
shouldSubmit = true;
|
||||
} else {
|
||||
ElMessage.error('尚未上传文件!');
|
||||
return;
|
||||
}
|
||||
|
||||
if (shouldSubmit) {
|
||||
// 弹出确认提交的对话框
|
||||
ElMessageBox.confirm('确定要提交吗?提交时将以当下已保存的文件为准。', '确认提交', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
try {//提交逻辑
|
||||
const adminuserId =props.adminuserId;
|
||||
const problemId = ProblemId;
|
||||
const submitReport1 = {
|
||||
problemId,
|
||||
adminuserId
|
||||
};
|
||||
const res = await api.submitInfoToProps(submitReport1);
|
||||
emit('clickSaveAndSubmit');
|
||||
emit('refreshAttachment');
|
||||
ElMessage.success('提交成功!');
|
||||
} catch (error) {
|
||||
console.error("Failed to submit:", error);
|
||||
ElMessage.error('提交时发生错误!');
|
||||
}
|
||||
}).catch(() => {
|
||||
// 用户取消提交
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const onWithdraw = () => {
|
||||
// TODO: 实现申请撤回逻辑
|
||||
const onWithdraw = () => { //撤回提交
|
||||
ElMessageBox.confirm('确定撤回已提交的报告吗?', '确认撤回', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
try {//撤回逻辑
|
||||
const adminuserId =props.adminuserId;
|
||||
const problemId = ProblemId;
|
||||
const submitReport2 = {
|
||||
problemId,
|
||||
adminuserId
|
||||
};
|
||||
const res = await api.withdrawInfoToProps(submitReport2);
|
||||
emit('clickWithdraw');
|
||||
ElMessage.success('撤回成功!');
|
||||
} catch (error) {
|
||||
console.error("Failed to Withdraw:", error);
|
||||
ElMessage.error('撤回时发生错误!');
|
||||
}
|
||||
}).catch(() => {
|
||||
// 用户取消撤回
|
||||
});
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
import { ref, onMounted } from 'vue';
|
||||
import api from '@/api/user';
|
||||
import { useRoute } from 'vue-router';
|
||||
import {ElMessage} from "element-plus";
|
||||
|
||||
const route = useRoute();
|
||||
const examId = route.params.examId;
|
||||
|
|
@ -28,8 +29,13 @@ const getJudgeInfo = async () => {
|
|||
// 查询批阅相关信息
|
||||
try {
|
||||
const res = await api.getSubmitReport({ params: { examId } });
|
||||
if(res.data==null){
|
||||
ElMessage.warning("尚未提交作业!")
|
||||
}
|
||||
else {
|
||||
comment.value = res.data.comment; // 更新教师评语
|
||||
plagiarismStatus.value = res.data.plagiarismStatus; // 更新抄袭状态
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch problem info:", error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,16 @@ import com.example.aes.problem.model.*;
|
|||
import com.example.aes.problem.model.DataGrid;
|
||||
import com.example.aes.problem.service.ProblemServiceI;
|
||||
import com.example.aes.user.model.Classstudents;
|
||||
import com.example.aes.user.model.PMUser;
|
||||
import com.example.aes.user.service.ClassesServiceI;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -295,7 +300,7 @@ public class ProblemController {
|
|||
//根据班级id查询所有作业
|
||||
List<PMProblem> pMproblems = problemServiceI.getProblemsByClassIds(classIds);
|
||||
|
||||
// 根据学生ID和作业列表查询提交报告的状态,分为提交状态和查重状态,并更新到pmproblem中
|
||||
// 根据学生ID和作业列表查询提交报告的状态,分为提交状态和查重状态,并更新到pMproblems中
|
||||
problemServiceI.findStatusByStudentIdAndProblems(Integer.parseInt(userId), pMproblems);
|
||||
|
||||
//分页处理
|
||||
|
|
@ -372,7 +377,7 @@ public class ProblemController {
|
|||
UReportSubmitted ureportsubmitted =
|
||||
problemServiceI.findScoreAndRankByIds(examId, userId);
|
||||
if (ureportsubmitted != null) {
|
||||
return RespBean.ok("查询成绩排名成功!", ureportsubmitted);
|
||||
return RespBean.ok("查询作业信息成功!", ureportsubmitted);
|
||||
} else {
|
||||
return RespBean.ok("尚未提交作业!");
|
||||
}
|
||||
|
|
@ -401,4 +406,77 @@ public class ProblemController {
|
|||
return RespBean.error("获取教师布置实验具体信息失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//学生保存报告
|
||||
@PostMapping("/saveInfoToProps")
|
||||
public RespBean saveInfoToProps(@RequestBody SubmitReport submitReport,HttpServletRequest request) {
|
||||
DecodeToken decodeToken = new DecodeToken(request);
|
||||
String UserId = decodeToken.getUserId();
|
||||
int userId = Integer.parseInt(UserId);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
submitReport.setStudentId(userId);
|
||||
if(problemServiceI.findReportSubmitted(submitReport)){//如果之前保存过数据,更新数据
|
||||
submitReport.setSubmissionTime(now);
|
||||
boolean result = problemServiceI.updateSubmitInfoToProps(submitReport);
|
||||
if (result) {
|
||||
return RespBean.ok("信息更新成功");
|
||||
} else {
|
||||
return RespBean.error("信息更新失败");
|
||||
}
|
||||
}
|
||||
else { //新生成一条数据
|
||||
submitReport.setPlagiarismStatus("0");//查重状态默认为0
|
||||
submitReport.setSubmissionStatus("0");//提交状态在保存时设置为0
|
||||
submitReport.setSubmissionTime(now);
|
||||
boolean result = problemServiceI.saveSubmitInfoToProps(submitReport);
|
||||
if (result) {
|
||||
return RespBean.ok("信息添加成功");
|
||||
} else {
|
||||
return RespBean.error("信息添加失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//学生提交报告
|
||||
@PostMapping("/submitInfoToProps")
|
||||
public RespBean submitInfoToProps(@RequestBody SubmitReport submitReport,HttpServletRequest request) {
|
||||
DecodeToken decodeToken = new DecodeToken(request);
|
||||
String UserId = decodeToken.getUserId();
|
||||
int userId = Integer.parseInt(UserId);
|
||||
submitReport.setStudentId(userId);
|
||||
|
||||
if (problemServiceI.findReportSubmitted(submitReport)) {
|
||||
boolean result = problemServiceI.updateSubmitInfoForSubmission(submitReport);
|
||||
if (result) {
|
||||
return RespBean.ok("提交信息更新成功");
|
||||
} else {
|
||||
return RespBean.error("提交信息更新失败");
|
||||
}
|
||||
}
|
||||
else{
|
||||
return RespBean.error("未找到该学生提交信息!");
|
||||
}
|
||||
}
|
||||
//学生撤回报告
|
||||
@PostMapping("/withdrawInfoToProps")
|
||||
public RespBean withdrawInfoToProps(@RequestBody SubmitReport submitReport,HttpServletRequest request) {
|
||||
DecodeToken decodeToken = new DecodeToken(request);
|
||||
String UserId = decodeToken.getUserId();
|
||||
int userId = Integer.parseInt(UserId);
|
||||
submitReport.setStudentId(userId);
|
||||
|
||||
if (problemServiceI.findReportSubmitted(submitReport)) {
|
||||
boolean result = problemServiceI.withdrawSubmitInfo(submitReport);
|
||||
if (result) {
|
||||
return RespBean.ok("撤回信息更新成功");
|
||||
} else {
|
||||
return RespBean.error("撤回信息更新失败");
|
||||
}
|
||||
}
|
||||
else{
|
||||
return RespBean.error("未找到该学生提交信息!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,4 +18,10 @@ public interface SubmitReportDaoI extends BaseDaoI<SubmitReport> {
|
|||
public List<Object[]> findScoreList(PMStudentSubmit pmStudentSubmit);
|
||||
public List<Integer> findNextId(int problemId);
|
||||
|
||||
|
||||
public boolean saveSubmitInfo(SubmitReport submitReport);
|
||||
public boolean getReportSubmitted(SubmitReport submitReport);
|
||||
public boolean updateReportSubmitted(SubmitReport submitReport);
|
||||
public boolean updateReportSubmittedForSubmission(SubmitReport submitReport);
|
||||
public boolean withdrawReportSubmitted(SubmitReport submitReport);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import com.example.aes.problem.model.PMStudentSubmit;
|
|||
import com.example.aes.problem.model.SubmitReport;
|
||||
import com.example.aes.user.dao.impl.BaseDaoImpl;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
|
|
@ -60,6 +62,7 @@ String chineseName=
|
|||
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateAddTime(LocalDateTime addTime, int problemId, int studentId) {
|
||||
String hql = "UPDATE SubmitReport sr SET" +
|
||||
|
|
@ -74,6 +77,7 @@ String chineseName=
|
|||
int num = q.executeUpdate();
|
||||
return num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int editScoreAndComment(PMReviewMessage pmReviewMessage) {
|
||||
Float score = pmReviewMessage.getScore();
|
||||
|
|
@ -96,6 +100,7 @@ String chineseName=
|
|||
int num = q.executeUpdate();
|
||||
return num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int redoReport(PMReviewMessage pmReviewMessage) {
|
||||
String hql = "UPDATE SubmitReport sr set" +
|
||||
|
|
@ -112,6 +117,7 @@ String chineseName=
|
|||
int num = q.executeUpdate();
|
||||
return num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object[]> findYijiaoList(PMStudentSubmit pmStudentSubmit) {
|
||||
int classId = pmStudentSubmit.getClassId();
|
||||
|
|
@ -162,6 +168,7 @@ String chineseName=
|
|||
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object[]> findScoreList(PMStudentSubmit pmStudentSubmit) {
|
||||
int classId = pmStudentSubmit.getClassId();
|
||||
|
|
@ -199,6 +206,7 @@ String chineseName=
|
|||
query.setParameter("problemId", problemId);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object[]> findProblemReview(PMReviewMessage pmReviewMessage) {
|
||||
int studentId = pmReviewMessage.getStudentId();
|
||||
|
|
@ -225,6 +233,7 @@ String chineseName=
|
|||
query.setParameter("problemId", problemId);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> findNextId(int problemId) {
|
||||
String hql = "SELECT " +
|
||||
|
|
@ -244,4 +253,108 @@ String chineseName=
|
|||
q.setParameter("problemId", problemId);
|
||||
return q.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveSubmitInfo(SubmitReport submitReport) {
|
||||
Session session = this.getCurrentSession();
|
||||
try {
|
||||
session.save(submitReport);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getReportSubmitted(SubmitReport submitReport) {
|
||||
Session session = this.getCurrentSession();
|
||||
boolean isSubmitted = false;
|
||||
try {
|
||||
// 构建查询语句 可能报错但不影响
|
||||
String hql = "FROM SubmitReport WHERE problemId = :problemId AND studentId = :studentId AND adminuserId = :adminuserId";
|
||||
|
||||
Query<SubmitReport> query = session.createQuery(hql, SubmitReport.class);
|
||||
query.setParameter("problemId", submitReport.getProblemId());
|
||||
query.setParameter("studentId", submitReport.getStudentId());
|
||||
query.setParameter("adminuserId", submitReport.getAdminuserId());
|
||||
SubmitReport result = query.uniqueResult();
|
||||
isSubmitted = (result != null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return isSubmitted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateReportSubmitted(SubmitReport submitReport) {
|
||||
Session session = this.getCurrentSession();
|
||||
try {
|
||||
|
||||
//只更新submissionTime和attachment
|
||||
String hql = "UPDATE SubmitReport SET submissionTime = :submissionTime, attachment = :attachment " +
|
||||
"WHERE problemId = :problemId AND adminuserId = :adminuserId AND studentId = :studentId";
|
||||
|
||||
Query query = session.createQuery(hql);
|
||||
|
||||
query.setParameter("submissionTime", submitReport.getSubmissionTime());
|
||||
query.setParameter("attachment", submitReport.getAttachment());
|
||||
query.setParameter("problemId", submitReport.getProblemId());
|
||||
query.setParameter("adminuserId", submitReport.getAdminuserId());
|
||||
query.setParameter("studentId", submitReport.getStudentId());
|
||||
|
||||
int result = query.executeUpdate();
|
||||
|
||||
return result > 0;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateReportSubmittedForSubmission(SubmitReport submitReport) {
|
||||
Session session = this.getCurrentSession();
|
||||
try {
|
||||
|
||||
String hql = "UPDATE SubmitReport SET submissionStatus = '1' " +
|
||||
"WHERE problemId = :problemId " +
|
||||
"AND adminuserId = :adminuserId " +
|
||||
"AND studentId = :studentId";
|
||||
|
||||
Query query = session.createQuery(hql);
|
||||
query.setParameter("problemId", submitReport.getProblemId());
|
||||
query.setParameter("adminuserId", submitReport.getAdminuserId());
|
||||
query.setParameter("studentId", submitReport.getStudentId());
|
||||
|
||||
int result = query.executeUpdate();
|
||||
return result > 0;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean withdrawReportSubmitted(SubmitReport submitReport) {
|
||||
Session session = this.getCurrentSession();
|
||||
try {
|
||||
|
||||
String hql = "UPDATE SubmitReport SET submissionStatus = '2' " +
|
||||
"WHERE problemId = :problemId " +
|
||||
"AND adminuserId = :adminuserId " +
|
||||
"AND studentId = :studentId";
|
||||
|
||||
Query query = session.createQuery(hql);
|
||||
query.setParameter("problemId", submitReport.getProblemId());
|
||||
query.setParameter("adminuserId", submitReport.getAdminuserId());
|
||||
query.setParameter("studentId", submitReport.getStudentId());
|
||||
|
||||
int result = query.executeUpdate();
|
||||
return result > 0;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -154,14 +154,20 @@ public class ProblemServiceImpl implements ProblemServiceI {
|
|||
if (reportStatus != null && studentId.equals(reportStatus.getStudentId())) {
|
||||
pmProblem.setSubmissionStatus(reportStatus.getSubmissionStatus());
|
||||
pmProblem.setPlagiarismStatus(reportStatus.getPlagiarismStatus());
|
||||
if (reportStatus.getScore() != null) {
|
||||
pmProblem.setScore(reportStatus.getScore());
|
||||
}
|
||||
|
||||
// 根据submissionStatus设置status
|
||||
if ("0".equals(reportStatus.getSubmissionStatus())) {
|
||||
pmProblem.setStatus("未提交");
|
||||
} else if ("1".equals(reportStatus.getSubmissionStatus())) {
|
||||
}
|
||||
else if ("1".equals(reportStatus.getSubmissionStatus())) {
|
||||
pmProblem.setStatus("已提交");
|
||||
}
|
||||
else if("2".equals(reportStatus.getSubmissionStatus())){
|
||||
pmProblem.setStatus("已撤回");
|
||||
}
|
||||
|
||||
// 如果score不为空,则将status设置为score的具体值
|
||||
if (reportStatus.getScore() != null) {
|
||||
|
|
@ -478,6 +484,32 @@ public int redoReport(PMReviewMessage pmReviewMessage){
|
|||
return studentSubmitDao.findNextId(problemId).get(0);
|
||||
else return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveSubmitInfoToProps(SubmitReport submitReport) {
|
||||
return studentSubmitDao.saveSubmitInfo(submitReport);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean findReportSubmitted(SubmitReport submitReport) {
|
||||
return studentSubmitDao.getReportSubmitted(submitReport);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateSubmitInfoToProps(SubmitReport submitReport) {
|
||||
return studentSubmitDao.updateReportSubmitted(submitReport);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateSubmitInfoForSubmission(SubmitReport submitReport) {
|
||||
return studentSubmitDao.updateReportSubmittedForSubmission(submitReport);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean withdrawSubmitInfo(SubmitReport submitReport) {
|
||||
return studentSubmitDao.withdrawReportSubmitted(submitReport);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int editPostProblem(int classId,
|
||||
int problemId,LocalDateTime startTime,LocalDateTime endTime,boolean allow){
|
||||
|
|
|
|||
|
|
@ -55,4 +55,10 @@ public interface ProblemServiceI {
|
|||
public int redoReport(PMReviewMessage pmReviewMessage);
|
||||
public List<Float> findScoreList(PMStudentSubmit pmStudentSubmit);
|
||||
public int findNextId(int problemId);
|
||||
|
||||
boolean saveSubmitInfoToProps(SubmitReport submitReport);//学生保存报告(保存,之前未保存过)
|
||||
boolean findReportSubmitted(SubmitReport submitReport);//查询该学生之前是否已经提交过该问题的报告
|
||||
boolean updateSubmitInfoToProps(SubmitReport submitReport);//学生更新报告信息(保存,之前保存过)
|
||||
boolean updateSubmitInfoForSubmission(SubmitReport submitReport);//学生提交报告
|
||||
boolean withdrawSubmitInfo(SubmitReport submitReport);//学生撤回报告
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue