Rough sketch of models/exams

This commit is contained in:
Gregor Kleen 2019-05-15 15:12:00 +02:00
parent db915f5736
commit 09196971f8
3 changed files with 79 additions and 24 deletions

View File

@ -1,22 +1,40 @@
-- EXAMS ARE TODO; THIS IS JUST AN UNUSED STUB
Exam
course CourseId
name Text
description Text
begin UTCTime
end UTCTime
registrationBegin UTCTime
registrationEnd UTCTime
deregistrationEnd UTCTime
ratingVisible Bool -- may participants see their own rating yet
statisticsVisible Bool -- may participants view statistics over all participants (should not be allowed for 'small' courses)
--ExamEdit
-- user UserId
-- time UTCTime
-- exam ExamId
--ExamUser
-- user UserId
-- examId ExamId
-- -- CONTINUE HERE: Include rating in this table or separately?
-- UniqueExamUser user examId
-- By default this file is used in Model.hs (which is imported by Foundation.hs)
course CourseId
name (CI Text)
gradingKey [Points] -- [n1,n2,n3,...] means 0 <= p < n1 -> p ~= 5, n1 <= p < n2 -> p ~ 4.7, n2 <= p < n3 -> p ~ 4.3, ...
bonusRule ExamBonusRule
occuranceRule ExamOccuranceRule
registerFrom UTCTime Maybe
registerTo UTCTime Maybe
deregisterUntil UTCTime Maybe
start UTCTime
end UTCTime Maybe
finished UTCTime Maybe -- Grades shown to students, `ExamCorrector`s locked out
closed Bool -- Prüfungsamt hat Einsicht (notification)
publicStatistics Bool
description Html Maybe
UniqueExam course name
ExamPart
exam ExamId
name (CI Text)
maxPoints Points Maybe
weight Rational
UniqueExamPart exam name
ExamOccurance
exam ExamId
room Text
capacity Natural
ExamRegistration
exam ExamId
user UserId
occurance ExamOccuranceId Maybe
UniqueExamRegistration exam user
ExamResult
examPart ExamPartId
user UserId
result ExamPartResult
UniqueExamResult examPart user
ExamCorrector
examPart ExamPartId
user UserId
UniqueExamCorrector examPart user

View File

@ -288,6 +288,10 @@ customMigrations = Map.fromListWith (>>)
tableDropEmpty "tutorial"
tableDropEmpty "tutorial_user"
)
, ( AppliedMigrationKey [migrationVersion|12.0.0|] [version|13.0.0|]
, whenM (tableExists "exam") $ -- Exams were an unused stub before
tableDropEmpty "exam"
)
]

View File

@ -366,9 +366,42 @@ classifySubmissionMode (SubmissionMode False (Just _)) = SubmissionModeUser
classifySubmissionMode (SubmissionMode True (Just _)) = SubmissionModeBoth
data ExamStatus = Attended | NoShow | Voided
deriving (Show, Read, Eq, Ord, Enum, Bounded, Generic)
derivePersistField "ExamStatus"
data ExamPartResult = ExamAttended { examPartResult :: Maybe Points }
| ExamNoShow
| ExamVoided
deriving (Show, Read, Eq, Ord, Generic, Typeable)
deriveJSON defaultOptions
{ constructorTagModifier = camelToPathPiece' 1
, fieldLabelModifier = camelToPathPiece' 2
, omitNothingFields = True
, sumEncoding = TaggedObject "status" "result"
} ''ExamPartResult
derivePersistFieldJSON ''ExamPartResult
data ExamBonusRule = ExamNoBonus
| ExamBonusPoints
{ bonusExchangeRate :: Rational
, bonusOnlyPassed :: Bool
}
deriving (Show, Read, Eq, Ord, Generic, Typeable)
deriveJSON defaultOptions
{ constructorTagModifier = camelToPathPiece' 1
, fieldLabelModifier = camelToPathPiece' 1
, sumEncoding = TaggedObject "rule" "settings"
} ''ExamBonusRule
derivePersistFieldJSON ''ExamBonusRule
data ExamOccuranceRule = ExamRoomManual
| ExamRoomSurname
| ExamRoomMatriculation
| ExamRoomRandom
deriving (Show, Read, Eq, Ord, Generic, Typeable)
deriveJSON defaultOptions
{ constructorTagModifier = camelToPathPiece' 2
, fieldLabelModifier = camelToPathPiece' 1
, sumEncoding = TaggedObject "rule" "settings"
} ''ExamOccuranceRule
derivePersistFieldJSON ''ExamOccuranceRule
-- | Specify a corrector's workload
data Load -- = ByTutorial { countsToLoad :: Bool } | ByProportion { load :: Rational }