Unify sheet type with grading schema

This commit is contained in:
Gregor Kleen 2017-10-09 19:46:45 +02:00
parent 3cebf133bf
commit 59f4c0c74a
3 changed files with 18 additions and 8 deletions

6
models
View File

@ -53,8 +53,6 @@ Sheet
courseId CourseId courseId CourseId
name Text name Text
sheetType SheetType sheetType SheetType
maxPoints Double Maybe
requiredPoints Double Maybe
markingText Text Maybe markingText Text Maybe
activeFrom UTCTime activeFrom UTCTime
activeTo UTCTime activeTo UTCTime
@ -73,11 +71,11 @@ File
title FilePath title FilePath
content ByteString Maybe -- Nothing iff this is a directory content ByteString Maybe -- Nothing iff this is a directory
modified UTCTime modified UTCTime
deriving Show Eq Ord deriving Show Eq
Submission Submission
sheetId SheetId sheetId SheetId
ratingBy UserId Maybe ratingBy UserId Maybe
ratingPoints Double Maybe ratingPoints Points Maybe
ratingComment Text Maybe ratingComment Text Maybe
rated UTCTime Maybe rated UTCTime Maybe
created UTCTime created UTCTime

View File

@ -10,3 +10,5 @@ import Settings.StaticFiles as Import
import Yesod.Auth as Import import Yesod.Auth as Import
import Yesod.Core.Types as Import (loggerSet) import Yesod.Core.Types as Import (loggerSet)
import Yesod.Default.Config2 as Import import Yesod.Default.Config2 as Import
import Data.Fixed as Import

View File

@ -8,6 +8,8 @@ module Model.Types where
import ClassyPrelude import ClassyPrelude
import Data.Fixed
import Common import Common
import Database.Persist.TH import Database.Persist.TH
@ -26,14 +28,22 @@ import qualified Data.CaseInsensitive as CI
import Yesod.Core.Dispatch (PathPiece(..)) import Yesod.Core.Dispatch (PathPiece(..))
import Data.Aeson (FromJSON(..), ToJSON(..), withText, Value(..)) import Data.Aeson (FromJSON(..), ToJSON(..), withText, Value(..))
import Data.Aeson.TH (deriveJSON, defaultOptions)
import GHC.Generics (Generic) import GHC.Generics (Generic)
import Data.Typeable (Typeable) import Data.Typeable (Typeable)
data SheetType = Regular | Bonus | Extra type Points = Centi
deriving (Show, Read, Eq, Ord, Enum, Bounded)
derivePersistField "SheetType" 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 data ExamStatus = Attended | NoShow | Voided
deriving (Show, Read, Eq, Ord, Enum, Bounded) deriving (Show, Read, Eq, Ord, Enum, Bounded)