From 59f4c0c74acd831dbb172166dc3e8cfe31af53f8 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 9 Oct 2017 19:46:45 +0200 Subject: [PATCH] Unify sheet type with grading schema --- models | 8 +++----- src/Import/NoFoundation.hs | 2 ++ src/Model/Types.hs | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/models b/models index c0f97f8dc..d8ca30dcf 100644 --- a/models +++ b/models @@ -52,9 +52,7 @@ CourseParticipant Sheet courseId CourseId name Text - sheetType SheetType - maxPoints Double Maybe - requiredPoints Double Maybe + sheetType SheetType markingText Text Maybe activeFrom UTCTime activeTo UTCTime @@ -73,11 +71,11 @@ File title FilePath content ByteString Maybe -- Nothing iff this is a directory modified UTCTime - deriving Show Eq Ord + deriving Show Eq Submission sheetId SheetId ratingBy UserId Maybe - ratingPoints Double Maybe + ratingPoints Points Maybe ratingComment Text Maybe rated UTCTime Maybe created UTCTime diff --git a/src/Import/NoFoundation.hs b/src/Import/NoFoundation.hs index 9ca93f2a7..cf17f5064 100644 --- a/src/Import/NoFoundation.hs +++ b/src/Import/NoFoundation.hs @@ -10,3 +10,5 @@ import Settings.StaticFiles as Import import Yesod.Auth as Import import Yesod.Core.Types as Import (loggerSet) import Yesod.Default.Config2 as Import + +import Data.Fixed as Import diff --git a/src/Model/Types.hs b/src/Model/Types.hs index 6f82c640a..08856e56a 100644 --- a/src/Model/Types.hs +++ b/src/Model/Types.hs @@ -8,6 +8,8 @@ module Model.Types where import ClassyPrelude +import Data.Fixed + import Common import Database.Persist.TH @@ -26,14 +28,22 @@ import qualified Data.CaseInsensitive as CI import Yesod.Core.Dispatch (PathPiece(..)) import Data.Aeson (FromJSON(..), ToJSON(..), withText, Value(..)) +import Data.Aeson.TH (deriveJSON, defaultOptions) import GHC.Generics (Generic) import Data.Typeable (Typeable) -data SheetType = Regular | Bonus | Extra - deriving (Show, Read, Eq, Ord, Enum, Bounded) -derivePersistField "SheetType" +type Points = Centi + +data SheetType + = Bonus { maxPoints :: Points } + | Normal { maxPoints :: Points } + | Pass { maxPoints, passingPoints :: Points } + | NotGraded + deriving (Show, Read, Eq) +deriveJSON defaultOptions ''SheetType +derivePersistFieldJSON "SheetType" data ExamStatus = Attended | NoShow | Voided deriving (Show, Read, Eq, Ord, Enum, Bounded)