Skip to content

Commit

Permalink
Evaluation detail props reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
SemaiCZE committed Oct 26, 2017
1 parent c9f9983 commit 9ea05a5
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Table } from 'react-bootstrap';
import Box from '../../widgets/Box';
import { MaybeSucceededIcon } from '../../icons';

const EvaluationDetail = ({ evaluation, note = '' }) => (
const EvaluationDetail = ({ evaluation, isCorrect }) =>
<Box
title={
<FormattedMessage
Expand Down Expand Up @@ -40,18 +40,6 @@ const EvaluationDetail = ({ evaluation, note = '' }) => (
</td>
</tr>

<tr>
<th>
<FormattedMessage
id="app.evaluationDetail.isValid"
defaultMessage="Evaluation is valid:"
/>
</th>
<td className="text-center">
<MaybeSucceededIcon success={evaluation.isValid} />
</td>
</tr>

<tr>
<th>
<FormattedMessage
Expand All @@ -74,8 +62,8 @@ const EvaluationDetail = ({ evaluation, note = '' }) => (
<td
className={classnames({
'text-center': true,
'text-danger': !evaluation.isCorrect,
'text-success': evaluation.isCorrect
'text-danger': !isCorrect,
'text-success': isCorrect
})}
>
<b>
Expand All @@ -85,12 +73,11 @@ const EvaluationDetail = ({ evaluation, note = '' }) => (
</tr>
</tbody>
</Table>
</Box>
);
</Box>;

EvaluationDetail.propTypes = {
evaluation: PropTypes.object.isRequired,
note: PropTypes.string
isCorrect: PropTypes.bool.isRequired
};

export default EvaluationDetail;
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ReferenceSolutionEvaluationDetail extends Component {
exerciseId={exerciseId}
/>
<Row>
{referenceSolution.solution.files.map(file => (
{referenceSolution.solution.files.map(file =>
<Col lg={6} md={12} key={file.id}>
<a
href="#"
Expand All @@ -45,19 +45,21 @@ class ReferenceSolutionEvaluationDetail extends Component {
<SourceCodeInfoBox {...file} />
</a>
</Col>
))}
)}
</Row>
{solutionEvaluation.evaluation && (
{solutionEvaluation.evaluation &&
<CompilationLogs
initiationOutputs={
solutionEvaluation.evaluation.initiationOutputs
}
/>
)}
/>}
</Col>
{solutionEvaluation.evaluation && (
{solutionEvaluation.evaluation &&
<Col lg={6} sm={12}>
<EvaluationDetail evaluation={solutionEvaluation.evaluation} />
<EvaluationDetail
evaluation={solutionEvaluation.evaluation}
isCorrect={solutionEvaluation.isCorrect}
/>

<TestResults
evaluation={solutionEvaluation.evaluation}
Expand All @@ -71,8 +73,7 @@ class ReferenceSolutionEvaluationDetail extends Component {
</a>
</Col>
</Row>
</Col>
)}
</Col>}
</Row>

<SourceCodeViewerContainer
Expand Down
68 changes: 25 additions & 43 deletions src/components/Submissions/EvaluationDetail/EvaluationDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import BonusPoints from '../../Assignments/SubmissionsTable/BonusPoints';
const EvaluationDetail = ({
assignment: { firstDeadline, allowSecondDeadline, secondDeadline },
evaluation,
note = '',
isCorrect,
submittedAt,
maxPoints
}) => (
}) =>
<Box
title={
<FormattedMessage
Expand Down Expand Up @@ -56,40 +56,25 @@ const EvaluationDetail = ({
/>
</th>
<td className="text-center">
{submittedAt < firstDeadline ? (
<Icon name="check" className="text-success" />
) : (
<Icon name="times" className="text-danger" />
)}
{submittedAt < firstDeadline
? <Icon name="check" className="text-success" />
: <Icon name="times" className="text-danger" />}
</td>
</tr>

{submittedAt >= firstDeadline &&
allowSecondDeadline === true && (
<tr>
<th>
<FormattedMessage
id="app.evaluationDetail.beforeSecondDeadline"
defaultMessage="Was submitted before the second deadline:"
/>
</th>
<td className="text-center">
<MaybeSucceededIcon success={submittedAt < secondDeadline} />
</td>
</tr>
)}

<tr>
<th>
<FormattedMessage
id="app.evaluationDetail.isValid"
defaultMessage="Evaluation is valid:"
/>
</th>
<td className="text-center">
<MaybeSucceededIcon success={evaluation.isValid} />
</td>
</tr>
allowSecondDeadline === true &&
<tr>
<th>
<FormattedMessage
id="app.evaluationDetail.beforeSecondDeadline"
defaultMessage="Was submitted before the second deadline:"
/>
</th>
<td className="text-center">
<MaybeSucceededIcon success={submittedAt < secondDeadline} />
</td>
</tr>}

<tr>
<th>
Expand All @@ -113,8 +98,8 @@ const EvaluationDetail = ({
<td
className={classnames({
'text-center': true,
'text-danger': !evaluation.isCorrect,
'text-success': evaluation.isCorrect
'text-danger': !isCorrect,
'text-success': isCorrect
})}
>
<b>
Expand Down Expand Up @@ -142,7 +127,7 @@ const EvaluationDetail = ({
{evaluation.points}/{maxPoints}
</td>
</tr>
{evaluation.bonusPoints !== 0 && (
{evaluation.bonusPoints !== 0 &&
<tr>
<th>
<FormattedMessage
Expand All @@ -153,9 +138,8 @@ const EvaluationDetail = ({
<td className="text-center">
<BonusPoints bonus={evaluation.bonusPoints} />
</td>
</tr>
)}
{evaluation.bonusPoints !== 0 && (
</tr>}
{evaluation.bonusPoints !== 0 &&
<tr>
<th>
<FormattedMessage
Expand All @@ -178,20 +162,18 @@ const EvaluationDetail = ({
{evaluation.points + evaluation.bonusPoints}/{maxPoints}
</b>
</td>
</tr>
)}
</tr>}
</tbody>
</Table>
</Box>
);
</Box>;

EvaluationDetail.propTypes = {
assignment: PropTypes.shape({
firstDeadline: PropTypes.number.isRequired,
allowSecondDeadline: PropTypes.bool.isRequired,
secondDeadline: PropTypes.number
}).isRequired,
note: PropTypes.string,
isCorrect: PropTypes.bool.isRequired,
submittedAt: PropTypes.number.isRequired,
evaluation: PropTypes.object,
maxPoints: PropTypes.number.isRequired
Expand Down
31 changes: 15 additions & 16 deletions src/components/Submissions/SubmissionDetail/SubmissionDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class SubmissionDetail extends Component {
evaluation,
accepted,
originalSubmissionId,
runtimeEnvironmentId
runtimeEnvironmentId,
isCorrect
},
assignment,
isSupervisor
Expand All @@ -54,7 +55,7 @@ class SubmissionDetail extends Component {
assignmentId={assignment.id}
/>
<Row>
{files.map(file => (
{files.map(file =>
<Col lg={6} md={12} key={file.id}>
<a
href="#"
Expand All @@ -66,46 +67,43 @@ class SubmissionDetail extends Component {
<SourceCodeInfoBox {...file} />
</a>
</Col>
))}
)}
</Row>
{evaluation && (
{evaluation &&
<CompilationLogs
initiationOutputs={evaluation.initiationOutputs}
/>
)}
/>}
<CommentThreadContainer threadId={id} />
</Col>

{evaluation && (
{evaluation &&
<Col md={6} sm={12}>
<EvaluationDetail
assignment={assignment}
evaluation={evaluation}
submittedAt={submittedAt}
maxPoints={maxPoints}
isCorrect={isCorrect}
/>

{isSupervisor && (
{isSupervisor &&
<BonusPointsContainer
submissionId={id}
evaluation={evaluation}
/>
)}
/>}

<TestResults
evaluation={evaluation}
runtimeEnvironmentId={runtimeEnvironmentId}
/>

{isSupervisor && (
{isSupervisor &&
<Row>
<Col lg={6} md={12}>
<DownloadResultArchiveContainer submissionId={id} />
</Col>
</Row>
)}
</Col>
)}
</Row>}
</Col>}
</Row>

<SourceCodeViewerContainer
Expand All @@ -130,7 +128,8 @@ SubmissionDetail.propTypes = {
maxPoints: PropTypes.number.isRequired,
files: PropTypes.array,
originalSubmissionId: PropTypes.string,
runtimeEnvironmentId: PropTypes.string
runtimeEnvironmentId: PropTypes.string,
isCorrect: PropTypes.bool
}).isRequired,
assignment: PropTypes.object.isRequired,
isSupervisor: PropTypes.bool
Expand Down

0 comments on commit 9ea05a5

Please sign in to comment.