完成作业提交界面剩余所有内容,三个控件等,修复了当成绩为空时查询作业列表方法空指针问题。
剩余接入算法和一些细节调整。
This commit is contained in:
parent
1c7695c067
commit
a30ecee6a5
|
|
@ -51,4 +51,13 @@ export default {
|
||||||
url: `/downloadFile/downloadFile/${fileName}`,
|
url: `/downloadFile/downloadFile/${fileName}`,
|
||||||
method: 'get',
|
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">
|
<div slot="header" class="clearfix card-header">
|
||||||
<span class="subtitle">实验提交</span>
|
<span class="subtitle">实验提交</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="attachment" class="file-list">
|
||||||
|
<span class="file-list-title">已保存的文件:</span>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
{{ attachment }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<el-button size="small" type="success" @click="showUploadDialog">上传附件</el-button>
|
<el-button size="small" type="success" @click="showUploadDialog">上传附件</el-button>
|
||||||
<div v-if="fileUrls.length > 0" class="file-list">
|
<div v-if="fileUrls.length > 0" class="file-list">
|
||||||
<span class="file-list-title">已上传文件:</span>
|
<span class="file-list-title">已上传文件(保存过的文件将被覆盖保存):</span>
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="(file, index) in fileUrls" :key="index">
|
<li v-for="(file, index) in fileUrls" :key="index">
|
||||||
{{ file.name }}
|
{{ file.name }}
|
||||||
|
|
@ -35,6 +43,8 @@
|
||||||
v-model:file-list="fileList"
|
v-model:file-list="fileList"
|
||||||
drag
|
drag
|
||||||
accept=".txt,.doc,.docx,.pdf"
|
accept=".txt,.doc,.docx,.pdf"
|
||||||
|
:limit="1"
|
||||||
|
:on-exceed="handleExceed"
|
||||||
>
|
>
|
||||||
<i class="el-icon-upload"></i>
|
<i class="el-icon-upload"></i>
|
||||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||||
|
|
@ -44,7 +54,15 @@
|
||||||
<el-button type="primary" @click="uploadFile">确定</el-button>
|
<el-button type="primary" @click="uploadFile">确定</el-button>
|
||||||
</span>
|
</span>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<ReportActions class="bottom" />
|
<ReportActions
|
||||||
|
:fileUrls="fileUrls"
|
||||||
|
:ProblemId="ProblemId"
|
||||||
|
:adminuserId="adminuserId"
|
||||||
|
:attachment="attachment"
|
||||||
|
:disabled="isReportActionsDisabled"
|
||||||
|
@refreshAttachment="refreshAttachmentInfo"
|
||||||
|
class="bottom"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -59,11 +77,15 @@ import ReportActions from "@/views/user/report-submit/components/report-actions.
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const ProblemId = route.params.examId;
|
const ProblemId = route.params.examId;
|
||||||
|
const examId = route.params.examId;
|
||||||
const description = ref(""); // 实验描述
|
const description = ref(""); // 实验描述
|
||||||
|
const adminuserId = ref(""); //布置实验的教师id
|
||||||
const reportText = ref(""); // 实验报告文本
|
const reportText = ref(""); // 实验报告文本
|
||||||
const uploadDialogVisible = ref(false); // 控制上传弹窗的显示
|
const uploadDialogVisible = ref(false); // 控制上传弹窗的显示
|
||||||
const fileList = ref([]); // 上传的文件列表
|
const fileList = ref([]); // 上传的文件列表
|
||||||
const fileUrls = ref([]); // 文件的URL列表
|
const fileUrls = ref([]); // 文件的URL列表
|
||||||
|
const attachment = ref(null);//已保存的文件信息
|
||||||
|
const isReportActionsDisabled = ref(false); // 控制ReportActions组件的禁用状态
|
||||||
const uploadComponent = ref(null); // 用于引用el-upload组件
|
const uploadComponent = ref(null); // 用于引用el-upload组件
|
||||||
|
|
||||||
const getProblemInfo = async () => {
|
const getProblemInfo = async () => {
|
||||||
|
|
@ -71,6 +93,7 @@ const getProblemInfo = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await api.findProblemById1({ params: { ProblemId } });
|
const res = await api.findProblemById1({ params: { ProblemId } });
|
||||||
description.value = res.data.description; // 更新作业名称
|
description.value = res.data.description; // 更新作业名称
|
||||||
|
adminuserId.value = res.data.adminuserId.toString(); // 更新教师id
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch problem info:", error);
|
console.error("Failed to fetch problem info:", error);
|
||||||
}
|
}
|
||||||
|
|
@ -78,6 +101,10 @@ const getProblemInfo = async () => {
|
||||||
|
|
||||||
// 显示上传弹窗
|
// 显示上传弹窗
|
||||||
const showUploadDialog = () => {
|
const showUploadDialog = () => {
|
||||||
|
if (fileUrls.value.length > 0) {
|
||||||
|
ElMessage.warning('您已经上传了文件,不能再次上传。');
|
||||||
|
return;
|
||||||
|
}
|
||||||
uploadDialogVisible.value = true;
|
uploadDialogVisible.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -89,11 +116,11 @@ const handleFileChange = (file, fileList) => {
|
||||||
// 处理文件上传成功
|
// 处理文件上传成功
|
||||||
const handleUploadSuccess = (response, file, fileList) => {
|
const handleUploadSuccess = (response, file, fileList) => {
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
ElMessage.success('文件上传成功');
|
|
||||||
// 更新文件URL列表
|
// 更新文件URL列表
|
||||||
fileUrls.value.push({ url: response.urls, name: response.data });
|
fileUrls.value.push({ url: response.urls, name: response.data });
|
||||||
uploadDialogVisible.value = false;
|
uploadDialogVisible.value = false;
|
||||||
fileList.value = [];
|
fileList.value = [];
|
||||||
|
ElMessage.success('文件上传成功');
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error('文件上传失败');
|
ElMessage.error('文件上传失败');
|
||||||
}
|
}
|
||||||
|
|
@ -105,6 +132,11 @@ const handleUploadError = (err, file, fileList) => {
|
||||||
ElMessage.error('文件上传失败');
|
ElMessage.error('文件上传失败');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 处理文件数量超出限制
|
||||||
|
const handleExceed = (files, fileList) => {
|
||||||
|
ElMessage.error('只能上传一个附件');
|
||||||
|
};
|
||||||
|
|
||||||
// 上传文件
|
// 上传文件
|
||||||
const uploadFile = async () => {
|
const uploadFile = async () => {
|
||||||
if (fileList.value.length === 0) {
|
if (fileList.value.length === 0) {
|
||||||
|
|
@ -119,38 +151,53 @@ const uploadFile = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await api.uploadFiles(formData); // 调用上传文件的方法
|
const response = await api.uploadFiles(formData); // 调用上传文件的方法
|
||||||
console.log('Response from server:', response); // 打印响应内容
|
console.log('Response from server:', response); // 打印响应内容
|
||||||
if (response.code === 0) {
|
|
||||||
ElMessage.success('文件上传成功');
|
ElMessage.success('文件上传成功');
|
||||||
// 更新文件URL列表
|
// 更新文件URL列表
|
||||||
fileUrls.value.push({ url: response.urls, name: response.data });
|
fileUrls.value.push({ url: response.urls, name: response.data });
|
||||||
uploadDialogVisible.value = false;
|
uploadDialogVisible.value = false;
|
||||||
fileList.value = [];
|
fileList.value = [];
|
||||||
} else {
|
|
||||||
ElMessage.error('文件上传失败1');
|
}catch (error) {
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to upload files:", error);
|
console.error("Failed to upload files:", error);
|
||||||
ElMessage.error('文件上传失败2');
|
ElMessage.error('文件上传失败2');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 下载文件
|
|
||||||
const downloadFile = (url) => {
|
const getSubmitReportInfo = async () => {
|
||||||
const link = document.createElement('a');
|
// 查询已保存的文件信息
|
||||||
link.href = url;
|
try {
|
||||||
link.target = '_blank';
|
const res = await api.getSubmitReport({ params: { examId } });
|
||||||
link.download = url.split('/').pop(); // 提取文件名
|
if (res.data.attachment) {
|
||||||
document.body.appendChild(link);
|
attachment.value = res.data.attachment; // 更新附件信息
|
||||||
link.click();
|
} else {
|
||||||
document.body.removeChild(link);
|
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(() => {
|
onMounted(() => {
|
||||||
getProblemInfo(); // 挂载时查询作业信息
|
getProblemInfo(); // 挂载时查询作业信息
|
||||||
|
getSubmitReportInfo();//查询已保存的文件信息
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.card-header {
|
.card-header {
|
||||||
background-color: #f5f5f5; /* 加深灰色背景 */
|
background-color: #f5f5f5; /* 加深灰色背景 */
|
||||||
|
|
@ -187,7 +234,7 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
.file-list {
|
.file-list {
|
||||||
margin-top: 20px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.file-list-title {
|
.file-list-title {
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,130 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="button-container">
|
<div class="button-container">
|
||||||
<n-button type="primary" size="small" @click="onSave">保存</n-button>
|
<n-button type="primary" size="small" @click="onSave" :disabled="props.disabled">保存</n-button>
|
||||||
<n-button type="success" size="small" @click="onSaveAndSubmit">保存并提交</n-button>
|
<n-button type="success" size="small" @click="onSaveAndSubmit" :disabled="props.disabled">保存并提交</n-button>
|
||||||
<n-button type="warning" size="small" @click="onWithdraw">申请撤回</n-button>
|
<n-button type="warning" size="small" @click="onWithdraw" :disabled="props.disabled">撤回提交</n-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
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 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 = () => {
|
const emit = defineEmits(['clickSave', 'clickSaveAndSubmit', 'clickWithdraw', 'refreshAttachment']);
|
||||||
// TODO: 实现保存逻辑
|
|
||||||
emit('clickSave');
|
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 = () => {
|
const onSaveAndSubmit = async () => {//保存并提交
|
||||||
// TODO: 实现保存并提交逻辑
|
let shouldSubmit = false;
|
||||||
emit('clickSaveAndSubmit');
|
|
||||||
};
|
// 检查是否有新上传的文件
|
||||||
|
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 = () => { //撤回提交
|
||||||
|
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(() => {
|
||||||
|
// 用户取消撤回
|
||||||
|
});
|
||||||
|
|
||||||
const onWithdraw = () => {
|
|
||||||
// TODO: 实现申请撤回逻辑
|
|
||||||
emit('clickWithdraw');
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import api from '@/api/user';
|
import api from '@/api/user';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
import {ElMessage} from "element-plus";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const examId = route.params.examId;
|
const examId = route.params.examId;
|
||||||
|
|
@ -28,8 +29,13 @@ const getJudgeInfo = async () => {
|
||||||
// 查询批阅相关信息
|
// 查询批阅相关信息
|
||||||
try {
|
try {
|
||||||
const res = await api.getSubmitReport({ params: { examId } });
|
const res = await api.getSubmitReport({ params: { examId } });
|
||||||
comment.value = res.data.comment; // 更新教师评语
|
if(res.data==null){
|
||||||
plagiarismStatus.value = res.data.plagiarismStatus; // 更新抄袭状态
|
ElMessage.warning("尚未提交作业!")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
comment.value = res.data.comment; // 更新教师评语
|
||||||
|
plagiarismStatus.value = res.data.plagiarismStatus; // 更新抄袭状态
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch problem info:", 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.model.DataGrid;
|
||||||
import com.example.aes.problem.service.ProblemServiceI;
|
import com.example.aes.problem.service.ProblemServiceI;
|
||||||
import com.example.aes.user.model.Classstudents;
|
import com.example.aes.user.model.Classstudents;
|
||||||
|
import com.example.aes.user.model.PMUser;
|
||||||
import com.example.aes.user.service.ClassesServiceI;
|
import com.example.aes.user.service.ClassesServiceI;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
@ -295,7 +300,7 @@ public class ProblemController {
|
||||||
//根据班级id查询所有作业
|
//根据班级id查询所有作业
|
||||||
List<PMProblem> pMproblems = problemServiceI.getProblemsByClassIds(classIds);
|
List<PMProblem> pMproblems = problemServiceI.getProblemsByClassIds(classIds);
|
||||||
|
|
||||||
// 根据学生ID和作业列表查询提交报告的状态,分为提交状态和查重状态,并更新到pmproblem中
|
// 根据学生ID和作业列表查询提交报告的状态,分为提交状态和查重状态,并更新到pMproblems中
|
||||||
problemServiceI.findStatusByStudentIdAndProblems(Integer.parseInt(userId), pMproblems);
|
problemServiceI.findStatusByStudentIdAndProblems(Integer.parseInt(userId), pMproblems);
|
||||||
|
|
||||||
//分页处理
|
//分页处理
|
||||||
|
|
@ -372,7 +377,7 @@ public class ProblemController {
|
||||||
UReportSubmitted ureportsubmitted =
|
UReportSubmitted ureportsubmitted =
|
||||||
problemServiceI.findScoreAndRankByIds(examId, userId);
|
problemServiceI.findScoreAndRankByIds(examId, userId);
|
||||||
if (ureportsubmitted != null) {
|
if (ureportsubmitted != null) {
|
||||||
return RespBean.ok("查询成绩排名成功!", ureportsubmitted);
|
return RespBean.ok("查询作业信息成功!", ureportsubmitted);
|
||||||
} else {
|
} else {
|
||||||
return RespBean.ok("尚未提交作业!");
|
return RespBean.ok("尚未提交作业!");
|
||||||
}
|
}
|
||||||
|
|
@ -401,4 +406,77 @@ public class ProblemController {
|
||||||
return RespBean.error("获取教师布置实验具体信息失败!");
|
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<Object[]> findScoreList(PMStudentSubmit pmStudentSubmit);
|
||||||
public List<Integer> findNextId(int problemId);
|
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.problem.model.SubmitReport;
|
||||||
import com.example.aes.user.dao.impl.BaseDaoImpl;
|
import com.example.aes.user.dao.impl.BaseDaoImpl;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.Transaction;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
|
|
@ -15,26 +17,26 @@ import java.util.List;
|
||||||
@Repository("SubmitReportDao")
|
@Repository("SubmitReportDao")
|
||||||
public class SubmitReportDaoImpl extends BaseDaoImpl<SubmitReport> implements SubmitReportDaoI {
|
public class SubmitReportDaoImpl extends BaseDaoImpl<SubmitReport> implements SubmitReportDaoI {
|
||||||
@Override
|
@Override
|
||||||
public List<Object[]> findWeijiaoList(PMStudentSubmit pmStudentSubmit){
|
public List<Object[]> findWeijiaoList(PMStudentSubmit pmStudentSubmit) {
|
||||||
int classId= pmStudentSubmit.getClassId();
|
int classId = pmStudentSubmit.getClassId();
|
||||||
int problemId= pmStudentSubmit.getProblemId();
|
int problemId = pmStudentSubmit.getProblemId();
|
||||||
String studentNo=
|
String studentNo =
|
||||||
'%'+pmStudentSubmit.getStudentNo()+'%';
|
'%' + pmStudentSubmit.getStudentNo() + '%';
|
||||||
String chineseName=
|
String chineseName =
|
||||||
'%'+pmStudentSubmit.getChineseName()+'%';
|
'%' + pmStudentSubmit.getChineseName() + '%';
|
||||||
String hql="SELECT u.chineseName," +
|
String hql = "SELECT u.chineseName," +
|
||||||
"u.studentNo, sr" +
|
"u.studentNo, sr" +
|
||||||
".readTime," +
|
".readTime," +
|
||||||
"sr.submissionStatus,u.id " +
|
"sr.submissionStatus,u.id " +
|
||||||
"FROM Classstudents cs left " +
|
"FROM Classstudents cs left " +
|
||||||
"join Users u on cs" +
|
"join Users u on cs" +
|
||||||
".userId=u.id "+
|
".userId=u.id " +
|
||||||
"left join PostProblem pp on cs" +
|
"left join PostProblem pp on cs" +
|
||||||
".classId=pp.classId "+
|
".classId=pp.classId " +
|
||||||
"left JOIN"+
|
"left JOIN" +
|
||||||
" SubmitReport sr ON " +
|
" SubmitReport sr ON " +
|
||||||
"sr" +
|
"sr" +
|
||||||
".studentId=u.id"+
|
".studentId=u.id" +
|
||||||
" WHERE cs.classId=:classId " +
|
" WHERE cs.classId=:classId " +
|
||||||
"and " +
|
"and " +
|
||||||
"pp.problemId " +
|
"pp.problemId " +
|
||||||
|
|
@ -46,40 +48,42 @@ String chineseName=
|
||||||
"and u" +
|
"and u" +
|
||||||
".chineseName like :chineseName";
|
".chineseName like :chineseName";
|
||||||
Query<Object[]> query =
|
Query<Object[]> query =
|
||||||
this.getCurrentSession().createQuery(hql,Object[].class);
|
this.getCurrentSession().createQuery(hql, Object[].class);
|
||||||
query.setParameter("classId", classId);
|
query.setParameter("classId", classId);
|
||||||
query.setParameter("problemId", problemId);
|
query.setParameter("problemId", problemId);
|
||||||
query.setParameter("studentNo",studentNo);
|
query.setParameter("studentNo", studentNo);
|
||||||
query.setParameter("chineseName",
|
query.setParameter("chineseName",
|
||||||
chineseName);
|
chineseName);
|
||||||
int page= pmStudentSubmit.getPageNum();
|
int page = pmStudentSubmit.getPageNum();
|
||||||
int rows= pmStudentSubmit.getPageSize();
|
int rows = pmStudentSubmit.getPageSize();
|
||||||
// 设置分页
|
// 设置分页
|
||||||
query.setFirstResult((page - 1) * rows); // 计算起始行
|
query.setFirstResult((page - 1) * rows); // 计算起始行
|
||||||
query.setMaxResults(rows); // 设置每页行数
|
query.setMaxResults(rows); // 设置每页行数
|
||||||
|
|
||||||
return query.getResultList();
|
return query.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateAddTime(LocalDateTime addTime,int problemId,int studentId){
|
public int updateAddTime(LocalDateTime addTime, int problemId, int studentId) {
|
||||||
String hql= "UPDATE SubmitReport sr SET" +
|
String hql = "UPDATE SubmitReport sr SET" +
|
||||||
" sr.addTime= :addTime "
|
" sr.addTime= :addTime "
|
||||||
+ "WHERE sr.problemId = " +
|
+ "WHERE sr.problemId = " +
|
||||||
":problemId" +
|
":problemId" +
|
||||||
" AND sr.studentId= :studentId";
|
" AND sr.studentId= :studentId";
|
||||||
Query q = this.getCurrentSession().createQuery(hql);
|
Query q = this.getCurrentSession().createQuery(hql);
|
||||||
q.setParameter("addTime",addTime);
|
q.setParameter("addTime", addTime);
|
||||||
q.setParameter("problemId",problemId);
|
q.setParameter("problemId", problemId);
|
||||||
q.setParameter("studentId",studentId);
|
q.setParameter("studentId", studentId);
|
||||||
int num = q.executeUpdate();
|
int num = q.executeUpdate();
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int editScoreAndComment(PMReviewMessage pmReviewMessage){
|
public int editScoreAndComment(PMReviewMessage pmReviewMessage) {
|
||||||
Float score= pmReviewMessage.getScore();
|
Float score = pmReviewMessage.getScore();
|
||||||
String comment=
|
String comment =
|
||||||
pmReviewMessage.getComment();
|
pmReviewMessage.getComment();
|
||||||
String hql= "UPDATE SubmitReport sr SET" +
|
String hql = "UPDATE SubmitReport sr SET" +
|
||||||
" sr.score= :score,sr" +
|
" sr.score= :score,sr" +
|
||||||
".comment=:comment,sr" +
|
".comment=:comment,sr" +
|
||||||
".submissionStatus='已批阅' "
|
".submissionStatus='已批阅' "
|
||||||
|
|
@ -87,8 +91,8 @@ String chineseName=
|
||||||
":problemId" +
|
":problemId" +
|
||||||
" AND sr.studentId= :studentId";
|
" AND sr.studentId= :studentId";
|
||||||
Query q = this.getCurrentSession().createQuery(hql);
|
Query q = this.getCurrentSession().createQuery(hql);
|
||||||
q.setParameter("score",score);
|
q.setParameter("score", score);
|
||||||
q.setParameter("comment",comment);
|
q.setParameter("comment", comment);
|
||||||
q.setParameter("problemId",
|
q.setParameter("problemId",
|
||||||
pmReviewMessage.getProblemId());
|
pmReviewMessage.getProblemId());
|
||||||
q.setParameter("studentId",
|
q.setParameter("studentId",
|
||||||
|
|
@ -96,9 +100,10 @@ String chineseName=
|
||||||
int num = q.executeUpdate();
|
int num = q.executeUpdate();
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int redoReport(PMReviewMessage pmReviewMessage){
|
public int redoReport(PMReviewMessage pmReviewMessage) {
|
||||||
String hql= "UPDATE SubmitReport sr set" +
|
String hql = "UPDATE SubmitReport sr set" +
|
||||||
" sr.submissionStatus='已领取'," +
|
" sr.submissionStatus='已领取'," +
|
||||||
"sr.submissionTime=null " +
|
"sr.submissionTime=null " +
|
||||||
"WHERE sr.problemId = " +
|
"WHERE sr.problemId = " +
|
||||||
|
|
@ -112,15 +117,16 @@ String chineseName=
|
||||||
int num = q.executeUpdate();
|
int num = q.executeUpdate();
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Object[]> findYijiaoList(PMStudentSubmit pmStudentSubmit){
|
public List<Object[]> findYijiaoList(PMStudentSubmit pmStudentSubmit) {
|
||||||
int classId= pmStudentSubmit.getClassId();
|
int classId = pmStudentSubmit.getClassId();
|
||||||
int problemId= pmStudentSubmit.getProblemId();
|
int problemId = pmStudentSubmit.getProblemId();
|
||||||
String studentNo=
|
String studentNo =
|
||||||
'%'+pmStudentSubmit.getStudentNo()+'%';
|
'%' + pmStudentSubmit.getStudentNo() + '%';
|
||||||
String chineseName=
|
String chineseName =
|
||||||
'%'+pmStudentSubmit.getChineseName()+'%';
|
'%' + pmStudentSubmit.getChineseName() + '%';
|
||||||
String hql="SELECT u.chineseName," +
|
String hql = "SELECT u.chineseName," +
|
||||||
"u.studentNo, sr" +
|
"u.studentNo, sr" +
|
||||||
".submissionTime," +
|
".submissionTime," +
|
||||||
"sr.submissionStatus," +
|
"sr.submissionStatus," +
|
||||||
|
|
@ -129,13 +135,13 @@ String chineseName=
|
||||||
"AS finalScore ,u.id " +
|
"AS finalScore ,u.id " +
|
||||||
"FROM Classstudents cs left " +
|
"FROM Classstudents cs left " +
|
||||||
"join Users u on cs" +
|
"join Users u on cs" +
|
||||||
".userId=u.id "+
|
".userId=u.id " +
|
||||||
"left join PostProblem pp on cs" +
|
"left join PostProblem pp on cs" +
|
||||||
".classId=pp.classId "+
|
".classId=pp.classId " +
|
||||||
"left JOIN"+
|
"left JOIN" +
|
||||||
" SubmitReport sr ON " +
|
" SubmitReport sr ON " +
|
||||||
"sr" +
|
"sr" +
|
||||||
".studentId=u.id"+
|
".studentId=u.id" +
|
||||||
" WHERE cs.classId=:classId " +
|
" WHERE cs.classId=:classId " +
|
||||||
"and " +
|
"and " +
|
||||||
"pp.problemId " +
|
"pp.problemId " +
|
||||||
|
|
@ -148,29 +154,30 @@ String chineseName=
|
||||||
"and u" +
|
"and u" +
|
||||||
".chineseName like :chineseName";
|
".chineseName like :chineseName";
|
||||||
Query<Object[]> query =
|
Query<Object[]> query =
|
||||||
this.getCurrentSession().createQuery(hql,Object[].class);
|
this.getCurrentSession().createQuery(hql, Object[].class);
|
||||||
query.setParameter("classId", classId);
|
query.setParameter("classId", classId);
|
||||||
query.setParameter("problemId", problemId);
|
query.setParameter("problemId", problemId);
|
||||||
query.setParameter("studentNo",studentNo);
|
query.setParameter("studentNo", studentNo);
|
||||||
query.setParameter("chineseName",
|
query.setParameter("chineseName",
|
||||||
chineseName);
|
chineseName);
|
||||||
int page= pmStudentSubmit.getPageNum();
|
int page = pmStudentSubmit.getPageNum();
|
||||||
int rows= pmStudentSubmit.getPageSize();
|
int rows = pmStudentSubmit.getPageSize();
|
||||||
// 设置分页
|
// 设置分页
|
||||||
query.setFirstResult((page - 1) * rows); // 计算起始行
|
query.setFirstResult((page - 1) * rows); // 计算起始行
|
||||||
query.setMaxResults(rows); // 设置每页行数
|
query.setMaxResults(rows); // 设置每页行数
|
||||||
|
|
||||||
return query.getResultList();
|
return query.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Object[]> findScoreList(PMStudentSubmit pmStudentSubmit){
|
public List<Object[]> findScoreList(PMStudentSubmit pmStudentSubmit) {
|
||||||
int classId= pmStudentSubmit.getClassId();
|
int classId = pmStudentSubmit.getClassId();
|
||||||
int problemId= pmStudentSubmit.getProblemId();
|
int problemId = pmStudentSubmit.getProblemId();
|
||||||
// String studentNo=
|
// String studentNo=
|
||||||
// '%'+pmStudentSubmit.getStudentNo()+'%';
|
// '%'+pmStudentSubmit.getStudentNo()+'%';
|
||||||
// String chineseName=
|
// String chineseName=
|
||||||
// '%'+pmStudentSubmit.getChineseName()+'%';
|
// '%'+pmStudentSubmit.getChineseName()+'%';
|
||||||
String hql="SELECT u.chineseName," +
|
String hql = "SELECT u.chineseName," +
|
||||||
"u.studentNo, sr" +
|
"u.studentNo, sr" +
|
||||||
".submissionTime," +
|
".submissionTime," +
|
||||||
"sr.submissionStatus," +
|
"sr.submissionStatus," +
|
||||||
|
|
@ -179,13 +186,13 @@ String chineseName=
|
||||||
"AS finalScore ,u.id " +
|
"AS finalScore ,u.id " +
|
||||||
"FROM Classstudents cs left " +
|
"FROM Classstudents cs left " +
|
||||||
"join Users u on cs" +
|
"join Users u on cs" +
|
||||||
".userId=u.id "+
|
".userId=u.id " +
|
||||||
"left join PostProblem pp on cs" +
|
"left join PostProblem pp on cs" +
|
||||||
".classId=pp.classId "+
|
".classId=pp.classId " +
|
||||||
"left JOIN"+
|
"left JOIN" +
|
||||||
" SubmitReport sr ON " +
|
" SubmitReport sr ON " +
|
||||||
"sr" +
|
"sr" +
|
||||||
".studentId=u.id"+
|
".studentId=u.id" +
|
||||||
" WHERE cs.classId=:classId " +
|
" WHERE cs.classId=:classId " +
|
||||||
"and " +
|
"and " +
|
||||||
"pp.problemId " +
|
"pp.problemId " +
|
||||||
|
|
@ -194,16 +201,17 @@ String chineseName=
|
||||||
" and sr" +
|
" and sr" +
|
||||||
".submissionTime is not null";
|
".submissionTime is not null";
|
||||||
Query<Object[]> query =
|
Query<Object[]> query =
|
||||||
this.getCurrentSession().createQuery(hql,Object[].class);
|
this.getCurrentSession().createQuery(hql, Object[].class);
|
||||||
query.setParameter("classId", classId);
|
query.setParameter("classId", classId);
|
||||||
query.setParameter("problemId", problemId);
|
query.setParameter("problemId", problemId);
|
||||||
return query.getResultList();
|
return query.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Object[]> findProblemReview(PMReviewMessage pmReviewMessage){
|
public List<Object[]> findProblemReview(PMReviewMessage pmReviewMessage) {
|
||||||
int studentId= pmReviewMessage.getStudentId();
|
int studentId = pmReviewMessage.getStudentId();
|
||||||
int problemId= pmReviewMessage.getProblemId();
|
int problemId = pmReviewMessage.getProblemId();
|
||||||
String hql="select p.title," +
|
String hql = "select p.title," +
|
||||||
"p.description,u.chineseName," +
|
"p.description,u.chineseName," +
|
||||||
"u.studentNo,u.banji," +
|
"u.studentNo,u.banji," +
|
||||||
"sr.attachment," +
|
"sr.attachment," +
|
||||||
|
|
@ -220,14 +228,15 @@ String chineseName=
|
||||||
" " +
|
" " +
|
||||||
"p.id=:problemId";
|
"p.id=:problemId";
|
||||||
Query<Object[]> query =
|
Query<Object[]> query =
|
||||||
this.getCurrentSession().createQuery(hql,Object[].class);
|
this.getCurrentSession().createQuery(hql, Object[].class);
|
||||||
query.setParameter("studentId", studentId);
|
query.setParameter("studentId", studentId);
|
||||||
query.setParameter("problemId", problemId);
|
query.setParameter("problemId", problemId);
|
||||||
return query.getResultList();
|
return query.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Integer> findNextId(int problemId){
|
public List<Integer> findNextId(int problemId) {
|
||||||
String hql="SELECT " +
|
String hql = "SELECT " +
|
||||||
"sr.studentId " +
|
"sr.studentId " +
|
||||||
"FROM Users u " +
|
"FROM Users u " +
|
||||||
"INNER JOIN " +
|
"INNER JOIN " +
|
||||||
|
|
@ -244,4 +253,108 @@ String chineseName=
|
||||||
q.setParameter("problemId", problemId);
|
q.setParameter("problemId", problemId);
|
||||||
return q.list();
|
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())) {
|
if (reportStatus != null && studentId.equals(reportStatus.getStudentId())) {
|
||||||
pmProblem.setSubmissionStatus(reportStatus.getSubmissionStatus());
|
pmProblem.setSubmissionStatus(reportStatus.getSubmissionStatus());
|
||||||
pmProblem.setPlagiarismStatus(reportStatus.getPlagiarismStatus());
|
pmProblem.setPlagiarismStatus(reportStatus.getPlagiarismStatus());
|
||||||
pmProblem.setScore(reportStatus.getScore());
|
if (reportStatus.getScore() != null) {
|
||||||
|
pmProblem.setScore(reportStatus.getScore());
|
||||||
|
}
|
||||||
|
|
||||||
// 根据submissionStatus设置status
|
// 根据submissionStatus设置status
|
||||||
if ("0".equals(reportStatus.getSubmissionStatus())) {
|
if ("0".equals(reportStatus.getSubmissionStatus())) {
|
||||||
pmProblem.setStatus("未提交");
|
pmProblem.setStatus("未提交");
|
||||||
} else if ("1".equals(reportStatus.getSubmissionStatus())) {
|
}
|
||||||
|
else if ("1".equals(reportStatus.getSubmissionStatus())) {
|
||||||
pmProblem.setStatus("已提交");
|
pmProblem.setStatus("已提交");
|
||||||
}
|
}
|
||||||
|
else if("2".equals(reportStatus.getSubmissionStatus())){
|
||||||
|
pmProblem.setStatus("已撤回");
|
||||||
|
}
|
||||||
|
|
||||||
// 如果score不为空,则将status设置为score的具体值
|
// 如果score不为空,则将status设置为score的具体值
|
||||||
if (reportStatus.getScore() != null) {
|
if (reportStatus.getScore() != null) {
|
||||||
|
|
@ -478,6 +484,32 @@ public int redoReport(PMReviewMessage pmReviewMessage){
|
||||||
return studentSubmitDao.findNextId(problemId).get(0);
|
return studentSubmitDao.findNextId(problemId).get(0);
|
||||||
else return 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
|
@Override
|
||||||
public int editPostProblem(int classId,
|
public int editPostProblem(int classId,
|
||||||
int problemId,LocalDateTime startTime,LocalDateTime endTime,boolean allow){
|
int problemId,LocalDateTime startTime,LocalDateTime endTime,boolean allow){
|
||||||
|
|
|
||||||
|
|
@ -55,4 +55,10 @@ public interface ProblemServiceI {
|
||||||
public int redoReport(PMReviewMessage pmReviewMessage);
|
public int redoReport(PMReviewMessage pmReviewMessage);
|
||||||
public List<Float> findScoreList(PMStudentSubmit pmStudentSubmit);
|
public List<Float> findScoreList(PMStudentSubmit pmStudentSubmit);
|
||||||
public int findNextId(int problemId);
|
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