diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index c630abf7e..df3ad315b 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -46,7 +46,7 @@ debugType = "admin"; // 老师 // debugType="teacher"; // 学生 -//debugType="student"; +debugType="student"; diff --git a/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js b/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js index 337a9b7e9..9f60b3481 100644 --- a/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js +++ b/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js @@ -10,12 +10,13 @@ import moment from 'moment'; import { WordsBtn,markdownToHTML,ActionBtn,getImageUrl, MarkdownToHtml } from 'educoder'; import Modals from '../../modals/Modals'; import CoursesListType from '../coursesPublic/CoursesListType'; - +import QuillForEditor from "../../../common/quillForEditor"; import Multiple from './question/multiple'; import Single from './question/single'; import FillEmpty from './question/fillEmpty'; import SimpleAnswer from './question/simpleAnswer'; import ShixunAnswer from './question/shixunAnswer'; +import QuestionModalPicture from '../../question/component/QuestionModalPicture' import update from 'immutability-helper'; @@ -37,7 +38,7 @@ const tagArray = [ const $ = window.$; const statudmap={1:"未发布",2:"已发布",3:"已截止"} -const type=["单选题","多选题","判断题","填空题","简答题","实训题"] +const type=["单选题","多选题","判断题","填空题","简答题","实训题","编程题"] const format="YYYY-MM-DD HH:mm" class ExerciseReviewAndAnswer extends Component{ @@ -86,8 +87,12 @@ class ExerciseReviewAndAnswer extends Component{ // 加载效果 isSpin:false, // 调分数组 - ajustSore:undefined - } + ajustSore:undefined, + //是否是md编辑器 + is_md:false, + url: "", + + } } componentDidUpdate (prevProps) { // 需要等get_user_info执行完才能getInfo @@ -102,6 +107,18 @@ class ExerciseReviewAndAnswer extends Component{ //window.addEventListener('scroll', this.handleScroll); } + handleShowUploadImage = (url) => { + // console.log('==============>>>>>>>>>>>>',url); + // setUrl(url); + this.setState({ + url:url + }) + } + handleClose=()=>{ + this.setState({ + url:'', + }) + } remainTime=(time)=>{ // let { time } = this.state; @@ -206,6 +223,7 @@ class ExerciseReviewAndAnswer extends Component{ data:result.data, e_ReviewInfo:result.data, exercise:result.data.exercise, + is_md:result.data.exercise.is_md, exercise_types:result.data.exercise_scores.exercise_types, exercise_scores:result.data.exercise_scores, exercise_start_at:result.data.exercise_answer_user.start_at, @@ -633,7 +651,9 @@ class ExerciseReviewAndAnswer extends Component{ Loadtype, exerciseTotalScore, isSpin, - ajustSore + ajustSore, + is_md, + url }=this.state let isAdmin = this.props.isAdmin(); let isStudent =this.props.isStudent(); @@ -670,8 +690,15 @@ class ExerciseReviewAndAnswer extends Component{ .standardAnswer.editormd-html-preview,.answerStyle.editormd-html-preview{ width:100%!important } + .ql-editor{ + padding:0px !important + } `} - {/*

*/} + {url? + this.handleClose()}> + : + "" + } 0 && 实训题 {exercise_types.q_shixuns} 题,共 {exercise_types && exercise_types.q_shixuns_scores} 分 } + { + exercise_types && exercise_types.q_pros > 0 && + 编程题 {exercise_types.q_pros} 题,共 {exercise_types && exercise_types.q_pros_scores} 分 + } {exercise_types &&exercise_types.q_scores} 合计 {exercise_types &&exercise_types.q_counts} 题:

