feat: notification about externalExamResults to exam-office
This commit is contained in:
parent
bcd5326129
commit
a30484003a
@ -866,6 +866,9 @@ MailExamOfficeExamResultsIntro courseName@Text termDesc@Text examn@ExamName: Ein
|
|||||||
MailSubjectExamOfficeExamResultsChanged csh@CourseShorthand examn@ExamName: Ergebnisse für #{examn} in #{csh} wurden verändert
|
MailSubjectExamOfficeExamResultsChanged csh@CourseShorthand examn@ExamName: Ergebnisse für #{examn} in #{csh} wurden verändert
|
||||||
MailExamOfficeExamResultsChangedIntro courseName@Text termDesc@Text examn@ExamName: Ein Kursverwalter hat Prüfungsleistungen für #{examn} im Kurs #{courseName} (#{termDesc}) verändert.
|
MailExamOfficeExamResultsChangedIntro courseName@Text termDesc@Text examn@ExamName: Ein Kursverwalter hat Prüfungsleistungen für #{examn} im Kurs #{courseName} (#{termDesc}) verändert.
|
||||||
|
|
||||||
|
MailSubjectExamOfficeExternalExamResults coursen@CourseName examn@ExamName: Ergebnisse für #{examn} in #{coursen}
|
||||||
|
MailExamOfficeExternalExamResultsIntro coursen@CourseName termDesc@Text examn@ExamName: Ein Kursverwalter hat Prüfungsleistungen für #{examn} im Kurs #{coursen} (#{termDesc}) erstellt oder angepasst.
|
||||||
|
|
||||||
MailSubjectExamRegistrationActive csh@CourseShorthand examn@ExamName: Anmeldung für #{examn} in #{csh} ist möglich
|
MailSubjectExamRegistrationActive csh@CourseShorthand examn@ExamName: Anmeldung für #{examn} in #{csh} ist möglich
|
||||||
MailExamRegistrationActiveIntro courseName@Text termDesc@Text examn@ExamName: Sie können sich nun für #{examn} im Kurs #{courseName} (#{termDesc}) anmelden.
|
MailExamRegistrationActiveIntro courseName@Text termDesc@Text examn@ExamName: Sie können sich nun für #{examn} im Kurs #{courseName} (#{termDesc}) anmelden.
|
||||||
|
|
||||||
|
|||||||
@ -307,6 +307,27 @@ determineCrontab = execWriterT $ do
|
|||||||
|
|
||||||
runConduit $ transPipe lift (selectSource [] []) .| C.mapM_ examJobs
|
runConduit $ transPipe lift (selectSource [] []) .| C.mapM_ examJobs
|
||||||
|
|
||||||
|
|
||||||
|
let
|
||||||
|
externalExamJobs (Entity nExternalExam ExternalExam{..}) = do
|
||||||
|
newestResult <- lift . E.select . E.from $ \externalExamResult -> do
|
||||||
|
E.where_ $ externalExamResult E.^. ExternalExamResultExam E.==. E.val nExternalExam
|
||||||
|
return . E.max_ $ externalExamResult E.^. ExternalExamResultLastChanged
|
||||||
|
|
||||||
|
case newestResult of
|
||||||
|
[E.Value (Just lastChange)] ->
|
||||||
|
tell $ HashMap.singleton
|
||||||
|
(JobCtlQueue $ JobQueueNotification NotificationExamOfficeExternalExamResults{..})
|
||||||
|
Cron
|
||||||
|
{ cronInitial = CronTimestamp . utcToLocalTimeTZ appTZ $ addUTCTime appNotificationCollateDelay lastChange
|
||||||
|
, cronRepeat = CronRepeatOnChange
|
||||||
|
, cronRateLimit = nominalDay
|
||||||
|
, cronNotAfter = Left appNotificationExpiration
|
||||||
|
}
|
||||||
|
_other -> return ()
|
||||||
|
|
||||||
|
runConduit $ transPipe lift (selectSource [] []) .| C.mapM_ externalExamJobs
|
||||||
|
|
||||||
let
|
let
|
||||||
allocationJobs (Entity nAllocation Allocation{..}) = do
|
allocationJobs (Entity nAllocation Allocation{..}) = do
|
||||||
whenIsJust allocationStaffRegisterFrom $ \staffRegisterFrom ->
|
whenIsJust allocationStaffRegisterFrom $ \staffRegisterFrom ->
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import Jobs.Queue
|
|||||||
import qualified Data.Set as Set
|
import qualified Data.Set as Set
|
||||||
|
|
||||||
import Handler.Utils.ExamOffice.Exam
|
import Handler.Utils.ExamOffice.Exam
|
||||||
|
import Handler.Utils.ExamOffice.ExternalExam
|
||||||
|
|
||||||
|
|
||||||
dispatchJobQueueNotification :: Notification -> Handler ()
|
dispatchJobQueueNotification :: Notification -> Handler ()
|
||||||
@ -198,6 +199,12 @@ determineNotificationCandidates NotificationExamOfficeExamResultsChanged{..} =
|
|||||||
E.where_ $ examResult E.^. ExamResultId `E.in_` E.valList (Set.toList nExamResults)
|
E.where_ $ examResult E.^. ExamResultId `E.in_` E.valList (Set.toList nExamResults)
|
||||||
E.where_ $ examOfficeExamResultAuth (user E.^. UserId) examResult
|
E.where_ $ examOfficeExamResultAuth (user E.^. UserId) examResult
|
||||||
return user
|
return user
|
||||||
|
determineNotificationCandidates NotificationExamOfficeExternalExamResults{..} =
|
||||||
|
E.select . E.from $ \user -> do
|
||||||
|
E.where_ . E.exists . E.from $ \externalExamResult -> do
|
||||||
|
E.where_ $ externalExamResult E.^. ExternalExamResultExam E.==. E.val nExternalExam
|
||||||
|
E.where_ $ examOfficeExternalExamResultAuth (user E.^. UserId) externalExamResult
|
||||||
|
return user
|
||||||
determineNotificationCandidates notif@NotificationAllocationResults{..} = do
|
determineNotificationCandidates notif@NotificationAllocationResults{..} = do
|
||||||
lastExec <- fmap (fmap $ cronLastExecTime . entityVal) . getBy . UniqueCronLastExec . toJSON $ JobQueueNotification notif
|
lastExec <- fmap (fmap $ cronLastExecTime . entityVal) . getBy . UniqueCronLastExec . toJSON $ JobQueueNotification notif
|
||||||
E.select . E.from $ \user -> do
|
E.select . E.from $ \user -> do
|
||||||
@ -261,6 +268,7 @@ classifyNotification NotificationAllocationOutdatedRatings{} = return NTAll
|
|||||||
classifyNotification NotificationAllocationUnratedApplications{} = return NTAllocationUnratedApplications
|
classifyNotification NotificationAllocationUnratedApplications{} = return NTAllocationUnratedApplications
|
||||||
classifyNotification NotificationExamOfficeExamResults{} = return NTExamOfficeExamResults
|
classifyNotification NotificationExamOfficeExamResults{} = return NTExamOfficeExamResults
|
||||||
classifyNotification NotificationExamOfficeExamResultsChanged{} = return NTExamOfficeExamResultsChanged
|
classifyNotification NotificationExamOfficeExamResultsChanged{} = return NTExamOfficeExamResultsChanged
|
||||||
|
classifyNotification NotificationExamOfficeExternalExamResults{} = return NTExamOfficeExamResults
|
||||||
classifyNotification NotificationAllocationResults{} = return NTAllocationResults
|
classifyNotification NotificationAllocationResults{} = return NTAllocationResults
|
||||||
classifyNotification NotificationCourseRegistered{} = return NTCourseRegistered
|
classifyNotification NotificationCourseRegistered{} = return NTCourseRegistered
|
||||||
classifyNotification NotificationSubmissionEdited{} = return NTSubmissionEdited
|
classifyNotification NotificationSubmissionEdited{} = return NTSubmissionEdited
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
module Jobs.Handler.SendNotification.ExamOffice
|
module Jobs.Handler.SendNotification.ExamOffice
|
||||||
( dispatchNotificationExamOfficeExamResults
|
( dispatchNotificationExamOfficeExamResults
|
||||||
, dispatchNotificationExamOfficeExamResultsChanged
|
, dispatchNotificationExamOfficeExamResultsChanged
|
||||||
|
, dispatchNotificationExamOfficeExternalExamResults
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
@ -61,3 +62,22 @@ dispatchNotificationExamOfficeExamResultsChanged nExamResults jRecipient = do
|
|||||||
|
|
||||||
addAlternatives $
|
addAlternatives $
|
||||||
providePreferredAlternative ($(ihamletFile "templates/mail/examOffice/examResultsChanged.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX))
|
providePreferredAlternative ($(ihamletFile "templates/mail/examOffice/examResultsChanged.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX))
|
||||||
|
|
||||||
|
|
||||||
|
dispatchNotificationExamOfficeExternalExamResults :: ExternalExamId -> UserId -> Handler ()
|
||||||
|
dispatchNotificationExamOfficeExternalExamResults nExternalExam jRecipient = userMailT jRecipient $ do
|
||||||
|
ExternalExam{..} <- liftHandler . runDB $ getJust nExternalExam
|
||||||
|
replaceMailHeader "Auto-Submitted" $ Just "auto-generated"
|
||||||
|
setSubjectI $ MsgMailSubjectExamOfficeExternalExamResults externalExamCourseName externalExamExamName
|
||||||
|
|
||||||
|
MsgRenderer mr <- getMailMsgRenderer
|
||||||
|
let termDesc = mr . ShortTermIdentifier $ unTermKey externalExamTerm
|
||||||
|
tid = externalExamTerm
|
||||||
|
ssh = externalExamSchool
|
||||||
|
coursen = externalExamCourseName
|
||||||
|
examn = externalExamExamName
|
||||||
|
|
||||||
|
editNotifications <- mkEditNotifications jRecipient
|
||||||
|
|
||||||
|
addAlternatives $
|
||||||
|
providePreferredAlternative ($(ihamletFile "templates/mail/examOffice/externalExamResults.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX))
|
||||||
|
|||||||
@ -89,6 +89,7 @@ data Notification = NotificationSubmissionRated { nSubmission :: SubmissionId }
|
|||||||
| NotificationAllocationOutdatedRatings { nAllocation :: AllocationId }
|
| NotificationAllocationOutdatedRatings { nAllocation :: AllocationId }
|
||||||
| NotificationExamOfficeExamResults { nExam :: ExamId }
|
| NotificationExamOfficeExamResults { nExam :: ExamId }
|
||||||
| NotificationExamOfficeExamResultsChanged { nExamResults :: Set ExamResultId }
|
| NotificationExamOfficeExamResultsChanged { nExamResults :: Set ExamResultId }
|
||||||
|
| NotificationExamOfficeExternalExamResults { nExternalExam :: ExternalExamId }
|
||||||
| NotificationAllocationResults { nAllocation :: AllocationId }
|
| NotificationAllocationResults { nAllocation :: AllocationId }
|
||||||
| NotificationCourseRegistered { nUser :: UserId, nCourse :: CourseId }
|
| NotificationCourseRegistered { nUser :: UserId, nCourse :: CourseId }
|
||||||
| NotificationSubmissionEdited { nInitiator :: UserId, nSubmission :: SubmissionId }
|
| NotificationSubmissionEdited { nInitiator :: UserId, nSubmission :: SubmissionId }
|
||||||
|
|||||||
18
templates/mail/examOffice/externalExamResults.hamlet
Normal file
18
templates/mail/examOffice/externalExamResults.hamlet
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
$newline never
|
||||||
|
\<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<style>
|
||||||
|
h1 {
|
||||||
|
font-size: 1.25em;
|
||||||
|
font-variant: small-caps;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
<body>
|
||||||
|
<h1>
|
||||||
|
_{MsgMailExamOfficeExternalExamResultsIntro coursen termDesc externalExamExamName}
|
||||||
|
<p>
|
||||||
|
<a href=@{EExamR tid ssh coursen examn EEGradesR}>
|
||||||
|
#{externalExamExamName}
|
||||||
|
^{editNotifications}
|
||||||
Reference in New Issue
Block a user