diff --git a/messages/uniworx/de.msg b/messages/uniworx/de.msg index 306ac800c..7117498a4 100644 --- a/messages/uniworx/de.msg +++ b/messages/uniworx/de.msg @@ -1924,11 +1924,17 @@ CourseDeregistrationAllocationShouldLog: Selbstverschuldet CourseDeregistrationAllocationShouldLogTip: Falls der Platz des Studierenden, der abgemeldet wird, aus einer Zentralanmeldung stammt, ist vorgesehen einen permanenten Eintrag im System zu speichern, der den Studierenden u.U. bei zukünftigen Zentralanmeldungen benachteiligt. Als Kursverwalter haben Sie die Möglichkeit dies zu unterbinden, wenn der Studierende gute Gründe vorweisen kann, warum seine Abmeldung nicht selbstverschuldet ist. MailSubjectAllocationResults allocation@AllocationName: Plätze für Zentralanmeldung „#{allocation}“ wurden verteilt -AllocationResultsLecturer: Es wurden Plätze zugewiesen, wie folgt: -AllocationResultLecturer csh@CourseShorthand count@Int64: #{count} Teilnehmer für #{csh} +AllocationResultsLecturer: Im Rahmen der oben genannten Zentralanmeldung wurden Plätze zugewiesen, wie folgt: +AllocationResultLecturer csh@CourseShorthand count@Int64 count2@Int64: #{count} Teilnehmer (von insgesamt #{count2}) für #{csh} +AllocationResultLecturerAll csh@CourseShorthand count@Int64: #{count} Teilnehmer für #{csh} +AllocationResultLecturerNone csh@CourseShorthand: Keine Teilnehmer für #{csh} AllocationResultsStudent: Sie haben Plätze erhalten in: AllocationNoResultsStudent: Sie haben leider keine Plätze erhalten. AllocationResultStudent csh@CourseShorthand: Sie haben einen Platz in #{csh} erhalten. +AllocationResultsTip: Die folgenden Informationen entsprechen dem aktuellen Stand der Zentralanmeldung und können sich, z.B. durch die Verteilung von Plätzen an Nachrücker, noch ändern. Über zukünftige Änderungen, die Sie betreffen, werden Sie gesondert informiert. +AllocationResultsStudentTip: Unten aufgeführt sind alle Plätze, die Sie im Rahmen der genannten Zentralanmeldung erhalten haben und von denen Sie seit dem weder abgemeldet wurden, noch sich selbst abgemeldet haben. Plätze, über die Sie ggf. bereits informiert wurden, können also erneut aufgeführt sein. +AllocationResultStudentRegistrationTip: Sie sind zu oben genanntem Kurs in Uni2work angemeldet. +AllocationResultsStudentRegistrationTip: Sie sind zu den oben genannten Kursen in Uni2work angemeldet. FavouriteVisited: Kürzlich besucht FavouriteParticipant: Ihre Kurse diff --git a/src/Handler/Utils/Allocation.hs b/src/Handler/Utils/Allocation.hs index 827e1e467..ae9cffcb1 100644 --- a/src/Handler/Utils/Allocation.hs +++ b/src/Handler/Utils/Allocation.hs @@ -58,8 +58,12 @@ sinkAllocationPriorities allocId = C.mapM_ . imapM_ $ \matr prio -> computeAllocation :: AllocationId - -> DB (AllocationFingerprint, Set (UserId, CourseId), Seq (MatchingLog UserId CourseId Natural)) -computeAllocation allocId = do + -> Maybe (Set CourseId) -- ^ Optionally restrict allocation to only consider the given courses + -> DB ( AllocationFingerprint + , Set (UserId, CourseId) + , Seq (MatchingLog UserId CourseId Natural) + ) +computeAllocation allocId cRestr = do allocations <- selectList [ CourseParticipantAllocated ==. Just allocId ] [] let allocations' = allocations & map ((, Sum 1) . courseParticipantUser . entityVal) @@ -94,6 +98,9 @@ computeAllocation allocId = do E.&&. lecturer E.^. LecturerUser E.==. participant E.^. CourseParticipantUser return E.countRows + whenIsJust cRestr $ \restrSet -> + E.where_ $ course E.^. CourseId `E.in_` E.valList (Set.toList restrSet) + return ( allocationCourse , E.maybe E.nothing (\c -> E.just $ c E.-. participants) (course E.^. CourseCapacity) , allocationCourse E.^. AllocationCourseMinCapacity E.-. participants @@ -110,6 +117,7 @@ computeAllocation allocId = do & filterM (fmap not . alreadyAssigned) let preferences = Map.fromList $ do Entity _ CourseApplication{..} <- applications'' + guard $ Map.member courseApplicationCourse capacities return ((courseApplicationUser, courseApplicationCourse), (courseApplicationAllocationPriority, courseApplicationRatingPoints)) gradeScale <- getsYesod $ view _appAllocationGradeScale diff --git a/src/Jobs.hs b/src/Jobs.hs index a78b8dc39..526af3b6f 100644 --- a/src/Jobs.hs +++ b/src/Jobs.hs @@ -276,10 +276,10 @@ execCrontab = do Just (_, MatchNone) -> liftBase retry Just x -> return (crontab, x) - -- do - -- lastTimes <- State.get - -- now <- liftIO getCurrentTime - -- $logDebugS "Crontab" . intercalate "\n" . map tshow . sortOn fst . flip map (HashMap.toList currentCrontab) $ \(job, cron) -> (,job) $ nextCronMatch appTZ (getMax <$> HashMap.lookup job lastTimes) (debouncingAcc settings job) now cron + do + lastTimes <- State.get + now <- liftIO getCurrentTime + $logDebugS "Crontab" . intercalate "\n" . map tshow . sortOn fst . flip map (HashMap.toList currentCrontab) $ \(job, cron) -> (,job) $ nextCronMatch appTZ (getMax <$> HashMap.lookup job lastTimes) (debouncingAcc settings job) now cron let doJob = mapRWST (liftHandler . runDBJobs . setSerializable) $ do newCrontab <- lift . hoist lift $ determineCrontab' diff --git a/src/Jobs/Crontab.hs b/src/Jobs/Crontab.hs index 210fa4cc7..7c0a9cf0c 100644 --- a/src/Jobs/Crontab.hs +++ b/src/Jobs/Crontab.hs @@ -222,7 +222,7 @@ determineCrontab = execWriterT $ do { cronInitial = CronTimestamp . utcToLocalTimeTZ appTZ $ max visibleFrom ts , cronRepeat = CronRepeatOnChange , cronRateLimit = appNotificationRateLimit - , cronNotAfter = Left appNotificationExpiration + , cronNotAfter = Right . CronTimestamp . utcToLocalTimeTZ appTZ . addUTCTime appNotificationExpiration $ max visibleFrom ts } _other -> return () @@ -346,7 +346,7 @@ determineCrontab = execWriterT $ do { cronInitial = CronTimestamp . utcToLocalTimeTZ appTZ $ addUTCTime appNotificationCollateDelay doneSince' , cronRepeat = CronRepeatOnChange , cronRateLimit = appNotificationRateLimit - , cronNotAfter = Left appNotificationExpiration + , cronNotAfter = Right . CronTimestamp . utcToLocalTimeTZ appTZ . addUTCTime appNotificationCollateDelay $ addUTCTime appNotificationExpiration doneSince' } runConduit $ transPipe lift (selectSource [] []) .| C.mapM_ allocationJobs diff --git a/src/Jobs/Handler/SendNotification/Allocation.hs b/src/Jobs/Handler/SendNotification/Allocation.hs index 914fb05db..30fc48c25 100644 --- a/src/Jobs/Handler/SendNotification/Allocation.hs +++ b/src/Jobs/Handler/SendNotification/Allocation.hs @@ -170,12 +170,18 @@ dispatchNotificationAllocationResults nAllocation jRecipient = userMailT jRecipi E.where_ $ allocationCourse E.^. AllocationCourseCourse E.==. course E.^. CourseId E.&&. allocationCourse E.^. AllocationCourseAllocation E.==. E.val nAllocation ) - let participantCount = E.sub_select . E.from $ \participant -> do + let allocatedCount = E.sub_select . E.from $ \participant -> do E.where_ $ participant E.^. CourseParticipantCourse E.==. lecturer E.^. LecturerCourse E.&&. participant E.^. CourseParticipantAllocated E.==. E.just (E.val nAllocation) return E.countRows :: E.SqlQuery (E.SqlExpr (E.Value Int64)) - return (course, participantCount) - let lecturerResults = flip map lecturerResults' $ \(Entity _ Course{..}, E.Value partCount) -> SomeMessage $ MsgAllocationResultLecturer courseShorthand partCount + let participantCount = E.sub_select . E.from $ \participant -> do + E.where_ $ participant E.^. CourseParticipantCourse E.==. lecturer E.^. LecturerCourse + return E.countRows :: E.SqlQuery (E.SqlExpr (E.Value Int64)) + return (course, allocatedCount, participantCount) + let lecturerResults = flip map lecturerResults' $ \(Entity _ Course{..}, E.Value allocCount, E.Value partCount) -> SomeMessage $ if + | allocCount == partCount -> MsgAllocationResultLecturerAll courseShorthand allocCount + | allocCount == 0 -> MsgAllocationResultLecturerNone courseShorthand + | otherwise -> MsgAllocationResultLecturer courseShorthand allocCount partCount doParticipantResults <- E.selectExists . E.from $ \application -> E.where_ $ application E.^. CourseApplicationAllocation E.==. E.just (E.val nAllocation) diff --git a/templates/mail/allocationResults.hamlet b/templates/mail/allocationResults.hamlet index 6973dc619..bf2bddf89 100644 --- a/templates/mail/allocationResults.hamlet +++ b/templates/mail/allocationResults.hamlet @@ -13,6 +13,9 @@ $newline never
+ _{SomeMessage MsgAllocationResultsTip} + $if not (null lecturerResults)
_{SomeMessage MsgAllocationResultsLecturer} @@ -21,16 +24,20 @@ $newline never
+ _{SomeMessage MsgAllocationResultsStudentTip} $case pResults $of []
_{SomeMessage MsgAllocationNoResultsStudent} $of [csh]
_{SomeMessage $ MsgAllocationResultStudent csh} +
_{SomeMessage MsgAllocationResultStudentRegistrationTip} $of cshs
_{SomeMessage MsgAllocationResultsStudent}
_{SomeMessage MsgAllocationResultsStudentRegistrationTip} ^{ihamletSomeMessage editNotifications}