Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to new submission data format #137

Merged
merged 14 commits into from
Nov 17, 2017
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const AssignmentDetails = ({
isBonus,
runtimeEnvironments,
canSubmit,
pointsPercentualThreshold
pointsPercentualThreshold,
alreadySubmitted
}) =>
<Box
title={
Expand Down Expand Up @@ -112,7 +113,7 @@ const AssignmentDetails = ({
</tr>
<tr>
<td className="text-center">
<Icon name="cloud-upload" />
<Icon name="ban" />
</td>
<td>
<FormattedMessage
Expand All @@ -124,6 +125,20 @@ const AssignmentDetails = ({
{submissionsCountLimit === null ? '-' : submissionsCountLimit}
</td>
</tr>
<tr>
<td className="text-center">
<Icon name="coffee" />
</td>
<td>
<FormattedMessage
id="app.assignment.alreadySubmitted"
defaultMessage="Already submitted:"
/>
</td>
<td>
{alreadySubmitted}
</td>
</tr>
<tr>
<td className="text-center">
<Icon name="unlock-alt" />
Expand Down Expand Up @@ -204,7 +219,8 @@ AssignmentDetails.propTypes = {
isBonus: PropTypes.bool,
runtimeEnvironments: PropTypes.array,
canSubmit: ImmutablePropTypes.map,
pointsPercentualThreshold: PropTypes.number
pointsPercentualThreshold: PropTypes.number,
alreadySubmitted: PropTypes.number.isRequired
};

export default AssignmentDetails;
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,21 @@ import { FormattedDate, FormattedTime, FormattedMessage } from 'react-intl';
import { Link } from 'react-router';
import AssignmentStatusIcon from '../Assignment/AssignmentStatusIcon';

const EvaluationFailedTableRow = ({ link, note, submittedAt }) => (
const EvaluationFailedTableRow = ({ link, note, solution: { createdAt } }) =>
<tr>
<td><AssignmentStatusIcon id={link} status="evaluation-failed" /></td>
<td>
<FormattedDate value={submittedAt * 1000} />
<AssignmentStatusIcon id={link} status="evaluation-failed" />
</td>
<td>
<FormattedDate value={createdAt * 1000} />
&nbsp;
<FormattedTime value={submittedAt * 1000} />
<FormattedTime value={createdAt * 1000} />
</td>
<td className="text-center">
<span className="text-danger">
-
</span>
<span className="text-danger">-</span>
</td>
<td className="text-center">
<span className="text-danger">
-
</span>
<span className="text-danger">-</span>
</td>
<td>
{note}
Expand All @@ -33,13 +31,14 @@ const EvaluationFailedTableRow = ({ link, note, submittedAt }) => (
/>
</Link>
</td>
</tr>
);
</tr>;

EvaluationFailedTableRow.propTypes = {
link: PropTypes.string.isRequired,
submittedAt: PropTypes.number.isRequired,
note: PropTypes.string.isRequired
note: PropTypes.string.isRequired,
solution: PropTypes.shape({
createdAt: PropTypes.number.isRequired
}).isRequired
};

export default EvaluationFailedTableRow;
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ import Points from './Points';
const FailedSubmissionTableRow = ({
link,
note,
submittedAt,
lastSubmission: { evaluation: { score, points } },
maxPoints,
evaluation: { score, points, bonusPoints },
bonusPoints,
solution: { createdAt },
accepted
}) =>
<tr>
<td>
<AssignmentStatusIcon id={link} status="failed" accepted={accepted} />
</td>
<td>
<FormattedDate value={submittedAt * 1000} />
<FormattedDate value={createdAt * 1000} />
&nbsp;
<FormattedTime value={submittedAt * 1000} />
<FormattedTime value={createdAt * 1000} />
</td>
<td className="text-center">
<span className="text-danger">
Expand Down Expand Up @@ -56,12 +57,17 @@ const FailedSubmissionTableRow = ({

FailedSubmissionTableRow.propTypes = {
link: PropTypes.string.isRequired,
submittedAt: PropTypes.number.isRequired,
note: PropTypes.string.isRequired,
maxPoints: PropTypes.number.isRequired,
evaluation: PropTypes.shape({
score: PropTypes.number.isRequired,
points: PropTypes.number.isRequired
bonusPoints: PropTypes.number.isRequired,
lastSubmission: PropTypes.shape({
evaluation: PropTypes.shape({
score: PropTypes.number.isRequired,
points: PropTypes.number.isRequired
})
}).isRequired,
solution: PropTypes.shape({
createdAt: PropTypes.number.isRequired
}).isRequired,
accepted: PropTypes.bool
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ import { FormattedDate, FormattedTime, FormattedMessage } from 'react-intl';
import { Link } from 'react-router';
import AssignmentStatusIcon from '../Assignment/AssignmentStatusIcon';

const NotEvaluatedSubmissionTableRow = ({ link, note, submittedAt }) => (
const NotEvaluatedSubmissionTableRow = ({
link,
note,
solution: { createdAt }
}) =>
<tr>
<td><AssignmentStatusIcon id={link} status="work-in-progress" /></td>
<td>
<FormattedDate value={submittedAt * 1000} />
<AssignmentStatusIcon id={link} status="work-in-progress" />
</td>
<td>
<FormattedDate value={createdAt * 1000} />
&nbsp;
<FormattedTime value={submittedAt * 1000} />
<FormattedTime value={createdAt * 1000} />
</td>
<td className="text-center">-</td>
<td className="text-center">- / -</td>
Expand All @@ -25,13 +31,14 @@ const NotEvaluatedSubmissionTableRow = ({ link, note, submittedAt }) => (
/>
</Link>
</td>
</tr>
);
</tr>;

NotEvaluatedSubmissionTableRow.propTypes = {
link: PropTypes.string.isRequired,
submittedAt: PropTypes.number.isRequired,
note: PropTypes.string.isRequired
note: PropTypes.string.isRequired,
solution: PropTypes.shape({
createdAt: PropTypes.number.isRequired
}).isRequired
};

export default NotEvaluatedSubmissionTableRow;
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const SubmissionsTable = ({
const id = data.id;
const link = SUBMISSION_DETAIL_URI_FACTORY(assignmentId, id);

switch (data.evaluationStatus) {
switch (data.lastSubmission.evaluationStatus) {
case 'done':
return (
<SuccessfulSubmissionTableRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@ import Points from './Points';
const SuccessfulSubmissionTableRow = ({
link,
note,
submittedAt,
lastSubmission: { evaluation: { score, points } },
maxPoints,
evaluation: { score, bonusPoints, points },
bonusPoints,
solution: { createdAt },
accepted
}) => (
}) =>
<tr>
<td>
<AssignmentStatusIcon id={link} status="done" accepted={accepted} />
</td>
<td>
<FormattedDate value={submittedAt * 1000} />
<FormattedDate value={createdAt * 1000} />
&nbsp;
<FormattedTime value={submittedAt * 1000} />
<FormattedTime value={createdAt * 1000} />
</td>
<td className="text-center">
<strong className="text-success">
Expand All @@ -53,17 +54,21 @@ const SuccessfulSubmissionTableRow = ({
/>
</Link>
</td>
</tr>
);
</tr>;

SuccessfulSubmissionTableRow.propTypes = {
link: PropTypes.string.isRequired,
submittedAt: PropTypes.number.isRequired,
note: PropTypes.string.isRequired,
maxPoints: PropTypes.number.isRequired,
evaluation: PropTypes.shape({
score: PropTypes.number.isRequired,
points: PropTypes.number.isRequired
bonusPoints: PropTypes.number.isRequired,
lastSubmission: PropTypes.shape({
evaluation: PropTypes.shape({
score: PropTypes.number.isRequired,
points: PropTypes.number.isRequired
})
}).isRequired,
solution: PropTypes.shape({
createdAt: PropTypes.number.isRequired
}).isRequired,
accepted: PropTypes.bool
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ const ReferenceSolutionsList = ({
.map(
({
id,
uploadedAt,
description,
permissionHints,
solution: { userId }
solution: { userId, createdAt }
}) =>
<tr key={id}>
<td className="text-center">
Expand All @@ -49,8 +48,8 @@ const ReferenceSolutionsList = ({
{description}
</td>
<td>
<FormattedDate value={new Date(uploadedAt * 1000)} /> &nbsp;{' '}
<FormattedTime value={new Date(uploadedAt * 1000)} />
<FormattedDate value={new Date(createdAt * 1000)} /> &nbsp;{' '}
<FormattedTime value={new Date(createdAt * 1000)} />
</td>
<td>
<UsersNameContainer userId={userId} />
Expand Down
13 changes: 4 additions & 9 deletions src/components/Groups/ResultsTable/ResultsTableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,12 @@ const ResultsTableRow = ({ userId, assignmentsIds, submissions }) => {
const points =
submission &&
submission !== null &&
submission.evaluation &&
submission.evaluation !== null
? submission.evaluation.points
submission.lastSubmission.evaluation &&
submission.lastSubmission.evaluation.points
? submission.lastSubmission.evaluation.points
: '-';
const bonusPoints =
submission &&
submission !== null &&
submission.evaluation &&
submission.evaluation !== null
? submission.evaluation.bonusPoints
: 0;
submission && submission !== null ? submission.bonusPoints : 0;
totalPoints += points !== '-' ? points : 0;
totalPoints += bonusPoints;
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.activeRow {
background-color: #eee;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@ import {
FormattedNumber
} from 'react-intl';
import { Table } from 'react-bootstrap';
import { Link } from 'react-router';
import classnames from 'classnames';

import withLinks from '../../../hoc/withLinks';
import AssignmentStatusIcon from '../../Assignments/Assignment/AssignmentStatusIcon';
import './EvaluationTable.css';

const EvaluationTable = ({
evaluations,
referenceSolutionId,
exerciseId,
links: { REFERENCE_SOLUTION_EVALUATION_URI_FACTORY }
}) =>
const EvaluationTable = ({ evaluations, renderButtons, selectedRowId = '' }) =>
<Table>
<thead>
<tr>
Expand Down Expand Up @@ -47,7 +40,7 @@ const EvaluationTable = ({
return b.evaluation.evaluatedAt - a.evaluation.evaluatedAt;
})
.map(e =>
<tr key={e.id}>
<tr key={e.id} className={selectedRowId === e.id ? 'activeRow' : ''}>
<td>
<AssignmentStatusIcon
id={e.id}
Expand Down Expand Up @@ -81,21 +74,7 @@ const EvaluationTable = ({
/>
</i>
</td>}
<td className="text-right">
<Link
to={REFERENCE_SOLUTION_EVALUATION_URI_FACTORY(
exerciseId,
referenceSolutionId,
e.id
)}
className="btn btn-flat btn-default btn-xs"
>
<FormattedMessage
id="app.evaluationTable.showDetails"
defaultMessage="Show details"
/>
</Link>
</td>
{renderButtons && renderButtons(e.id)}
</tr>
)}

Expand All @@ -113,9 +92,8 @@ const EvaluationTable = ({

EvaluationTable.propTypes = {
evaluations: PropTypes.array.isRequired,
referenceSolutionId: PropTypes.string.isRequired,
exerciseId: PropTypes.string.isRequired,
links: PropTypes.object
renderButtons: PropTypes.func,
selectedRowId: PropTypes.string
};

export default withLinks(EvaluationTable);
export default EvaluationTable;
Loading