-
Notifications
You must be signed in to change notification settings - Fork 0
/
BAMQuiz-test.hs
executable file
·49 lines (44 loc) · 1.14 KB
/
BAMQuiz-test.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{-# LANGUAGE QuasiQuotes, TypeFamilies, GeneralizedNewtypeDeriving, FlexibleContexts #-}
{-# LANGUAGE TemplateHaskell, OverloadedStrings, GADTs, MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns, RecordWildCards #-}
import Yesod
import Yesod.Form.Jquery
import Text.Blaze (preEscapedToMarkup)
import Data.Text
import Data.List (sortBy)
import Data.Ord (comparing)
import Data.Maybe (isJust)
import Database.Persist
import Database.Persist.Store
import Database.Persist.Sqlite
import Database.Persist.TH
import Control.Monad.Error
import Control.Monad (Join)
import Control.Applicative ((<$>), (<*>))
-- Our foundation type.
data Quiz = Quiz {dbPool :: ConnectionPool}
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persist|
Category
name Text
deriving Show
Team
name Text
deriving Show
Question
category CategoryId
body Text
choice1 Text
choice2 Text Maybe
choice3 Text Maybe
choice4 Text Maybe
answer Int
points Int
deriving Show
Submission
team teamId
category CategoryId
question QuestionId
choice Int
correct Bool
points Int
|]