diff --git a/Handler/Shared.hs b/Handler/Shared.hs index b327ccd..159018d 100644 --- a/Handler/Shared.hs +++ b/Handler/Shared.hs @@ -316,9 +316,19 @@ thenCmp :: Ordering -> Ordering -> Ordering thenCmp EQ o2 = o2 thenCmp o1 _ = o1 +-- get the test with the highest priority getMainTest :: [Entity Test] -> Entity Test getMainTest tests = DL.maximumBy testComparator tests +-- get all the non-dev tests starting with the one with the highest priorty +-- (or all the tests if there are no non-dev tests) +getMainTests :: [Entity Test] -> [Entity Test] +getMainTests tests = sortBy (flip testComparator) tests' + where tests' = if null tests'' + then tests + else tests'' + tests'' = filter (not . ("dev-" `isPrefixOf`) . testName . entityVal) tests + testComparator :: Entity Test -> Entity Test -> Ordering testComparator (Entity _ a) (Entity _ b) = ((testName a) `compare` (testName b)) diff --git a/Handler/ShowChallenge.hs b/Handler/ShowChallenge.hs index c6ccc95..0e634d2 100644 --- a/Handler/ShowChallenge.hs +++ b/Handler/ShowChallenge.hs @@ -528,8 +528,12 @@ challengeAllSubmissionsWidget :: Maybe UserId -> WidgetFor App () challengeAllSubmissionsWidget muserId challenge scheme challengeRepo submissions tests params = $(widgetFile "challenge-all-submissions") - where chartJSs = mconcat $ map (getChartJs challenge mainTest) params - mainTest = getMainTest tests + where chartJSs = getCharsJss challenge selectedTests params + selectedTests = getMainTests tests + +getCharsJss :: Challenge -> [Entity Test] -> [Text] -> JavascriptUrl (Route App) +getCharsJss challenge tests params = + mconcat $ [(getChartJs challenge test param) | test <- tests, param <- params] getChartJs :: Challenge -> Entity Test diff --git a/templates/challenge-all-submissions.hamlet b/templates/challenge-all-submissions.hamlet index f6f41a8..9dd6fd1 100644 --- a/templates/challenge-all-submissions.hamlet +++ b/templates/challenge-all-submissions.hamlet @@ -16,7 +16,8 @@ $if not (null params) $forall param <- params

#{param} -
+ $forall test <- selectedTests +