Skip to content

Commit

Permalink
#1497 fixes msg around assignments are graded and all goals are set (#…
Browse files Browse the repository at this point in the history
…1539)

* #1497 fixes msg around assignments are graded and all goals are set
  • Loading branch information
pushyamig authored Sep 15, 2023
1 parent 945c036 commit 05b29ba
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions assets/src/hooks/useMathWarning.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 05b29ba

Please sign in to comment.