From daf8559d80640574ea3d1a82cd75507d667fcd01 Mon Sep 17 00:00:00 2001 From: Martin Krulis Date: Sun, 30 Oct 2022 22:27:52 +0100 Subject: [PATCH] Reloading can-submit info right after a solution is submitted. --- .../AssignmentDetails/AssignmentDetails.js | 19 ++++++++++++++++--- src/locales/cs.json | 2 +- src/locales/en.json | 2 +- src/pages/Assignment/Assignment.js | 11 ++++++++--- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/components/Assignments/Assignment/AssignmentDetails/AssignmentDetails.js b/src/components/Assignments/Assignment/AssignmentDetails/AssignmentDetails.js index b56a230d1..162d239e9 100644 --- a/src/components/Assignments/Assignment/AssignmentDetails/AssignmentDetails.js +++ b/src/components/Assignments/Assignment/AssignmentDetails/AssignmentDetails.js @@ -267,15 +267,28 @@ const AssignmentDetails = ({ {isStudent ? ( <> - {lastAttemptIndex || canSubmit.submittedCount} + {lastAttemptIndex || canSubmit.total} + {canSubmit.total > canSubmit.evaluated && ( + + {' '} + {canSubmit.evaluated - canSubmit.total} + + + + + )} {submissionsCountLimit !== null && ` / ${submissionsCountLimit}`} - {lastAttemptIndex && lastAttemptIndex > canSubmit.submittedCount && ( + {lastAttemptIndex && lastAttemptIndex > canSubmit.total && ( ( ) diff --git a/src/locales/cs.json b/src/locales/cs.json index 6ccc78d43..b5db802c3 100644 --- a/src/locales/cs.json +++ b/src/locales/cs.json @@ -131,6 +131,7 @@ "app.assignment.solutionFilesLimitExplanation": "Omezení se uplatňují na počet odevzdaných souborů a jejich celkovou velikost.", "app.assignment.solutionFilesLimitSize": "{size} KiB {count, plural, one {} other {celkem}}", "app.assignment.submissionCountLimitIncreasedByDeletion": "+{count} {count, plural, one {pokus vytvořen} =2 {pokusy vytvořeny} =3 {pokusy vytvořeny} =4 {pokusy vytvořeny} other {pokusů vytvořeno}} smazáním řešení", + "app.assignment.submissionCounterDecreasedByNotEvaluated": "Řešení, která nebyla vyhodnocena nebo jejich vyhodnocení selhalo, se nepočítají do limitu odevzdaných řešení.", "app.assignment.submissionsCountLimit": "Počet pokusů", "app.assignment.submissionsCountLimitExplanation": "Maximální počet odevzdaných řešení této úlohy od jednoho studenta. Vyučující můž udělit další pokusy tak, že smaže starší odevzdaná řešení.", "app.assignment.syncAttachmentFiles": "Přiložené soubory", @@ -1169,7 +1170,6 @@ "app.passwordStrength.somewhatOk": "Šlo by to i lépe.", "app.passwordStrength.unknown": "...", "app.passwordStrength.worst": "Nevyhovující", - "app.pendingReviewsList.by": "od", "app.pendingReviewsList.failed": "Načítání otevřených revizí řešení selhalo. Prosíme, zkuste po chvíli občerstvit tuto komponentu.", "app.pendingReviewsList.reviewOpenedAt": "revize otevřena", "app.pendingReviewsList.submitted": "odevzdáno", diff --git a/src/locales/en.json b/src/locales/en.json index a08d50540..afa1b2782 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -131,6 +131,7 @@ "app.assignment.solutionFilesLimitExplanation": "The restrictions may limit maximal number of submitted files and their total size.", "app.assignment.solutionFilesLimitSize": "{size} KiB {count, plural, one {} other {total}}", "app.assignment.submissionCountLimitIncreasedByDeletion": "+{count} {count, plural, one {attempt} other {attempts}} added by deleted solutions", + "app.assignment.submissionCounterDecreasedByNotEvaluated": "Failed and not evaluated submissions are not counted when restricting submission attempts.", "app.assignment.submissionsCountLimit": "Submission attempts", "app.assignment.submissionsCountLimitExplanation": "Maximal number of solutions logged by one student for this assignment. The teacher may choose to grant additional attempts by deleting old solutions.", "app.assignment.syncAttachmentFiles": "Text attachment files", @@ -1169,7 +1170,6 @@ "app.passwordStrength.somewhatOk": "You can do better.", "app.passwordStrength.unknown": "...", "app.passwordStrength.worst": "Unsatisfactory", - "app.pendingReviewsList.by": "by", "app.pendingReviewsList.failed": "Loading of the open reviews failed. Please try refreshing this component later.", "app.pendingReviewsList.reviewOpenedAt": "review opened at", "app.pendingReviewsList.submitted": "submitted", diff --git a/src/pages/Assignment/Assignment.js b/src/pages/Assignment/Assignment.js index 5d94aa581..29171479e 100644 --- a/src/pages/Assignment/Assignment.js +++ b/src/pages/Assignment/Assignment.js @@ -83,8 +83,11 @@ class Assignment extends Component { } } - reloadSolvers = () => - this.props.reloadSolvers(this.props.match.params.assignmentId, this.props.userId || this.props.loggedInUserId); + reloadAfterSubmit = () => + Promise.all([ + this.props.reloadSolvers(this.props.match.params.assignmentId, this.props.userId || this.props.loggedInUserId), + this.props.reloadCanSubmit(), + ]); render() { const { @@ -190,7 +193,7 @@ class Assignment extends Component { id={assignment.id} onSubmit={submitSolution} presubmitValidation={presubmitSolution} - afterEvaluationStarts={this.reloadSolvers} + afterEvaluationStarts={this.reloadAfterSubmit} onReset={init} isOpen={submitting} solutionFilesLimit={assignment.solutionFilesLimit} @@ -277,6 +280,7 @@ Assignment.propTypes = { fetchManyStatus: PropTypes.string, assignmentSolversLoading: PropTypes.bool, assignmentSolverSelector: PropTypes.func.isRequired, + reloadCanSubmit: PropTypes.func.isRequired, reloadSolvers: PropTypes.func.isRequired, }; @@ -318,6 +322,7 @@ export default connect( init: userId => () => dispatch(init(userId, assignmentId)), loadAsync: userId => Assignment.loadAsync({ assignmentId }, dispatch, { userId }), exerciseSync: () => dispatch(syncWithExercise(assignmentId)), + reloadCanSubmit: () => dispatch(canSubmit(assignmentId)), reloadSolvers: (assignmentId, userId) => dispatch(fetchAssignmentSolvers({ assignmentId, userId })), }) )(Assignment);