source-academy/frontend

Improvement for Submission Status logic

Opened this issue · 1 comments

export const backendParamsToProgressStatus = (
  isManuallyGraded: boolean,
  isGradingPublished: boolean,
  submissionStatus: AssessmentStatus,
  numGraded: number,
  numQuestions: number
): ProgressStatus => {
  if (!isManuallyGraded) {
    return ProgressStatuses.autograded;
  } else if (submissionStatus !== AssessmentStatuses.submitted) {
    return submissionStatus;
  } else if (numGraded < numQuestions) {
    return ProgressStatuses.submitted;
  } else if (!isGradingPublished) {
    return ProgressStatuses.graded;
  } else {
    return ProgressStatuses.published;
  }
};

With the current implementation of getting the submission status, there is no way to manually unsubmit/unpublish something if there is a bug with the backend. For example: If the backend somehow publishes a submission when isManuallyGraded is true, the progress will be ProgressStatuses.submitted because there was no manual grading done, therefore numGraded < numQuestions.

When the status is submitted, the frontend hides the buttons for unpublishing and therefore we cannot unsubmit since we must unpublish before unsubmitting.

I propose we check for isGradingPublished as the 2nd priority behind autograded.

One issue with this solution is we will not be able to know if a bug has occured i.e. Autopublished but grading not done since it will just show as published.

I am open to suggestions regarding this.