|
@@ -1,6 +1,7 @@
|
|
|
import React from 'react';
|
|
|
import ReactDOM from 'react-dom';
|
|
|
import './index.less';
|
|
|
+import { Checkbox } from 'antd';
|
|
|
import Assets from '@src/components/Assets';
|
|
|
import Page from '@src/containers/Page';
|
|
|
import Button from '../../../components/Button';
|
|
@@ -9,73 +10,156 @@ import Answer from '../../../components/Answer';
|
|
|
import Calculator from '../../../components/Calculator';
|
|
|
import AnswerSelect from '../../../components/AnswerSelect';
|
|
|
import AnswerTable from '../../../components/AnswerTable';
|
|
|
+import { Question } from '../../../stores/question';
|
|
|
+import Editor from '../../../components/Editor';
|
|
|
|
|
|
export default class extends Page {
|
|
|
initState() {
|
|
|
- return { showCalculator: false };
|
|
|
+ return {
|
|
|
+ showCalculator: false,
|
|
|
+ start: !this.props.core.query.r,
|
|
|
+ reportId: this.props.core.query.r,
|
|
|
+ type: this.props.core.query.type,
|
|
|
+ disorder: false,
|
|
|
+ step: 0,
|
|
|
+ info: {},
|
|
|
+ reportInfo: {},
|
|
|
+ questionInfo: {},
|
|
|
+ answer: {},
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
- renderView() {
|
|
|
- return this.renderDetail();
|
|
|
+ initData() {
|
|
|
+ const { start } = this.state;
|
|
|
+ Question.getPaper(this.params.id).then(result => {
|
|
|
+ this.setState({ info: result });
|
|
|
+ });
|
|
|
+ if (!start) {
|
|
|
+ this.continue();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- initData() {
|
|
|
+ onChangeQuestion(index, value) {
|
|
|
+ const { question = {}, answer = {} } = this.state;
|
|
|
+ answer.questions[index] = { [question.type]: value };
|
|
|
+ this.setState({ answer });
|
|
|
+ }
|
|
|
+
|
|
|
+ onChangeAwa(value) {
|
|
|
+ const { answer = {} } = this.state;
|
|
|
+ answer.awa = value;
|
|
|
+ this.setState({ answer });
|
|
|
+ }
|
|
|
+
|
|
|
+ start() {
|
|
|
+ const { type, info, disorder } = this.state;
|
|
|
+ Question.start(type, info.id, disorder).then(result => {
|
|
|
+ this.setState({ reportInfo: result });
|
|
|
+ this.next();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ continue() {
|
|
|
+ const { reportId } = this.state;
|
|
|
+ Question.continue(reportId).then(result => {
|
|
|
+ this.setState({ reportInfo: result });
|
|
|
+ this.next();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ next() {
|
|
|
+ const { reportInfo } = this.state;
|
|
|
+ Question.next(reportInfo.id).then(result => {
|
|
|
+ this.setState({
|
|
|
+ questionInfo: result,
|
|
|
+ question: result.question,
|
|
|
+ answer: { questions: [], subject: [], predicate: [], object: [], options: [], awa: '' },
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ submit() {
|
|
|
+ const { question, answer } = this.state;
|
|
|
+ Question.submit(question.questionNoId, answer).then(() => {
|
|
|
+ this.next();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ finish() {
|
|
|
+ const { reportInfo } = this.state;
|
|
|
+ Question.finish(reportInfo.id).then(() => {});
|
|
|
+ }
|
|
|
+
|
|
|
+ formatStrem(text) {
|
|
|
+ if (!text) return '';
|
|
|
+ const { question = { content: {} } } = this.state;
|
|
|
+ const { table = {}, questions = [] } = question.content;
|
|
|
+ text = text.replace(/#select#/g, "<span class='#select#' />");
|
|
|
+ text = text.replace(/#table#/g, "<span class='#table#' />");
|
|
|
setTimeout(() => {
|
|
|
- ReactDOM.render(
|
|
|
- <AnswerSelect list={[{ title: '123' }, { title: '321' }]} />,
|
|
|
- document.getElementById('#select#'),
|
|
|
- );
|
|
|
- ReactDOM.render(
|
|
|
- <AnswerTable
|
|
|
- list={[{ title: '123' }, { title: '321' }]}
|
|
|
- columns={[{ key: 'one', title: 'one' }, { key: 'two', title: 'two' }]}
|
|
|
- data={[{ one: '123', two: '321' }]}
|
|
|
- />,
|
|
|
- document.getElementById('#table#'),
|
|
|
- );
|
|
|
+ const selectList = document.getElementsByClassName('#select#');
|
|
|
+ const tableList = document.getElementsByClassName('#table#');
|
|
|
+ for (let i = 0; i < selectList.length; i += 1) {
|
|
|
+ ReactDOM.render(
|
|
|
+ <AnswerSelect list={questions[i].select} onChange={v => this.onChangeQuestion(i, v)} />,
|
|
|
+ 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],
|
|
|
+ );
|
|
|
+ }
|
|
|
}, 1);
|
|
|
+ return text;
|
|
|
+ }
|
|
|
+
|
|
|
+ renderView() {
|
|
|
+ const { start } = this.state;
|
|
|
+ if (!start) return this.renderStart();
|
|
|
+ return this.renderDetail();
|
|
|
}
|
|
|
|
|
|
renderCotent() {
|
|
|
+ const { question = { content: {} }, step } = this.state;
|
|
|
+ const { steps = [] } = question.content;
|
|
|
return (
|
|
|
<div className="block block-content">
|
|
|
- <Navigation list={['Sports Association', 'News Orgnization', 'News Orgnization']} onChange={() => {}} />
|
|
|
- <div className="text">
|
|
|
- For each of the following statements, select Both accept if, based on the information provided, it can be
|
|
|
- inferred that both the sports association and the news organizations would likely accept that the statement is
|
|
|
- true. If not, select Otherwise.
|
|
|
- <span id="#table#" />
|
|
|
- For each of the following statements, select Both accept if, based on the information provided, it can be
|
|
|
- inferred <span id="#select#" />
|
|
|
- that both the sports association and the news organizations would likely accept that the statement is true. If
|
|
|
- not, select Otherwise.
|
|
|
- </div>
|
|
|
+ {steps.length > 0 && <Navigation list={question.content.steps} active={step} onChange={() => {}} />}
|
|
|
+ <div className="text">{this.formatStrem(steps.length > 0 ? steps[step].stem : question.stem)}</div>
|
|
|
</div>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
renderAnswer() {
|
|
|
+ const { question = { content: {} } } = this.state;
|
|
|
+ const { questions = [] } = question.content;
|
|
|
+ if (question.type === 'inline') return '';
|
|
|
return (
|
|
|
<div className="block block-answer">
|
|
|
- <div className="text m-b-2">
|
|
|
- For each of the following statements, select Both accept if, based on the information provided, it can be
|
|
|
- inferred that both the sports association and the news organizations would likely accept that the statement is
|
|
|
- true. If not, select Otherwise.{' '}
|
|
|
- </div>
|
|
|
- <Answer
|
|
|
- list={[
|
|
|
- 'Neuroscientists, having amassed a wealth of knowledge',
|
|
|
- 'the past twenty years about the brain and its development from birth to adulthood',
|
|
|
- 'Neuroscientists, having amassed a wealth of knowledge',
|
|
|
- 'the past twenty years about the brain and its development from birth to adulthood, ) the past twenty years about the brain and its development from birth to adulthood',
|
|
|
- ]}
|
|
|
- />
|
|
|
+ <Editor onChange={v => this.onChangeAwa(v)} />
|
|
|
+ {question.type === 'awa' && <Editor onChange={v => this.onChangeAwa(v)} />}
|
|
|
+ {questions.map((item, index) => {
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ <div className="text m-b-2">{item.description}</div>
|
|
|
+ <Answer
|
|
|
+ list={item.select}
|
|
|
+ type={question.type}
|
|
|
+ direction={question.direction}
|
|
|
+ onChange={v => this.onChangeQuestion(index, v)}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ })}
|
|
|
</div>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
renderDetail() {
|
|
|
- const { showCalculator } = this.state;
|
|
|
+ const { showCalculator, info, question = { content: {} } } = this.state;
|
|
|
+ const { typeset = 'one' } = question.content;
|
|
|
return (
|
|
|
<div className="layout">
|
|
|
<div className="fixed">
|
|
@@ -89,18 +173,19 @@ export default class extends Page {
|
|
|
</div>
|
|
|
<Calculator show={showCalculator} />
|
|
|
<div className="layout-header">
|
|
|
- <div className="title">OG18:1-20</div>
|
|
|
+ <div className="title">{info.title}</div>
|
|
|
<div className="right">
|
|
|
<div className="block">
|
|
|
<Assets name="timeleft_icon" />
|
|
|
Time left 00:02
|
|
|
</div>
|
|
|
<div className="block">
|
|
|
- <Assets name="subjectnumber_icon" />1 of 20
|
|
|
+ <Assets name="subjectnumber_icon" />
|
|
|
+ {question.no} of {info.questionNumer}
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div className="layout-body two">
|
|
|
+ <div className={`layout-body ${typeset}`}>
|
|
|
{this.renderCotent()}
|
|
|
{this.renderAnswer()}
|
|
|
</div>
|
|
@@ -112,7 +197,7 @@ export default class extends Page {
|
|
|
<div className="full">
|
|
|
<Assets name="fullscreen_icon" />
|
|
|
</div>
|
|
|
- <div className="next">
|
|
|
+ <div className="next" onClick={() => this.next()}>
|
|
|
Next
|
|
|
<Assets name="next_icon" />
|
|
|
</div>
|
|
@@ -122,30 +207,34 @@ export default class extends Page {
|
|
|
}
|
|
|
|
|
|
renderStart() {
|
|
|
+ const { info, disorder } = this.state;
|
|
|
return (
|
|
|
<div className="start">
|
|
|
<div className="bg" />
|
|
|
<div className="fixed-content">
|
|
|
- <div className="title">「练习」OG18 综合:第1-20题</div>
|
|
|
+ <div className="title">{info.title}</div>
|
|
|
<div className="desc">
|
|
|
<div className="block">
|
|
|
<div className="desc-title">
|
|
|
<Assets name="subject_icon" />
|
|
|
题目总数
|
|
|
</div>
|
|
|
- <div className="desc-info">20</div>
|
|
|
+ <div className="desc-info">{info.questionNumer}</div>
|
|
|
</div>
|
|
|
<div className="block">
|
|
|
<div className="desc-title">
|
|
|
<Assets name="time_icon" />
|
|
|
建议用时
|
|
|
</div>
|
|
|
- <div className="desc-info">20 min</div>
|
|
|
+ <div className="desc-info">{info.time}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div className="tip">题目选项乱序显示</div>
|
|
|
+ <div className="tip">
|
|
|
+ <Checkbox className="m-r-1" checked={disorder} onChange={() => this.setState({ disorder: !disorder })} />
|
|
|
+ 题目选项乱序显示
|
|
|
+ </div>
|
|
|
<div className="submit">
|
|
|
- <Button size="lager" radius>
|
|
|
+ <Button size="lager" radius onClick={() => this.start()}>
|
|
|
开始练习
|
|
|
</Button>
|
|
|
</div>
|