Skip to content

Commit

Permalink
Deadlines explanation graph is not shown (nor the button) in trivial …
Browse files Browse the repository at this point in the history
…case when max points is zero all the time.
  • Loading branch information
krulis-martin committed Oct 10, 2021
1 parent 569feae commit 610d6e0
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,15 @@ const AssignmentDetails = ({
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."
/>
</Explanation>
<br />
<Button variant="primary" onClick={() => setOpen(true)} size="xs" noShadow>
<PointsGraphIcon gapRight />
<FormattedMessage id="app.assignment.deadlinesGraphButton" defaultMessage="Show Graph" />
</Button>
{(maxPointsBeforeFirstDeadline !== 0 || maxPointsBeforeSecondDeadline !== 0) && (
<>
<br />
<Button variant="primary" onClick={() => setOpen(true)} size="xs" noShadow>
<PointsGraphIcon gapRight />
<FormattedMessage id="app.assignment.deadlinesGraphButton" defaultMessage="Show Graph" />
</Button>
</>
)}
</>
) : (
<>
Expand Down Expand Up @@ -303,7 +307,7 @@ const AssignmentDetails = ({
</tbody>
</Table>

{allowSecondDeadline && (
{(maxPointsBeforeFirstDeadline !== 0 || (allowSecondDeadline && maxPointsBeforeSecondDeadline !== 0)) && (
<Modal show={open} backdrop="static" onHide={() => setOpen(false)} size="xl">
<Modal.Header closeButton>
<Modal.Title>
Expand Down
62 changes: 33 additions & 29 deletions src/components/Solutions/SolutionStatus/SolutionStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,38 +458,42 @@ class SolutionStatus extends Component {
</p>
)}

<hr />
{(maxPointsBeforeFirstDeadline !== 0 || (allowSecondDeadline && maxPointsBeforeSecondDeadline !== 0)) && (
<>
<hr />

<div className="text-muted mb-1">
<FormattedMessage
id="app.assignment.deadlinesGraphDialog.title"
defaultMessage="Visualization of points limits and corresponding deadlines"
/>
{(overriddenPoints !== null || evaluation.score * 100 < pointsPercentualThreshold) && (
<>
{' '}
<div className="text-muted mb-1">
<FormattedMessage
id="app.solution.pointsExplainDialog.deadlinesGraphNotUsedSuffix"
defaultMessage="(but it was not used in the scoring process of this solution)"
id="app.assignment.deadlinesGraphDialog.title"
defaultMessage="Visualization of points limits and corresponding deadlines"
/>
</>
)}
:
</div>

<div className={allowSecondDeadline ? 'mt-1' : 'two-third-width my-5 mx-auto'}>
<AssignmentDeadlinesGraph
firstDeadline={firstDeadline}
secondDeadline={secondDeadline}
maxPointsBeforeFirstDeadline={maxPointsBeforeFirstDeadline}
maxPointsBeforeSecondDeadline={maxPointsBeforeSecondDeadline}
allowSecondDeadline={allowSecondDeadline}
maxPointsDeadlineInterpolation={maxPointsDeadlineInterpolation}
markerTime={submittedAt}
markerPoints={maxPoints}
viewportAspectRatio={2 / 5}
/>
</div>
{(overriddenPoints !== null || evaluation.score * 100 < pointsPercentualThreshold) && (
<>
{' '}
<FormattedMessage
id="app.solution.pointsExplainDialog.deadlinesGraphNotUsedSuffix"
defaultMessage="(but it was not used in the scoring process of this solution)"
/>
</>
)}
:
</div>

<div className={allowSecondDeadline ? 'mt-1' : 'two-third-width my-5 mx-auto'}>
<AssignmentDeadlinesGraph
firstDeadline={firstDeadline}
secondDeadline={secondDeadline}
maxPointsBeforeFirstDeadline={maxPointsBeforeFirstDeadline}
maxPointsBeforeSecondDeadline={maxPointsBeforeSecondDeadline}
allowSecondDeadline={allowSecondDeadline}
maxPointsDeadlineInterpolation={maxPointsDeadlineInterpolation}
markerTime={submittedAt}
markerPoints={maxPoints}
viewportAspectRatio={2 / 5}
/>
</div>
</>
)}
</Modal.Body>
</Modal>
)}
Expand Down
24 changes: 17 additions & 7 deletions src/components/forms/EditAssignmentForm/DeadlinesGraphDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,27 @@ import { PointsGraphIcon } from '../../icons';
import Button from '../../widgets/TheButton';
import { deadlinesAndPontsAreValid } from './deadlineHelpers';

const DeadlinesGraphDialog = ({ deadlines, ...props }) => {
const DeadlinesGraphDialog = ({ deadlines, maxPointsBeforeFirstDeadline, maxPointsBeforeSecondDeadline, ...props }) => {
const [open, setOpen] = useState(false);
const valid = deadlinesAndPontsAreValid({ deadlines, ...props });
const valid = deadlinesAndPontsAreValid({
deadlines,
maxPointsBeforeFirstDeadline,
maxPointsBeforeSecondDeadline,
...props,
});
const trivial = maxPointsBeforeFirstDeadline === 0 && (deadlines === 'single' || maxPointsBeforeSecondDeadline === 0);

return (
<>
<Button variant="primary" onClick={() => setOpen(true)} disabled={!valid} size="sm" className="mt-2">
<PointsGraphIcon gapRight />
<FormattedMessage id="app.editAssignmentForm.deadlinesGraphDialog.button" defaultMessage="Deadlines Graph" />
</Button>
{!trivial && (
<Button variant="primary" onClick={() => setOpen(true)} disabled={!valid} size="sm" className="mt-2">
<PointsGraphIcon gapRight />
<FormattedMessage id="app.editAssignmentForm.deadlinesGraphDialog.button" defaultMessage="Deadlines Graph" />
</Button>
)}

<Modal
show={open && valid}
show={open && valid && !trivial}
backdrop="static"
onHide={() => setOpen(false)}
size={deadlines === 'single' ? 'lg' : 'xl'}>
Expand All @@ -39,6 +47,8 @@ const DeadlinesGraphDialog = ({ deadlines, ...props }) => {
allowSecondDeadline={deadlines !== 'single'}
maxPointsDeadlineInterpolation={deadlines === 'interpolated'}
viewportAspectRatio={deadlines === 'single' ? 1 / 3 : 1 / 2}
maxPointsBeforeFirstDeadline={maxPointsBeforeFirstDeadline}
maxPointsBeforeSecondDeadline={maxPointsBeforeSecondDeadline}
{...props}
/>
)}
Expand Down

0 comments on commit 610d6e0

Please sign in to comment.