feat(faq): exam-points

Fixes #595
This commit is contained in:
Gregor Kleen 2020-05-18 14:36:47 +02:00
parent baf8b18dc3
commit aebc05d021
6 changed files with 39 additions and 3 deletions

View File

@ -2,4 +2,5 @@ FAQNoCampusAccount: Ich habe keine LMU-Benutzerkennung (ehem. Campus-Kennung); k
FAQForgottenPassword: Ich habe mein Passwort vergessen
FAQCampusCantLogin: Ich kann mich mit meiner LMU-Benutzerkennung (ehem. Campus-Kennung) nicht anmelden
FAQCourseCorrectorsTutors: Wie kann ich Tutoren oder Korrektoren für meinen Kurs einstellen?
FAQNotLecturerHowToCreateCourses: Wie kann ich einen neuen Kurs anlegen?
FAQNotLecturerHowToCreateCourses: Wie kann ich einen neuen Kurs anlegen?
FAQExamPoints: Warum kann ich bei meiner Klausur keine Punkte eintragen?

View File

@ -3,3 +3,4 @@ FAQForgottenPassword: I have forgotten my password
FAQCampusCantLogin: I can't log in using my LMU user ID (formerly Campus-ID)
FAQCourseCorrectorsTutors: How can I add tutors or correctors to my course?
FAQNotLecturerHowToCreateCourses: How can I create new courses?
FAQExamPoints: Why can't I enter achievements for my exam as points?

View File

@ -14,7 +14,7 @@ module Database.Esqueleto.Utils
, orderByList
, orderByOrd, orderByEnum
, strip, lower, ciEq
, selectExists
, selectExists, selectNotExists
, SqlHashable
, sha256
, maybe, unsafeCoalesce
@ -206,13 +206,14 @@ ciEq :: E.SqlString s => E.SqlExpr (E.Value s) -> E.SqlExpr (E.Value s) -> E.Sql
ciEq a b = lower a E.==. lower b
selectExists :: forall m a. MonadIO m => E.SqlQuery a -> E.SqlReadT m Bool
selectExists, selectNotExists :: forall m a. MonadIO m => E.SqlQuery a -> E.SqlReadT m Bool
selectExists query = do
res <- E.select . return . E.exists $ void query
case res of
[E.Value b] -> return b
_other -> error "SELECT EXISTS ... returned zero or more than one rows"
selectNotExists = fmap not . selectExists
class SqlHashable a

View File

@ -7,6 +7,9 @@ import Handler.Info.TH
import qualified Data.Map as Map
import qualified Data.CaseInsensitive as CI
import qualified Database.Esqueleto as E
import qualified Database.Esqueleto.Utils as E
import Development.GitRev
-- | Versionsgeschichte
@ -156,6 +159,17 @@ showFAQ (CourseR tid ssh csh _) FAQCourseCorrectorsTutors
(or2M (hasWriteAccessTo $ CourseR tid ssh csh SheetNewR)
(hasWriteAccessTo $ CourseR tid ssh csh CTutorialNewR)
)
showFAQ (CExamR tid ssh csh examn _) FAQExamPoints
= and2M (hasWriteAccessTo $ CExamR tid ssh csh examn EEditR)
noExamParts
where
noExamParts = liftHandler . runDB . E.selectNotExists . E.from $ \(examPart `E.InnerJoin` exam `E.InnerJoin` course) -> do
E.on $ course E.^. CourseId E.==. exam E.^. ExamCourse
E.on $ exam E.^. ExamId E.==. examPart E.^. ExamPartExam
E.where_ $ course E.^. CourseTerm E.==. E.val tid
E.&&. course E.^. CourseSchool E.==. E.val ssh
E.&&. course E.^. CourseShorthand E.==. E.val csh
E.&&. exam E.^. ExamName E.==. E.val examn
showFAQ _ _ = return False
prioFAQ :: Monad m
@ -165,3 +179,4 @@ prioFAQ _ FAQCampusCantLogin = return 1
prioFAQ _ FAQForgottenPassword = return 1
prioFAQ _ FAQNotLecturerHowToCreateCourses = return 1
prioFAQ _ FAQCourseCorrectorsTutors = return 1
prioFAQ _ FAQExamPoints = return 2

View File

@ -0,0 +1,9 @@
$newline never
<p>
Klausurpunkte werden in Uni2work pro Teilaufgabe verwaltet.
<p>
Um Klausurleistungen als Punkte anzugeben (und optional automatisch #
eine Note daraus zu berechnen), müssen Sie mindestens eine #
Teilprüfung/Aufgabe anlegen.

View File

@ -0,0 +1,9 @@
$newline never
<p>
Exam points are managed in Uni2work on a per-exam-part basis.
<p>
To store exam achievements in the form of points (and optionally #
automatically compute grades), you need to create at least one #
exam part/question.