From 3e3c1334cab7ca6986b23055a48cd3e80c58bc66 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 3 Mar 2020 17:15:29 +0100 Subject: [PATCH] chore: add test courses --- test/Database/Fill.hs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/Database/Fill.hs b/test/Database/Fill.hs index d4638331f..c6e2c17ee 100644 --- a/test/Database/Fill.hs +++ b/test/Database/Fill.hs @@ -974,3 +974,33 @@ fillDb = do forM_ grpUsers $ void . insert . flip SubmissionUser sub void . insert $ SubmissionEdit pUid now sub _other -> return () + + forM_ ([1..100] :: [Int]) $ \n -> do + csh <- pack . take 3 <$> getRandomRs ('A', 'Z') + + cid <- insert' Course + { courseName = CI.mk [st|Test Kurs #{n} (#{csh})|] + , courseDescription = Nothing + , courseLinkExternal = Nothing + , courseShorthand = CI.mk csh + , courseTerm = TermKey $ seasonTerm False Winter + , courseSchool = ifi + , courseCapacity = Just 50 + , courseRegisterFrom = Nothing + , courseRegisterTo = Nothing + , courseDeregisterUntil = Nothing + , courseRegisterSecret = Nothing + , courseMaterialFree = True + , courseApplicationsRequired = False + , courseApplicationsInstructions = Nothing + , courseApplicationsText = False + , courseApplicationsFiles = NoUpload + , courseApplicationsRatingsVisible = False + } + insert_ $ CourseEdit gkleen now cid + void . insert' $ Lecturer gkleen cid CourseLecturer + + participants <- getRandomR (0, 50) + manyUsers' <- shuffleM manyUsers + forM_ (take participants manyUsers') $ \uid -> + void . insert $ CourseParticipant cid uid now Nothing Nothing