chore: create (incomplete) ignore/reconsider buttons
This commit is contained in:
parent
25262aa7a5
commit
a35a481f33
@ -2824,6 +2824,8 @@ BtnExamAutoOccurrenceCalculate: Verteilungstabelle berechnen
|
|||||||
BtnExamAutoOccurrenceAccept: Verteilung akzeptieren
|
BtnExamAutoOccurrenceAccept: Verteilung akzeptieren
|
||||||
BtnExamAutoOccurrenceNudgeUp: +
|
BtnExamAutoOccurrenceNudgeUp: +
|
||||||
BtnExamAutoOccurrenceNudgeDown: -
|
BtnExamAutoOccurrenceNudgeDown: -
|
||||||
|
BtnExamAutoOccurrenceIgnoreEnable: Ignorieren
|
||||||
|
BtnExamAutoOccurrenceIgnoreDisable: Berücksichtigen
|
||||||
ExamRoomMappingSurname: Nachnamen beginnend mit
|
ExamRoomMappingSurname: Nachnamen beginnend mit
|
||||||
ExamRoomMappingMatriculation: Matrikelnummern endend in
|
ExamRoomMappingMatriculation: Matrikelnummern endend in
|
||||||
ExamRoomMappingRandom: Verteilung
|
ExamRoomMappingRandom: Verteilung
|
||||||
|
|||||||
@ -2824,6 +2824,8 @@ BtnExamAutoOccurrenceCalculate: Calculate assignment rules
|
|||||||
BtnExamAutoOccurrenceAccept: Accept assignments
|
BtnExamAutoOccurrenceAccept: Accept assignments
|
||||||
BtnExamAutoOccurrenceNudgeUp: +
|
BtnExamAutoOccurrenceNudgeUp: +
|
||||||
BtnExamAutoOccurrenceNudgeDown: -
|
BtnExamAutoOccurrenceNudgeDown: -
|
||||||
|
BtnExamAutoOccurrenceIgnoreEnable: Ignore
|
||||||
|
BtnExamAutoOccurrenceIgnoreDisable: Reconsider
|
||||||
ExamRoomMappingSurname: Surnames starting with
|
ExamRoomMappingSurname: Surnames starting with
|
||||||
ExamRoomMappingMatriculation: Matriculation numbers ending in
|
ExamRoomMappingMatriculation: Matriculation numbers ending in
|
||||||
ExamRoomMappingRandom: Distribution
|
ExamRoomMappingRandom: Distribution
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import Handler.Utils
|
|||||||
import Handler.Utils.Exam
|
import Handler.Utils.Exam
|
||||||
|
|
||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
|
import qualified Data.Set as Set
|
||||||
|
|
||||||
import qualified Database.Esqueleto as E
|
import qualified Database.Esqueleto as E
|
||||||
import Database.Persist.Sql (updateWhereCount)
|
import Database.Persist.Sql (updateWhereCount)
|
||||||
@ -35,6 +36,7 @@ data ExamAutoOccurrenceButton
|
|||||||
= BtnExamAutoOccurrenceCalculate
|
= BtnExamAutoOccurrenceCalculate
|
||||||
| BtnExamAutoOccurrenceAccept
|
| BtnExamAutoOccurrenceAccept
|
||||||
| BtnExamAutoOccurrenceNudgeUp | BtnExamAutoOccurrenceNudgeDown
|
| BtnExamAutoOccurrenceNudgeUp | BtnExamAutoOccurrenceNudgeDown
|
||||||
|
| BtnExamAutoOccurrenceIgnoreEnable | BtnExamAutoOccurrenceIgnoreDisable
|
||||||
deriving (Eq, Ord, Read, Show, Enum, Bounded, Generic, Typeable)
|
deriving (Eq, Ord, Read, Show, Enum, Bounded, Generic, Typeable)
|
||||||
instance Universe ExamAutoOccurrenceButton
|
instance Universe ExamAutoOccurrenceButton
|
||||||
instance Finite ExamAutoOccurrenceButton
|
instance Finite ExamAutoOccurrenceButton
|
||||||
@ -53,8 +55,14 @@ examAutoOccurrenceCalculateForm ExamAutoOccurrenceCalculateForm{ eaofConfig }
|
|||||||
= identifyForm FIDExamAutoOccurrenceCalculate . renderAForm FormStandard $ ExamAutoOccurrenceCalculateForm <$> eaocForm
|
= identifyForm FIDExamAutoOccurrenceCalculate . renderAForm FormStandard $ ExamAutoOccurrenceCalculateForm <$> eaocForm
|
||||||
where
|
where
|
||||||
eaocForm =
|
eaocForm =
|
||||||
(set _eaocMinimizeRooms <$> apopt checkBoxField (fslI MsgExamAutoOccurrenceMinimizeRooms & setTooltip MsgExamAutoOccurrenceMinimizeRoomsTip) (Just $ eaofConfig ^. _eaocMinimizeRooms))
|
(set _eaocIgnoreRooms . automaticIfTrue <$> apopt checkBoxField (fslI MsgExamAutoOccurrenceMinimizeRooms & setTooltip MsgExamAutoOccurrenceMinimizeRoomsTip) (Just . ignoreRooms $ eaofConfig ^. _eaocIgnoreRooms))
|
||||||
<*> pure def
|
<*> pure def
|
||||||
|
automaticIfTrue :: Bool -> ExamAutoOccurrenceIgnoreRooms
|
||||||
|
automaticIfTrue True = EAOIRAutomatic
|
||||||
|
automaticIfTrue False = EAOIRManual Set.empty
|
||||||
|
ignoreRooms :: ExamAutoOccurrenceIgnoreRooms -> Bool
|
||||||
|
ignoreRooms EAOIRAutomatic = True
|
||||||
|
ignoreRooms (EAOIRManual s) = null s
|
||||||
|
|
||||||
examAutoOccurrenceNudgeForm :: ExamOccurrenceId -> Maybe ExamAutoOccurrenceCalculateForm -> Form ExamAutoOccurrenceCalculateForm
|
examAutoOccurrenceNudgeForm :: ExamOccurrenceId -> Maybe ExamAutoOccurrenceCalculateForm -> Form ExamAutoOccurrenceCalculateForm
|
||||||
examAutoOccurrenceNudgeForm occId protoForm html = do
|
examAutoOccurrenceNudgeForm occId protoForm html = do
|
||||||
@ -73,6 +81,28 @@ examAutoOccurrenceNudgeForm occId protoForm html = do
|
|||||||
oldDataView = fieldView (secretJsonField :: Field Handler _) oldDataId (toPathPiece PostExamAutoOccurrencePrevious) [] (Right . fromMaybe protoForm' $ formResult' res) False
|
oldDataView = fieldView (secretJsonField :: Field Handler _) oldDataId (toPathPiece PostExamAutoOccurrencePrevious) [] (Right . fromMaybe protoForm' $ formResult' res) False
|
||||||
return (res, wgt <> oldDataView)
|
return (res, wgt <> oldDataView)
|
||||||
|
|
||||||
|
examAutoOccurrenceIgnoreRoomsForm :: ExamOccurrenceId -> Maybe ExamAutoOccurrenceCalculateForm -> Form ExamAutoOccurrenceCalculateForm
|
||||||
|
examAutoOccurrenceIgnoreRoomsForm occId protoForm html = do
|
||||||
|
cID <- encrypt occId
|
||||||
|
-- TODO new constructor instead of FIDExamAutoOccurrenceNudge
|
||||||
|
-- type FormIdentifier, lives in Utils.Form
|
||||||
|
(btnRes, wgt) <- identifyForm (FIDExamAutoOccurrenceIgnoreRooms $ ciphertext cID) (buttonForm' [BtnExamAutoOccurrenceIgnoreEnable, BtnExamAutoOccurrenceIgnoreDisable]) html
|
||||||
|
oldDataRes <- globalPostParamField PostExamAutoOccurrencePrevious secretJsonField
|
||||||
|
oldDataId <- newIdent
|
||||||
|
|
||||||
|
let protoForm' = fromMaybe def $ oldDataRes <|> protoForm
|
||||||
|
genForm btn = protoForm' & _eaofConfig . _eaocIgnoreRooms %~ EAOIRManual . action occId . toManualSet
|
||||||
|
where
|
||||||
|
toManualSet EAOIRAutomatic = Set.empty
|
||||||
|
toManualSet (EAOIRManual s) = s
|
||||||
|
action = case btn of
|
||||||
|
BtnExamAutoOccurrenceIgnoreEnable -> Set.insert
|
||||||
|
BtnExamAutoOccurrenceIgnoreDisable -> 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)
|
||||||
|
|
||||||
examAutoOccurrenceAcceptForm :: Maybe ExamAutoOccurrenceAcceptForm -> Form ExamAutoOccurrenceAcceptForm
|
examAutoOccurrenceAcceptForm :: Maybe ExamAutoOccurrenceAcceptForm -> Form ExamAutoOccurrenceAcceptForm
|
||||||
examAutoOccurrenceAcceptForm confirmData = identifyForm FIDExamAutoOccurrenceConfirm $ \html -> do
|
examAutoOccurrenceAcceptForm confirmData = identifyForm FIDExamAutoOccurrenceConfirm $ \html -> do
|
||||||
(confirmDataRes, confirmDataView) <- mreq secretJsonField "" confirmData
|
(confirmDataRes, confirmDataView) <- mreq secretJsonField "" confirmData
|
||||||
@ -102,8 +132,11 @@ postEAutoOccurrenceR tid ssh csh examn = do
|
|||||||
|
|
||||||
nudgeRes <- sequence . flip Map.fromSet (setOf (folded . _entityKey) occurrences) $ \occId ->
|
nudgeRes <- sequence . flip Map.fromSet (setOf (folded . _entityKey) occurrences) $ \occId ->
|
||||||
runFormPost $ examAutoOccurrenceNudgeForm occId (formResult' calculateRes)
|
runFormPost $ examAutoOccurrenceNudgeForm occId (formResult' calculateRes)
|
||||||
|
|
||||||
|
ignoreRoomsRes <- sequence . flip Map.fromSet (setOf (folded . _entityKey) occurrences) $ \occId ->
|
||||||
|
runFormPost $ examAutoOccurrenceIgnoreRoomsForm occId (formResult' calculateRes)
|
||||||
|
|
||||||
let calculateRes' = asum $ calculateRes : nudgeRes ^.. folded . _1 . _1
|
let calculateRes' = asum $ calculateRes : nudgeRes ^.. folded . _1 . _1 ++ ignoreRoomsRes ^.. folded . _1 . _1
|
||||||
|
|
||||||
calcResult <- formResultMaybe calculateRes' $ \ExamAutoOccurrenceCalculateForm{..} -> runDB $ do
|
calcResult <- formResultMaybe calculateRes' $ \ExamAutoOccurrenceCalculateForm{..} -> runDB $ do
|
||||||
participants <- E.select . E.from $ \(registration `E.InnerJoin` user) -> do
|
participants <- E.select . E.from $ \(registration `E.InnerJoin` user) -> do
|
||||||
@ -115,11 +148,12 @@ postEAutoOccurrenceR tid ssh csh examn = do
|
|||||||
return (uid, (userRec, examRegistrationOccurrence))
|
return (uid, (userRec, examRegistrationOccurrence))
|
||||||
occurrences' = Map.fromList $ map (\(Entity eoId ExamOccurrence{..}) -> (eoId, _examOccurrenceCapacityIso # (fromIntegral <$> examOccurrenceCapacity))) occurrences
|
occurrences' = Map.fromList $ map (\(Entity eoId ExamOccurrence{..}) -> (eoId, _examOccurrenceCapacityIso # (fromIntegral <$> examOccurrenceCapacity))) occurrences
|
||||||
autoOccurrenceResult = examAutoOccurrence eId examOccurrenceRule eaofConfig occurrences' participants'
|
autoOccurrenceResult = examAutoOccurrence eId examOccurrenceRule eaofConfig occurrences' participants'
|
||||||
(eaofMapping, eaofAssignment) <- case autoOccurrenceResult of
|
(eaofMapping, eaofAssignment, _ignoredOccurrences) <- case autoOccurrenceResult of
|
||||||
(Left e) -> do
|
(Left e) -> do
|
||||||
addMessageI Error e
|
addMessageI Error e
|
||||||
redirect $ CExamR tid ssh csh examn EUsersR
|
redirect $ CExamR tid ssh csh examn EUsersR
|
||||||
(Right r) -> pure r
|
(Right r) -> pure r
|
||||||
|
-- TODO use returned ignoredOccurrences
|
||||||
return $ Just ExamAutoOccurrenceAcceptForm{..}
|
return $ Just ExamAutoOccurrenceAcceptForm{..}
|
||||||
|
|
||||||
((confirmRes, confirmView), confirmEncoding) <- runFormPost $ examAutoOccurrenceAcceptForm calcResult
|
((confirmRes, confirmView), confirmEncoding) <- runFormPost $ examAutoOccurrenceAcceptForm calcResult
|
||||||
@ -153,6 +187,14 @@ postEAutoOccurrenceR tid ssh csh examn = do
|
|||||||
, formAttrs = [("class", "buttongroup")]
|
, formAttrs = [("class", "buttongroup")]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let ignoreRoomWgt = ignoreRoomsRes <&> \((_, ignoreRoomsView), ignoreRoomsEncoding) ->
|
||||||
|
wrapForm ignoreRoomsView def
|
||||||
|
{ formAction = Just . SomeRoute $ CExamR tid ssh csh examn EAutoOccurrenceR
|
||||||
|
, formEncoding = ignoreRoomsEncoding
|
||||||
|
, formSubmit = FormNoSubmit
|
||||||
|
, formAttrs = [("class", "buttongroup")]
|
||||||
|
}
|
||||||
|
|
||||||
ExamAutoOccurrenceAcceptForm{..} <- maybe (redirect $ CExamR tid ssh csh examn EUsersR) return calcResult
|
ExamAutoOccurrenceAcceptForm{..} <- maybe (redirect $ CExamR tid ssh csh examn EUsersR) return calcResult
|
||||||
|
|
||||||
let heading = MsgTitleExamAutoOccurrence tid ssh csh examn
|
let heading = MsgTitleExamAutoOccurrence tid ssh csh examn
|
||||||
|
|||||||
@ -6,7 +6,7 @@ module Handler.Utils.Exam
|
|||||||
, examRelevantSheets, examBonusPossible, examBonusAchieved
|
, examRelevantSheets, examBonusPossible, examBonusAchieved
|
||||||
, examResultBonus, examGrade
|
, examResultBonus, examGrade
|
||||||
, examBonusGrade
|
, examBonusGrade
|
||||||
, ExamAutoOccurrenceConfig
|
, ExamAutoOccurrenceConfig, ExamAutoOccurrenceIgnoreRooms(..)
|
||||||
, eaocIgnoreRooms, eaocFinenessCost, eaocNudge, eaocNudgeSize
|
, eaocIgnoreRooms, eaocFinenessCost, eaocNudge, eaocNudgeSize
|
||||||
, _eaocIgnoreRooms, _eaocFinenessCost, _eaocNudge, _eaocNudgeSize
|
, _eaocIgnoreRooms, _eaocFinenessCost, _eaocNudge, _eaocNudgeSize
|
||||||
, ExamAutoOccurrenceException(..)
|
, ExamAutoOccurrenceException(..)
|
||||||
|
|||||||
@ -229,7 +229,7 @@ data FormIdentifier
|
|||||||
| FIDUserAuthMode | FIDUserAssimilate | FIDUserRights | FIDUserAuthentication
|
| FIDUserAuthMode | FIDUserAssimilate | FIDUserRights | FIDUserAuthentication
|
||||||
| FIDAllUsersAction
|
| FIDAllUsersAction
|
||||||
| FIDLanguage
|
| FIDLanguage
|
||||||
| FIDExamAutoOccurrenceCalculate | FIDExamAutoOccurrenceConfirm | FIDExamAutoOccurrenceNudge UUID
|
| FIDExamAutoOccurrenceCalculate | FIDExamAutoOccurrenceConfirm | FIDExamAutoOccurrenceNudge UUID | FIDExamAutoOccurrenceIgnoreRooms UUID
|
||||||
| FIDAllocationAccept
|
| FIDAllocationAccept
|
||||||
| FIDTestDownload
|
| FIDTestDownload
|
||||||
| FIDAllocationRegister
|
| FIDAllocationRegister
|
||||||
|
|||||||
@ -34,6 +34,8 @@ $newline never
|
|||||||
<td .table__td>
|
<td .table__td>
|
||||||
$maybe nudgeWgt' <- Map.lookup occId nudgeWgt
|
$maybe nudgeWgt' <- Map.lookup occId nudgeWgt
|
||||||
^{nudgeWgt'}
|
^{nudgeWgt'}
|
||||||
|
$maybe ignoreRoomWgt' <- Map.lookup occId ignoreRoomWgt
|
||||||
|
^{ignoreRoomWgt'}
|
||||||
<td .table__td>
|
<td .table__td>
|
||||||
$maybe mappingWgt <- occMapping occId
|
$maybe mappingWgt <- occMapping occId
|
||||||
^{mappingWgt}
|
^{mappingWgt}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user