source-academy / frontend

Frontend of Source Academy, an online experiential environment for computational thinking (React, Redux, Saga, Blueprint)
https://sourceacademy.org
Apache License 2.0
103 stars 167 forks source link

Improvement for Submission Status logic #3033

Open GabrielCWT opened 2 months ago

GabrielCWT commented 2 months ago
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.

GabrielCWT commented 2 months ago

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.