diff --git a/src/pages/academy/grading/Grading.tsx b/src/pages/academy/grading/Grading.tsx index df289704bc..3d4fcf13c9 100644 --- a/src/pages/academy/grading/Grading.tsx +++ b/src/pages/academy/grading/Grading.tsx @@ -2,13 +2,12 @@ import '@tremor/react/dist/esm/tremor.css'; import { Icon as BpIcon, NonIdealState, Position, Spinner, SpinnerSize } from '@blueprintjs/core'; import { IconNames } from '@blueprintjs/icons'; -import { Button, Card, Col, ColGrid, Flex, Text, Title } from '@tremor/react'; +import { Button, Card, Flex, Text, Title } from '@tremor/react'; import React, { useEffect, useState } from 'react'; import { useDispatch } from 'react-redux'; import { Navigate, useParams } from 'react-router'; import { fetchGradingOverviews } from 'src/commons/application/actions/SessionActions'; import { Role } from 'src/commons/application/ApplicationTypes'; -import { GradingStatuses } from 'src/commons/assessment/AssessmentTypes'; import SimpleDropdown from 'src/commons/SimpleDropdown'; import { useSession } from 'src/commons/utils/Hooks'; import { numberRegExp } from 'src/features/academy/AcademyTypes'; @@ -17,28 +16,24 @@ import { exportGradingCSV, isSubmissionUngraded } from 'src/features/grading/Gra import ContentDisplay from '../../../commons/ContentDisplay'; import { convertParamToInt } from '../../../commons/utils/ParamParseHelper'; import GradingSubmissionsTable from './subcomponents/GradingSubmissionsTable'; -import GradingSummary from './subcomponents/GradingSummary'; import GradingWorkspace from './subcomponents/GradingWorkspace'; +const groupOptions = [ + { value: false, label: 'my groups' }, + { value: true, label: 'all groups' } +]; + +const showOptions = [ + { value: false, label: 'ungraded' }, + { value: true, label: 'all' } +]; + const Grading: React.FC = () => { - const { - courseId, - gradingOverviews, - role, - group, - assessmentOverviews: assessments = [] - } = useSession(); - const params = useParams<{ - submissionId: string; - questionId: string; - }>(); + const { courseId, gradingOverviews, role, group } = useSession(); + const params = useParams<{ submissionId: string; questionId: string }>(); const isAdmin = role === Role.Admin; const [showAllGroups, setShowAllGroups] = useState(isAdmin || group === null); - const groupOptions = [ - { value: false, label: 'my groups' }, - { value: true, label: 'all groups' } - ]; const dispatch = useDispatch(); useEffect(() => { @@ -46,10 +41,6 @@ const Grading: React.FC = () => { }, [dispatch, role, showAllGroups]); const [showAllSubmissions, setShowAllSubmissions] = useState(false); - const showOptions = [ - { value: false, label: 'ungraded' }, - { value: true, label: 'all' } - ]; // If submissionId or questionId is defined but not numeric, redirect back to the Grading overviews page if ( @@ -88,63 +79,42 @@ const Grading: React.FC = () => { gradingOverviews === undefined ? ( loadingDisplay ) : ( - - - - - - Submissions - - - - - Viewing - - submissions from - - - showAllSubmissions || isSubmissionUngraded(s) - )} - /> - - - - - - - groupName === group && gradingStatus !== GradingStatuses.excluded - )} - assessments={assessments} - /> - - - + + + + Submissions + + + + + Viewing + + submissions from + + + showAllSubmissions || isSubmissionUngraded(s))} + /> + ) } fullWidth={true} diff --git a/src/pages/academy/grading/subcomponents/GradingSummary.tsx b/src/pages/academy/grading/subcomponents/GradingSummary.tsx deleted file mode 100644 index 2e302f543b..0000000000 --- a/src/pages/academy/grading/subcomponents/GradingSummary.tsx +++ /dev/null @@ -1,111 +0,0 @@ -import { - Badge, - Block, - Bold, - Flex, - List, - ListItem, - Metric, - ProgressBar, - Text, - Title -} from '@tremor/react'; -import { AssessmentOverview } from 'src/commons/assessment/AssessmentTypes'; -import { GradingOverview } from 'src/features/grading/GradingTypes'; -import { isSubmissionUngraded } from 'src/features/grading/GradingUtils'; - -import { AssessmentTypeBadge } from './GradingBadges'; - -type GradingSummaryProps = { - submissions: GradingOverview[]; - assessments: AssessmentOverview[]; -}; - -type AssessmentSummary = { - id: number; - type: string; - title: string; -}; - -const GradingSummary: React.FC = ({ submissions, assessments }) => { - const ungraded = submissions.filter(isSubmissionUngraded); - const ungradedAssessments = [...new Set(ungraded.map(({ assessmentId }) => assessmentId))].reduce( - (acc: AssessmentSummary[], assessmentId) => { - const assessment = assessments.find(assessment => assessment.id === assessmentId); - if (!assessment) return acc; - return [ - ...acc, - { - id: assessmentId, - type: assessment.type, - title: assessment.title - } - ]; - }, - [] - ); - - const numSubmissions = submissions.length; - const numGraded = numSubmissions - ungraded.length; - const percentGraded = Math.round((numGraded / numSubmissions) * 100); - - const numUngradedByAssessment = (assessmentId: number) => { - return ungraded.filter(({ assessmentId: id }) => id === assessmentId).length; - }; - - return ( - <> - My gradings - - {numGraded} - / {numSubmissions} graded - - - - - - Graded - - {numGraded} ({percentGraded}%) - - - - Ungraded - - {numSubmissions - numGraded} ({100 - percentGraded}%) - - - - - - Ungraded assessments - - {ungradedAssessments.length === 0 ? ( - 🎉 Good job! You've graded everything! 🎉 - ) : ( - - {ungradedAssessments.map(({ id, title, type }) => ( - - - - {title} - - - - ))} - - )} - - ); -}; - -export default GradingSummary;