Compiles again. Model complete enough for initial run; exam support missing

This commit is contained in:
SJost 2017-10-03 10:04:23 +02:00
parent 12996816df
commit 8fc45cfd23
4 changed files with 74 additions and 52 deletions

View File

@ -20,12 +20,22 @@ Term json
name Text name Text
start UTCTime start UTCTime
end UTCTime end UTCTime
holidays [UTCTime]
UniqueTerm name UniqueTerm name
deriving Eq deriving Eq
School json School json
name Text name Text
UniqueSchool name UniqueSchool name
deriving Eq deriving Eq
Degree json
name Text
schoolId SchoolId
UniqueDegree name schoolId
deriving Eq
DegreeCourse json
degreeId DegreeId
courseId CourseId
UniqueDegreeCourse degreeId courseId
Course json Course json
name Text name Text
owner UserId owner UserId
@ -54,7 +64,7 @@ Sheet
exerciseId FileId Maybe exerciseId FileId Maybe
hintId FileId Maybe hintId FileId Maybe
solutionId FileId Maybe solutionId FileId Maybe
markingId FIleID Maybe markingId FileId Maybe
markingText Text markingText Text
activeFrom UTCTime activeFrom UTCTime
activeTo UTCTime activeTo UTCTime
@ -65,8 +75,8 @@ Sheet
createdBy UserId createdBy UserId
changedBy UserId changedBy UserId
File File
name Text title Text
content ByteStream content ByteString
Submission Submission
sheetId SheetId sheetId SheetId
fileId FileId fileId FileId
@ -91,46 +101,55 @@ SubmissionGroup
createdBy UserId createdBy UserId
changedBy UserId changedBy UserId
SubmissionGroupUser SubmissionGroupUser
solutionGroupId SolutionGroupId submissionGroupId SubmissionGroupId
userId UserId userId UserId
UniqueSubmissionGroupUser solutionGroupId userId UniqueSubmissionGroupUser submissionGroupId userId
--
Tutorial json Tutorial json
name Text name Text
tutor UserId tutor UserId
TutorialParticipant TutorialUser
userId UserId userId UserId
tutorialId TutorialId tutorialId TutorialId
UniqueTutorialParticipant userId tutorialId UniqueTutorialUser userId tutorialId
-- Unclear how to model this correctly Booking
termId TermId
begin UTCTime
end UTCTime
weekly Bool
exceptions [UTCTime]
created UTCTime
changed UTCTime
createdBy UserId
changedBy UserId
Room Room
name Text name Text
capacity Int Maybe capacity Int Maybe
building Text building Text
RoomCourse RoomCourse
roomId RoomId
courseId CourseId courseId CourseId
-- not unique, as a course might happen several times tutorialId TutorialId Maybe
RoomTutorial examId ExamId Maybe
roomId RoomId
tutorialId TutorialId
RoomExam
roomId RoomId
examId ExamId
RoomBookingRecurring
roomId RoomId
termId termId
start TimeOfDay
end TimeOfDay
day Weekday
created UTCTime
changed UTCTime
RoomBooking
roomId RoomId roomId RoomId
bookingId BookingId
UniqueRoomCourse courseId roomId bookingId
Exam
courseId CourseId
name Text
description Text
begin UTCTime begin UTCTime
end UTCTime end UTCTime
registrationBegin UTCTime
registrationEnd UTCTime
deregistrationEnd UTCTime
ratingVisible Bool
statisticsVisible Bool
created UTCTime created UTCTime
changed UTCTime changed UTCTime
createdBy UserId
changedBy UserId
ExamUser
userId UserId
examId ExamId
-- CONTINUE HERE: Inlcude rating in this table or seperatly?
UniqueExamUser userId examId
-- By default this file is used in Model.hs (which is imported by Foundation.hs) -- By default this file is used in Model.hs (which is imported by Foundation.hs)

View File

@ -4,3 +4,4 @@ module Import
import Foundation as Import import Foundation as Import
import Import.NoFoundation as Import import Import.NoFoundation as Import
import ModelData as Import

View File

@ -11,6 +11,9 @@ module Model where
import ClassyPrelude.Yesod import ClassyPrelude.Yesod
import Database.Persist.Quasi import Database.Persist.Quasi
-- import Data.Time
-- import Data.ByteString
import ModelData
-- You can define all of your database entities in the entities file. -- You can define all of your database entities in the entities file.
-- You can find more information on persistent and how to declare entities -- You can find more information on persistent and how to declare entities
@ -20,7 +23,7 @@ share [mkPersist sqlSettings, mkMigrate "migrateAll"]
$(persistFileWith lowerCaseSettings "config/models") $(persistFileWith lowerCaseSettings "config/models")
instance Show Term where instance Show Term where
show = termName show = ClassyPrelude.Yesod.unpack . termName

View File

@ -9,13 +9,11 @@ data SheetType = Regular | Bonus | Extra
deriving (Show, Read, Eq, Ord, Enum, Bounded) deriving (Show, Read, Eq, Ord, Enum, Bounded)
derivePersistField "SheetType" derivePersistField "SheetType"
{- Not needed data ExamStatus = Attended | NoShow | Voided
data Weekday = Mon | Tue | Wed | Thu | Fri | Sat | Sun
deriving (Show, Read, Eq, Ord, Enum, Bounded) deriving (Show, Read, Eq, Ord, Enum, Bounded)
derivePersistField "Weekday" derivePersistField "ExamStatus"
-}
{- {- Modelled in DB
data Season = WS | SO data Season = WS | SO
deriving (Show, Read, Eq, Enum) deriving (Show, Read, Eq, Enum)
derivePersistField "Season" derivePersistField "Season"
@ -24,9 +22,10 @@ data Term = Term { season:: Season, year :: Int }
instance Show Term where instance Show Term where
show (Term {season, year}) = take 1 (show season) ++ (show year) show (Term {season, year}) = take 1 (show season) ++ (show year)
instance PersistField Term where
toPersistValue (Term {season, year}) = undefined
fromPersistValue (Term {season, year}) = undefined
sqlType _ = SqlInteger
isNullable _ = False
-} -}
-- instance PersistField Term where
-- toPersistValue (Term {season, year}) = undefined
-- fromPersistValue (Term {season, year}) = undefined
-- sqlType _ = SqlInteger
-- isNullable _ = False