Sfoglia il codice sorgente

update:修改课程教学管理的ThemeInfoVO数据结构

guochao 5 anni fa
parent
commit
87f032c3e2

+ 1 - 1
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/ctrl/ThemeController.java

@@ -229,7 +229,7 @@ public class ThemeController extends BaseSearchController {
      */
 //    @RequiresPermissions("assignedTasks:view")
     @RequestMapping(value = UrlConstants.API + "theme/result/{themeId}", method = RequestMethod.GET)
-    public List<ThemeInfoVO> getScoreListByExamId(@PathVariable(name = "themeId") Long themeId) throws Exception {
+    public ThemeInfoVO getScoreListByExamId(@PathVariable(name = "themeId") Long themeId) throws Exception {
         Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
         String examPermissionStr = userId.toString() + ":task:view:" + themeId.toString();
         if (!SecurityUtils.getSubject().isPermitted(new ExamPermission(examPermissionStr))) {

+ 19 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/data/ExamResultVO.java

@@ -0,0 +1,19 @@
+package cn.iselab.mooctest.site.web.data;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+/**
+ * @author guochao
+ * @date 2020-02-12 17:13
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class ExamResultVO {
+    private ExamVO examVO;
+    private List<Double> scoreList;
+}

+ 10 - 8
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/data/ThemeInfoVO.java

@@ -1,7 +1,10 @@
 package cn.iselab.mooctest.site.web.data;
 
 import cn.iselab.mooctest.site.models.Exam;
+import cn.iselab.mooctest.site.models.ThemeDetail;
+import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import java.util.List;
 
@@ -10,13 +13,12 @@ import java.util.List;
  * @date 2020-02-12 16:31
  */
 @Data
+@NoArgsConstructor
+@AllArgsConstructor
 public class ThemeInfoVO {
-
-    private ExamVO examVO;
-    private List<Double> scoreList;
-
-    public ThemeInfoVO(ExamVO examVO, List<Double> scoreList) {
-        this.examVO = examVO;
-        this.scoreList = scoreList;
-    }
+    private ThemeDetailVO themeDetailVO;
+    private int studentNum;
+    private int learningCompletedRate;
+    private int ExamCompletedRate;
+    private List<ExamResultVO> examResultVOList;
 }

+ 1 - 1
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/logic/ThemeLogic.java

@@ -64,5 +64,5 @@ public interface ThemeLogic{
 
     CourseResourceVO getCourseResourceById(long resourceId);
 
-    List<ThemeInfoVO> getThemeInfoByThemeId(Long themeId);
+    ThemeInfoVO getThemeInfoByThemeId(Long themeId);
 }

+ 10 - 4
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/logic/impl/ThemeLogicImpl.java

@@ -386,8 +386,13 @@ public class ThemeLogicImpl implements ThemeLogic {
     }
 
     @Override
-    public List<ThemeInfoVO> getThemeInfoByThemeId(Long themeId) {
-        List<ThemeInfoVO> themeInfoVOList = new ArrayList<>();
+    public ThemeInfoVO getThemeInfoByThemeId(Long themeId) {
+        ThemeInfoVO themeInfoVO = new ThemeInfoVO();
+        ThemeDetail themeDetail = themeService.getThemeDetailById(themeId);
+        ThemeDetailVO themeDetailVO = themeVOWrapper.wrapperThemeDetail(themeDetail);
+        themeInfoVO.setThemeDetailVO(themeDetailVO);
+        themeInfoVO.setStudentNum(examVOWrapper.wrapExamFrom(examService.getTask(themeDetailVO.getGroupId())).getParticipantCount());
+        List<ExamResultVO> examResultVOS = new ArrayList<>();
         List<ThemeEntityRelations> themeEntityRelations = themeService.getThemeEntityRelations(themeId).stream()
                 .filter(entityRelation -> entityRelation.getEntityType() == EntityTypeEnum.EXAM).collect(Collectors.toList());
         for(ThemeEntityRelations relation : themeEntityRelations){
@@ -397,8 +402,9 @@ public class ThemeLogicImpl implements ThemeLogic {
                 throw new HttpNotFoundException("exam doesn't exists");
             }
             ExamVO examVO = examVOWrapper.wrapExamFrom(exam);
-            themeInfoVOList.add(new ThemeInfoVO(examVO, scoreList));
+            examResultVOS.add(new ExamResultVO(examVO, scoreList));
         }
-        return themeInfoVOList;
+        themeInfoVO.setExamResultVOList(examResultVOS);
+        return themeInfoVO;
     }
 }