dev_forum
hjm 5 years ago
parent 4db7e1e058
commit 199c603ac9

@ -3,7 +3,6 @@ import { markdownToHTML } from 'educoder'
import './MarkdownToHtml.css' import './MarkdownToHtml.css'
/** /**
selector 需要传入唯一的selector作为id不然会引起冲突 selector 需要传入唯一的selector作为id不然会引起冲突
delay 如果有公式需要传入delay={true}
*/ */
class MarkdownToHtml extends Component{ class MarkdownToHtml extends Component{
constructor(props){ constructor(props){
@ -12,16 +11,7 @@ class MarkdownToHtml extends Component{
} }
} }
_markdownToHTML = (content, selector) => { _markdownToHTML = (content, selector) => {
if (this.props.delay == true) {
(function(content, selector) {
// console.log('selector: ', selector)
// setTimeout(() => {
markdownToHTML(content, selector) markdownToHTML(content, selector)
// }, 600)
})(content, selector)
} else {
markdownToHTML(content, selector)
}
} }
componentDidUpdate = (prevProps) => { componentDidUpdate = (prevProps) => {
if (this.props.content) { if (this.props.content) {

@ -7,7 +7,7 @@ import '../poll/pollStyle.css'
import '../css/Courses.css' import '../css/Courses.css'
import moment from 'moment' import moment from 'moment'
import { WordsBtn,markdownToHTML,ActionBtn,getImageUrl } from 'educoder' import { WordsBtn,markdownToHTML,ActionBtn,getImageUrl, MarkdownToHtml } from 'educoder'
import Modals from '../../modals/Modals' import Modals from '../../modals/Modals'
import CoursesListType from '../coursesPublic/CoursesListType'; import CoursesListType from '../coursesPublic/CoursesListType';
@ -537,7 +537,7 @@ class ExerciseReviewAndAnswer extends Component{
/> />
<div className="educontent mt10 mb50"> <div className="educontent mt10 mb50">
<p className="clearfix mb20"> <p className="clearfix mb20">
<WordsBtn style="grey" className="fl" to={current_user.first_category_url}>{courseName}</WordsBtn> <WordsBtn style="grey" className="fl" to={current_user && current_user.first_category_url}>{courseName}</WordsBtn>
<span className="color-grey-9 fl ml3 mr3">&gt;</span> <span className="color-grey-9 fl ml3 mr3">&gt;</span>
<WordsBtn style="grey" className="fl" to={`/courses/${coursesId}/exercises/${data && data.left_banner_id}`}>{data && data.left_banner_name}</WordsBtn> <WordsBtn style="grey" className="fl" to={`/courses/${coursesId}/exercises/${data && data.left_banner_id}`}>{data && data.left_banner_name}</WordsBtn>
<span className="color-grey-9 fl ml3 mr3">&gt;</span> <span className="color-grey-9 fl ml3 mr3">&gt;</span>
@ -712,7 +712,10 @@ class ExerciseReviewAndAnswer extends Component{
</span> </span>
</p> </p>
<li className="break_word mt15 mb15 pl30 pr30"> <li className="break_word mt15 mb15 pl30 pr30">
<p className="standardAnswer markdown-body" dangerouslySetInnerHTML={{__html: markdownToHTML(item.question_type == 5 ? item.shixun_name : item.question_title).replace(/▁/g,"▁▁▁")}}></p> {/* <p className="standardAnswer markdown-body" dangerouslySetInnerHTML={{__html: markdownToHTML1(item.question_type == 5 ? item.shixun_name : item.question_title).replace(/▁/g,"▁▁▁")}}></p> */}
<MarkdownToHtml content={(item.question_type == 5 ? item.shixun_name : item.question_title)} selector={'answer_' + key}
className="standardAnswer"
></MarkdownToHtml>
</li> </li>
{ {
// 选择题和判断题共用 // 选择题和判断题共用
@ -724,6 +727,7 @@ class ExerciseReviewAndAnswer extends Component{
questionType={item} questionType={item}
user_exercise_status={user_exercise_status} user_exercise_status={user_exercise_status}
changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)} changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)}
index={key}
></Single> ></Single>
} }
{ {
@ -736,6 +740,8 @@ class ExerciseReviewAndAnswer extends Component{
questionType={item} questionType={item}
user_exercise_status={user_exercise_status} user_exercise_status={user_exercise_status}
changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)} changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)}
index={key}
></Multiple> ></Multiple>
} }
{ {
@ -748,6 +754,8 @@ class ExerciseReviewAndAnswer extends Component{
questionType={item} questionType={item}
user_exercise_status={user_exercise_status} user_exercise_status={user_exercise_status}
changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)} changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)}
index={key}
></FillEmpty> ></FillEmpty>
} }
{ {
@ -774,6 +782,8 @@ class ExerciseReviewAndAnswer extends Component{
questionType={item} questionType={item}
user_exercise_status={user_exercise_status} user_exercise_status={user_exercise_status}
id={this.state.Id} id={this.state.Id}
index={key}
></ShixunAnswer> ></ShixunAnswer>
} }

@ -1,5 +1,5 @@
import React, {Component} from "react"; import React, {Component} from "react";
import {WordsBtn,markdownToHTML} from 'educoder'; import {WordsBtn,markdownToHTML, MarkdownToHtml} from 'educoder';
import { Form, Select, Input, Button,Checkbox,Upload,Icon,message,Modal, Table, Divider,InputNumber, Tag,DatePicker,Radio,Tooltip,Pagination} from "antd"; import { Form, Select, Input, Button,Checkbox,Upload,Icon,message,Modal, Table, Divider,InputNumber, Tag,DatePicker,Radio,Tooltip,Pagination} from "antd";
import {Link,Switch,Route,Redirect} from 'react-router-dom'; import {Link,Switch,Route,Redirect} from 'react-router-dom';
import axios from 'axios'; import axios from 'axios';
@ -194,8 +194,10 @@ class Exercisestatisticalresult extends Component {
<span className="CACFF">{item.ques_position+"."}{item.ques_type===0?"单选":item.ques_type===1?"多选":item.ques_type===2?"判断":item.ques_type===3?"填空":item.ques_type===4?"主观":item.ques_type===5?"实训":""}</span> <span className="CACFF">{item.ques_position+"."}{item.ques_type===0?"单选":item.ques_type===1?"多选":item.ques_type===2?"判断":item.ques_type===3?"填空":item.ques_type===4?"主观":item.ques_type===5?"实训":""}</span>
<div> <div>
{/*Q{item.ques_position}*/} {/*Q{item.ques_position}*/}
<div className={"markdown-body"} dangerouslySetInnerHTML={{__html: markdownToHTML(item.ques_title).replace(/▁/g,"▁▁▁")}}></div> {/* <div className={"markdown-body"} dangerouslySetInnerHTML={{__html: markdownToHTML1(item.ques_title).replace(/▁/g,"▁▁▁")}}></div> */}
<MarkdownToHtml content={item.ques_title} selector={'ques_title_' + key}
className=""
></MarkdownToHtml>
{/*<span className="markdown-body" dangerouslySetInnerHTML={createMarkup(item.ques_title)}></span>*/} {/*<span className="markdown-body" dangerouslySetInnerHTML={createMarkup(item.ques_title)}></span>*/}
</div> </div>
</div> </div>

@ -87,9 +87,12 @@ class JudgeDisplay extends Component{
return ( return (
<div key={optionIndex} className="fl mr30"> <div key={optionIndex} className="fl mr30">
<Radio disabled checked={item.standard_boolean}></Radio> <Radio disabled checked={item.standard_boolean}></Radio>
<span>{item.choice_text}</span> {/* <span>{item.choice_text}</span> */}
<MarkdownToHtml content={item.choice_text} selector={'judge_' + optionIndex}
className=""
></MarkdownToHtml>
{/* <span style={{ display: 'inline-block'}} className="markdown-body" {/* <span style={{ display: 'inline-block'}} className="markdown-body"
dangerouslySetInnerHTML={{__html: markdownToHTML(item.choice_text)}}></span> */} dangerouslySetInnerHTML={{__html: markdownToHTML1(item.choice_text)}}></span> */}
</div>) </div>)
})} })}

