Reubencf commited on
Commit
23ca656
·
1 Parent(s): 9953d0a

some quiz issue

Browse files
Files changed (1) hide show
  1. mcp-server.js +14 -2
mcp-server.js CHANGED
@@ -739,7 +739,19 @@ class ReubenOSMCPServer {
739
 
740
  // Parse the quiz and answers
741
  const quiz = JSON.parse(quizFile.content);
742
- const answers = JSON.parse(answersFile.content);
 
 
 
 
 
 
 
 
 
 
 
 
743
 
744
  // Analyze the answers
745
  let correctCount = 0;
@@ -748,7 +760,7 @@ class ReubenOSMCPServer {
748
  const feedback = [];
749
 
750
  quiz.questions.forEach((question, index) => {
751
- const userAnswer = answers.answers?.[question.id] || answers[question.id];
752
  const points = question.points || 1;
753
  maxPoints += points;
754
 
 
739
 
740
  // Parse the quiz and answers
741
  const quiz = JSON.parse(quizFile.content);
742
+ const answersData = JSON.parse(answersFile.content);
743
+
744
+ // Convert answers array to object for easier lookup
745
+ const answers = {};
746
+ if (answersData.answers && Array.isArray(answersData.answers)) {
747
+ // QuizApp format: { answers: [{ questionId, answer }], metadata: {...} }
748
+ answersData.answers.forEach(item => {
749
+ answers[item.questionId] = item.answer;
750
+ });
751
+ } else {
752
+ // Fallback for direct object format
753
+ Object.assign(answers, answersData);
754
+ }
755
 
756
  // Analyze the answers
757
  let correctCount = 0;
 
760
  const feedback = [];
761
 
762
  quiz.questions.forEach((question, index) => {
763
+ const userAnswer = answers[question.id];
764
  const points = question.points || 1;
765
  maxPoints += points;
766