import { CanvasClient } from '../CanvasClient';
import {
    DummyGradeResponse,
    DummyGradeCreateBody,
    DummyGradeUpdateParams,
    DummyGradeDeleteParams
} from '@/apps/canvas-api/types/DummyGradeTypes';

export class DummyGradesService {
    private canvas: CanvasClient;

    constructor(canvasClient: CanvasClient) {
        this.canvas = canvasClient;
    }

    async getAllDummyGrades(): Promise<DummyGradeResponse> {
        // Return mock data
        return {
            success: true,
            message: 'Dummy grades retrieved successfully',
            data: {
                grades: [
                    {
                        id: 1,
                        student_id: 101,
                        course_id: 1,
                        assignment_id: 1,
                        score: 85,
                        grade: 'B',
                        submitted_at: '2024-03-15T10:00:00Z',
                        graded_at: '2024-03-16T14:30:00Z'
                    },
                    {
                        id: 2,
                        student_id: 102,
                        course_id: 1,
                        assignment_id: 1,
                        score: 92,
                        grade: 'A',
                        submitted_at: '2024-03-15T11:00:00Z',
                        graded_at: '2024-03-16T15:00:00Z'
                    }
                ]
            }
        };
    }

    async addDummyGrade(payload: DummyGradeCreateBody): Promise<DummyGradeResponse> {
        // Return mock success response
        return {
            success: true,
            message: 'Dummy grade added successfully',
            data: {
                id: 3,
                student_id: payload.student_id,
                course_id: payload.course_id,
                assignment_id: payload.assignment_id,
                score: payload.score,
                grade: this.calculateGrade(payload.score),
                submitted_at: new Date().toISOString(),
                graded_at: new Date().toISOString()
            }
        };
    }

    async updateDummyGrade(payload: DummyGradeUpdateParams): Promise<DummyGradeResponse> {
        // Return mock success response
        return {
            success: true,
            message: 'Dummy grade updated successfully',
            data: {
                id: payload.id,
                student_id: payload.student_id,
                course_id: payload.course_id,
                assignment_id: payload.assignment_id,
                score: payload.score,
                grade: this.calculateGrade(payload.score),
                submitted_at: payload.submitted_at || new Date().toISOString(),
                graded_at: new Date().toISOString()
            }
        };
    }

    async deleteDummyGrade(payload: DummyGradeDeleteParams): Promise<void> {
        // Return mock success response
        return;
    }

    private calculateGrade(score: number): string {
        if (score >= 90) return 'A';
        if (score >= 80) return 'B';
        if (score >= 70) return 'C';
        if (score >= 60) return 'D';
        return 'F';
    }
} 