> ## Documentation Index
> Fetch the complete documentation index at: https://www.help.creatora.io/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> When building or modifying an integration with the Creatora API, start with https://www.help.creatora.io/en/api/build-with-ai.md. Retrieve the current GraphQL SDL from https://api.creatora.io/sdl before relying on API schema information.

# Compare quiz results for a Course

> Compare completed quiz attempts and latest results by Student.

Read quiz attempts across a Course and compare each Student’s latest attempt. Replace the Course ID.

## Request

<RequestExample>
  ```graphql theme={null}
  {
    courseById(courseId: "22222222-2222-4222-8222-222222222222") {
      id name
      modules { contents {
        id name variantData {
          __typename
          ... on CourseModuleContentQuiz {
            passingScore
            attempts { id createdOn completedOn score isPassed student { id email } }
          }
        }
      } }
    }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Illustrative response theme={null}
  {
    "data": {
      "courseById": {
        "id": "22222222-2222-4222-8222-222222222222",
        "name": "Drawing Essentials",
        "modules": [
          {
            "contents": [
              {
                "id": "77777777-7777-4777-8777-777777777777",
                "name": "Drawing basic shapes",
                "variantData": {
                  "__typename": "CourseModuleContentVideoLesson"
                }
              },
              {
                "id": "99999999-9999-4999-8999-999999999999",
                "name": "Check your understanding",
                "variantData": {
                  "__typename": "CourseModuleContentQuiz",
                  "passingScore": 80,
                  "attempts": [
                    {
                      "id": "99999999-9999-4999-8999-999999999999",
                      "createdOn": 1788220800000,
                      "completedOn": 1788224400000,
                      "score": 100,
                      "isPassed": true,
                      "student": {
                        "id": "33333333-3333-4333-8333-333333333333",
                        "email": "student@example.com"
                      }
                    }
                  ]
                }
              }
            ]
          }
        ]
      }
    }
  }
  ```
</ResponseExample>

## Use the result

```javascript theme={null}
const course = response.data.courseById;
const rows = course.modules.flatMap(module => module.contents).flatMap(content => {
  const quiz = content.variantData;
  if (quiz?.__typename !== "CourseModuleContentQuiz") return [];
  const latest = new Map();
  for (const attempt of quiz.attempts) {
    const previous = latest.get(attempt.student.id);
    if (!previous || attempt.createdOn > previous.createdOn) latest.set(attempt.student.id, attempt);
  }
  const completed = [...latest.values()].filter(attempt => attempt.completedOn !== null);
  const passing = completed.filter(attempt => attempt.isPassed);
  return [{
    contentId: content.id, quiz: content.name, studentsWithAttempts: latest.size,
    studentsWithCompletedLatestAttempt: completed.length, studentsPassed: passing.length,
    passRate: completed.length ? passing.length / completed.length : null
  }];
});
```

Administrator mode returns all attempts for each quiz, including attempts by accounts outside the current Course roster. Apply a roster filter if you need current Students only. This report uses the latest attempt, even if it is still incomplete, instead of picking the best score. The returned `isPassed` uses that attempt’s passing score; the quiz’s current setting may have changed. Equal creation timestamps need manual tie resolution.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.