fix(submissions): off-by-one when isLecturer
This commit is contained in:
parent
bcd3e467d6
commit
01e61f9bfd
@ -464,14 +464,12 @@ submissionHelper tid ssh csh shn mcid = do
|
|||||||
res' <- case res of
|
res' <- case res of
|
||||||
FormMissing -> return FormMissing
|
FormMissing -> return FormMissing
|
||||||
(FormFailure failmsgs) -> return $ FormFailure failmsgs
|
(FormFailure failmsgs) -> return $ FormFailure failmsgs
|
||||||
-- #227 Part II: no longer ignore submitter, if the user is lecturer or admin (allow lecturers to submit for their students)
|
|
||||||
(FormSuccess res'@(_, groupMembers))
|
(FormSuccess res'@(_, groupMembers))
|
||||||
| groupMembers == subUsersOld -> return $ FormSuccess res'
|
| groupMembers == subUsersOld -> return $ FormSuccess res'
|
||||||
| Arbitrary{..} <- sheetGrouping -> do -- Validate AdHoc Group Members
|
| Arbitrary{..} <- sheetGrouping -> do -- Validate AdHoc Group Members
|
||||||
-- , length gEMails < maxParticipants -> do -- < since submitting user is already accounted for
|
|
||||||
let (gEMails, gIds) = partitionEithers $ Set.toList groupMembers
|
let (gEMails, gIds) = partitionEithers $ Set.toList groupMembers
|
||||||
prep :: [(E.Value UserEmail, (E.Value UserId, E.Value Bool, E.Value Bool))] -> Map UserEmail (Maybe (UserId, Bool, Bool))
|
prep :: [(E.Value UserEmail, (E.Value UserId, E.Value Bool, E.Value Bool))] -> Map UserEmail (Maybe (UserId, Bool, Bool))
|
||||||
prep ps = Map.filter (maybe True $ \(i,_,_) -> i /= uid) . Map.fromList $ map (, Nothing) gEMails ++ [(m, Just (i,p,s))|(E.Value m, (E.Value i, E.Value p, E.Value s)) <- ps]
|
prep ps = Map.fromList $ map (, Nothing) gEMails ++ [(m, Just (i,p,s))|(E.Value m, (E.Value i, E.Value p, E.Value s)) <- ps]
|
||||||
participants <- fmap prep . E.select . E.from $ \user -> do
|
participants <- fmap prep . E.select . E.from $ \user -> do
|
||||||
E.where_ $ (user E.^. UserId) `E.in_` E.valList gIds
|
E.where_ $ (user E.^. UserId) `E.in_` E.valList gIds
|
||||||
let
|
let
|
||||||
@ -499,8 +497,8 @@ submissionHelper tid ssh csh shn mcid = do
|
|||||||
(Just (_,_, True)) -> pure . mr $ MsgSubmissionAlreadyExistsFor email
|
(Just (_,_, True)) -> pure . mr $ MsgSubmissionAlreadyExistsFor email
|
||||||
_other -> mempty
|
_other -> mempty
|
||||||
, case fromIntegral (Map.size participants) `compare` maxParticipants of
|
, case fromIntegral (Map.size participants) `compare` maxParticipants of
|
||||||
LT -> mempty
|
GT | not isLecturer -> pure $ mr MsgTooManyParticipants
|
||||||
_ -> pure $ mr MsgTooManyParticipants
|
_ -> mempty
|
||||||
]
|
]
|
||||||
return $ if null failmsgs
|
return $ if null failmsgs
|
||||||
then FormSuccess res'
|
then FormSuccess res'
|
||||||
|
|||||||
Reference in New Issue
Block a user