From 3745447b8a134b6cb1591587b60d93d07cf7a31d Mon Sep 17 00:00:00 2001 From: nsavinda Date: Wed, 4 Dec 2024 07:13:50 +0530 Subject: [PATCH 1/3] fix map error --- src/pages/examSetter/Grade.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/examSetter/Grade.tsx b/src/pages/examSetter/Grade.tsx index 35f6eab..5b3d130 100644 --- a/src/pages/examSetter/Grade.tsx +++ b/src/pages/examSetter/Grade.tsx @@ -130,8 +130,8 @@ const highlightTextWithFeedback = ( let incorrectPatterns: RegExp[] = []; if (feedback) { - correctPatterns = feedback.correct_points.map((point) => new RegExp(`\\b${point}\\b`, "gi")); - incorrectPatterns = feedback.incorrect_points.map((point) => new RegExp(`\\b${point}\\b`, "gi")); + correctPatterns = feedback.correct_points?.map((point) => new RegExp(`\\b${point}\\b`, "gi")); + incorrectPatterns = feedback.incorrect_points?.map((point) => new RegExp(`\\b${point}\\b`, "gi")); } From 01fb555789e74263ba9a7f745263f19c46fc32c3 Mon Sep 17 00:00:00 2001 From: nsavinda Date: Wed, 4 Dec 2024 07:20:11 +0530 Subject: [PATCH 2/3] grading error fix --- src/pages/examSetter/Grade.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/examSetter/Grade.tsx b/src/pages/examSetter/Grade.tsx index 5b3d130..0e31101 100644 --- a/src/pages/examSetter/Grade.tsx +++ b/src/pages/examSetter/Grade.tsx @@ -61,7 +61,7 @@ const initialData: GradingQuestion[] = [ questionText: "What were two causes of the American Civil War?", userAnswer: "The issue of slavery, The Southern states' belief in the necessity of a strong central government", coverPoints: [ - { coverPointText: "The issue of slavery", marks: 5 }, + { coverPointText: "slavery", marks: 5 }, ], // feedback: { // correct_points: ["The issue of slavery"], @@ -75,7 +75,7 @@ const initialData: GradingQuestion[] = [ questionText: "What were two significant achievements of Napoleon Bonaparte during his rule?", userAnswer: "The establishment of the Napoleonic Code, His successful invasion and permanent conquest of Russia", coverPoints: [ - { coverPointText: "The establishment of the Napoleonic Code", marks: 5 }, + { coverPointText: "Napoleonic Code", marks: 5 }, ], // feedback: { // correct_points: ["The establishment of the Napoleonic Code"], @@ -89,7 +89,7 @@ const initialData: GradingQuestion[] = [ questionText: "Which of the following was a primary cause of the French Revolution?", userAnswer: "The effects of the industrial revolution on French factories, The severe hunger and economic problems faced by ordinary French citizens, Foreign countries invading France and causing rebellion.", coverPoints: [ - { coverPointText: "The severe hunger and economic problems faced by ordinary French citizens", marks: 5 }, + { coverPointText: "hunger and economic problems faced by ordinary French citizens", marks: 5 }, ], // feedback: { // correct_points: ["The severe hunger and economic problems faced by ordinary French citizens"], @@ -106,7 +106,7 @@ const initialData: GradingQuestion[] = [ questionText: "Which of the following was a major reason for the Revolt of 1857 in India?", userAnswer: "The introduction of Western-style education, The discontent among Indian soldiers due to cultural insensitivity, The establishment of the Indian National Congress.", coverPoints: [ - { coverPointText: "The discontent among Indian soldiers due to cultural insensitivity", marks: 5 }, + { coverPointText: "The discontent among Indian soldiers ", marks: 5 }, ], // feedback: { // correct_points: ["The discontent among Indian soldiers due to cultural insensitivity"], @@ -138,7 +138,7 @@ const highlightTextWithFeedback = ( // Avoid overlapping matches by tracking used ranges const matchedRanges: { start: number; end: number; style: "correct" | "incorrect" }[] = []; - correctPatterns.forEach((pattern) => { + correctPatterns?.forEach((pattern) => { let match; while ((match = pattern.exec(text)) !== null) { matchedRanges.push({ @@ -149,7 +149,7 @@ const highlightTextWithFeedback = ( } }); - incorrectPatterns.forEach((pattern) => { + incorrectPatterns?.forEach((pattern) => { let match; while ((match = pattern.exec(text)) !== null) { matchedRanges.push({ From 75bc7cfedbd4758b52919ddc337efb677933975a Mon Sep 17 00:00:00 2001 From: Nirmal Savinda Date: Wed, 4 Dec 2024 07:22:53 +0530 Subject: [PATCH 3/3] Update src/pages/examSetter/Grade.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/pages/examSetter/Grade.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/examSetter/Grade.tsx b/src/pages/examSetter/Grade.tsx index 0e31101..3e4b62d 100644 --- a/src/pages/examSetter/Grade.tsx +++ b/src/pages/examSetter/Grade.tsx @@ -130,8 +130,8 @@ const highlightTextWithFeedback = ( let incorrectPatterns: RegExp[] = []; if (feedback) { - correctPatterns = feedback.correct_points?.map((point) => new RegExp(`\\b${point}\\b`, "gi")); - incorrectPatterns = feedback.incorrect_points?.map((point) => new RegExp(`\\b${point}\\b`, "gi")); + correctPatterns = (feedback.correct_points ?? []).map((point) => new RegExp(`\\b${point}\\b`, "gi")); + incorrectPatterns = (feedback.incorrect_points ?? []).map((point) => new RegExp(`\\b${point}\\b`, "gi")); }