Gradebook Backend API Documentation - v0.0.1
    Preparing search index...

    Service responsible for managing course-related operations in the gradebook system. Handles course creation, student enrollment, grade management, and course information retrieval.

    Index

    Constructors

    Methods

    • Adds a grade for a specific student in a course. Only the teacher of the course can add grades.

      Parameters

      • courseId: number

        The ID of the course

      • studentEmail: string

        The email of the student receiving the grade

      • grade: number

        The numeric grade value

      • teacher: User

        The teacher adding the grade

      Returns Promise<{ date: Date; grade: number; id: number }>

      The newly created grade object

      NotFoundException if the course or student is not found

      BadRequestException if the teacher is not authorized to add grades

    • Creates a new course with the specified teacher as the owner.

      Parameters

      • title: string

        The title of the course

      • description: string

        The description of the course

      • teacherEmail: string

        The email of the teacher creating the course

      Returns Promise<Course>

      The newly created course entity

      NotFoundException if the teacher is not found

      BadRequestException if a course with the same title already exists

    • Marks a grade as deleted (soft delete). Only the teacher of the course can delete grades. The deletion is recorded in grade history.

      Parameters

      • gradeId: number

        The ID of the grade to delete

      • teacher: User

        The teacher deleting the grade

      Returns Promise<boolean>

      True if the grade was successfully marked as deleted

      NotFoundException if the grade is not found

      BadRequestException if the teacher is not authorized to delete the grade

    • Deletes a course from the system. Only the teacher who created the course is authorized to delete it.

      Parameters

      • title: string

        The title of the course to delete

      • teacherEmail: string

        The email of the teacher attempting to delete the course

      Returns Promise<{ message: string }>

      A success message upon successful deletion

      NotFoundException if the course is not found

      BadRequestException if the user is not authorized to delete the course

    • Edits an existing grade for a student. Only the teacher of the course can edit grades. The change is recorded in grade history.

      Parameters

      • gradeId: number

        The ID of the grade to edit

      • grade: number

        The new grade value

      • teacher: User

        The teacher editing the grade

      Returns Promise<boolean>

      True if the grade was successfully updated

      NotFoundException if the grade is not found

      BadRequestException if the teacher is not authorized to edit the grade

    • Enrolls a student in a specific course.

      Parameters

      • courseTitle: string

        The title of the course

      • studentEmail: string

        The email of the student to enroll

      • teacherEmail: string

        The email of the teacher authorizing the enrollment

      Returns Promise<{ message: string }>

      The result of the enrollment operation

      NotFoundException if the course is not found

    • Finds a course by its title, including related teacher and student information.

      Parameters

      • title: string

        The title of the course to find

      Returns Promise<null | Course>

      The course entity if found, otherwise null

    • Retrieves all courses in which a specific student is enrolled.

      Parameters

      • studentEmail: string

        The email of the student

      Returns Promise<
          {
              description: string;
              grades: { date: Date; grade: number; id: number }[];
              id: number;
              students: StudentCourse[];
              teacher: {
                  email: string;
                  firstName: string;
                  image: string;
                  lastName: string;
                  role: UserRole;
              };
              title: string;
          }[],
      >

      An array of course information objects

    • Retrieves all courses taught by a specific teacher.

      Parameters

      • teacherEmail: string

        The email of the teacher

      Returns Promise<
          {
              description: string;
              id: number;
              students: {
                  email: string;
                  firstName: string;
                  image: string;
                  lastName: string;
                  role: UserRole;
              }[];
              teacher: {
                  email: string;
                  firstName: string;
                  image: string;
                  lastName: string;
                  role: UserRole;
              };
              title: string;
          }[],
      >

      An array of course information objects

      NotFoundException if the teacher is not found

    • Retrieves detailed information about a specific course, with access control based on user role. Teachers see all student information and grades, while students only see their own grades.

      Parameters

      • id: number

        The ID of the course to retrieve

      • user: User

        The user requesting the course information

      Returns Promise<
          {
              description: string;
              grades: undefined
              | StudentCourseGrade[];
              id: number;
              students:
                  | undefined
                  | {
                      email: string;
                      firstName: string;
                      grades: { date: Date; grade: number; id: number }[];
                      image: string;
                      lastName: string;
                      role: UserRole;
                  }[];
              teacher: {
                  email: string;
                  firstName: string;
                  image: string;
                  lastName: string;
                  role: UserRole;
              };
              title: string;
          },
      >

      Course details including teacher info and conditionally student info and grades

      NotFoundException if the course is not found

      BadRequestException if the user is not authorized to view the course

    • Retrieves the list of students enrolled in a specific course.

      Parameters

      • courseTitle: string

        The title of the course

      Returns Promise<
          {
              email: string;
              firstName: string;
              image: string;
              lastName: string;
              role: UserRole;
          }[],
      >

      An array of student information objects

      NotFoundException if the course is not found

    • Submits multiple grades for students in a course at once. Only the teacher of the course can submit grades.

      Parameters

      • courseId: number

        The ID of the course

      • gradesArray: { email: string; grade: number }[]

        Array of objects containing student emails and their grades

      • teacher: User

        The teacher submitting the grades

      Returns Promise<{ message: string }>

      A success message upon successful submission

      NotFoundException if the course or a student is not found

      BadRequestException if the teacher is not authorized to submit grades