forked from filipg/gonito
add submitter to a submission
This commit is contained in:
parent
652e82fa62
commit
ba81476e80
@ -74,6 +74,7 @@ doCreateSubmission challengeId description url branch chan = do
|
|||||||
getSubmission :: Key Repo -> SHA1 -> Key Challenge -> Text -> Channel -> Handler (Key Submission)
|
getSubmission :: Key Repo -> SHA1 -> Key Challenge -> Text -> Channel -> Handler (Key Submission)
|
||||||
getSubmission repoId commit challengeId description chan = do
|
getSubmission repoId commit challengeId description chan = do
|
||||||
maybeSubmission <- runDB $ getBy $ UniqueSubmissionRepoCommitChallenge repoId commit challengeId
|
maybeSubmission <- runDB $ getBy $ UniqueSubmissionRepoCommitChallenge repoId commit challengeId
|
||||||
|
userId <- requireAuthId
|
||||||
case maybeSubmission of
|
case maybeSubmission of
|
||||||
Just (Entity submissionId submission) -> do
|
Just (Entity submissionId submission) -> do
|
||||||
msg chan "Submission already there, re-checking"
|
msg chan "Submission already there, re-checking"
|
||||||
@ -86,7 +87,8 @@ getSubmission repoId commit challengeId description chan = do
|
|||||||
submissionCommit=commit,
|
submissionCommit=commit,
|
||||||
submissionChallenge=challengeId,
|
submissionChallenge=challengeId,
|
||||||
submissionDescription=description,
|
submissionDescription=description,
|
||||||
submissionStamp=time }
|
submissionStamp=time,
|
||||||
|
submissionSubmitter=userId }
|
||||||
|
|
||||||
getOuts :: Channel -> Key Submission -> Handler ([Out])
|
getOuts :: Channel -> Key Submission -> Handler ([Out])
|
||||||
getOuts chan submissionId = do
|
getOuts chan submissionId = do
|
||||||
@ -207,24 +209,31 @@ getChallengeAllSubmissionsR name = do
|
|||||||
evaluationMaps <- mapM getEvaluationMap submissions
|
evaluationMaps <- mapM getEvaluationMap submissions
|
||||||
challengeLayout True challenge (challengeAllSubmissionsWidget challenge evaluationMaps tests)
|
challengeLayout True challenge (challengeAllSubmissionsWidget challenge evaluationMaps tests)
|
||||||
|
|
||||||
getEvaluationMap :: Entity Submission -> Handler (Entity Submission, Map (Key Test) Evaluation)
|
getEvaluationMap :: Entity Submission -> Handler (Entity Submission, User, Map (Key Test) Evaluation)
|
||||||
getEvaluationMap s@(Entity submissionId submission) = do
|
getEvaluationMap s@(Entity submissionId submission) = do
|
||||||
outs <- runDB $ selectList [OutSubmission ==. submissionId] []
|
outs <- runDB $ selectList [OutSubmission ==. submissionId] []
|
||||||
|
user <- runDB $ get404 $ submissionSubmitter submission
|
||||||
maybeEvaluations <- runDB $ mapM (\(Entity _ o) -> getBy $ UniqueEvaluationTestChecksum (outTest o) (outChecksum o)) outs
|
maybeEvaluations <- runDB $ mapM (\(Entity _ o) -> getBy $ UniqueEvaluationTestChecksum (outTest o) (outChecksum o)) outs
|
||||||
let evaluations = catMaybes maybeEvaluations
|
let evaluations = catMaybes maybeEvaluations
|
||||||
let m = Map.fromList $ map (\(Entity _ e) -> (evaluationTest e, e)) evaluations
|
let m = Map.fromList $ map (\(Entity _ e) -> (evaluationTest e, e)) evaluations
|
||||||
return (s, m)
|
return (s, user, m)
|
||||||
|
|
||||||
challengeAllSubmissionsWidget challenge submissions tests = $(widgetFile "challenge-all-submissions")
|
challengeAllSubmissionsWidget challenge submissions tests = $(widgetFile "challenge-all-submissions")
|
||||||
|
|
||||||
submissionsTable :: [Entity Test] -> Table site (Entity Submission, Map (Key Test) Evaluation)
|
submissionsTable :: [Entity Test] -> Table site (Entity Submission, User, Map (Key Test) Evaluation)
|
||||||
submissionsTable tests = mempty
|
submissionsTable tests = mempty
|
||||||
++ Table.string "when" (show . submissionStamp . \(Entity _ s, _) -> s)
|
++ Table.text "submitter" (formatSubmitter . \(_, submitter, _) -> submitter)
|
||||||
++ Table.text "description" (submissionDescription . \(Entity _ s, _) -> s)
|
++ Table.string "when" (show . submissionStamp . \(Entity _ s, _, _) -> s)
|
||||||
|
++ Table.text "description" (submissionDescription . \(Entity _ s, _, _) -> s)
|
||||||
++ mconcat (map (\(Entity k t) -> Table.string (testName t) (submissionScore k)) tests)
|
++ mconcat (map (\(Entity k t) -> Table.string (testName t) (submissionScore k)) tests)
|
||||||
|
|
||||||
submissionScore :: Key Test -> (Entity Submission, Map (Key Test) Evaluation) -> String
|
formatSubmitter :: User -> Text
|
||||||
submissionScore k (_, m) = fromMaybe "N/A" (presentScore <$> lookup k m)
|
formatSubmitter user = case userName user of
|
||||||
|
Just name -> name
|
||||||
|
Nothing -> "[name not given]"
|
||||||
|
|
||||||
|
submissionScore :: Key Test -> (Entity Submission, User, Map (Key Test) Evaluation) -> String
|
||||||
|
submissionScore k (_, _, m) = fromMaybe "N/A" (presentScore <$> lookup k m)
|
||||||
|
|
||||||
presentScore :: Evaluation -> String
|
presentScore :: Evaluation -> String
|
||||||
presentScore evaluation = fromMaybe "???" (show <$> evaluationScore evaluation)
|
presentScore evaluation = fromMaybe "???" (show <$> evaluationScore evaluation)
|
||||||
|
@ -39,6 +39,7 @@ Submission
|
|||||||
challenge ChallengeId
|
challenge ChallengeId
|
||||||
description Text
|
description Text
|
||||||
stamp UTCTime default=now()
|
stamp UTCTime default=now()
|
||||||
|
submitter UserId
|
||||||
UniqueSubmissionRepoCommitChallenge repo commit challenge
|
UniqueSubmissionRepoCommitChallenge repo commit challenge
|
||||||
Evaluation
|
Evaluation
|
||||||
test TestId
|
test TestId
|
||||||
|
Loading…
Reference in New Issue
Block a user