import React 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 Page from '@src/containers/Page'; import { formatSeconds, formatPercent, formatDate, sortListWithOrder } 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 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 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: "
I like book
", // }, // userQuestion: { // userAnswer: { // subject: [{ text: 'I', uuid: 'kBJe' }], // options: ['compare'], // }, // no: 2, // }, // paper: { // title: '长难句练习', // questionNumber: 20, // }, // report: { // paperModule: 'sentence', // }, }; } initData() { const { id } = this.params; Question.getDetailById(id).then(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]); }); question.answer.questions.forEach((q, i) => { Object.keys(q).forEach((k) => { if (q[k]) q[k] = sortListWithOrder(q[k], setting.questions[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, questionNos }); }); } prevQuestion() { const { userQuestion } = this.state; if (userQuestion.no === 1) return; Question.getDetailByNo(userQuestion.reportId, userQuestion.no - 1).then((r) => { linkTo(`/paper/question/${r.id}`); }); } nextQuestion() { const { userQuestion } = this.state; if (userQuestion.questionNumber === userQuestion.no) return; Question.getDetailByNo(userQuestion.reportId, userQuestion.no + 1).then((r) => { linkTo(`/paper/question/${r.id}`); }); } submitAsk() { const { userQuestion = {}, ask = {} } = this.state; if (ask.originContent === '' || ask.content === '' || ask.target === '') return; My.addQuestionAsk(userQuestion.id, ask.target, userQuestion.questionModule, ask.originContent, ask.content).then(() => { this.setState({ askModal: false, askOkModal: true }); }).catch(err => { this.setState({ askError: err.message }); }); } submitFeedbackError() { const { feedback = {}, question = {}, questionNo = {} } = this.state; if (feedback.originContent === '' || feedback.content === '' || feedback.target === '') return; My.addFeedbackErrorQuestion(question.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 = {}, note = {} } = this.state; My.updateQuestionNote(userQuestion.questionModule, userQuestion.questionNoId, 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 = {} } = this.state; if (!userQuestion.collect) { My.addQuestionCollect(userQuestion.questionModule, userQuestion.questionNoId).then(() => { userQuestion.collect = true; this.setState({ userQuestion }); }); } else { My.delQuestionCollect(userQuestion.questionModule, userQuestion.questionNoId).then(() => { userQuestion.collect = false; this.setState({ userQuestion }); }); } } formatStem(text) { if (!text) return ''; const { showAnswer, question = { content: {} }, userQuestion } = this.state; 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(题源汇总
{(questionNos || []).map((row) =>ID:{row.title}
)}