清理未用到的quill编辑器

dev_aliyun2
harry 5 years ago
parent eb02258a54
commit 593cbfc1b8

@ -14019,6 +14019,24 @@
} }
} }
}, },
"showdown-katex": {
"version": "0.6.0",
"resolved": "https://registry.npm.taobao.org/showdown-katex/download/showdown-katex-0.6.0.tgz",
"integrity": "sha1-Jaq2qjH2DA/4aIwe2KcI6hgjqHQ=",
"requires": {
"katex": "^0.10.0"
},
"dependencies": {
"katex": {
"version": "0.10.2",
"resolved": "https://registry.npm.taobao.org/katex/download/katex-0.10.2.tgz",
"integrity": "sha1-OZc+27Ze2ltvnn9BZIeB5VfdSTI=",
"requires": {
"commander": "^2.19.0"
}
}
}
},
"signal-exit": { "signal-exit": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "http://registry.npm.taobao.org/signal-exit/download/signal-exit-3.0.2.tgz", "resolved": "http://registry.npm.taobao.org/signal-exit/download/signal-exit-3.0.2.tgz",

@ -52,6 +52,7 @@
"rsuite": "^4.0.1", "rsuite": "^4.0.1",
"scroll-into-view": "^1.12.3", "scroll-into-view": "^1.12.3",
"showdown": "^1.9.1", "showdown": "^1.9.1",
"showdown-katex": "^0.6.0",
"store": "^2.0.12", "store": "^2.0.12",
"styled-components": "^5.0.1", "styled-components": "^5.0.1",
"whatwg-fetch": "2.0.3", "whatwg-fetch": "2.0.3",

@ -10,8 +10,6 @@ import './index.less';
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Form, Button, Input } from 'antd'; import { Form, Button, Input } from 'antd';
import QuillForEditor from '../../quillForEditor'; import QuillForEditor from '../../quillForEditor';
// import { QuillDeltaToHtmlConverter } from 'quill-delta-to-html'
// import {formatDelta} from './util';
const FormItem = Form.Item; const FormItem = Form.Item;
function CommentForm(props) { function CommentForm(props) {

@ -7,10 +7,6 @@
* @LastEditTime : 2019-12-27 11:05:17 * @LastEditTime : 2019-12-27 11:05:17
*/ */
import './index.less'; import './index.less';
import 'quill/dist/quill.core.css'; // 核心样式
import 'quill/dist/quill.snow.css'; // 有工具栏
import 'quill/dist/quill.bubble.css'; // 无工具栏
import 'katex/dist/katex.min.css'; // katex 表达式样式
import React, { useState } from 'react'; import React, { useState } from 'react';
import CommentIcon from './CommentIcon'; import CommentIcon from './CommentIcon';
import { getImageUrl, CNotificationHOC } from 'educoder' import { getImageUrl, CNotificationHOC } from 'educoder'
@ -20,7 +16,6 @@ import QuillForEditor from '../../quillForEditor';
function CommentItem({ function CommentItem({
isAdmin, isAdmin,
options,
confirm, confirm,
comment, comment,
submitDeleteComment, submitDeleteComment,

@ -21,7 +21,6 @@ import ImageBlot from './ImageBlot';
import FillBlot from './FillBlot'; import FillBlot from './FillBlot';
const Size = Quill.import('attributors/style/size'); const Size = Quill.import('attributors/style/size');
const Font = Quill.import('formats/font'); const Font = Quill.import('formats/font');
// const Color = Quill.import('attributes/style/color');
Size.whitelist = ['12px', '14px', '16px', '18px', '20px', false]; Size.whitelist = ['12px', '14px', '16px', '18px', '20px', false];
Font.whitelist = ['SimSun', 'SimHei', 'Microsoft-YaHei', 'KaiTi', 'FangSong', 'Arial', 'Times-New-Roman', 'sans-serif']; Font.whitelist = ['SimSun', 'SimHei', 'Microsoft-YaHei', 'KaiTi', 'FangSong', 'Arial', 'Times-New-Roman', 'sans-serif'];
@ -30,11 +29,9 @@ window.katex = katex;
Quill.register(ImageBlot); Quill.register(ImageBlot);
Quill.register(Size); Quill.register(Size);
Quill.register(Font, true); Quill.register(Font, true);
// Quill.register({'modules/toolbar': Toolbar});
Quill.register({ Quill.register({
'formats/fill': FillBlot 'formats/fill': FillBlot
}); });
// Quill.register(Color);
function QuillForEditor({ function QuillForEditor({

@ -1,28 +1,22 @@
import React,{ Component } from "react"; import React, { Component } from "react";
import { import {
Form, Input, InputNumber, Switch, Radio, InputNumber, Tooltip
Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Tooltip
} from 'antd'; } from 'antd';
import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor'; import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
import axios from 'axios' import axios from 'axios'
import update from 'immutability-helper' import update from 'immutability-helper'
import {getUrl, ActionBtn, DMDEditor, ConditionToolTip} from 'educoder'; import { ActionBtn, DMDEditor, ConditionToolTip } from 'educoder';
import QuillForEditor from "../../../../common/quillForEditor"; import QuillForEditor from "../../../../common/quillForEditor";
const { TextArea } = Input;
const confirm = Modal.confirm;
const $ = window.$
const { Option } = Select;
const tagArray = [ const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
] ]
class SingleEditor extends Component{ class SingleEditor extends Component {
constructor(props){ constructor(props) {
super(props); super(props);
/** /**
choice_id: 32076 choice_id: 32076
@ -30,7 +24,7 @@ class SingleEditor extends Component{
choice_text: "1" choice_text: "1"
standard_boolean: true standard_boolean: true
*/ */
const {question_choices} = this.props; const { question_choices } = this.props;
let _standard_answers = undefined; let _standard_answers = undefined;
let _question_choices = undefined; let _question_choices = undefined;
if (question_choices) { if (question_choices) {
@ -60,25 +54,25 @@ class SingleEditor extends Component{
this.setState({ question_choices, standard_answers }) this.setState({ question_choices, standard_answers })
} }
deleteOption = (index) => { deleteOption = (index) => {
let {question_choices}=this.state; let { question_choices } = this.state;
if(question_choices[index]===""){ if (question_choices[index] === "") {
// repeat code // repeat code
this.toMDMode(null) this.toMDMode(null)
this.setState( this.setState(
(prevState) => ({ (prevState) => ({
question_choices : update(prevState.question_choices, {$splice: [[index, 1]]}), question_choices: update(prevState.question_choices, { $splice: [[index, 1]] }),
standard_answers : update(prevState.standard_answers, {$splice: [[index, 1]]}) standard_answers: update(prevState.standard_answers, { $splice: [[index, 1]] })
}) })
) )
}else{ } else {
this.props.confirm({ this.props.confirm({
content: `确认要删除这个选项吗?`, content: `确认要删除这个选项吗?`,
onOk: () => { onOk: () => {
this.toMDMode(null) this.toMDMode(null)
this.setState( this.setState(
(prevState) => ({ (prevState) => ({
question_choices : update(prevState.question_choices, {$splice: [[index, 1]]}), question_choices: update(prevState.question_choices, { $splice: [[index, 1]] }),
standard_answers : update(prevState.standard_answers, {$splice: [[index, 1]]}) standard_answers: update(prevState.standard_answers, { $splice: [[index, 1]] })
}) })
) )
} }
@ -86,11 +80,11 @@ class SingleEditor extends Component{
} }
} }
onSave = () => { onSave = () => {
const {question_title, question_score, question_type, question_choices, standard_answers } = this.state; const { question_title, question_score, question_type, question_choices, standard_answers } = this.state;
const { question_id_to_insert_after, question_id } = this.props const { question_id_to_insert_after, question_id } = this.props
// TODO check // TODO check
const answerArray = standard_answers.map((item, index) => { return item == true ? index+1 : -1 }).filter(item => item != -1); const answerArray = standard_answers.map((item, index) => { return item == true ? index + 1 : -1 }).filter(item => item != -1);
if(!question_title) { if (!question_title) {
this.refs['titleEditor'].showError() this.refs['titleEditor'].showError()
this.props.showNotification('题目:不能为空'); return; this.props.showNotification('题目:不能为空'); return;
@ -100,18 +94,18 @@ class SingleEditor extends Component{
const intScore = parseFloat(question_score) const intScore = parseFloat(question_score)
if (intScore == 0) { if (intScore == 0) {
this.props.showNotification('分值必须大于0'); return; this.props.showNotification('分值必须大于0'); return;
} else if(!question_score || intScore == NaN) { } else if (!question_score || intScore == NaN) {
this.props.showNotification('分值:不能为空'); return; this.props.showNotification('分值:不能为空'); return;
} }
if(!answerArray || answerArray.length == 0) { if (!answerArray || answerArray.length == 0) {
this.props.showNotification('请先点击选择本选择题的正确选项'); return; this.props.showNotification('请先点击选择本选择题的正确选项'); return;
} }
if(!question_title) { if (!question_title) {
this.refs['titleEditor'].showError() this.refs['titleEditor'].showError()
this.props.showNotification('题目:不能为空'); return; this.props.showNotification('题目:不能为空'); return;
} }
for(let i = 0; i < question_choices.length; i++) { for (let i = 0; i < question_choices.length; i++) {
if (!question_choices[i]) { if (!question_choices[i]) {
this.refs[`optionEditor${i}`].showError() this.refs[`optionEditor${i}`].showError()
this.props.showNotification(`请先输入 ${tagArray[i]} 选项的内容`); return; this.props.showNotification(`请先输入 ${tagArray[i]} 选项的内容`); return;
@ -138,9 +132,9 @@ class SingleEditor extends Component{
}).then((response) => { }).then((response) => {
if (response.data.status == 0) { if (response.data.status == 0) {
this.props.addSuccess() this.props.addSuccess()
}else if(response.data.status == 3){ } else if (response.data.status == 3) {
// 已发布试卷编辑保存 // 已发布试卷编辑保存
this.props.changeScore(question_id,answerArray); this.props.changeScore(question_id, answerArray);
} }
}) })
.catch(function (error) { .catch(function (error) {
@ -212,7 +206,7 @@ class SingleEditor extends Component{
// 切换编辑器 // 切换编辑器
handleChangeEditor = (e) => { handleChangeEditor = (e) => {
const {quill_question_title} = this.state; const { quill_question_title } = this.state;
const value = e.target.value const value = e.target.value
if (value === 'quill') { if (value === 'quill') {
const _val = quill_question_title ? JSON.parse(quill_question_title) : ''; const _val = quill_question_title ? JSON.parse(quill_question_title) : '';
@ -245,7 +239,7 @@ class SingleEditor extends Component{
// const { getFieldDecorator } = this.props.form; // const { getFieldDecorator } = this.props.form;
const isAdmin = this.props.isAdmin() const isAdmin = this.props.isAdmin()
const courseId=this.props.match.params.coursesId; const courseId = this.props.match.params.coursesId;
const isEdit = !!this.props.question_id const isEdit = !!this.props.question_id
const qNumber = `question_${index}`; const qNumber = `question_${index}`;
// TODO show模式 isNew为false isEdit为false // TODO show模式 isNew为false isEdit为false
@ -257,7 +251,7 @@ class SingleEditor extends Component{
console.log(answerTagArray); console.log(answerTagArray);
console.log(!exerciseIsPublish); console.log(!exerciseIsPublish);
return( return (
<div className="padding20-30 bor-bottom-greyE signleEditor" id={qNumber}> <div className="padding20-30 bor-bottom-greyE signleEditor" id={qNumber}>
<style>{` <style>{`
.optionMdEditor { .optionMdEditor {
@ -306,7 +300,7 @@ class SingleEditor extends Component{
{choice_editor === 'md' {choice_editor === 'md'
? <TPMMDEditor mdID={qNumber} placeholder="请您输入题目" height={155} className="mb20" ? <TPMMDEditor mdID={qNumber} placeholder="请您输入题目" height={155} className="mb20"
initValue={question_title} onChange={(val) => this.setState({ question_title: val})} initValue={question_title} onChange={(val) => this.setState({ question_title: val })}
ref="titleEditor" ref="titleEditor"
></TPMMDEditor> ></TPMMDEditor>
@ -320,20 +314,20 @@ class SingleEditor extends Component{
></QuillForEditor> ></QuillForEditor>
} }
{question_choices.map( (item, index) => { {question_choices.map((item, index) => {
const bg = standard_answers[index] ? 'check-option-bg' : '' const bg = standard_answers[index] ? 'check-option-bg' : ''
return <div className="df optionRow " > return <div className="df optionRow " >
{/* 点击设置答案 */} {/* 点击设置答案 */}
{/* TODO 加了tooltip后会丢失掉span的class */} {/* TODO 加了tooltip后会丢失掉span的class */}
{/* <Tooltip title={standard_answers[index] ? '点击取消标准答案设置' : '点击设置为标准答案'}> */} {/* <Tooltip title={standard_answers[index] ? '点击取消标准答案设置' : '点击设置为标准答案'}> */}
<span class={`option-item fr mr10 color-grey select-choice ${bg} `} <span class={`option-item fr mr10 color-grey select-choice ${bg} `}
name="option_span" onClick={() => this.onOptionClick(index)} style={{flex: '0 0 38px'}}> name="option_span" onClick={() => this.onOptionClick(index)} style={{ flex: '0 0 38px' }}>
<ConditionToolTip title={standard_answers[index] ? '点击取消标准答案设置' : '点击设置为标准答案'} placement="left" condition={true}> <ConditionToolTip title={standard_answers[index] ? '点击取消标准答案设置' : '点击设置为标准答案'} placement="left" condition={true}>
<div style={{width: '100%', height: '100%'}}>{tagArray[index]}</div> <div style={{ width: '100%', height: '100%' }}>{tagArray[index]}</div>
</ConditionToolTip> </ConditionToolTip>
</span> </span>
{/* </Tooltip> */} {/* </Tooltip> */}
<div style={{ flex: '0 0 1038px'}}> <div style={{ flex: '0 0 1038px' }}>
<DMDEditor <DMDEditor
ref={`optionEditor${index}`} ref={`optionEditor${index}`}
toMDMode={this.toMDMode} toShowMode={this.toShowMode} toMDMode={this.toMDMode} toShowMode={this.toShowMode}
@ -342,25 +336,25 @@ class SingleEditor extends Component{
initValue={item} initValue={item}
></DMDEditor> ></DMDEditor>
</div> </div>
{exerciseIsPublish || index===0? {exerciseIsPublish || index === 0 ?
<i className=" font-18 ml15 mr20"></i> <i className=" font-18 ml15 mr20"></i>
:<Tooltip title="删除"> : <Tooltip title="删除">
<i className="iconfont icon-htmal5icon19 font-18 color-grey-c ml15" onClick={() => this.deleteOption(index)}></i> <i className="iconfont icon-htmal5icon19 font-18 color-grey-c ml15" onClick={() => this.deleteOption(index)}></i>
</Tooltip> } </Tooltip>}
{ !exerciseIsPublish && <Tooltip title={`新增参考答案`}> {!exerciseIsPublish && <Tooltip title={`新增参考答案`}>
<i className="color-green font-16 iconfont icon-roundaddfill ml6" <i className="color-green font-16 iconfont icon-roundaddfill ml6"
onClick={() => this.addOption()} onClick={() => this.addOption()}
style={{float: 'right', visibility: index == question_choices.length - 1 ? '' : 'hidden', marginTop: '2px'}} style={{ float: 'right', visibility: index == question_choices.length - 1 ? '' : 'hidden', marginTop: '2px' }}
></i> ></i>
</Tooltip>} </Tooltip>}
</div> </div>
}) } })}
<div className="mb20"> <div className="mb20">
<span <span
style={{color: '#FF6800'}}>{'温馨提示:点击选项输入框可设置答案;选中的选项即为正确答案,选择多个答案即为多选题'}</span> style={{ color: '#FF6800' }}>{'温馨提示:点击选项输入框可设置答案;选中的选项即为正确答案,选择多个答案即为多选题'}</span>
{ answerTagArray && !!answerTagArray.length ? {answerTagArray && !!answerTagArray.length ?
<React.Fragment> <React.Fragment>
<span className="fr color-orange">{answerTagArray.join(' ')}</span> <span className="fr color-orange">{answerTagArray.join(' ')}</span>
<span className="fr">标准答案</span> <span className="fr">标准答案</span>
@ -372,7 +366,7 @@ class SingleEditor extends Component{
<div> <div>
分值 分值
<InputNumber step={0.1} precision={1} min={0} max={100} style={{width: 100}} value={question_score} onChange={this.on_question_score_change} <InputNumber step={0.1} precision={1} min={0} max={100} style={{ width: 100 }} value={question_score} onChange={this.on_question_score_change}
disabled={exerciseIsPublish} disabled={exerciseIsPublish}
></InputNumber>&nbsp; ></InputNumber>&nbsp;

@ -7,16 +7,13 @@
* @LastEditTime : 2020-02-05 13:26:58 * @LastEditTime : 2020-02-05 13:26:58
*/ */
import './index.less'; import './index.less';
// import 'katex/dist/katex.css';
import React from 'react'; import React from 'react';
import { Form, Input, Select, InputNumber, Button, Cascader, notification } from 'antd'; import { Form, Input, Select, InputNumber, Button, Cascader, notification } from 'antd';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import AddTestDemo from './AddTestDemo'; import AddTestDemo from './AddTestDemo';
// import QuillEditor from '../../../quillEditor';
import actions from '../../../../../redux/actions'; import actions from '../../../../../redux/actions';
import CONST from '../../../../../constants'; import CONST from '../../../../../constants';
import { toStore } from 'educoder'; // 保存和读取store值 import { toStore } from 'educoder'; // 保存和读取store值
// import Wrapper from '../../../../../common/reactQuill';
import QuillForEditor from '../../../../../common/quillForEditor'; import QuillForEditor from '../../../../../common/quillForEditor';
import KnowLedge from '../../../components/knowledge'; import KnowLedge from '../../../components/knowledge';
const scrollIntoView = require('scroll-into-view'); const scrollIntoView = require('scroll-into-view');
@ -462,17 +459,6 @@ class EditTab extends React.Component {
/> />
</FormItem> </FormItem>
{/* <FormItem
className={`input_area flex_50 flex_50_right`}
label={<span>{myLabel(jcLabel['openOrNot'], '社区:您的任务将向整个社会公开')}</span>}
validateStatus={ojFormValidate.openOrNot.validateStatus}
help={ojFormValidate.openOrNot.errMsg}
colon={ false }
>
<Select onChange={this.handleChangeOpenOrNot} value={`${ojForm.openOrNot}`}>
{getOptions('openOrNot')}
</Select>
</FormItem> */}
</Form> </Form>

@ -1,183 +0,0 @@
<!--
* @Description:
* @Author: tangjiang
* @Github:
* @Date: 2019-11-25 09:46:10
* @LastEditors: tangjiang
* @LastEditTime: 2019-11-25 10:10:11
-->
## Quill配置
### 容器
- css 或者 DOM元素
```
const editor = new Quill(container)
```
### 配置项
var options = {
debug: 'info',
modules: {
toolbar: '#toolbar' // toolbar为一个代码块在页面中指定所需要的工具
},
placeholder: '', //
readOnly: false,
theme: 'snow'
}
const editor = new Quill('#editor', options);
- 对应的接口模型
```
export interface QuillOptionsStatic {
debug?: string | boolean;
modules: StringMap;
placeholder?: string;
readOnly?: boolean;
theme?: string;
formats?: string[];
bounds?: HTMLElement | string;
scrollingContainer?: HTMLElement | string;
strict?: boolean;
}
```
### 格式化
<br> Inline </br>
- background 背景色
- bold 粗体
- color 颜色
- font 字体
- code 内联代码
- italic 斜体
- link 链接
- size 大小
- strike 删除线
- script 上标/下标
- underline 下划线
<br> Block </br>
- blockquote 引用
- header 标题
- indent 缩进
- list 列表
- align 对齐方式
- direction 文字方向
- code-block 代码块
<br> Embeds </br>
- formula 公式 (需要 Katex)
- image 图片
- video 视频
### Quill 常用模块
- 工具栏
- 键盘
- 历史记录
- 剪贴板
- 语法高量
<b> 用法 </b>
> 工具栏模块 [toolbar](src="https://quilljs.com/docs/modules/toolbar/")
modules: {
toolbar: {
container: '#toolbar',
xx: {}
}
}
> 键盘模块 [keyboard](src="https://quilljs.com/docs/modules/keyboard/")
modules: {
keyboard: {
bindings: {
tab: {
key: 9,
handler: function () {}
}
}
}
}
> 历史模块
负责记录模块负责处理Quill的撤销和重做
modules: {
history: {
delay: 2000, // 在2000毫秒内的更改将被合并为单次更改
maxStack: 500, // 历史记录撤销/重做堆栈的大小
userOnly: true // 仅撤销或重做用户的更改
}
}
> 剪贴板模块
处理 Quill 和外部应用程序之间的复制
modules: {
clipboard: {
matchers: [
['B', xx]
]
}
}
> 语法高亮模块
语法高亮模块通过自动检测和应用语法突出显示来增强代码块格式。该模块依赖 [highlight.js](url="https://highlightjs.org/") 库用作解析和格式化代码块。
hljs.configure({ // optionally configure hljs
languages: ['javascript', 'ruby', 'python']
});
var quill = new Quill('#editor', {
modules: {
syntax: true, // Include syntax module
toolbar: [['code-block']] // Include button in toolbar
},
theme: 'snow'
});
> 模块扩展
Quill 中的模块可以被扩展和重新注册,从而替换原始模块
var Clipboard = Quill.import('modules/clipboard');
var Delta = Quill.import('delta');
class PlainClipboard extends Clipboard {
convert(html = null) {
if (typeof html === 'string') {
this.container.innerHTML = html;
}
let text = this.container.innerText;
this.container.innerHTML = '';
return new Delta().insert(text);
}
}
Quill.register('modules/clipboard', PlainClipboard, true);
// Will be created with instance of PlainClipboard
var quill = new Quill('#editor');

@ -1,134 +0,0 @@
/*
* @Description: Quill 编辑器
* @Author: tangjiang
* @Github:
* @Date: 2019-11-25 09:46:03
* @LastEditors: tangjiang
* @LastEditTime: 2019-12-10 16:10:23
*/
// import 'quill/dist/quill.core.css';
// import 'quill/dist/quill.bubble.css';
// import 'quill/dist/quill.snow.css';
// import 'katex/dist/katex.css';
import './index.less';
import 'katex/dist/katex.min.css';
import React from 'react';
import katex from 'katex';
const Quill = require('quill');
// 将katex挂载到window上
window.katex = katex;
window.Quill = Quill;
// const Quill = window.Quill;
// 指定 Quill 默认配置项
const defaultOptions = [
[{ header: [1, 2, 3, 4, 5, 6, false] }], // 自定义标题大小
['bold', 'italic', 'underline', 'strike'], // 切换按钮
['blockquote', 'code-block'], // 代码块
[{ 'list': 'ordered' }, { 'list': 'bullet' }], // 列表
[{ 'script': 'sub' }, { 'script': 'super' }], // 上标/下标
[{ 'indent': '-1' }, { 'indent': '+1' }], // 减少缩进/缩进
[{ 'direction': 'rtl' }],
[{ 'size': ['small', 'large', 'huge', false] }], // 用户自定义下拉
[{ 'color': [] }, { 'background': [] }], // 字体颜色与背景色
[{ 'font': [] }, { 'align': [] }], // 字体与对齐方式
['formula', 'image', 'video'], // 数学公式、图片、视频
['clean'], // 清除格式
];
/**
* @description 抽取一个React编辑器组件基于Quill
* @class QuillEditor类
* @param [object] props 接收的属性
* props: {
* options: {} // 编辑器配置信息, 不传使用 defaultOptions, 传了的话 使用用户自定义的,
* placeholder: '' // 编辑器提示信息
* innerHtml: '', // 编辑器内容
* onEditorChange: '', // 编辑器内容改变时调用此方法, 返回更改的内容
* }
* @return [stirng] content 返回编辑器内容
*/
class QuillEditor extends React.Component {
state = {
quillEditor: null,
// quillOptions: defaultOptions
}
constructor(props) {
super(props);
this.editorRef = React.createRef(null);
}
componentDidMount() {
const { options, placeholder = '', readOnly = false } = this.props;
let { quillEditor } = this.state;
// console.log(placeholder);
const renderOptions = options || defaultOptions;
const editorOption = {
placeholder: placeholder,
modules: {
toolbar: renderOptions
},
readOnly,
theme: readOnly ? 'bubble' : 'snow',
}
// 实例化 Quill 编辑器
quillEditor = new Quill(this.editorRef.current, editorOption);
this.setState({
quillEditor: quillEditor
});
// 开启一个定时器读取 html初始时, 如果没有最多执行10次后自动清
let count = 0;
this.timer = setInterval(() => {
count++;
if (count >= 10 || this.props.htmlCtx) {
quillEditor.container.firstChild.innerHTML = this.props.htmlCtx || '';
clearInterval(this.timer);
this.timer = null;
}
}, 50);
// quillEditor.setText('<p>aaa</p>');
quillEditor.on('editor-change', this.handleQuillChange);
// console.log('====>>>', quillEditor);
}
// 处理quill事件 editor-change
/**
* @param [string] eventName 事件名
* @param [object] args 参数
*/
handleQuillChange = (eventName, ...args) => {
const { onEditorChange } = this.props;
// 获取编辑器内容
const innerHTML = this.state.quillEditor.container.firstChild.innerHTML;
onEditorChange && onEditorChange(innerHTML);
// if ('text-change' === eventName) {
// const {delta, oldDelta, source} = args;
// console.log('textChange', delta, oldDelta, source);
// } else if ('selection-change' === eventName) {
// const {range, oldRange, source} = args;
// console.log('selectionChange', range, oldRange, source);
// }
}
componentWillUnmount() {
// 删除事件监听
this.state.quillEditor.off(this.handleQuillChange);
}
render() {
const styles = this.props.style || {}
return (
<div
id="quill_editor"
style={styles}
className={'quill_editor_area'}
ref={this.editorRef}>
</div>
);
}
}
export default QuillEditor;

@ -6,15 +6,12 @@
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2020-01-02 14:23:43 * @LastEditTime : 2020-01-02 14:23:43
*/ */
import React, { useState, useEffect } from 'react'; import React, { useState } from 'react';
import {connect} from 'react-redux'; import { connect } from 'react-redux';
import MyMonacoEditor from '../../components/myMonacoEditor'; import MyMonacoEditor from '../../components/myMonacoEditor';
import ControlSetting from '../../components/controlSetting'; import ControlSetting from '../../components/controlSetting';
import actions from '../../../../redux/actions'; import actions from '../../../../redux/actions';
// import QuillForEditor from '../../../../common/quillForEditor';
// import TextArea from 'antd/lib/input/TextArea';
import { Input, Form, Button } from 'antd'; import { Input, Form, Button } from 'antd';
// import FormItem from 'antd/lib/form/FormItem';
const { TextArea } = Input; const { TextArea } = Input;
const FormItem = Form.Item; const FormItem = Form.Item;
const RightPane = (props) => { const RightPane = (props) => {
@ -33,33 +30,16 @@ const RightPane = (props) => {
updateNotice, updateNotice,
saveUserInputCode, saveUserInputCode,
restoreInitialCode, restoreInitialCode,
// saveOpacityType,
saveUserCodeForInterval, saveUserCodeForInterval,
addNotes, addNotes,
changeLoadingState changeLoadingState
} = props; } = props;
// const [editorCode, setEditorCode] = useState(editor_code || hack.code);
const [noteClazz, setNoteClazz] = useState('editor_nodte_area'); const [noteClazz, setNoteClazz] = useState('editor_nodte_area');
const [noteCount] = useState(5000); const [noteCount] = useState(5000);
// const [code, setCode] = useState(editor_code || hack.code);
// let initFlag = true;
// useEffect(() => {
// if (editor_code) {
// setEditorCode(editor_code);
// } else {
// setEditorCode(hack.code);
// }
// }, [hack, editor_code]);
const handleSubmitForm = () => { const handleSubmitForm = () => {
// 提交时, 先调用提交接口,提交成功后,循环调用测评接口
// saveOpacityType('submit');
submitUserCode(identifier, submitInput, 'submit'); submitUserCode(identifier, submitInput, 'submit');
// // 提交时,先调用评测接口, 评测通过后才调用保存接口
// updateCode(identifier, submitInput, 'submit');
} }
let timer = null; // 定时器 let timer = null; // 定时器
@ -141,7 +121,7 @@ const RightPane = (props) => {
<Form> <Form>
<FormItem> <FormItem>
{ {
getFieldDecorator('notes',{ getFieldDecorator('notes', {
rules: [ rules: [
{ required: true, message: '笔记不能为空' }, { required: true, message: '笔记不能为空' },
{ max: noteCount, message: `笔记最大字数为${noteCount}` } { max: noteCount, message: `笔记最大字数为${noteCount}` }
@ -166,7 +146,7 @@ const RightPane = (props) => {
identifier={identifier} identifier={identifier}
inputValue={input} inputValue={input}
onDebuggerCode={handleDebuggerCode} onDebuggerCode={handleDebuggerCode}
onSubmitForm={handleSubmitForm}/> onSubmitForm={handleSubmitForm} />
</div> </div>
); );
} }

@ -1,20 +1,8 @@
import React, {Component} from "react"; import React, { Component } from "react";
import {Link, NavLink} from 'react-router-dom'; import { markdownToHTML } from 'educoder';
import {WordsBtn, ActionBtn, getImageUrl, markdownToHTML} from 'educoder';
import axios from 'axios';
import { import {
notification,
Spin,
Table,
Pagination,
Drawer,
Input,
Button,
Breadcrumb,
Radio Radio
} from "antd"; } from "antd";
import Itembankstop from "./component/Itembankstop";
import NoneData from './component/NoneData';
import './questioncss/questioncom.css'; import './questioncss/questioncom.css';
import '../tpm/newshixuns/css/Newshixuns.css'; import '../tpm/newshixuns/css/Newshixuns.css';
import QuillForEditor from "../../common/quillForEditor"; import QuillForEditor from "../../common/quillForEditor";
@ -68,32 +56,32 @@ class Paperreview_single extends Component {
} }
render() { render() {
let {questions, totalscore, total, items} = this.state; let { questions, totalscore, total, items } = this.state;
let {objectsingle, indexx, paperreviewsingleindex, indexxy,name} = this.props; let { objectsingle, indexx, paperreviewsingleindex, indexxy, name } = this.props;
var itemssname=""; var itemssname = "";
try { try {
itemssname= JSON.parse(objectsingle.name); itemssname = JSON.parse(objectsingle.name);
}catch (e) { } catch (e) {
itemssname=objectsingle.name; itemssname = objectsingle.name;
} }
if(itemssname===undefined){ if (itemssname === undefined) {
itemssname=objectsingle.name itemssname = objectsingle.name
} }
var itemsnamesy=""; var itemsnamesy = "";
try { try {
itemsnamesy= JSON.parse(objectsingle&&objectsingle.program_attr&&objectsingle.program_attr.description); itemsnamesy = JSON.parse(objectsingle && objectsingle.program_attr && objectsingle.program_attr.description);
}catch (e) { } catch (e) {
itemsnamesy=objectsingle&&objectsingle.program_attr&&objectsingle.program_attr.description; itemsnamesy = objectsingle && objectsingle.program_attr && objectsingle.program_attr.description;
} }
return ( return (
<div key={indexxy} <div key={indexxy}
className={ "w100s borderwdswuh mb20 pd20 "} className={"w100s borderwdswuh mb20 pd20 "}
onMouseEnter={() => this.props.showparagraphs(indexxy,name)} style={{ onMouseEnter={() => this.props.showparagraphs(indexxy, name)} style={{
minHeight: "114px", minHeight: "114px",
}}> }}>
<style>{ <style>{
@ -142,28 +130,30 @@ class Paperreview_single extends Component {
} }
</style> </style>
{ {
objectsingle.item_type==="PROGRAM"? objectsingle.item_type === "PROGRAM" ?
<div className="w100s sortinxdirection"> <div className="w100s sortinxdirection">
<div className=" tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{wordBreak: "break-word", <div className=" tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{
minWidth:"32px" wordBreak: "break-word",
minWidth: "32px"
}} }}
> >
({objectsingle.score}) ({objectsingle.score})
</div> </div>
<div className="ml10 lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{wordBreak: "break-word"}} <div className="ml10 lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{ wordBreak: "break-word" }}
dangerouslySetInnerHTML={{__html: markdownToHTML(objectsingle.name).replace(/▁/g, "▁▁▁")}}> dangerouslySetInnerHTML={{ __html: markdownToHTML(objectsingle.name).replace(/▁/g, "▁▁▁") }}>
</div> </div>
</div> </div>
: :
<div className="w100s sortinxdirection"> <div className="w100s sortinxdirection">
<div className="tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{wordBreak: "break-word", <div className="tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{
minWidth:"32px" wordBreak: "break-word",
minWidth: "32px"
}} }}
> >
({objectsingle.score}) ({objectsingle.score})
</div> </div>
<div className="ml10 lh28 listjihetixingstit cretitlecolrlist programquill" style={{wordBreak: "break-word"}} <div className="ml10 lh28 listjihetixingstit cretitlecolrlist programquill" style={{ wordBreak: "break-word" }}
> >
<QuillForEditor <QuillForEditor
readOnly={true} readOnly={true}
@ -199,8 +189,8 @@ class Paperreview_single extends Component {
<p className="w100s listjihetixingstitssy sortinxdirection "> <p className="w100s listjihetixingstitssy sortinxdirection ">
<p className={"sortinxdirection mt15"}> <p className={"sortinxdirection mt15"}>
{ {
objectsingle&&objectsingle.program_attr&&objectsingle.program_attr.description? objectsingle && objectsingle.program_attr && objectsingle.program_attr.description ?
<p className="programquill" style={{wordBreak: "break-word"}} <p className="programquill" style={{ wordBreak: "break-word" }}
> >
<QuillForEditor <QuillForEditor
readOnly={true} readOnly={true}
@ -215,27 +205,27 @@ class Paperreview_single extends Component {
<p className="w100s listjihetixingstits verticallayout "> <p className="w100s listjihetixingstits verticallayout ">
{ {
objectsingle === undefined || objectsingle === null ? "" : objectsingle.choices.map((object, index) => { objectsingle === undefined || objectsingle === null ? "" : objectsingle.choices.map((object, index) => {
var string="" var string = ""
try { try {
string=JSON.parse(object.choice_text); string = JSON.parse(object.choice_text);
}catch (e) { } catch (e) {
string=object.choice_text; string = object.choice_text;
} }
return ( return (
<p key={index} className={index === 0 ? "sortinxdirection" : "sortinxdirection mt15"}> <p key={index} className={index === 0 ? "sortinxdirection" : "sortinxdirection mt15"}>
{tagArray[index]} {tagArray[index]}
<p className="programquills" style={{wordBreak: "break-word"}}> <p className="programquills" style={{ wordBreak: "break-word" }}>
{object ? {object ?
object.choice_text === undefined || object.choice_text=== null || object.choice_text === "" ? object.choice_text === undefined || object.choice_text === null || object.choice_text === "" ?
"" ""
: :
object.choice_text.length>0? object.choice_text.length > 0 ?
<QuillForEditor <QuillForEditor
readOnly={true} readOnly={true}
value={string} value={string}
/> />
:"" : ""
: :
"" ""
} }

@ -1,20 +1,10 @@
import React,{ Component } from "react"; import React, { Component } from "react";
import { import { Tooltip } from 'antd';
Form, Input, InputNumber, Switch, Radio,
Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Tooltip
} from 'antd';
import TPMMDEditor from '../../../modules/tpm/challengesnew/TPMMDEditor';
import axios from 'axios'
import update from 'immutability-helper' import update from 'immutability-helper'
import './../questioncss/questioncom.css'; import './../questioncss/questioncom.css';
import {getUrl, ActionBtn, DMDEditor, ConditionToolTip} from 'educoder'; import { ConditionToolTip } from 'educoder';
import QuillForEditor from '../../../common/quillForEditor'; import QuillForEditor from '../../../common/quillForEditor';
const { TextArea } = Input;
const confirm = Modal.confirm;
const $ = window.$
const { Option } = Select;
const tagArray = [ const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
@ -23,8 +13,8 @@ const tagArray = [
] ]
//题库的试卷 多选题 组件 //题库的试卷 多选题 组件
class ChoquesEditor extends Component{ class ChoquesEditor extends Component {
constructor(props){ constructor(props) {
super(props); super(props);
/** /**
choice_id: 32076 choice_id: 32076
@ -32,7 +22,7 @@ class ChoquesEditor extends Component{
choice_text: "1" choice_text: "1"
standard_boolean: true standard_boolean: true
*/ */
const {question_choices} = this.props; const { question_choices } = this.props;
let _standard_answers = undefined; let _standard_answers = undefined;
let _question_choices = undefined; let _question_choices = undefined;
if (question_choices) { if (question_choices) {
@ -44,15 +34,15 @@ class ChoquesEditor extends Component{
_question_choices.push(item.choice_text) _question_choices.push(item.choice_text)
}) })
} }
const choicescomy=[]; const choicescomy = [];
try { try {
if(this.props.item_banksedit){ if (this.props.item_banksedit) {
if(this.props.item_banksedit.choices){ if (this.props.item_banksedit.choices) {
this.props.item_banksedit.choices.forEach((item, index) => { this.props.item_banksedit.choices.forEach((item, index) => {
choicescomy.push({ choicescomy.push({
choice_text:item.choice_text, choice_text: item.choice_text,
standard_boolean:item.is_answer, standard_boolean: item.is_answer,
}) })
}) })
@ -65,19 +55,19 @@ class ChoquesEditor extends Component{
} }
} }
}catch (e) { } catch (e) {
} }
this.state = { this.state = {
question_choices: _question_choices || ['', '', '', ''], question_choices: _question_choices || ['', '', '', ''],
standard_answers: _standard_answers || [false, false, false, false], standard_answers: _standard_answers || [false, false, false, false],
question_title: this.props.question_title!==undefined?JSON.parse(this.props.question_title):"", question_title: this.props.question_title !== undefined ? JSON.parse(this.props.question_title) : "",
question_type: this.props.question_type || 0, question_type: this.props.question_type || 0,
question_score: this.props.question_score || this.props.init_question_score, question_score: this.props.question_score || this.props.init_question_score,
question_titles: this.props.question_titles!==undefined?JSON.parse(this.props.question_titles):"", question_titles: this.props.question_titles !== undefined ? JSON.parse(this.props.question_titles) : "",
question_titlesysl:this.props.question_titlesysl||'', question_titlesysl: this.props.question_titlesysl || '',
question_titleysl:this.props.question_title || '', question_titleysl: this.props.question_title || '',
item_banksedit:[], item_banksedit: [],
} }
} }
addOption = () => { addOption = () => {
@ -93,21 +83,21 @@ class ChoquesEditor extends Component{
this.setState({ question_choices, standard_answers }) this.setState({ question_choices, standard_answers })
} }
deleteOption = (index) => { deleteOption = (index) => {
let {question_choices}=this.state; let { question_choices } = this.state;
// //////console.log("deleteOption"); // //////console.log("deleteOption");
// //////console.log(question_choices); // //////console.log(question_choices);
if(question_choices[index]===""){ if (question_choices[index] === "") {
// repeat code // repeat code
this.toMDMode(null) this.toMDMode(null)
this.setState( this.setState(
(prevState) => ({ (prevState) => ({
question_choices : update(prevState.question_choices, {$splice: [[index, 1]]}), question_choices: update(prevState.question_choices, { $splice: [[index, 1]] }),
standard_answers : update(prevState.standard_answers, {$splice: [[index, 1]]}) standard_answers: update(prevState.standard_answers, { $splice: [[index, 1]] })
}) })
) )
}else{ } else {
// this.props.confirm({ // this.props.confirm({
// content: `确认要删除这个选项吗?`, // content: `确认要删除这个选项吗?`,
// onOk: () => { // onOk: () => {
@ -115,8 +105,8 @@ class ChoquesEditor extends Component{
this.toMDMode(null) this.toMDMode(null)
this.setState( this.setState(
(prevState) => ({ (prevState) => ({
question_choices : update(prevState.question_choices, {$splice: [[index, 1]]}), question_choices: update(prevState.question_choices, { $splice: [[index, 1]] }),
standard_answers : update(prevState.standard_answers, {$splice: [[index, 1]]}) standard_answers: update(prevState.standard_answers, { $splice: [[index, 1]] })
}) })
) )
@ -125,27 +115,27 @@ class ChoquesEditor extends Component{
} }
} }
onSave = () => { onSave = () => {
var editordata=[]; var editordata = [];
const {question_title, question_score,question_titleysl,question_titlesysl, question_type,question_titles, question_choices, standard_answers } = this.state; const { question_title, question_score, question_titleysl, question_titlesysl, question_type, question_titles, question_choices, standard_answers } = this.state;
const { question_id_to_insert_after, question_id } = this.props const { question_id_to_insert_after, question_id } = this.props
// TODO check // TODO check
const answerArray = standard_answers.map((item, index) => { return item == true ? index+1 : -1 }).filter(item => item != -1); const answerArray = standard_answers.map((item, index) => { return item == true ? index + 1 : -1 }).filter(item => item != -1);
if(!question_titleysl) { if (!question_titleysl) {
this.props.showNotification('请您输入题干'); this.props.showNotification('请您输入题干');
return editordata; return editordata;
} }
for(let i = 0; i < question_choices.length; i++) { for (let i = 0; i < question_choices.length; i++) {
if (!question_choices[i]) { if (!question_choices[i]) {
this.props.showNotification(`请先输入 ${tagArray[i]} 选项的内容`); this.props.showNotification(`请先输入 ${tagArray[i]} 选项的内容`);
return editordata; return editordata;
} }
} }
if(!answerArray || answerArray.length == 0) { if (!answerArray || answerArray.length == 0) {
this.props.showNotification('请先点击选择本选择题的正确选项'); this.props.showNotification('请先点击选择本选择题的正确选项');
return editordata; return editordata;
} }
if(!answerArray || answerArray.length < 2) { if (!answerArray || answerArray.length < 2) {
this.props.showNotification('多选题最小正确选项为2个'); this.props.showNotification('多选题最小正确选项为2个');
return editordata; return editordata;
} }
@ -161,7 +151,7 @@ class ChoquesEditor extends Component{
"question_choices":["a答案","b答案","c答案","d答案"], "question_choices":["a答案","b答案","c答案","d答案"],
"standard_answers":[1] "standard_answers":[1]
}*/ }*/
editordata=[question_titleysl,answerArray,question_choices,question_titlesysl]; editordata = [question_titleysl, answerArray, question_choices, question_titlesysl];
// question_title, // question_title,
// question_type: answerArray.length > 1 ? 1 : 0, // question_type: answerArray.length > 1 ? 1 : 0,
// question_score, // question_score,
@ -179,22 +169,22 @@ class ChoquesEditor extends Component{
componentDidMount = () => { componentDidMount = () => {
try { try {
this.props.getanswerMdRef(this); this.props.getanswerMdRef(this);
}catch (e) { } catch (e) {
} }
try { try {
this.setState({ this.setState({
item_banksedit:this.props.item_banksedit, item_banksedit: this.props.item_banksedit,
question_title: this.props.item_banksedit.name!==undefined?JSON.parse(this.props.item_banksedit.name):"", question_title: this.props.item_banksedit.name !== undefined ? JSON.parse(this.props.item_banksedit.name) : "",
question_titleysl:this.props.item_banksedit.name|| '', question_titleysl: this.props.item_banksedit.name || '',
question_titles: this.props.item_banksedit.analysis!==undefined?JSON.parse(this.props.item_banksedit.analysis):"", question_titles: this.props.item_banksedit.analysis !== undefined ? JSON.parse(this.props.item_banksedit.analysis) : "",
question_titlesysl:this.props.item_banksedit.analysis||'', question_titlesysl: this.props.item_banksedit.analysis || '',
mychoicess:this.props.item_banksedit.choices, mychoicess: this.props.item_banksedit.choices,
}) })
}catch (e) { } catch (e) {
} }
} }
@ -203,13 +193,13 @@ class ChoquesEditor extends Component{
// ////console.log(prevProps); // ////console.log(prevProps);
// ////console.log(this.props.item_banksedit); // ////console.log(this.props.item_banksedit);
if(prevProps.item_banksedit !== this.props.item_banksedit) { if (prevProps.item_banksedit !== this.props.item_banksedit) {
this.setState({ this.setState({
item_banksedit: this.props.item_banksedit, item_banksedit: this.props.item_banksedit,
question_title: this.props.item_banksedit.name!==undefined?JSON.parse(this.props.item_banksedit.name):"", question_title: this.props.item_banksedit.name !== undefined ? JSON.parse(this.props.item_banksedit.name) : "",
question_titleysl:this.props.item_banksedit.name|| '', question_titleysl: this.props.item_banksedit.name || '',
question_titles: this.props.item_banksedit.analysis!==undefined?JSON.parse(this.props.item_banksedit.analysis):"", question_titles: this.props.item_banksedit.analysis !== undefined ? JSON.parse(this.props.item_banksedit.analysis) : "",
question_titlesysl:this.props.item_banksedit.analysis||'', question_titlesysl: this.props.item_banksedit.analysis || '',
mychoicess: this.props.item_banksedit.choices, mychoicess: this.props.item_banksedit.choices,
}) })
@ -220,7 +210,7 @@ class ChoquesEditor extends Component{
standard_answers[index] = !standard_answers[index] standard_answers[index] = !standard_answers[index]
this.setState({ standard_answers }) this.setState({ standard_answers })
} }
onOptionContentChange = (value,quill,index) => { onOptionContentChange = (value, quill, index) => {
if (index >= this.state.question_choices.length) { if (index >= this.state.question_choices.length) {
// TODO 新建然后删除CD选项再输入题干会调用到这里且index是3 // TODO 新建然后删除CD选项再输入题干会调用到这里且index是3
return; return;
@ -230,16 +220,16 @@ class ChoquesEditor extends Component{
const reg = /^[\s\S]*.*[^\s][\s\S]*$/; const reg = /^[\s\S]*.*[^\s][\s\S]*$/;
if (!reg.test(_text)) { if (!reg.test(_text)) {
// 处理编辑器内容为空 // 处理编辑器内容为空
texts=""; texts = "";
} else {
if (_text.length >= 301) {
var result = _text.substring(0, 300);
texts = { "ops": [{ "insert": result }] };
texts = JSON.stringify(texts);
} else { } else {
if(_text.length>=301){
var result = _text.substring(0,300);
texts={"ops":[{"insert":result}]};
texts=JSON.stringify(texts);
}else {
// 提交到后台的内容需要处理一下; // 提交到后台的内容需要处理一下;
value = JSON.stringify(value); value = JSON.stringify(value);
texts=value; texts = value;
} }
} }
let question_choices = this.state.question_choices.slice(0); let question_choices = this.state.question_choices.slice(0);
@ -264,58 +254,58 @@ class ChoquesEditor extends Component{
} }
onContentChange=(value,quill)=>{ onContentChange = (value, quill) => {
const _text = quill.getText(); const _text = quill.getText();
const reg = /^[\s\S]*.*[^\s][\s\S]*$/; const reg = /^[\s\S]*.*[^\s][\s\S]*$/;
if (!reg.test(_text)) { if (!reg.test(_text)) {
// 处理编辑器内容为空 // 处理编辑器内容为空
this.setState({ this.setState({
question_titleysl:"" question_titleysl: ""
}) })
} else { } else {
// 提交到后台的内容需要处理一下; // 提交到后台的内容需要处理一下;
var texts=""; var texts = "";
if(_text.length>=1001){ if (_text.length >= 1001) {
var result = _text.substring(0,1000); var result = _text.substring(0, 1000);
texts={"ops":[{"insert":result}]}; texts = { "ops": [{ "insert": result }] };
texts=JSON.stringify(texts); texts = JSON.stringify(texts);
}else { } else {
value = JSON.stringify(value) value = JSON.stringify(value)
texts=value; texts = value;
} }
this.setState({ this.setState({
question_titleysl:texts question_titleysl: texts
}) })
} }
} }
onContentChanges=(value,quill)=>{ onContentChanges = (value, quill) => {
const _text = quill.getText(); const _text = quill.getText();
const reg = /^[\s\S]*.*[^\s][\s\S]*$/; const reg = /^[\s\S]*.*[^\s][\s\S]*$/;
if (!reg.test(_text)) { if (!reg.test(_text)) {
// 处理编辑器内容为空 // 处理编辑器内容为空
this.setState({ this.setState({
question_titlesysl:"" question_titlesysl: ""
}) })
} else { } else {
// 提交到后台的内容需要处理一下; // 提交到后台的内容需要处理一下;
var texts=""; var texts = "";
if(_text.length>=1001){ if (_text.length >= 1001) {
var result = _text.substring(0,1000); var result = _text.substring(0, 1000);
texts={"ops":[{"insert":result}]}; texts = { "ops": [{ "insert": result }] };
texts=JSON.stringify(texts); texts = JSON.stringify(texts);
}else { } else {
value = JSON.stringify(value) value = JSON.stringify(value)
texts=value; texts = value;
} }
this.setState({ this.setState({
question_titlesysl:texts question_titlesysl: texts
}) })
} }
} }
render() { render() {
let { question_title, question_score, question_type, question_choices, standard_answers,question_titles} = this.state; let { question_title, question_score, question_type, question_choices, standard_answers, question_titles } = this.state;
let { question_id, index, exerciseIsPublish, let { question_id, index, exerciseIsPublish,
// question_title, // question_title,
// question_type, // question_type,
@ -337,7 +327,7 @@ class ChoquesEditor extends Component{
// //////console.log(answerTagArray); // //////console.log(answerTagArray);
// //////console.log(!exerciseIsPublish); // //////console.log(!exerciseIsPublish);
return( return (
<div className="padding20-30 signleEditor duoxuano" id={qNumber}> <div className="padding20-30 signleEditor duoxuano" id={qNumber}>
<style>{` <style>{`
.optionMdEditor { .optionMdEditor {
@ -366,8 +356,8 @@ class ChoquesEditor extends Component{
<QuillForEditor <QuillForEditor
autoFocus={true} autoFocus={true}
imgAttrs={{width: '146px', height: '136px'}} imgAttrs={{ width: '146px', height: '136px' }}
style={{ height: '155px'}} style={{ height: '155px' }}
placeholder="请您输入题干" placeholder="请您输入题干"
options={['code-block', 'image', 'formula']} options={['code-block', 'image', 'formula']}
value={question_title} value={question_title}
@ -381,59 +371,59 @@ class ChoquesEditor extends Component{
<span className="xingtigans fl"><span className="xingtigan">答案选项</span></span> <span className="xingtigans fl"><span className="xingtigan">答案选项</span></span>
</div> </div>
{question_choices.map( (item, index) => { {question_choices.map((item, index) => {
const bg = standard_answers[index] ? 'check-option-bg' : '' const bg = standard_answers[index] ? 'check-option-bg' : ''
return <div key={index} className={index>0?"df optionRow mt15": "df optionRow"} > return <div key={index} className={index > 0 ? "df optionRow mt15" : "df optionRow"} >
{/* 点击设置答案 */} {/* 点击设置答案 */}
{/* TODO 加了tooltip后会丢失掉span的class */} {/* TODO 加了tooltip后会丢失掉span的class */}
{/* <Tooltip title={standard_answers[index] ? '点击取消标准答案设置' : '点击设置为标准答案'}> */} {/* <Tooltip title={standard_answers[index] ? '点击取消标准答案设置' : '点击设置为标准答案'}> */}
<span className={`option-item fr mr10 color-grey select-choice ${bg} `} <span className={`option-item fr mr10 color-grey select-choice ${bg} `}
name="option_span" onClick={() => this.onOptionClick(index)} style={{flex: '0 0 38px'}}> name="option_span" onClick={() => this.onOptionClick(index)} style={{ flex: '0 0 38px' }}>
<ConditionToolTip title={standard_answers[index] ? '点击取消标准答案设置' : '点击设置为标准答案'} placement="left" condition={true}> <ConditionToolTip title={standard_answers[index] ? '点击取消标准答案设置' : '点击设置为标准答案'} placement="left" condition={true}>
<div style={{width: '100%', height: '100%'}}>{tagArray[index]}</div> <div style={{ width: '100%', height: '100%' }}>{tagArray[index]}</div>
</ConditionToolTip> </ConditionToolTip>
</span> </span>
{/* </Tooltip> */} {/* </Tooltip> */}
<div style={{ flex: '0 0 1038px'}}> <div style={{ flex: '0 0 1038px' }}>
{ {
item===undefined||item===null||item===""? item === undefined || item === null || item === "" ?
<QuillForEditor <QuillForEditor
autoFocus={false} autoFocus={false}
imgAttrs={{width: '146px', height: '136px'}} imgAttrs={{ width: '146px', height: '136px' }}
style={{ height: '166px'}} style={{ height: '166px' }}
placeholder="请您输入题干" placeholder="请您输入题干"
options={['code-block', 'image', 'formula']} options={['code-block', 'image', 'formula']}
value={item} value={item}
onContentChange={(value,quill) => this.onOptionContentChange(value,quill,index)} onContentChange={(value, quill) => this.onOptionContentChange(value, quill, index)}
/> />
: :
<QuillForEditor <QuillForEditor
autoFocus={false} autoFocus={false}
imgAttrs={{width: '146px', height: '136px'}} imgAttrs={{ width: '146px', height: '136px' }}
style={{ height: '166px'}} style={{ height: '166px' }}
placeholder="请您输入题干" placeholder="请您输入题干"
options={['code-block', 'image', 'formula']} options={['code-block', 'image', 'formula']}
value={JSON.parse(item)} value={JSON.parse(item)}
onContentChange={(value,quill) => this.onOptionContentChange(value,quill,index)} onContentChange={(value, quill) => this.onOptionContentChange(value, quill, index)}
/> />
} }
</div> </div>
{exerciseIsPublish || index<=2? {exerciseIsPublish || index <= 2 ?
<i className=" font-18 ml15 mr20"></i> <i className=" font-18 ml15 mr20"></i>
:<Tooltip title="删除"> : <Tooltip title="删除">
<i className="iconfont icon-htmal5icon19 font-18 color-grey-c ml15" onClick={() => this.deleteOption(index)}></i> <i className="iconfont icon-htmal5icon19 font-18 color-grey-c ml15" onClick={() => this.deleteOption(index)}></i>
</Tooltip> } </Tooltip>}
{ !exerciseIsPublish && index<7 && <Tooltip title={`新增参考答案`}> {!exerciseIsPublish && index < 7 && <Tooltip title={`新增参考答案`}>
<i className="color-green font-16 iconfont icon-roundaddfill ml6" <i className="color-green font-16 iconfont icon-roundaddfill ml6"
onClick={() => this.addOption()} onClick={() => this.addOption()}
style={{float: 'right', visibility: index == question_choices.length - 1 ? '' : 'hidden', marginTop: '2px'}} style={{ float: 'right', visibility: index == question_choices.length - 1 ? '' : 'hidden', marginTop: '2px' }}
></i> ></i>
</Tooltip>} </Tooltip>}
</div> </div>
}) } })}
@ -449,8 +439,8 @@ class ChoquesEditor extends Component{
<div className="mt10"></div> <div className="mt10"></div>
<QuillForEditor <QuillForEditor
autoFocus={false} autoFocus={false}
imgAttrs={{width: '146px', height: '136px'}} imgAttrs={{ width: '146px', height: '136px' }}
style={{height: '166px' }} style={{ height: '166px' }}
placeholder="请您输入题目解析" placeholder="请您输入题目解析"
options={['code-block', 'image', 'formula']} options={['code-block', 'image', 'formula']}
value={question_titles} value={question_titles}

@ -1,22 +1,10 @@
import React,{ Component } from "react"; import React, { Component } from "react";
import { import { Radio } from 'antd';
Form, Input, InputNumber, Switch, Radio,
Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Tooltip
} from 'antd';
import TPMMDEditor from '../../../modules/tpm/challengesnew/TPMMDEditor';
import axios from 'axios'
import update from 'immutability-helper' import update from 'immutability-helper'
import './../questioncss/questioncom.css'; import './../questioncss/questioncom.css';
import {getUrl, ActionBtn, DMDEditor, ConditionToolTip} from 'educoder';
import QuillForEditor from '../../../common/quillForEditor'; import QuillForEditor from '../../../common/quillForEditor';
const { TextArea } = Input;
const confirm = Modal.confirm;
const $ = window.$
const { Option } = Select;
const tagArray = [ const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
@ -24,8 +12,8 @@ const tagArray = [
] ]
//题库的试卷 判断题 组件 //题库的试卷 判断题 组件
class JudquestionEditor extends Component{ class JudquestionEditor extends Component {
constructor(props){ constructor(props) {
super(props); super(props);
/** /**
choice_id: 32076 choice_id: 32076
@ -33,7 +21,7 @@ class JudquestionEditor extends Component{
choice_text: "1" choice_text: "1"
standard_boolean: true standard_boolean: true
*/ */
const {question_choices} = this.props; const { question_choices } = this.props;
let _standard_answers = undefined; let _standard_answers = undefined;
let _question_choices = undefined; let _question_choices = undefined;
if (question_choices) { if (question_choices) {
@ -48,15 +36,15 @@ class JudquestionEditor extends Component{
this.state = { this.state = {
question_choices: _question_choices || ['', '', '', ''], question_choices: _question_choices || ['', '', '', ''],
standard_answers: _standard_answers || [false, false, false, false], standard_answers: _standard_answers || [false, false, false, false],
question_title: this.props.question_title!==undefined?JSON.parse(this.props.question_title):"", question_title: this.props.question_title !== undefined ? JSON.parse(this.props.question_title) : "",
question_type: this.props.question_type || 0, question_type: this.props.question_type || 0,
question_score: this.props.question_score || this.props.init_question_score, question_score: this.props.question_score || this.props.init_question_score,
question_titles: this.props.question_titles!==undefined?JSON.parse(this.props.question_titles):"", question_titles: this.props.question_titles !== undefined ? JSON.parse(this.props.question_titles) : "",
question_titlesysl:this.props.question_titlesysl||'', question_titlesysl: this.props.question_titlesysl || '',
question_titleysl:this.props.question_title || '', question_titleysl: this.props.question_title || '',
zqda:null, zqda: null,
item_banksedit:[], item_banksedit: [],
mychoicess:[], mychoicess: [],
} }
} }
addOption = () => { addOption = () => {
@ -72,29 +60,29 @@ class JudquestionEditor extends Component{
this.setState({ question_choices, standard_answers }) this.setState({ question_choices, standard_answers })
} }
deleteOption = (index) => { deleteOption = (index) => {
let {question_choices}=this.state; let { question_choices } = this.state;
// ////////console.log("deleteOption"); // ////////console.log("deleteOption");
// ////////console.log(question_choices); // ////////console.log(question_choices);
if(question_choices[index]===""){ if (question_choices[index] === "") {
// repeat code // repeat code
this.toMDMode(null) this.toMDMode(null)
this.setState( this.setState(
(prevState) => ({ (prevState) => ({
question_choices : update(prevState.question_choices, {$splice: [[index, 1]]}), question_choices: update(prevState.question_choices, { $splice: [[index, 1]] }),
standard_answers : update(prevState.standard_answers, {$splice: [[index, 1]]}) standard_answers: update(prevState.standard_answers, { $splice: [[index, 1]] })
}) })
) )
}else{ } else {
this.props.confirm({ this.props.confirm({
content: `确认要删除这个选项吗?`, content: `确认要删除这个选项吗?`,
onOk: () => { onOk: () => {
this.toMDMode(null) this.toMDMode(null)
this.setState( this.setState(
(prevState) => ({ (prevState) => ({
question_choices : update(prevState.question_choices, {$splice: [[index, 1]]}), question_choices: update(prevState.question_choices, { $splice: [[index, 1]] }),
standard_answers : update(prevState.standard_answers, {$splice: [[index, 1]]}) standard_answers: update(prevState.standard_answers, { $splice: [[index, 1]] })
}) })
) )
} }
@ -102,17 +90,17 @@ class JudquestionEditor extends Component{
} }
} }
onSave = () => { onSave = () => {
var editordata=[]; var editordata = [];
const {question_title, question_score,question_titleysl,question_titlesysl, question_type,question_titles, zqda,question_choices, standard_answers } = this.state; const { question_title, question_score, question_titleysl, question_titlesysl, question_type, question_titles, zqda, question_choices, standard_answers } = this.state;
const { question_id_to_insert_after, question_id } = this.props const { question_id_to_insert_after, question_id } = this.props
// TODO check // TODO check
const answerArray = standard_answers.map((item, index) => { return item == true ? index+1 : -1 }).filter(item => item != -1); const answerArray = standard_answers.map((item, index) => { return item == true ? index + 1 : -1 }).filter(item => item != -1);
if(!question_titleysl) { if (!question_titleysl) {
this.props.showNotification('请您输入题干'); this.props.showNotification('请您输入题干');
return editordata; return editordata;
} }
if(zqda===null) { if (zqda === null) {
this.props.showNotification('请先点击选择本选择题的正确选项'); this.props.showNotification('请先点击选择本选择题的正确选项');
return editordata; return editordata;
} }
@ -134,7 +122,7 @@ class JudquestionEditor extends Component{
}*/ }*/
editordata=[question_titleysl,zqda,question_titlesysl]; editordata = [question_titleysl, zqda, question_titlesysl];
// question_title, // question_title,
// question_type: answerArray.length > 1 ? 1 : 0, // question_type: answerArray.length > 1 ? 1 : 0,
// question_score, // question_score,
@ -152,39 +140,39 @@ class JudquestionEditor extends Component{
componentDidMount = () => { componentDidMount = () => {
try { try {
this.props.getanswerMdRef(this); this.props.getanswerMdRef(this);
}catch (e) { } catch (e) {
} }
try { try {
this.setState({ this.setState({
item_banksedit:this.props.item_banksedit, item_banksedit: this.props.item_banksedit,
question_title: this.props.item_banksedit.name!==undefined?JSON.parse(this.props.item_banksedit.name):"", question_title: this.props.item_banksedit.name !== undefined ? JSON.parse(this.props.item_banksedit.name) : "",
question_titles: this.props.item_banksedit.analysis!==undefined?JSON.parse(this.props.item_banksedit.analysis):"", question_titles: this.props.item_banksedit.analysis !== undefined ? JSON.parse(this.props.item_banksedit.analysis) : "",
mychoicess:this.props.item_banksedit.choices, mychoicess: this.props.item_banksedit.choices,
question_titleysl:this.props.item_banksedit.name|| '', question_titleysl: this.props.item_banksedit.name || '',
question_titlesysl:this.props.item_banksedit.analysis||'', question_titlesysl: this.props.item_banksedit.analysis || '',
}) })
if(this.props.item_banksedit){ if (this.props.item_banksedit) {
if(this.props.item_banksedit.choices){ if (this.props.item_banksedit.choices) {
for(var ik=0;ik<this.props.item_banksedit.choices.length;ik++ ){ for (var ik = 0; ik < this.props.item_banksedit.choices.length; ik++) {
if( this.props.item_banksedit.choices[ik].choice_text==="正确"){ if (this.props.item_banksedit.choices[ik].choice_text === "正确") {
if( this.props.item_banksedit.choices[ik].is_answer===true){ if (this.props.item_banksedit.choices[ik].is_answer === true) {
this.setState({ this.setState({
zqda:"0" zqda: "0"
}) })
} }
}else{ } else {
if( this.props.item_banksedit.choices[ik].is_answer===true){ if (this.props.item_banksedit.choices[ik].is_answer === true) {
this.setState({ this.setState({
zqda:"1" zqda: "1"
}) })
} }
} }
} }
} }
} }
}catch (e) { } catch (e) {
} }
} }
@ -194,30 +182,30 @@ class JudquestionEditor extends Component{
////console.log(prevProps); ////console.log(prevProps);
////console.log(this.props.item_banksedit); ////console.log(this.props.item_banksedit);
if(prevProps.item_banksedit !== this.props.item_banksedit){ if (prevProps.item_banksedit !== this.props.item_banksedit) {
this.setState({ this.setState({
item_banksedit:this.props.item_banksedit, item_banksedit: this.props.item_banksedit,
question_title: this.props.item_banksedit.name!==undefined?JSON.parse(this.props.item_banksedit.name):"", question_title: this.props.item_banksedit.name !== undefined ? JSON.parse(this.props.item_banksedit.name) : "",
question_titles: this.props.item_banksedit.analysis!==undefined?JSON.parse(this.props.item_banksedit.analysis):"", question_titles: this.props.item_banksedit.analysis !== undefined ? JSON.parse(this.props.item_banksedit.analysis) : "",
mychoicess:this.props.item_banksedit.choices, mychoicess: this.props.item_banksedit.choices,
question_titleysl:this.props.item_banksedit.name|| '', question_titleysl: this.props.item_banksedit.name || '',
question_titlesysl:this.props.item_banksedit.analysis||'', question_titlesysl: this.props.item_banksedit.analysis || '',
}) })
if(this.props.item_banksedit){ if (this.props.item_banksedit) {
if(this.props.item_banksedit.choices){ if (this.props.item_banksedit.choices) {
for(var ik=0;ik<this.props.item_banksedit.choices.length;ik++ ){ for (var ik = 0; ik < this.props.item_banksedit.choices.length; ik++) {
if( this.props.item_banksedit.choices[ik].choice_text==="正确"){ if (this.props.item_banksedit.choices[ik].choice_text === "正确") {
if( this.props.item_banksedit.choices[ik].is_answer===true){ if (this.props.item_banksedit.choices[ik].is_answer === true) {
this.setState({ this.setState({
zqda:"0" zqda: "0"
}) })
} }
}else{ } else {
if( this.props.item_banksedit.choices[ik].is_answer===true){ if (this.props.item_banksedit.choices[ik].is_answer === true) {
this.setState({ this.setState({
zqda:"1" zqda: "1"
}) })
} }
} }
@ -234,10 +222,10 @@ class JudquestionEditor extends Component{
// ////////console.log(standard_answers); // ////////console.log(standard_answers);
// ////////console.log(standard_answers[index]); // ////////console.log(standard_answers[index]);
// ////////console.log(!standard_answers[index]); // ////////console.log(!standard_answers[index]);
for (var i=0;i<standard_answers.length;i++){ for (var i = 0; i < standard_answers.length; i++) {
if(index===i){ if (index === i) {
standard_answers[index] = true; standard_answers[index] = true;
}else{ } else {
standard_answers[i] = false; standard_answers[i] = false;
} }
@ -271,66 +259,66 @@ class JudquestionEditor extends Component{
} }
handleFormLayoutChange=(e)=>{ handleFormLayoutChange = (e) => {
////////console.log("难度塞选"); ////////console.log("难度塞选");
////////console.log(value); ////////console.log(value);
this.setState({ this.setState({
zqda:e.target.value, zqda: e.target.value,
}) })
} }
onContentChange=(value,quill)=>{ onContentChange = (value, quill) => {
const _text = quill.getText(); const _text = quill.getText();
const reg = /^[\s\S]*.*[^\s][\s\S]*$/; const reg = /^[\s\S]*.*[^\s][\s\S]*$/;
if (!reg.test(_text)) { if (!reg.test(_text)) {
// 处理编辑器内容为空 // 处理编辑器内容为空
this.setState({ this.setState({
question_titleysl:"" question_titleysl: ""
}) })
} else { } else {
// 提交到后台的内容需要处理一下; // 提交到后台的内容需要处理一下;
var texts=""; var texts = "";
if(_text.length>=1001){ if (_text.length >= 1001) {
var result = _text.substring(0,1000); var result = _text.substring(0, 1000);
texts={"ops":[{"insert":result}]}; texts = { "ops": [{ "insert": result }] };
texts=JSON.stringify(texts); texts = JSON.stringify(texts);
}else { } else {
value = JSON.stringify(value) value = JSON.stringify(value)
texts=value; texts = value;
} }
this.setState({ this.setState({
question_titleysl:texts question_titleysl: texts
}) })
} }
} }
onContentChanges=(value,quill)=>{ onContentChanges = (value, quill) => {
const _text = quill.getText(); const _text = quill.getText();
const reg = /^[\s\S]*.*[^\s][\s\S]*$/; const reg = /^[\s\S]*.*[^\s][\s\S]*$/;
if (!reg.test(_text)) { if (!reg.test(_text)) {
// 处理编辑器内容为空 // 处理编辑器内容为空
this.setState({ this.setState({
question_titlesysl:"" question_titlesysl: ""
}) })
} else { } else {
// 提交到后台的内容需要处理一下; // 提交到后台的内容需要处理一下;
var texts=""; var texts = "";
if(_text.length>=1001){ if (_text.length >= 1001) {
var result = _text.substring(0,1000); var result = _text.substring(0, 1000);
texts={"ops":[{"insert":result}]}; texts = { "ops": [{ "insert": result }] };
texts=JSON.stringify(texts); texts = JSON.stringify(texts);
}else { } else {
value =JSON.stringify(value); value = JSON.stringify(value);
texts=value; texts = value;
} }
this.setState({ this.setState({
question_titlesysl:texts question_titlesysl: texts
}) })
} }
} }
render() { render() {
let { question_title, question_score, question_type, question_choices, standard_answers,question_titles} = this.state; let { question_title, question_score, question_type, question_choices, standard_answers, question_titles } = this.state;
let { question_id, index, exerciseIsPublish, let { question_id, index, exerciseIsPublish,
// question_title, // question_title,
// question_type, // question_type,
@ -351,8 +339,8 @@ class JudquestionEditor extends Component{
// ////////console.log("xuanzheshijuan"); // ////////console.log("xuanzheshijuan");
// ////////console.log(answerTagArray); // ////////console.log(answerTagArray);
// ////////console.log(!exerciseIsPublish); // ////////console.log(!exerciseIsPublish);
const params= this.props&&this.props.match&&this.props.match.params; const params = this.props && this.props.match && this.props.match.params;
return( return (
<div className="padding20-30 signleEditor danxuano" id={qNumber}> <div className="padding20-30 signleEditor danxuano" id={qNumber}>
<style>{` <style>{`
.optionMdEditor { .optionMdEditor {
@ -381,8 +369,8 @@ class JudquestionEditor extends Component{
<QuillForEditor <QuillForEditor
autoFocus={true} autoFocus={true}
imgAttrs={{width: '146px', height: '136px'}} imgAttrs={{ width: '146px', height: '136px' }}
style={{ height: '155px'}} style={{ height: '155px' }}
placeholder="请您输入题干" placeholder="请您输入题干"
options={['code-block', 'image', 'formula']} options={['code-block', 'image', 'formula']}
value={question_title} value={question_title}
@ -431,8 +419,8 @@ class JudquestionEditor extends Component{
<QuillForEditor <QuillForEditor
autoFocus={false} autoFocus={false}
imgAttrs={{width: '146px', height: '136px'}} imgAttrs={{ width: '146px', height: '136px' }}
style={{height: '166px' }} style={{ height: '166px' }}
placeholder="请您输入题目解析" placeholder="请您输入题目解析"
options={['code-block', 'image', 'formula']} options={['code-block', 'image', 'formula']}
value={question_titles} value={question_titles}

@ -1,12 +1,6 @@
import React, {Component} from "react"; import React, { Component } from "react";
import {Link, NavLink} from 'react-router-dom'; import { markdownToHTML } from 'educoder';
import {WordsBtn, ActionBtn, SnackbarHOC, getImageUrl, markdownToHTML} from 'educoder';
import axios from 'axios';
import { import {
notification,
Spin,
Table,
Pagination,
Radio, Radio,
Tooltip Tooltip
} from "antd"; } from "antd";
@ -64,8 +58,8 @@ class Listjihe extends Component {
render() { render() {
let {page, name, nd} = this.state; let { page, name, nd } = this.state;
let {defaultActiveKey, items, listjihe, chakanjiexiboolindex, keindex} = this.props; let { defaultActiveKey, items, listjihe, chakanjiexiboolindex, keindex } = this.props;
// 编程答案 // 编程答案
var rightkey = null var rightkey = null
@ -90,17 +84,17 @@ class Listjihe extends Component {
} }
} else { } else {
// 单选题和判断题 // 单选题和判断题
if(items.item_type === "MULTIPLE"){ if (items.item_type === "MULTIPLE") {
if (items.choices) { if (items.choices) {
if (items.choices.length > 0) { if (items.choices.length > 0) {
var arr = items.choices; var arr = items.choices;
for (var i = 0; i < arr.length; i++) { for (var i = 0; i < arr.length; i++) {
if (arr[i].is_answer === true) { if (arr[i].is_answer === true) {
if(MULTIPLEkey===null){ if (MULTIPLEkey === null) {
MULTIPLEkey = tagArrays[i]; MULTIPLEkey = tagArrays[i];
}else{ } else {
MULTIPLEkey =MULTIPLEkey+ tagArrays[i]; MULTIPLEkey = MULTIPLEkey + tagArrays[i];
} }
} }
@ -108,7 +102,7 @@ class Listjihe extends Component {
} }
} }
}else{ } else {
if (items.choices) { if (items.choices) {
if (items.choices.length > 0) { if (items.choices.length > 0) {
var arr = items.choices; var arr = items.choices;
@ -126,30 +120,30 @@ class Listjihe extends Component {
} }
} }
var itemssname=""; var itemssname = "";
try { try {
itemssname= JSON.parse(items.name); itemssname = JSON.parse(items.name);
}catch (e) { } catch (e) {
} }
if(itemssname===undefined){ if (itemssname === undefined) {
itemssname=items.name itemssname = items.name
} }
var itemsnamesy=""; var itemsnamesy = "";
try { try {
itemsnamesy= JSON.parse(items&&items.program_attr&&items.program_attr.description); itemsnamesy = JSON.parse(items && items.program_attr && items.program_attr.description);
}catch (e) { } catch (e) {
itemsnamesy=items&&items.program_attr&&items.program_attr.description; itemsnamesy = items && items.program_attr && items.program_attr.description;
} }
var analysisnames=""; var analysisnames = "";
try { try {
analysisnames= JSON.parse(items&&items.analysis); analysisnames = JSON.parse(items && items.analysis);
}catch (e) { } catch (e) {
analysisnames=items&&items.analysis; analysisnames = items && items.analysis;
} }
return ( return (
@ -179,22 +173,22 @@ class Listjihe extends Component {
}. }.
</div> </div>
{ {
items.item_type==="PROGRAM"? items.item_type === "PROGRAM" ?
<a href={`/problems/${items.program_attr.identifier}/edit`}> <a href={`/problems/${items.program_attr.identifier}/edit`}>
<div className="ml10 w100s " style={{wordBreak: "break-word"}} dangerouslySetInnerHTML={{__html: markdownToHTML(items&&items.name).replace(/▁/g, "▁▁▁")}}></div> <div className="ml10 w100s " style={{ wordBreak: "break-word" }} dangerouslySetInnerHTML={{ __html: markdownToHTML(items && items.name).replace(/▁/g, "▁▁▁") }}></div>
</a> </a>
: :
<div className="ml10 w100s markdown-body" style={{wordBreak: "break-word"}}> <div className="ml10 w100s markdown-body" style={{ wordBreak: "break-word" }}>
{ items===undefined||items===null||items===""?"": {items === undefined || items === null || items === "" ? "" :
items.name === undefined || items.name === null || items.name === "" ? items.name === undefined || items.name === null || items.name === "" ?
"" ""
: :
items.name.length>0? items.name.length > 0 ?
<QuillForEditor <QuillForEditor
readOnly={true} readOnly={true}
value={itemssname} value={itemssname}
/> />
:"" : ""
} }
</div> </div>
} }
@ -220,8 +214,8 @@ class Listjihe extends Component {
<p className="w100s listjihetixingstitssy sortinxdirection "> <p className="w100s listjihetixingstitssy sortinxdirection ">
<p className={"sortinxdirection mt15"}> <p className={"sortinxdirection mt15"}>
{ {
items&&items.program_attr&&items.program_attr.description? items && items.program_attr && items.program_attr.description ?
<p className="programquill" style={{wordBreak: "break-word"}} <p className="programquill" style={{ wordBreak: "break-word" }}
> >
<QuillForEditor <QuillForEditor
readOnly={true} readOnly={true}
@ -229,7 +223,7 @@ class Listjihe extends Component {
/> />
</p> </p>
:"" : ""
} }
@ -240,27 +234,27 @@ class Listjihe extends Component {
<p className="w100s listjihetixingstitsp verticallayout "> <p className="w100s listjihetixingstitsp verticallayout ">
{ {
items === undefined || items === null ? "" : items.choices.map((object, index) => { items === undefined || items === null ? "" : items.choices.map((object, index) => {
var string="" var string = ""
try { try {
string=JSON.parse(object.choice_text); string = JSON.parse(object.choice_text);
}catch (e) { } catch (e) {
string=object.choice_text; string = object.choice_text;
} }
return ( return (
<p className={index === 0 ? "sortinxdirection " : "sortinxdirection mt15 "}> <p className={index === 0 ? "sortinxdirection " : "sortinxdirection mt15 "}>
<p className="lh20s">{tagArray[index]}</p> <p className="lh20s">{tagArray[index]}</p>
<p className="programquill" style={{wordBreak: "break-word"}}> <p className="programquill" style={{ wordBreak: "break-word" }}>
{object ? {object ?
object.choice_text === undefined || object.choice_text=== null || object.choice_text === "" ? object.choice_text === undefined || object.choice_text === null || object.choice_text === "" ?
"" ""
: :
object.choice_text.length>0? object.choice_text.length > 0 ?
<QuillForEditor <QuillForEditor
readOnly={true} readOnly={true}
value={string} value={string}
/> />
:"" : ""
: :
@ -343,7 +337,7 @@ class Listjihe extends Component {
</p> </p>
{ {
items.item_type === "PROGRAM" ? items.item_type === "PROGRAM" ?
this.props.Isitapopup&&this.props.Isitapopup==="true"? this.props.Isitapopup && this.props.Isitapopup === "true" ?
"" ""
: :
<a href={`/problems/${items.program_attr.identifier}/edit`}> <a href={`/problems/${items.program_attr.identifier}/edit`}>
@ -353,7 +347,7 @@ class Listjihe extends Component {
</p> </p>
</a> </a>
: :
this.props.Isitapopup&&this.props.Isitapopup==="true"? this.props.Isitapopup && this.props.Isitapopup === "true" ?
"" ""
: :
<a href={`/question/edit/${items.id}`}> <a href={`/question/edit/${items.id}`}>
@ -369,14 +363,14 @@ class Listjihe extends Component {
items.program_attr.status === 0 ? items.program_attr.status === 0 ?
"" ""
: :
items.apply===false? items.apply === false ?
<p className="viewparsings xiaoshou mr25" onClick={() => this.props.showmodels(items.id)}> <p className="viewparsings xiaoshou mr25" onClick={() => this.props.showmodels(items.id)}>
<i className="iconfont icon-gongkai font-17 lg ml7 lh30 icontianjiadaohangcolors mr5"></i> <i className="iconfont icon-gongkai font-17 lg ml7 lh30 icontianjiadaohangcolors mr5"></i>
<span>公开</span> <span>公开</span>
</p> </p>
: :
"" ""
:items.apply===false? : items.apply === false ?
<p className="viewparsings xiaoshou mr25" onClick={() => this.props.showmodels(items.id)}> <p className="viewparsings xiaoshou mr25" onClick={() => this.props.showmodels(items.id)}>
<i className="iconfont icon-gongkai font-17 lg ml7 lh30 icontianjiadaohangcolors mr5"></i> <i className="iconfont icon-gongkai font-17 lg ml7 lh30 icontianjiadaohangcolors mr5"></i>
<span>公开</span> <span>公开</span>
@ -412,21 +406,21 @@ class Listjihe extends Component {
{ {
items.item_type === "SINGLE" ? items.item_type === "SINGLE" ?
<p className=" testfondex yldxtit" <p className=" testfondex yldxtit"
style={{wordBreak: "break-word"}} style={{ wordBreak: "break-word" }}
dangerouslySetInnerHTML={{__html: markdownToHTML("答案:" + tagArrays[rightkey]).replace(/▁/g, "▁▁▁")}} dangerouslySetInnerHTML={{ __html: markdownToHTML("答案:" + tagArrays[rightkey]).replace(/▁/g, "▁▁▁") }}
> >
</p> </p>
: items.item_type === "MULTIPLE"? : items.item_type === "MULTIPLE" ?
<p className=" testfondex yldxtit" <p className=" testfondex yldxtit"
style={{wordBreak: "break-word"}} style={{ wordBreak: "break-word" }}
dangerouslySetInnerHTML={{__html: markdownToHTML("答案:" + MULTIPLEkey).replace(/▁/g, "▁▁▁")}} dangerouslySetInnerHTML={{ __html: markdownToHTML("答案:" + MULTIPLEkey).replace(/▁/g, "▁▁▁") }}
> >
</p> </p>
: :
<p className=" testfondex yldxtit" <p className=" testfondex yldxtit"
style={{wordBreak: "break-word"}} style={{ wordBreak: "break-word" }}
dangerouslySetInnerHTML={{__html: markdownToHTML("答案:" + rightkey).replace(/▁/g, "▁▁▁")}} dangerouslySetInnerHTML={{ __html: markdownToHTML("答案:" + rightkey).replace(/▁/g, "▁▁▁") }}
> >
</p> </p>
} }
@ -434,16 +428,16 @@ class Listjihe extends Component {
</div> </div>
<div className=" sortinxdirection mt15 yldxtit"> <div className=" sortinxdirection mt15 yldxtit">
<p className=" testfondex yldxtit programquill" <p className=" testfondex yldxtit programquill"
style={{wordBreak: "break-word"}} style={{ wordBreak: "break-word" }}
> >
{items ? {items ?
items.analysis=== undefined || items.analysis=== null || items.analysis === "" ? items.analysis === undefined || items.analysis === null || items.analysis === "" ?
"" ""
: :
items.analysis.length>0? items.analysis.length > 0 ?
<QuillForEditor <QuillForEditor
imgAttrs={{width: '60px', height: '30px'}} imgAttrs={{ width: '60px', height: '30px' }}
readOnly={true} readOnly={true}
value={analysisnames} value={analysisnames}
/> />

@ -1,21 +1,10 @@
import React,{ Component } from "react"; import React, { Component } from "react";
import { import { Tooltip } from 'antd';
Form, Input, InputNumber, Switch, Radio,
Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Tooltip
} from 'antd';
import QuillForEditor from '../../../common/quillForEditor'; import QuillForEditor from '../../../common/quillForEditor';
import TPMMDEditor from '../../../modules/tpm/challengesnew/TPMMDEditor';
import axios from 'axios'
import update from 'immutability-helper' import update from 'immutability-helper'
import './../questioncss/questioncom.css'; import './../questioncss/questioncom.css';
import {getUrl, ActionBtn, DMDEditor, ConditionToolTip} from 'educoder'; import { ConditionToolTip } from 'educoder';
const { TextArea } = Input;
const confirm = Modal.confirm;
const $ = window.$
const { Option } = Select;
const tagArray = [ const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
@ -23,8 +12,8 @@ const tagArray = [
] ]
//题库的试卷 单选题 组件 //题库的试卷 单选题 组件
class SingleEditor extends Component{ class SingleEditor extends Component {
constructor(props){ constructor(props) {
super(props); super(props);
/** /**
choice_id: 32076 choice_id: 32076
@ -33,7 +22,7 @@ class SingleEditor extends Component{
standard_boolean: true standard_boolean: true
*/ */
const {question_choices} = this.props; const { question_choices } = this.props;
let _standard_answers = undefined; let _standard_answers = undefined;
let _question_choices = undefined; let _question_choices = undefined;
if (question_choices) { if (question_choices) {
@ -46,17 +35,17 @@ class SingleEditor extends Component{
}) })
} }
const choicescomy=[]; const choicescomy = [];
try { try {
if(this.props.item_banksedit){ if (this.props.item_banksedit) {
if(this.props.item_banksedit.choices){ if (this.props.item_banksedit.choices) {
this.props.item_banksedit.choices.forEach((item, index) => { this.props.item_banksedit.choices.forEach((item, index) => {
////console.log("SingleEditor"); ////console.log("SingleEditor");
////console.log(item); ////console.log(item);
choicescomy.push({ choicescomy.push({
choice_text:item.choice_text, choice_text: item.choice_text,
standard_boolean:item.is_answer, standard_boolean: item.is_answer,
}) })
}) })
@ -69,19 +58,19 @@ class SingleEditor extends Component{
} }
} }
}catch (e) { } catch (e) {
} }
this.state = { this.state = {
question_choices: _question_choices || ['', '', '', ''], question_choices: _question_choices || ['', '', '', ''],
standard_answers: _standard_answers || [false, false, false, false], standard_answers: _standard_answers || [false, false, false, false],
question_title: this.props.question_title!==undefined?JSON.parse(this.props.question_title):"", question_title: this.props.question_title !== undefined ? JSON.parse(this.props.question_title) : "",
question_type: this.props.question_type || 0, question_type: this.props.question_type || 0,
question_score: this.props.question_score || this.props.init_question_score, question_score: this.props.question_score || this.props.init_question_score,
question_titles: this.props.question_titles!==undefined?JSON.parse(this.props.question_titles):"", question_titles: this.props.question_titles !== undefined ? JSON.parse(this.props.question_titles) : "",
question_titlesysl:this.props.question_titlesysl||'', question_titlesysl: this.props.question_titlesysl || '',
question_titleysl:this.props.question_title || '', question_titleysl: this.props.question_title || '',
item_banksedit:[], item_banksedit: [],
} }
} }
addOption = () => { addOption = () => {
@ -97,36 +86,36 @@ class SingleEditor extends Component{
this.setState({ question_choices, standard_answers }) this.setState({ question_choices, standard_answers })
} }
deleteOption = (index) => { deleteOption = (index) => {
let {question_choices}=this.state; let { question_choices } = this.state;
// //////console.log("deleteOption"); // //////console.log("deleteOption");
// //////console.log(question_choices); // //////console.log(question_choices);
if(question_choices[index]===""){ if (question_choices[index] === "") {
// repeat code // repeat code
this.toMDMode(null) this.toMDMode(null)
this.setState( this.setState(
(prevState) => ({ (prevState) => ({
question_choices : update(prevState.question_choices, {$splice: [[index, 1]]}), question_choices: update(prevState.question_choices, { $splice: [[index, 1]] }),
standard_answers : update(prevState.standard_answers, {$splice: [[index, 1]]}) standard_answers: update(prevState.standard_answers, { $splice: [[index, 1]] })
}) })
) )
}else{ } else {
this.toMDMode(null) this.toMDMode(null)
this.setState( this.setState(
(prevState) => ({ (prevState) => ({
question_choices : update(prevState.question_choices, {$splice: [[index, 1]]}), question_choices: update(prevState.question_choices, { $splice: [[index, 1]] }),
standard_answers : update(prevState.standard_answers, {$splice: [[index, 1]]}) standard_answers: update(prevState.standard_answers, { $splice: [[index, 1]] })
}) })
) )
} }
} }
onSave = () => { onSave = () => {
var editordata=[]; var editordata = [];
const {question_title, question_titleysl,question_score, question_type,question_titles,question_titlesysl, question_choices, standard_answers } = this.state; const { question_title, question_titleysl, question_score, question_type, question_titles, question_titlesysl, question_choices, standard_answers } = this.state;
const { question_id_to_insert_after, question_id } = this.props const { question_id_to_insert_after, question_id } = this.props
// TODO check // TODO check
const answerArray = standard_answers.map((item, index) => { return item == true ? index+1 : -1 }).filter(item => item != -1); const answerArray = standard_answers.map((item, index) => { return item == true ? index + 1 : -1 }).filter(item => item != -1);
// const _text = quill.getText(); // const _text = quill.getText();
// const reg = /^[\s\S]*.*[^\s][\s\S]*$/; // const reg = /^[\s\S]*.*[^\s][\s\S]*$/;
@ -136,12 +125,12 @@ class SingleEditor extends Component{
// // 提交到后台的内容需要处理一下; // // 提交到后台的内容需要处理一下;
// value = JSON.stringify(value) // value = JSON.stringify(value)
// } // }
if(!question_titleysl) { if (!question_titleysl) {
// this.refs['titleEditor'].showError() // this.refs['titleEditor'].showError()
this.props.showNotification('请您输入题干'); this.props.showNotification('请您输入题干');
return editordata; return editordata;
} }
for(let i = 0; i < question_choices.length; i++) { for (let i = 0; i < question_choices.length; i++) {
if (!question_choices[i]) { if (!question_choices[i]) {
// this.refs[`optionEditor${i}`].showError() // this.refs[`optionEditor${i}`].showError()
this.props.showNotification(`请先输入 ${tagArray[i]} 选项的内容`); this.props.showNotification(`请先输入 ${tagArray[i]} 选项的内容`);
@ -149,7 +138,7 @@ class SingleEditor extends Component{
} }
} }
if(!answerArray || answerArray.length == 0) { if (!answerArray || answerArray.length == 0) {
this.props.showNotification('请先点击选择本选择题的正确选项'); this.props.showNotification('请先点击选择本选择题的正确选项');
return editordata; return editordata;
} }
@ -169,7 +158,7 @@ class SingleEditor extends Component{
"question_choices":["a答案","b答案","c答案","d答案"], "question_choices":["a答案","b答案","c答案","d答案"],
"standard_answers":[1] "standard_answers":[1]
}*/ }*/
editordata=[question_titleysl,answerArray,question_choices,question_titlesysl]; editordata = [question_titleysl, answerArray, question_choices, question_titlesysl];
// question_title, // question_title,
// question_type: answerArray.length > 1 ? 1 : 0, // question_type: answerArray.length > 1 ? 1 : 0,
// question_score, // question_score,
@ -187,24 +176,24 @@ class SingleEditor extends Component{
componentDidMount = () => { componentDidMount = () => {
try { try {
this.props.getanswerMdRef(this); this.props.getanswerMdRef(this);
}catch (e) { } catch (e) {
} }
try { try {
this.setState({ this.setState({
item_banksedit:this.props.item_banksedit, item_banksedit: this.props.item_banksedit,
question_title: this.props.item_banksedit.name!==undefined?JSON.parse(this.props.item_banksedit.name):"", question_title: this.props.item_banksedit.name !== undefined ? JSON.parse(this.props.item_banksedit.name) : "",
question_titleysl:this.props.item_banksedit.name|| '', question_titleysl: this.props.item_banksedit.name || '',
question_titles: this.props.item_banksedit.analysis!==undefined?JSON.parse(this.props.item_banksedit.analysis):"", question_titles: this.props.item_banksedit.analysis !== undefined ? JSON.parse(this.props.item_banksedit.analysis) : "",
question_titlesysl:this.props.item_banksedit.analysis||'', question_titlesysl: this.props.item_banksedit.analysis || '',
mychoicess:this.props.item_banksedit.choices, mychoicess: this.props.item_banksedit.choices,
}) })
}catch (e) { } catch (e) {
} }
} }
@ -213,13 +202,13 @@ class SingleEditor extends Component{
// ////console.log(prevProps); // ////console.log(prevProps);
// ////console.log(this.props.item_banksedit); // ////console.log(this.props.item_banksedit);
if(prevProps.item_banksedit !== this.props.item_banksedit) { if (prevProps.item_banksedit !== this.props.item_banksedit) {
this.setState({ this.setState({
item_banksedit: this.props.item_banksedit, item_banksedit: this.props.item_banksedit,
question_title: this.props.item_banksedit.name!==undefined?JSON.parse(this.props.item_banksedit.name):"", question_title: this.props.item_banksedit.name !== undefined ? JSON.parse(this.props.item_banksedit.name) : "",
question_titleysl:this.props.item_banksedit.name|| '', question_titleysl: this.props.item_banksedit.name || '',
question_titles: this.props.item_banksedit.analysis!==undefined?JSON.parse(this.props.item_banksedit.analysis):"", question_titles: this.props.item_banksedit.analysis !== undefined ? JSON.parse(this.props.item_banksedit.analysis) : "",
question_titlesysl:this.props.item_banksedit.analysis||'', question_titlesysl: this.props.item_banksedit.analysis || '',
mychoicess: this.props.item_banksedit.choices, mychoicess: this.props.item_banksedit.choices,
}) })
@ -232,10 +221,10 @@ class SingleEditor extends Component{
// //////console.log(standard_answers); // //////console.log(standard_answers);
// //////console.log(standard_answers[index]); // //////console.log(standard_answers[index]);
// //////console.log(!standard_answers[index]); // //////console.log(!standard_answers[index]);
for (var i=0;i<standard_answers.length;i++){ for (var i = 0; i < standard_answers.length; i++) {
if(index===i){ if (index === i) {
standard_answers[index] = true; standard_answers[index] = true;
}else{ } else {
standard_answers[i] = false; standard_answers[i] = false;
} }
@ -243,7 +232,7 @@ class SingleEditor extends Component{
// standard_answers[index] = !standard_answers[index]; // standard_answers[index] = !standard_answers[index];
this.setState({ standard_answers }) this.setState({ standard_answers })
} }
onOptionContentChange = (value,quill,index) => { onOptionContentChange = (value, quill, index) => {
if (index >= this.state.question_choices.length) { if (index >= this.state.question_choices.length) {
// TODO 新建然后删除CD选项再输入题干会调用到这里且index是3 // TODO 新建然后删除CD选项再输入题干会调用到这里且index是3
return; return;
@ -253,16 +242,16 @@ class SingleEditor extends Component{
const reg = /^[\s\S]*.*[^\s][\s\S]*$/; const reg = /^[\s\S]*.*[^\s][\s\S]*$/;
if (!reg.test(_text)) { if (!reg.test(_text)) {
// 处理编辑器内容为空 // 处理编辑器内容为空
texts=""; texts = "";
} else {
if (_text.length >= 301) {
var result = _text.substring(0, 300);
texts = { "ops": [{ "insert": result }] };
texts = JSON.stringify(texts);
} else { } else {
if(_text.length>=301){
var result = _text.substring(0,300);
texts={"ops":[{"insert":result}]};
texts=JSON.stringify(texts);
}else {
// 提交到后台的内容需要处理一下; // 提交到后台的内容需要处理一下;
value = JSON.stringify(value) value = JSON.stringify(value)
texts=value; texts = value;
} }
} }
let question_choices = this.state.question_choices.slice(0); let question_choices = this.state.question_choices.slice(0);
@ -285,58 +274,58 @@ class SingleEditor extends Component{
} }
onContentChange=(value,quill)=>{ onContentChange = (value, quill) => {
var _text = quill.getText(); var _text = quill.getText();
const reg = /^[\s\S]*.*[^\s][\s\S]*$/; const reg = /^[\s\S]*.*[^\s][\s\S]*$/;
if (!reg.test(_text)) { if (!reg.test(_text)) {
// 处理编辑器内容为空 // 处理编辑器内容为空
this.setState({ this.setState({
question_titleysl:"" question_titleysl: ""
}) })
} else { } else {
// 提交到后台的内容需要处理一下; // 提交到后台的内容需要处理一下;
var texts=""; var texts = "";
if(_text.length>=1001){ if (_text.length >= 1001) {
var result = _text.substring(0,1000); var result = _text.substring(0, 1000);
texts={"ops":[{"insert":result}]}; texts = { "ops": [{ "insert": result }] };
texts=JSON.stringify(texts); texts = JSON.stringify(texts);
}else { } else {
value = JSON.stringify(value) value = JSON.stringify(value)
texts=value; texts = value;
} }
this.setState({ this.setState({
question_titleysl:texts question_titleysl: texts
}) })
try { try {
//console.log("onContentChange"); //console.log("onContentChange");
//console.log(quill.getText().length); //console.log(quill.getText().length);
}catch (e) { } catch (e) {
} }
} }
} }
onContentChanges=(value,quill)=>{ onContentChanges = (value, quill) => {
const _text = quill.getText(); const _text = quill.getText();
const reg = /^[\s\S]*.*[^\s][\s\S]*$/; const reg = /^[\s\S]*.*[^\s][\s\S]*$/;
if (!reg.test(_text)) { if (!reg.test(_text)) {
// 处理编辑器内容为空 // 处理编辑器内容为空
this.setState({ this.setState({
question_titlesysl:"" question_titlesysl: ""
}) })
} else { } else {
var texts=""; var texts = "";
if(_text.length>=1001){ if (_text.length >= 1001) {
var result = _text.substring(0,1000); var result = _text.substring(0, 1000);
texts={"ops":[{"insert":result}]}; texts = { "ops": [{ "insert": result }] };
texts=JSON.stringify(texts); texts = JSON.stringify(texts);
}else { } else {
value = JSON.stringify(value) value = JSON.stringify(value)
texts=value; texts = value;
} }
this.setState({ this.setState({
question_titlesysl:texts question_titlesysl: texts
}) })
} }
} }
@ -347,7 +336,7 @@ class SingleEditor extends Component{
} }
render() { render() {
let { question_title, question_score, question_type, question_choices, standard_answers,question_titles,question_titlesysl} = this.state; let { question_title, question_score, question_type, question_choices, standard_answers, question_titles, question_titlesysl } = this.state;
let { question_id, index, exerciseIsPublish, let { question_id, index, exerciseIsPublish,
// question_title, // question_title,
// question_type, // question_type,
@ -368,7 +357,7 @@ class SingleEditor extends Component{
// //////console.log("xuanzheshijuan"); // //////console.log("xuanzheshijuan");
// //////console.log(answerTagArray); // //////console.log(answerTagArray);
// //////console.log(!exerciseIsPublish); // //////console.log(!exerciseIsPublish);
return( return (
<div className="padding20-30 signleEditor danxuano" id={qNumber}> <div className="padding20-30 signleEditor danxuano" id={qNumber}>
<style>{` <style>{`
@ -398,8 +387,8 @@ class SingleEditor extends Component{
<QuillForEditor <QuillForEditor
autoFocus={true} autoFocus={true}
imgAttrs={{width: '146px', height: '136px'}} imgAttrs={{ width: '146px', height: '136px' }}
style={{ height: '155px'}} style={{ height: '155px' }}
placeholder="请您输入题干" placeholder="请您输入题干"
options={['code-block', 'image', 'formula']} options={['code-block', 'image', 'formula']}
value={question_title} value={question_title}
@ -412,40 +401,40 @@ class SingleEditor extends Component{
<span className="xingtigans fl"><span className="xingtigan">答案选项</span></span> <span className="xingtigans fl"><span className="xingtigan">答案选项</span></span>
</div> </div>
{question_choices.map( (item, index) => { {question_choices.map((item, index) => {
const bg = standard_answers[index] ? 'check-option-bg' : '' const bg = standard_answers[index] ? 'check-option-bg' : ''
return <div className={index>0?"df optionRow mt15": "df optionRow"} key={index} > return <div className={index > 0 ? "df optionRow mt15" : "df optionRow"} key={index} >
{/* 点击设置答案 */} {/* 点击设置答案 */}
{/* TODO 加了tooltip后会丢失掉span的class */} {/* TODO 加了tooltip后会丢失掉span的class */}
{/* <Tooltip title={standard_answers[index] ? '点击取消标准答案设置' : '点击设置为标准答案'}> */} {/* <Tooltip title={standard_answers[index] ? '点击取消标准答案设置' : '点击设置为标准答案'}> */}
<span className={`option-item fr mr10 color-grey select-choice ${bg} `} <span className={`option-item fr mr10 color-grey select-choice ${bg} `}
name="option_span" onClick={() => this.onOptionClick(index)} style={{flex: '0 0 38px'}}> name="option_span" onClick={() => this.onOptionClick(index)} style={{ flex: '0 0 38px' }}>
<ConditionToolTip key={index} title={'点击设置为标准答案'} placement="left" condition={true}> <ConditionToolTip key={index} title={'点击设置为标准答案'} placement="left" condition={true}>
<div style={{width: '100%', height: '100%'}}>{tagArray[index]}</div> <div style={{ width: '100%', height: '100%' }}>{tagArray[index]}</div>
</ConditionToolTip> </ConditionToolTip>
</span> </span>
{/* </Tooltip> */} {/* </Tooltip> */}
<div style={{ flex: '0 0 1038px'}}> <div style={{ flex: '0 0 1038px' }}>
{ {
item===undefined||item===null||item===""? item === undefined || item === null || item === "" ?
<QuillForEditor <QuillForEditor
autoFocus={false} autoFocus={false}
imgAttrs={{width: '146px', height: '136px'}} imgAttrs={{ width: '146px', height: '136px' }}
style={{ height: '166px'}} style={{ height: '166px' }}
placeholder="请您输入题干" placeholder="请您输入题干"
options={['code-block', 'image', 'formula']} options={['code-block', 'image', 'formula']}
value={item} value={item}
onContentChange={(value,quill) => this.onOptionContentChange(value,quill,index)} onContentChange={(value, quill) => this.onOptionContentChange(value, quill, index)}
/> />
: :
<QuillForEditor <QuillForEditor
autoFocus={false} autoFocus={false}
imgAttrs={{width: '146px', height: '136px'}} imgAttrs={{ width: '146px', height: '136px' }}
style={{ height: '166px'}} style={{ height: '166px' }}
placeholder="请您输入题干" placeholder="请您输入题干"
options={['code-block', 'image', 'formula']} options={['code-block', 'image', 'formula']}
value={JSON.parse(item)} value={JSON.parse(item)}
onContentChange={(value,quill) => this.onOptionContentChange(value,quill,index)} onContentChange={(value, quill) => this.onOptionContentChange(value, quill, index)}
/> />
} }
@ -455,20 +444,20 @@ class SingleEditor extends Component{
</div> </div>
{exerciseIsPublish || index<=1? {exerciseIsPublish || index <= 1 ?
<i className=" font-18 ml15 mr20"></i> <i className=" font-18 ml15 mr20"></i>
:<Tooltip title="删除"> : <Tooltip title="删除">
<i className="iconfont icon-htmal5icon19 font-18 color-grey-c ml15" onClick={() => this.deleteOption(index)}></i> <i className="iconfont icon-htmal5icon19 font-18 color-grey-c ml15" onClick={() => this.deleteOption(index)}></i>
</Tooltip> } </Tooltip>}
{ !exerciseIsPublish && index<7 && <Tooltip title={`新增参考答案`}> {!exerciseIsPublish && index < 7 && <Tooltip title={`新增参考答案`}>
<i className="color-green font-16 iconfont icon-roundaddfill ml6" <i className="color-green font-16 iconfont icon-roundaddfill ml6"
onClick={() => this.addOption()} onClick={() => this.addOption()}
style={{float: 'right', visibility: index == question_choices.length - 1 ? '' : 'hidden', marginTop: '2px'}} style={{ float: 'right', visibility: index == question_choices.length - 1 ? '' : 'hidden', marginTop: '2px' }}
></i> ></i>
</Tooltip>} </Tooltip>}
</div> </div>
}) } })}
@ -481,8 +470,8 @@ class SingleEditor extends Component{
<div className="mt10"></div> <div className="mt10"></div>
<QuillForEditor <QuillForEditor
autoFocus={false} autoFocus={false}
imgAttrs={{width: '146px', height: '136px'}} imgAttrs={{ width: '146px', height: '136px' }}
style={{height: '166px' }} style={{ height: '166px' }}
placeholder="请您输入题目解析" placeholder="请您输入题目解析"
options={['code-block', 'image', 'formula']} options={['code-block', 'image', 'formula']}
value={question_titles} value={question_titles}

@ -1,16 +1,6 @@
import React, {Component} from "react"; import React, { Component } from "react";
import {Link, NavLink} from 'react-router-dom'; import { markdownToHTML } from 'educoder';
import {WordsBtn, ActionBtn, getImageUrl, markdownToHTML} from 'educoder';
import axios from 'axios';
import { import {
notification,
Spin,
Table,
Pagination,
Drawer,
Input,
Button,
Breadcrumb,
Radio Radio
} from "antd"; } from "antd";
import '../testioncss/testioncss.css'; import '../testioncss/testioncss.css';
@ -66,29 +56,29 @@ class Paperlibraryseeid_items extends Component {
} }
render() { render() {
let {questions, totalscore, total, items} = this.state; let { questions, totalscore, total, items } = this.state;
let {objectsingle, indexx, paperreviewsingleindex, indexxy,name} = this.props; let { objectsingle, indexx, paperreviewsingleindex, indexxy, name } = this.props;
var itemssname=""; var itemssname = "";
try { try {
itemssname= JSON.parse(objectsingle.name); itemssname = JSON.parse(objectsingle.name);
}catch (e) { } catch (e) {
} }
if(itemssname===undefined){ if (itemssname === undefined) {
itemssname=objectsingle.name itemssname = objectsingle.name
} }
var itemsnamesy=""; var itemsnamesy = "";
try { try {
itemsnamesy= JSON.parse(objectsingle&&objectsingle.program_attr&&objectsingle.program_attr.description); itemsnamesy = JSON.parse(objectsingle && objectsingle.program_attr && objectsingle.program_attr.description);
}catch (e) { } catch (e) {
itemsnamesy=objectsingle&&objectsingle.program_attr&&objectsingle.program_attr.description; itemsnamesy = objectsingle && objectsingle.program_attr && objectsingle.program_attr.description;
} }
return ( return (
<div key={indexxy} <div key={indexxy}
className={ "w100s borderwdswuh mb20 pd20 "} className={"w100s borderwdswuh mb20 pd20 "}
style={{ style={{
minHeight: "114px", minHeight: "114px",
}}> }}>
@ -138,27 +128,30 @@ class Paperlibraryseeid_items extends Component {
} }
</style> </style>
{ {
objectsingle.item_type==="PROGRAM"? objectsingle.item_type === "PROGRAM" ?
<div className="w100s sortinxdirection"> <div className="w100s sortinxdirection">
<div className=" tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{wordBreak: "break-word", <div className=" tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{
minWidth:"32px" wordBreak: "break-word",
minWidth: "32px"
}} }}
> >
({objectsingle.score}) ({objectsingle.score})
</div> </div>
<div className="ml10 lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{wordBreak: "break-word"}} <div className="ml10 lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{ wordBreak: "break-word" }}
dangerouslySetInnerHTML={{__html: markdownToHTML(objectsingle.name).replace(/▁/g, "▁▁▁")}}> dangerouslySetInnerHTML={{ __html: markdownToHTML(objectsingle.name).replace(/▁/g, "▁▁▁") }}>
</div> </div>
</div> </div>
: :
<div className="w100s sortinxdirection"> <div className="w100s sortinxdirection">
<div className="tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{wordBreak: "break-word", <div className="tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{
minWidth:"32px"}} wordBreak: "break-word",
minWidth: "32px"
}}
> >
({objectsingle.score}) ({objectsingle.score})
</div> </div>
<div className="ml10 lh28 listjihetixingstit cretitlecolrlist programquill" style={{wordBreak: "break-word"}} <div className="ml10 lh28 listjihetixingstit cretitlecolrlist programquill" style={{ wordBreak: "break-word" }}
> >
<QuillForEditor <QuillForEditor
readOnly={true} readOnly={true}
@ -193,8 +186,8 @@ class Paperlibraryseeid_items extends Component {
<p className="w100s listjihetixingstitssy sortinxdirection "> <p className="w100s listjihetixingstitssy sortinxdirection ">
<p className={"sortinxdirection mt15"}> <p className={"sortinxdirection mt15"}>
{ {
objectsingle&&objectsingle.program_attr&&objectsingle.program_attr.description? objectsingle && objectsingle.program_attr && objectsingle.program_attr.description ?
<p className="programquill" style={{wordBreak: "break-word"}} <p className="programquill" style={{ wordBreak: "break-word" }}
> >
<QuillForEditor <QuillForEditor
readOnly={true} readOnly={true}
@ -209,26 +202,26 @@ class Paperlibraryseeid_items extends Component {
<p className="w100s listjihetixingstits verticallayout "> <p className="w100s listjihetixingstits verticallayout ">
{ {
objectsingle === undefined || objectsingle === null ? "" : objectsingle.choices.map((object, index) => { objectsingle === undefined || objectsingle === null ? "" : objectsingle.choices.map((object, index) => {
var string="" var string = ""
try { try {
string=JSON.parse(object.choice_text); string = JSON.parse(object.choice_text);
}catch (e) { } catch (e) {
string=object.choice_text; string = object.choice_text;
} }
return ( return (
<p className={index === 0 ? "sortinxdirection" : "sortinxdirection mt15"}> <p className={index === 0 ? "sortinxdirection" : "sortinxdirection mt15"}>
{tagArray[index]} {tagArray[index]}
<p className="programquills" style={{wordBreak: "break-word"}}> <p className="programquills" style={{ wordBreak: "break-word" }}>
{object ? {object ?
object.choice_text === undefined || object.choice_text=== null || object.choice_text === "" ? object.choice_text === undefined || object.choice_text === null || object.choice_text === "" ?
"" ""
: :
object.choice_text.length>0? object.choice_text.length > 0 ?
<QuillForEditor <QuillForEditor
readOnly={true} readOnly={true}
value={string} value={string}
/> />
:"" : ""
: :
"" ""
} }

Loading…
Cancel
Save