Skip to content

Commit 610d6e0

Browse files
committed
Deadlines explanation graph is not shown (nor the button) in trivial case when max points is zero all the time.
1 parent 569feae commit 610d6e0

File tree

3 files changed

+60
-42
lines changed

3 files changed

+60
-42
lines changed

src/components/Assignments/Assignment/AssignmentDetails/AssignmentDetails.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,15 @@ const AssignmentDetails = ({
128128
defaultMessage="Solutions submitted before the first deadline are considered to be on time and graded with full points. Submissions made between the deadlines are considered to be late but still worth some points. Submissions made after the second deadline are evaluated, but awarded no points. Open the graph to see in detail how the deadlines affect the awarded points."
129129
/>
130130
</Explanation>
131-
<br />
132-
<Button variant="primary" onClick={() => setOpen(true)} size="xs" noShadow>
133-
<PointsGraphIcon gapRight />
134-
<FormattedMessage id="app.assignment.deadlinesGraphButton" defaultMessage="Show Graph" />
135-
</Button>
131+
{(maxPointsBeforeFirstDeadline !== 0 || maxPointsBeforeSecondDeadline !== 0) && (
132+
<>
133+
<br />
134+
<Button variant="primary" onClick={() => setOpen(true)} size="xs" noShadow>
135+
<PointsGraphIcon gapRight />
136+
<FormattedMessage id="app.assignment.deadlinesGraphButton" defaultMessage="Show Graph" />
137+
</Button>
138+
</>
139+
)}
136140
</>
137141
) : (
138142
<>
@@ -303,7 +307,7 @@ const AssignmentDetails = ({
303307
</tbody>
304308
</Table>
305309

306-
{allowSecondDeadline && (
310+
{(maxPointsBeforeFirstDeadline !== 0 || (allowSecondDeadline && maxPointsBeforeSecondDeadline !== 0)) && (
307311
<Modal show={open} backdrop="static" onHide={() => setOpen(false)} size="xl">
308312
<Modal.Header closeButton>
309313
<Modal.Title>

src/components/Solutions/SolutionStatus/SolutionStatus.js

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -458,38 +458,42 @@ class SolutionStatus extends Component {
458458
</p>
459459
)}
460460

461-
<hr />
461+
{(maxPointsBeforeFirstDeadline !== 0 || (allowSecondDeadline && maxPointsBeforeSecondDeadline !== 0)) && (
462+
<>
463+
<hr />
462464

463-
<div className="text-muted mb-1">
464-
<FormattedMessage
465-
id="app.assignment.deadlinesGraphDialog.title"
466-
defaultMessage="Visualization of points limits and corresponding deadlines"
467-
/>
468-
{(overriddenPoints !== null || evaluation.score * 100 < pointsPercentualThreshold) && (
469-
<>
470-
{' '}
465+
<div className="text-muted mb-1">
471466
<FormattedMessage
472-
id="app.solution.pointsExplainDialog.deadlinesGraphNotUsedSuffix"
473-
defaultMessage="(but it was not used in the scoring process of this solution)"
467+
id="app.assignment.deadlinesGraphDialog.title"
468+
defaultMessage="Visualization of points limits and corresponding deadlines"
474469
/>
475-
</>
476-
)}
477-
:
478-
</div>
479-
480-
<div className={allowSecondDeadline ? 'mt-1' : 'two-third-width my-5 mx-auto'}>
481-
<AssignmentDeadlinesGraph
482-
firstDeadline={firstDeadline}
483-
secondDeadline={secondDeadline}
484-
maxPointsBeforeFirstDeadline={maxPointsBeforeFirstDeadline}
485-
maxPointsBeforeSecondDeadline={maxPointsBeforeSecondDeadline}
486-
allowSecondDeadline={allowSecondDeadline}
487-
maxPointsDeadlineInterpolation={maxPointsDeadlineInterpolation}
488-
markerTime={submittedAt}
489-
markerPoints={maxPoints}
490-
viewportAspectRatio={2 / 5}
491-
/>
492-
</div>
470+
{(overriddenPoints !== null || evaluation.score * 100 < pointsPercentualThreshold) && (
471+
<>
472+
{' '}
473+
<FormattedMessage
474+
id="app.solution.pointsExplainDialog.deadlinesGraphNotUsedSuffix"
475+
defaultMessage="(but it was not used in the scoring process of this solution)"
476+
/>
477+
</>
478+
)}
479+
:
480+
</div>
481+
482+
<div className={allowSecondDeadline ? 'mt-1' : 'two-third-width my-5 mx-auto'}>
483+
<AssignmentDeadlinesGraph
484+
firstDeadline={firstDeadline}
485+
secondDeadline={secondDeadline}
486+
maxPointsBeforeFirstDeadline={maxPointsBeforeFirstDeadline}
487+
maxPointsBeforeSecondDeadline={maxPointsBeforeSecondDeadline}
488+
allowSecondDeadline={allowSecondDeadline}
489+
maxPointsDeadlineInterpolation={maxPointsDeadlineInterpolation}
490+
markerTime={submittedAt}
491+
markerPoints={maxPoints}
492+
viewportAspectRatio={2 / 5}
493+
/>
494+
</div>
495+
</>
496+
)}
493497
</Modal.Body>
494498
</Modal>
495499
)}

src/components/forms/EditAssignmentForm/DeadlinesGraphDialog.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,27 @@ import { PointsGraphIcon } from '../../icons';
88
import Button from '../../widgets/TheButton';
99
import { deadlinesAndPontsAreValid } from './deadlineHelpers';
1010

11-
const DeadlinesGraphDialog = ({ deadlines, ...props }) => {
11+
const DeadlinesGraphDialog = ({ deadlines, maxPointsBeforeFirstDeadline, maxPointsBeforeSecondDeadline, ...props }) => {
1212
const [open, setOpen] = useState(false);
13-
const valid = deadlinesAndPontsAreValid({ deadlines, ...props });
13+
const valid = deadlinesAndPontsAreValid({
14+
deadlines,
15+
maxPointsBeforeFirstDeadline,
16+
maxPointsBeforeSecondDeadline,
17+
...props,
18+
});
19+
const trivial = maxPointsBeforeFirstDeadline === 0 && (deadlines === 'single' || maxPointsBeforeSecondDeadline === 0);
1420

1521
return (
1622
<>
17-
<Button variant="primary" onClick={() => setOpen(true)} disabled={!valid} size="sm" className="mt-2">
18-
<PointsGraphIcon gapRight />
19-
<FormattedMessage id="app.editAssignmentForm.deadlinesGraphDialog.button" defaultMessage="Deadlines Graph" />
20-
</Button>
23+
{!trivial && (
24+
<Button variant="primary" onClick={() => setOpen(true)} disabled={!valid} size="sm" className="mt-2">
25+
<PointsGraphIcon gapRight />
26+
<FormattedMessage id="app.editAssignmentForm.deadlinesGraphDialog.button" defaultMessage="Deadlines Graph" />
27+
</Button>
28+
)}
2129

2230
<Modal
23-
show={open && valid}
31+
show={open && valid && !trivial}
2432
backdrop="static"
2533
onHide={() => setOpen(false)}
2634
size={deadlines === 'single' ? 'lg' : 'xl'}>
@@ -39,6 +47,8 @@ const DeadlinesGraphDialog = ({ deadlines, ...props }) => {
3947
allowSecondDeadline={deadlines !== 'single'}
4048
maxPointsDeadlineInterpolation={deadlines === 'interpolated'}
4149
viewportAspectRatio={deadlines === 'single' ? 1 / 3 : 1 / 2}
50+
maxPointsBeforeFirstDeadline={maxPointsBeforeFirstDeadline}
51+
maxPointsBeforeSecondDeadline={maxPointsBeforeSecondDeadline}
4252
{...props}
4353
/>
4454
)}

0 commit comments

Comments
 (0)