diff --git a/src/components/forms/EditExerciseSimpleConfigForm/EditExerciseSimpleConfigForm.js b/src/components/forms/EditExerciseSimpleConfigForm/EditExerciseSimpleConfigForm.js
index 809f35649..e986c3fed 100644
--- a/src/components/forms/EditExerciseSimpleConfigForm/EditExerciseSimpleConfigForm.js
+++ b/src/components/forms/EditExerciseSimpleConfigForm/EditExerciseSimpleConfigForm.js
@@ -21,7 +21,8 @@ class EditExerciseSimpleConfigForm extends Component {
hasSucceeded = false,
invalid,
formValues,
- supplementaryFiles
+ supplementaryFiles,
+ exerciseTests
} = this.props;
return (
@@ -40,6 +41,7 @@ class EditExerciseSimpleConfigForm extends Component {
formValues={formValues}
supplementaryFiles={files}
prefix="config"
+ exerciseTests={exerciseTests}
/>}
@@ -92,7 +94,8 @@ EditExerciseSimpleConfigForm.propTypes = {
id: PropTypes.string.isRequired
}),
formValues: PropTypes.object,
- supplementaryFiles: ImmutablePropTypes.map
+ supplementaryFiles: ImmutablePropTypes.map,
+ exerciseTests: PropTypes.array
};
const validate = () => {
diff --git a/src/components/forms/EditExerciseSimpleConfigForm/EditExerciseSimpleConfigTest.js b/src/components/forms/EditExerciseSimpleConfigForm/EditExerciseSimpleConfigTest.js
index 11a50b620..4e5376a63 100644
--- a/src/components/forms/EditExerciseSimpleConfigForm/EditExerciseSimpleConfigTest.js
+++ b/src/components/forms/EditExerciseSimpleConfigForm/EditExerciseSimpleConfigTest.js
@@ -13,9 +13,11 @@ import {
} from '../Fields';
const EditExerciseSimpleConfigTest = ({
+ fields,
prefix,
supplementaryFiles,
formValues,
+ exerciseTests,
intl
}) => {
const supplementaryFilesOptions = [{ key: '', name: '...' }].concat(
@@ -29,145 +31,193 @@ const EditExerciseSimpleConfigTest = ({
);
return (
-
-
- Test 1
-
-
-
-
-
-
-
-
+
+
+
+
+ {exerciseTests[i].name}
+
+
+
+
+
+
+
+
+
+ }
+ rightLabel={
+
+ }
/>
- }
- rightLabel={
-
+ }
/>
- }
- />
-
+
+
+
+
+
+ }
/>
- }
- />
-
-
-
-
-
-
+
+
+
+
+
+ }
/>
- }
- />
-
-
-
-
-
-
+ }
+ />}
+
+ }
/>
- }
- />
- {formValues &&
- formValues.useStdout !== 'true' &&
-
+
+
- }
- />}
-
- }
- />
-
-
-
-
-
-
+
+ }
/>
- }
- />
-
+ }
+ />
+ :
+ }
+ />}
+
+ }
/>
- }
- />
-
-
+
+
+
+ )}
);
};
EditExerciseSimpleConfigTest.propTypes = {
+ fields: PropTypes.object.isRequired,
prefix: PropTypes.string.isRequired,
supplementaryFiles: PropTypes.array.isRequired,
+ exerciseTests: PropTypes.array,
formValues: PropTypes.object,
intl: PropTypes.shape({ locale: PropTypes.string.isRequired }).isRequired
};
diff --git a/src/components/forms/Fields/ExpandingInputFilesField.js b/src/components/forms/Fields/ExpandingInputFilesField.js
index cfa5e553b..f06e2ceff 100644
--- a/src/components/forms/Fields/ExpandingInputFilesField.js
+++ b/src/components/forms/Fields/ExpandingInputFilesField.js
@@ -17,10 +17,9 @@ class ExpandingInputFilesField extends Component {
componentDidMount() {
const { input: { value } } = this.props;
- const initialValue =
- Array.isArray(value) && value.first && value.second
- ? value.concat([EMPTY_VALUE])
- : [EMPTY_VALUE];
+ const initialValue = Array.isArray(value)
+ ? value.concat([EMPTY_VALUE])
+ : [EMPTY_VALUE];
this.setState({ texts: initialValue });
}
diff --git a/src/pages/EditExerciseSimpleConfig/EditExerciseSimpleConfig.js b/src/pages/EditExerciseSimpleConfig/EditExerciseSimpleConfig.js
index 0ff35e87c..4f248bec4 100644
--- a/src/pages/EditExerciseSimpleConfig/EditExerciseSimpleConfig.js
+++ b/src/pages/EditExerciseSimpleConfig/EditExerciseSimpleConfig.js
@@ -121,6 +121,91 @@ const transformAndSendTestsValues = (
]);
};
+const getSimpleConfigInitValues = (config, tests, locale) => {
+ const confTests = config[0].tests.sort((a, b) =>
+ a.name.localeCompare(b.name, locale)
+ );
+
+ let res = [];
+ for (let test of confTests) {
+ let testObj = { name: test.name };
+ const variables = test.pipelines.reduce(
+ (acc, pipeline) => acc.concat(pipeline.variables),
+ []
+ );
+
+ const inputFiles = variables.find(
+ variable => variable.name === 'input-files'
+ );
+ const actualInputs = variables.find(
+ variable => variable.name === 'actual-inputs'
+ );
+ if (inputFiles) {
+ testObj.inputFiles = inputFiles.value.map((value, i) => ({
+ first: value,
+ second:
+ actualInputs && actualInputs.value && actualInputs.value[i]
+ ? actualInputs.value[i]
+ : ''
+ }));
+ }
+
+ const expectedOutput = variables.find(
+ variable => variable.name === 'expected-output'
+ );
+ if (expectedOutput) {
+ testObj.expectedOutput = expectedOutput.value;
+ }
+
+ const runArgs = variables.find(variable => variable.name === 'run-args');
+ if (runArgs) {
+ testObj.runArgs = runArgs.value;
+ }
+
+ const actualOutput = variables.find(
+ variable => variable.name === 'actual-output'
+ );
+ if (actualOutput) {
+ testObj.useOutFile = true;
+ testObj.outputFile = actualOutput.value;
+ }
+
+ const stdinFile = variables.find(
+ variable => variable.name === 'stdin-file'
+ );
+ if (stdinFile) {
+ testObj.inputStdin = stdinFile.value;
+ }
+
+ const standardJudge = variables.find(
+ variable => variable.name === 'judge-type'
+ );
+ if (standardJudge) {
+ testObj.useCustomJudge = false;
+ testObj.judgeBinary = standardJudge.value;
+ }
+
+ const customJudge = variables.find(
+ variable => variable.name === 'custom-judge'
+ );
+ if (customJudge) {
+ testObj.customJudgeBinary = customJudge.value;
+ testObj.useCustomJudge = customJudge.value.trim() !== '';
+ }
+
+ const judgeArgs = variables.find(
+ variable => variable.name === 'judge-args'
+ );
+ if (judgeArgs) {
+ testObj.judgeArgs = judgeArgs.value;
+ }
+
+ res.push(testObj);
+ }
+
+ return { config: res };
+};
+
class EditExerciseSimpleConfig extends Component {
componentWillMount = () => this.props.loadAsync();
componentWillReceiveProps = props => {
@@ -287,10 +372,25 @@ class EditExerciseSimpleConfig extends Component {
}
unlimitedHeight
>
-
console.log(data)}
- />
+
+ {(config, tests) => {
+ const sortedTests = tests.sort((a, b) =>
+ a.name.localeCompare(b.name, locale)
+ );
+ return (
+ console.log(data)}
+ />
+ );
+ }}
+