chore(tutorial): switch relevant exams from registerFrom/To to examStart/End
registering is of users/supervisors, but this page is for admins, so examStart/examEnd are only relevant for when it is actually happening
This commit is contained in:
parent
be0b90d0a1
commit
f954ebce43
@ -96,7 +96,7 @@ postTUsersR tid ssh csh tutn = do
|
|||||||
let croute = CTutorialR tid ssh csh tutn TUsersR
|
let croute = CTutorialR tid ssh csh tutn TUsersR
|
||||||
now <- liftIO getCurrentTime
|
now <- liftIO getCurrentTime
|
||||||
isAdmin <- hasReadAccessTo AdminR
|
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
|
trm <- get404 tid
|
||||||
-- cid <- getKeyBy404 $ TermSchoolCourseShort tid ssh csh
|
-- cid <- getKeyBy404 $ TermSchoolCourseShort tid ssh csh
|
||||||
-- tutEnt@(Entity tutid _) <- fetchTutorial tid ssh csh tutn
|
-- tutEnt@(Entity tutid _) <- fetchTutorial tid ssh csh tutn
|
||||||
@ -154,7 +154,7 @@ postTUsersR tid ssh csh tutn = do
|
|||||||
, ( TutorialUserPrintQualification, pure TutorialUserPrintQualificationData )
|
, ( TutorialUserPrintQualification, pure TutorialUserPrintQualificationData )
|
||||||
]
|
]
|
||||||
table <- makeCourseUserTable cid acts isInTut colChoices psValidator (Just csvColChoices)
|
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)
|
let courseQids = Set.fromList (entityKey <$> qualifications)
|
||||||
tcontent <- formResultMaybe participantRes $ \case
|
tcontent <- formResultMaybe participantRes $ \case
|
||||||
@ -220,8 +220,9 @@ postTUsersR tid ssh csh tutn = do
|
|||||||
case tcontent of
|
case tcontent of
|
||||||
Just act -> act -- execute action and return produced content
|
Just act -> act -- execute action and return produced content
|
||||||
Nothing -> do -- no table action, continue normally
|
Nothing -> do -- no table action, continue normally
|
||||||
|
let (fmap (toMidnight . succ) -> tbegin, fmap toMidnight -> tend) = munzip timespan
|
||||||
(openExams, tutors) <- runDBRead $ (,)
|
(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
|
<*> E.select (do
|
||||||
(tutor :& user) <- E.from $ E.table @Tutor `E.innerJoin` E.table @User
|
(tutor :& user) <- E.from $ E.table @Tutor `E.innerJoin` E.table @User
|
||||||
`E.on` (\(tutor :& user) -> tutor E.^. TutorUser E.==. user E.^. UserId)
|
`E.on` (\(tutor :& user) -> tutor E.^. TutorUser E.==. user E.^. UserId)
|
||||||
|
|||||||
@ -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 @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.innerJoin` E.table @ExamOccurrence `E.on` (\(_ :& exm :& occ) -> exm E.^. ExamId E.==. occ E.^. ExamOccurrenceExam)
|
||||||
E.where_ $ E.and $ catMaybes
|
E.where_ $ E.and $ catMaybes
|
||||||
[ toMaybe onlyOpen $ E.justVal now E.>=. exm E.^. ExamRegisterFrom -- fail on null
|
[ toMaybe onlyOpen $ E.justVal now E.>=. exm E.^. ExamStart -- fail on null
|
||||||
E.&&. E.val now E.<~. exm E.^. ExamRegisterTo -- success on null
|
E.&&. E.val now E.<~. exm E.^. ExamEnd -- success on null
|
||||||
, mbcid <&> ((E.==. (crs E.^. CourseId)) . E.val)
|
, mbcid <&> ((E.==. (crs E.^. CourseId)) . E.val)
|
||||||
, Just $ crs E.^. CourseSchool E.==. E.val ssh
|
, Just $ crs E.^. CourseSchool E.==. E.val ssh
|
||||||
, Just $ E.withinPeriod dlimit (occ E.^. ExamOccurrenceStart) (occ E.^. ExamOccurrenceEnd)
|
, Just $ E.withinPeriod dlimit (occ E.^. ExamOccurrenceStart) (occ E.^. ExamOccurrenceEnd)
|
||||||
|
|||||||
Reference in New Issue
Block a user