作业库完成,作业列表显示完成
This commit is contained in:
parent
01b56e4bf9
commit
d14d16fd37
|
|
@ -86,4 +86,5 @@ export default {
|
|||
findScoringStandardByProblemId: (data) => request.post('/problem/findScoringStandardByProblemId', data),
|
||||
editProblem:(data) => request.post('/problem/editProblem', data),
|
||||
deleteProblem:(data) => request.post('/problem/deleteProblem', data),
|
||||
findAllProblemByCourseIdAndClassId:(data)=>request.post('/problem/findAllProblemByCourseIdAndClassId',data),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import ProblemActions from
|
|||
'./ProblemActions.vue';
|
||||
import {formatDateTime} from '@/utils';
|
||||
import { useUserStore } from '@/store';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
const rules=ref(null)
|
||||
const userStore = useUserStore()
|
||||
const router = useRouter()
|
||||
|
|
@ -42,6 +42,7 @@ const loading = ref(true)
|
|||
const ScoringRubricList =
|
||||
ref([])
|
||||
const role=userStore.getRole()
|
||||
const route = useRoute()
|
||||
const paginationReactive = reactive({
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
|
|
@ -114,15 +115,9 @@ const onChangePage = (page) => {
|
|||
onMounted(()=>{
|
||||
queryByPage()
|
||||
})
|
||||
watch(
|
||||
()=>router.currentRoute.value.fullPath,
|
||||
()=>{
|
||||
if
|
||||
(router.currentRoute.value.fullPath==='/admin/problem/problem-scoring-standard') {
|
||||
queryByPage(paginationReactive.page)
|
||||
}
|
||||
}
|
||||
)
|
||||
watch(route, () => {
|
||||
queryByPage() // 路由变化时重新获取数据
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import ProblemActions from
|
|||
'./ProblemActions.vue';
|
||||
import {formatDateTime} from '@/utils';
|
||||
import { useUserStore } from '@/store';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
const rules=ref(null)
|
||||
const userStore = useUserStore()
|
||||
const router = useRouter()
|
||||
|
|
@ -44,6 +44,7 @@ const ProblemList =
|
|||
const options1=ref([])
|
||||
const role=userStore.getRole()
|
||||
const teacherId=ref()
|
||||
const route = useRoute()
|
||||
const paginationReactive = reactive({
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
|
|
@ -145,15 +146,9 @@ const onChangePage = (page) => {
|
|||
onMounted(()=>{
|
||||
queryByPage()
|
||||
})
|
||||
watch(
|
||||
()=>router.currentRoute.value.fullPath,
|
||||
()=>{
|
||||
if
|
||||
(router.currentRoute.value.fullPath==='/admin/problem/problem-list') {
|
||||
queryByPage(paginationReactive.page)
|
||||
}
|
||||
}
|
||||
)
|
||||
watch(route, () => {
|
||||
queryByPage(); // 路由变化时重新获取数据
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,6 @@ let columns = [
|
|||
]
|
||||
const cancel = ()=>{
|
||||
tagsStore.removeTag(path.value)
|
||||
router.push({path: 'problem-list'})
|
||||
}
|
||||
const onAdd = ()=>{
|
||||
router.push({name: 'AdminProblemScoringStandard'})
|
||||
|
|
|
|||
|
|
@ -16,15 +16,16 @@
|
|||
<n-form-item label="班级:"
|
||||
path="name" Problem="flex-item">
|
||||
<n-select
|
||||
v-model:value="ProblemInfoValue.ProblemId"
|
||||
v-model:value="ProblemInfoValue.classId"
|
||||
:options="options1"
|
||||
@update:value="search"
|
||||
style="min-width: 80px;width: 140px"></n-select>
|
||||
</n-form-item>
|
||||
<n-form-item style="margin-left: 10px">
|
||||
<n-button type="primary" @click="search" style="margin-left: 10px;margin-right: 20px">查询</n-button>
|
||||
</n-form-item>
|
||||
<!-- <n-form-item style="margin-left: 10px">-->
|
||||
<!-- <n-button type="primary" @click="search" style="margin-left: 10px;margin-right: 20px">查询</n-button>-->
|
||||
<!-- </n-form-item>-->
|
||||
<div
|
||||
class="status-options"style='display: flex;gap: 20px'>
|
||||
class="status-options"style='display: flex;gap: 20px;margin-left: 30px'>
|
||||
<label>状态:</label>
|
||||
<label>
|
||||
<input type="radio" value="" v-model="selectedStatus" @change="filterData" />
|
||||
|
|
@ -73,33 +74,24 @@ import ProblemActions from
|
|||
'./components/ProblemActions.vue';
|
||||
import {formatDateTime} from '@/utils';
|
||||
import { useUserStore } from '@/store';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
const rules=ref(null)
|
||||
const userStore = useUserStore()
|
||||
const router = useRouter()
|
||||
const ProblemInfoRef = ref(null)
|
||||
const loading = ref(true)
|
||||
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 role=userStore.getRole()
|
||||
const teacherId=ref()
|
||||
const selectedStatus=ref('')
|
||||
const selectedStatus=ref("")
|
||||
const today = new Date();
|
||||
const filteredData =ref([]);
|
||||
const filterData = () => {
|
||||
if (selectedStatus.value === '') {
|
||||
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 route = useRoute()
|
||||
const { courseId, history } = route.query
|
||||
const filterData =() => {
|
||||
search(paginationReactive.page)
|
||||
};
|
||||
const paginationReactive = reactive({
|
||||
page: 1,
|
||||
|
|
@ -115,6 +107,8 @@ const ProblemInfoValue = ref({
|
|||
pageSize:paginationReactive.pageSize,
|
||||
id:0,
|
||||
teacherId:'',
|
||||
title:"",
|
||||
classId:0
|
||||
});
|
||||
const onAdd = ()=>{
|
||||
router.push({name: 'AdminProblemAdd'})
|
||||
|
|
@ -142,9 +136,7 @@ watch(()=>ProblemInfoValue.value.id,
|
|||
options1.value=[]
|
||||
queryByPage1(newVal)
|
||||
})
|
||||
let columns
|
||||
if (role[0]=='admin'){
|
||||
columns = [
|
||||
let columns = [
|
||||
{
|
||||
key: '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)=>{
|
||||
loading.value = true;
|
||||
ProblemInfoValue.value.pageNum=currentPage
|
||||
ProblemInfoValue.value.pageSize=paginationReactive.pageSize
|
||||
try {
|
||||
ProblemInfoValue.value.pageSize=paginationReactive.pageSize
|
||||
const res = await api.findAllProblemPage(
|
||||
{
|
||||
...ProblemInfoValue.value
|
||||
}
|
||||
);
|
||||
console.log(res.data)
|
||||
// if (userStore.getRole().some((r) => r === 'admin')){
|
||||
// const res1=await api.findAllShoolsInAdminusers()
|
||||
// const list1=res1.data
|
||||
// const transformedDatas=list1.map(item => ({
|
||||
// label: item.name,
|
||||
// value: item.id,
|
||||
// }));
|
||||
// transformedDatas.unshift({
|
||||
// label: '全部',
|
||||
// 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 res1=await
|
||||
api.findClassByCourseId({
|
||||
courseId:courseId
|
||||
})
|
||||
const list1=res1.data
|
||||
const transformedDatas=list1.map(item => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
}));
|
||||
transformedDatas.unshift({
|
||||
label: '无',
|
||||
value: 0,
|
||||
});
|
||||
options1.value=transformedDatas;
|
||||
|
||||
// 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) {
|
||||
} finally {
|
||||
loading.value = false;
|
||||
|
|
@ -313,22 +258,34 @@ const onReviewProblem = async (problemid)=>{
|
|||
'AdminProblemStudent',
|
||||
params: {clId: id}})
|
||||
}
|
||||
const search=async ()=>{
|
||||
loading.value=true
|
||||
// const search=async ()=>{
|
||||
// // 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 {
|
||||
if (userStore.getRole().some((r)=>r==='admin')){
|
||||
const res=await api.findAllProblemPage({
|
||||
...ProblemInfoValue.value
|
||||
})
|
||||
const { pageNum, pageSize, total, list } = res.data
|
||||
paginationReactive.page = pageNum
|
||||
paginationReactive.pageSize = pageSize
|
||||
paginationReactive.itemCount = total
|
||||
ProblemList.value=list.map((item,i)=>{return item;})
|
||||
}
|
||||
}catch (err){
|
||||
}finally {
|
||||
loading.value=false
|
||||
const res = await
|
||||
api.findAllProblemByCourseIdAndClassId(
|
||||
{
|
||||
...ProblemInfoValue.value,
|
||||
courseId:courseId,
|
||||
selectedStatus:selectedStatus.value
|
||||
}
|
||||
);
|
||||
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) {
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
const handleSearchSchool = async (query) => {
|
||||
|
|
@ -371,8 +328,7 @@ const onChangePage = (page) => {
|
|||
}
|
||||
}
|
||||
onMounted(()=>{
|
||||
queryByPage()
|
||||
filteredData.value=ProblemList.value
|
||||
queryByPage(paginationReactive.page)
|
||||
})
|
||||
watch(
|
||||
()=>router.currentRoute.value.fullPath,
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ const router = useRouter()
|
|||
const ProblemInfoRef = ref(null)
|
||||
const loading = ref(true)
|
||||
const ProblemList =
|
||||
ref([{title:"C++班级",creater:"zlm"}])
|
||||
ref([])
|
||||
const options1=ref([])
|
||||
const role=userStore.getRole()
|
||||
const teacherId=ref()
|
||||
|
|
@ -248,15 +248,9 @@ const onChangePage = (page) => {
|
|||
onMounted(()=>{
|
||||
queryByPage(paginationReactive.page)
|
||||
})
|
||||
watch(
|
||||
()=>router.currentRoute.value.fullPath,
|
||||
()=>{
|
||||
if
|
||||
(router.currentRoute.value.fullPath==='/admin/problem/problem-store') {
|
||||
queryByPage(paginationReactive.page)
|
||||
}
|
||||
}
|
||||
)
|
||||
// watch(route, () => {
|
||||
// queryByPage(); // 路由变化时重新获取数据
|
||||
// });
|
||||
</script>
|
||||
<style>
|
||||
|
||||
|
|
|
|||
|
|
@ -132,6 +132,9 @@ public class ProblemController {
|
|||
@PostMapping("/deleteProblem")
|
||||
public RespBean deleteCourse(@RequestBody PMProblem pmProblem) {
|
||||
problemServiceI.deleteProblem(pmProblem.getId());
|
||||
problemServiceI.deleteScoringStandard(pmProblem.getId());
|
||||
//删除作业时要把发布作业的记录也删除
|
||||
//那么学生提交该作业的记录也要删除
|
||||
return RespBean.ok("删除成功");
|
||||
}
|
||||
@PostMapping("/deleteScoringRubric")
|
||||
|
|
@ -146,12 +149,19 @@ public class ProblemController {
|
|||
}
|
||||
@PostMapping("/findAllProblemByCourseId")
|
||||
public RespBean findAllProblemByCourseId(@RequestBody PMProblem pmProblem){
|
||||
if (pmProblem.getPageNum() < 1 || pmProblem.getPageSize() < 1)
|
||||
return RespBean.error("参数错误!");
|
||||
DataGrid dataGrid=
|
||||
problemServiceI.findProblemByCourseId(pmProblem);
|
||||
// if (pmProblem.getPageNum() < 1 || pmProblem.getPageSize() < 1)
|
||||
// return RespBean.error("参数错误!");
|
||||
DataGrid dataGrid= problemServiceI.findProblemByCourseId(pmProblem);
|
||||
return RespBean.ok("查询作业库成功",dataGrid);
|
||||
|
||||
}
|
||||
@PostMapping(
|
||||
"/findAllProblemByCourseIdAndClassId")
|
||||
public RespBean findAllProblemByCourseIdAndClassId(@RequestBody PMProblem pmProblem){
|
||||
DataGrid dataGrid=
|
||||
problemServiceI.findProblemByCourseIdAndClassId(pmProblem);
|
||||
return RespBean.ok("查询作业列表成功",dataGrid);
|
||||
|
||||
}
|
||||
@PostMapping("/findProblemById")
|
||||
public RespBean findProblemById(@RequestBody PMProblem pmProblem){
|
||||
|
|
|
|||
|
|
@ -6,4 +6,6 @@ import com.example.aes.user.dao.BaseDaoI;
|
|||
|
||||
public interface PostProblemDaoI extends BaseDaoI<PostProblem> {
|
||||
public void postProblem(PMPostProblem pmPostProblem, Integer classId);
|
||||
public long getPostProblemNum(int courseId,
|
||||
int classId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import com.example.aes.user.model.PMCourse;
|
|||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public interface ProblemDaoI extends BaseDaoI<Problem> {
|
||||
|
|
@ -23,6 +24,10 @@ public interface ProblemDaoI extends BaseDaoI<Problem> {
|
|||
public List<Problem> findProblemIdByTitle(String title);
|
||||
public void addProblem(Problem problem);
|
||||
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,
|
||||
int page, int rows);
|
||||
public List<Problem> findProblemById(int id);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||
public interface ScoringStandardDaoI extends BaseDaoI<ScoringStandard> {
|
||||
public void addScoringStandard(PMScoringStandard pmScoringStandard);
|
||||
public List<ScoringStandard> getStandardIdNoProblemId();
|
||||
public List<ScoringStandard> getStandardIdByProblemId(Integer problemId);
|
||||
public List<ScoringStandard> getStandardIdNoProblemIdDesc();
|
||||
public void updateProblemId(int problemId);
|
||||
public List<ScoringStandard> getStandardByProblemId(Integer problemId);
|
||||
|
|
|
|||
|
|
@ -21,4 +21,12 @@ public class PostProblemDaoImpl extends BaseDaoImpl<PostProblem> implements Post
|
|||
else postProblem.setAllow(0);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ import com.example.aes.user.model.Classstudents;
|
|||
import com.example.aes.user.model.Course;
|
||||
import com.example.aes.user.model.PMCourse;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.security.core.parameters.P;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
@ -88,6 +88,7 @@ public class ProblemDaoImpl extends BaseDaoImpl<Problem> implements ProblemDaoI{
|
|||
this.find(hql,page,rows);
|
||||
return problemList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Problem> findProblemById(int 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);
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean editProblem(String title,
|
||||
String description,Integer id){
|
||||
|
|
@ -133,4 +135,78 @@ public class ProblemDaoImpl extends BaseDaoImpl<Problem> implements ProblemDaoI{
|
|||
else
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,13 @@ public class ScoringStandardDaoImpl extends BaseDaoImpl<ScoringStandard> impleme
|
|||
return this.find(sql);
|
||||
}
|
||||
@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){
|
||||
String sql="from " +
|
||||
"ScoringStandard where " +
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
|
|
@ -25,13 +26,17 @@ public class PMProblem extends Problem implements java.io.Serializable{//继承P
|
|||
|
||||
|
||||
// (作业列表)页面上其他需要的属性
|
||||
private Date startTime;//开始时间,来自postproblem
|
||||
private Date endTime;//结束时间
|
||||
private LocalDateTime startTime;//开始时间,来自postproblem
|
||||
private LocalDateTime endTime;//结束时间
|
||||
private String submissonStatus;//提交状态,来自submitproblem
|
||||
private String plagiarismStatus;//查重状态
|
||||
private float score;//最终分数
|
||||
private String status;//最后在页面显示的状态,取决于上面三个参数。
|
||||
|
||||
private long daipi;
|
||||
private long yijiao;
|
||||
private long weijiao;
|
||||
private String timeRange;
|
||||
private String selectedStatus;
|
||||
//(作业列表)页面需要的后台数据
|
||||
private int studentId;//学生id
|
||||
private int classId;//班级id
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
package com.example.aes.problem.service.Impl;
|
||||
|
||||
import com.example.aes.problem.dao.PostProblemDaoI;
|
||||
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.dao.*;
|
||||
import com.example.aes.problem.model.*;
|
||||
import com.example.aes.problem.service.ProblemServiceI;
|
||||
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.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@Service
|
||||
|
|
@ -146,6 +144,18 @@ public class ProblemServiceImpl implements ProblemServiceI {
|
|||
}
|
||||
}
|
||||
@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){
|
||||
return problemDao.findProblemByTitle(title);
|
||||
}
|
||||
|
|
@ -189,6 +199,37 @@ changeModel2(pmProblems,theProblemList);
|
|||
dg.setPageNum(pmProblem.getPageNum());
|
||||
// // 设置当前页的数据行数量
|
||||
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);
|
||||
return dg;
|
||||
|
|
@ -239,6 +280,26 @@ changeModel2(pmProblems,theProblemList);
|
|||
pmProblem.setDescription(problem.getDescription());
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@ public interface ProblemServiceI {
|
|||
public void updateProblemId(int problemId);
|
||||
public void deleteScoringRubric();
|
||||
public void deleteScoringStandard();
|
||||
public void deleteScoringStandard(Integer problemId);
|
||||
public DataGrid findProblemByCourseId(PMProblem pmProblem);
|
||||
public DataGrid findProblemByCourseIdAndClassId(PMProblem pmProblem);
|
||||
public List<Problem> findProblemById(int id);
|
||||
public void postProblem(PMPostProblem pmPostProblem, Integer classId);
|
||||
public void deleteProblem(Integer id);
|
||||
|
|
|
|||
|
|
@ -11,21 +11,12 @@ public interface ClassstudentsDaoI extends BaseDaoI<Classstudents> {
|
|||
|
||||
public boolean findClassStudentByUserId(int userId, int classId); // 查看该同学是否已在该课程中
|
||||
|
||||
boolean findClassInviteCode(String inviteCode);
|
||||
|
||||
public int getClassStudentsNum(int classId); // 获取班级的学生人数
|
||||
|
||||
public List<Classstudents> getClassStudentsByExamId(int examId, boolean history); // 获取考试的学生
|
||||
|
||||
public List<Classstudents> getClassStudentsByClassId(int classId);
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,15 +45,6 @@ public class ClassstudentsDaoImpl extends BaseDaoImpl<Classstudents> implements
|
|||
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
|
||||
public int getClassStudentsNum(int classId) { // 获取班级学生的总数
|
||||
|
|
@ -64,21 +55,7 @@ public class ClassstudentsDaoImpl extends BaseDaoImpl<Classstudents> implements
|
|||
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
|
||||
public List<Classstudents> getClassStudentsByClassId(int classId) {
|
||||
|
|
@ -88,32 +65,5 @@ public class ClassstudentsDaoImpl extends BaseDaoImpl<Classstudents> implements
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue