-
Notifications
You must be signed in to change notification settings - Fork 252
Feature: Option to retain old grading data #7256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
david-yz-liu
merged 20 commits into
MarkUsProject:master
from
pranavrao145:feat/retain-old-grading-data-option
Nov 23, 2024
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
3e1efe6
feat(retain-old-grading-data-option): core copy logic
pranavrao145 1c77974
feat(retain-old-grading-data-option): retain for mass collection
pranavrao145 a37d9ba
feat(retain-old-grading-data-option): copy automated tests
pranavrao145 3acc7ff
test(retain-old-grading-data-option): tested copy_grading_data
pranavrao145 2bf29ca
fix(retain-old-grading-data-option): some bugs
pranavrao145 9759871
test(retain-old-grading-data-option): tests for feedback files and fi…
pranavrao145 4fb0ec7
fix(retain-old-grading-data-option): fixed inconsistent override chec…
pranavrao145 92e5748
feat(retain-old-grading-data-option): only show option if collected s…
pranavrao145 b05cf38
test(retain-old-grading-data-option): collect submissions modal jest
pranavrao145 f8a40d0
test(retain-old-grading-data-option): repo_browser_manual_collection_…
pranavrao145 553b4f4
test(retain-old-grading-data-option): submissions controller and i18n…
pranavrao145 a891492
docs(retain-old-grading-data-option): changelog
pranavrao145 b0ada59
test(retain-old-grading-data-option): further test coverage
pranavrao145 12fa583
refactor(retain-old-grading-data-option): move logic to submission model
pranavrao145 2b231f2
test(retain-old-grading-data-option): rewrite tests after refactor
pranavrao145 6e0f977
chore(retain-old-grading-data-option): misc fixes for code quality
pranavrao145 aa6c643
feat(retain-old-grading-data-option): also copy remark data
pranavrao145 310af70
test(retain-old-grading-data-option): remark tests
pranavrao145 7561810
chore(retain-old-grading-data-option): minor fixes
pranavrao145 b6b69f8
chore(retain-old-grading-data-option): handle failure case
pranavrao145 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
72 changes: 72 additions & 0 deletions
72
app/assets/javascripts/Components/__tests__/collect_submissions_modal.test.jsx
This file contains hidden or 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,72 @@ | ||
| import {render, screen, fireEvent, waitFor} from "@testing-library/react"; | ||
| import CollectSubmissionsModal from "../Modals/collect_submissions_modal"; | ||
| import Modal from "react-modal"; | ||
|
|
||
| describe("CollectSubmissionsModal", () => { | ||
| let props; | ||
|
|
||
| beforeEach(() => { | ||
| props = { | ||
| isOpen: true, | ||
| isScannedExam: false, | ||
| onRequestClose: jest.fn(), | ||
| onSubmit: jest.fn(), | ||
| }; | ||
|
|
||
| // Set the app element for React Modal | ||
| Modal.setAppElement("body"); | ||
| render(<CollectSubmissionsModal {...props} />); | ||
| }); | ||
|
|
||
| it("should display the option to recollect old submissions unchecked by default", () => { | ||
| const lblRecollectExistingSubmissions = screen.getByTestId( | ||
| "lbl_recollect_existing_submissions" | ||
| ); | ||
| const chkRecollectExistingSubmissions = screen.getByTestId( | ||
| "chk_recollect_existing_submissions" | ||
| ); | ||
|
|
||
| expect(lblRecollectExistingSubmissions).toBeInTheDocument(); | ||
| expect(chkRecollectExistingSubmissions).toBeInTheDocument(); | ||
| expect(chkRecollectExistingSubmissions.checked).toBe(false); | ||
| }); | ||
|
|
||
| describe("when the option to recollect checkbox is checked", () => { | ||
| beforeEach(() => { | ||
| fireEvent.click(screen.getByTestId("chk_recollect_existing_submissions")); | ||
| }); | ||
|
|
||
| it("should display the option to retain existing grading checked by default", () => { | ||
| const lblRetainExistingGrading = screen.getByTestId("lbl_retain_existing_grading"); | ||
| const chkRetainExistingGrading = screen.getByTestId("chk_retain_existing_grading"); | ||
|
|
||
| expect(lblRetainExistingGrading).toBeInTheDocument(); | ||
| expect(chkRetainExistingGrading).toBeInTheDocument(); | ||
| expect(chkRetainExistingGrading.checked).toBe(true); | ||
| }); | ||
|
|
||
| it("should display a warning when the retain existing grading option is unchecked", () => { | ||
| const chkRetainExistingGrading = screen.getByTestId("chk_retain_existing_grading"); | ||
|
|
||
| fireEvent.click(chkRetainExistingGrading); | ||
|
|
||
| const divGradingDataWillBeLost = screen.getByTestId("div_grading_data_will_be_lost"); | ||
| const lblRetainExistingGrading = screen.queryByTestId("lbl_retain_existing_grading"); | ||
|
|
||
| expect(chkRetainExistingGrading.checked).toBe(false); | ||
| expect(divGradingDataWillBeLost).toBeInTheDocument(); | ||
| expect(lblRetainExistingGrading).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("should call onSubmit with the correct parameters when the form is submitted", async () => { | ||
| const btnCollectSubmissions = screen.getByTestId("btn_collect_submissions"); | ||
|
|
||
| fireEvent.click(btnCollectSubmissions); | ||
|
|
||
| await waitFor(() => { | ||
| expect(props.onSubmit).toHaveBeenCalledTimes(1); | ||
| expect(props.onSubmit).toHaveBeenCalledWith(true, false, true, true); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
66 changes: 66 additions & 0 deletions
66
app/assets/javascripts/Components/__tests__/repo_browser_manual_collection_form.test.jsx
This file contains hidden or 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,66 @@ | ||
| import {render, screen, fireEvent} from "@testing-library/react"; | ||
| import {ManualCollectionForm} from "../repo_browser"; | ||
|
|
||
| jest.mock("@fortawesome/react-fontawesome", () => ({ | ||
| FontAwesomeIcon: () => { | ||
| return null; | ||
| }, | ||
| })); | ||
|
|
||
| describe("RepoBrowser's ManualCollectionForm", () => { | ||
| let props, component; | ||
|
|
||
| beforeEach(() => { | ||
| props = { | ||
| course_id: 1, | ||
| assignment_id: 2, | ||
| late_penalty: false, | ||
| grouping_id: 1, | ||
| revision_identifier: "test", | ||
| collected_revision_id: "test", | ||
| }; | ||
|
|
||
| component = render(<ManualCollectionForm {...props} />); | ||
| }); | ||
|
|
||
| it("shows the option to retain existing grading when there is a collected revision present", () => { | ||
| const lblRecollectExistingSubmissions = screen.getByTestId("lbl_retain_existing_grading"); | ||
| const chkRecollectExistingSubmissions = screen.getByTestId("chk_retain_existing_grading"); | ||
|
|
||
| expect(lblRecollectExistingSubmissions).toBeVisible(); | ||
| expect(chkRecollectExistingSubmissions).toBeVisible(); | ||
| }); | ||
|
|
||
| it("does not show the option to retain existing grading when there is a not collected revision present", () => { | ||
| props.collected_revision_id = ""; | ||
| component.rerender(<ManualCollectionForm {...props} />); | ||
|
|
||
| const lblRecollectExistingSubmissions = screen.queryByTestId("lbl_retain_existing_grading"); | ||
| const chkRecollectExistingSubmissions = screen.queryByTestId("chk_retain_existing_grading"); | ||
|
|
||
| expect(lblRecollectExistingSubmissions).not.toBeVisible(); | ||
| expect(chkRecollectExistingSubmissions).not.toBeVisible(); | ||
| }); | ||
|
|
||
| it("should confirm with a full overwrite warning when retain existing grading option is checked", () => { | ||
| const confirmSpy = jest.spyOn(window, "confirm").mockImplementation(() => false); | ||
| const manualCollectionForm = component.getByTestId("form_manual_collection"); | ||
|
|
||
| fireEvent.submit(manualCollectionForm); | ||
|
|
||
| expect(confirmSpy).toHaveBeenCalledWith( | ||
| I18n.t("submissions.collect.confirm_recollect_retain_data") | ||
| ); | ||
| }); | ||
|
|
||
| it("should confirm with a full overwrite warning when retain existing grading option is not checked", () => { | ||
| const confirmSpy = jest.spyOn(window, "confirm").mockImplementation(() => false); | ||
| const chkRecollectExistingSubmissions = screen.queryByTestId("chk_retain_existing_grading"); | ||
| const manualCollectionForm = component.getByTestId("form_manual_collection"); | ||
|
|
||
| fireEvent.click(chkRecollectExistingSubmissions); | ||
| fireEvent.submit(manualCollectionForm); | ||
|
|
||
| expect(confirmSpy).toHaveBeenCalledWith(I18n.t("submissions.collect.full_overwrite_warning")); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.