From 05b29ba935afd8b1769d61943f93b5b084698c14 Mon Sep 17 00:00:00 2001 From: Pushyami Gundala Date: Fri, 15 Sep 2023 13:02:52 -0400 Subject: [PATCH] #1497 fixes msg around assignments are graded and all goals are set (#1539) * #1497 fixes msg around assignments are graded and all goals are set --- assets/src/hooks/useMathWarning.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/assets/src/hooks/useMathWarning.js b/assets/src/hooks/useMathWarning.js index 0664698f..8730de2e 100644 --- a/assets/src/hooks/useMathWarning.js +++ b/assets/src/hooks/useMathWarning.js @@ -1,13 +1,20 @@ import { useEffect, useState } from 'react' -const allAssignmentsHasGoalGrade = assignments => - assignments.filter(a => !(a.goalGradeSetByUser)).length === 0 +// this is the case when either few assignments are graded or few has goal grade. +// if an assignment is graded then it won't have goal grade. +const isFewAssignmentsAreGradedOrHasGoalGrade = assignments => + assignments.filter(a => !(a.graded || a.goalGradeSetByUser)).length === 0 + +// this is the case when all assignments are graded and design won't allow assignment goal setting but course grade is allowed +const allAssignmentsAreGraded = assignments => assignments.filter(a => !(a.graded)).length === 0 const useMathWarning = assignments => { const [showMathWarning, setShowMathWarning] = useState(false) useEffect(() => { - if (allAssignmentsHasGoalGrade(assignments)) { + if (allAssignmentsAreGraded(assignments)) { + setShowMathWarning(false) + } else if (isFewAssignmentsAreGradedOrHasGoalGrade(assignments)) { setShowMathWarning(true) } else { setShowMathWarning(false)