-- SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Wolfgang Witt <Wolfgang.Witt@campus.lmu.de>
--
-- SPDX-License-Identifier: AGPL-3.0-or-later

Exam
  course CourseId OnDeleteCascade OnUpdateCascade
  name ExamName
  gradingRule ExamGradingRule Maybe
  bonusRule ExamBonusRule Maybe
  occurrenceRule ExamOccurrenceRule
  examOccurrenceMapping (ExamOccurrenceMapping ExamOccurrenceName) Maybe
  visibleFrom UTCTime Maybe
  registerFrom UTCTime Maybe
  registerTo UTCTime Maybe
  deregisterUntil UTCTime Maybe
  publishOccurrenceAssignments UTCTime Maybe
  start UTCTime Maybe
  end UTCTime Maybe
  finished UTCTime Maybe -- Grades shown to students, `ExamCorrector`s locked out
  closed UTCTime Maybe -- Prüfungsamt hat Einsicht (notification)
  publicStatistics Bool
  gradingMode ExamGradingMode
  description StoredMarkup Maybe
  examMode ExamMode
  staff Text Maybe
  partsFrom UTCTime Maybe
  authorshipStatement AuthorshipStatementDefinitionId Maybe
  UniqueExam course name
  deriving Generic
ExamPart
  exam ExamId
  number ExamPartNumber
  name ExamPartName Maybe
  maxPoints Points Maybe
  weight Rational
  UniqueExamPartNumber exam number
  UniqueExamPartName exam name !force
  deriving Read Show Eq Ord Generic
ExamOccurrence
  exam ExamId
  name ExamOccurrenceName
  room RoomReference Maybe
  roomHidden Bool default=false
  capacity Word64 Maybe
  start UTCTime
  end UTCTime Maybe
  description StoredMarkup Maybe
  UniqueExamOccurrence exam name
  deriving Generic
ExamRegistration
  exam ExamId
  user UserId
  occurrence ExamOccurrenceId Maybe
  time UTCTime default=now()
  UniqueExamRegistration exam user
  deriving Eq Ord Show Generic
ExamPartResult
  examPart ExamPartId
  user UserId
  result ExamResultPoints
  lastChanged UTCTime default=now()
  UniqueExamPartResult examPart user
  deriving Eq Ord Show Generic
ExamBonus
  exam ExamId
  user UserId
  bonus Points
  lastChanged UTCTime default=now()
  UniqueExamBonus exam user
  deriving Eq Ord Show Generic
ExamResult
  exam ExamId
  user UserId
  result ExamResultPassedGrade
  lastChanged UTCTime default=now()
  UniqueExamResult exam user
  deriving Eq Ord Show Generic
ExamCorrector
  exam ExamId
  user UserId
  UniqueExamCorrector exam user
  deriving Generic
ExamPartCorrector
  part ExamPartId
  corrector ExamCorrectorId
  UniqueExamPartCorrector part corrector
  deriving Generic
ExamOfficeSchool
  school SchoolId
  exam ExamId
  UniqueExamOfficeSchool exam school
  deriving Generic
