diff --git a/ruoyi-exam/src/main/java/com/ruoyi/exam/controller/ExamQuestionController.java b/ruoyi-exam/src/main/java/com/ruoyi/exam/controller/ExamQuestionController.java index ce8551a33..f7e462995 100644 --- a/ruoyi-exam/src/main/java/com/ruoyi/exam/controller/ExamQuestionController.java +++ b/ruoyi-exam/src/main/java/com/ruoyi/exam/controller/ExamQuestionController.java @@ -1,7 +1,11 @@ package com.ruoyi.exam.controller; +import java.util.ArrayList; import java.util.Enumeration; import java.util.List; + +import com.ruoyi.exam.domain.ExamQuestionCategory; +import com.ruoyi.exam.service.IExamQuestionCategoryService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -31,6 +35,9 @@ public class ExamQuestionController extends BaseController @Autowired private IExamQuestionService examQuestionService; + + @Autowired + private IExamQuestionCategoryService examQuestionCategoryService; @RequiresPermissions("exam:examQuestion:view") @GetMapping() @@ -71,8 +78,28 @@ public class ExamQuestionController extends BaseController @ResponseBody public TableDataInfo list(ExamQuestion examQuestion) { - List list = examQuestionService.selectExamQuestionList(examQuestion); - return getDataTable(list); + ArrayList objects = new ArrayList<>(); + List listByIds = getListByIds(objects, examQuestion); + return getDataTable(listByIds); + } + + /** + * 递归找到所有下级的题目 + * @param list + * @param examQuestion + * @return + */ + private List getListByIds(List list,ExamQuestion examQuestion){ + list.addAll(examQuestionService.selectExamQuestionList(examQuestion)); + String categoryId = examQuestion.getCategoryId(); + ExamQuestionCategory examQuestionCategory = new ExamQuestionCategory(); + examQuestionCategory.setParentId(Long.parseLong(categoryId)); + List examQuestionCategories = examQuestionCategoryService.selectList(examQuestionCategory); + for (ExamQuestionCategory questionCategory : examQuestionCategories) { + examQuestion.setCategoryId(questionCategory.getId().toString()); + getListByIds(list,examQuestion); + } + return list; } diff --git a/ruoyi-exam/src/main/resources/templates/exam/examQuestion/examQuestion.html b/ruoyi-exam/src/main/resources/templates/exam/examQuestion/examQuestion.html index 9a28602ca..1afe8c19c 100644 --- a/ruoyi-exam/src/main/resources/templates/exam/examQuestion/examQuestion.html +++ b/ruoyi-exam/src/main/resources/templates/exam/examQuestion/examQuestion.html @@ -36,7 +36,7 @@
- +
  • @@ -97,9 +97,9 @@ $(function () { $('body').layout({west__size: 185}); - $("#categoryId").val(0); queryExamQuestionList(); -// $.table.search(); + $("#categoryId").val(1); + $.table.search(); queryExamQuestionCategoryTree(); }); @@ -116,21 +116,11 @@ columns: [{ checkbox: true }, - { - field: 'id', - title: 'ID', - sortable: true - }, { field: 'title', title: '问题标题', sortable: true }, - { - field: 'answer', - title: '问题答案', - sortable: true - }, { field: 'type', title: '问题类型', @@ -151,19 +141,9 @@ title: '创建时间', sortable: true }, - { - field: 'updateBy', - title: '更新者', - sortable: true - }, - { - field: 'updateDate', - title: '更新时间', - sortable: true - }, { field: 'remarks', - title: '备注信息', + title: '答案解析', sortable: true }, { @@ -190,9 +170,6 @@ $.tree.init(options); function zOnClick(event, treeId, treeNode) { -// if(treeNode.pId == 1 || treeNode.pId == 0 ||treeNode.pId == null) { -// return; -// } $("#categoryId").val(treeNode.id); $.table.search(); } @@ -222,27 +199,24 @@ } function addChoiceQuestion(){ - if($("#categoryId").val() == null||$("#categoryId").val() == ''||$("#categoryId").val() == 1 || $("#categoryId").val() == 0 ){ - alert("请选择题库!") - return; + if(!$.tree.notAllowParents($._tree)){ + return ; } var url = prefix + "/choiceadd/"+$("#categoryId").val(); $.operate.jumpModeltoUrl("添加单选题",url); } function addMoreChoiceQuestion(){ - if($("#categoryId").val() == null||$("#categoryId").val() == ''||$("#categoryId").val() == 1 || $("#categoryId").val() == 0 ){ - alert("请选择题库!") - return; + if(!$.tree.notAllowParents($._tree)){ + return ; } var url = prefix + "/morechoiceadd/"+$("#categoryId").val(); $.operate.jumpModeltoUrl("添加多选题",url); } function addJudgeQuestion(){ - if($("#categoryId").val() == null||$("#categoryId").val() == ''||$("#categoryId").val() == 1 || $("#categoryId").val() == 0 ){ - alert("请选择题库!") - return; + if(!$.tree.notAllowParents($._tree)){ + return ; } var url = prefix + "/judgeadd/"+$("#categoryId").val(); $.operate.jumpModeltoUrl("添加多选题",url);