Skip to content

Commit

Permalink
Add button to sync grades
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Sep 12, 2024
1 parent 6969bce commit 6f31fea
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Button } from '@hypothesis/frontend-shared';
import classnames from 'classnames';
import { useMemo } from 'preact/hooks';
import { useLocation, useParams, useSearch } from 'wouter-preact';
Expand All @@ -18,6 +19,7 @@ import FormattedDate from './FormattedDate';
import GradeIndicator from './GradeIndicator';
import type { OrderableActivityTableColumn } from './OrderableActivityTable';
import OrderableActivityTable from './OrderableActivityTable';
import SyncGradesButton from './SyncGradesButton';

type StudentsTableRow = {
lms_id: string;
Expand All @@ -33,7 +35,7 @@ type StudentsTableRow = {
*/
export default function AssignmentActivity() {
const { dashboard } = useConfig(['dashboard']);
const { routes } = dashboard;
const { routes, user } = dashboard;
const { assignmentId, organizationPublicId } = useParams<{
assignmentId: string;
organizationPublicId?: string;
Expand Down Expand Up @@ -133,40 +135,43 @@ export default function AssignmentActivity() {
{assignment.data && title}
</h2>
</div>
{assignment.data && (
<DashboardActivityFilters
courses={{
activeItem: assignment.data.course,
// When the active course is cleared, navigate to home, but keep
// active assignment and students
onClear: () =>
navigate(
urlWithFilters(
{ studentIds, assignmentIds: [assignmentId] },
{ path: '' },
<div className="flex justify-between items-end gap-x-4">
{assignment.data && (
<DashboardActivityFilters
courses={{
activeItem: assignment.data.course,
// When the active course is cleared, navigate to home, but keep
// active assignment and students
onClear: () =>
navigate(
urlWithFilters(
{ studentIds, assignmentIds: [assignmentId] },
{ path: '' },
),
),
),
}}
assignments={{
activeItem: assignment.data,
// When active assignment is cleared, navigate to its course page,
// but keep other query params intact
onClear: () => {
const query = search.length === 0 ? '' : `?${search}`;
navigate(`${courseURL(assignment.data!.course.id)}${query}`);
},
}}
students={{
selectedIds: studentIds,
onChange: studentIds => updateFilters({ studentIds }),
}}
onClearSelection={
studentIds.length > 0
? () => updateFilters({ studentIds: [] })
: undefined
}
/>
)}
}}
assignments={{
activeItem: assignment.data,
// When active assignment is cleared, navigate to its course page,
// but keep other query params intact
onClear: () => {
const query = search.length === 0 ? '' : `?${search}`;
navigate(`${courseURL(assignment.data!.course.id)}${query}`);
},
}}
students={{
selectedIds: studentIds,
onChange: studentIds => updateFilters({ studentIds }),
}}
onClearSelection={
studentIds.length > 0
? () => updateFilters({ studentIds: [] })
: undefined
}
/>
)}
{autoGradingEnabled && !user.is_staff && <SyncGradesButton />}
</div>
<OrderableActivityTable
loading={students.isLoading}
title={assignment.isLoading ? 'Loading...' : title}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Button } from '@hypothesis/frontend-shared';

export default function SyncGradesButton() {
return (
<Button variant="primary" disabled>
Grades synced
</Button>
);
}

0 comments on commit 6f31fea

Please sign in to comment.