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
start UTCTime
end UTCTime
holidays [UTCTime]
UniqueTerm name
deriving Eq
School json
name Text
UniqueSchool name
deriving Eq
Degree json
name Text
schoolId SchoolId
UniqueDegree name schoolId
deriving Eq
DegreeCourse json
degreeId DegreeId
courseId CourseId
UniqueDegreeCourse degreeId courseId
Course json
name Text
owner UserId
@ -37,13 +47,13 @@ Course json
registerFrom UTCTime
registerTo UTCTime
Lecturer
userId UserId
courseId CourseId
userId UserId
courseId CourseId
UniqueLecturer userId courseId
CourseParticipant
userId UserId
courseId CourseId
registration UTCTime
userId UserId
courseId CourseId
registration UTCTime
UniqueCourseParticipant userId courseId
Sheet
courseId CourseId
@ -54,7 +64,7 @@ Sheet
exerciseId FileId Maybe
hintId FileId Maybe
solutionId FileId Maybe
markingId FIleID Maybe
markingId FileId Maybe
markingText Text
activeFrom UTCTime
activeTo UTCTime
@ -65,8 +75,8 @@ Sheet
createdBy UserId
changedBy UserId
File
name Text
content ByteStream
title Text
content ByteString
Submission
sheetId SheetId
fileId FileId
@ -91,46 +101,55 @@ SubmissionGroup
createdBy UserId
changedBy UserId
SubmissionGroupUser
solutionGroupId SolutionGroupId
userId UserId
UniqueSubmissionGroupUser solutionGroupId userId
--
submissionGroupId SubmissionGroupId
userId UserId
UniqueSubmissionGroupUser submissionGroupId userId
Tutorial json
name Text
tutor UserId
TutorialParticipant
TutorialUser
userId UserId
tutorialId TutorialId
UniqueTutorialParticipant userId tutorialId
-- Unclear how to model this correctly
UniqueTutorialUser userId tutorialId
Booking
termId TermId
begin UTCTime
end UTCTime
weekly Bool
exceptions [UTCTime]
created UTCTime
changed UTCTime
createdBy UserId
changedBy UserId
Room
name Text
capacity Int Maybe
building Text
RoomCourse
roomId RoomId
courseId CourseId
-- not unique, as a course might happen several times
RoomTutorial
tutorialId TutorialId Maybe
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
begin UTCTime
end UTCTime
created UTCTime
changed UTCTime
bookingId BookingId
UniqueRoomCourse courseId roomId bookingId
Exam
courseId CourseId
name Text
description Text
begin UTCTime
end UTCTime
registrationBegin UTCTime
registrationEnd UTCTime
deregistrationEnd UTCTime
ratingVisible Bool
statisticsVisible Bool
created 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)

View File

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

View File

@ -11,6 +11,9 @@ module Model where
import ClassyPrelude.Yesod
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 find more information on persistent and how to declare entities
@ -20,7 +23,7 @@ share [mkPersist sqlSettings, mkMigrate "migrateAll"]
$(persistFileWith lowerCaseSettings "config/models")
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)
derivePersistField "SheetType"
{- Not needed
data Weekday = Mon | Tue | Wed | Thu | Fri | Sat | Sun
deriving (Show, Read, Eq, Ord, Enum, Bounded)
derivePersistField "Weekday"
-}
data ExamStatus = Attended | NoShow | Voided
deriving (Show, Read, Eq, Ord, Enum, Bounded)
derivePersistField "ExamStatus"
{-
{- Modelled in DB
data Season = WS | SO
deriving (Show, Read, Eq, Enum)
derivePersistField "Season"
@ -24,9 +22,10 @@ data Term = Term { season:: Season, year :: Int }
instance Show Term where
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
-}