Skip to content

[#13594] Question incorrectly displayed as saved when there are submission errors#13595

Merged
samuelfangjw merged 10 commits intoTEAMMATES:masterfrom
samuelfangjw:save-state-failure
Apr 24, 2026
Merged

[#13594] Question incorrectly displayed as saved when there are submission errors#13595
samuelfangjw merged 10 commits intoTEAMMATES:masterfrom
samuelfangjw:save-state-failure

Conversation

@samuelfangjw
Copy link
Copy Markdown
Member

@samuelfangjw samuelfangjw commented Mar 12, 2026

Fixes #13594

Outline of Solution

Root cause was that hasResponseChangedForRecipients and isSaved is unconditionally set even when there are submission failures. The initial solution was to set these only when the response has been successfully saved.

However, a lot of subtle bugs were uncovered because hasResponseChangedForRecipients, hasResponseChanged, isSaved and isSubmitAllClicked are all states related states that are managed separately and updated independently in various places. In addition, recipientId (the key of hasResponseChangedForRecipients) is not a stable key, it can be updated and modified, leading to more bugs.

To solve this, isModified was added to the question response model. This serves as the source of truth of whether a response has been modified. All other variables were either removed (if redundant) or now derive their state from isModified.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an issue in the feedback session submission UI where a question tab could be shown as “saved” even when submissions fail, by tightening the conditions under which “saved/changed” state is updated.

Changes:

  • Removes isSubmitAllClicked state plumbing and centralizes “changed” tracking on hasResponseChangedForRecipients.
  • Updates save flow to reset “changed” flags only on successful save, and renames getformattedSessionClosingTime to getFormattedSessionClosingTime.
  • Updates unit tests and snapshots to reflect the new state tracking and template bindings.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/web/app/pages-session/session-submission-page/session-submission-page.component.ts Adjusts save flow and “changed” reset logic; renames session closing-time formatter; changes recipient-save error handling.
src/web/app/pages-session/session-submission-page/session-submission-page.component.spec.ts Updates save-flow tests to reflect new hasResponseChangedForRecipients behavior and updated method signature.
src/web/app/pages-session/session-submission-page/session-submission-page.component.html Removes isSubmitAllClicked bindings and updates save handler calls to match the new signature.
src/web/app/pages-session/session-submission-page/snapshots/session-submission-page.component.spec.ts.snap Snapshot updates removing the isSubmitAllClicked input.
src/web/app/components/question-submission-form/question-submission-form.component.ts Replaces mutable hasResponseChanged with a getter; simplifies saved-state calculation; removes isSubmitAllClicked input/output.
src/web/app/components/question-submission-form/question-submission-form.component.spec.ts Updates/extends tests for the new derived hasResponseChanged and revised saved-state behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@samuelfangjw samuelfangjw force-pushed the save-state-failure branch 3 times, most recently from ec11b76 to 71eb7ab Compare April 23, 2026 06:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/web/app/pages-session/session-submission-page/session-submission-page.component.spec.ts:757

  • This test is marked async but does not await anything. If async is not needed here, please remove it to avoid implying asynchronous behavior (and to satisfy linters that flag unnecessary async functions).
  it('should snap with feedback session question submission forms', async () => {
    component.questionSubmissionForms = [
      testMcqQuestionSubmissionForm,
      testTextQuestionSubmissionForm,
      testMcqQuestionSubmissionForm2,
      testMsqQuestionSubmissionForm,
      testNumscaleQuestionSubmissionForm,
      testConstsumQuestionSubmissionForm,
      testContribQuestionSubmissionForm,
      testRubricQuestionSubmissionForm,
      testRankOptionsQuestionSubmissionForm,
      testRankRecipientsQuestionSubmissionForm,
    ];
    component.isCourseLoading = false;
    component.isFeedbackSessionLoading = false;
    component.isFeedbackSessionQuestionsLoading = false;
    fixture.detectChanges();
    expect(fixture).toMatchSnapshot();
  });

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

commentEditFormModel: {
commentText: 'comment text here',
isUsingCustomVisibilities: false,
isUsingCustomVisibilities: true,
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this test comment model, isUsingCustomVisibilities is set to true, but the production getCommentModel() explicitly sets participant comments to not use custom visibilities. The fixture should match production behavior (and/or include showCommentTo/showGiverNameTo only when custom visibilities are enabled) to avoid testing an impossible state.

Suggested change
isUsingCustomVisibilities: true,
isUsingCustomVisibilities: false,

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current bug - when isUsingCustomVisibilities is set to false, a state change is triggered which updates isModified. This will be resolved in another PR.

@samuelfangjw samuelfangjw marked this pull request as ready for review April 24, 2026 09:26
@samuelfangjw samuelfangjw merged commit aa04a40 into TEAMMATES:master Apr 24, 2026
10 checks passed
@samuelfangjw samuelfangjw deleted the save-state-failure branch April 24, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Question incorrectly displayed as saved when there are submission errors

2 participants