From bb9b4f06ae135e9af8b3333b42e78ff38baab3d8 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 4 Mar 2020 10:21:46 +0100 Subject: [PATCH] fix: fix build & minor refactor --- messages/uniworx/en-eu.msg | 2 -- src/Handler/Course/Users.hs | 11 +++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/messages/uniworx/en-eu.msg b/messages/uniworx/en-eu.msg index 5195ea531..8b4634e8f 100644 --- a/messages/uniworx/en-eu.msg +++ b/messages/uniworx/en-eu.msg @@ -2378,5 +2378,3 @@ AllocationPrioritiesFile: CSV file AllocationPrioritiesSunk num: Successfully registered central priorities for #{num} #{pluralEN num "applicant" "applicants"} AllocationPrioritiesMissing num: Could not register central priorities for #{num} #{pluralEN num "applicant" "applicants"} because their matriculation was not found in the uploaded CSV file AllocationMissingPrioritiesIgnored: Applicants for whom no central priority has been registered will be ignored during assignment! -ParticipantsIntersectCourseOption tid@TermId ssh@SchoolId coursen@CourseName: #{tid} - #{ssh} - #{coursen} -ParticipantsIntersectCourses: Courses diff --git a/src/Handler/Course/Users.hs b/src/Handler/Course/Users.hs index 9d8f4dbad..8229537d7 100644 --- a/src/Handler/Course/Users.hs +++ b/src/Handler/Course/Users.hs @@ -485,13 +485,11 @@ postCUsersR tid ssh csh = do mayRegister <- hasWriteAccessTo $ CourseR tid ssh csh CAddUserR ent@(Entity cid _) <- getBy404 $ TermSchoolCourseShort tid ssh csh hasTutorials <- exists [TutorialCourse ==. cid] - exams <- E.select . E.from $ \exam -> do - E.where_ $ exam E.^. ExamCourse E.==. E.val cid - return exam examOccurrencesPerExam <- E.select . E.from $ \(exam `E.LeftOuterJoin` examOccurrence) -> do E.on $ E.just (exam E.^. ExamId) E.==. examOccurrence E.?. ExamOccurrenceExam E.where_ $ exam E.^. ExamCourse E.==. E.val cid return (exam, examOccurrence) + let exams = nubOn entityKey $ examOccurrencesPerExam ^.. folded . _1 let colChoices = mconcat $ catMaybes [ pure $ dbSelect (applying _2) id (return . view (hasEntity . _entityKey)) , pure $ colUserNameLink (CourseR tid ssh csh . CUserR) @@ -582,11 +580,12 @@ postCUsersR tid ssh csh = do , examRegistrationOccurrence = mOccurrence , examRegistrationTime = now } - if isJust mExamReg - then do + case mExamReg of + Just _ -> do audit $ TransactionExamRegister exam uid return 1 - else return 0 + Nothing -> + return mempty addMessageI Success $ MsgCourseUsersExamRegistered nrReg redirect $ CourseR tid ssh csh CUsersR let headingLong = [whamlet|_{MsgMenuCourseMembers} #{courseName course} #{tid}|]