Skip to content

Commit

Permalink
Show algorithm parameter fields without clicking first
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Feb 8, 2016
1 parent 318083b commit cd3c72e
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions src/js/components/experiments/ExperimentWizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class ExperimentWizard extends Wizard {
type: "enum",
label: "Task Chooser Algorithm",
help: "How should tasks be chosen?",
values: this.state.algorithms.taskChooserAlgorithms.map(algorithmMapper)
values: this.state.algorithms.taskChooserAlgorithms.map(algorithmMapper),
};

Object.assign(base, algorithmOptions("algorithmTaskChooser", "taskChooserAlgorithms"));
Expand Down Expand Up @@ -480,13 +480,32 @@ class ExperimentWizard extends Wizard {

fetchAlgorithms() {
this.props.backend.request("GET", "algorithms").then((response) => {
this.setState({
algorithms: {
taskChooserAlgorithms: response.data.taskChooserAlgorithms || [],
ratingQualityAlgorithms: response.data.ratingQualityAlgorithms || [],
answerQualityAlgorithms: response.data.answerQualityAlgorithms || []
let form = this.state.form;

let taskChooser = response.data.taskChooserAlgorithms;
let ratingQuality = response.data.ratingQualityAlgorithms;
let answerQuality = response.data.answerQualityAlgorithms;

Object.assign(form, {
"algorithmTaskChooser": {
name: taskChooser.length ? taskChooser[0].name : ""
},
"algorithmQualityRating": {
name: ratingQuality.length ? ratingQuality[0].name : ""
},
"algorithmQualityAnswer": {
name: answerQuality.length ? answerQuality[0].name : ""
}
});

this.setState({
algorithms: {
taskChooserAlgorithms: taskChooser,
ratingQualityAlgorithms: ratingQuality,
answerQualityAlgorithms: answerQuality
},
form: form
}, () => console.log(this.state));
}).catch(() => {
this.setState({
algorithmsFailed: true
Expand Down

0 comments on commit cd3c72e

Please sign in to comment.