diff --git a/src/Handler/Tutorial.hs b/src/Handler/Tutorial.hs index 94a00e645..04fc02220 100644 --- a/src/Handler/Tutorial.hs +++ b/src/Handler/Tutorial.hs @@ -1,480 +1,13 @@ -{-# OPTIONS_GHC -fno-warn-orphans #-} - module Handler.Tutorial ( module Handler.Tutorial ) where -import Import -import Handler.Utils -import Handler.Utils.Tutorial -import Handler.Utils.Delete -import Handler.Utils.Communication -import Handler.Utils.Form.Occurrences -import Handler.Utils.Invitations -import Jobs.Queue - -import qualified Database.Esqueleto as E -import qualified Database.Esqueleto.Utils as E -import Database.Esqueleto.Utils.TH - -import Data.Map ((!)) -import qualified Data.Map as Map -import qualified Data.Set as Set - -import qualified Data.CaseInsensitive as CI - -import Data.Aeson hiding (Result(..)) -import Text.Hamlet (ihamlet) - -import Handler.Tutorial.Users as Handler.Tutorial - -{-# ANN module ("Hlint: ignore Redundant void" :: String) #-} - - -getCTutorialListR :: TermId -> SchoolId -> CourseShorthand -> Handler Html -getCTutorialListR tid ssh csh = do - Entity cid Course{..} <- runDB . getBy404 $ TermSchoolCourseShort tid ssh csh - - let - tutorialDBTable = DBTable{..} - where - dbtSQLQuery tutorial = do - E.where_ $ tutorial E.^. TutorialCourse E.==. E.val cid - let participants = E.sub_select . E.from $ \tutorialParticipant -> do - E.where_ $ tutorialParticipant E.^. TutorialParticipantTutorial E.==. tutorial E.^. TutorialId - return E.countRows :: E.SqlQuery (E.SqlExpr (E.Value Int)) - return (tutorial, participants) - dbtRowKey = (E.^. TutorialId) - dbtProj = return . over (_dbrOutput . _2) E.unValue - dbtColonnade = dbColonnade $ mconcat - [ sortable (Just "type") (i18nCell MsgTutorialType) $ \DBRow{ dbrOutput = (Entity _ Tutorial{..}, _) } -> textCell $ CI.original tutorialType - , sortable (Just "name") (i18nCell MsgTutorialName) $ \DBRow{ dbrOutput = (Entity _ Tutorial{..}, _) } -> anchorCell (CTutorialR tid ssh csh tutorialName TUsersR) [whamlet|#{tutorialName}|] - , sortable Nothing (i18nCell MsgTutorialTutors) $ \DBRow{ dbrOutput = (Entity tutid _, _) } -> sqlCell $ do - tutors <- fmap (map $(unValueN 3)) . E.select . E.from $ \(tutor `E.InnerJoin` user) -> do - E.on $ tutor E.^. TutorUser E.==. user E.^. UserId - E.where_ $ tutor E.^. TutorTutorial E.==. E.val tutid - return (user E.^. UserEmail, user E.^. UserDisplayName, user E.^. UserSurname) - return [whamlet| - $newline never -