From 1bf19a76bd6c03ff23ab417fcfc0e86596dc896f Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 8 Feb 2020 01:42:50 +0100 Subject: [PATCH] feat(exam-correct): explanation & length restriction --- .../src/utils/exam-correct/exam-correct.sass | 5 ++++ messages/uniworx/de-de-formal.msg | 1 + messages/uniworx/en-eu.msg | 1 + src/Handler/Exam/Correct.hs | 8 +++++-- templates/exam-correct.hamlet | 4 ++-- .../de-de-formal.hamlet | 23 ++++++++++++++++++- .../exam-correct-explanation/en-eu.hamlet | 21 ++++++++++++++++- 7 files changed, 57 insertions(+), 6 deletions(-) diff --git a/frontend/src/utils/exam-correct/exam-correct.sass b/frontend/src/utils/exam-correct/exam-correct.sass index 8ca2f93b7..2c036782a 100644 --- a/frontend/src/utils/exam-correct/exam-correct.sass +++ b/frontend/src/utils/exam-correct/exam-correct.sass @@ -91,3 +91,8 @@ table[uw-exam-correct] .exam-correct--error color: var(--color-error) + +.uw-exam-correct--explanation + color: var(--color-fontsec) + font-weight: 600 + font-size: 0.9rem diff --git a/messages/uniworx/de-de-formal.msg b/messages/uniworx/de-de-formal.msg index e88e994ba..e41922081 100644 --- a/messages/uniworx/de-de-formal.msg +++ b/messages/uniworx/de-de-formal.msg @@ -1411,6 +1411,7 @@ ExamCorrectHeadStatus: Status ExamCorrectButtonSend: Senden +ExamCorrectErrorNeedleTooShort: Dieser Identifikator ist zu kurz. ExamCorrectErrorMultipleMatchingParticipants: Dem Identifikator konnten mehrere Prüfungsteilnehmer zugeordnet werden. ExamCorrectErrorNoMatchingParticipants: Dem Identifikator konnte kein Prüfungsteilnehmer zugeordnet werden. ExamCorrectErrorPartResultOutOfBounds examPartNumber@ExamPartNumber: Prüfungsergebnis für Teil #{examPartNumber} ist nicht größer Null. diff --git a/messages/uniworx/en-eu.msg b/messages/uniworx/en-eu.msg index 94874fbad..9005224b0 100644 --- a/messages/uniworx/en-eu.msg +++ b/messages/uniworx/en-eu.msg @@ -1407,6 +1407,7 @@ ExamCorrectHeadStatus: Status ExamCorrectButtonSend: Submit +ExamCorrectErrorNeedleTooShort: This identifier is too short. ExamCorrectErrorMultipleMatchingParticipants: This identifier matches on multiple exam participants. ExamCorrectErrorNoMatchingParticipants: This identifier does not match on any exam participant. ExamCorrectErrorPartResultOutOfBounds examPartNumber: Exam part result for #{examPartNumber} ist not greater zero. diff --git a/src/Handler/Exam/Correct.hs b/src/Handler/Exam/Correct.hs index 38f862fa6..95adddd58 100644 --- a/src/Handler/Exam/Correct.hs +++ b/src/Handler/Exam/Correct.hs @@ -116,6 +116,10 @@ postECorrectR tid ssh csh examn = do Entity eId Exam{..} <- lift $ fetchExam tid ssh csh examn euid <- traverse decrypt ciqUser + guardMExceptT (maybe True ((>= 3) . length) $ euid ^? _Left) $ + CorrectInterfaceResponseFailure Nothing <$> (getMessageRender <*> pure MsgExamCorrectErrorNeedleTooShort) + + participantMatches <- lift . E.select . E.from $ \(examRegistration `E.InnerJoin` user) -> do E.on $ examRegistration E.^. ExamRegistrationUser E.==. user E.^. UserId E.where_ $ examRegistration E.^. ExamRegistrationExam E.==. E.val eId @@ -124,8 +128,6 @@ postECorrectR tid ssh csh examn = do uidMatch = either (const $ E.val False) (\uid -> user E.^. UserId E.==. E.val uid) euid mUserIdent = euid ^? _Left E.where_ $ uidMatch - E.||. user E.^. UserMatrikelnummer E.==. E.val mUserIdent - E.||. user E.^. UserMatrikelnummer `E.hasInfix` E.val mUserIdent E.||. (case mUserIdent of Just userIdent -> user E.^. UserSurname E.==. E.val userIdent E.||. user E.^. UserSurname `E.hasInfix` E.val userIdent @@ -133,6 +135,8 @@ postECorrectR tid ssh csh examn = do E.||. user E.^. UserFirstName `E.hasInfix` E.val userIdent E.||. user E.^. UserDisplayName E.==. E.val userIdent E.||. user E.^. UserDisplayName `E.hasInfix` E.val userIdent + E.||. user E.^. UserMatrikelnummer E.==. E.val mUserIdent + E.||. user E.^. UserMatrikelnummer `E.hasInfix` E.val mUserIdent Nothing -> E.val False) return user diff --git a/templates/exam-correct.hamlet b/templates/exam-correct.hamlet index af99ec374..6bd2e65e3 100644 --- a/templates/exam-correct.hamlet +++ b/templates/exam-correct.hamlet @@ -1,5 +1,5 @@ $newline never -
+
^{examCorrectExplanation}
@@ -23,7 +23,7 @@ $newline never - +
    $forall ExamPart{examPartNumber} <- examParts diff --git a/templates/i18n/exam-correct-explanation/de-de-formal.hamlet b/templates/i18n/exam-correct-explanation/de-de-formal.hamlet index 27a418ba4..5cc48c036 100644 --- a/templates/i18n/exam-correct-explanation/de-de-formal.hamlet +++ b/templates/i18n/exam-correct-explanation/de-de-formal.hamlet @@ -4,6 +4,27 @@ $newline never Teilnehmer-Spalte einen beliebigen eindeutigen Identifikator des # Teilnehmers angeben.
    + Es können nur Ergebnisse für Studierende eingetragen werden, die # + bereits Prüfungsteilnehmer sind. # + Über diese Oberfläche können keine neuen Benutzer zur Klausur # + angemeldet werden.
    + Vermutlich eindeutig ist die Matrikelnummer des Teilnehmers, aber # auch der Name oder ein Teil der Matrikelnummer können unter # - Umständen bereits eindeutig sein. # + Umständen bereits eindeutig sein.
    + + Wenn Felder für Ergebnisse frei gelassen werden, wird an dieser # + Stelle nichts in die Datenbank eingetragen.
    + + Beim Senden von Ergebnissen wird der bisherige Stand in der # + Datenbank überschrieben. # + Es werden auch Ergebnisse überschrieben, die andere Benutzer # + eingetragen haben.
    + + Bereits eingetragene Ergebnisse können auch gelöscht werden; es ist # + danach für den jeweiligen Teil der Prüfung kein Ergebnis mehr in der # + Datenbank hinterlegt.
    + + Falls eine automatische Notenberechnung konfiguriert ist, müssen die # + berechneten Ergebnisse noch auf der Seite der Klausurteilnehmerliste # + akzeptiert werden. diff --git a/templates/i18n/exam-correct-explanation/en-eu.hamlet b/templates/i18n/exam-correct-explanation/en-eu.hamlet index 146e37f65..2b41a9ee8 100644 --- a/templates/i18n/exam-correct-explanation/en-eu.hamlet +++ b/templates/i18n/exam-correct-explanation/en-eu.hamlet @@ -3,6 +3,25 @@ $newline never To enter a participant's exam achievement you can submit any string # that uniquely identifies the participant.
    + Results can only be entered for users who are already exam # + participants. # + No new participants can be added to the exam using this interface. # + Matriculation numbers are likely unique. # The participant's name or a part of their matriculation number may # - also be sufficiently unique. + also be sufficiently unique.
    + + If any fields are left blank no result is saved for that part of the # + exam.
    + + When entering results, the current state in the database is # + overwritten. # + Results entered by other users are also overwritten.
    + + It is possible to delete results. # + After doing so no result is saved for that part of the exam within # + the database.
    + + If grades are to be computed automatically for this exam, the # + results need to be accepted. # + This is done via the listing of exam participants.