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