فهرست منبع

fix:状态判断

xuexiaobo 4 سال پیش
والد
کامیت
475d855c0b

+ 1 - 1
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/dao/PaperDao.java

@@ -20,7 +20,7 @@ import java.util.List;
 public interface PaperDao extends PagingAndSortingRepository<Paper, Long>, JpaSpecificationExecutor<Paper>, UpdateAdapter<Paper, Long> {
 
     @Query("select p from Paper p where p.isDeleted = false and p.id = :paperId")
-    Paper findById(long paperId);
+    Paper findById(@Param("paperId") long paperId);
 
     @Query("select p from Paper p,Paper2Case t2c where t2c.caseId=:caseId and t2c.paperId=p.id and p.isDeleted=false and p.isPublic=true ")
     Page<Paper> findByCaseId(@Param("caseId") Long caseId, Pageable pageable);

+ 2 - 2
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/ctrl/PaperController.java

@@ -57,14 +57,14 @@ public class PaperController extends BaseSearchController{
         String permissionStr = userId.toString() + ":paper:*:" + paperId.toString();
         boolean isOwner = SecurityUtils.getSubject().isPermitted(new PaperPermission(permissionStr));
         boolean isAdmin = roleLogic.isAdmin(userId);
-        boolean isStudentFromExam = (examId == null);
+        boolean isStudentFromExam = (examId != null);
         if (!isOwner && !isAdmin && !isStudentFromExam) {
             throw new UnauthenticatedException("forbidden");
         }
 
         // 试卷在考试开始前的同学应该看不到
-        ExamVO exam = examLogic.getExamByIdAndParticipantIdIfPermited(examId, userId);
         if (isStudentFromExam) {
+            ExamVO exam = examLogic.getExamByIdAndParticipantIdIfPermited(examId, userId);
             if (exam.getStatus().equals(Exam.STATUS_UPCOMING)) {
                 throw new UnauthenticatedException("forbidden");
             }