All files / src/api/teacher TeacherAssignmentAPI.js

51.72% Statements 15/29
100% Branches 2/2
50% Functions 7/14
51.72% Lines 15/29

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120          4x 2x       3x 2x                 3x 2x       6x 6x 5x                                                                                                                                                   3x 2x       4x     3x       4x     3x      
import axios from "axios";
import { API_ENDPOINTS } from "@/api/endpoints";
 
export class TeacherAssignmentAPI {
    async fetchAllAssignments(classCode) {
        const response = await axios.get(API_ENDPOINTS.teacher.assignment.fetchAll(classCode));
        return response;
    }
 
    async createAssignment(newAssignment) {
        const response = await axios.post(API_ENDPOINTS.teacher.assignment.create, newAssignment);
        return response;
    }
 
    async createStaffAssignment(newAssignment) {
        const response = await axios.post(API_ENDPOINTS.teacher.assignment.staffAssignmentsCreate, newAssignment);
        return response;
    }
 
    async teacherFetchSpecificAssignment(assignmentUUID) {
        const response = await axios.get(API_ENDPOINTS.teacher.assignment.fetch(assignmentUUID));
        return response;
    }
 
    async teacherUpdateAssignment(assignmentUUID, updatedAssignment) {
        delete updatedAssignment["_id"];
        const request = await axios.put(API_ENDPOINTS.teacher.assignment.update(assignmentUUID), updatedAssignment);
        return request;
    }
 
    async updateQuestionPoints(assignmentId, questionId, points) {
        const response = await axios.put(
            API_ENDPOINTS.teacher.assignment.updateQuestionPoints(assignmentId, questionId),
            {
                points,
            }
        );
        return response;
    }
 
    async markStudentAnswer(classCode, assignmentId, studentId, questionId, points, feedback) {
        const response = await axios.post(
            API_ENDPOINTS.teacher.assignment.analytics.markStudentAnswer(
                classCode,
                assignmentId,
                studentId,
                questionId
            ),
            { points, feedback }
        );
        return response;
    }
 
    async fetchStudentSubmission(classCode, assignmentId, studentId) {
        const response = await axios.get(
            API_ENDPOINTS.teacher.assignment.analytics.studentSubmission(classCode, assignmentId, studentId)
        );
        return response;
    }
 
    async addStudentAnswerComment(classCode, assignmentId, studentId, questionId, comment) {
        const response = await axios.post(
            API_ENDPOINTS.teacher.assignment.analytics.addStudentAnswerComment(
                classCode,
                assignmentId,
                studentId,
                questionId
            ),
            { comment }
        );
        return response;
    }
 
    async updateStudentAnswerComment(classCode, assignmentId, studentId, questionId, comment) {
        const response = await axios.put(
            API_ENDPOINTS.teacher.assignment.analytics.updateStudentAnswerComment(
                classCode,
                assignmentId,
                studentId,
                questionId
            ),
            { comment }
        );
        return response;
    }
 
    async deleteStudentAnswerComment(classCode, assignmentId, studentId, questionId) {
        const response = await axios.delete(
            API_ENDPOINTS.teacher.assignment.analytics.deleteStudentAnswerComment(
                classCode,
                assignmentId,
                studentId,
                questionId
            )
        );
        return response;
    }
 
    // EI-1210 — late-submission teacher-approval methods
 
    async fetchPendingLateSubmissions(assignmentUuid) {
        const response = await axios.get(API_ENDPOINTS.teacher.assignment.latePendingFetch(assignmentUuid));
        return response;
    }
 
    async approveLateSubmission(submissionId, latePenalty) {
        const response = await axios.post(API_ENDPOINTS.teacher.assignment.approveLateSubmission(submissionId), {
            late_penalty: latePenalty,
        });
        return response;
    }
 
    async rejectLateSubmission(submissionId, reason) {
        const response = await axios.post(API_ENDPOINTS.teacher.assignment.rejectLateSubmission(submissionId), {
            reason: reason ?? null,
        });
        return response;
    }
}