2016-05-16 23:44:28 +02:00
|
|
|
module Handler.Presentation where
|
|
|
|
|
|
|
|
import Import
|
|
|
|
|
|
|
|
import Handler.ShowChallenge
|
|
|
|
import Handler.Tables
|
|
|
|
|
|
|
|
import qualified Yesod.Table as Table
|
|
|
|
|
|
|
|
import Text.Hamlet (hamletFile)
|
|
|
|
|
|
|
|
sampleChallengeName :: Text
|
|
|
|
sampleChallengeName = "petite-difference-challenge"
|
|
|
|
|
2016-05-17 14:55:03 +02:00
|
|
|
sampleChallengeName' :: Text
|
|
|
|
sampleChallengeName' = "retroc"
|
|
|
|
|
2017-05-30 14:20:22 +02:00
|
|
|
retrocChallengeName :: Text
|
|
|
|
retrocChallengeName = "retroc"
|
|
|
|
|
|
|
|
retroc2ChallengeName :: Text
|
|
|
|
retroc2ChallengeName = "retroc2"
|
|
|
|
|
2016-05-17 14:55:03 +02:00
|
|
|
|
|
|
|
sampleUserIdent :: Text
|
|
|
|
sampleUserIdent = "ptlen@ceti.pl"
|
|
|
|
|
2016-05-16 23:44:28 +02:00
|
|
|
getPresentation4RealR :: Handler Html
|
|
|
|
getPresentation4RealR = do
|
|
|
|
readme <- challengeReadme sampleChallengeName
|
|
|
|
|
2018-07-28 21:53:13 +02:00
|
|
|
(Entity challengeId challenge) <- runDB $ getBy404 $ UniqueName sampleChallengeName
|
2016-05-17 14:55:03 +02:00
|
|
|
|
|
|
|
(Just (Entity sampleUserId _)) <- runDB $ getBy $ UniqueUser sampleUserIdent
|
|
|
|
let condition = (\(Entity _ submission) -> (submissionSubmitter submission == sampleUserId))
|
|
|
|
(evaluationMaps', tests) <- getChallengeSubmissionInfos condition challengeId
|
|
|
|
let evaluationMaps = take 10 evaluationMaps'
|
|
|
|
|
|
|
|
sampleLeaderboard <- getSampleLeaderboard sampleChallengeName
|
|
|
|
sampleLeaderboard' <- getSampleLeaderboard sampleChallengeName'
|
|
|
|
|
2018-06-06 13:43:17 +02:00
|
|
|
app <- getYesod
|
|
|
|
let scheme = appRepoScheme $ appSettings app
|
|
|
|
|
|
|
|
challengeRepo <- runDB $ get404 $ challengePublicRepo challenge
|
|
|
|
|
2016-05-17 14:55:03 +02:00
|
|
|
presentationLayout $(widgetFile "presentation-4real")
|
|
|
|
|
2017-05-27 08:59:10 +02:00
|
|
|
getPresentationDATeCH2017R = do
|
2017-05-30 14:20:22 +02:00
|
|
|
readme <- challengeReadme retrocChallengeName
|
|
|
|
retrocLeaderboard <- getSampleLeaderboard retrocChallengeName
|
|
|
|
retroc2Leaderboard <- getSampleLeaderboard retroc2ChallengeName
|
2017-05-27 08:59:10 +02:00
|
|
|
presentationLayout $(widgetFile "presentation-datech-2017")
|
|
|
|
|
2016-05-17 14:55:03 +02:00
|
|
|
|
2018-09-08 19:21:06 +02:00
|
|
|
getSampleLeaderboard :: Text -> HandlerFor App (WidgetFor App ())
|
2016-05-17 14:55:03 +02:00
|
|
|
getSampleLeaderboard name = do
|
2018-07-28 21:53:13 +02:00
|
|
|
(Entity challengeId challenge) <- runDB $ getBy404 $ UniqueName name
|
2016-05-17 14:55:03 +02:00
|
|
|
|
2018-09-08 21:21:21 +02:00
|
|
|
(leaderboard, (_, tests)) <- getLeaderboardEntries BySubmitter challengeId
|
2016-05-17 14:55:03 +02:00
|
|
|
let leaderboardWithRanks = zip [1..] (take 10 leaderboard)
|
2016-05-16 23:44:28 +02:00
|
|
|
|
2018-06-06 13:43:17 +02:00
|
|
|
app <- getYesod
|
|
|
|
let scheme = appRepoScheme $ appSettings app
|
|
|
|
|
|
|
|
challengeRepo <- runDB $ get404 $ challengePublicRepo challenge
|
|
|
|
|
2018-07-28 21:53:13 +02:00
|
|
|
return $ Table.buildBootstrap (leaderboardTable Nothing
|
|
|
|
(challengeName challenge)
|
2018-09-08 19:21:06 +02:00
|
|
|
scheme challengeRepo tests)
|
2018-07-28 21:53:13 +02:00
|
|
|
leaderboardWithRanks
|
2016-05-16 23:44:28 +02:00
|
|
|
|
|
|
|
presentationLayout widget = do
|
|
|
|
pc <- widgetToPageContent widget
|
|
|
|
withUrlRenderer $(hamletFile "templates/presentation-layout.hamlet")
|