Skip to content

Commit

Permalink
fixup! fix: Fixes the saving pop-up to appear
Browse files Browse the repository at this point in the history
  • Loading branch information
farhaanbukhsh committed Oct 21, 2024
1 parent 26872db commit 064375f
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/grading-settings/grading-scale/GradingScale.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,31 @@ const GradingScale = ({
}, [gradingSegments, letters]);

const addNewGradingSegment = () => {
setGradingSegments(prevSegments => {
setGradingSegments((prevSegments) => {
let updatedGradingSegment = [];
if (prevSegments.length >= 5) {
const segSize = MAXIMUM_SCALE_LENGTH / (prevSegments.length + 1);
updatedGradingSegment = Array.from({ length: prevSegments.length + 1 }).map((_, i) => (
{
current: 100 - i * segSize,
previous: 100 - (i + 1) * segSize,
}
));
}
else {
updatedGradingSegment = Array.from({
length: prevSegments.length + 1,
}).map((_, i) => ({
current: 100 - i * segSize,
previous: 100 - (i + 1) * segSize,
}));
} else {
const firstSegment = prevSegments[prevSegments.length - 1];
const secondSegment = prevSegments[prevSegments.length - 2];
const newCurrentValue = Math.ceil((secondSegment.current - secondSegment.previous) / 2);
const newCurrentValue = Math.ceil(
(secondSegment.current - secondSegment.previous) / 2,
);

const newSegment = {
current: (firstSegment.current + newCurrentValue),
current: firstSegment.current + newCurrentValue,
previous: firstSegment.current,
};

const updatedSecondSegment = {
...secondSegment,
previous: (firstSegment.current + newCurrentValue),
previous: firstSegment.current + newCurrentValue,
};
updatedGradingSegment = [
...prevSegments.slice(0, prevSegments.length - 2),
Expand Down

0 comments on commit 064375f

Please sign in to comment.