@@ -831,6 +862,28 @@ class ExerciseReviewAndAnswer extends Component{ { exercise_questions && exercise_questions.map((item,key)=>{ let list = ajustSore && ajustSore.filter(obj => obj.id === item.question_id); + let titename=""; + if(is_md===true){ + console.log(is_md); + titename=(item.question_type == 5 ? item.shixun_name : item.question_title); + }else{ + try { + titename = JSON.parse(item.question_title); + }catch (e) { + titename={"ops":[{"insert":item.question_title}]}; + } + if(titename===undefined){ + titename={"ops":[{"insert":item.question_title}]}; + } + try { + // JSON.parse 转换的时候如果是数字字符串就转成整数了 + if(titename>=0){ + titename={"ops":[{"insert":item.question_title}]}; + } + }catch (e) { + + } + } return(

@@ -869,9 +922,19 @@ class ExerciseReviewAndAnswer extends Component{

  • {/*

    */} - + { + is_md===true? + + : + + } +
  • { // 选择题和判断题共用 @@ -879,12 +942,14 @@ class ExerciseReviewAndAnswer extends Component{ this.changeOption(index,ids)} changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)} index={key} + handleShowUploadImage={(u)=>this.handleShowUploadImage(u)} > } { @@ -893,13 +958,14 @@ class ExerciseReviewAndAnswer extends Component{ this.changeOption(index,ids)} changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)} index={key} - + handleShowUploadImage={(u)=>this.handleShowUploadImage(u)} > } { @@ -910,10 +976,11 @@ class ExerciseReviewAndAnswer extends Component{ {...this.state} exercise={exercise} questionType={item} - user_exercise_status={user_exercise_status} + is_md={is_md} + user_exercise_status={user_exercise_status} changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)} index={key} - + handleShowUploadImage={(u)=>this.handleShowUploadImage(u)} > } { @@ -922,13 +989,15 @@ class ExerciseReviewAndAnswer extends Component{ this.changeQuestionStatus(No,flag)} changeA_flag={(index,status)=>this.changeA_flag(index,status)} index={key} - > + handleShowUploadImage={(u)=>this.handleShowUploadImage(u)} + > } { // 实训题 @@ -936,12 +1005,13 @@ class ExerciseReviewAndAnswer extends Component{ this.handleShowUploadImage(u)} > } diff --git a/public/react/src/modules/courses/exercise/question/multiple.js b/public/react/src/modules/courses/exercise/question/multiple.js index 2e1023faa..f5ba1f864 100644 --- a/public/react/src/modules/courses/exercise/question/multiple.js +++ b/public/react/src/modules/courses/exercise/question/multiple.js @@ -1,6 +1,7 @@ import React,{ Component } from "react"; import {Checkbox,Radio, Input} from "antd"; import {markdownToHTML, MarkdownToHtml} from 'educoder' +import QuillForEditor from "../../../../common/quillForEditor"; import axios from 'axios' const tagArray = [ @@ -33,29 +34,70 @@ class Multiple extends Component{ console.log(error); }) } - + render(){ - let { - questionType , + let { + questionType , exercise, - user_exercise_status + user_exercise_status, + is_md }=this.props let isStudent =this.props.isStudent(); console.log(questionType); return(
    + { questionType.question_choices && questionType.question_choices.map((item,key)=>{ let prefix = `${tagArray[key]}.` + let titename=""; + if(is_md===true){ + titename=item.choice_text; + }else{ + try { + titename = JSON.parse(item.choice_text); + }catch (e) { + titename={"ops":[{"insert":item.choice_text}]}; + } + // JSON.parse 有些异常数据是undefined + if(titename===undefined){ + titename={"ops":[{"insert":item.choice_text}]}; + } + try { + // JSON.parse 转换的时候如果是数字字符串就转成整数了 + if(titename>=0){ + titename={"ops":[{"insert":item.choice_text}]}; + } + }catch (e) { + } + } return(

    - + {prefix} - + { + is_md? + + : + + + }

    ) @@ -64,7 +106,7 @@ class Multiple extends Component{
    { // 答案公开,且试卷已经截止 - isStudent && exercise && exercise.answer_open==true && exercise.exercise_status == 3 && + isStudent && exercise && exercise.answer_open==true && exercise.exercise_status == 3 &&

    参考答案: {questionType.standard_answer.map((i,k)=>{ return( @@ -78,4 +120,4 @@ class Multiple extends Component{ ) } } -export default Multiple \ No newline at end of file +export default Multiple diff --git a/public/react/src/modules/courses/exercise/question/single.js b/public/react/src/modules/courses/exercise/question/single.js index e739b8f1c..e33aa9e4b 100644 --- a/public/react/src/modules/courses/exercise/question/single.js +++ b/public/react/src/modules/courses/exercise/question/single.js @@ -1,5 +1,6 @@ import React,{ Component } from "react"; import {Checkbox,Radio, Input} from "antd"; +import QuillForEditor from "../../../../common/quillForEditor"; import {markdownToHTML, MarkdownToHtml} from 'educoder' import axios from 'axios' @@ -30,36 +31,80 @@ class single extends Component{ }) } render(){ - let { - questionType , + let { + questionType , exercise, - user_exercise_status + user_exercise_status, + is_md }=this.props - + let isStudent =this.props.isStudent(); let isJudge = questionType.question_type == 2 return(

    + { questionType.question_choices && questionType.question_choices.map((item,key)=>{ let prefix = isJudge ? undefined : `${tagArray[key]}.` + + let titename=""; + if(is_md===true){ + titename=item.choice_text; + }else{ + try { + titename = JSON.parse(item.choice_text); + }catch (e) { + titename={"ops":[{"insert":item.choice_text}]}; + } + // JSON.parse 有些异常数据是undefined + if(titename===undefined){ + titename={"ops":[{"insert":item.choice_text}]}; + } + try { + // JSON.parse 转换的时候如果是数字字符串就转成整数了 + if(titename>=0){ + titename={"ops":[{"insert":item.choice_text}]}; + } + }catch (e) { + + } + } return(

    - + {prefix} - + { + is_md? + + : + + + } +

    ) }) }
    - { + { // 答案公开,且试卷已经截止 - isStudent && exercise && exercise.answer_open==true && (exercise.exercise_status == 3 || user_exercise_status == 1) && + isStudent && exercise && exercise.answer_open==true && (exercise.exercise_status == 3 || user_exercise_status == 1) &&

    参考答案: {questionType.standard_answer.map((i,k)=>{ return( @@ -73,4 +118,4 @@ class single extends Component{ ) } } -export default single \ No newline at end of file +export default single diff --git a/public/react/src/modules/question/component/Contentpart.js b/public/react/src/modules/question/component/Contentpart.js index 5cafe5937..06d563a55 100644 --- a/public/react/src/modules/question/component/Contentpart.js +++ b/public/react/src/modules/question/component/Contentpart.js @@ -18,7 +18,7 @@ import LoadingSpin from '../../../common/LoadingSpin'; import Contentquestionbank from "./Contentquestionbank"; import Listjihe from "./Listjihe"; import Certifiedprofessional from "../../modals/Certifiedprofessional"; -import QuestionModalPicture from '../component/QuestionModalPicture.js' +import QuestionModalPicture from '../component/QuestionModalPicture' const { TabPane } = Tabs; const Search = Input.Search; class Contentpart extends Component {