作业库完成,作业列表显示完成

This commit is contained in:
zlm133588 2025-03-24 21:11:13 +08:00
parent 01b56e4bf9
commit d14d16fd37
19 changed files with 323 additions and 222 deletions

View File

@ -86,4 +86,5 @@ export default {
findScoringStandardByProblemId: (data) => request.post('/problem/findScoringStandardByProblemId', data), findScoringStandardByProblemId: (data) => request.post('/problem/findScoringStandardByProblemId', data),
editProblem:(data) => request.post('/problem/editProblem', data), editProblem:(data) => request.post('/problem/editProblem', data),
deleteProblem:(data) => request.post('/problem/deleteProblem', data), deleteProblem:(data) => request.post('/problem/deleteProblem', data),
findAllProblemByCourseIdAndClassId:(data)=>request.post('/problem/findAllProblemByCourseIdAndClassId',data),
} }

View File

@ -33,7 +33,7 @@ import ProblemActions from
'./ProblemActions.vue'; './ProblemActions.vue';
import {formatDateTime} from '@/utils'; import {formatDateTime} from '@/utils';
import { useUserStore } from '@/store'; import { useUserStore } from '@/store';
import { useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router'
const rules=ref(null) const rules=ref(null)
const userStore = useUserStore() const userStore = useUserStore()
const router = useRouter() const router = useRouter()
@ -42,6 +42,7 @@ const loading = ref(true)
const ScoringRubricList = const ScoringRubricList =
ref([]) ref([])
const role=userStore.getRole() const role=userStore.getRole()
const route = useRoute()
const paginationReactive = reactive({ const paginationReactive = reactive({
page: 1, page: 1,
pageSize: 50, pageSize: 50,
@ -114,15 +115,9 @@ const onChangePage = (page) => {
onMounted(()=>{ onMounted(()=>{
queryByPage() queryByPage()
}) })
watch( watch(route, () => {
()=>router.currentRoute.value.fullPath, queryByPage() // 路由变化时重新获取数据
()=>{ });
if
(router.currentRoute.value.fullPath==='/admin/problem/problem-scoring-standard') {
queryByPage(paginationReactive.page)
}
}
)
</script> </script>
<style> <style>

View File

@ -33,7 +33,7 @@ import ProblemActions from
'./ProblemActions.vue'; './ProblemActions.vue';
import {formatDateTime} from '@/utils'; import {formatDateTime} from '@/utils';
import { useUserStore } from '@/store'; import { useUserStore } from '@/store';
import { useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router'
const rules=ref(null) const rules=ref(null)
const userStore = useUserStore() const userStore = useUserStore()
const router = useRouter() const router = useRouter()
@ -44,6 +44,7 @@ const ProblemList =
const options1=ref([]) const options1=ref([])
const role=userStore.getRole() const role=userStore.getRole()
const teacherId=ref() const teacherId=ref()
const route = useRoute()
const paginationReactive = reactive({ const paginationReactive = reactive({
page: 1, page: 1,
pageSize: 50, pageSize: 50,
@ -145,15 +146,9 @@ const onChangePage = (page) => {
onMounted(()=>{ onMounted(()=>{
queryByPage() queryByPage()
}) })
watch( watch(route, () => {
()=>router.currentRoute.value.fullPath, queryByPage(); // 路由变化时重新获取数据
()=>{ });
if
(router.currentRoute.value.fullPath==='/admin/problem/problem-list') {
queryByPage(paginationReactive.page)
}
}
)
</script> </script>
<style> <style>

View File

@ -103,7 +103,6 @@ let columns = [
] ]
const cancel = ()=>{ const cancel = ()=>{
tagsStore.removeTag(path.value) tagsStore.removeTag(path.value)
router.push({path: 'problem-list'})
} }
const onAdd = ()=>{ const onAdd = ()=>{
router.push({name: 'AdminProblemScoringStandard'}) router.push({name: 'AdminProblemScoringStandard'})

View File

@ -16,15 +16,16 @@
<n-form-item label="班级:" <n-form-item label="班级:"
path="name" Problem="flex-item"> path="name" Problem="flex-item">
<n-select <n-select
v-model:value="ProblemInfoValue.ProblemId" v-model:value="ProblemInfoValue.classId"
:options="options1" :options="options1"
@update:value="search"
style="min-width: 80px;width: 140px"></n-select> style="min-width: 80px;width: 140px"></n-select>
</n-form-item> </n-form-item>
<n-form-item style="margin-left: 10px"> <!-- <n-form-item style="margin-left: 10px">-->
<n-button type="primary" @click="search" style="margin-left: 10px;margin-right: 20px">查询</n-button> <!-- <n-button type="primary" @click="search" style="margin-left: 10px;margin-right: 20px">查询</n-button>-->
</n-form-item> <!-- </n-form-item>-->
<div <div
class="status-options"style='display: flex;gap: 20px'> class="status-options"style='display: flex;gap: 20px;margin-left: 30px'>
<label>状态:</label> <label>状态:</label>
<label> <label>
<input type="radio" value="" v-model="selectedStatus" @change="filterData" /> <input type="radio" value="" v-model="selectedStatus" @change="filterData" />
@ -73,33 +74,24 @@ import ProblemActions from
'./components/ProblemActions.vue'; './components/ProblemActions.vue';
import {formatDateTime} from '@/utils'; import {formatDateTime} from '@/utils';
import { useUserStore } from '@/store'; import { useUserStore } from '@/store';
import { useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router'
const rules=ref(null) const rules=ref(null)
const userStore = useUserStore() const userStore = useUserStore()
const router = useRouter() const router = useRouter()
const ProblemInfoRef = ref(null) const ProblemInfoRef = ref(null)
const loading = ref(true) const loading = ref(true)
const ProblemList = const ProblemList =
ref([{title:"C++班级",timeRange:"2025-03-01 10:00:00 - 2025-03-05 18:00:00",daipi:"50",yijiao:"60",weijiao:"20"}]) ref([])
const options1=ref([]) const options1=ref([])
const role=userStore.getRole() const role=userStore.getRole()
const teacherId=ref() const teacherId=ref()
const selectedStatus=ref('') const selectedStatus=ref("")
const today = new Date(); const today = new Date();
const filteredData =ref([]); const filteredData =ref([]);
const route = useRoute()
const { courseId, history } = route.query
const filterData =() => { const filterData =() => {
if (selectedStatus.value === '') { search(paginationReactive.page)
filteredData.value = ProblemList.value;
} else if(selectedStatus.value=='completed'){
filteredData.value = ProblemList.value.filter(item =>
item.endTime<today);
}else if(selectedStatus.value=='not_started'){
filteredData.value = ProblemList.value.filter(item =>
item.startTime>today);
}else{
filteredData.value = ProblemList.value.filter(item =>
item.startTime<=today&&item.endTime>=today);
}
}; };
const paginationReactive = reactive({ const paginationReactive = reactive({
page: 1, page: 1,
@ -115,6 +107,8 @@ const ProblemInfoValue = ref({
pageSize:paginationReactive.pageSize, pageSize:paginationReactive.pageSize,
id:0, id:0,
teacherId:'', teacherId:'',
title:"",
classId:0
}); });
const onAdd = ()=>{ const onAdd = ()=>{
router.push({name: 'AdminProblemAdd'}) router.push({name: 'AdminProblemAdd'})
@ -142,9 +136,7 @@ watch(()=>ProblemInfoValue.value.id,
options1.value=[] options1.value=[]
queryByPage1(newVal) queryByPage1(newVal)
}) })
let columns let columns = [
if (role[0]=='admin'){
columns = [
{ {
key: 'title', key: 'title',
title: '作业标题', title: '作业标题',
@ -190,88 +182,41 @@ if (role[0]=='admin'){
} }
} }
] ]
}else {
columns = [
{
key: 'name',
title: '班级名称',
width: '260',
},
{
key: 'studentNum',
title: '学生数',
width: '80',
},
{
key: 'createTime',
title: '创建时间',
width: '190',
render: (row) => {
return row["createTime"]=formatDateTime(row["createTime"]);
}
},
{
key: 'inviteCode',
title: '邀请码',
width: '130',
},
{
key: 'actions',
title: '操作',
width: '450',
render(row) {
if(role[0]==='teacher'){
return h(
ProblemActions,
{
onClickStudent: () => onStudentProblem(row),
onClickAssistant: () => onAssistantProblem(row),
onClickEdit: () => onEditProblem(row),
onClickDelete: () => onDeleteProblem(row),
}
);
}
if(role[0]==='assistant'){
return h(
ProblemActions,
{
onClickStudent: () => onStudentProblem(row),
}
);
}
}
}
]
}
const queryByPage = async (currentPage)=>{ const queryByPage = async (currentPage)=>{
loading.value = true; loading.value = true;
try { ProblemInfoValue.value.pageNum=currentPage
ProblemInfoValue.value.pageSize=paginationReactive.pageSize ProblemInfoValue.value.pageSize=paginationReactive.pageSize
const res = await api.findAllProblemPage( try {
{ const res1=await
...ProblemInfoValue.value api.findClassByCourseId({
} courseId:courseId
); })
console.log(res.data) const list1=res1.data
// if (userStore.getRole().some((r) => r === 'admin')){ const transformedDatas=list1.map(item => ({
// const res1=await api.findAllShoolsInAdminusers() label: item.name,
// const list1=res1.data value: item.id,
// const transformedDatas=list1.map(item => ({ }));
// label: item.name, transformedDatas.unshift({
// value: item.id, label: '无',
// })); value: 0,
// transformedDatas.unshift({ });
// label: '全部', options1.value=transformedDatas;
// value: 0,
// });
// options.value=transformedDatas;
// }
const {pageNum, pageSize, total, list} = res.data
paginationReactive.page = pageNum
paginationReactive.pageSize = pageSize
paginationReactive.itemCount = total
ProblemList.value=list.map((item,i)=>{return item;})
// const res = await
// api.findAllProblemByCourseId(
// {
// ...ProblemInfoValue.value,
// courseId:courseId
// }
// );
//
// const {pageNum, pageSize, total, list} = res.data
// paginationReactive.page = pageNum
// paginationReactive.pageSize = pageSize
// paginationReactive.itemCount = total
// ProblemList.value = list.map((item,i)=>{return item;})
// filteredData.value=ProblemList.value
// console.log(ProblemList.value)
} catch (err) { } catch (err) {
} finally { } finally {
loading.value = false; loading.value = false;
@ -313,22 +258,34 @@ const onReviewProblem = async (problemid)=>{
'AdminProblemStudent', 'AdminProblemStudent',
params: {clId: id}}) params: {clId: id}})
} }
const search=async ()=>{ // const search=async ()=>{
loading.value=true // // ProblemInfoRef.value?.validate(async (errors) => {
// // await queryByPage(1)
// // })
// }
const search = async (currentPage)=>{
loading.value = true;
ProblemInfoValue.value.pageNum=currentPage
ProblemInfoValue.value.pageSize=paginationReactive.pageSize
try { try {
if (userStore.getRole().some((r)=>r==='admin')){ const res = await
const res=await api.findAllProblemPage({ api.findAllProblemByCourseIdAndClassId(
...ProblemInfoValue.value {
}) ...ProblemInfoValue.value,
courseId:courseId,
selectedStatus:selectedStatus.value
}
);
const {pageNum, pageSize, total, list} = res.data const {pageNum, pageSize, total, list} = res.data
paginationReactive.page = pageNum paginationReactive.page = pageNum
paginationReactive.pageSize = pageSize paginationReactive.pageSize = pageSize
paginationReactive.itemCount = total paginationReactive.itemCount = total
ProblemList.value = list.map((item,i)=>{return item;}) ProblemList.value = list.map((item,i)=>{return item;})
} filteredData.value=ProblemList.value
// console.log(ProblemList.value)
} catch (err) { } catch (err) {
} finally { } finally {
loading.value=false loading.value = false;
} }
} }
const handleSearchSchool = async (query) => { const handleSearchSchool = async (query) => {
@ -371,8 +328,7 @@ const onChangePage = (page) => {
} }
} }
onMounted(()=>{ onMounted(()=>{
queryByPage() queryByPage(paginationReactive.page)
filteredData.value=ProblemList.value
}) })
watch( watch(
()=>router.currentRoute.value.fullPath, ()=>router.currentRoute.value.fullPath,

View File

@ -62,7 +62,7 @@ const router = useRouter()
const ProblemInfoRef = ref(null) const ProblemInfoRef = ref(null)
const loading = ref(true) const loading = ref(true)
const ProblemList = const ProblemList =
ref([{title:"C++班级",creater:"zlm"}]) ref([])
const options1=ref([]) const options1=ref([])
const role=userStore.getRole() const role=userStore.getRole()
const teacherId=ref() const teacherId=ref()
@ -248,15 +248,9 @@ const onChangePage = (page) => {
onMounted(()=>{ onMounted(()=>{
queryByPage(paginationReactive.page) queryByPage(paginationReactive.page)
}) })
watch( // watch(route, () => {
()=>router.currentRoute.value.fullPath, // queryByPage(); // 路由变化时重新获取数据
()=>{ // });
if
(router.currentRoute.value.fullPath==='/admin/problem/problem-store') {
queryByPage(paginationReactive.page)
}
}
)
</script> </script>
<style> <style>

View File

@ -132,6 +132,9 @@ public class ProblemController {
@PostMapping("/deleteProblem") @PostMapping("/deleteProblem")
public RespBean deleteCourse(@RequestBody PMProblem pmProblem) { public RespBean deleteCourse(@RequestBody PMProblem pmProblem) {
problemServiceI.deleteProblem(pmProblem.getId()); problemServiceI.deleteProblem(pmProblem.getId());
problemServiceI.deleteScoringStandard(pmProblem.getId());
//删除作业时要把发布作业的记录也删除
//那么学生提交该作业的记录也要删除
return RespBean.ok("删除成功"); return RespBean.ok("删除成功");
} }
@PostMapping("/deleteScoringRubric") @PostMapping("/deleteScoringRubric")
@ -146,12 +149,19 @@ public class ProblemController {
} }
@PostMapping("/findAllProblemByCourseId") @PostMapping("/findAllProblemByCourseId")
public RespBean findAllProblemByCourseId(@RequestBody PMProblem pmProblem){ public RespBean findAllProblemByCourseId(@RequestBody PMProblem pmProblem){
if (pmProblem.getPageNum() < 1 || pmProblem.getPageSize() < 1) // if (pmProblem.getPageNum() < 1 || pmProblem.getPageSize() < 1)
return RespBean.error("参数错误!"); // return RespBean.error("参数错误!");
DataGrid dataGrid= DataGrid dataGrid= problemServiceI.findProblemByCourseId(pmProblem);
problemServiceI.findProblemByCourseId(pmProblem);
return RespBean.ok("查询作业库成功",dataGrid); return RespBean.ok("查询作业库成功",dataGrid);
}
@PostMapping(
"/findAllProblemByCourseIdAndClassId")
public RespBean findAllProblemByCourseIdAndClassId(@RequestBody PMProblem pmProblem){
DataGrid dataGrid=
problemServiceI.findProblemByCourseIdAndClassId(pmProblem);
return RespBean.ok("查询作业列表成功",dataGrid);
} }
@PostMapping("/findProblemById") @PostMapping("/findProblemById")
public RespBean findProblemById(@RequestBody PMProblem pmProblem){ public RespBean findProblemById(@RequestBody PMProblem pmProblem){

View File

@ -6,4 +6,6 @@ import com.example.aes.user.dao.BaseDaoI;
public interface PostProblemDaoI extends BaseDaoI<PostProblem> { public interface PostProblemDaoI extends BaseDaoI<PostProblem> {
public void postProblem(PMPostProblem pmPostProblem, Integer classId); public void postProblem(PMPostProblem pmPostProblem, Integer classId);
public long getPostProblemNum(int courseId,
int classId);
} }

View File

@ -13,6 +13,7 @@ import com.example.aes.user.model.PMCourse;
import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaBuilder;
import java.util.List; import java.util.List;
import java.util.Objects;
public interface ProblemDaoI extends BaseDaoI<Problem> { public interface ProblemDaoI extends BaseDaoI<Problem> {
@ -23,6 +24,10 @@ public interface ProblemDaoI extends BaseDaoI<Problem> {
public List<Problem> findProblemIdByTitle(String title); public List<Problem> findProblemIdByTitle(String title);
public void addProblem(Problem problem); public void addProblem(Problem problem);
public long getAllProblemsNum(int courseId); public long getAllProblemsNum(int courseId);
List<Object[]> getProblemsByPage(Integer courseId,
Integer classId,String selectedStatus,
int page, int rows);
List<Problem> getProblemsByPage(Integer courseId,String title, List<Problem> getProblemsByPage(Integer courseId,String title,
int page, int rows); int page, int rows);
public List<Problem> findProblemById(int id); public List<Problem> findProblemById(int id);

View File

@ -9,6 +9,7 @@ import java.util.List;
public interface ScoringStandardDaoI extends BaseDaoI<ScoringStandard> { public interface ScoringStandardDaoI extends BaseDaoI<ScoringStandard> {
public void addScoringStandard(PMScoringStandard pmScoringStandard); public void addScoringStandard(PMScoringStandard pmScoringStandard);
public List<ScoringStandard> getStandardIdNoProblemId(); public List<ScoringStandard> getStandardIdNoProblemId();
public List<ScoringStandard> getStandardIdByProblemId(Integer problemId);
public List<ScoringStandard> getStandardIdNoProblemIdDesc(); public List<ScoringStandard> getStandardIdNoProblemIdDesc();
public void updateProblemId(int problemId); public void updateProblemId(int problemId);
public List<ScoringStandard> getStandardByProblemId(Integer problemId); public List<ScoringStandard> getStandardByProblemId(Integer problemId);

View File

@ -21,4 +21,12 @@ public class PostProblemDaoImpl extends BaseDaoImpl<PostProblem> implements Post
else postProblem.setAllow(0); else postProblem.setAllow(0);
this.save(postProblem); this.save(postProblem);
} }
@Override
public long getPostProblemNum(int courseId,
int classId){
String hql = "select count(*) from " +
"PostProblem where classId="+classId+" and problemId in (select id from Problem where courseId="+courseId+")";
long count=this.count(hql);
return count;
}
} }

View File

@ -11,12 +11,12 @@ import com.example.aes.user.model.Classstudents;
import com.example.aes.user.model.Course; import com.example.aes.user.model.Course;
import com.example.aes.user.model.PMCourse; import com.example.aes.user.model.PMCourse;
import org.hibernate.Query; import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.core.parameters.P; import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -88,6 +88,7 @@ public class ProblemDaoImpl extends BaseDaoImpl<Problem> implements ProblemDaoI{
this.find(hql,page,rows); this.find(hql,page,rows);
return problemList; return problemList;
} }
@Override @Override
public List<Problem> findProblemById(int id){ public List<Problem> findProblemById(int id){
String hql="from Problem where id="+id; String hql="from Problem where id="+id;
@ -116,6 +117,7 @@ public class ProblemDaoImpl extends BaseDaoImpl<Problem> implements ProblemDaoI{
long count=this.count(hql); long count=this.count(hql);
return count; return count;
} }
@Override @Override
public boolean editProblem(String title, public boolean editProblem(String title,
String description,Integer id){ String description,Integer id){
@ -133,4 +135,78 @@ public class ProblemDaoImpl extends BaseDaoImpl<Problem> implements ProblemDaoI{
else else
return false; return false;
} }
@Override
public List<Object[]> getProblemsByPage(Integer courseId, Integer classId,String selectedStatus,
int page,
int rows){
String hql=new String();
if(selectedStatus.equals("")){
hql = "SELECT p.id as id, p.title as title, pp.startTime as startTime, pp.endTime as endTime," +
"COUNT(CASE WHEN sr.score IS NULL AND sr.autoscore IS NOT NULL THEN 1 END) AS daipi," +
"COUNT(CASE WHEN sr.submissionTime IS NOT NULL THEN 1 END) AS yijiao, " +
"COUNT(CASE WHEN sr.submissionTime IS NULL THEN 1 END) AS weijiao " +
"FROM Problem p " +
"INNER JOIN PostProblem pp ON p.id = pp.problemId " +
"LEFT JOIN SubmitReport sr ON " +
"p.id = sr.problemId " +
"WHERE pp.classId =:classId "+
"AND p.courseId =:courseId "+
"GROUP BY p.id, p.title, pp" +
".startTime, pp.endTime";}
else if (selectedStatus.equals("not_started")) {
hql = "SELECT p.id as id, p.title as title, pp.startTime as startTime, pp.endTime as endTime, " +
"COUNT(CASE WHEN sr.score IS NULL AND sr.autoscore IS NOT NULL THEN 1 END) AS daipi, " +
"COUNT(CASE WHEN sr.submissionTime IS NOT NULL THEN 1 END) AS yijiao, " +
"COUNT(CASE WHEN sr.submissionTime IS NULL THEN 1 END) AS weijiao " +
"FROM Problem p " +
"INNER JOIN PostProblem pp ON p.id = pp.problemId " +
"LEFT JOIN SubmitReport sr ON " +
"p.id = sr.problemId " +
"WHERE pp.classId =:classId "+
"AND p.courseId =:courseId "+
"AND NOW() < pp.startTime " +
"GROUP BY p.id, p.title, pp" +
".startTime, pp.endTime";
} else if (selectedStatus.equals("in_progress")) {
hql = "SELECT p.id as id, p.title as title, pp.startTime as startTime, pp.endTime as endTime, " +
"COUNT(CASE WHEN sr.score IS NULL AND sr.autoscore IS NOT NULL THEN 1 END) AS daipi, " +
"COUNT(CASE WHEN sr.submissionTime IS NOT NULL THEN 1 END) AS yijiao, " +
"COUNT(CASE WHEN sr.submissionTime IS NULL THEN 1 END) AS weijiao " +
"FROM Problem p " +
"INNER JOIN PostProblem pp ON p.id = pp.problemId " +
"LEFT JOIN SubmitReport sr ON " +
"p.id = sr.problemId " +
"WHERE pp.classId =:classId "+
"AND p.courseId =:courseId "+
"AND NOW() >= pp.startTime " +
"and NOW()<=pp.endTime " +
"GROUP BY p.id, p.title, pp" +
".startTime, pp.endTime";
}else{
hql = "SELECT p.id as id, p.title as title, pp.startTime as startTime, pp.endTime as endTime, " +
"COUNT(CASE WHEN sr.score IS NULL AND sr.autoscore IS NOT NULL THEN 1 END) AS daipi, " +
"COUNT(CASE WHEN sr.submissionTime IS NOT NULL THEN 1 END) AS yijiao, " +
"COUNT(CASE WHEN sr.submissionTime IS NULL THEN 1 END) AS weijiao " +
"FROM Problem p " +
"INNER JOIN PostProblem pp ON p.id = pp.problemId " +
"LEFT JOIN SubmitReport sr ON " +
"p.id = sr.problemId " +
"WHERE pp.classId =:classId "+
"AND p.courseId =:courseId "+
"AND NOW() > endTime " +
"GROUP BY p.id, p.title, pp" +
".startTime, pp.endTime";
}
Session session =this.getCurrentSession();
Query<Object[]> query = session.createQuery(hql, Object[].class);
query.setParameter("classId", classId);
query.setParameter("courseId", courseId);
// 设置分页
query.setFirstResult((page - 1) * rows); // 计算起始行
query.setMaxResults(rows); // 设置每页行数
return query.getResultList();
}
} }

View File

@ -28,6 +28,13 @@ public class ScoringStandardDaoImpl extends BaseDaoImpl<ScoringStandard> impleme
return this.find(sql); return this.find(sql);
} }
@Override @Override
public List<ScoringStandard> getStandardIdByProblemId(Integer problemId){
String sql="from " +
"ScoringStandard where " +
"problemId="+problemId;
return this.find(sql);
}
@Override
public List<ScoringStandard> getStandardByProblemId(Integer problemId){ public List<ScoringStandard> getStandardByProblemId(Integer problemId){
String sql="from " + String sql="from " +
"ScoringStandard where " + "ScoringStandard where " +

View File

@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
@Data @Data
@ -25,13 +26,17 @@ public class PMProblem extends Problem implements java.io.Serializable{//继承P
// (作业列表)页面上其他需要的属性 // (作业列表)页面上其他需要的属性
private Date startTime;//开始时间,来自postproblem private LocalDateTime startTime;//开始时间,来自postproblem
private Date endTime;//结束时间 private LocalDateTime endTime;//结束时间
private String submissonStatus;//提交状态,来自submitproblem private String submissonStatus;//提交状态,来自submitproblem
private String plagiarismStatus;//查重状态 private String plagiarismStatus;//查重状态
private float score;//最终分数 private float score;//最终分数
private String status;//最后在页面显示的状态,取决于上面三个参数。 private String status;//最后在页面显示的状态,取决于上面三个参数。
private long daipi;
private long yijiao;
private long weijiao;
private String timeRange;
private String selectedStatus;
//(作业列表)页面需要的后台数据 //(作业列表)页面需要的后台数据
private int studentId;//学生id private int studentId;//学生id
private int classId;//班级id private int classId;//班级id

View File

@ -0,0 +1,43 @@
package com.example.aes.problem.model;
import lombok.Data;
import javax.persistence.*;
import java.time.LocalDateTime;
@Data
@Entity
@Table(name = "submitreport",catalog = "aes")
public class SubmitReport {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Integer id;
@Column(name = "problemId")
private int problemId;
@Column(name = "adminuserId")
private int adminuserId;
@Column(name = "studentId")
private int studentId;
@Column(name = "readTime")
private LocalDateTime readTime;
@Column(name = "submissionTime")
private LocalDateTime submissionTime;
@Column(name = "submissionStatus")
private String submissionStatus;
@Column(name = "plagiarismStatus")
private String plagiarismStatus;
@Column(name = "attachment")
private String attachment;
@Column(name = "autoscore")
private Float autoscore;
@Column(name = "autocomment")
private String autocomment;
@Column(name = "score")
private Float score;
@Column(name = "comment")
private String comment;
@Column(name = "addTime")
private LocalDateTime addTime;
}

View File

@ -1,9 +1,6 @@
package com.example.aes.problem.service.Impl; package com.example.aes.problem.service.Impl;
import com.example.aes.problem.dao.PostProblemDaoI; import com.example.aes.problem.dao.*;
import com.example.aes.problem.dao.ProblemDaoI;
import com.example.aes.problem.dao.ScoringRubricDaoI;
import com.example.aes.problem.dao.ScoringStandardDaoI;
import com.example.aes.problem.model.*; import com.example.aes.problem.model.*;
import com.example.aes.problem.service.ProblemServiceI; import com.example.aes.problem.service.ProblemServiceI;
import com.example.aes.user.dao.AdminusersDaoI; import com.example.aes.user.dao.AdminusersDaoI;
@ -11,6 +8,7 @@ import com.example.aes.user.model.DataGrid;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@Service @Service
@ -146,6 +144,18 @@ public class ProblemServiceImpl implements ProblemServiceI {
} }
} }
@Override @Override
public void deleteScoringStandard(Integer problemId){
//先找出无problemid的standrd的list
List<ScoringStandard> scoringStandardList=scoringStandardDao.getStandardIdByProblemId(problemId);
//再根据standardid删掉rubric
for(ScoringStandard scoringStandard:scoringStandardList){
scoringRubricDao.deleteScoringRubricByStandrdId(scoringStandard.getId());
//最后删掉无problemid的standrd
scoringStandardDao.delete(scoringStandard);
}
}
@Override
public String findProblemByTitle(String title){ public String findProblemByTitle(String title){
return problemDao.findProblemByTitle(title); return problemDao.findProblemByTitle(title);
} }
@ -189,6 +199,37 @@ changeModel2(pmProblems,theProblemList);
dg.setPageNum(pmProblem.getPageNum()); dg.setPageNum(pmProblem.getPageNum());
// // 设置当前页的数据行数量 // // 设置当前页的数据行数量
dg.setCurrentPageLineNum(pmProblems.size()); dg.setCurrentPageLineNum(pmProblems.size());
// // 设置当前页的所有数据行
dg.setList(pmProblems);
return dg;
}
}
@Override
public DataGrid findProblemByCourseIdAndClassId(PMProblem pmProblem){
DataGrid dg = new DataGrid();
int totalLines;
List<Object[]> theProblemList;
totalLines= (int) postProblemDao.getPostProblemNum(pmProblem.getCourseId(),pmProblem.getClassId());
int page= pmProblem.getPageNum();
if ((page-1)*pmProblem.getPageSize()>=totalLines){
pmProblem.setPageNum(1);
}
theProblemList=
problemDao.getProblemsByPage(pmProblem.getCourseId(),pmProblem.getClassId(),pmProblem.getSelectedStatus(),pmProblem.getPageNum(), pmProblem.getPageSize());
if (theProblemList== null) {
return null;
} else {
List<PMProblem> pmProblems=new ArrayList<>();
changeModel3(pmProblems,
theProblemList);
dg.setTotal(totalLines);
dg.setPageSize(pmProblem.getPageSize());
dg.setTotalPages((long) (Math.ceil((double) dg.getTotal() / (double) dg.getPageSize())));
// // 设置当前显示第几页
dg.setPageNum(pmProblem.getPageNum());
// // 设置当前页的数据行数量
dg.setCurrentPageLineNum(pmProblems.size());
// // 设置当前页的所有数据行 // // 设置当前页的所有数据行
dg.setList(pmProblems); dg.setList(pmProblems);
return dg; return dg;
@ -239,6 +280,26 @@ changeModel2(pmProblems,theProblemList);
pmProblem.setDescription(problem.getDescription()); pmProblem.setDescription(problem.getDescription());
pmp.add(pmProblem); pmp.add(pmProblem);
}
}
}
private void changeModel3(List<PMProblem> pmp,
List<Object[]> pmp2) {
if (pmp2 != null && pmp2.size() > 0) {
for (Object[] p2 : pmp2) {
PMProblem pmProblem=new PMProblem();
pmProblem.setId((int)p2[0]);
pmProblem.setTitle((String) p2[1]);
pmProblem.setStartTime((LocalDateTime) p2[2]);
pmProblem.setEndTime((LocalDateTime) p2[3]);
pmProblem.setDaipi((Long) p2[4]);
pmProblem.setYijiao((Long) p2[5]);
pmProblem.setWeijiao((Long) p2[6]);
String timeRange=
pmProblem.getStartTime()+"~"+pmProblem.getEndTime();
pmProblem.setTimeRange(timeRange.replace("T", " "));
pmp.add(pmProblem);
} }
} }
} }

View File

@ -28,7 +28,9 @@ public interface ProblemServiceI {
public void updateProblemId(int problemId); public void updateProblemId(int problemId);
public void deleteScoringRubric(); public void deleteScoringRubric();
public void deleteScoringStandard(); public void deleteScoringStandard();
public void deleteScoringStandard(Integer problemId);
public DataGrid findProblemByCourseId(PMProblem pmProblem); public DataGrid findProblemByCourseId(PMProblem pmProblem);
public DataGrid findProblemByCourseIdAndClassId(PMProblem pmProblem);
public List<Problem> findProblemById(int id); public List<Problem> findProblemById(int id);
public void postProblem(PMPostProblem pmPostProblem, Integer classId); public void postProblem(PMPostProblem pmPostProblem, Integer classId);
public void deleteProblem(Integer id); public void deleteProblem(Integer id);

View File

@ -11,21 +11,12 @@ public interface ClassstudentsDaoI extends BaseDaoI<Classstudents> {
public boolean findClassStudentByUserId(int userId, int classId); // 查看该同学是否已在该课程中 public boolean findClassStudentByUserId(int userId, int classId); // 查看该同学是否已在该课程中
boolean findClassInviteCode(String inviteCode);
public int getClassStudentsNum(int classId); // 获取班级的学生人数 public int getClassStudentsNum(int classId); // 获取班级的学生人数
public List<Classstudents> getClassStudentsByExamId(int examId, boolean history); // 获取考试的学生
public List<Classstudents> getClassStudentsByClassId(int classId); public List<Classstudents> getClassStudentsByClassId(int classId);
public boolean findClassesByUserId(int userId); public boolean findClassesByUserId(int userId);
public List<Classstudents> getClassStudentsByExamId(Integer examId);
public long addClassStudent(Classstudents classstudent);
public void deleteClassStudent(int classId, int userId);
public void deleteClassStudent(int id);
} }

View File

@ -45,15 +45,6 @@ public class ClassstudentsDaoImpl extends BaseDaoImpl<Classstudents> implements
return false; return false;
} }
@Override
public boolean findClassInviteCode(String inviteCode){
String hql = "from Classstudents where inviteCode=" + inviteCode;
List<Classstudents> classstudents = this.find(hql);
if(classstudents.size()>0)
return true;
else
return false;
}
@Override @Override
public int getClassStudentsNum(int classId) { // 获取班级学生的总数 public int getClassStudentsNum(int classId) { // 获取班级学生的总数
@ -64,21 +55,7 @@ public class ClassstudentsDaoImpl extends BaseDaoImpl<Classstudents> implements
return countInt(hql, params); return countInt(hql, params);
} }
@Override
public List<Classstudents> getClassStudentsByExamId(int examId, boolean history) {
// TODO Auto-generated method stub
String hql = "";
if(history){
hql = "from Classstudents c where c.classId in (select e.classId from Examclasses_his e where examId="
+ examId + ")";
}
else {
hql = "from Classstudents c where c.classId in (select e.classId from Examclasses e where examId="
+ examId + ")";
}
List<Classstudents> classstudents = this.find(hql);
return classstudents;
}
@Override @Override
public List<Classstudents> getClassStudentsByClassId(int classId) { public List<Classstudents> getClassStudentsByClassId(int classId) {
@ -88,32 +65,5 @@ public class ClassstudentsDaoImpl extends BaseDaoImpl<Classstudents> implements
return classstudents; return classstudents;
} }
@Override
public List<Classstudents> getClassStudentsByExamId(Integer examId) {
String hql = "FROM Classstudents WHERE classId IN (SELECT classId FROM Examclasses WHERE examId = :examId)";
Map<String, Object> params = new HashMap<>();
params.put("examId", examId);
return this.find(hql, params);
}
@Override
public long addClassStudent(Classstudents classstudent) {
this.save(classstudent);
return classstudent.getId();
}
@Override
public void deleteClassStudent(int classId, int userId) {
// 删除考试对应的班级数据
String hql = "delete from Classstudents where classId=" + classId
+ " and userId=" + userId;
this.executeHql(hql);
}
@Override
public void deleteClassStudent(int id) {
// 删除考试对应的班级数据
String hql = "delete from Classstudents where id=" + id;
this.executeHql(hql);
}
} }