diff --git a/messages/uniworx/categories/qualification/de-de-formal.msg b/messages/uniworx/categories/qualification/de-de-formal.msg index 642e9cdee..fa4fc8214 100644 --- a/messages/uniworx/categories/qualification/de-de-formal.msg +++ b/messages/uniworx/categories/qualification/de-de-formal.msg @@ -1,3 +1,4 @@ +TableLmsUser: Prüfling TableLmsIdent: Identifikation TableLmsPin: E-Lernen Pin TableLmsResetPin: Pin zurücksetzen? diff --git a/messages/uniworx/categories/qualification/en-eu.msg b/messages/uniworx/categories/qualification/en-eu.msg index cf100eece..c6391e536 100644 --- a/messages/uniworx/categories/qualification/en-eu.msg +++ b/messages/uniworx/categories/qualification/en-eu.msg @@ -1,3 +1,4 @@ +TableLmsUser: Examinee TableLmsIdent: Identifier TableLmsPin: E-learning pin TableLmsResetPin: Reset pin? diff --git a/src/Handler/LMS.hs b/src/Handler/LMS.hs index f21033eed..7b8c5618a 100644 --- a/src/Handler/LMS.hs +++ b/src/Handler/LMS.hs @@ -169,7 +169,7 @@ instance HasEntity LmsResultTableData LmsResult where {- MaybeHasUser only! instance HasUser LmsResultTableData where - hasUser = _dbrOutput . _4 . _entityVal + hasUser = resultUser . _entityVal -} resultQualification :: Lens' LmsResultTableData (Entity Qualification) @@ -204,23 +204,33 @@ mkLmsTable qid = do dbtRowKey = queryLmsResult >>> (E.^. LmsResultId) dbtProj = dbtProjFilteredPostId -- TODO: or dbtProjSimple what is the difference? dbtColonnade = dbColonnade $ mconcat - [ sortable (Just "school") (i18nCell MsgTableSchool) $ \(view $ resultQualification . _entityVal . _qualificationSchool -> schoolShorthand) -> wgtCell $ toWgt schoolShorthand + [ sortable (Just "school") (i18nCell MsgTableSchool) $ \(view $ resultQualification . _entityVal . _qualificationSchool -> schoolShorthand) -> wgtCell $ toWgt schoolShorthand + , sortable (Just "user") (i18nCell MsgTableLmsUser) $ -- \(preview resultUser -> entuser) -> maybeCell entuser (cellHasUserLink AdminUserR) + foldMap (cellHasUserLink AdminUserR) . (^? resultUser) + , sortable (Just "email") (i18nCell MsgTableEmail) $ -- \(preview $ resultUser . _entityVal -> user) -> maybeCell user cellHasEMail + foldMap cellHasEMail . (^? resultUser) , sortable (Just csvLmsIdent) (i18nCell MsgTableLmsIdent) $ \(view $ resultLmsResult . _entityVal . _lmsResultIdent . _getLmsIdent -> ident) -> textCell ident , sortable (Just csvLmsSuccess) (i18nCell MsgTableLmsSuccess) $ \(view $ resultLmsResult . _entityVal . _lmsResultSuccess -> success) -> dayCell success ] -- TODO: add more columns for manual debugging view !!! dbtSorting = Map.fromList [ ("school" , SortColumn $ queryQualification >>> (E.^. QualificationSchool)) - , (csvLmsIdent , SortColumn $ queryLmsResult >>> (E.^. LmsResultIdent)) - -- , (csvLmsSuccess, SortColumn $ queryLmsResult >>> (E.^. LmsResultSuccess)) + , ("user" , SortColumn $ queryUser >>> (E.?. UserDisplayName)) + , ("email" , SortColumn $ queryUser >>> (E.?. UserEmail)) + , (csvLmsIdent , SortColumn $ queryLmsResult >>> (E.^. LmsResultIdent)) + -- , (csvLmsSuccess, SortColumn $ queryLmsResult >>> (E.^. LmsResultSuccess)) , (csvLmsSuccess, SortColumn $ views (to queryLmsResult) (E.^. LmsResultSuccess)) ] dbtFilter = Map.fromList - [ ("school" , FilterColumn . E.mkExactFilter $ views (to queryQualification) (E.^. QualificationSchool)) - , (csvLmsIdent , FilterColumn . E.mkContainsFilterWith LmsIdent $ views (to queryLmsResult) (E.^. LmsResultIdent)) - , (csvLmsSuccess, FilterColumn . E.mkExactFilter $ views (to queryLmsResult) (E.^. LmsResultSuccess)) + [ ("school" , FilterColumn . E.mkExactFilter $ views (to queryQualification) (E.^. QualificationSchool)) + , ("user" , FilterColumn . E.mkContainsFilterWith Just $ views (to queryUser) (E.?. UserDisplayName)) + , ("email" , FilterColumn . E.mkContainsFilterWith Just $ views (to queryUser) (E.?. UserEmail)) + , (csvLmsIdent , FilterColumn . E.mkContainsFilterWith LmsIdent $ views (to queryLmsResult) (E.^. LmsResultIdent)) + , (csvLmsSuccess, FilterColumn . E.mkExactFilter $ views (to queryLmsResult) (E.^. LmsResultSuccess)) ] dbtFilterUI = \mPrev -> mconcat [ prismAForm (singletonFilter "school" . maybePrism (_PathPiece . from _SchoolId)) mPrev $ aopt (hoistField lift schoolField) (fslI MsgTableCourseSchool) + , prismAForm (singletonFilter "user" . maybePrism _PathPiece) mPrev $ aopt (hoistField lift textField) (fslI MsgTableLmsUser) + , prismAForm (singletonFilter "email" . maybePrism _PathPiece) mPrev $ aopt (hoistField lift textField) (fslI MsgTableEmail) , prismAForm (singletonFilter csvLmsIdent . maybePrism _PathPiece) mPrev $ aopt (hoistField lift textField) (fslI MsgTableLmsIdent) , prismAForm (singletonFilter csvLmsSuccess . maybePrism _PathPiece) mPrev $ aopt (hoistField lift checkBoxField) (fslI MsgTableLmsSuccess) ] diff --git a/src/Handler/Utils/Table/Cells.hs b/src/Handler/Utils/Table/Cells.hs index e6f08695a..b5f58a691 100644 --- a/src/Handler/Utils/Table/Cells.hs +++ b/src/Handler/Utils/Table/Cells.hs @@ -159,6 +159,11 @@ dateTimeCellVisible watershed t userCell :: IsDBTable m a => Text -> Text -> DBCell m a userCell displayName surname = cell $ nameWidget displayName surname +{- Recall: +userCell' :: IsDBTable m a => User -> DBCell m a +userCell' = cellHasUser +-} + emailCell :: IsDBTable m a => CI Text -> DBCell m a emailCell email = cell $(widgetFile "widgets/link-email") where linkText= toWgt email diff --git a/src/Utils/Lens.hs b/src/Utils/Lens.hs index 2d9458f31..c5c105837 100644 --- a/src/Utils/Lens.hs +++ b/src/Utils/Lens.hs @@ -147,6 +147,10 @@ instance HasStudyDegree a => HasStudyDegree (Entity a) where class HasEntity c record where hasEntity :: Lens' c (Entity record) +--Trivial instance, usefull for lifting to maybes +instance HasEntity (Entity r) r where + hasEntity = id + -- Typed convenience to avoid type signatures, due to the missing FunctionalDepenency that we do not want. hasEntityUser :: (HasEntity a User) => Lens' a (Entity User) hasEntityUser = hasEntity @@ -156,8 +160,8 @@ hasEntityUser = hasEntity -- hasUser = hasEntityUser -- -- Possible, but rather useless: --- instance (HasUser a) => HasUser (Entity a) where --- hasUser = _entityVal . hasUser +instance (HasUser a) => HasUser (Entity a) where + hasUser = _entityVal . hasUser makeLenses_ ''SheetCorrector