From 55468496e0842ca014af6d6b93e87c1c0f46f222 Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Wed, 19 Jun 2019 09:53:01 +0200 Subject: [PATCH 1/3] fix: minor heat correction for correction overview --- messages/uniworx/de.msg | 2 +- src/Foundation.hs | 2 +- src/Handler/Corrections.hs | 5 +++-- src/Utils.hs | 2 +- templates/corrections-overview.hamlet | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/messages/uniworx/de.msg b/messages/uniworx/de.msg index 22c502e1f..8057ca78a 100644 --- a/messages/uniworx/de.msg +++ b/messages/uniworx/de.msg @@ -409,7 +409,7 @@ NrSubmissionsNewlyAssigned: Neu zugeteilt NrSubmissionsNotAssigned: Nicht zugeteilt NrSubmissionsNotCorrected: Unkorrigiert CorrectionTime: Korrekturdauer (Min/Avg/Max) -AssignSubmissionsRandomWarning: Die Zuteilungsvorschau kann geringfügig von der tatsächlichen Zuteilung abweichen, da die Zuteilung ein randomisierter Prozess ist. Mehrfaches neues Laden dieser Seite vor Betätigung des Zuteilungsknopfes kann dies sichtbar machen. +AssignSubmissionsRandomWarning: Die Zuteilungsvorschau kann von der tatsächlichen Zuteilung abweichen, wenn mehrere Blätter auf einmal zugeteilt werden, da beim Ausgleich der Kontigente nur bereits zugeteilte Abgaben berücksichtigt werden. Da es ein randomisierte Prozess ist, kann es auch bei einzelnen Blättern gerinfgügige Abweichungen geben. CorrectionsUploaded num@Int64: #{display num} Korrekturen wurden gespeichert: NoCorrectionsUploaded: In der hochgeladenen Datei wurden keine Korrekturen gefunden. diff --git a/src/Foundation.hs b/src/Foundation.hs index ad0d88b3c..3be718bb7 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -1427,7 +1427,7 @@ instance YesodBreadcrumbs UniWorX where breadcrumb (CourseR tid ssh csh CInviteR) = return ("Einladung", Just $ CourseR tid ssh csh CShowR) breadcrumb (CourseR tid ssh csh (CUserR _)) = return ("Teilnehmer" , Just $ CourseR tid ssh csh CUsersR) breadcrumb (CourseR tid ssh csh CCorrectionsR) = return ("Abgaben" , Just $ CourseR tid ssh csh CShowR) - breadcrumb (CourseR tid ssh csh CAssignR) = return ("Korrektur" , Just $ CourseR tid ssh csh CCorrectionsR) + breadcrumb (CourseR tid ssh csh CAssignR) = return ("Zuteilung" , Just $ CourseR tid ssh csh CCorrectionsR) breadcrumb (CourseR tid ssh csh SheetListR) = return ("Übungen" , Just $ CourseR tid ssh csh CShowR) breadcrumb (CourseR tid ssh csh SheetNewR ) = return ("Neu", Just $ CourseR tid ssh csh SheetListR) breadcrumb (CourseR tid ssh csh SheetCurrentR) = return ("Aktuelles Blatt", Just $ CourseR tid ssh csh SheetListR) diff --git a/src/Handler/Corrections.hs b/src/Handler/Corrections.hs index b64959f0c..26ba218cc 100644 --- a/src/Handler/Corrections.hs +++ b/src/Handler/Corrections.hs @@ -1134,10 +1134,11 @@ assignHandler tid ssh csh cid assignSids = do let shn = sheetName $ sheets ! sid -- is sheet closed? guardM $ lift $ hasWriteAccessTo $ CSheetR tid ssh csh shn SAssignR -- we must check, whether the submission is already closed and thus assignable - -- has at least one submisison? + -- has at least one uncorrected / unassigned submisison? [E.Value hasSubmission] <- lift $ E.select $ return $ E.exists $ E.from $ \submission -> do E.where_ $ submission E.^. SubmissionSheet E.==. E.val sid - E.where_ $ E.isNothing $ submission E.^. SubmissionRatingBy + E.where_ $ E.isNothing $ submission E.^. SubmissionRatingBy -- no corrector + E.where_ $ E.isNothing $ submission E.^. SubmissionRatingTime -- not done guard hasSubmission -- has at least one active corrector? [E.Value hasCorrector] <- lift $ E.select $ return $ E.exists $ E.from $ \corrector -> do diff --git a/src/Utils.hs b/src/Utils.hs index a6fa63d38..4f565befe 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -386,7 +386,7 @@ cutOffPercent :: Double -> Double -> Double -> Double cutOffPercent offset full achieved | full <= achieved = 0 | full <= 0 = 0 -  | otherwise = offset + (1-offset * (1 - percent)) +  | otherwise = offset + (1-offset) * (1 - percent) where percent = achieved / full diff --git a/templates/corrections-overview.hamlet b/templates/corrections-overview.hamlet index 19d13e265..621ffd51e 100644 --- a/templates/corrections-overview.hamlet +++ b/templates/corrections-overview.hamlet @@ -22,7 +22,7 @@ (-#{show (Set.size splus)}, failed: #{show (Set.size sfailed)}) $elseif 0 < Set.size splus #{ciSubmissions - ciAssigned} - (-#{show (Set.size splus)}) + (-#{show (Set.size splus)}) $else #{ciSubmissions - ciAssigned} $nothing @@ -60,7 +60,7 @@ $maybe nrNew <- getCorrNewAssignment ciCorrector shn #{ciSubmissions} $# #{ciAssigned} `ciSubmissions` is here always identical to `ciAssigned` and also works for `ciCorrector == Nothing`. ciAssigned only useful in aggregate maps like `sheetMap` - (+#{nrNew}) + (+#{nrNew}) $nothing #{ciSubmissions} #{ciSubmissions - ciCorrected} From 3bded5071bf0e32a6d4df0dcc49f6039f283785e Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Wed, 19 Jun 2019 10:49:22 +0200 Subject: [PATCH 2/3] fix: filter submission by not having corrector --- messages/uniworx/de.msg | 1 + src/Handler/Corrections.hs | 18 +++++++++++++----- templates/table/layout.hamlet | 4 ++++ templates/table/layout.lucius | 7 +++++++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/messages/uniworx/de.msg b/messages/uniworx/de.msg index 8057ca78a..c0ee216ae 100644 --- a/messages/uniworx/de.msg +++ b/messages/uniworx/de.msg @@ -415,6 +415,7 @@ CorrectionsUploaded num@Int64: #{display num} Korrekturen wurden gespeichert: NoCorrectionsUploaded: In der hochgeladenen Datei wurden keine Korrekturen gefunden. RatingBy: Korrigiert von +HasCorrector: Korrektor zugeteilt AssignedTime: Zuteilung AchievedBonusPoints: Erreichte Bonuspunkte AchievedNormalPoints: Erreichte Punkte diff --git a/src/Handler/Corrections.hs b/src/Handler/Corrections.hs index 26ba218cc..dc8cb791e 100644 --- a/src/Handler/Corrections.hs +++ b/src/Handler/Corrections.hs @@ -334,6 +334,12 @@ makeCorrectionsTable whereClause dbtColonnade dbtFilterUI psValidator dbtProj' d | otherwise -> corrector E.?. UserEmail `E.in_` E.justList (E.valList . catMaybes $ Set.toList emails) E.||. (if Nothing `Set.member` emails then E.isNothing (corrector E.?. UserEmail) else E.val False) ) + , ( "isassigned" + , FilterColumn $ \((_ `E.InnerJoin` _ `E.InnerJoin` submission) `E.LeftOuterJoin` _ :: CorrectionTableExpr) criterion -> case getLast (criterion :: Last Bool) of + Nothing -> E.val True :: E.SqlExpr (E.Value Bool) + Just True -> E.not_ . E.isNothing $ submission E.^. SubmissionRatingBy + Just False-> E.isNothing $ submission E.^. SubmissionRatingBy + ) , ( "israted" , FilterColumn $ \((_ `E.InnerJoin` _ `E.InnerJoin` submission) `E.LeftOuterJoin` _ :: CorrectionTableExpr) criterion -> case getLast (criterion :: Last Bool) of Nothing -> E.val True :: E.SqlExpr (E.Value Bool) @@ -636,10 +642,11 @@ postCCorrectionsR tid ssh csh = do filterUI = Just $ \mPrev -> mconcat [ prismAForm (singletonFilter "user-name-email") mPrev $ aopt textField (fslI MsgCourseMembers) , prismAForm (singletonFilter "user-matriclenumber") mPrev $ aopt textField (fslI MsgMatrikelNr) - , prismAForm (singletonFilter "corrector-name-email") mPrev $ aopt textField (fslI MsgCorrector) - -- "pseudonym" TODO DB only stores Word24 + -- "pseudonym" TODO DB only stores Word24 , Map.singleton "sheet-search" . maybeToList <$> aopt textField (fslI MsgSheet) (Just <$> listToMaybe =<< ((Map.lookup "sheet-search" =<< mPrev) <|> (Map.lookup "sheet" =<< mPrev))) - , prismAForm (singletonFilter "israted" . maybePrism _PathPiece) mPrev $ aopt boolField (fslI MsgRatingTime) + , prismAForm (singletonFilter "corrector-name-email") mPrev $ aopt textField (fslI MsgCorrector) + , prismAForm (singletonFilter "isassigned" . maybePrism _PathPiece) mPrev $ aopt boolField (fslI MsgHasCorrector) + , prismAForm (singletonFilter "israted" . maybePrism _PathPiece) mPrev $ aopt boolField (fslI MsgRatingTime) ] psValidator = def & defaultPagesize PagesizeAll -- Assisstant always want to see them all at once anyway correctionsR whereClause colonnade filterUI psValidator $ Map.fromList @@ -669,8 +676,9 @@ postSSubsR tid ssh csh shn = do [ prismAForm (singletonFilter "user-name-email") mPrev $ aopt textField (fslI MsgCourseMembers) , prismAForm (singletonFilter "user-matriclenumber") mPrev $ aopt textField (fslI MsgMatrikelNr) , prismAForm (singletonFilter "corrector-name-email") mPrev $ aopt textField (fslI MsgCorrector) - -- "pseudonym" TODO DB only stores Word24 - , prismAForm (singletonFilter "israted" . maybePrism _PathPiece) mPrev $ aopt boolField (fslI MsgRatingTime) + , prismAForm (singletonFilter "isassigned" . maybePrism _PathPiece) mPrev $ aopt boolField (fslI MsgHasCorrector) + , prismAForm (singletonFilter "israted" . maybePrism _PathPiece) mPrev $ aopt boolField (fslI MsgRatingTime) + -- "pseudonym" TODO DB only stores Word24 ] psValidator = def & defaultPagesize PagesizeAll -- Assisstant always want to see them all at once anyway correctionsR whereClause colonnade filterUI psValidator $ Map.fromList diff --git a/templates/table/layout.hamlet b/templates/table/layout.hamlet index b292cee5c..eb8baadcb 100644 --- a/templates/table/layout.hamlet +++ b/templates/table/layout.hamlet @@ -2,6 +2,10 @@ $newline never $if null rows && (dbsEmptyStyle == DBESNoHeading) _{dbsEmptyMessage} $else +
+
+ _{MsgRowCount rowCount} + ^{table}
diff --git a/templates/table/layout.lucius b/templates/table/layout.lucius index c03851b27..0c402442b 100644 --- a/templates/table/layout.lucius +++ b/templates/table/layout.lucius @@ -1,3 +1,10 @@ +/* TABLE HEADER */ +.table-header { + display: flex; + flex-flow: row-reverse; + justify-content: space-between; +} + /* TABLE FOOTER */ .table-footer { display: flex; From 4423817ef536f9ee0844059b82f3eedd6a604206 Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Wed, 19 Jun 2019 10:55:59 +0200 Subject: [PATCH 3/3] fix build: linting javascript --- .vscode/tasks.json | 5 +++++ frontend/src/utils/async-table/async-table.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 1c0b71c32..fabc6a5d5 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -63,6 +63,11 @@ "type": "npm", "script": "frontend:lint", "problemMatcher": [] + }, + { + "type": "npm", + "script": "lint", + "problemMatcher": [] } ] } \ No newline at end of file diff --git a/frontend/src/utils/async-table/async-table.js b/frontend/src/utils/async-table/async-table.js index 26dfb5624..0c9e9cb04 100644 --- a/frontend/src/utils/async-table/async-table.js +++ b/frontend/src/utils/async-table/async-table.js @@ -296,7 +296,7 @@ export class AsyncTable { return el.getAttribute('href') || el.querySelector('a').getAttribute('href'); } - _changePagesizeHandler = (event) => { + _changePagesizeHandler = () => { const url = new URL(getLocalStorageParameter('currentTableUrl') || window.location.href); const formData = new FormData(this._pagesizeForm);