@ -70,10 +70,10 @@ class MainDisplay extends Component{
<div style={{color: '#05101A'}} className="font-16 mb5 font-bd">参考答案</div> <div style={{color: '#05101A'}} className="font-16 mb5 font-bd">参考答案</div>
<MarkdownToHtml content={standard_answer[0]} selector={'answer_' + qNumber} <MarkdownToHtml content={standard_answer[0]} selector={'answer_' + qNumber}
delay={true} className="" className=""
></MarkdownToHtml> ></MarkdownToHtml>
{/* <div className="mainQuestionDisplay markdown-body" {/* <div className="mainQuestionDisplay markdown-body"
dangerouslySetInnerHTML={{__html: markdownToHTML(standard_answer[0])}} dangerouslySetInnerHTML={{__html: markdownToHTML1(standard_answer[0])}}
> >
</div> */} </div> */}
</React.Fragment> </React.Fragment>

@ -109,7 +109,7 @@ class NullDisplay extends Component{
<div className="answers"> <div className="answers">
{ answers.answer_text.map((item, itemIndex) => { { answers.answer_text.map((item, itemIndex) => {
return <MarkdownToHtml return <MarkdownToHtml
className="answer" key={itemIndex} delay={true} className="answer" key={itemIndex}
content={item} selector={'null_' + (index + 1) + '' + (itemIndex + 1)} content={item} selector={'null_' + (index + 1) + '' + (itemIndex + 1)}
></MarkdownToHtml> ></MarkdownToHtml>
})} })}

@ -82,9 +82,9 @@ class QestionDisplayHeader extends Component{
</div> </div>
{ question_title && { question_title &&
<MarkdownToHtml content={question_title} selector={'qtitle_' + (index + 1)} style={{ display: 'inline-block', width:'100%' , margin: '10px 0px 15px' }} <MarkdownToHtml content={question_title} selector={'qtitle_' + (index + 1)} style={{ display: 'inline-block', width:'100%' , margin: '10px 0px 15px' }}
delay={true}
></MarkdownToHtml> ></MarkdownToHtml>
// <div className="markdown-body" dangerouslySetInnerHTML={{__html: markdownToHTML(question_title)}} // <div className="markdown-body" dangerouslySetInnerHTML={{__html: markdownToHTML1(question_title)}}
// style={{ display: 'inline-block', width:'100%' , margin: '10px 0px 15px' }}></div> // style={{ display: 'inline-block', width:'100%' , margin: '10px 0px 15px' }}></div>
} }
</React.Fragment> </React.Fragment>

@ -101,10 +101,10 @@ class SingleDisplay extends Component{
<div className="mb10 clearfix" key={optionIndex}> <div className="mb10 clearfix" key={optionIndex}>
<Radio disabled className="fl lineh-20" checked={item.standard_boolean}>{prefix}</Radio> <Radio disabled className="fl lineh-20" checked={item.standard_boolean}>{prefix}</Radio>
<MarkdownToHtml content={item.choice_text} selector={'single_' + (index + 1) + '' + (optionIndex + 1)} style={{ float: 'left', display: 'inline-block' }} <MarkdownToHtml content={item.choice_text} selector={'single_' + (index + 1) + '' + (optionIndex + 1)} style={{ float: 'left', display: 'inline-block' }}
delay={true}
></MarkdownToHtml> ></MarkdownToHtml>
{/* <span style={{ display: 'inline-block'}} className="markdown-body fl" {/* <span style={{ display: 'inline-block'}} className="markdown-body fl"
dangerouslySetInnerHTML={{__html: markdownToHTML(item.choice_text)}}></span> */} dangerouslySetInnerHTML={{__html: markdownToHTML1(item.choice_text)}}></span> */}
</div>) </div>)
} else { } else {
@ -112,10 +112,10 @@ class SingleDisplay extends Component{
<div className="mb10 clearfix" key={optionIndex}> <div className="mb10 clearfix" key={optionIndex}>
<Checkbox disabled className="fl lineh-20" checked={item.standard_boolean}>{prefix}</Checkbox> <Checkbox disabled className="fl lineh-20" checked={item.standard_boolean}>{prefix}</Checkbox>
<MarkdownToHtml content={item.choice_text} selector={'single_' + (index + 1)+ '' + (optionIndex + 1)} style={{ float: 'left', display: 'inline-block' }} <MarkdownToHtml content={item.choice_text} selector={'single_' + (index + 1)+ '' + (optionIndex + 1)} style={{ float: 'left', display: 'inline-block' }}
delay={true}
></MarkdownToHtml> ></MarkdownToHtml>
{/* <span style={{ display: 'inline-block'}} className="markdown-body fl" {/* <span style={{ display: 'inline-block'}} className="markdown-body fl"
dangerouslySetInnerHTML={{__html: markdownToHTML(item.choice_text)}}></span> */} dangerouslySetInnerHTML={{__html: markdownToHTML1(item.choice_text)}}></span> */}
</div>) </div>)
} }
})} })}

@ -1,6 +1,6 @@
import React,{ Component } from "react"; import React,{ Component } from "react";
import {Checkbox,Radio, Input} from "antd"; import {Checkbox,Radio, Input} from "antd";
import {DMDEditor,markdownToHTML } from 'educoder' import {DMDEditor,markdownToHTML, MarkdownToHtml } from 'educoder'
import axios from 'axios' import axios from 'axios'
@ -140,7 +140,10 @@ class fillEmpty extends Component{
{ {
item.answer_text && item.answer_text.map((i,index)=>{ item.answer_text && item.answer_text.map((i,index)=>{
return( return(
<div className="standardAnswer markdown-body answerStyle mb10" dangerouslySetInnerHTML={{__html: markdownToHTML(i)}}></div> <MarkdownToHtml content={i} selector={'empty_' + (this.props.index + 1) +(k + 1) + (index + 1)}
className="standardAnswer answerStyle mb10"
></MarkdownToHtml>
// <div className="standardAnswer markdown-body answerStyle mb10" dangerouslySetInnerHTML={{__html: markdownToHTML1(i)}}></div>
) )
}) })
} }

@ -1,6 +1,6 @@
import React,{ Component } from "react"; import React,{ Component } from "react";
import {Checkbox,Radio, Input} from "antd"; import {Checkbox,Radio, Input} from "antd";
import {markdownToHTML} from 'educoder' import {markdownToHTML, MarkdownToHtml} from 'educoder'
import axios from 'axios' import axios from 'axios'
const tagArray = [ const tagArray = [
@ -51,7 +51,10 @@ class Multiple extends Component{
<p className="clearfix mb15 df"> <p className="clearfix mb15 df">
<Checkbox className="fl lineh-20 " value={item.choice_id}>{prefix}</Checkbox> <Checkbox className="fl lineh-20 " value={item.choice_id}>{prefix}</Checkbox>
{/* <span class="fl lineh-20 mt1"></span> */} {/* <span class="fl lineh-20 mt1"></span> */}
<span style={{display:"inline-block"}} className="markdown-body " dangerouslySetInnerHTML={{__html: markdownToHTML(item.choice_text)}}></span> {/* <span style={{display:"inline-block"}} className="markdown-body " dangerouslySetInnerHTML={{__html: markdownToHTML1(item.choice_text)}}></span> */}
<MarkdownToHtml content={item.choice_text} selector={'multiple_' + (this.props.index + 1) + (key + 1)}
className="" style={{display:"inline-block"}}
></MarkdownToHtml>
</p> </p>
) )
}) })

@ -1,6 +1,6 @@
import React,{ Component } from "react"; import React,{ Component } from "react";
import {Checkbox,Radio, Input} from "antd"; import {Checkbox,Radio, Input} from "antd";
import {markdownToHTML} from 'educoder' import {markdownToHTML, MarkdownToHtml} from 'educoder'
import TPMMDEditor from '../../../../modules/tpm/challengesnew/TPMMDEditor' import TPMMDEditor from '../../../../modules/tpm/challengesnew/TPMMDEditor'
import axios from 'axios' import axios from 'axios'
@ -54,7 +54,10 @@ class simpleAnswer extends Component{
<li className="with100"> <li className="with100">
{ {
user_exercise_status == 1 ? user_exercise_status == 1 ?
<div className="markdown-body answerStyle" dangerouslySetInnerHTML={{__html: markdownToHTML(questionType.user_answer.length>0 ? questionType.user_answer[0]:"")}}></div> // <div className="markdown-body answerStyle" dangerouslySetInnerHTML={{__html: markdownToHTML1(questionType.user_answer.length>0 ? questionType.user_answer[0]:"")}}></div>
<MarkdownToHtml content={questionType.user_answer.length>0 ? questionType.user_answer[0]:""} selector={'simgle_' + (this.props.index + 1)}
className="answerStyle"
></MarkdownToHtml>
: :
<div> <div>
<TPMMDEditor ref={this.mdRef} initValue={questionType.user_answer.length > 0 ? questionType.user_answer[0]:''} mdID={'simpleEditor'+questionType.question_id} placeholder="请输入你的答案" <TPMMDEditor ref={this.mdRef} initValue={questionType.user_answer.length > 0 ? questionType.user_answer[0]:''} mdID={'simpleEditor'+questionType.question_id} placeholder="请输入你的答案"
@ -70,7 +73,10 @@ class simpleAnswer extends Component{
exercise.answer_status == 1 || questionType.a_flag ? exercise.answer_status == 1 || questionType.a_flag ?
<div className="standardAnswer"> <div className="standardAnswer">
<p className="mb10 font-16">参考答案</p> <p className="mb10 font-16">参考答案</p>
<li className="markdown-body answerStyle" dangerouslySetInnerHTML={{__html: markdownToHTML(questionType.standard_answer && questionType.standard_answer[0])}}></li> {/* <li className="markdown-body answerStyle" dangerouslySetInnerHTML={{__html: markdownToHTML1(questionType.standard_answer && questionType.standard_answer[0])}}></li> */}
<MarkdownToHtml content={questionType.standard_answer && questionType.standard_answer[0]} selector={'simgle_standard_' + (this.props.index + 1)}
className="answerStyle"
></MarkdownToHtml>
<p className="mt15"><a className="color-blue font-16" onClick={()=>this.showAndHide(false)}>隐藏参考答案</a></p> <p className="mt15"><a className="color-blue font-16" onClick={()=>this.showAndHide(false)}>隐藏参考答案</a></p>
</div> </div>
: :
@ -82,7 +88,10 @@ class simpleAnswer extends Component{
isStudent && exercise.answer_open==true && exercise.exercise_status == 3 ? isStudent && exercise.answer_open==true && exercise.exercise_status == 3 ?
<div className="bor-top-greyE pt20 mt20 standardAnswer"> <div className="bor-top-greyE pt20 mt20 standardAnswer">
<p>参考答案</p> <p>参考答案</p>
<li className="markdown-body answerStyle" dangerouslySetInnerHTML={{__html: markdownToHTML(questionType.standard_answer && questionType.standard_answer[0])}}></li> {/* <li className="markdown-body answerStyle" dangerouslySetInnerHTML={{__html: markdownToHTML1(questionType.standard_answer && questionType.standard_answer[0])}}></li> */}
<MarkdownToHtml content={questionType.standard_answer && questionType.standard_answer[0]} selector={'simgle_standard2_' + (this.props.index + 1)}
className="answerStyle"
></MarkdownToHtml>
</div>:"" </div>:""
} }
</div> </div>

@ -1,7 +1,7 @@
import React,{ Component } from "react"; import React,{ Component } from "react";
import {Checkbox,Radio, Input} from "antd"; import {Checkbox,Radio, Input} from "antd";
import {markdownToHTML} from 'educoder' import {markdownToHTML, MarkdownToHtml} from 'educoder'
import axios from 'axios' import axios from 'axios'
const tagArray = [ const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
@ -46,7 +46,10 @@ class single extends Component{
<p className={parseInt(questionType.question_type) == 0 ? "clearfix mb15 df" : "fl mr40"}> <p className={parseInt(questionType.question_type) == 0 ? "clearfix mb15 df" : "fl mr40"}>
<Radio className="fl lineh-20" value={item.choice_id}>{prefix}</Radio> <Radio className="fl lineh-20" value={item.choice_id}>{prefix}</Radio>
{/* <span className="fl lineh-20 mr3 "></span> */} {/* <span className="fl lineh-20 mr3 "></span> */}
<span style={{display:"inline-block", 'margin-top': '-1px'}} className="markdown-body fl " dangerouslySetInnerHTML={{__html: markdownToHTML(item.choice_text)}}></span> {/* <span style={{display:"inline-block", 'margin-top': '-1px'}} className="markdown-body fl " dangerouslySetInnerHTML={{__html: markdownToHTML1(item.choice_text)}}></span> */}
<MarkdownToHtml content={item.choice_text} selector={'single_' + (this.props.index + 1) + (key + 1)}
className="fl" style={{display:"inline-block", 'margin-top': '-1px'}}
></MarkdownToHtml>
</p> </p>
) )
}) })

Loading…
Cancel
Save