|
@@ -45,14 +45,16 @@ export default class extends Page {
|
|
let { libraryId } = this.state.search;
|
|
let { libraryId } = this.state.search;
|
|
libraryId = Number(libraryId || 0);
|
|
libraryId = Number(libraryId || 0);
|
|
handler = Textbook.getNextQuestion({ libraryId }).then(result => {
|
|
handler = Textbook.getNextQuestion({ libraryId }).then(result => {
|
|
- return { libraryId: libraryId || '', no: result, question: { content: { number: 1, type: 'single', typeset: 'one', questions: [], steps: [] } } };
|
|
|
|
|
|
+ return { libraryId: libraryId || '', no: result, question: { content: { number: 1, type: 'single', typeset: 'one', questions: [] } } };
|
|
});
|
|
});
|
|
}
|
|
}
|
|
handler
|
|
handler
|
|
.then(result => {
|
|
.then(result => {
|
|
const { questionNoIds } = result;
|
|
const { questionNoIds } = result;
|
|
- result.time = [result.startTime, result.endTime];
|
|
|
|
|
|
+ // result.time = [result.startTime, result.endTime];
|
|
this.uuid[0] = -1;
|
|
this.uuid[0] = -1;
|
|
|
|
+ let type = result.question.content.type || 'single';
|
|
|
|
+ if (type === 'inline') type = 'single';
|
|
result.question.content.questions.forEach((row, index) => {
|
|
result.question.content.questions.forEach((row, index) => {
|
|
const keys = [];
|
|
const keys = [];
|
|
this.uuid[index] = 0;
|
|
this.uuid[index] = 0;
|
|
@@ -60,37 +62,27 @@ export default class extends Page {
|
|
for (; this.uuid[index] < row.select.length; this.uuid[index] += 1) {
|
|
for (; this.uuid[index] < row.select.length; this.uuid[index] += 1) {
|
|
keys.push(this.uuid[index]);
|
|
keys.push(this.uuid[index]);
|
|
form.getFieldDecorator(`question.content.questions[${index}].select[${this.uuid}]`);
|
|
form.getFieldDecorator(`question.content.questions[${index}].select[${this.uuid}]`);
|
|
- form.getFieldDecorator(`question.content.questions[${index}].answer[${this.uuid}]`);
|
|
|
|
- }
|
|
|
|
- const answerMap = {};
|
|
|
|
- row.answer.forEach(r => {
|
|
|
|
- answerMap[r] = true;
|
|
|
|
- });
|
|
|
|
- row.answer = row.select.map(r => answerMap[r] || false);
|
|
|
|
- } else if (row.answer && row.answer.length > 0) {
|
|
|
|
- for (; this.uuid[index] < row.answer.length; this.uuid[index] += 1) {
|
|
|
|
- keys.push(this.uuid);
|
|
|
|
- form.getFieldDecorator(`question.content.questions[${index}].answer[${this.uuid}]`);
|
|
|
|
|
|
+ form.getFieldDecorator(`question.answer.questions[${index}].${type}[${this.uuid}]`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
form.getFieldDecorator(`question.content.questions[${index}].keys`);
|
|
form.getFieldDecorator(`question.content.questions[${index}].keys`);
|
|
row.keys = keys;
|
|
row.keys = keys;
|
|
return row;
|
|
return row;
|
|
});
|
|
});
|
|
- result.question.content.steps.forEach((row, index) => {
|
|
|
|
- form.getFieldDecorator(`question.content.steps[${index}].title`);
|
|
|
|
- form.getFieldDecorator(`question.content.steps[${index}].stem`);
|
|
|
|
- });
|
|
|
|
|
|
|
|
- form.getFieldDecorator('question.content.step');
|
|
|
|
form.getFieldDecorator('question.content.number');
|
|
form.getFieldDecorator('question.content.number');
|
|
form.getFieldDecorator('question.content.type');
|
|
form.getFieldDecorator('question.content.type');
|
|
form.getFieldDecorator('question.content.typeset');
|
|
form.getFieldDecorator('question.content.typeset');
|
|
- form.getFieldDecorator('libraryId');
|
|
|
|
- form.getFieldDecorator('no');
|
|
|
|
|
|
+
|
|
|
|
+ form.getFieldDecorator('question.stem');
|
|
form.getFieldDecorator('question.questionType');
|
|
form.getFieldDecorator('question.questionType');
|
|
|
|
+ form.getFieldDecorator('question.qxContent');
|
|
form.getFieldDecorator('question.place');
|
|
form.getFieldDecorator('question.place');
|
|
form.getFieldDecorator('question.id');
|
|
form.getFieldDecorator('question.id');
|
|
|
|
+ form.getFieldDecorator('questionId');
|
|
|
|
+ form.getFieldDecorator('libraryId');
|
|
|
|
+ form.getFieldDecorator('title');
|
|
|
|
+ form.getFieldDecorator('no');
|
|
form.getFieldDecorator('id');
|
|
form.getFieldDecorator('id');
|
|
form.setFieldsValue(result);
|
|
form.setFieldsValue(result);
|
|
|
|
|
|
@@ -140,7 +132,11 @@ export default class extends Page {
|
|
addQuestion(index) {
|
|
addQuestion(index) {
|
|
const { form } = this.props;
|
|
const { form } = this.props;
|
|
const keys = form.getFieldValue(`question.content.questions[${index}].keys`) || [];
|
|
const keys = form.getFieldValue(`question.content.questions[${index}].keys`) || [];
|
|
- this.uuid[index] += 1;
|
|
|
|
|
|
+ if (!this.uuid[index]) {
|
|
|
|
+ this.uuid[index] = 1;
|
|
|
|
+ } else {
|
|
|
|
+ this.uuid[index] += 1;
|
|
|
|
+ }
|
|
const nextKeys = keys.concat(this.uuid[index]);
|
|
const nextKeys = keys.concat(this.uuid[index]);
|
|
form.setFieldsValue({
|
|
form.setFieldsValue({
|
|
[`question.content.questions[${index}].keys`]: nextKeys,
|
|
[`question.content.questions[${index}].keys`]: nextKeys,
|
|
@@ -160,10 +156,10 @@ export default class extends Page {
|
|
|
|
|
|
changeQuestion(index, k, value) {
|
|
changeQuestion(index, k, value) {
|
|
const { form } = this.props;
|
|
const { form } = this.props;
|
|
- let answer = form.getFieldValue(`question.content.answer[${index}].single`) || [];
|
|
|
|
|
|
+ let answer = form.getFieldValue(`question.answer.questions[${index}].single`) || [];
|
|
answer = answer.map(() => !value);
|
|
answer = answer.map(() => !value);
|
|
answer[k] = !!value;
|
|
answer[k] = !!value;
|
|
- form.setFieldsValue({ [`question.content.answer[${index}].single`]: answer });
|
|
|
|
|
|
+ form.setFieldsValue({ [`question.answer.questions[${index}].single`]: answer });
|
|
}
|
|
}
|
|
|
|
|
|
submit() {
|
|
submit() {
|
|
@@ -171,15 +167,20 @@ export default class extends Page {
|
|
form.validateFields((err) => {
|
|
form.validateFields((err) => {
|
|
if (!err) {
|
|
if (!err) {
|
|
const data = form.getFieldsValue();
|
|
const data = form.getFieldsValue();
|
|
- [data.startTime, data.endTime] = data.time;
|
|
|
|
|
|
+ // [data.startTime, data.endTime] = data.time;
|
|
let handler;
|
|
let handler;
|
|
if (!data.id) {
|
|
if (!data.id) {
|
|
handler = Textbook.editQuestion(data);
|
|
handler = Textbook.editQuestion(data);
|
|
} else {
|
|
} else {
|
|
handler = Textbook.addQuestion(data);
|
|
handler = Textbook.addQuestion(data);
|
|
}
|
|
}
|
|
- handler.then(() => {
|
|
|
|
|
|
+ handler.then((result) => {
|
|
asyncSMessage('保存成功');
|
|
asyncSMessage('保存成功');
|
|
|
|
+ if (data.id) {
|
|
|
|
+ linkTo(`/subject/textbook/question/${data.id}`);
|
|
|
|
+ } else {
|
|
|
|
+ linkTo(`/subject/textbook/question/${result.id}`);
|
|
|
|
+ }
|
|
}).catch((e) => {
|
|
}).catch((e) => {
|
|
if (e.result) form.setFields(formatFormError(data, e.result));
|
|
if (e.result) form.setFields(formatFormError(data, e.result));
|
|
});
|
|
});
|
|
@@ -360,7 +361,7 @@ export default class extends Page {
|
|
return <Block flex>
|
|
return <Block flex>
|
|
<Form>
|
|
<Form>
|
|
<Form.Item label='千行解析'>
|
|
<Form.Item label='千行解析'>
|
|
- {getFieldDecorator('qxContent', {
|
|
|
|
|
|
+ {getFieldDecorator('question.qxContent', {
|
|
})(
|
|
})(
|
|
<Editor placeholder='输入内容' />,
|
|
<Editor placeholder='输入内容' />,
|
|
)}
|
|
)}
|