-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display badge indicating when a student dropped an assignment (#6898)
- Loading branch information
Showing
7 changed files
with
130 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
lms/static/scripts/frontend_apps/components/dashboard/StudentStatusBadge.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import classnames from 'classnames'; | ||
|
||
/** | ||
* Grade syncing: | ||
* - `new`: A new grade exists that has not been synced. | ||
* - `error`: Last attempt on syncing a grade failed. | ||
* - `syncing`: Syncing grades is in progress for a particular student. | ||
* Assignment participation: | ||
* - `drop`: The student dropped the assignment. | ||
*/ | ||
export type StudentStatusType = 'new' | 'error' | 'syncing' | 'drop'; | ||
|
||
/** | ||
* Badge displaying different student-related statuses around assignment | ||
* participation or grade syncing | ||
*/ | ||
export default function StudentStatusBadge({ | ||
type, | ||
}: { | ||
type: StudentStatusType; | ||
}) { | ||
return ( | ||
<div | ||
className={classnames( | ||
'px-1 py-0.5 rounded cursor-auto font-bold uppercase text-[0.65rem]', | ||
{ | ||
'bg-grey-7 text-white': type === 'new' || type === 'drop', | ||
'bg-grade-error-light text-grade-error': type === 'error', | ||
'bg-grey-2 text-grey-7': type === 'syncing', | ||
}, | ||
)} | ||
> | ||
{type === 'new' && 'New'} | ||
{type === 'error' && 'Error'} | ||
{type === 'syncing' && 'Syncing'} | ||
{type === 'drop' && 'Drop'} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
lms/static/scripts/frontend_apps/components/dashboard/test/StudentStatusBadge-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { mount } from 'enzyme'; | ||
|
||
import StudentStatusBadge from '../StudentStatusBadge'; | ||
|
||
describe('StudentStatusBadge', () => { | ||
[ | ||
{ type: 'new', expectedText: 'New' }, | ||
{ type: 'error', expectedText: 'Error' }, | ||
{ type: 'syncing', expectedText: 'Syncing' }, | ||
{ type: 'drop', expectedText: 'Drop' }, | ||
].forEach(({ type, expectedText }) => { | ||
it('shows right text based on type', () => { | ||
const badge = mount(<StudentStatusBadge type={type} />); | ||
assert.equal(badge.text(), expectedText); | ||
}); | ||
}); | ||
}); |