1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- import React from 'react';
- import './index.less';
- import Page from '@src/containers/Page';
- import { sortListWithOrder } from '@src/services/Tools';
- import { AskTarget } from '../../../../Constant';
- import { Question } from '../../../stores/question';
- import Detail from './detail';
- 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',
- // },
- };
- }
- initData() {
- const { id } = this.params;
- const { search } = this.state;
- Question.getDetailById(id).then(userQuestion => {
- const { question, questionNos, paper, note, report, setting, questionStatus } = userQuestion;
- paper.paperModule = 'examination';
- 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(q.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]);
- });
- });
- }
- // 只显示单个提问
- if (search.askId) {
- const askId = Number(search.askId);
- userQuestion.asks = (userQuestion.asks || []).filter(row => row.askId === askId);
- }
- this.setState({ userQuestion, question, questionNo, note, paper, questionNos, questionStatus });
- });
- }
- renderView() {
- return (
- <Detail {...this.state} detail flow={this} />
- );
- }
- }
|