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

Trigger evaluation of newly created ref solutions #101

Merged
merged 1 commit into from
Oct 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/Submissions/SubmitSolution/SubmitSolution.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const SubmitSolution = ({
autodetection,
saveNote,
submitSolution,
useReferenceMessages,
isReferenceSolution,
messages,
intl: { formatMessage }
}) =>
Expand Down Expand Up @@ -215,15 +215,15 @@ SubmitSolution.propTypes = {
runtimeEnvironments: PropTypes.array,
autodetection: PropTypes.bool,
changeRuntimeEnvironment: PropTypes.func.isRequired,
useReferenceMessages: PropTypes.bool,
isReferenceSolution: PropTypes.bool,
messages: PropTypes.object.isRequired,
intl: intlShape.isRequired
};

export default injectIntl(
connect(
(state, { useReferenceMessages = false }) => ({
messages: useReferenceMessages
(state, { isReferenceSolution = false }) => ({
messages: isReferenceSolution
? referenceSolutionMessages
: submissionMessages
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SourceCodeViewerContainer extends Component {
loadingFooterRef.clientHeight;
this.setState({ height });
} else {
console.log('already has height', this.state.height);
// console.log('already has height', this.state.height);
}
}

Expand Down
16 changes: 11 additions & 5 deletions src/containers/SubmitSolutionContainer/SubmitSolutionContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
import { loggedInUserIdSelector } from '../../redux/selectors/auth';
import { cancel, changeNote } from '../../redux/modules/submission';
import { reset as resetUpload } from '../../redux/modules/upload';
import { evaluateReferenceSolution } from '../../redux/modules/referenceSolutions';

import withLinks from '../../hoc/withLinks';

Expand Down Expand Up @@ -65,7 +66,7 @@ class SubmitSolutionContainer extends Component {
links: { SUBMISSION_DETAIL_URI_FACTORY },
showProgress = true,
autodetection = true,
useReferenceSolutionMessages = false
isReferenceSolution = false
} = this.props;

const { runtimeEnvironment } = this.state;
Expand All @@ -89,7 +90,7 @@ class SubmitSolutionContainer extends Component {
changeRuntimeEnvironment={this.changeRuntimeEnvironment}
submitSolution={this.submit}
autodetection={autodetection}
useReferenceMessages={useReferenceSolutionMessages}
isReferenceSolution={isReferenceSolution}
/>

{showProgress &&
Expand Down Expand Up @@ -125,7 +126,7 @@ SubmitSolutionContainer.propTypes = {
runtimeEnvironments: PropTypes.array,
showProgress: PropTypes.bool,
autodetection: PropTypes.bool,
useReferenceSolutionMessages: PropTypes.bool
isReferenceSolution: PropTypes.bool
};

export default withLinks(
Expand All @@ -145,11 +146,16 @@ export default withLinks(
monitor: getMonitorParams(state)
};
},
(dispatch, { id, userId, onSubmit, onReset }) => ({
(dispatch, { id, userId, onSubmit, onReset, isReferenceSolution }) => ({
changeNote: note => dispatch(changeNote(note)),
cancel: () => dispatch(cancel()),
submitSolution: (note, files, runtimeEnvironmentId = null) =>
dispatch(onSubmit(userId, id, note, files, runtimeEnvironmentId)),
dispatch(onSubmit(userId, id, note, files, runtimeEnvironmentId)).then(
res =>
isReferenceSolution
? dispatch(evaluateReferenceSolution(res.value.id))
: Promise.resolve()
),
reset: () => dispatch(resetUpload(id)) && dispatch(onReset(userId, id))
})
)(SubmitSolutionContainer)
Expand Down
92 changes: 41 additions & 51 deletions src/pages/Exercise/Exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ class Exercise extends Component {
}
]}
>
{exercise => (
{exercise =>
<div>
<Row>
<Col sm={12}>
<div>
{isAuthorOfExercise(exercise.id) && (
{isAuthorOfExercise(exercise.id) &&
<ButtonGroup>
<LinkContainer
to={EXERCISE_EDIT_URI_FACTORY(exercise.id)}
Expand All @@ -210,8 +210,7 @@ class Exercise extends Component {
/>
</Button>
</LinkContainer>
</ButtonGroup>
)}
</ButtonGroup>}
<ForkExerciseButtonContainer
exerciseId={exercise.id}
forkId={forkId}
Expand All @@ -223,9 +222,8 @@ class Exercise extends Component {
<Row>
<Col lg={6}>
<div>
{exercise.localizedTexts.length > 0 && (
<LocalizedTexts locales={exercise.localizedTexts} />
)}
{exercise.localizedTexts.length > 0 &&
<LocalizedTexts locales={exercise.localizedTexts} />}
</div>
<Box
title={formatMessage(messages.groupsBox)}
Expand All @@ -243,17 +241,15 @@ class Exercise extends Component {
forceLoading={supervisedGroups.length === 0}
resource={supervisedGroups}
>
{() => (
{() =>
<GroupsList
groups={supervisedGroups}
renderButtons={groupId => (
renderButtons={groupId =>
<AssignExerciseButton
isLocked={exercise.isLocked}
assignExercise={() => this.assignExercise(groupId)}
/>
)}
/>
)}
/>}
/>}
</ResourceRenderer>
</Box>
<Box
Expand Down Expand Up @@ -282,10 +278,10 @@ class Exercise extends Component {
isOpen
>
<ResourceRenderer resource={exercisePipelines.toArray()}>
{(...pipelines) => (
{(...pipelines) =>
<PipelinesSimpleList
pipelines={pipelines}
createActions={pipelineId => (
createActions={pipelineId =>
<div>
<LinkContainer
to={PIPELINE_EDIT_URI_FACTORY(pipelineId)}
Expand Down Expand Up @@ -324,10 +320,8 @@ class Exercise extends Component {
/>
</Button>
</Confirm>
</div>
)}
/>
)}
</div>}
/>}
</ResourceRenderer>
</Box>
</Col>
Expand All @@ -352,36 +346,33 @@ class Exercise extends Component {
>
<ResourceRenderer resource={referenceSolutions}>
{referenceSolutions =>
referenceSolutions.length > 0 ? (
<ReferenceSolutionsList
referenceSolutions={referenceSolutions}
renderButtons={evaluationId => (
<Button
bsSize="xs"
onClick={() =>
push(
EXERCISE_REFERENCE_SOLUTION_URI_FACTORY(
exercise.id,
evaluationId
)
)}
>
<SendIcon />{' '}
<FormattedMessage
id="app.exercise.referenceSolutionDetail"
defaultMessage="View detail"
/>
</Button>
)}
/>
) : (
<p className="text-center">
<FormattedMessage
id="app.exercise.noReferenceSolutions"
defaultMessage="There are no reference solutions for this exercise yet."
referenceSolutions.length > 0
? <ReferenceSolutionsList
referenceSolutions={referenceSolutions}
renderButtons={evaluationId =>
<Button
bsSize="xs"
onClick={() =>
push(
EXERCISE_REFERENCE_SOLUTION_URI_FACTORY(
exercise.id,
evaluationId
)
)}
>
<SendIcon />{' '}
<FormattedMessage
id="app.exercise.referenceSolutionDetail"
defaultMessage="View detail"
/>
</Button>}
/>
</p>
)}
: <p className="text-center">
<FormattedMessage
id="app.exercise.noReferenceSolutions"
defaultMessage="There are no reference solutions for this exercise yet."
/>
</p>}
</ResourceRenderer>
</Box>
</Col>
Expand All @@ -395,10 +386,9 @@ class Exercise extends Component {
runtimeEnvironments={exercise.runtimeEnvironments}
showProgress={false}
autodetection={false}
useReferenceSolutionMessages={true}
isReferenceSolution={true}
/>
</div>
)}
</div>}
</Page>
);
}
Expand Down