Uniwory und PageAction ExerciseSheet

This commit is contained in:
SJost 2018-04-26 09:41:57 +02:00
parent f3aa2b32c9
commit 56476ccb3e
8 changed files with 37 additions and 10 deletions

1
routes
View File

@ -12,6 +12,7 @@
/term/edit TermEditR GET POST !adminAny /term/edit TermEditR GET POST !adminAny
/term/#TermId/edit TermEditExistR GET !adminAny /term/#TermId/edit TermEditExistR GET !adminAny
-- For Pattern Synonyms see Foundation
/course/ CourseListR GET /course/ CourseListR GET
!/course/new CourseNewR GET POST !lecturerAny !/course/new CourseNewR GET POST !lecturerAny
!/course/#TermId CourseListTermR GET !/course/#TermId CourseListTermR GET

View File

@ -350,7 +350,7 @@ instance YesodBreadcrumbs UniWorX where
breadcrumb SubmissionListR = return ("Abgaben", Just HomeR) breadcrumb SubmissionListR = return ("Abgaben", Just HomeR)
breadcrumb HomeR = return ("UniworkY", Nothing) breadcrumb HomeR = return ("Uniworky", Nothing)
breadcrumb (AuthR _) = return ("Login", Just HomeR) breadcrumb (AuthR _) = return ("Login", Just HomeR)
breadcrumb ProfileR = return ("Profile", Just HomeR) breadcrumb ProfileR = return ("Profile", Just HomeR)
breadcrumb _ = return ("home", Nothing) breadcrumb _ = return ("home", Nothing)

View File

@ -43,7 +43,7 @@ getHomeR :: Handler Html
getHomeR = do getHomeR = do
(btnWdgt, btnEnctype) <- generateFormPost (buttonForm :: Form CreateButton) (btnWdgt, btnEnctype) <- generateFormPost (buttonForm :: Form CreateButton)
defaultLayout $ do defaultLayout $ do
setTitle "Willkommen zum UniworkY Test!" setTitle "Willkommen zum Uniworky Test!"
$(widgetFile "home") $(widgetFile "home")

View File

@ -196,7 +196,15 @@ getSheetShowR tid csh shn = do
return $ (file E.^. FileTitle, sheetFile E.^. SheetFileType) return $ (file E.^. FileTitle, sheetFile E.^. SheetFileType)
let fileLinks = map (\(E.Value fName, E.Value fType) -> CSheetR tid csh (SheetFileR shn fType fName)) fileNameTypes let fileLinks = map (\(E.Value fName, E.Value fType) -> CSheetR tid csh (SheetFileR shn fType fName)) fileNameTypes
defaultLayout $ do let pageActions =
[ PageActionPrime $ MenuItem
{ menuItemLabel = "Abgabe"
, menuItemIcon = Nothing
, menuItemRoute = CSheetR tid csh SheetNewR
, menuItemAccessCallback' = return True
}
]
defaultLinkLayout pageActions $ do
setTitle $ toHtml $ T.append "Übung " $ sheetName sheet setTitle $ toHtml $ T.append "Übung " $ sheetName sheet
$(widgetFile "sheetShow") $(widgetFile "sheetShow")
[whamlet| Under Construction !!! |] -- TODO [whamlet| Under Construction !!! |] -- TODO

View File

@ -42,6 +42,7 @@ import Data.Set (Set)
import qualified Data.Set as Set import qualified Data.Set as Set
import Data.Map (Map) import Data.Map (Map)
import qualified Data.Map as Map import qualified Data.Map as Map
import Data.Bifunctor
import System.FilePath import System.FilePath
@ -125,7 +126,7 @@ postSubmissionR tid csh shn (SubmissionMode mcid) = do
E.orderBy [E.desc $ submissionEdit E.^. SubmissionEditTime] E.orderBy [E.desc $ submissionEdit E.^. SubmissionEditTime]
E.limit 1 E.limit 1
return $ (user E.^. UserDisplayName, submissionEdit E.^. SubmissionEditTime) return $ (user E.^. UserDisplayName, submissionEdit E.^. SubmissionEditTime)
let lastEdits = map (\(a,b)-> (E.unValue a, E.unValue b)) lastEditValues let lastEdits = map (bimap E.unValue E.unValue) lastEditValues
return (sheet,buddies,oldfiles,lastEdits) return (sheet,buddies,oldfiles,lastEdits)
let unpackZips = True -- undefined -- TODO let unpackZips = True -- undefined -- TODO
((res,formWidget), formEnctype) <- runFormPost $ makeSubmissionForm unpackZips sheetGrouping $ map E.unValue buddies ((res,formWidget), formEnctype) <- runFormPost $ makeSubmissionForm unpackZips sheetGrouping $ map E.unValue buddies

View File

@ -15,9 +15,11 @@ module Handler.Utils.Form where
import Handler.Utils.Form.Types import Handler.Utils.Form.Types
import Handler.Utils.DateTime
import Import import Import
import qualified Data.Char as Char import qualified Data.Char as Char
import Handler.Utils.DateTime
import Data.String (IsString(..)) import Data.String (IsString(..))
import qualified Data.Foldable as Foldable import qualified Data.Foldable as Foldable
@ -328,6 +330,25 @@ sheetGroupAFormReq d _other = -- TODO
-- TODO, offer options to choose between Arbitrary/Registered/NoGroups -- TODO, offer options to choose between Arbitrary/Registered/NoGroups
Arbitrary <$> areq (natField "Abgabegruppengröße") d (Just 1) Arbitrary <$> areq (natField "Abgabegruppengröße") d (Just 1)
{-
dayTimeField :: FieldSettings UniWorX -> Maybe UTCTime -> Form Handler UTCTime
dayTimeField fs mutc = do
let (mbDay,mbTime) = case mutcs of
Nothing -> return (Nothing,Nothing)
(Just utc) ->
(dayResult, dayView) <- mreq dayField fs
(result, view) <- (,) <$> dayField <*> timeField
where
(mbDay,mbTime)
| (Just utc) <- mutc =
let lt = utcToLocalTime ??? utcs
in (Just $ localDay lt, Just $ localTimeOfDay lt)
| otherwise = (Nothing,Nothing)
-}
utcTimeField :: (Monad m, RenderMessage (HandlerSite m) FormMessage) => Field m UTCTime utcTimeField :: (Monad m, RenderMessage (HandlerSite m) FormMessage) => Field m UTCTime
-- StackOverflow: dayToUTC <$> (areq (jqueryDayField def {...}) settings Nothing) -- StackOverflow: dayToUTC <$> (areq (jqueryDayField def {...}) settings Nothing)
-- TODO: Verify whether this is UTC or local time from Browser -- TODO: Verify whether this is UTC or local time from Browser

View File

@ -53,10 +53,6 @@ whenIsJust Nothing _ = return ()
-- Tuples -- -- Tuples --
------------ ------------
both :: (a -> b) -> (a,a) -> (b,b)
both f (x,y) = (f x, f y)
---------- ----------
-- Maps -- -- Maps --
---------- ----------

View File

@ -1,5 +1,5 @@
<div .container> <div .container>
<h1>UniworkY - Demo <h1>Uniworky - Demo
<h3> <h3>
Testumgebung für die Re-Implementierung von <a href="https://uniworx.ifi.lmu.de/">UniWorX</a> Testumgebung für die Re-Implementierung von <a href="https://uniworx.ifi.lmu.de/">UniWorX</a>
<p> <p>