show course in Achievements
This commit is contained in:
parent
76831ab2e3
commit
c8500ea128
@ -9,6 +9,7 @@ import qualified Yesod.Table as Table
|
||||
data AchievementInfo = AchievementInfo {
|
||||
achievementInfoId :: AchievementId,
|
||||
achievementInfoName :: Text,
|
||||
achievementInfoCourse :: Entity Course,
|
||||
achievementInfoChallenge :: Entity Challenge,
|
||||
achievementInfoDescription :: Maybe Text,
|
||||
achievementInfoPoints :: Int,
|
||||
@ -32,9 +33,13 @@ getAchievementInfo mUser (Entity achievementId achievement) = do
|
||||
let challengeId = achievementChallenge achievement
|
||||
challenge <- get404 challengeId
|
||||
|
||||
let courseId = achievementCourse achievement
|
||||
course <- get404 courseId
|
||||
|
||||
return $ AchievementInfo {
|
||||
achievementInfoId = achievementId,
|
||||
achievementInfoName = achievementName achievement,
|
||||
achievementInfoCourse = Entity courseId course,
|
||||
achievementInfoChallenge = Entity challengeId challenge,
|
||||
achievementInfoDescription = achievementDescription achievement,
|
||||
achievementInfoPoints = achievementPoints achievement,
|
||||
|
@ -31,7 +31,7 @@ postAchievementsR = do
|
||||
when (checkIfAdmin mUser) $ do
|
||||
case result of
|
||||
FormSuccess (name, description, points, deadlineDay, deadlineTime, maxSubmitters, mTags, challengeId, courseId) -> do
|
||||
achievementId <- runDB $ insert $ Achievement name challengeId points description (UTCTime { utctDay = deadlineDay, utctDayTime = timeOfDayToTime deadlineTime }) maxSubmitters (Just courseId)
|
||||
achievementId <- runDB $ insert $ Achievement name challengeId points description (UTCTime { utctDay = deadlineDay, utctDayTime = timeOfDayToTime deadlineTime }) maxSubmitters courseId
|
||||
|
||||
tids <- runDB $ tagsAsTextToTagIds mTags
|
||||
|
||||
@ -56,6 +56,7 @@ doAchievements mUser formWidget formEnctype = do
|
||||
achievementsTable :: Table.Table App (AchievementInfo)
|
||||
achievementsTable = mempty
|
||||
++ Table.text "achievement" achievementInfoName
|
||||
++ Table.text "course" (courseName . entityVal . achievementInfoCourse)
|
||||
++ Table.linked "challenge" (challengeTitle . entityVal . achievementInfoChallenge) (ShowChallengeR . challengeName . entityVal . achievementInfoChallenge)
|
||||
++ achievementDescriptionCell id
|
||||
++ Table.int "points" achievementInfoPoints
|
||||
|
@ -91,7 +91,7 @@ Achievement
|
||||
description Text Maybe
|
||||
deadline UTCTime
|
||||
maxWinners Int Maybe
|
||||
course CourseId Maybe
|
||||
course CourseId
|
||||
UniqueAchievementName name
|
||||
AchievementTag
|
||||
achievement AchievementId
|
||||
|
Loading…
Reference in New Issue
Block a user