完成作业库列表显示和查找作业标题的接口

This commit is contained in:
zlm133588 2025-03-20 22:51:42 +08:00
parent 0299363867
commit 8781cf1f92
19 changed files with 214 additions and 129 deletions

View File

@ -77,4 +77,7 @@ export default {
addProblem:(data) => request.post('/problem/addProblem', data),
findClassById: (data) => request.post('/classes/findClassById', data),
editClassMessage: (data) => request.post('/classes/editClassMessage', data),
deleteScoringRubric:(data)=>request.post('/problem/deleteScoringRubric',data),
deleteScoringStandard:(data)=>request.post('/problem/deleteScoringStandard',data),
findAllProblemByCourseId:(data)=>request.post('/problem/findAllProblemByCourseId',data),
}

View File

@ -175,8 +175,10 @@ const onAddProblem= async (courseId)=>{
'AdminProblemAdd', query: { courseId: id
} })
}
const onProblemStore= ()=>{
router.push({name: 'AdminProblemStore'})
const onProblemStore=async (courseId)=>{
const { id } = courseId
await router.push({name: 'AdminProblemStore',
query: { courseId: id}})
}
const rowKey = (rowData) => {
return rowData.id

View File

@ -42,6 +42,15 @@ const loading = ref(true)
const ScoringRubricList =
ref([])
const role=userStore.getRole()
const paginationReactive = reactive({
page: 1,
pageSize: 50,
showSizePicker: true,
pageSizes: [50, 100,150],
prefix ({ itemCount }) {
return `总共 ${itemCount} 条`
}
})
let columns = [
{
key: 'range',
@ -110,7 +119,7 @@ watch(
()=>{
if
(router.currentRoute.value.fullPath==='/admin/problem/problem-scoring-standard') {
queryByPage()
queryByPage(paginationReactive.page)
}
}
)

View File

@ -50,7 +50,6 @@
</template>
<script setup>
import { useRoute, useRouter } from 'vue-router'
import {ref} from "vue";
import api from "@/api/admin";
import { useTagsStore } from '@/store'
@ -58,6 +57,7 @@ import StandardsList
from '@/views/admin/problem/components/StandardList.vue'
import RichTextEditor
from '@/components/common/RichTextEditor.vue'
import { useRoute, useRouter } from 'vue-router'
const tagsStore = useTagsStore()
const path=ref('')
const router = useRouter()
@ -72,12 +72,13 @@ const problemInfoValue = ref({
const problemInfoRef = ref(null)
const descEditorHeight = ref('160px')
const cancel = ()=>{
const cancel = async () => {
await api.deleteScoringStandard({})
tagsStore.removeTag(path.value)
router.push({path: 'problem-list'})
}
const onAdd = ()=>{
router.push({name: 'AdminProblemScoringStandard'})
router.push({name:
'AdminProblemScoringStandard',query:{courseId:courseId}})
}
const submit =async ()=> {
if (problemInfoValue.value.title !== '' && problemInfoValue.value.description !== '') {
@ -89,10 +90,10 @@ const submit =async ()=> {
})
$message.success("添加作业成功")
tagsStore.removeTag(path.value)
await router.push({ name: 'AdminProblemList' })
// await router.push({ name: 'AdminProblemList' })
} catch (err) {
tagsStore.removeTag(path.value)
await router.push({ name: 'AdminProblemList' })
// await router.push({ name: 'AdminProblemList' })
}
} else if (problemInfoValue.value.title == "") {
$message.error("作业名称不能为空")

View File

@ -58,10 +58,12 @@
</template>
<script setup>
import {useRouter} from "vue-router";
import { useRoute, useRouter } from 'vue-router'
import {ref} from "vue";
import api from "@/api/admin";
import { useTagsStore } from '@/store'
const route = useRoute()
const { courseId, history } = route.query
import RichTextEditor
from '@/components/common/RichTextEditor.vue'
import { once } from '@/utils'
@ -81,10 +83,7 @@ const handleDescEditorFocus = once(() => {
})
const cancel = ()=>{
tagsStore.removeTag(path.value)
router.push({path: 'problem-scoring-standard'})
}
const onAdd = ()=>{
router.push({name: 'AdminProblemScoringRubric'})
router.push({path: 'problem-scoring-standard',query:{courseId:courseId}})
}
const submit =async ()=>{
if(problemInfoValue.value.lowerLimit!==''&&problemInfoValue.value.upperLimit!==''&&problemInfoValue.value.description!==''){
@ -94,10 +93,10 @@ const submit =async ()=>{
})
$message.success("添加评分细则成功")
tagsStore.removeTag(path.value)
await router.push({name: 'AdminProblemScoringStandard'})
await router.push({name: 'AdminProblemScoringStandard',query:{courseId:courseId}})
} catch (err) {
tagsStore.removeTag(path.value)
await router.push({name: 'AdminProblemScoringStandard'})
await router.push({name: 'AdminProblemScoringStandard',query:{courseId:courseId}})
}
}else {
$message.error("评分细则不能为空")

View File

@ -51,14 +51,14 @@
</template>
<script setup>
import {useRouter} from "vue-router";
import { useRoute, useRouter } from 'vue-router'
import { onMounted, ref } from 'vue'
import api from "@/api/admin";
import { useTagsStore } from '@/store'
import RubricList from
'@/views/admin/problem/components/RubricList.vue'
import RichTextEditor
from '@/components/common/RichTextEditor.vue'
const route = useRoute()
const { courseId, history } = route.query
const tagsStore = useTagsStore()
const path=ref('')
const router = useRouter()
@ -70,11 +70,15 @@ const ScoringStandardInfoValue = ref({
});
const problemInfoRef = ref(null)
const cancel = ()=>{
const cancel = async () => {
await api.deleteScoringRubric({})
tagsStore.removeTag(path.value)
await router.push({name:
'AdminProblemAdd',query:{courseId:courseId}})
}
const onAdd = ()=>{
router.push({name: 'AdminProblemScoringRubric'})
router.push({name:
'AdminProblemScoringRubric',query:{courseId:courseId}})
}
const submit =async ()=>{
if(ScoringStandardInfoValue.value.dimension!==''&&ScoringStandardInfoValue.value.weight!==''){
@ -84,10 +88,15 @@ const submit =async ()=>{
})
$message.success("添加评分标准成功")
tagsStore.removeTag(path.value)
await router.push({name: 'AdminProblemAdd'})
await router.push({name:
'AdminProblemAdd', query: {
courseId: courseId
}})
} catch (err) {
tagsStore.removeTag(path.value)
await router.push({name: 'AdminProblemAdd'})
await router.push({name: 'AdminProblemAdd', query: {
courseId: courseId
}})
}
}else {
$message.error("维度或权重不能为空")

View File

@ -16,7 +16,7 @@
class="flex-item"
style="margin-left: -30px">
<n-input
v-model:value="ProblemInfoValue.ProblemId"
v-model:value="ProblemInfoValue.title"
style="min-width: 80px" placeholder=""></n-input>
</n-form-item>
<n-form-item style="margin-left: 20px">
@ -56,9 +56,11 @@ 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'
import ProblemActions2
from '@/views/admin/problem/components/ProblemActions2.vue'
import problem
from '@/views/user/problem/index.vue'
const rules=ref(null)
const userStore = useUserStore()
const router = useRouter()
@ -69,6 +71,8 @@ const ProblemList =
const options1=ref([])
const role=userStore.getRole()
const teacherId=ref()
const route = useRoute()
const { courseId, history } = route.query
const paginationReactive = reactive({
page: 1,
pageSize: 50,
@ -83,6 +87,7 @@ const ProblemInfoValue = ref({
pageSize:paginationReactive.pageSize,
id:0,
teacherId:'',
title:""
});
const onAdd = ()=>{
router.push({name: 'AdminProblemAdd'})
@ -110,9 +115,7 @@ watch(()=>ProblemInfoValue.value.id,
options1.value=[]
queryByPage1(newVal)
})
let columns
if (role[0]=='admin'){
columns = [
let columns = [
{
key: 'title',
title: '作业标题',
@ -120,7 +123,7 @@ if (role[0]=='admin'){
},
{
key: 'creater',
key: 'teacherName',
title: '创建者',
width: '60',
align:'center'
@ -143,93 +146,37 @@ 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(
ProblemActions2,
{
onClickStudent: () => onStudentProblem(row),
onClickAssistant: () => onAssistantProblem(row),
onClickEdit: () => onEditProblem(row),
onClickDelete: () => onDeleteProblem(row),
}
);
}
if(role[0]==='assistant'){
return h(
ProblemActions2,
{
onClickStudent: () => onStudentProblem(row),
}
);
}
}
}
]
}
const queryByPage = async (currentPage)=>{
loading.value = true;
try {
ProblemInfoValue.value.pageNum=currentPage
ProblemInfoValue.value.pageSize=paginationReactive.pageSize
const res = await api.findAllProblemPage(
try {
const res = await
api.findAllProblemByCourseId(
{
...ProblemInfoValue.value
...ProblemInfoValue.value,
courseId:courseId
}
);
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;})
ProblemList.value =
list.map((item,i)=>{return item;})
} catch (err) {
} finally {
loading.value = false;
}
}
const search=async ()=>{
ProblemInfoRef.value?.validate(async (errors) => {
await queryByPage(1)
})
}
const onDeleteProblem = async (problemid)=>{
const {id} = problemid
try {
@ -263,24 +210,7 @@ const onPostProblem = async (problemid)=>{
await router.push({name: 'AdminProblemPost',
params: {clId: id}})
}
const search=async ()=>{
loading.value=true
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 handleSearchSchool = async (query) => {
const res = await api.getSchoolByschoolName({
name: query,
@ -321,7 +251,7 @@ const onChangePage = (page) => {
}
}
onMounted(()=>{
queryByPage()
queryByPage(paginationReactive.page)
})
watch(
()=>router.currentRoute.value.fullPath,

View File

@ -159,6 +159,7 @@ export default {
{
name: 'AdminProblemTest',
path: 'problem-test',
isHidden: true,
component: () => import('@/views/admin/problem/test.vue'),
meta: {
title: '测试页',

View File

@ -10,8 +10,9 @@ import com.example.aes.user.service.ClassesServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import com.example.aes.user.model.DataGrid;
import javax.servlet.http.HttpServletRequest;
import javax.swing.event.ListDataEvent;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -95,6 +96,25 @@ public class ProblemController {
return RespBean.error("获取评分标准列表失败!");
}
}
@PostMapping("/deleteScoringRubric")
public RespBean deleteScoringRubric(){
problemServiceI.deleteScoringRubric();
return RespBean.ok("删除评分细则成功");
}
@PostMapping("/deleteScoringStandard")
public RespBean deleteScoringStandrd(){
problemServiceI.deleteScoringStandard();
return RespBean.ok("删除评分标准成功");
}
@PostMapping("/findAllProblemByCourseId")
public RespBean findAllProblemByCourseId(@RequestBody PMProblem pmProblem){
if (pmProblem.getPageNum() < 1 || pmProblem.getPageSize() < 1)
return RespBean.error("参数错误!");
DataGrid dataGrid=
problemServiceI.findProblemByCourseId(pmProblem);
return RespBean.ok("查询作业库成功",dataGrid);
}
//获取作业列表
@GetMapping("/getExamList")

View File

@ -6,9 +6,11 @@ import com.example.aes.problem.model.PMScoringRubric;
import com.example.aes.problem.model.Problem;
import com.example.aes.user.dao.BaseDaoI;
import com.example.aes.user.model.Classstudents;
import com.example.aes.user.model.Course;
import com.example.aes.user.model.PMCourse;
import javax.persistence.criteria.CriteriaBuilder;
import java.util.List;
@ -18,6 +20,8 @@ public interface ProblemDaoI extends BaseDaoI<Problem> {
public String findProblemByTitle(String title);
public List<Problem> findProblemIdByTitle(String title);
public void addProblem(Problem problem);
public long getAllProblemsNum(int courseId);
List<Problem> getProblemsByPage(Integer courseId,String title,
int page, int rows);
}

View File

@ -10,5 +10,7 @@ public interface ScoringRubricDaoI extends BaseDaoI<ScoringRubric> {
public void addScoringRubric(PMScoringRubric pmScoringRubric);
public List<ScoringRubric> getScoringRubricNoStandardId();
public void updateStandardId(Integer standardId);
public void deleteScoringRubric();
public void deleteScoringRubricByStandrdId(Integer standardId);
public List<ScoringRubric> getScoringRubricByStandardId(Integer standardId);
}

View File

@ -1,5 +1,6 @@
package com.example.aes.problem.dao.impl;
import cn.hutool.poi.excel.cell.CellSetter;
import com.example.aes.problem.dao.ProblemDaoI;
import com.example.aes.problem.model.PMProblem;
import com.example.aes.problem.model.PMScoringRubric;
@ -12,9 +13,11 @@ import com.example.aes.user.model.PMCourse;
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;
@Repository("ProblemDao")
public class ProblemDaoImpl extends BaseDaoImpl<Problem> implements ProblemDaoI{
@ -61,6 +64,18 @@ public class ProblemDaoImpl extends BaseDaoImpl<Problem> implements ProblemDaoI{
List<Problem> problemList = this.find(hql);
return problemList;
}
@Override
public List<Problem> getProblemsByPage(Integer courseId,String title,
int page,
int rows){
String hql="from Problem where courseId=" +
courseId+" and title like '%"+title+
"%'";
List<Problem> problemList =
this.find(hql,page,rows);
return problemList;
}
@Override
public void addProblem(Problem problem) {
// TODO Auto-generated method stub
@ -71,4 +86,11 @@ public class ProblemDaoImpl extends BaseDaoImpl<Problem> implements ProblemDaoI{
problem1.setDescription(problem.getDescription());
this.save(problem1);
}
@Override
public long getAllProblemsNum(int courseId){
String hql = "select count(*) from " +
"Problem where courseId="+courseId;
long count=this.count(hql);
return count;
}
}

View File

@ -43,4 +43,18 @@ public class ScoringRubricDaoImpl extends BaseDaoImpl<ScoringRubric> implements
this.find(hql);
return scoringRubricList;
}
@Override
public void deleteScoringRubric(){
String hql =
"delete from ScoringRubric where" +
" standardId is null";
this.executeHql(hql);
}
@Override
public void deleteScoringRubricByStandrdId(Integer standardId){
String hql =
"delete from ScoringRubric where" +
" standardId="+standardId;
this.executeHql(hql);
}
}

View File

@ -21,6 +21,7 @@ public class PMProblem extends Problem implements java.io.Serializable{//继承P
// 作业列表分页exam
private int pageNum;
private int pageSize;
private String teacherName;
// (作业列表)页面上其他需要的属性

View File

@ -1,10 +1,4 @@
package com.example.aes.problem.model;
import lombok.Data;
@Data
public class UProblem {
private String title;
private String description;
private int courseId;
}

View File

@ -5,10 +5,8 @@ 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.service.ProblemServiceI;
import com.example.aes.user.model.Course;
import com.example.aes.user.dao.AdminusersDaoI;
import com.example.aes.user.model.DataGrid;
import com.example.aes.user.model.PMCourse;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -20,6 +18,12 @@ public class ProblemServiceImpl implements ProblemServiceI {
private ProblemDaoI problemDao;
private ScoringRubricDaoI scoringRubricDao;
private ScoringStandardDaoI scoringStandardDao;
private AdminusersDaoI adminusersDao;
@Autowired
public void setAdminusersDao(AdminusersDaoI adminusersDao) {
this.adminusersDao = adminusersDao;
}
@Autowired
public void setScoringStandardDao(ScoringStandardDaoI scoringStandardDao) {
this.scoringStandardDao = scoringStandardDao;
@ -99,6 +103,21 @@ public class ProblemServiceImpl implements ProblemServiceI {
scoringStandardDao.updateProblemId(problemId);
}
@Override
public void deleteScoringRubric(){
scoringRubricDao.deleteScoringRubric();
}
@Override
public void deleteScoringStandard(){
//先找出无problemid的standrd的list
List<ScoringStandard> scoringStandardList=scoringStandardDao.getStandardIdNoProblemId();
//再根据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);
}
@ -109,6 +128,35 @@ public class ProblemServiceImpl implements ProblemServiceI {
}
@Override
public DataGrid findProblemByCourseId(PMProblem pmProblem){
DataGrid dg = new DataGrid();
int totalLines;
List<Problem> theProblemList;
totalLines=
(int) problemDao.getAllProblemsNum(pmProblem.getCourseId());
int page= pmProblem.getPageNum();
if ((page-1)*pmProblem.getPageSize()>=totalLines){
pmProblem.setPageNum(1);
} theProblemList =
problemDao.getProblemsByPage(pmProblem.getCourseId(),pmProblem.getTitle(),pmProblem.getPageNum(), pmProblem.getPageSize());
if (theProblemList == null) {
return null;
} else {
List<PMProblem> pmProblems=new ArrayList<>();
changeModel2(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;
}
}
@Override
public void addProblem(Problem problem) {
// TODO Auto-generated method stub
problemDao.addProblem(problem);
@ -126,4 +174,20 @@ public class ProblemServiceImpl implements ProblemServiceI {
}
}
}
private void changeModel2(List<PMProblem> pmp,
List<Problem> p) {
if (p != null && p.size() > 0) {
for (Problem problem : p) {
PMProblem pmProblem=new PMProblem();
pmProblem.setId(problem.getId());
pmProblem.setCourseId(problem.getCourseId());
pmProblem.setAdminuserId(problem.getAdminuserId());
pmProblem.setTeacherName(adminusersDao.findTeacherNameByTeacherId(problem.getAdminuserId()));
pmProblem.setTitle(problem.getTitle());
pmProblem.setDescription(problem.getDescription());
pmp.add(pmProblem);
}
}
}
}

View File

@ -19,5 +19,8 @@ public interface ProblemServiceI {
public List<Problem> findProblemIdByTitle(String title);
public void addProblem(Problem problem);
public void updateProblemId(int problemId);
public void deleteScoringRubric();
public void deleteScoringStandard();
public DataGrid findProblemByCourseId(PMProblem pmProblem);
}

View File

@ -35,4 +35,5 @@ public interface AdminusersDaoI extends BaseDaoI<Adminusers> {
public long getAssistantNotBelongClassNum(int classId,
String account, String name, String email, String no);
public String findTeacherNameByTeacherId(int teacherId);
}

View File

@ -446,4 +446,10 @@ public class AdminusersDaoImpl extends BaseDaoImpl<Adminusers> implements
q.setParameter("no", "%" + no + "%");
return q.list().size();
}
@Override
public String findTeacherNameByTeacherId(int teacherId){
String hql=
"from Adminusers where id="+teacherId;
return this.find(hql).get(0).getName();
}
}