diff --git a/lms/static/scripts/frontend_apps/api-types.ts b/lms/static/scripts/frontend_apps/api-types.ts index d1e5c2143b..ab8d82b1d6 100644 --- a/lms/static/scripts/frontend_apps/api-types.ts +++ b/lms/static/scripts/frontend_apps/api-types.ts @@ -177,9 +177,6 @@ export type CoursesMetricsResponse = { courses: CourseWithMetrics[]; }; -/** - * Response for `/api/dashboard/assignments/{assignment_id}` call. - */ export type Assignment = { id: number; title: string; @@ -204,10 +201,44 @@ export type StudentsMetricsResponse = { students: StudentWithMetrics[]; }; -export type AssignmentWithCourse = Assignment & { +type AssignmentWithCourse = Assignment & { course: Course; }; +/** + * - all_or_nothing: students need to meet a minimum value, making them get + * either 0% or 100% + * - scaled: students may get a proportional grade based on the amount of + * annotations. If requirement is 4, and they created 3, they'll + * get a 75% + */ +export type GradingType = 'all_or_nothing' | 'scaled'; + +/** + * - cumulative: both annotations and replies will be counted together for + * the grade calculation + * - separate: students will have different annotation and reply goals. + */ +export type ActivityCalculation = 'cumulative' | 'separate'; + +export type AutoGradingConfig = { + grading_type: GradingType; + activity_calculation: ActivityCalculation; + required_annotations: number; + required_replies?: number; +}; + +/** + * Response for `/api/dashboard/assignments/{assignment_id}` call. + */ +export type AssignmentDetails = AssignmentWithCourse & { + /** + * If defined, it indicates this assignment was configured with auto grading + * enabled. + */ + auto_grading_config?: AutoGradingConfig; +}; + export type AssignmentWithMetrics = AssignmentWithCourse & { annotation_metrics: AnnotationMetrics; }; diff --git a/lms/static/scripts/frontend_apps/components/AutoGradingConfigurator.tsx b/lms/static/scripts/frontend_apps/components/AutoGradingConfigurator.tsx index 5cff5c51d1..ca737629a8 100644 --- a/lms/static/scripts/frontend_apps/components/AutoGradingConfigurator.tsx +++ b/lms/static/scripts/frontend_apps/components/AutoGradingConfigurator.tsx @@ -7,27 +7,13 @@ import { import type { ComponentChildren } from 'preact'; import { useCallback, useId } from 'preact/hooks'; -export type GradingType = 'all_or_nothing' | 'scaled'; +import type { ActivityCalculation, GradingType } from '../api-types'; export type AutoGradingConfig = { /** Whether auto grading is enabled for the assignment or not */ enabled?: boolean; - - /** - * - all_or_nothing: students need to meet a minimum value, making them get - * either 0% or 100% - * - scaled: students may get a proportional grade based on the amount of - * annotations. If requirement is 4, and they created 3, they'll - * get a 75% - */ gradingType: GradingType; - - /** - * - cumulative: both annotations and replies will be counted together for - * the grade calculation - * - separate: students will have different annotation and reply goals. - */ - activityCalculation: 'cumulative' | 'separate'; + activityCalculation: ActivityCalculation; /** * Required number of annotations if activityCalculation is 'separate' or diff --git a/lms/static/scripts/frontend_apps/components/FilePickerApp.tsx b/lms/static/scripts/frontend_apps/components/FilePickerApp.tsx index ab4d0d9ed4..ab12cf01c1 100644 --- a/lms/static/scripts/frontend_apps/components/FilePickerApp.tsx +++ b/lms/static/scripts/frontend_apps/components/FilePickerApp.tsx @@ -16,6 +16,7 @@ import type { ComponentChildren } from 'preact'; import { useCallback, useEffect, useRef, useState } from 'preact/hooks'; import { Link as RouterLink } from 'wouter-preact'; +import type { AutoGradingConfig as APIAutoGradingConfig } from '../api-types'; import { useConfig } from '../config'; import type { ConfigObject } from '../config'; import { apiCall } from '../utils/api'; @@ -160,6 +161,10 @@ function PanelLabel({ ); } +type DeepLinkingAPIData = Record & { + auto_grading_config: APIAutoGradingConfig | null; +}; + /** * An application that allows the user to choose the web page or PDF for an * assignment. @@ -256,7 +261,7 @@ export default function FilePickerApp({ onSubmit }: FilePickerAppProps) { // When deepLinkingAPI is present we want to call the backend to return the form // fields we'll forward to the LMS to complete the Deep Linking request try { - const data = { + const data: DeepLinkingAPIData = { ...deepLinkingAPI.data, auto_grading_config: autoGradingEnabled && autoGradingConfig.enabled diff --git a/lms/static/scripts/frontend_apps/components/dashboard/AssignmentActivity.tsx b/lms/static/scripts/frontend_apps/components/dashboard/AssignmentActivity.tsx index 36e78ca953..141709db91 100644 --- a/lms/static/scripts/frontend_apps/components/dashboard/AssignmentActivity.tsx +++ b/lms/static/scripts/frontend_apps/components/dashboard/AssignmentActivity.tsx @@ -2,7 +2,7 @@ import { useMemo } from 'preact/hooks'; import { useLocation, useParams, useSearch } from 'wouter-preact'; import type { - AssignmentWithCourse, + AssignmentDetails, StudentsMetricsResponse, } from '../../api-types'; import { useConfig } from '../../config'; @@ -40,7 +40,7 @@ export default function AssignmentActivity() { const search = useSearch(); const [, navigate] = useLocation(); - const assignment = useAPIFetch( + const assignment = useAPIFetch( replaceURLParams(routes.assignment, { assignment_id: assignmentId }), );