Skip to content

Commit fd19262

Browse files
committed
Additional warnings added for second points limit in edit assignment form.
1 parent 3aee1fc commit fd19262

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

src/components/forms/EditAssignmentForm/EditAssignmentForm.js

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -940,25 +940,44 @@ const warn = (
940940
) => {
941941
const warnings = {};
942942

943-
if (deadlines !== 'single' && !validateDeadline({}, formatMessage, firstDeadline, 'firstDeadline', null))
943+
if (deadlines !== 'single' && !validateDeadline({}, formatMessage, firstDeadline, 'firstDeadline', null)) {
944944
warnings.secondDeadline = (
945945
<FormattedMessage
946946
id="app.editAssignmentForm.warnings.chooseFirstDeadlineBeforeSecondDeadline"
947947
defaultMessage="You must select the date of the first deadline before selecting the date of the second deadline."
948948
/>
949949
);
950+
}
950951

951-
if (
952-
deadlines !== 'single' &&
953-
Number.isInteger(maxPointsBeforeSecondDeadline) &&
954-
maxPointsBeforeFirstDeadline === maxPointsBeforeSecondDeadline
955-
) {
956-
warnings.maxPointsBeforeSecondDeadline = (
957-
<FormattedMessage
958-
id="app.editAssignmentForm.warnings.pointsAreTheSame"
959-
defaultMessage="Both points limits are the same, so there is no need for dual-deadline setup."
960-
/>
961-
);
952+
if (deadlines !== 'single' && Number.isInteger(maxPointsBeforeSecondDeadline)) {
953+
if (maxPointsBeforeFirstDeadline === maxPointsBeforeSecondDeadline) {
954+
warnings.maxPointsBeforeSecondDeadline = (
955+
<FormattedMessage
956+
id="app.editAssignmentForm.warnings.pointsAreTheSame"
957+
defaultMessage="Both points limits are the same, so there is no need for dual-deadline setup."
958+
/>
959+
);
960+
} else if (maxPointsBeforeFirstDeadline < maxPointsBeforeSecondDeadline) {
961+
warnings.maxPointsBeforeSecondDeadline = (
962+
<FormattedMessage
963+
id="app.editAssignmentForm.warnings.secondLimitIsGreaterThanFirstLimit"
964+
defaultMessage="The limit is greater than the first limit which is quite unusal."
965+
/>
966+
);
967+
} else if (maxPointsBeforeSecondDeadline === 0) {
968+
warnings.maxPointsBeforeSecondDeadline =
969+
deadlines === 'dual' ? (
970+
<FormattedMessage
971+
id="app.editAssignmentForm.warnings.secondLimitIsZero"
972+
defaultMessage="The limit is zero, so there is no need for dual-deadline setup."
973+
/>
974+
) : (
975+
<FormattedMessage
976+
id="app.editAssignmentForm.warnings.interpolationGoesToZero"
977+
defaultMessage="The limit will reach zero before the second deadline (see the graph for details)."
978+
/>
979+
);
980+
}
962981
}
963982

964983
if (canViewJudgeStdout) {

src/locales/cs.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@
278278
"app.editAssignmentForm.visibility.visibleFrom": "Bude viditelná od daného data",
279279
"app.editAssignmentForm.visibleFrom": "Datum zveřejnění:",
280280
"app.editAssignmentForm.warnings.chooseFirstDeadlineBeforeSecondDeadline": "Před nastavením druhého termínu odevzdání je nutné zvolit první termín.",
281+
"app.editAssignmentForm.warnings.interpolationGoesToZero": "Limit dosáhne nuly ještě před druhým deadline (viz graf).",
281282
"app.editAssignmentForm.warnings.pointsAreTheSame": "Oba bodové limity jsou stejné, takže není důvod používat nastavení se dvěma termíny odevzdání.",
283+
"app.editAssignmentForm.warnings.secondLimitIsGreaterThanFirstLimit": "Limit je větší než první limit, což je poněkud neobvyklé.",
284+
"app.editAssignmentForm.warnings.secondLimitIsZero": "Limit je nula, takže není důvod používat nastavení se dvěma termíny odevzdání.",
282285
"app.editAssignmentForm.warninigs.alreadyAssigned": "Úloha je v této skupině již zadaná.",
283286
"app.editAssignmentForm.warninigs.alreadyAssignedGlobal": "Úloha již byla zadána do některých vybraných skupin. Po potvrzení formuláře bude tedy v některých skupinách úloha zadána vícekrát.",
284287
"app.editAssignmentForm.warninigs.canViewJudgeLogs": "Povolení zveřejnění logů sudího studentům sebou nese určitá rizika. U jednoduchých úloh může např. dojít k tomu, že studenti využijí tento kanál, aby získali vstupní data a očekávané výstupy jednotlivých testů a vyrobili triviální řešení, které má správné odpovědi přímo v kódu. Používejte tuto volbu uváživě.",

src/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@
278278
"app.editAssignmentForm.visibility.visibleFrom": "Become visible on exact date",
279279
"app.editAssignmentForm.visibleFrom": "Publish date:",
280280
"app.editAssignmentForm.warnings.chooseFirstDeadlineBeforeSecondDeadline": "You must select the date of the first deadline before selecting the date of the second deadline.",
281+
"app.editAssignmentForm.warnings.interpolationGoesToZero": "The limit will reach zero before the second deadline (see the graph for details).",
281282
"app.editAssignmentForm.warnings.pointsAreTheSame": "Both points limits are the same, so there is no need for dual-deadline setup.",
283+
"app.editAssignmentForm.warnings.secondLimitIsGreaterThanFirstLimit": "The limit is greater than the first limit which is quite unusal.",
284+
"app.editAssignmentForm.warnings.secondLimitIsZero": "The limit is zero, so there is no need for dual-deadline setup.",
282285
"app.editAssignmentForm.warninigs.alreadyAssigned": "The exercise has been already assigned in this group.",
283286
"app.editAssignmentForm.warninigs.alreadyAssignedGlobal": "The exercise has been already assigned in some of the selected groups. It will be assigned again.",
284287
"app.editAssignmentForm.warninigs.canViewJudgeLogs": "Allowing the students to see judge logs has its security risks. In case of simple exercises, the students may use this channel to retrieve the test inputs and expected outputs and design a trivial solution which embeds the correct outputs directly into the source code. Use this option wisely.",

0 commit comments

Comments
 (0)