More navigation bugs and fixed broken modal during transition
This commit is contained in:
@@ -61,8 +61,8 @@ export default function Finish({ user, practiceScores, scores, modules, informat
|
||||
|
||||
const aiUsage = Math.round(ai_usage(solutions) * 100);
|
||||
|
||||
//const entity = useMemo(() => assignment?.entity || user.entities[0]?.id || "", [assignment?.entity, user.entities])
|
||||
//const { gradingSystem } = useGradingSystem(entity);
|
||||
const entity = useMemo(() => assignment?.entity || user.entities[0]?.id || "", [assignment?.entity, user.entities])
|
||||
const { gradingSystem } = useGradingSystem(entity);
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
@@ -104,7 +104,7 @@ export default function Finish({ user, practiceScores, scores, modules, informat
|
||||
|
||||
const showLevel = (level: number) => {
|
||||
if (selectedModule === "level") {
|
||||
const label = getGradingLabel(level, []);
|
||||
const label = getGradingLabel(level, gradingSystem?.steps || []);
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center gap-1">
|
||||
<span className="text-xl font-bold">{label}</span>
|
||||
@@ -180,7 +180,7 @@ export default function Finish({ user, practiceScores, scores, modules, informat
|
||||
<BsPen className="h-6 w-6" />
|
||||
<span className="font-semibold">Writing</span>
|
||||
</div>
|
||||
{aiUsage >= 50 && user.type !== "student" && (
|
||||
{aiUsage >= 50 && selectedModule === "writing" && user.type !== "student" && (
|
||||
<div
|
||||
className={clsx("flex items-center justify-center border px-3 h-full rounded", {
|
||||
"bg-orange-100 border-orange-400 text-orange-700": aiUsage < 80,
|
||||
|
||||
@@ -65,7 +65,6 @@ const Level: React.FC<ExamProps<LevelExam>> = ({ exam, showSolutions = false, pr
|
||||
const [showQuestionsModal, setShowQuestionsModal] = useState(false);
|
||||
const [continueAnyways, setContinueAnyways] = useState(false);
|
||||
const [textRender, setTextRender] = useState(false);
|
||||
const [changedPrompt, setChangedPrompt] = useState(false);
|
||||
|
||||
|
||||
const [questionModalKwargs, setQuestionModalKwargs] = useState<{
|
||||
@@ -98,9 +97,9 @@ const Level: React.FC<ExamProps<LevelExam>> = ({ exam, showSolutions = false, pr
|
||||
{
|
||||
exam, module: "level", showBlankModal: showQuestionsModal,
|
||||
setShowBlankModal: setShowQuestionsModal, showSolutions,
|
||||
preview, disableBetweenParts: true, modalKwargs
|
||||
});
|
||||
|
||||
preview, disableBetweenParts: true, modalBetweenParts: true ,modalKwargs
|
||||
}
|
||||
);
|
||||
|
||||
const registerSolution = useCallback((updateSolution: () => UserSolution) => {
|
||||
userSolutionRef.current = updateSolution;
|
||||
@@ -299,7 +298,6 @@ const Level: React.FC<ExamProps<LevelExam>> = ({ exam, showSolutions = false, pr
|
||||
currentExercise!.questions[questionIndex + i].prompt = updatedPrompt;
|
||||
}
|
||||
})
|
||||
setChangedPrompt(true);
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@@ -366,14 +364,14 @@ const Level: React.FC<ExamProps<LevelExam>> = ({ exam, showSolutions = false, pr
|
||||
onNext={() => { setShowPartDivider(false); setIsFirstTimeRender(false); setBgColor("bg-white"); setSeenParts(prev => new Set(prev).add(partIndex)); }}
|
||||
/> : (
|
||||
<>
|
||||
<SectionNavbar
|
||||
{exam.parts.length > 1 && <SectionNavbar
|
||||
module="level"
|
||||
sectionLabel="Part"
|
||||
seenParts={seenParts}
|
||||
setShowPartDivider={setShowPartDivider}
|
||||
setSeenParts={setSeenParts}
|
||||
preview={preview}
|
||||
/>
|
||||
/>}
|
||||
<ModuleTitle
|
||||
examLabel={exam.label}
|
||||
partLabel={partLabel()}
|
||||
|
||||
@@ -75,10 +75,10 @@ const useExamNavigation: UseExamNavigation = ({
|
||||
|
||||
// when navbar is used
|
||||
useEffect(()=> {
|
||||
if(startNow && partIndex !== 0) {
|
||||
if(startNow && !showPartDivider && partIndex !== 0) {
|
||||
setStartNow(false);
|
||||
}
|
||||
} , [partIndex, startNow])
|
||||
} , [partIndex, startNow, showPartDivider])
|
||||
|
||||
useEffect(() => {
|
||||
if (!showSolutions && hasDivider(exam, isPartExam ? partIndex : exerciseIndex) && !seenParts.has(partIndex)) {
|
||||
@@ -161,8 +161,7 @@ const useExamNavigation: UseExamNavigation = ({
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(modalBetweenParts);
|
||||
if (modalBetweenParts && !answeredEveryQuestion(exam as PartExam, userSolutions) && !keepGoing && setShowBlankModal && !showSolutions && !preview) {
|
||||
if (modalBetweenParts && !seenParts.has(partIndex + 1) && !answeredEveryQuestion(exam as PartExam, userSolutions) && !keepGoing && setShowBlankModal && !showSolutions && !preview) {
|
||||
if (modalKwargs) modalKwargs();
|
||||
setShowBlankModal(true);
|
||||
return;
|
||||
@@ -197,7 +196,7 @@ const useExamNavigation: UseExamNavigation = ({
|
||||
|
||||
const previousPartExam = () => {
|
||||
|
||||
if (partIndex === 0 && exerciseIndex === 0 && !startNow) {
|
||||
if (!showPartDivider && partIndex === 0 && exerciseIndex === 0 && questionIndex === 0 && !startNow) {
|
||||
setStartNow(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user