From d5bd5042ad920b26df847845cc437c3f0616575c Mon Sep 17 00:00:00 2001 From: Wolfgang Witt Date: Thu, 18 Mar 2021 16:51:40 +0100 Subject: [PATCH] fix: correctly handle original minimizeRooms-flag --- src/Handler/Exam/AutoOccurrence.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Handler/Exam/AutoOccurrence.hs b/src/Handler/Exam/AutoOccurrence.hs index 9021eebe9..f8d2908cf 100644 --- a/src/Handler/Exam/AutoOccurrence.hs +++ b/src/Handler/Exam/AutoOccurrence.hs @@ -93,11 +93,12 @@ examAutoOccurrenceIgnoreRoomsForm occId protoForm html = do let protoForm' = fromMaybe def $ protoForm <|> oldDataRes genForm btn = protoForm' & _eaofConfig . _eaocIgnoreRooms %~ action where - action EAOIRAutomatic = EAOIRManual {eaoirmIgnored=Set.empty, eaoirmSorted=True} - action ir@EAOIRManual {eaoirmIgnored, eaoirmSorted} = case btn of - BtnExamAutoOccurrenceIgnore -> EAOIRManual {eaoirmIgnored=Set.insert occId eaoirmIgnored, eaoirmSorted} - BtnExamAutoOccurrenceReconsider -> EAOIRManual {eaoirmIgnored=Set.delete occId eaoirmIgnored, eaoirmSorted} - _other -> ir + action EAOIRAutomatic = EAOIRManual {eaoirmIgnored=setAction occId Set.empty, eaoirmSorted=True} + action EAOIRManual {eaoirmIgnored, eaoirmSorted} = EAOIRManual {eaoirmIgnored=setAction occId eaoirmIgnored, eaoirmSorted} + setAction = case btn of + BtnExamAutoOccurrenceIgnore -> Set.insert + BtnExamAutoOccurrenceReconsider -> Set.delete + _other -> flip const -- i.e. ignore argument res = genForm <$> btnRes oldDataView = fieldView (secretJsonField :: Field Handler _) oldDataId (toPathPiece PostExamAutoOccurrencePrevious) [] (Right . fromMaybe protoForm' $ formResult' res) False return (res, wgt <> oldDataView) @@ -149,7 +150,7 @@ postEAutoOccurrenceR tid ssh csh examn = do return (uid, (userRec, examRegistrationOccurrence)) occurrences' = Map.fromList $ map (\(Entity eoId ExamOccurrence{..}) -> (eoId, _examOccurrenceCapacityIso # (fromIntegral <$> examOccurrenceCapacity))) occurrences autoOccurrenceResult = examAutoOccurrence eId examOccurrenceRule eaofConfig occurrences' participants' - (eaofMapping, eaofAssignment, _ignoredOccurrences) <- case autoOccurrenceResult of + (eaofMapping, eaofAssignment, ignoredOccurrences) <- case autoOccurrenceResult of (Left e) -> do addMessageI Error e pure ( ExamOccurrenceMapping {