module Model.Rating where

import ClassyPrelude.Yesod
import Model
-- import Data.Text (Text)
import Data.Text.Encoding.Error (UnicodeException(..))
import GHC.Generics (Generic)
import Data.Typeable (Typeable)


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 String -- ^ 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
  deriving (Show, Eq, Generic, Typeable)

instance Exception RatingException
