36 lines
1.5 KiB
Haskell
36 lines
1.5 KiB
Haskell
module Model.Rating where
|
|
|
|
import ClassyPrelude.Yesod
|
|
import Model
|
|
-- import Data.Text (Text)
|
|
import Data.Text.Encoding.Error (UnicodeException(..))
|
|
|
|
|
|
data Rating = Rating
|
|
{ ratingCourseName :: CourseName
|
|
, ratingSheetName :: SheetName
|
|
, ratingCorrectorName :: Maybe Text
|
|
, ratingSheetType :: SheetType
|
|
, ratingValues :: Rating'
|
|
} deriving (Read, Show, Eq, Generic, Typeable)
|
|
|
|
data Rating' = Rating'
|
|
{ ratingPoints :: Maybe Points
|
|
, ratingComment :: Maybe Text
|
|
, ratingTime :: Maybe UTCTime
|
|
} deriving (Read, Show, Eq, Generic, Typeable)
|
|
|
|
data RatingException = RatingNotUnicode UnicodeException -- ^ Rating failed to parse as unicode
|
|
| RatingMissingSeparator -- ^ Could not split rating header from comments
|
|
| RatingMultiple -- ^ Encountered multiple point values in rating
|
|
| RatingInvalid Text -- ^ Failed to parse rating point value
|
|
| RatingFileIsDirectory -- ^ We do not expect this to, it's included for totality
|
|
| RatingNegative -- ^ Rating points must be non-negative
|
|
| RatingExceedsMax -- ^ Rating point must not exceed maximum points
|
|
| RatingNotExpected -- ^ Rating not expected
|
|
| RatingBinaryExpected -- ^ Rating must be 0 or 1
|
|
| RatingPointsRequired -- ^ Rating without points for sheet that requires there to be points
|
|
deriving (Show, Eq, Generic, Typeable)
|
|
|
|
instance Exception RatingException
|