/**
 * GraphQL 操作字符串定义（ai14）
 *
 * 使用 urql 的 gql tag 定义所有 57 个 GraphQL 操作（35 查询 + 22 变更）。
 * 操作名与 MSW handlers.ts 的 operationName 分发对齐。
 *
 * 所有操作的响应均包裹在 ActionState 信封中：
 *   query/mutation → { data: { <op>: ActionState<T> } }
 *
 * 查询变量类型见 types.ts；Hook 层负责解包 ActionState 提取 data。
 */

import { gql } from "urql";

// ===========================================================================
// 查询操作（35 个）
// ===========================================================================

/** 当前学生信息（含权限 + 视口 + 数据范围） */
export const CURRENT_USER_QUERY = gql`
  query currentUser {
    currentUser {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        name
        studentNo
        grade
        avatar
        roles
        permissions
        dataScope
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 我的班级列表 */
export const MY_CLASSES_QUERY = gql`
  query myClasses {
    myClasses {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        name
        homeroomTeacher
        studentCount
        grade
        year
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 我的考试列表 */
export const MY_EXAMS_QUERY = gql`
  query myExams {
    myExams {
      success
      errors {
        code
        message
      }
      data {
        id
        name
        subject {
          id
          name
        }
        status
        startsAt
        expiresAt
        durationSeconds
        questionCount
        totalScore
        submittedAt
        submissionId
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 考试详情（含题目） */
export const EXAM_DETAIL_QUERY = gql`
  query examDetail($examId: ID!) {
    examDetail(examId: $examId) {
      success
      errors {
        code
        message
      }
      data {
        id
        name
        subject {
          id
          name
        }
        status
        startsAt
        expiresAt
        durationSeconds
        totalScore
        questionCount
        questions {
          id
          type
          content
          options {
            id
            text
          }
          score
          maxScore
        }
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 我的作业列表 */
export const MY_HOMEWORK_QUERY = gql`
  query myHomework {
    myHomework {
      success
      errors {
        code
        message
      }
      data {
        id
        title
        subject {
          id
          name
        }
        status
        dueAt
        assignedAt
        questionCount
        totalScore
        submittedAt
        gradedAt
        score
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 作业详情（含题目） */
export const HOMEWORK_DETAIL_QUERY = gql`
  query homeworkDetail($homeworkId: ID!) {
    homeworkDetail(homeworkId: $homeworkId) {
      success
      errors {
        code
        message
      }
      data {
        id
        title
        subject {
          id
          name
        }
        status
        dueAt
        assignedAt
        questionCount
        totalScore
        questions {
          id
          type
          content
          options {
            id
            text
          }
          maxScore
        }
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 我的成绩列表 */
export const MY_GRADES_QUERY = gql`
  query myGrades {
    myGrades {
      success
      errors {
        code
        message
      }
      data {
        id
        examId
        examName
        subject {
          id
          name
        }
        score
        maxScore
        grade
        rank
        submittedAt
        gradedAt
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 我的考勤记录 */
export const MY_ATTENDANCE_QUERY = gql`
  query myAttendance {
    myAttendance {
      success
      errors {
        code
        message
      }
      data {
        id
        date
        status
        subject {
          id
          name
        }
        lateMinutes
        reason
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 教材列表 */
export const TEXTBOOKS_QUERY = gql`
  query textbooks {
    textbooks {
      success
      errors {
        code
        message
      }
      data {
        id
        name
        subject {
          id
          name
        }
        version
        author
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 章节列表（树形结构） */
export const CHAPTERS_QUERY = gql`
  query chapters($textbookId: ID!) {
    chapters(textbookId: $textbookId) {
      success
      errors {
        code
        message
      }
      data {
        id
        textbookId
        name
        level
        parentId
        order
        children {
          id
          textbookId
          name
          level
          parentId
          order
          children {
            id
            textbookId
            name
            level
            parentId
            order
            children {
              id
              textbookId
              name
              level
              parentId
              order
            }
          }
        }
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 学习路径（8 知识点 + 掌握度） */
export const LEARNING_PATH_QUERY = gql`
  query learningPath {
    learningPath {
      success
      errors {
        code
        message
      }
      data {
        id
        name
        knowledgePointId
        status
        mastery
        dependencies
        recommendedOrder
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 学生仪表盘聚合数据 */
export const STUDENT_DASHBOARD_QUERY = gql`
  query studentDashboard {
    studentDashboard {
      success
      errors {
        code
        message
      }
      data {
        upcomingHomework {
          id
          title
          dueAt
          subject {
            id
            name
          }
          status
        }
        upcomingExams {
          id
          name
          startsAt
          expiresAt
          durationSeconds
          subject {
            id
            name
          }
          status
        }
        recentGrades {
          id
          examName
          score
          maxScore
          grade
          submittedAt
        }
        attendanceRate
        learningStreakDays
        avgScore
        classRank
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 我的薄弱点（错题本） */
export const MY_WEAKNESS_QUERY = gql`
  query myWeakness {
    myWeakness {
      success
      errors {
        code
        message
      }
      data {
        id
        questionId
        questionContent
        subject {
          id
          name
        }
        knowledgePointId
        knowledgePointName
        mastery
        wrongCount
        lastWrongAt
        recommendedAction
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 学习趋势（7 数据点） */
export const MY_TREND_QUERY = gql`
  query myTrend {
    myTrend {
      success
      errors {
        code
        message
      }
      data {
        date
        score
        examName
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 通知列表 */
export const MY_NOTIFICATIONS_QUERY = gql`
  query myNotifications($first: Int, $after: String) {
    myNotifications(first: $first, after: $after) {
      success
      errors {
        code
        message
      }
      data {
        items {
          id
          type
          title
          content
          read
          createdAt
        }
        totalCount
        unreadCount
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 服务器时间（倒计时校正用） */
export const SERVER_TIME_QUERY = gql`
  query serverTime {
    serverTime {
      success
      errors {
        code
        message
      }
      data {
        timestamp
        offset
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

// ===========================================================================
// 变更操作（22 个）
// ===========================================================================

/** 提交作业 */
export const SUBMIT_HOMEWORK_MUTATION = gql`
  mutation submitHomework($input: SubmitHomeworkInput!) {
    submitHomework(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        submissionId
        submittedAt
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 提交考试 */
export const SUBMIT_EXAM_MUTATION = gql`
  mutation submitExam($input: SubmitExamInput!) {
    submitExam(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        submissionId
        submittedAt
        score
        maxScore
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 保存考试草稿（自动保存） */
export const SAVE_EXAM_DRAFT_MUTATION = gql`
  mutation saveExamDraft($input: SaveExamDraftInput!) {
    saveExamDraft(input: $input) {
      success
      errors {
        code
        message
      }
      data {
        savedAt
        ok
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 标记通知已读 */
export const MARK_AS_READ_MUTATION = gql`
  mutation markAsRead($input: MarkAsReadInput!) {
    markAsRead(input: $input) {
      success
      errors {
        code
        message
      }
      data {
        notificationId
        read
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 批量标记已读 */
export const MARK_ALL_AS_READ_MUTATION = gql`
  mutation markAllAsRead($input: MarkAllAsReadInput) {
    markAllAsRead(input: $input) {
      success
      errors {
        code
        message
      }
      data {
        updatedCount
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 记录考试违规（防作弊） */
export const RECORD_EXAM_VIOLATION_MUTATION = gql`
  mutation recordExamViolation($input: RecordExamViolationInput!) {
    recordExamViolation(input: $input) {
      success
      errors {
        code
        message
      }
      data {
        recorded
        violationCount
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 记录粘贴事件（防作弊） */
export const RECORD_PASTE_EVENT_MUTATION = gql`
  mutation recordPasteEvent($input: RecordPasteEventInput!) {
    recordPasteEvent(input: $input) {
      success
      errors {
        code
        message
      }
      data {
        recorded
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

/** 更新通知偏好 */
export const UPDATE_NOTIFICATION_PREFERENCE_MUTATION = gql`
  mutation updateNotificationPreference(
    $input: UpdateNotificationPreferenceInput!
  ) {
    updateNotificationPreference(input: $input) {
      success
      errors {
        code
        message
      }
      data {
        type
        enabled
        updatedAt
      }
      extensions {
        degraded
        degradedReason
      }
    }
  }
`;

// ===========================================================================
// 扩展操作（4 查询 + 5 变更）
// ===========================================================================

/** 我的课表（周视图） */
export const MY_SCHEDULE_QUERY = gql`
  query mySchedule {
    mySchedule {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        dayOfWeek
        startTime
        endTime
        subject
        teacher
        classroom
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 学生成长曲线（vs 班级平均） */
export const STUDENT_GROWTH_QUERY = gql`
  query studentGrowth {
    studentGrowth {
      success
      errors {
        code
        message
        field
      }
      data {
        date
        myScore
        classAverage
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 作业分析 */
export const ASSIGNMENT_ANALYSIS_QUERY = gql`
  query assignmentAnalysis($homeworkId: ID!) {
    assignmentAnalysis(homeworkId: $homeworkId) {
      success
      errors {
        code
        message
        field
      }
      data {
        homeworkId
        title
        totalScore
        avgScore
        maxScore
        minScore
        submitCount
        questions {
          questionId
          questionText
          questionType
          correctRate
          referenceAnswer
          knowledgePoints
        }
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 学生个人资料 */
export const MY_PROFILE_QUERY = gql`
  query myProfile {
    myProfile {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        name
        studentNo
        email
        phone
        gender
        avatar
        grade
        classId
        className
        bio
        preferredSubjectId
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 更新个人资料 */
export const UPDATE_PROFILE_MUTATION = gql`
  mutation updateProfile($input: UpdateProfileInput!) {
    updateProfile(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        name
        email
        phone
        gender
        bio
        preferredSubjectId
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 修改密码 */
export const CHANGE_PASSWORD_MUTATION = gql`
  mutation changePassword($input: ChangePasswordInput!) {
    changePassword(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        ok
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 作业延期申请 */
export const REQUEST_EXTENSION_MUTATION = gql`
  mutation requestExtension($input: RequestExtensionInput!) {
    requestExtension(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        homeworkId
        approved
        newDueDate
        reason
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 加入班级 */
export const JOIN_CLASS_MUTATION = gql`
  mutation joinClass($input: JoinClassInput!) {
    joinClass(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        classId
        className
        grade
        inviteCode
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 退出班级 */
export const LEAVE_CLASS_MUTATION = gql`
  mutation leaveClass($input: LeaveClassInput!) {
    leaveClass(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        classId
        ok
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

// ===========================================================================
// 批次 A 扩展操作（9 查询 + 8 变更）
// ===========================================================================

/** 我的错题本 */
export const MY_ERROR_BOOK_QUERY = gql`
  query myErrorBook {
    myErrorBook {
      success
      errors {
        code
        message
        field
      }
      data {
        items {
          id
          questionId
          questionContent
          sourceType
          subject {
            id
            name
          }
          knowledgePointIds
          knowledgePointName
          status
          masteryLevel
          nextReviewAt
          reviewCount
          correctStreak
          note
          errorTags
          createdAt
          updatedAt
        }
        stats {
          totalCount
          newCount
          learningCount
          masteredCount
          dueReviewCount
          masteredRate
        }
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 添加错题 */
export const ADD_ERROR_BOOK_ITEM_MUTATION = gql`
  mutation addErrorBookItem($input: AddErrorBookItemInput!) {
    addErrorBookItem(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        status
        createdAt
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 更新错题（含复习自评） */
export const UPDATE_ERROR_BOOK_ITEM_MUTATION = gql`
  mutation updateErrorBookItem($input: UpdateErrorBookItemInput!) {
    updateErrorBookItem(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        status
        masteryLevel
        nextReviewAt
        reviewCount
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 删除错题 */
export const DELETE_ERROR_BOOK_ITEM_MUTATION = gql`
  mutation deleteErrorBookItem($input: DeleteErrorBookItemInput!) {
    deleteErrorBookItem(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        deleted
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 我的请假记录 */
export const MY_LEAVE_REQUESTS_QUERY = gql`
  query myLeaveRequests {
    myLeaveRequests {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        leaveType
        startDate
        endDate
        reason
        status
        reviewComment
        reviewedAt
        reviewerName
        className
        attendanceSynced
        createdAt
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 创建请假申请 */
export const CREATE_LEAVE_REQUEST_MUTATION = gql`
  mutation createLeaveRequest($input: CreateLeaveRequestInput!) {
    createLeaveRequest(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        status
        createdAt
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 撤销请假申请 */
export const CANCEL_LEAVE_REQUEST_MUTATION = gql`
  mutation cancelLeaveRequest($input: CancelLeaveRequestInput!) {
    cancelLeaveRequest(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        status
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 我的选课记录 */
export const MY_ELECTIVE_SELECTIONS_QUERY = gql`
  query myElectiveSelections {
    myElectiveSelections {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        courseId
        courseName
        status
        selectedAt
        enrolledAt
        droppedAt
        dropReason
        course {
          id
          name
          teacherName
          subjectName
          capacity
          enrolledCount
          classroom
          schedule
          credit
          status
        }
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 可选课程列表 */
export const AVAILABLE_ELECTIVE_COURSES_QUERY = gql`
  query availableElectiveCourses {
    availableElectiveCourses {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        name
        teacherName
        subjectName
        gradeName
        description
        capacity
        enrolledCount
        classroom
        schedule
        startDate
        endDate
        selectionStartAt
        selectionEndAt
        dropDeadline
        status
        selectionMode
        credit
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 选课 */
export const SELECT_ELECTIVE_COURSE_MUTATION = gql`
  mutation selectElectiveCourse($input: SelectElectiveCourseInput!) {
    selectElectiveCourse(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        courseId
        status
        selectedAt
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 退选 */
export const DROP_ELECTIVE_COURSE_MUTATION = gql`
  mutation dropElectiveCourse($input: DropElectiveCourseInput!) {
    dropElectiveCourse(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        courseId
        status
        droppedAt
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 我的练习会话列表 */
export const MY_PRACTICE_SESSIONS_QUERY = gql`
  query myPracticeSessions {
    myPracticeSessions {
      success
      errors {
        code
        message
        field
      }
      data {
        sessions {
          id
          practiceType
          status
          totalQuestions
          answeredQuestions
          correctCount
          accuracy
          startedAt
          completedAt
        }
        stats {
          totalSessions
          completedSessions
          totalQuestionsAnswered
          totalCorrect
          overallAccuracy
        }
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 启动练习会话 */
export const START_PRACTICE_SESSION_QUERY = gql`
  query startPracticeSession($input: StartPracticeSessionInput!) {
    startPracticeSession(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        session {
          id
          practiceType
          status
          totalQuestions
          answeredQuestions
          correctCount
          accuracy
          startedAt
          currentQuestionIndex
          questions {
            id
            questionId
            content
            type
            options {
              id
              text
            }
            maxScore
            status
          }
        }
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 提交练习答题 */
export const SUBMIT_PRACTICE_ANSWER_MUTATION = gql`
  mutation submitPracticeAnswer($input: SubmitPracticeAnswerInput!) {
    submitPracticeAnswer(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        answerId
        isCorrect
        score
        maxScore
        correctAnswer
        sessionCompleted
        session {
          id
          answeredQuestions
          correctCount
          accuracy
          status
        }
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 公告列表 */
export const ANNOUNCEMENTS_QUERY = gql`
  query announcements {
    announcements {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        title
        content
        type
        status
        authorName
        publishedAt
        isPinned
        isReadByCurrentUser
        createdAt
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 公告详情 */
export const ANNOUNCEMENT_DETAIL_QUERY = gql`
  query announcementDetail($announcementId: ID!) {
    announcementDetail(announcementId: $announcementId) {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        title
        content
        type
        status
        authorName
        publishedAt
        isPinned
        isReadByCurrentUser
        createdAt
        updatedAt
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 标记公告已读 */
export const MARK_ANNOUNCEMENT_READ_MUTATION = gql`
  mutation markAnnouncementRead($input: MarkAnnouncementReadInput!) {
    markAnnouncementRead(input: $input) {
      success
      errors {
        code
        message
        field
      }
      data {
        announcementId
        read
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 我的课案列表（仅已发布） */
export const MY_LESSON_PLANS_QUERY = gql`
  query myLessonPlans {
    myLessonPlans {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        title
        subjectName
        gradeName
        chapterTitle
        creatorName
        status
        publishedAt
        updatedAt
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 课案详情 */
export const LESSON_PLAN_DETAIL_QUERY = gql`
  query lessonPlanDetail($planId: ID!) {
    lessonPlanDetail(planId: $planId) {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        title
        subjectName
        gradeName
        chapterTitle
        creatorName
        status
        content {
          objectives
          keyPoints
          summary
          homework
          blackboard
        }
        publishedAt
        updatedAt
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 我的课程计划列表 */
export const MY_COURSE_PLANS_QUERY = gql`
  query myCoursePlans {
    myCoursePlans {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        className
        subjectName
        teacherName
        semester
        totalHours
        completedHours
        weeklyHours
        startDate
        endDate
        syllabus
        objectives
        status
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 课程计划详情 */
export const COURSE_PLAN_DETAIL_QUERY = gql`
  query coursePlanDetail($planId: ID!) {
    coursePlanDetail(planId: $planId) {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        className
        subjectName
        teacherName
        semester
        totalHours
        completedHours
        weeklyHours
        startDate
        endDate
        syllabus
        objectives
        status
        items {
          id
          week
          topic
          content
          hours
          textbookChapter
          notes
          isCompleted
          completedAt
        }
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 成绩报告卡 */
export const MY_REPORT_CARD_QUERY = gql`
  query myReportCard($academicYearId: ID, $semester: String) {
    myReportCard(academicYearId: $academicYearId, semester: $semester) {
      success
      errors {
        code
        message
        field
      }
      data {
        studentId
        studentName
        classId
        className
        classTeacherName
        academicYearName
        semester
        subjects {
          subjectId
          subjectName
          averageScore
          rankInSubject
          totalStudentsInSubject
          fullScoreTotal
          records {
            id
            examName
            score
            maxScore
            grade
            rank
            submittedAt
          }
        }
        overallAverage
        overallRank
        classTotalStudents
        overallPassRate
        overallExcellentRate
        generatedAt
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 我的诊断报告列表 */
export const MY_DIAGNOSTIC_REPORTS_QUERY = gql`
  query myDiagnosticReports {
    myDiagnosticReports {
      success
      errors {
        code
        message
        field
      }
      data {
        id
        reportType
        period
        summary
        strengths
        weaknesses
        recommendations
        overallScore
        status
        createdAt
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;

/** 我的掌握度摘要 */
export const MY_MASTERY_SUMMARY_QUERY = gql`
  query myMasterySummary {
    myMasterySummary {
      success
      errors {
        code
        message
        field
      }
      data {
        studentId
        studentName
        averageMastery
        totalKnowledgePoints
        confidenceLevel
        mastery {
          knowledgePointId
          knowledgePointName
          masteryLevel
          totalQuestions
          correctQuestions
          lastAssessedAt
        }
      }
      extensions {
        degraded
        degradedReason
        traceId
      }
    }
  }
`;
