From bed12dee3454f73ea5f40f6409f6642b67387698 Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Sat, 1 Sep 2018 14:23:41 +0200 Subject: [PATCH] show only numerical params on graphs --- Handler/ShowChallenge.hs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Handler/ShowChallenge.hs b/Handler/ShowChallenge.hs index 4b943ac..081ab0b 100644 --- a/Handler/ShowChallenge.hs +++ b/Handler/ShowChallenge.hs @@ -20,6 +20,8 @@ import Handler.Tables import Handler.TagUtils import Handler.MakePublic +import qualified Text.Read as TR + import GEval.Core import GEval.OptionsParser import GEval.ParseParams (parseParamsFromFilePath, OutputFileParsed(..)) @@ -48,7 +50,7 @@ getShowChallengeR name = do mauth <- maybeAuth let muserId = (\(Entity uid _) -> uid) <$> mauth - let params = getAllParams entries + let params = getNumericalParams entries app <- getYesod let scheme = appRepoScheme $ appSettings app @@ -534,7 +536,7 @@ getChallengeSubmissions condition name = do challengeRepo <- runDB $ get404 $ challengePublicRepo challenge - let params = getAllParams evaluationMaps + let params = getNumericalParams evaluationMaps challengeLayout True challenge (challengeAllSubmissionsWidget muserId challenge @@ -544,6 +546,21 @@ getChallengeSubmissions condition name = do tests params) +getNumericalParams :: [TableEntry] -> [Text] +getNumericalParams entries = filter (isNumericalParam entries) $ getAllParams entries + +isNumericalParam :: [TableEntry] -> Text -> Bool +isNumericalParam entries param = + all doesTextRepresentNumber + $ concat + $ map ((map parameterValue) + . (filter (\p -> parameterName p == param)) + . (map entityVal) + . tableEntryParams) entries + +doesTextRepresentNumber :: Text -> Bool +doesTextRepresentNumber t = isJust $ ((TR.readMaybe $ T.unpack t) :: Maybe Double) + getAllParams :: [TableEntry] -> [Text] getAllParams entries = sort $ nub