fix(submission): allow not modifying submissionUsers

This commit is contained in:
Gregor Kleen 2019-12-06 12:09:14 +01:00
parent 98c0d6919e
commit 030fd7abf1

View File

@ -265,6 +265,9 @@ makeSubmissionForm cid msmid uploadMode grouping isLecturer prefillUsers = ident
postProcess :: Map ListPosition (Either UserEmail UserId, ()) -> Set (Either UserEmail UserId)
postProcess valMap
| is _Just msmid
, resultUsers == prefillUsers
= resultUsers
| Just maxSize' <- maxSize
, fromIntegral maxSize' >= Set.size resultUsers
= resultUsers
@ -399,11 +402,19 @@ submissionHelper tid ssh csh shn mcid = do
}
mCID <- fmap join . msgSubmissionErrors . runDBJobs $ do
-- Determine old submission users
subUsersOld <- if
| Just smid <- msmid -> Set.union
<$> (setOf (folded . _entityVal . _submissionUserUser . to Right) <$> selectList [SubmissionUserSubmission ==. smid] [])
<*> (sourceInvitationsF smid <&> Set.fromList . map (\(email, InvDBDataSubmissionUser) -> Left email))
| otherwise -> return Set.empty
res' <- case res of
FormMissing -> return FormMissing
(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))
| groupMembers == subUsersOld -> return $ FormSuccess res'
| 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
@ -479,13 +490,6 @@ submissionHelper tid ssh csh shn mcid = do
-- SubmissionUser for all group members (pre-registered & ad-hoc)
return $ groupUids `Set.union` adhocMembers
-- Determine old submission users
subUsersOld <- if
| isJust msmid -> Set.union
<$> (setOf (folded . _entityVal . _submissionUserUser . to Right) <$> selectList [SubmissionUserSubmission ==. smid] [])
<*> (sourceInvitationsF smid <&> Set.fromList . map (\(email, InvDBDataSubmissionUser) -> Left email))
| otherwise -> return Set.empty -- optimization (do not perform selection if submission was freshly created)
-- Since invitations carry no data we only need to consider changes to
-- the set of users/invited emails
-- Otherwise we would have to update old invitations (via