diff --git a/src/Handler/Corrections.hs b/src/Handler/Corrections.hs index 446b93273..ddf820d18 100644 --- a/src/Handler/Corrections.hs +++ b/src/Handler/Corrections.hs @@ -1177,8 +1177,10 @@ assignHandler tid ssh csh cid assignSids = do let -- infoMap :: Map SheetName (Map (Maybe UserId) CorrectionInfo) -- repeated here for easier reference -- create aggregate maps - sheetNames :: [SheetName] - sheetNames = Map.keys infoMap + + -- Always iterate over sheetList for consistent sorting! + sheetList :: [(SheetName, CorrectionInfo)] + sheetList = Map.toDescList sheetMap -- newest Sheet first, except for CorrectionSheetTable sheetMap :: Map SheetName CorrectionInfo sheetMap = Map.map fold infoMap @@ -1197,6 +1199,11 @@ assignHandler tid ssh csh cid assignSids = do corrMap :: Map (Maybe UserId) CorrectionInfo corrMap = Map.unionsWith (<>) $ Map.elems infoMap + corrInfos :: [CorrectionInfo] + corrInfos = sortBy (compare `on` (byName . ciCorrector) ) $ Map.elems corrMap + where byName Nothing = Nothing + byName (Just uid) = Map.lookup uid correctorMap + corrMapSum :: CorrectionInfo corrMapSum = fold corrMap @@ -1235,7 +1242,9 @@ assignHandler tid ssh csh cid assignSids = do showAvgsDays Nothing _ = mempty showAvgsDays (Just dt) n = formatDiffDays $ dt / fromIntegral n heat :: Integer -> Integer -> Double - heat full achieved = roundToDigits 3 $ cutOffPercent 0.4 (fromIntegral full) (fromIntegral achieved) + heat = heat' 0.3 + heat' :: Double -> Integer -> Integer -> Double + heat' cut full achieved = roundToDigits 3 $ cutOffPercent cut (fromIntegral full^2) (fromIntegral achieved^2) let headingShort | 0 < Map.size assignment = MsgMenuCorrectionsAssignSheet $ Text.intercalate ", " $ fmap CI.original $ Map.keys assignment | otherwise = MsgMenuCorrectionsAssign diff --git a/src/Model.hs b/src/Model.hs index 45ce97e6d..ee5a8bbd8 100644 --- a/src/Model.hs +++ b/src/Model.hs @@ -37,5 +37,14 @@ deriving instance Eq (Unique Material) -- instance Eq UniqueMaterial deriving instance Eq (Unique Tutorial) -- instance Eq Tutorial deriving instance Eq (Unique Exam) +instance Ord User where + compare User{userSurname=surnameA, userDisplayName=displayNameA, userEmail=emailA} + User{userSurname=surnameB, userDisplayName=displayNameB, userEmail=emailB} + = compare surnameA surnameB + <> compare displayNameA displayNameB + <> compare emailA emailB -- userEmail is unique, so this suffices + + + submissionRatingDone :: Submission -> Bool submissionRatingDone Submission{..} = isJust submissionRatingTime diff --git a/templates/corrections-overview.hamlet b/templates/corrections-overview.hamlet index 94ada0543..61e75f123 100644 --- a/templates/corrections-overview.hamlet +++ b/templates/corrections-overview.hamlet @@ -1,5 +1,6 @@

_{MsgCorrectionSheets} + _{MsgCourseParticipants nrParticipants} @@ -16,7 +17,8 @@
_{MsgGenericMin} _{MsgGenericAvg} _{MsgGenericMax} - $forall (sheetName, CorrectionInfo{ciSubmittors, ciSubmissions, ciAssigned, ciCorrected, ciMin, ciTot, ciMax}) <- Map.toList sheetMap + $# Always iterate over sheetList for consistent sorting! Newest first, except in this table + $forall (sheetName, CorrectionInfo{ciSubmittors, ciSubmissions, ciAssigned, ciCorrected, ciMin, ciTot, ciMax}) <- reverse sheetList
^{simpleLink (toWidget sheetName) (CSheetR tid ssh csh sheetName SSubsR)} $if groupsPossible @@ -39,15 +41,19 @@ #{showDiffDays ciMin} #{showAvgsDays ciTot ciCorrected} #{showDiffDays ciMax} + +

_{MsgCorrectionCorrectors} + @@ -56,13 +62,14 @@
_{MsgCorrector} _{MsgGenericAll} _{MsgCorDeficitProportion} _{MsgCorrectionTime} - $forall shn <- sheetNames + $# Always iterate over sheetList for consistent sorting! Newest first, except in this table + $forall (shn,_) <- sheetList #{shn} $# ^{simpleLinkI (SomeMessage MsgMenuCorrectors) (CSheetR tid ssh csh shn SCorrR)}
_{MsgGenericMin} _{MsgGenericAvg} _{MsgGenericMax} - $forall _shn <- sheetNames + $# Always iterate over sheetList for consistent sorting! Newest first, except in this table + $forall _shn <- sheetList _{MsgCorProportion} _{MsgNrSubmissionsTotalShort} _{MsgGenericNumChange} _{MsgNrSubmissionsNotCorrectedShort} _{MsgGenericAvg} - $forall (CorrectionInfo{ciCorrector, ciSubmissions=ciSubmissionsNr, ciCorrected, ciMin, ciTot, ciMax}) <- Map.elems corrMap + $forall (CorrectionInfo{ciCorrector, ciSubmissions=ciSubmissionsNr, ciCorrected, ciMin, ciTot, ciMax}) <- corrInfos $with (nameW,loadM) <- getCorrector ciCorrector
^{nameW} @@ -77,7 +84,8 @@ #{showDiffDays ciMin} #{showAvgsDays ciTot ciCorrected} #{showDiffDays ciMax} - $forall (shn, CorrectionInfo{ciSubmissions=sheetSubmissionsNr}) <- Map.toList sheetMap + $# Always iterate over sheetList for consistent sorting! Newest first, except in this table + $forall (shn, CorrectionInfo{ciSubmissions=sheetSubmissionsNr}) <- sheetList $maybe SheetCorrector{sheetCorrectorLoad, sheetCorrectorState} <- Map.lookup shn loadM #{showCompactCorrectorLoad sheetCorrectorLoad sheetCorrectorState} @@ -101,7 +109,7 @@ - $if 0 < length sheetNames + $if not (null sheetList)
Σ $with ciSubmissionsNr <- ciSubmissions corrMapSum @@ -112,9 +120,11 @@ #{showDiffDays (ciMin corrMapSum)} #{showAvgsDays (ciTot corrMapSum) (ciCorrected corrMapSum)} #{showDiffDays (ciMax corrMapSum)} - $forall shn <- sheetNames + $# Always iterate over sheetList for consistent sorting! Newest first, except in this table + $forall (shn, CorrectionInfo{ciSubmissions}) <- sheetList #{getLoadSum shn} - ^{simpleLinkI (SomeMessage MsgMenuCorrectorsChange) (CSheetR tid ssh csh shn SCorrR)} + #{ciSubmissions} + ^{simpleLinkI (SomeMessage MsgMenuCorrectorsChange) (CSheetR tid ssh csh shn SCorrR)} ^{btnWdgt}

_{MsgAssignSubmissionsRandomWarning} \ No newline at end of file