Commit 43f55d7b authored by Nicolas Lenz's avatar Nicolas Lenz
Browse files

Various

parent 9404a109
Pipeline #866 passed with stages
in 4 minutes and 18 seconds
/ HomeR GET
/add/#Int/#Int AddR GET
/form/#String FormR GET POST
/form/#Text FormR GET POST
......@@ -11,6 +11,7 @@ dependencies:
default-extensions:
- NoImplicitPrelude
- OverloadedStrings
- RecordWildCards
library:
source-dirs: src
......
......@@ -2,9 +2,11 @@ module Config where
import ClassyPrelude
-- newtype Id = Id Text deriving Show
data Config = Config
{ configAdmin :: ConfigAdmin
, configForms :: [ConfigForm]
, configForms :: Map Text ConfigForm
}
data ConfigAdmin = ConfigAdmin
......@@ -12,32 +14,29 @@ data ConfigAdmin = ConfigAdmin
, configAdminHash :: ByteString
}
data ConfigForm = ConfigForm
{ configFormId :: Text
, configFormContent :: ConfigFormContent
}
data ConfigFormContent
data ConfigForm
= ConfigFormSurvey
{ configFormSurveyHandler :: ConfigFormHandler
, configFormSurveyQuestions :: [ConfigFormSurveyQuestion]
, configFormSurveyQuestions :: Map Text ConfigFormSurveyQuestion
}
| ConfigFormQuiz
{ configFormQuizSuccess :: ConfigFormHandler
, configFormQuizFail :: ConfigFormHandler
, configFormQuizQuestions :: [ConfigFormQuizQuestion]
, configFormQuizQuestions :: Map Text ConfigFormQuizQuestion
}
data ConfigFormHandler = ConfigFormHandlerSuccess | ConfigFormHandlerFailure
data ConfigFormSurveyQuestion = ConfigFormSurveyQuestion
{ configFormSurveyQuestionId :: Text
, configFormSurveyQuestionType :: ConfigFormQuestionType
}
data ConfigFormHandler
= ConfigFormHandlerRedirect
| ConfigFormHandlerFile
data ConfigFormQuizQuestion = ConfigFormQuizQuestion
{ configFormQuizQuestionId :: Text
, configFormQuizQuestionType :: ConfigFormQuestionType
}
data ConfigFormSurveyQuestion
= ConfigFormSurveyQuestionString
| ConfigFormSurveyQuestionInt
data ConfigFormQuestionType = ConfigFormQuestionTypeString | ConfigFormQuestionTypeInt
data ConfigFormQuizQuestion
= ConfigFormQuizQuestionString
{ configFormQuizQuestionStringCorrect :: Text
}
| ConfigFormQuizQuestionInt
{ configFormQuizQuestionIntCorrect :: Int
}
......@@ -6,9 +6,20 @@ module Form where
import ClassyPrelude hiding (Handler)
import Foundation
import Yesod.Core
import Config
import Result
getFormR :: String -> Handler TypedContent
getFormR :: Text -> Handler TypedContent
getFormR id = undefined
postFormR :: String -> Handler TypedContent
postFormR id = undefined
cf :: Map Text ConfigForm
cf = undefined
postFormR :: Text -> Handler Html
postFormR id = case lookup id cf of
Just ConfigFormSurvey{..} -> do
result <- mapM (\question -> undefined) configFormSurveyQuestions
defaultLayout [whamlet|<p>${show result}|]
Just ConfigFormQuiz{..} -> do
undefined
Nothing -> defaultLayout [whamlet|<p>Oops.|]
module Result where
import ClassyPrelude
data Result = Map Text Answer deriving (Show)
data Answer = AnswerString Text | AnswerInt Int deriving (Show)
......@@ -18,11 +18,12 @@ library
Form
Foundation
Home
Result
other-modules:
Paths_surver
hs-source-dirs:
src
default-extensions: NoImplicitPrelude OverloadedStrings
default-extensions: NoImplicitPrelude OverloadedStrings RecordWildCards
build-depends:
base
, classy-prelude
......@@ -36,7 +37,7 @@ executable surver
Paths_surver
hs-source-dirs:
app
default-extensions: NoImplicitPrelude OverloadedStrings
default-extensions: NoImplicitPrelude OverloadedStrings RecordWildCards
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
base
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment