import React,{ Component } from "react"; import {Checkbox,Radio, Input} from "antd"; import {DMDEditor,markdownToHTML, MarkdownToHtml } from 'educoder' import axios from 'axios' const tagArray = [ // 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', // 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', // 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' ] class fillEmpty extends Component{ constructor(props){ super(props); this.mdRef = React.createRef() let { questionType }=this.props; let array=[]; for(var i=0;i < questionType.multi_count; i++){ let item=""; if(questionType.user_answer.length>0){ if(questionType.user_answer[i]){ item=questionType.user_answer[i].answer_text; } } array.push({ value:item, q_id:questionType.question_number }) } this.state={ array } } toMDMode = (that) => { // if ( this.mdReactObject) { // let mdReactObject = this.mdReactObject; // this.mdReactObject = null // mdReactObject.toShowMode() // } this.mdReactObject = that; } onOptionContentChange = (value, index) => { let array = this.state.array.slice(0); array[index].value = value; this.setState({ array }) } onBlurEmpty=(index,number)=>{ let array = this.state.array.slice(0); let v=array[index].value; let question_id=this.props.questionType.question_id; let url=`/exercise_questions/${question_id}/exercise_answers.json` axios.post((url),{ exercise_choice_id:parseInt(index)+1, answer_text:v }).then((result)=>{ if(result.status==200){ //this.refs[`md${number}${index}`].toShowMode(); let count=0; for(var i=0;i{ console.log(error); }) } render(){ let { questionType , exercise , user_exercise_status, }=this.props let { array }=this.state let isAdmin = this.props.isAdmin(); let isStudent = this.props.isStudent(); return(
{ array.map((item,key)=>{ return(
  • 答案(填空{key+1}):
    { user_exercise_status == 1 ? : this.onOptionContentChange(value, key)} initValue={item.value} onCMBlur={()=>this.onBlurEmpty(key,questionType.q_position)} > }
  • ) }) } { // 答案公开,且试卷已经截止 questionType.standard_answer &&

    参考答案:

    { questionType.standard_answer && questionType.standard_answer.map((item,k)=>{ return(
      答案(填空{k+1}):
    • { item.answer_text && item.answer_text.map((i,index)=>{ return( //
      ) }) }
    ) }) }
    }
    ) } } export default fillEmpty