import React,{ Component } from "react"; import {Checkbox,Radio, Input} from "antd"; import {markdownToHTML, MarkdownToHtml} from 'educoder' import TPMMDEditor from '../../../../modules/tpm/challengesnew/TPMMDEditor' import axios from 'axios' class simpleAnswer extends Component{ constructor(props){ super(props); this.mdRef = React.createRef(); this.state={ simpleValue:undefined } } onChange=(value)=>{ this.setState({ simpleValue:value }) } onSimpleBlur=()=>{ let {simpleValue}=this.state let question_id =this.props.questionType.question_id; let url=`/exercise_questions/${question_id}/exercise_answers.json`; axios.post((url),{ answer_text:simpleValue }).then((result)=>{ if(result.status==200){ // this.setState({ // simpleValue:undefined // }) let k= simpleAnswer == "" ? 0 :1; this.props.changeQuestionStatus && this.props.changeQuestionStatus(parseInt(this.props.questionType.q_position)-1,k); } }).catch((error)=>{ console.log(error); }) } showAndHide=(flag)=>{ this.props.changeA_flag && this.props.changeA_flag(this.props.index,flag); } render(){ let { questionType , exercise, user_exercise_status, }=this.props let isAdmin=this.props.isAdmin(); let isStudent =this.props.isStudent(); return(
  • { user_exercise_status == 1 ? //
    0 ? questionType.user_answer[0]:"")}}>
    0 ? questionType.user_answer[0]:""} selector={'simgle_' + (this.props.index + 1)} className="answerStyle" > :
    0 ? questionType.user_answer[0]:''} mdID={'simpleEditor'+questionType.question_id} placeholder="请输入你的答案" height={150} onChange={this.onChange} onCMBlur={this.onSimpleBlur}>
    }
  • { // 答案公开,且试卷已经截止 isAdmin &&
    { exercise.answer_status == 1 || questionType.a_flag ?

    参考答案:

    {/*
  • */}

    this.showAndHide(false)}>隐藏参考答案

    : this.showAndHide(true)}>显示参考答案 }
    } { isStudent && questionType.standard_answer ?

    参考答案:

    {/*
  • */}
    :"" }
    ) } } export default simpleAnswer