diff --git a/src/Handler/Tutorial/Users.hs b/src/Handler/Tutorial/Users.hs index 477bf4b5d..58cda967a 100644 --- a/src/Handler/Tutorial/Users.hs +++ b/src/Handler/Tutorial/Users.hs @@ -96,7 +96,7 @@ postTUsersR tid ssh csh tutn = do let croute = CTutorialR tid ssh csh tutn TUsersR now <- liftIO getCurrentTime isAdmin <- hasReadAccessTo AdminR - (cid, Entity tutid tut@Tutorial{..}, (participantRes, participantTable), qualifications, exOccs) <- runDB do + (cid, Entity tutid tut@Tutorial{..}, (participantRes, participantTable), qualifications, timespan, exOccs) <- runDB do trm <- get404 tid -- cid <- getKeyBy404 $ TermSchoolCourseShort tid ssh csh -- tutEnt@(Entity tutid _) <- fetchTutorial tid ssh csh tutn @@ -154,7 +154,7 @@ postTUsersR tid ssh csh tutn = do , ( TutorialUserPrintQualification, pure TutorialUserPrintQualificationData ) ] table <- makeCourseUserTable cid acts isInTut colChoices psValidator (Just csvColChoices) - return (cid, tutEnt, table, qualifications, exOccs) + return (cid, tutEnt, table, qualifications, timespan, exOccs) let courseQids = Set.fromList (entityKey <$> qualifications) tcontent <- formResultMaybe participantRes $ \case @@ -220,8 +220,9 @@ postTUsersR tid ssh csh tutn = do case tcontent of Just act -> act -- execute action and return produced content Nothing -> do -- no table action, continue normally + let (fmap (toMidnight . succ) -> tbegin, fmap toMidnight -> tend) = munzip timespan (openExams, tutors) <- runDBRead $ (,) - <$> selectList ([ExamCourse ==. cid, ExamRegisterFrom <=. Just now] ++ ([ExamRegisterTo >=. Just now] ||. [ExamRegisterTo ==. Nothing])) [Asc ExamName] + <$> selectList ([ExamCourse ==. cid, ExamStart <=. tbegin] ++ ([ExamEnd >=. tend] ||. [ExamEnd ==. Nothing])) [Asc ExamName] <*> E.select (do (tutor :& user) <- E.from $ E.table @Tutor `E.innerJoin` E.table @User `E.on` (\(tutor :& user) -> tutor E.^. TutorUser E.==. user E.^. UserId) diff --git a/src/Handler/Utils/Course/Cache.hs b/src/Handler/Utils/Course/Cache.hs index f16a6d9c0..40fce11b1 100644 --- a/src/Handler/Utils/Course/Cache.hs +++ b/src/Handler/Utils/Course/Cache.hs @@ -147,8 +147,8 @@ getDayExamOccurrences onlyOpen ssh mbcid dlimit@(dstart, dend) `E.innerJoin` E.table @Exam `E.on` (\(crs :& exm) -> crs E.^. CourseId E.==. exm E.^. ExamCourse) `E.innerJoin` E.table @ExamOccurrence `E.on` (\(_ :& exm :& occ) -> exm E.^. ExamId E.==. occ E.^. ExamOccurrenceExam) E.where_ $ E.and $ catMaybes - [ toMaybe onlyOpen $ E.justVal now E.>=. exm E.^. ExamRegisterFrom -- fail on null - E.&&. E.val now E.<~. exm E.^. ExamRegisterTo -- success on null + [ toMaybe onlyOpen $ E.justVal now E.>=. exm E.^. ExamStart -- fail on null + E.&&. E.val now E.<~. exm E.^. ExamEnd -- success on null , mbcid <&> ((E.==. (crs E.^. CourseId)) . E.val) , Just $ crs E.^. CourseSchool E.==. E.val ssh , Just $ E.withinPeriod dlimit (occ E.^. ExamOccurrenceStart) (occ E.^. ExamOccurrenceEnd)