Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/pages/examSetter/Grade.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
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"],
Expand All @@ -75,7 +75,7 @@
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"],
Expand All @@ -89,7 +89,7 @@
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"],
Expand All @@ -106,7 +106,7 @@
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"],
Expand All @@ -130,15 +130,15 @@
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"));
}


// 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({
Expand All @@ -149,7 +149,7 @@
}
});

incorrectPatterns.forEach((pattern) => {
incorrectPatterns?.forEach((pattern) => {
let match;
while ((match = pattern.exec(text)) !== null) {
matchedRanges.push({
Expand Down Expand Up @@ -215,7 +215,7 @@
try {
const response = await getEssayDetails(examID, userID);
const essayDetails = response.data.map(question => ({
id: question.id, // use actual question ID if available

Check failure on line 218 in src/pages/examSetter/Grade.tsx

View workflow job for this annotation

GitHub Actions / build

Property 'id' does not exist on type 'GradeQuestionResponse'.
questionText: question.questionText,
userAnswer: question.userAnswer,
coverPoints: question.coverPoints.map(point => ({
Expand Down
Loading