SheetGradeSummary Refactor Attempt1

This commit is contained in:
SJost 2018-12-19 11:35:36 +01:00
parent b32654b720
commit 47b2808dd4
6 changed files with 26 additions and 14 deletions

View File

@ -69,7 +69,7 @@ CourseSemester: Semester
CourseSchool: Institut CourseSchool: Institut
CourseSchoolShort: Fach CourseSchoolShort: Fach
CourseSecretTip: Anmeldung zum Kurs erfordert Eingabe des Passworts, sofern gesetzt CourseSecretTip: Anmeldung zum Kurs erfordert Eingabe des Passworts, sofern gesetzt
CourseRegisterFromTip: Ohne Datum ist keine Anmeldung möglich CourseRegisterFromTip: Ohne Datum ist keine eigenständige Anmeldung von Studierenden möglich
CourseRegisterToTip: Anmeldung darf auch ohne Begrenzung möglich sein CourseRegisterToTip: Anmeldung darf auch ohne Begrenzung möglich sein
CourseDeregisterUntilTip: Abmeldung darf auch ohne Begrenzung möglich sein CourseDeregisterUntilTip: Abmeldung darf auch ohne Begrenzung möglich sein
CourseFilterSearch: Volltext-Suche CourseFilterSearch: Volltext-Suche

View File

@ -252,7 +252,6 @@ makeCorrectionsTable whereClause dbtColonnade psValidator dbtProj' dbtParams = d
E.orderBy [E.asc $ user E.^. UserSurname] E.orderBy [E.asc $ user E.^. UserSurname]
E.limit 1 E.limit 1
return (user E.^. UserSurname) return (user E.^. UserSurname)
) )
] ]
, dbtFilter = Map.fromList , dbtFilter = Map.fromList

View File

@ -201,7 +201,7 @@ getSheetListR tid ssh csh = do
] ]
psValidator = def psValidator = def
& defaultSorting [SortAscBy "submission-since"] & defaultSorting [SortDescBy "submission-since"]
(table,raw_statistics) <- runDB $ liftA2 (,) (table,raw_statistics) <- runDB $ liftA2 (,)
(dbTableWidget' psValidator DBTable (dbTableWidget' psValidator DBTable

View File

@ -109,7 +109,7 @@ instance FromJSON a => FromJSON (E.Value a) where
parseJSON = fmap E.Value . parseJSON parseJSON = fmap E.Value . parseJSON
type Count = Sum Integer
type Points = Centi type Points = Centi
toPoints :: Integral a => a -> Points -- deprecated toPoints :: Integral a => a -> Points -- deprecated
@ -130,6 +130,8 @@ data SheetGrading
| PassBinary -- non-zero means passed | PassBinary -- non-zero means passed
deriving (Eq, Read, Show, Generic) deriving (Eq, Read, Show, Generic)
makeLenses_ ''SheetGrading
deriveJSON defaultOptions deriveJSON defaultOptions
{ constructorTagModifier = camelToPathPiece { constructorTagModifier = camelToPathPiece
, fieldLabelModifier = intercalate "-" . map toLower . dropEnd 1 . splitCamel , fieldLabelModifier = intercalate "-" . map toLower . dropEnd 1 . splitCamel
@ -143,11 +145,15 @@ gradingPassed (PassPoints {..}) pts = Just $ pts >= passingPoints
gradingPassed (PassBinary {}) pts = Just $ pts /= 0 gradingPassed (PassBinary {}) pts = Just $ pts /= 0
data SheetGradeSummary = SheetGradeSummary data SheetGradeSummary = SheetGradeSummary
{ numSheets :: Sum Int { numSheets -- Total number of sheets, includes all
, numGradePasses :: Sum Int , numGradePasses -- Number of sheets required to pass
, sumGradePoints :: Sum Points , numPointSheets -- Number of sheets having points
, achievedPasses :: Maybe (Sum Int) , numMarked :: Count -- Number of already marked sheets
, achievedPoints :: Maybe (Sum Points) , numMarkedPoints:: Count -- Number of already marked sheets
, numMarkedPasses:: Count -- Number of already marked sheets
, sumGradePoints :: Sum Points -- Total of achievable points
, achievedPasses :: Count --
, achievedPoints :: Sum Points --
} deriving (Generic, Read, Show, Eq) } deriving (Generic, Read, Show, Eq)
instance Monoid SheetGradeSummary where instance Monoid SheetGradeSummary where
@ -160,15 +166,18 @@ instance Semigroup SheetGradeSummary where
makeLenses_ ''SheetGradeSummary makeLenses_ ''SheetGradeSummary
sheetGradeSum :: SheetGrading -> Maybe Points -> SheetGradeSummary sheetGradeSum :: SheetGrading -> Maybe Points -> SheetGradeSummary
sheetGradeSum gr (Just p) = sheetGradeSum gr (Just p) = sheetGradeSum gr Nothing
let baseSum = (sheetGradeSum gr Nothing) { achievedPasses = Sum . bool 0 1 <$> gradingPassed gr p } { numMarked = 1
in case gr of PassBinary -> baseSum , achievedPasses = fromMaybe mempty $ bool 0 1 <$> gradingPassed gr p
_other -> baseSum { achievedPoints = Just $ Sum $ p } , achievedPoints = bool mempty (Sum p) $ has _maxPoints gr
}
sheetGradeSum (Points {..}) Nothing = mempty { numSheets = Sum 1 sheetGradeSum (Points {..}) Nothing = mempty { numSheets = Sum 1
, numPointSheets = Sum 1
, sumGradePoints = Sum maxPoints , sumGradePoints = Sum maxPoints
} }
sheetGradeSum (PassPoints{..}) Nothing = mempty { numSheets = Sum 1 sheetGradeSum (PassPoints{..}) Nothing = mempty { numSheets = Sum 1
, numGradePasses = Sum 1 , numGradePasses = Sum 1
, numPointSheets = Sum 1
, sumGradePoints = Sum maxPoints , sumGradePoints = Sum maxPoints
} }
sheetGradeSum (PassBinary) Nothing = mempty { numSheets = Sum 1 sheetGradeSum (PassBinary) Nothing = mempty { numSheets = Sum 1

View File

@ -1,4 +1,8 @@
$# Displays gradings Summary for various purposes $# Displays gradings Summary for various purposes
$# Expects several variables:
$# hasPassing :: Maybe Int -- Should Passing be displayed?
$# hasPoints :: Maybe Points -- Should Points be displayed?
$# summary :: SheetGradeSummary -- summary to display
$# -- $# --
<div> <div>
<h3>_{title $ getSum $ numSheets $ sumSummaries} <h3>_{title $ getSum $ numSheets $ sumSummaries}

View File

@ -1,7 +1,7 @@
$# Displays one row of the grading summary $# Displays one row of the grading summary
$# Expects several variables: $# Expects several variables:
$# hasPassing :: Maybe Int -- Should Passing be displayed? $# hasPassing :: Maybe Int -- Should Passing be displayed?
$# hasPoints :: Maybe Poibts -- Should Points be displayed? $# hasPoints :: Maybe Points -- Should Points be displayed?
$# summary :: SheetGradeSummary -- summary to display $# summary :: SheetGradeSummary -- summary to display
$# sumHeader :: UniWorXMessage -- row header $# sumHeader :: UniWorXMessage -- row header
$# $#