|
@@ -25,37 +25,38 @@ import Sentence from '../process/sentence';
|
|
|
export default class extends Page {
|
|
|
initState() {
|
|
|
return {
|
|
|
+ step: 0,
|
|
|
hideAnalysis: true,
|
|
|
analysisTab: 'official',
|
|
|
showAnswer: false,
|
|
|
noteField: AskTarget[0].key,
|
|
|
showIds: false,
|
|
|
|
|
|
- question: {
|
|
|
- content: {
|
|
|
- typeset: 'one',
|
|
|
- },
|
|
|
- // questionType: 'awa',
|
|
|
- answer: {
|
|
|
- subject: [[{ text: 'like', uuid: 'hKyz' }]],
|
|
|
- options: ['parallel'],
|
|
|
- },
|
|
|
- stem: "<p><span uuid='kBJe'>I</span> <span uuid='hKyz'>like</span> <span uuid='fQXh'>book</span></p>",
|
|
|
- },
|
|
|
- userQuestion: {
|
|
|
- userAnswer: {
|
|
|
- subject: [{ text: 'I', uuid: 'kBJe' }],
|
|
|
- options: ['compare'],
|
|
|
- },
|
|
|
- no: 2,
|
|
|
- },
|
|
|
- paper: {
|
|
|
- title: '长难句练习',
|
|
|
- questionNumber: 20,
|
|
|
- },
|
|
|
- report: {
|
|
|
- paperModule: 'sentence',
|
|
|
- },
|
|
|
+ // question: {
|
|
|
+ // content: {
|
|
|
+ // typeset: 'one',
|
|
|
+ // },
|
|
|
+ // // questionType: 'awa',
|
|
|
+ // answer: {
|
|
|
+ // subject: [[{ text: 'like', uuid: 'hKyz' }]],
|
|
|
+ // options: ['parallel'],
|
|
|
+ // },
|
|
|
+ // stem: "<p><span uuid='kBJe'>I</span> <span uuid='hKyz'>like</span> <span uuid='fQXh'>book</span></p>",
|
|
|
+ // },
|
|
|
+ // userQuestion: {
|
|
|
+ // userAnswer: {
|
|
|
+ // subject: [{ text: 'I', uuid: 'kBJe' }],
|
|
|
+ // options: ['compare'],
|
|
|
+ // },
|
|
|
+ // no: 2,
|
|
|
+ // },
|
|
|
+ // paper: {
|
|
|
+ // title: '长难句练习',
|
|
|
+ // questionNumber: 20,
|
|
|
+ // },
|
|
|
+ // report: {
|
|
|
+ // paperModule: 'sentence',
|
|
|
+ // },
|
|
|
|
|
|
};
|
|
|
}
|
|
@@ -63,27 +64,35 @@ export default class extends Page {
|
|
|
initData() {
|
|
|
const { id } = this.params;
|
|
|
Question.getDetailById(id).then(userQuestion => {
|
|
|
- const { question, questionNos, paper, note, report, answer, setting } = userQuestion;
|
|
|
+ const { question, questionNos, paper, note, report, setting } = userQuestion;
|
|
|
let { questionNo } = userQuestion;
|
|
|
if (!questionNo) ([questionNo] = questionNos);
|
|
|
+ if (!question.answer) question.answer = { questions: [] };
|
|
|
+ if (!question.answerDistributed) question.answerDistributed = { questions: [] };
|
|
|
+ if (!userQuestion.userAnswer) userQuestion.userAnswer = { questions: [] };
|
|
|
if ((report.setting || {}).disorder) {
|
|
|
const { content } = question;
|
|
|
// 还原做题顺序
|
|
|
content.questions.forEach((q, i) => {
|
|
|
q.select = sortListWithOrder(question.select, setting.questions[i]);
|
|
|
});
|
|
|
- answer.questions.forEach((q, i) => {
|
|
|
+ question.answer.questions.forEach((q, i) => {
|
|
|
Object.keys(q).forEach((k) => {
|
|
|
if (q[k]) q[k] = sortListWithOrder(q[k], setting.questions[i]);
|
|
|
});
|
|
|
});
|
|
|
- question.answerDistributed.forEach((q, i) => {
|
|
|
+ question.answerDistributed.questions.forEach((q, i) => {
|
|
|
+ Object.keys(q).forEach((k) => {
|
|
|
+ if (q[k]) q[k] = sortListWithOrder(q[k], setting.questions[i]);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ userQuestion.userAnswer.questions.forEach((q, i) => {
|
|
|
Object.keys(q).forEach((k) => {
|
|
|
if (q[k]) q[k] = sortListWithOrder(q[k], setting.questions[i]);
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
- this.setState({ userQuestion, question, questionNo, note, paper });
|
|
|
+ this.setState({ userQuestion, question, questionNo, note, paper, questionNos });
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -154,7 +163,7 @@ export default class extends Page {
|
|
|
|
|
|
formatStem(text) {
|
|
|
if (!text) return '';
|
|
|
- const { question = { content: {} } } = this.state;
|
|
|
+ const { showAnswer, question = { content: {} }, userQuestion } = this.state;
|
|
|
const { table = {}, questions = [] } = question.content;
|
|
|
text = text.replace(/#select#/g, "<span class='#select#' />");
|
|
|
text = text.replace(/#table#/g, "<span class='#table#' />");
|
|
@@ -162,13 +171,25 @@ export default class extends Page {
|
|
|
const selectList = document.getElementsByClassName('#select#');
|
|
|
const tableList = document.getElementsByClassName('#table#');
|
|
|
for (let i = 0; i < selectList.length; i += 1) {
|
|
|
+ if (!questions[i]) break;
|
|
|
ReactDOM.render(
|
|
|
- <AnswerSelect list={questions[i].select} onChange={v => this.onChangeQuestion(i, v)} />,
|
|
|
+ <AnswerSelect
|
|
|
+ list={questions[i].select}
|
|
|
+ type={'single'}
|
|
|
+ selected={(userQuestion.userAnswer || { questions: [] }).questions[i]}
|
|
|
+ answer={(question.answer || { questions: [] }).questions[i]}
|
|
|
+ fix
|
|
|
+ show={showAnswer} />,
|
|
|
selectList[i],
|
|
|
);
|
|
|
}
|
|
|
- for (let i = 0; i < tableList.length; i += 1) {
|
|
|
- ReactDOM.render(<AnswerTable list={table.header} columns={table.header} data={table.data} />, tableList[i]);
|
|
|
+ if (table.row && table.col && table.header) {
|
|
|
+ const columns = table.header.map((title, index) => {
|
|
|
+ return { title, key: index };
|
|
|
+ });
|
|
|
+ for (let i = 0; i < tableList.length; i += 1) {
|
|
|
+ ReactDOM.render(<AnswerTable list={columns} columns={columns} data={table.data} />, tableList[i]);
|
|
|
+ }
|
|
|
}
|
|
|
}, 1);
|
|
|
return text;
|
|
@@ -336,8 +357,8 @@ export default class extends Page {
|
|
|
break;
|
|
|
case 'qa':
|
|
|
content = <div className="detail-block answer-block">
|
|
|
- {asks.map(ask => {
|
|
|
- return ask;
|
|
|
+ {asks.map((ask, index) => {
|
|
|
+ return <OtherAnswer key={index} data={ask} />;
|
|
|
})}
|
|
|
</div>;
|
|
|
break;
|
|
@@ -347,33 +368,28 @@ export default class extends Page {
|
|
|
return content;
|
|
|
}
|
|
|
|
|
|
- renderOtherAnswer() {
|
|
|
- const { otherAnswer = [1, 2, 3, 4, 5] } = this.state;
|
|
|
- return (
|
|
|
- <div className="other">
|
|
|
- {otherAnswer.map(() => {
|
|
|
- return <OtherAnswer />;
|
|
|
- })}
|
|
|
- </div>
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
renderAnswer() {
|
|
|
- const { question = { content: {} }, showAnswer } = this.state;
|
|
|
- const { questions = [] } = question.content;
|
|
|
- const { typeset = 'one' } = question.content;
|
|
|
+ const { question = { content: {} }, showAnswer, userQuestion = {} } = this.state;
|
|
|
+ const { questions = [], type, typeset = 'one' } = question.content;
|
|
|
+ console.log(userQuestion);
|
|
|
return <div className="block block-answer">
|
|
|
{typeset === 'two' ? <Switch checked={showAnswer} onChange={(value) => {
|
|
|
this.setState({ showAnswer: value });
|
|
|
}}>{showAnswer ? '显示答案' : '关闭答案'}</Switch> : ''}
|
|
|
- {questions.map((item) => {
|
|
|
+ {questions.map((item, index) => {
|
|
|
return (
|
|
|
<div>
|
|
|
<div className="text m-b-2">{item.description}</div>
|
|
|
<AnswerList
|
|
|
+ show={showAnswer}
|
|
|
+ selected={(userQuestion.userAnswer || { questions: [] }).questions[index]}
|
|
|
+ answer={(question.answer || { questions: [] }).questions[index]}
|
|
|
+ distributed={(question.answerDistributed || { questions: [] }).questions[index]}
|
|
|
list={item.select}
|
|
|
- type={question.type}
|
|
|
- direction={question.direction}
|
|
|
+ type={type}
|
|
|
+ first={item.first}
|
|
|
+ second={item.second}
|
|
|
+ direction={item.direction}
|
|
|
/>
|
|
|
</div>
|
|
|
);
|
|
@@ -382,18 +398,16 @@ export default class extends Page {
|
|
|
}
|
|
|
|
|
|
renderContent() {
|
|
|
- const { question = { content: {} }, userQuestion = {}, showAnswer, step } = this.state;
|
|
|
- const { userAnswer } = userQuestion;
|
|
|
+ const { question = { content: {} }, showAnswer, step } = this.state;
|
|
|
const { typeset = 'one' } = question.content;
|
|
|
const { steps = [] } = question.content;
|
|
|
- console.log(userAnswer);
|
|
|
return (
|
|
|
<div className="block block-content">
|
|
|
{typeset === 'one' && question.questionType !== 'awa' ? <Switch checked={showAnswer} onChange={(value) => {
|
|
|
this.setState({ showAnswer: value });
|
|
|
}}>{showAnswer ? '显示答案' : '关闭答案'}</Switch> : ''}
|
|
|
{question.questionType === 'awa' && <h2>Analytical Writing Assessment</h2>}
|
|
|
- {steps.length > 0 && <Navigation list={question.content.steps} active={step} onChange={() => { }} />}
|
|
|
+ {steps.length > 0 && <Navigation theme='detail' list={question.content.steps} active={step} onChange={(v) => this.setState({ step: v })} />}
|
|
|
<div className="text" style={{ height: 2000 }} dangerouslySetInnerHTML={{ __html: this.formatStem(steps.length > 0 ? steps[step].stem : question.stem) }} />
|
|
|
</div>
|
|
|
);
|