postSubmitExperimentR :: Handler Value
postSubmitExperimentR = do
    addHeader "Access-Control-Allow-Origin" "*"
    experiment <- requireJsonBody :: Handler Experiment
    let authinput = authentication experiment
        user = username authinput
        pass = password authinput
    mauth <- runDB $ getBy $ UniqueAuthentication user
    case mauth of
         Nothing -> return $ object [ "success" .= False ]
         Just (Entity _ auth) -> do
           let valid = verifyPassword (encodeUtf8 pass)
                                      (authenticationPassword auth)
           case valid of
                True -> do
                   time <- liftIO $ getZonedTime >>= \time -> return $ zonedTimeToUTC time
                   _ <- runDB $ do
                       subjId <- insert $ subject experiment
                       _ <- insert $ constructQuestion subjId time (questions experiment)
                       let rs = map (constructRating subjId) (ratings experiment)
                       mapM insert rs
                   return $ object [ "success" .= True ]
                False -> return $ object [ "success" .= False ]
postSubmitExperimentR :: Handler Value
postSubmitExperimentR = do
    addHeader "Access-Control-Allow-Origin" "*"
    experiment <- requireJsonBody :: Handler Experiment
    let authinput = authentication experiment
        user = username authinput
        pass = password authinput
    mauth <- runDB $ getBy $ UniqueAuthentication user
    case mauth of
         Nothing -> return $ object [ "success" .= False ]
         Just (Entity _ auth) -> do
           let valid = verifyPassword (encodeUtf8 pass)
                                      (authenticationPassword auth)
           case valid of
                True -> do
                   time <- liftIO $ getZonedTime >>= \time -> return $ zonedTimeToUTC time
                   _ <- runDB $ do
                       subjId <- insert $ subject experiment
                       _ <- insert $ constructQuestion subjId time (questions experiment)
                       let rs = map (constructRating subjId) (ratings experiment)
                       mapM insert rs
                   return $ object [ "success" .= True ]
                False -> return $ object [ "success" .= False ]
postSubmitExperimentR = do
    addHeader "Access-Control-Allow-Origin" "*"
    experiment <- requireJsonBody :: Handler Experiment
    let authinput = authentication experiment
        user = username authinput
        pass = password authinput
    mauth <- runDB $ getBy $ UniqueAuthentication user
    case mauth of
         Nothing -> return $ object [ "success" .= False ]
         Just (Entity _ auth) -> do
           let valid = verifyPassword (encodeUtf8 pass)
                                      (authenticationPassword auth)
           case valid of
                True -> do
                   time <- liftIO $ getZonedTime >>= \time -> return $ zonedTimeToUTC time
                   _ <- runDB $ do
                       subjId <- insert $ subject experiment
                       _ <- insert $ constructQuestion subjId time (questions experiment)
                       let rs = map (constructRating subjId) (ratings experiment)
                       mapM insert rs
                   return $ object [ "success" .= True ]
                False -> return $ object [ "success" .= False ]