feat(external-exams): display staff & add' schools
This commit is contained in:
parent
94bb3911cb
commit
c14d90fd53
@ -5,21 +5,41 @@ module Handler.ExternalExam.Show
|
||||
import Import
|
||||
|
||||
import Handler.Utils
|
||||
import Handler.Utils.Invitations
|
||||
import Handler.ExternalExam.StaffInvite ()
|
||||
|
||||
import qualified Data.CaseInsensitive as CI
|
||||
import qualified Data.Map as Map
|
||||
|
||||
import qualified Database.Esqueleto as E
|
||||
|
||||
|
||||
getEEShowR :: TermId -> SchoolId -> CourseName -> ExamName -> Handler Html
|
||||
getEEShowR tid ssh coursen examn = do
|
||||
mUid <- maybeAuthId
|
||||
|
||||
(Entity _ ExternalExam{..}, fmap entityVal -> mResult, School{..}) <- runDB $ do
|
||||
(Entity _ ExternalExam{..}, fmap entityVal -> mResult, School{..}, staff, addSchools) <- runDB $ do
|
||||
exam@(Entity eeId ExternalExam{..}) <- getBy404 $ UniqueExternalExam tid ssh coursen examn
|
||||
actualStaff <- E.select . E.from $ \(eeStaff `E.InnerJoin` user) -> do
|
||||
E.on $ eeStaff E.^. ExternalExamStaffUser E.==. user E.^. UserId
|
||||
E.where_ $ eeStaff E.^. ExternalExamStaffExam E.==. E.val eeId
|
||||
E.orderBy [E.asc $ user E.^. UserDisplayName]
|
||||
return user
|
||||
maySeeInvites <- hasReadAccessTo $ EExamR tid ssh coursen examn EEGradesR
|
||||
staffInvites <- if
|
||||
| maySeeInvites -> sourceInvitationsF @ExternalExamStaff eeId
|
||||
| otherwise -> return Map.empty
|
||||
let staff = map Right actualStaff ++ map Left (Map.keys staffInvites)
|
||||
addSchools <- E.select . E.from $ \(eeSchool `E.InnerJoin` school) -> do
|
||||
E.on $ eeSchool E.^. ExternalExamOfficeSchoolSchool E.==. school E.^. SchoolId
|
||||
E.where_ $ eeSchool E.^. ExternalExamOfficeSchoolExam E.==. E.val eeId
|
||||
E.orderBy [E.asc $ school E.^. SchoolName]
|
||||
return school
|
||||
school <- getJust externalExamSchool
|
||||
|
||||
mResult <- fmap join . for mUid $ getBy . UniqueExternalExamResult eeId
|
||||
|
||||
return (exam, mResult, school)
|
||||
return (exam, mResult, school, staff, addSchools)
|
||||
|
||||
let heading = CI.original examn
|
||||
|
||||
|
||||
@ -38,4 +38,25 @@ $maybe ExternalExamResult{externalExamResultResult} <- mResult
|
||||
_{MsgExamTime}
|
||||
<dd .deflist__dd>
|
||||
^{formatTimeW SelFormatDateTime examTime}
|
||||
|
||||
$if not (null addSchools)
|
||||
<dt .deflist__dt>
|
||||
_{MsgExternalExamExamOfficeSchools}
|
||||
<dd .deflist__dd>
|
||||
<ul>
|
||||
$forall Entity _ School{schoolName} <- addSchools
|
||||
<li>
|
||||
#{schoolName}
|
||||
$if not (null staff)
|
||||
<dt .deflist__dt>
|
||||
_{MsgExternalExamStaff}
|
||||
<dd .deflist__dd>
|
||||
<ul>
|
||||
$forall s <- staff
|
||||
$case s
|
||||
$of Right (Entity _ User{userDisplayName, userDisplayEmail, userSurname})
|
||||
<li>
|
||||
^{nameEmailWidget userDisplayEmail userDisplayName userSurname}
|
||||
$of Left email
|
||||
<li style="font-family: monospace">
|
||||
#{email}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user