Skip to content

Commit

Permalink
Merge pull request #220 from ReCodEx/data-only
Browse files Browse the repository at this point in the history
Data only
  • Loading branch information
Martin Kruliš authored Apr 26, 2018
2 parents d47cfdf + a30e9c6 commit 60ff17e
Show file tree
Hide file tree
Showing 22 changed files with 1,521 additions and 828 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: node_js
node_js:
- "node"
- "lts/*"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import FontAwesomeIcon from '@fortawesome/react-fontawesome';
import prettyMs from 'pretty-ms';
import { prettyPrintBytes } from '../../helpers/stringFormatters';
import Box from '../../widgets/Box';
import { getLimitsConstraintsOfSingleGroup } from '../../../helpers/exerciseLimits';
import { getLimitsConstraintsOfSingleGroup } from '../../../helpers/exercise/limits';

const HardwareGroupMetadata = ({ hardwareGroup, isSuperAdmin = false }) => {
const constraints = getLimitsConstraintsOfSingleGroup(hardwareGroup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const messages = defineMessages({
},
description: {
id: 'app.solutionArchiveInfoBox.description',
defaultMessage: 'All submitted source files in one ZIP archive'
defaultMessage: 'All files in a ZIP archive'
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { reduxForm, Field } from 'redux-form';
import { FormattedMessage } from 'react-intl';
import { FormattedMessage, intlShape, injectIntl } from 'react-intl';
import { Alert, Row, Col } from 'react-bootstrap';

import { CheckboxField } from '../Fields';
Expand All @@ -19,11 +19,28 @@ class EditEnvironmentSimpleForm extends Component {
submitFailed,
submitSucceeded,
invalid,
runtimeEnvironments
error,
runtimeEnvironments,
intl: { locale }
} = this.props;

return (
<div>
<Row>
{runtimeEnvironments
.sort((a, b) => a.longName.localeCompare(b.longName, locale))
.map((environment, i) =>
<Col key={i} xs={12} sm={6}>
<Field
name={`${environment.id}`}
component={CheckboxField}
onOff
label={environment.longName}
/>
</Col>
)}
</Row>

{submitFailed &&
<Alert bsStyle="danger">
<FormattedMessage
Expand All @@ -32,18 +49,10 @@ class EditEnvironmentSimpleForm extends Component {
/>
</Alert>}

<Row>
{runtimeEnvironments.map((environment, i) =>
<Col key={i} xs={12} sm={6}>
<Field
name={`${environment.id}`}
component={CheckboxField}
onOff
label={environment.longName}
/>
</Col>
)}
</Row>
{error &&
<Alert bsStyle="danger">
{error}
</Alert>}

<div className="text-center">
{dirty &&
Expand Down Expand Up @@ -103,28 +112,38 @@ EditEnvironmentSimpleForm.propTypes = {
submitFailed: PropTypes.bool,
submitSucceeded: PropTypes.bool,
invalid: PropTypes.bool,
runtimeEnvironments: PropTypes.array
error: PropTypes.any,
runtimeEnvironments: PropTypes.array,
intl: intlShape.isRequired
};

const validate = formData => {
const errors = {};
const allowedEnvrionmentsCount = Object.values(formData).filter(
value => value === true || value === 'true'
).length;

if (
Object.values(formData).filter(value => value === true || value === 'true')
.length === 0
) {
if (allowedEnvrionmentsCount === 0) {
errors['_error'] = (
<FormattedMessage
id="app.editEnvironmentSimpleForm.validation.environments"
defaultMessage="Please add at least one runtime environment."
/>
);
} else if (formData['data-linux'] && allowedEnvrionmentsCount > 1) {
errors['_error'] = (
<FormattedMessage
id="app.editEnvironmentSimpleForm.validation.dataOnlyCollision"
defaultMessage="Data-Only environment cannot be combined with any other environment."
/>
);
}

return errors;
};

export default reduxForm({
form: 'editEnvironmentSimple',
enableReinitialize: true,
keepDirtyOnReinitialize: false,
validate
})(EditEnvironmentSimpleForm);
})(injectIntl(EditEnvironmentSimpleForm));
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Field, FieldArray } from 'redux-form';
import { Row, Col } from 'react-bootstrap';
import { FormattedMessage, injectIntl } from 'react-intl';

import Button from '../../widgets/FlatButton';
import Icon from '../../icons';
import {
SelectField,
ExpandingTextField,
ExpandingInputFilesField
} from '../Fields';
import Confirm from '../../forms/Confirm';

import './EditExerciseSimpleConfigForm.css';

const validateCustomJudge = value =>
!value || value.trim() === ''
? <FormattedMessage
id="app.editExerciseSimpleConfigForm.validation.customJudge"
defaultMessage="Please, select the custom judge binary for this test or use one of the standard judges instead."
/>
: undefined;

class EditExerciseSimpleConfigDataTest extends Component {
render() {
const {
supplementaryFiles,
testName,
test,
testErrors,
smartFill,
intl
} = this.props;
const supplementaryFilesOptions = supplementaryFiles
.sort((a, b) => a.name.localeCompare(b.name, intl.locale))
.filter((item, pos, arr) => arr.indexOf(item) === pos) // WTF?
.map(data => ({
key: data.name,
name: data.name
}));
return (
<div className="configRow">
<Row>
<Col sm={12}>
<h3>
{testName}
</h3>
</Col>
</Row>
<Row>
<Col sm={12} lg={4}>
<h4>
<FormattedMessage
id="app.editExerciseSimpleConfigTests.inputTitle"
defaultMessage="Input"
/>
</h4>
<FieldArray
name={`${test}.input-files`}
component={ExpandingInputFilesField}
options={supplementaryFilesOptions}
leftLabel={
<FormattedMessage
id="app.editExerciseSimpleConfigTests.inputFilesActual"
defaultMessage="Input file:"
/>
}
rightLabel={
<FormattedMessage
id="app.editExerciseSimpleConfigTests.inputFilesRename"
defaultMessage="Rename as:"
/>
}
/>
{Boolean(smartFill) &&
<div className="smart-fill-tinybar">
<Confirm
id="smartFillInput"
onConfirmed={smartFill.input}
question={
<FormattedMessage
id="app.editExerciseConfigForm.smartFillInput.yesNoQuestion"
defaultMessage="Do you really wish to overwrite input configuration of all subsequent tests using the first test as a template? Files will be paired to individual test configurations by a heuristics based on matching name substrings."
/>
}
>
<Button
bsStyle={'primary'}
className="btn-flat"
bsSize="xs"
disabled={Boolean(testErrors)}
>
<Icon icon="arrows-alt" gapRight />
<FormattedMessage
id="app.editExerciseConfigForm.smartFillInput"
defaultMessage="Smart Fill Inputs"
/>
</Button>
</Confirm>
</div>}
</Col>
<Col sm={12} lg={4}>
<h4>
<FormattedMessage
id="app.editExerciseSimpleConfigTests.cmdlineTitle"
defaultMessage="Command Line"
/>
</h4>
<FieldArray
name={`${test}.run-args`}
component={ExpandingTextField}
label={
<FormattedMessage
id="app.editExerciseSimpleConfigTests.executionArguments"
defaultMessage="Execution arguments:"
/>
}
/>
{Boolean(smartFill) &&
<div className="smart-fill-tinybar">
<Confirm
id="smartFillArgs"
onConfirmed={smartFill.args}
question={
<FormattedMessage
id="app.editExerciseConfigForm.smartFillArgs.yesNoQuestion"
defaultMessage="Do you really wish to overwrite command line configuration of all subsequent tests using the first test as a template?"
/>
}
>
<Button
bsStyle={'primary'}
className="btn-flat"
bsSize="xs"
disabled={Boolean(testErrors)}
>
<Icon icon="arrows-alt" gapRight />
<FormattedMessage
id="app.editExerciseConfigForm.smartFillArgs"
defaultMessage="Smart Fill Arguments"
/>
</Button>
</Confirm>
</div>}
</Col>
<Col sm={12} lg={4}>
<h4>
<FormattedMessage
id="app.editExerciseSimpleConfigTests.judgeTitle"
defaultMessage="Judge"
/>
</h4>
<Field
name={`${test}.custom-judge`}
component={SelectField}
options={supplementaryFilesOptions}
addEmptyOption={true}
validate={validateCustomJudge}
label={
<FormattedMessage
id="app.editExerciseSimpleConfigTests.customJudgeBinary"
defaultMessage="Custom judge executable:"
/>
}
/>
{Boolean(smartFill) &&
<div className="smart-fill-tinybar">
<Confirm
id="smartFillJudge"
onConfirmed={smartFill.judge}
question={
<FormattedMessage
id="app.editExerciseConfigForm.smartFillJudge.yesNoQuestion"
defaultMessage="Do you really wish to overwrite judge configuration of all subsequent tests using the first test as a template? Files will be paired to individual test configurations by a heuristics based on matching name substrings."
/>
}
>
<Button
bsStyle={'primary'}
className="btn-flat"
bsSize="xs"
disabled={Boolean(testErrors)}
>
<Icon icon="arrows-alt" gapRight />
<FormattedMessage
id="app.editExerciseConfigForm.smartFillJudge"
defaultMessage="Smart Fill Judges"
/>
</Button>
</Confirm>
</div>}
</Col>
</Row>
{Boolean(smartFill) &&
<div className="smart-fill-bar">
<Confirm
id="smartFillAll"
onConfirmed={smartFill.all}
question={
<FormattedMessage
id="app.editExerciseConfigForm.smartFillAll.yesNoQuestion"
defaultMessage="Do you really wish to overwrite configuration of all subsequent tests using the first test as a template? Files will be paired to individual test configurations by a heuristics based on matching name substrings."
/>
}
>
<Button
bsStyle={'primary'}
className="btn-flat"
disabled={Boolean(testErrors)}
>
<Icon icon="arrows-alt" gapRight />
<FormattedMessage
id="app.editExerciseConfigForm.smartFillAll"
defaultMessage="Smart Fill All"
/>
</Button>
</Confirm>
</div>}
</div>
);
}
}

EditExerciseSimpleConfigDataTest.propTypes = {
testName: PropTypes.string.isRequired,
test: PropTypes.string.isRequired,
supplementaryFiles: PropTypes.array.isRequired,
exerciseTests: PropTypes.array,
testErrors: PropTypes.object,
smartFill: PropTypes.object,
intl: PropTypes.shape({ locale: PropTypes.string.isRequired }).isRequired
};

export default injectIntl(EditExerciseSimpleConfigDataTest);
Loading

0 comments on commit 60ff17e

Please sign in to comment.