Sort submissions by time, show lecturers in course
This commit is contained in:
parent
c4c5a6b05c
commit
3523549d0e
@ -250,6 +250,7 @@ NoUpcomingSheetDeadlines: Keine anstehenden Übungsblätter
|
|||||||
|
|
||||||
AdminFor: Administrator
|
AdminFor: Administrator
|
||||||
LecturerFor: Dozent
|
LecturerFor: Dozent
|
||||||
|
LecturersFor: Dozenten
|
||||||
UserListTitle: Komprehensive Benutzerliste
|
UserListTitle: Komprehensive Benutzerliste
|
||||||
|
|
||||||
DateTimeFormat: Datums- und Uhrzeitformat
|
DateTimeFormat: Datums- und Uhrzeitformat
|
||||||
|
|||||||
@ -263,7 +263,7 @@ getTermCourseListR tid = do
|
|||||||
getCShowR :: TermId -> SchoolId -> CourseShorthand -> Handler Html
|
getCShowR :: TermId -> SchoolId -> CourseShorthand -> Handler Html
|
||||||
getCShowR tid ssh csh = do
|
getCShowR tid ssh csh = do
|
||||||
mbAid <- maybeAuthId
|
mbAid <- maybeAuthId
|
||||||
(courseEnt,(schoolMB,participants,registered)) <- runDB $ do
|
(courseEnt,(schoolMB,participants,registered),lecturers) <- runDB $ do
|
||||||
courseEnt@(Entity cid course) <- getBy404 $ TermSchoolCourseShort tid ssh csh
|
courseEnt@(Entity cid course) <- getBy404 $ TermSchoolCourseShort tid ssh csh
|
||||||
dependent <- (,,)
|
dependent <- (,,)
|
||||||
<$> get (courseSchool course) -- join -- just fetch full school name here
|
<$> get (courseSchool course) -- join -- just fetch full school name here
|
||||||
@ -273,7 +273,11 @@ getCShowR tid ssh csh = do
|
|||||||
(Just aid) -> do
|
(Just aid) -> do
|
||||||
regL <- getBy (UniqueParticipant aid cid)
|
regL <- getBy (UniqueParticipant aid cid)
|
||||||
return $ isJust regL)
|
return $ isJust regL)
|
||||||
return $ (courseEnt,dependent)
|
lecturers <- E.select $ E.from $ \(lecturer `E.InnerJoin` user) -> do
|
||||||
|
E.on $ lecturer E.^. LecturerUser E.==. user E.^. UserId
|
||||||
|
E.where_ $ lecturer E.^. LecturerCourse E.==. E.val cid
|
||||||
|
return $ user E.^. UserDisplayName
|
||||||
|
return $ (courseEnt,dependent,E.unValue <$> lecturers)
|
||||||
let course = entityVal courseEnt
|
let course = entityVal courseEnt
|
||||||
(regWidget, regEnctype) <- generateFormPost $ identifyForm "registerBtn" $ registerForm registered $ courseRegisterSecret course
|
(regWidget, regEnctype) <- generateFormPost $ identifyForm "registerBtn" $ registerForm registered $ courseRegisterSecret course
|
||||||
registrationOpen <- (==Authorized) <$> isAuthorized (CourseR tid ssh csh CRegisterR) True
|
registrationOpen <- (==Authorized) <$> isAuthorized (CourseR tid ssh csh CRegisterR) True
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
{-# LANGUAGE MultiWayIf, LambdaCase #-}
|
{-# LANGUAGE MultiWayIf, LambdaCase #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE RecordWildCards #-}
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
|
{-# LANGUAGE PatternSynonyms #-}
|
||||||
{-# LANGUAGE PartialTypeSignatures #-}
|
{-# LANGUAGE PartialTypeSignatures #-}
|
||||||
{-# LANGUAGE ScopedTypeVariables #-}
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
{-# LANGUAGE QuasiQuotes #-}
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
@ -212,11 +213,11 @@ getProfileDataR = do
|
|||||||
)
|
)
|
||||||
, dbtColonnade = mconcat
|
, dbtColonnade = mconcat
|
||||||
[ colsCourseLink' $ _dbrOutput
|
[ colsCourseLink' $ _dbrOutput
|
||||||
-- [ colsCourseLink $ (over each _unValue) . _dbrOutput -- different types in Tupel prevents "over each"
|
-- [ colsCourseLink $ (over each _unValue) . _dbrOutput -- different types in Tuple prevents "over each"
|
||||||
]
|
]
|
||||||
, dbtProj = return
|
, dbtProj = return
|
||||||
, dbtSorting = Map.fromList
|
, dbtSorting = Map.fromList
|
||||||
[ ( "course", SortColumn $ withType $ \(crse `E.InnerJoin` _) -> crse E.^. CourseShorthand)
|
[ ( "course", SortColumn $ withType $ \(crse `E.InnerJoin` _) -> crse E.^. CourseShorthand) -- consider PatternSynonyms. Drawback: not enclosed with table, since they must be at Top-Level. Maybe make Lenses for InnerJoins then?
|
||||||
, ( "term" , SortColumn $ withType $ \(crse `E.InnerJoin` _) -> crse E.^. CourseTerm )
|
, ( "term" , SortColumn $ withType $ \(crse `E.InnerJoin` _) -> crse E.^. CourseTerm )
|
||||||
, ( "school", SortColumn $ withType $ \(crse `E.InnerJoin` _) -> crse E.^. CourseSchool )
|
, ( "school", SortColumn $ withType $ \(crse `E.InnerJoin` _) -> crse E.^. CourseSchool )
|
||||||
]
|
]
|
||||||
@ -284,6 +285,11 @@ getProfileDataR = do
|
|||||||
let validator = def -- DUPLICATED CODE: Handler.Corrections
|
let validator = def -- DUPLICATED CODE: Handler.Corrections
|
||||||
& restrictFilter (\name _ -> name /= "corrector") -- We need to be careful to restrict allowed sorting/filter to not expose sensitive information
|
& restrictFilter (\name _ -> name /= "corrector") -- We need to be careful to restrict allowed sorting/filter to not expose sensitive information
|
||||||
& restrictSorting (\name _ -> name /= "corrector")
|
& restrictSorting (\name _ -> name /= "corrector")
|
||||||
|
lastSubEdit submission = -- latest Edit-Time of this user for submission
|
||||||
|
E.sub_select . E.from $ \subEdit -> do
|
||||||
|
E.where_ $ subEdit E.^. SubmissionEditSubmission E.==. submission E.^. SubmissionId
|
||||||
|
E.&&. subEdit E.^. SubmissionEditUser E.==. E.val uid
|
||||||
|
return . E.max_ $ subEdit E.^. SubmissionEditTime
|
||||||
dbTableWidget' validator $ DBTable
|
dbTableWidget' validator $ DBTable
|
||||||
{ dbtIdent = "submissions" :: Text
|
{ dbtIdent = "submissions" :: Text
|
||||||
, dbtStyle = def
|
, dbtStyle = def
|
||||||
@ -292,10 +298,6 @@ getProfileDataR = do
|
|||||||
E.on $ sheet E.^. SheetId E.==. submission E.^. SubmissionSheet
|
E.on $ sheet E.^. SheetId E.==. submission E.^. SubmissionSheet
|
||||||
E.on $ course E.^. CourseId E.==. sheet E.^. SheetCourse
|
E.on $ course E.^. CourseId E.==. sheet E.^. SheetCourse
|
||||||
E.where_ $ subUser E.^. SubmissionUserUser E.==. E.val uid
|
E.where_ $ subUser E.^. SubmissionUserUser E.==. E.val uid
|
||||||
let subEdit = E.sub_select . E.from $ \subEdit -> do
|
|
||||||
E.where_ $ subEdit E.^. SubmissionEditSubmission E.==. submission E.^. SubmissionId
|
|
||||||
E.&&. subEdit E.^. SubmissionEditUser E.==. E.val uid
|
|
||||||
return . E.max_ $ subEdit E.^. SubmissionEditTime
|
|
||||||
let crse = ( course E.^. CourseTerm
|
let crse = ( course E.^. CourseTerm
|
||||||
, course E.^. CourseSchool
|
, course E.^. CourseSchool
|
||||||
, course E.^. CourseId
|
, course E.^. CourseId
|
||||||
@ -303,7 +305,7 @@ getProfileDataR = do
|
|||||||
)
|
)
|
||||||
let sht = ( sheet E.^. SheetName
|
let sht = ( sheet E.^. SheetName
|
||||||
)
|
)
|
||||||
return (crse, sht, submission, subEdit)
|
return (crse, sht, submission, lastSubEdit submission)
|
||||||
, dbtColonnade = mconcat
|
, dbtColonnade = mconcat
|
||||||
[ colsCourseLink' $ _dbrOutput . _1
|
[ colsCourseLink' $ _dbrOutput . _1
|
||||||
, sortable (Just "sheet") (i18nCell MsgSheet) $ do
|
, sortable (Just "sheet") (i18nCell MsgSheet) $ do
|
||||||
@ -327,7 +329,7 @@ getProfileDataR = do
|
|||||||
cid <- mkCid
|
cid <- mkCid
|
||||||
return $ CSubmissionR tid ssh csh shn cid SubShowR
|
return $ CSubmissionR tid ssh csh shn cid SubShowR
|
||||||
return $ anchorCellM mkRoute (mkCid >>= \cid -> [whamlet|#{display cid}|])
|
return $ anchorCellM mkRoute (mkCid >>= \cid -> [whamlet|#{display cid}|])
|
||||||
, sortable (const Nothing $ Just "edit") (i18nCell MsgSubmissionEditUser) $ do
|
, sortable (Just "edit") (i18nCell MsgSubmissionEditUser) $ do
|
||||||
regTime <- view $ _dbrOutput . _4 . _unValue
|
regTime <- view $ _dbrOutput . _4 . _unValue
|
||||||
return $ maybe mempty timeCell regTime
|
return $ maybe mempty timeCell regTime
|
||||||
]
|
]
|
||||||
@ -336,8 +338,8 @@ getProfileDataR = do
|
|||||||
[ ( "course", SortColumn $ withType $ \(crse `E.InnerJoin` _ `E.InnerJoin` _ `E.InnerJoin` _) -> crse E.^. CourseShorthand)
|
[ ( "course", SortColumn $ withType $ \(crse `E.InnerJoin` _ `E.InnerJoin` _ `E.InnerJoin` _) -> crse E.^. CourseShorthand)
|
||||||
, ( "term" , SortColumn $ withType $ \(crse `E.InnerJoin` _ `E.InnerJoin` _ `E.InnerJoin` _) -> crse E.^. CourseTerm )
|
, ( "term" , SortColumn $ withType $ \(crse `E.InnerJoin` _ `E.InnerJoin` _ `E.InnerJoin` _) -> crse E.^. CourseTerm )
|
||||||
, ( "school", SortColumn $ withType $ \(crse `E.InnerJoin` _ `E.InnerJoin` _ `E.InnerJoin` _) -> crse E.^. CourseSchool )
|
, ( "school", SortColumn $ withType $ \(crse `E.InnerJoin` _ `E.InnerJoin` _ `E.InnerJoin` _) -> crse E.^. CourseSchool )
|
||||||
-- , ( "time" , error "Time Sorting not yet supported") -- TODO
|
|
||||||
, ( "sheet" , SortColumn $ withType $ \(_ `E.InnerJoin` sheet `E.InnerJoin` _ `E.InnerJoin` _) -> sheet E.^. SheetName )
|
, ( "sheet" , SortColumn $ withType $ \(_ `E.InnerJoin` sheet `E.InnerJoin` _ `E.InnerJoin` _) -> sheet E.^. SheetName )
|
||||||
|
, ( "edit" , SortColumn $ withType $ \(_ `E.InnerJoin` _ `E.InnerJoin` submission `E.InnerJoin` _) -> lastSubEdit submission )
|
||||||
]
|
]
|
||||||
, dbtFilter = Map.fromList
|
, dbtFilter = Map.fromList
|
||||||
[ ( "course", FilterColumn $ withType $ \(crse `E.InnerJoin` _ `E.InnerJoin` _ `E.InnerJoin` _) -> emptyOrIn $ crse E.^. CourseShorthand)
|
[ ( "course", FilterColumn $ withType $ \(crse `E.InnerJoin` _ `E.InnerJoin` _ `E.InnerJoin` _) -> emptyOrIn $ crse E.^. CourseShorthand)
|
||||||
|
|||||||
@ -5,11 +5,22 @@
|
|||||||
<dd .deflist__dd>
|
<dd .deflist__dd>
|
||||||
<div>
|
<div>
|
||||||
#{schoolName school}
|
#{schoolName school}
|
||||||
|
|
||||||
$maybe descr <- courseDescription course
|
$maybe descr <- courseDescription course
|
||||||
<dt .deflist__dt>_{MsgCourseDescription}
|
<dt .deflist__dt>_{MsgCourseDescription}
|
||||||
<dd .deflist__dd>
|
<dd .deflist__dd>
|
||||||
<div>
|
<div>
|
||||||
#{descr}
|
#{descr}
|
||||||
|
|
||||||
|
$with numlecs <- length lecturers
|
||||||
|
$if numlecs > 1
|
||||||
|
<dt .deflist__dt>_{MsgLecturersFor}
|
||||||
|
$else
|
||||||
|
<dt .deflist__dt>_{MsgLecturerFor}
|
||||||
|
<dd .deflist__dd>
|
||||||
|
<div>
|
||||||
|
#{T.intercalate ", " lecturers}
|
||||||
|
|
||||||
$maybe link <- courseLinkExternal course
|
$maybe link <- courseLinkExternal course
|
||||||
<dt .deflist__dt>Website
|
<dt .deflist__dt>Website
|
||||||
<dd .deflist__dd>
|
<dd .deflist__dd>
|
||||||
|
|||||||
Reference in New Issue
Block a user