Better fix for lecturer names

This commit is contained in:
Steffen Jost 2019-06-27 19:53:26 +02:00
parent 16c556b852
commit 8476314a46
2 changed files with 11 additions and 9 deletions

View File

@ -1085,7 +1085,7 @@ assignHandler tid ssh csh cid assignSids = do
(btnWdgt, btnResult) <- runButtonForm FIDAssignSubmissions
-- gather data
(assignSheetNames, nrParticipants, groupsPossible, infoMap, correctorMap, assignment, lecturerNames) <- runDB $ do
(assignSheetNames, nrParticipants, groupsPossible, infoMap, correctorMap, assignment) <- runDB $ do
-- cid <- getKeyBy404 $ TermSchoolCourseShort tid ssh csh
nrParticipants <- count [CourseParticipantCourse ==. cid]
@ -1141,11 +1141,11 @@ assignHandler tid ssh csh cid assignSids = do
in Map.insertWith (\(usr, ma) (_, mb) -> (usr, Map.union ma mb)) uid (user, Map.singleton shn sheetcorr) acc
)
-- lecturerNames :: Map UserId User
lecturerNames <- fmap entities2map $ E.select $ E.from $ \(user `E.InnerJoin` lecturer) -> do
E.on $ user E.^. UserId E.==. lecturer E.^. LecturerUser
E.where_ $ lecturer E.^. LecturerCourse E.==. E.val cid
return user
-- -- lecturerNames :: Map UserId User
-- lecturerNames <- fmap entities2map $ E.select $ E.from $ \(user `E.InnerJoin` lecturer) -> do
-- E.on $ user E.^. UserId E.==. lecturer E.^. LecturerUser
-- E.where_ $ lecturer E.^. LecturerCourse E.==. E.val cid
-- return user
submissions <- E.select . E.from $ \submission -> do
E.where_ $ submission E.^. SubmissionSheet `E.in_` E.valList sheetIds
@ -1179,7 +1179,7 @@ assignHandler tid ssh csh cid assignSids = do
}
in Map.insertWith (Map.unionWith (<>)) shnm cinf m
return (assignSheetNames, nrParticipants, groupsPossible, infoMap, correctorMap, assignment, lecturerNames)
return (assignSheetNames, nrParticipants, groupsPossible, infoMap, correctorMap, assignment)
let -- infoMap :: Map SheetName (Map (Maybe UserId) CorrectionInfo) -- repeated here for easier reference
-- create aggregate maps
@ -1218,8 +1218,8 @@ assignHandler tid ssh csh cid assignSids = do
getCorrector (Just uid)
| Just (User{..},loadMap) <- Map.lookup uid correctorMap
= (nameEmailWidget userEmail userDisplayName userSurname, loadMap)
| Just (User{..} ) <- Map.lookup uid lecturerNames
= (nameEmailWidget userEmail userDisplayName userSurname, mempty) -- lecturers may also correct in rare cases
-- | Just (User{..} ) <- Map.lookup uid lecturerNames
-- = (nameEmailWidget userEmail userDisplayName userSurname, mempty) -- lecturers may also correct in rare cases
getCorrector _ = ([whamlet|_{MsgNoCorrectorAssigned}|], mempty)
-- avoid nestes hamlet $maybe with duplicated $nothing
getCorrSheetStatus :: Maybe UserId -> SheetName -> Maybe CorrectionInfo

View File

@ -30,6 +30,8 @@ instance Semigroup CorrectionInfo where
mergeWith prj f = on f prj corrA corrB
keepEqual (Just x) (Just y) | x==y = Just x
keepEqual Nothing other = other
keepEqual other Nothing = other
keepEqual _ _ = Nothing
instance Monoid CorrectionInfo where