Skip to content

Commit

Permalink
Reloading can-submit info right after a solution is submitted.
Browse files Browse the repository at this point in the history
  • Loading branch information
krulis-martin committed Nov 2, 2022
1 parent 0b3b777 commit daf8559
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,28 @@ const AssignmentDetails = ({
<td>
{isStudent ? (
<>
{lastAttemptIndex || canSubmit.submittedCount}
{lastAttemptIndex || canSubmit.total}
{canSubmit.total > canSubmit.evaluated && (
<span className="text-muted">
{' '}
{canSubmit.evaluated - canSubmit.total}
<Explanation id="submissionsCountDecreased">
<FormattedMessage
id="app.assignment.submissionCounterDecreasedByNotEvaluated"
defaultMessage="Failed and not evaluated submissions are not counted when restricting submission attempts."
values={{ count: lastAttemptIndex - canSubmit.total }}
/>
</Explanation>
</span>
)}
{submissionsCountLimit !== null && ` / ${submissionsCountLimit}`}
{lastAttemptIndex && lastAttemptIndex > canSubmit.submittedCount && (
{lastAttemptIndex && lastAttemptIndex > canSubmit.total && (
<small className="pl-2 text-muted">
(
<FormattedMessage
id="app.assignment.submissionCountLimitIncreasedByDeletion"
defaultMessage="+{count} {count, plural, one {attempt} other {attempts}} added by deleted solutions"
values={{ count: lastAttemptIndex - canSubmit.submittedCount }}
values={{ count: lastAttemptIndex - canSubmit.total }}
/>
)
</small>
Expand Down
2 changes: 1 addition & 1 deletion src/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
11 changes: 8 additions & 3 deletions src/pages/Assignment/Assignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -277,6 +280,7 @@ Assignment.propTypes = {
fetchManyStatus: PropTypes.string,
assignmentSolversLoading: PropTypes.bool,
assignmentSolverSelector: PropTypes.func.isRequired,
reloadCanSubmit: PropTypes.func.isRequired,
reloadSolvers: PropTypes.func.isRequired,
};

Expand Down Expand Up @@ -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);

0 comments on commit daf8559

Please sign in to comment.