import React, { Component } from 'react'; import ReactDOM from 'react-dom'; import { Carousel, Tooltip } from 'antd'; import { Link } from 'react-router-dom'; import Fullscreen from 'react-fullscreen-crossbrowser'; import './index.less'; import { formatSeconds, formatPercent, formatDate } from '@src/services/Tools'; import Assets from '@src/components/Assets'; import Navigation from '../../../../components/Navigation'; import Tabs from '../../../../components/Tabs'; import Icon from '../../../../components/Icon'; import Switch from '../../../../components/Switch'; import Select from '../../../../components/Select'; import { Button } from '../../../../components/Button'; import AnswerSelect from '../../../../components/AnswerSelect'; import AnswerList from '../../../../components/AnswerList'; import AnswerButton from '../../../../components/AnswerButton'; import AnswerTable from '../../../../components/AnswerTable'; import OtherAnswer from '../../../../components/OtherAnswer'; import { AskTarget } from '../../../../../Constant'; import { Question } from '../../../../stores/question'; import { My } from '../../../../stores/my'; import Sentence from '../../process/sentence'; export default class extends Component { constructor(props) { super(props); this.state = { step: 0, hideAnalysis: true, analysisTab: 'official', showAnswer: false, noteField: AskTarget[0].key, showIds: false, }; } prevQuestion() { const { userQuestion } = this.props; if (userQuestion.no === 1) return; Question.getDetailByNo(userQuestion.reportId, userQuestion.no - 1).then((r) => { linkTo(`/paper/question/${r.id}`); }); } nextQuestion() { const { userQuestion } = this.props; if (userQuestion.questionNumber === userQuestion.no) return; Question.getDetailByNo(userQuestion.reportId, userQuestion.no + 1).then((r) => { linkTo(`/paper/question/${r.id}`); }); } submitAsk() { const { userQuestion, questionNo = {} } = this.props; const { ask = {} } = this.state; if (ask.originContent === '' || ask.content === '' || ask.target === '') return; My.addQuestionAsk(userQuestion.id, ask.target, userQuestion.questionModule, questionNo.id, ask.originContent, ask.content).then(() => { this.setState({ askModal: false, askOkModal: true }); }).catch(err => { this.setState({ askError: err.message }); }); } submitFeedbackError() { const { userQuestion = {}, questionNo = {} } = this.props; const { feedback = {} } = this.state; if (feedback.originContent === '' || feedback.content === '' || feedback.target === '') return; My.addFeedbackErrorQuestion(userQuestion.questionModule, questionNo.id, questionNo.title, feedback.target, feedback.originContent, feedback.content).then(() => { this.setState({ feedbackModal: false, feedbackOkModal: true }); }).catch(err => { this.setState({ feedbackError: err.message }); }); } submitNote(close) { const { userQuestion = {}, questionNo = {} } = this.props; const { note = {} } = this.state; My.updateQuestionNote(userQuestion.questionModule, questionNo.id, note).then(() => { if (close) this.setState({ noteModal: false }); }).catch(err => { this.setState({ noteError: err.message }); }); } toggleFullscreen() { const { isFullscreenEnabled } = this.state; this.setState({ isFullscreenEnabled: !isFullscreenEnabled }); } toggleCollect() { const { userQuestion = {}, questionNo = {}, flow } = this.props; if (!userQuestion.collect) { My.addQuestionCollect(userQuestion.questionModule, questionNo.id).then(() => { userQuestion.collect = true; flow.setState({ userQuestion }); }); } else { My.delQuestionCollect(userQuestion.questionModule, questionNo.id).then(() => { userQuestion.collect = false; flow.setState({ userQuestion }); }); } } switchNo(no) { linkTo(`/question/detail/${no.id}`); } formatStem(text) { if (!text) return ''; const { showAnswer, question = { content: {} }, userQuestion } = this.props; const { table = {}, questions = [] } = question.content; text = text.replace(/#select#/g, ""); text = text.replace(/#table#/g, ""); setTimeout(() => { 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( , selectList[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(, tableList[i]); } } }, 1); return text; } render() { return ( this.setState({ isFullscreenEnabled })} > {this.renderDetail()} ); } renderDetail() { const { paper = {} } = this.props; switch (paper.paperModule) { case 'sentence': return ; default: return
{this.renderBase()}
; } } renderHeader() { const { userQuestion = {}, questionNo = {}, paper = {}, report = {}, questionNos = [], question = {}, info, detail } = this.props; const { showIds } = this.state; return
{detail &&
{paper.paperModule && paper.paperModule !== 'examination' &&
} {paper.paperModule && paper.paperModule === 'examination' &&
}
No.{userQuestion.stageNo || userQuestion.no}
{paper.title}
}
ID:{questionNo.title} {questionNos && questionNos.length > 0 && { this.setState({ showIds: true }); }} />} {showIds &&

题源汇总

{(questionNos || []).map((row) =>

info && this.switchNo(row)}>ID:{row.title}

)}
}
; } renderBase() { const { questionStatus, userQuestion = {}, paper = {}, detail } = this.props; const { showIds } = this.state; return
{ if (showIds) this.setState({ showIds: false }); }}> {this.renderHeader()}
{this.renderBody()}
this.setState({ noteModal: true })}>笔记 {questionStatus >= 0 && { if (questionStatus > 0) { this.setState({ askModal: true, ask: { target: AskTarget[0].value } }); } else { this.setState({ askFailModal: true }); } }}>提问} this.setState({ feedbackModal: true })}>纠错
{detail &&
{userQuestion.no !== 1 && this.prevQuestion()} />} {userQuestion.questionNumber !== userQuestion.no && this.nextQuestion()} />}
}
{this.state.askModal && this.renderAsk()} {this.state.askOkModal && this.renderAskOk()} {this.state.askFailModal && this.renderAskFail()} {this.state.feedbackModal && this.renderFeedbackError()} {this.state.feedbackOkModal && this.renderFeedbackErrorOk()} {this.state.noteModal && this.renderNote()}
; } renderBody() { const { question = { content: {} } } = this.props; const { typeset = 'one' } = question.content; const { hideAnalysis } = this.state; const show = typeset === 'one' ? true : !hideAnalysis; return (
{this.renderContent()} {question.questionType !== 'awa' && this.renderAnswer()} {question.questionType === 'awa' && this.renderAWA()}
{question.questionType !== 'awa' && this.renderAnalysis()} {typeset === 'two' && question.questionType !== 'awa' && (
this.setState({ hideAnalysis: !hideAnalysis })}> {show ? '收起解析 >' : '查看解析 <'}
)}
); } renderAnalysis() { const { question = { content: {} } } = this.props; const { typeset = 'one' } = question.content; const { hideAnalysis, analysisTab } = this.state; const show = typeset === 'one' ? true : !hideAnalysis; return (
{ this.setState({ analysisTab: key }); }} />
{typeset === 'two' && this.renderAnswer()} {this.renderText()}
); } renderText() { const { question = {}, userQuestion = {} } = this.props; const { asks = [], associations = [] } = userQuestion; const { analysisTab } = this.state; let content; switch (analysisTab) { case 'official': content =
; break; case 'qx': content =
; break; case 'association': content =
{associations.map(association => { return
; })}
; break; case 'qa': content =
{asks.map((ask, index) => { return ; })}
; break; default: break; } return content; } renderAnswer() { const { question = { content: {} }, userQuestion = {}, detail } = this.props; const { questions = [], type, typeset = 'one' } = question.content; const { showAnswer } = this.state; return
{detail && typeset === 'two' ? { this.setState({ showAnswer: value }); }}>{showAnswer ? '显示答案' : '关闭答案'} : ''} {questions.map((item, index) => { return (
{item.description}
); })}
; } renderContent() { const { question = { content: {} }, detail } = this.props; const { typeset = 'one' } = question.content; const { steps = [] } = question.content; const { showAnswer, step } = this.state; return (
{detail && typeset === 'one' && question.questionType !== 'awa' ? { this.setState({ showAnswer: value }); }}>{showAnswer ? '显示答案' : '关闭答案'} : ''} {question.questionType === 'awa' &&

Analytical Writing Assessment

} {steps.length > 0 && this.setState({ step: v })} />}
0 ? steps[step].stem : question.stem) }} />
); } renderAWA() { const { userQuestion = { detail: {}, userAnswer: {} } } = this.state; const { showAnswer } = this.state; return
{ this.setState({ showAnswer: value }); }}>{showAnswer ? '显示答案' : '关闭答案'}

Your Response

{showAnswer &&
用时:$1$2') }} /> {/* 用时:1m39s */} 单词数:{Number((userQuestion.detail || {}).words || 0)}
} {!showAnswer &&
选择「显示答案」查看自己的作文
}
; } renderAsk() { const { ask = {} } = this.state; return (
提问
我想对