refactor(exam-correct): get rid of hardcoded minNeedleLength
This commit is contained in:
parent
e6d540e55c
commit
62fef35475
@ -17,6 +17,11 @@ import Handler.Utils.Exam (fetchExam)
|
||||
import Utils.Exam
|
||||
|
||||
|
||||
-- | Minimum length of a participant identifier. Identifiers that are shorter would result in too many query results and are therefor rejected.
|
||||
minNeedleLength :: Int
|
||||
minNeedleLength = 3
|
||||
|
||||
|
||||
getECorrectR :: TermId -> SchoolId -> CourseShorthand -> ExamName -> Handler Html
|
||||
getECorrectR tid ssh csh examn = do
|
||||
MsgRenderer mr <- getMsgRenderer
|
||||
@ -54,12 +59,12 @@ postECorrectR tid ssh csh examn = do
|
||||
CorrectInterfaceRequest{..} <- requireCheckJsonBody
|
||||
|
||||
mayEditResults <- hasWriteAccessTo $ CExamR tid ssh csh examn EUsersR
|
||||
|
||||
|
||||
response <- runDB . exceptT (<$ transactionUndo) return $ do
|
||||
Entity eId Exam{..} <- lift $ fetchExam tid ssh csh examn
|
||||
euid <- traverse decrypt ciqUser
|
||||
|
||||
guardMExceptT (maybe True ((>= 3) . length) $ euid ^? _Left) $
|
||||
guardMExceptT (maybe True ((>= minNeedleLength) . length) $ euid ^? _Left) $
|
||||
CorrectInterfaceResponseFailure Nothing <$> (getMessageRender <*> pure MsgExamCorrectErrorNeedleTooShort)
|
||||
|
||||
|
||||
|
||||
@ -15,6 +15,10 @@ import Handler.Utils.ExternalExam
|
||||
|
||||
import Utils.Exam
|
||||
|
||||
-- | Minimum length of a participant identifier. Identifiers that are shorter would result in too many query results and are therefor rejected.
|
||||
minNeedleLength :: Int
|
||||
minNeedleLength = 3 -- TODO rethink
|
||||
|
||||
|
||||
getEECorrectR :: TermId -> SchoolId -> CourseName -> ExamName -> Handler Html
|
||||
getEECorrectR tid ssh coursen examn = do
|
||||
@ -59,7 +63,7 @@ postEECorrectR tid ssh coursen examn = do
|
||||
Entity eeId ExternalExam{..} <- lift $ fetchExternalExam tid ssh coursen examn
|
||||
euid <- traverse decrypt ciqUser
|
||||
|
||||
guardMExceptT (maybe True ((>= 3) . length) $ euid ^? _Left) $ -- TODO rethink max needle length
|
||||
guardMExceptT (maybe True ((>= minNeedleLength) . length) $ euid ^? _Left) $
|
||||
CorrectInterfaceResponseFailure Nothing <$> (getMessageRender <*> pure MsgExamCorrectErrorNeedleTooShort)
|
||||
|
||||
matches <- lift . E.select . E.from $ \user -> do
|
||||
|
||||
@ -23,7 +23,7 @@ $newline never
|
||||
<tr .table__row #exam-correct__new>
|
||||
<td .table__td .uw-exam-correct--date-cell>
|
||||
<td .table__td .exam-correct--input-status>
|
||||
<input #exam-correct__user .uw-exam-correct--user-cell type="text" autofocus minLength=3>
|
||||
<input #exam-correct__user .uw-exam-correct--user-cell type="text" autofocus minLength=#{minNeedleLength}>
|
||||
<i #exam-correct__user-status .fas .fa-fw>
|
||||
<ul #exam-correct__user-candidates>
|
||||
$forall ExamPart{examPartNumber} <- examParts
|
||||
|
||||
Loading…
Reference in New Issue
Block a user