From 32da6b5585b6f3f4255207f2f0723ce07d7594d5 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 17 Aug 2018 17:03:29 +0200 Subject: [PATCH] Traverse submissions in random order --- src/Handler/Utils/Submission.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Handler/Utils/Submission.hs b/src/Handler/Utils/Submission.hs index 2e866c46f..06f8ec024 100644 --- a/src/Handler/Utils/Submission.hs +++ b/src/Handler/Utils/Submission.hs @@ -166,7 +166,7 @@ assignSubmissions sid restriction = do $logDebugS "assignSubmissions" $ "Deterministic Queue: " <> tshow detQueue queue <- liftIO . Rand.evalRandIO . execWriterT $ do - tell . map Just =<< Rand.shuffleM detQueue + tell $ map Just detQueue forever $ tell . pure =<< Rand.weightedMay [ (sheetCorrectorUser, byProportion sheetCorrectorLoad) | Entity _ SheetCorrector{..} <- corrsProp ] @@ -184,8 +184,10 @@ assignSubmissions sid restriction = do maximumDeficit = do transposed <- uses _3 invertMap traverse (liftIO . Rand.evalRandIO . Rand.uniform . snd) (Map.lookupMax transposed) + + subTutor'' <- liftIO . Rand.evalRandIO . Rand.shuffleM $ Map.toList subTutor' - subTutor <- fmap (view _1) . flip execStateT (Map.empty, queue, deficit) . forM_ (Map.toList subTutor') $ \(smid, tuts) -> do + subTutor <- fmap (view _1) . flip execStateT (Map.empty, queue, deficit) . forM_ subTutor'' $ \(smid, tuts) -> do let restrictTuts | Set.null tuts = id