From 9ff41434fb5640d07c79f2d24a1ef0280d252087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 8 Jan 2020 16:23:09 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E9=A2=98=E5=B9=B2=20=E9=A2=98=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=20=E5=AD=97=E6=95=B0=E9=99=90=E5=88=B61000=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/question/component/ChoquesEditor.js | 8 ++++---- .../src/modules/question/component/JudquestionEditor.js | 8 ++++---- .../react/src/modules/question/component/SingleEditor.js | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/public/react/src/modules/question/component/ChoquesEditor.js b/public/react/src/modules/question/component/ChoquesEditor.js index c3412467d..8113322fb 100644 --- a/public/react/src/modules/question/component/ChoquesEditor.js +++ b/public/react/src/modules/question/component/ChoquesEditor.js @@ -277,8 +277,8 @@ class ChoquesEditor extends Component{ } else { // 提交到后台的内容需要处理一下; var texts=""; - if(_text.length>=101){ - var result = _text.substring(0,100); + if(_text.length>=1001){ + var result = _text.substring(0,1000); texts={"ops":[{"insert":result}]}; texts=JSON.stringify(texts); }else { @@ -301,8 +301,8 @@ class ChoquesEditor extends Component{ } else { // 提交到后台的内容需要处理一下; var texts=""; - if(_text.length>=101){ - var result = _text.substring(0,100); + if(_text.length>=1001){ + var result = _text.substring(0,1000); texts={"ops":[{"insert":result}]}; texts=JSON.stringify(texts); }else { diff --git a/public/react/src/modules/question/component/JudquestionEditor.js b/public/react/src/modules/question/component/JudquestionEditor.js index 08aa54955..65a80b8ab 100644 --- a/public/react/src/modules/question/component/JudquestionEditor.js +++ b/public/react/src/modules/question/component/JudquestionEditor.js @@ -289,8 +289,8 @@ class JudquestionEditor extends Component{ } else { // 提交到后台的内容需要处理一下; var texts=""; - if(_text.length>=101){ - var result = _text.substring(0,100); + if(_text.length>=1001){ + var result = _text.substring(0,1000); texts={"ops":[{"insert":result}]}; texts=JSON.stringify(texts); }else { @@ -313,8 +313,8 @@ class JudquestionEditor extends Component{ } else { // 提交到后台的内容需要处理一下; var texts=""; - if(_text.length>=101){ - var result = _text.substring(0,100); + if(_text.length>=1001){ + var result = _text.substring(0,1000); texts={"ops":[{"insert":result}]}; texts=JSON.stringify(texts); }else { diff --git a/public/react/src/modules/question/component/SingleEditor.js b/public/react/src/modules/question/component/SingleEditor.js index bf2c27b36..d7a326714 100644 --- a/public/react/src/modules/question/component/SingleEditor.js +++ b/public/react/src/modules/question/component/SingleEditor.js @@ -296,8 +296,8 @@ class SingleEditor extends Component{ } else { // 提交到后台的内容需要处理一下; var texts=""; - if(_text.length>=101){ - var result = _text.substring(0,100); + if(_text.length>=1001){ + var result = _text.substring(0,1000); texts={"ops":[{"insert":result}]}; texts=JSON.stringify(texts); }else { @@ -319,8 +319,8 @@ class SingleEditor extends Component{ }) } else { var texts=""; - if(_text.length>=101){ - var result = _text.substring(0,100); + if(_text.length>=1001){ + var result = _text.substring(0,1000); texts={"ops":[{"insert":result}]}; texts=JSON.stringify(texts); }else { From 84afe73ec8934272bb75e5d4cd790b3863cda42e Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Wed, 8 Jan 2020 16:28:08 +0800 Subject: [PATCH 2/4] add quill editor --- .../courses/exercise/new/SingleEditor.js | 74 +++++++++++++++++-- 1 file changed, 68 insertions(+), 6 deletions(-) diff --git a/public/react/src/modules/courses/exercise/new/SingleEditor.js b/public/react/src/modules/courses/exercise/new/SingleEditor.js index 0b1b7599a..8585e0a82 100644 --- a/public/react/src/modules/courses/exercise/new/SingleEditor.js +++ b/public/react/src/modules/courses/exercise/new/SingleEditor.js @@ -8,8 +8,9 @@ import { import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor'; import axios from 'axios' import update from 'immutability-helper' - import {getUrl, ActionBtn, DMDEditor, ConditionToolTip} from 'educoder'; +import QuillForEditor from "../../../../common/quillForEditor"; + const { TextArea } = Input; const confirm = Modal.confirm; const $ = window.$ @@ -47,6 +48,9 @@ class SingleEditor extends Component{ question_title: this.props.question_title || '', question_type: this.props.question_type || 0, question_score: this.props.question_score || this.props.init_question_score, + choice_editor: 'md', + quill_question_title: '', + quill_default_title: '' } } addOption = () => { @@ -205,8 +209,33 @@ class SingleEditor extends Component{ toShowMode = () => { } + + // 切换编辑器 + handleChangeEditor = (e) => { + const {quill_question_title} = this.state; + const value = e.target.value + if (value === 'quill') { + const _val = quill_question_title ? JSON.parse(quill_question_title) : ''; + this.setState({ + quill_default_title: _val + }) + } + this.setState({ + choice_editor: value + }); + } + + // quill编辑器内容变化时调用此接口 + handleCtxChange = (ctx) => { + console.log('编辑器内容', ctx); + // 保存编辑器内容 + this.setState({ + quill_question_title: JSON.stringify(ctx) + }); + } + render() { - let { question_title, question_score, question_type, question_choices, standard_answers } = this.state; + let { question_title, question_score, question_type, question_choices, standard_answers, choice_editor, quill_default_title } = this.state; let { question_id, index, exerciseIsPublish, // question_title, // question_type, @@ -245,18 +274,51 @@ class SingleEditor extends Component{ max-width: 1056px; word-break:break-all; } + .editor_area{ + display: inline-block; + float: right; + // line-height: 30px; + // height: 30px; + } + .editor_txt{ + margin-right: 10px; + font-size: 12px; + color: #999; + } + .radio_style{ + display: inline-block; + vertical: center; + } `}

{/* {!question_id ? '新建' : '编辑'} */} 选择题 (客观题,由系统自动评分,请设置标准答案) + {/* */} + {/*

+ 切换编辑器: + + MD + Quill + +
*/}

- this.setState({ question_title: val})} - ref="titleEditor" + {choice_editor === 'md' + ? this.setState({ question_title: val})} + ref="titleEditor" + > - > + : + } {question_choices.map( (item, index) => { const bg = standard_answers[index] ? 'check-option-bg' : '' From 598c2385e8153b0f9263b3d2097abb735cd5d459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 8 Jan 2020 16:40:06 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=AD=97=E6=95=B0=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/question/component/ChoquesEditor.js | 4 ++-- public/react/src/modules/question/component/SingleEditor.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/question/component/ChoquesEditor.js b/public/react/src/modules/question/component/ChoquesEditor.js index 8113322fb..1dc35ef4c 100644 --- a/public/react/src/modules/question/component/ChoquesEditor.js +++ b/public/react/src/modules/question/component/ChoquesEditor.js @@ -234,8 +234,8 @@ class ChoquesEditor extends Component{ // 处理编辑器内容为空 texts=""; } else { - if(_text.length>=101){ - var result = _text.substring(0,100); + if(_text.length>=301){ + var result = _text.substring(0,300); texts={"ops":[{"insert":result}]}; texts=JSON.stringify(texts); }else { diff --git a/public/react/src/modules/question/component/SingleEditor.js b/public/react/src/modules/question/component/SingleEditor.js index d7a326714..0b0a8b5f7 100644 --- a/public/react/src/modules/question/component/SingleEditor.js +++ b/public/react/src/modules/question/component/SingleEditor.js @@ -255,8 +255,8 @@ class SingleEditor extends Component{ // 处理编辑器内容为空 texts=""; } else { - if(_text.length>=101){ - var result = _text.substring(0,100); + if(_text.length>=301){ + var result = _text.substring(0,300); texts={"ops":[{"insert":result}]}; texts=JSON.stringify(texts); }else { From 9f6e038a3a14865256d0b558cbf61acd03e8731b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 8 Jan 2020 17:02:52 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E9=A2=98=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/question/component/Itembankstop.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/question/component/Itembankstop.js b/public/react/src/modules/question/component/Itembankstop.js index 5192eca4e..581baf844 100644 --- a/public/react/src/modules/question/component/Itembankstop.js +++ b/public/react/src/modules/question/component/Itembankstop.js @@ -413,6 +413,10 @@ class Itembankstop extends Component { } NewknTypedeldel=(bool)=>{ + if(this.state.rbkc===undefined || this.state.rbkc===null || this.state.rbkc===""){ + this.props.showNotification(`请选择课程方向`); + return; + } this.setState({ NewknTypedel:bool }) @@ -431,10 +435,6 @@ class Itembankstop extends Component { return } - if(this.state.rbkc===undefined || this.state.rbkc===null || this.state.rbkc===""){ - this.props.showNotification(`请选择课程方向`); - return; - } var data={ name:value, sub_discipline_id:this.state.rbkc[1]