diff --git a/public/react/config-overrides.js b/public/react/config-overrides.js
index 7a91afb73..9eabda352 100644
--- a/public/react/config-overrides.js
+++ b/public/react/config-overrides.js
@@ -75,9 +75,9 @@ module.exports = override(
// addWebpackPlugin(instance),
(config) => {
config.resolve.plugins = config.resolve.plugins.filter(plugin => !(plugin instanceof ModuleScopePlugin));
- if (process.env.NODE_ENV !== "development") {
- config.output.publicPath = `/react/build/`;
- }
+ //if (process.env.NODE_ENV !== "development") {
+ // config.output.publicPath = `/react/build/`;
+ //}
return config
}
);
\ No newline at end of file
diff --git a/public/react/package-lock.json b/public/react/package-lock.json
index d32cc0e95..f447cd7de 100644
--- a/public/react/package-lock.json
+++ b/public/react/package-lock.json
@@ -3794,9 +3794,9 @@
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
},
"codemirror": {
- "version": "5.52.0",
- "resolved": "https://registry.npm.taobao.org/codemirror/download/codemirror-5.52.0.tgz",
- "integrity": "sha1-Tb1q738OY9uCa5ojki8MA6x1wKc="
+ "version": "5.52.2",
+ "resolved": "https://registry.npm.taobao.org/codemirror/download/codemirror-5.52.2.tgz?cache=0&sync_timestamp=1584691606242&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcodemirror%2Fdownload%2Fcodemirror-5.52.2.tgz",
+ "integrity": "sha1-wp4fcXn4XrDdF8BYb6gQ5IOP9YQ="
},
"collection-visit": {
"version": "1.0.0",
@@ -5036,11 +5036,11 @@
}
},
"echarts": {
- "version": "4.6.0",
- "resolved": "https://registry.npm.taobao.org/echarts/download/echarts-4.6.0.tgz",
- "integrity": "sha1-taR6EEbOyTzu75VPnuVHUTQFWOw=",
+ "version": "4.7.0",
+ "resolved": "https://registry.npm.taobao.org/echarts/download/echarts-4.7.0.tgz",
+ "integrity": "sha1-Wzh1pML5HjkpQl+rq56s5+QJiz8=",
"requires": {
- "zrender": "4.2.0"
+ "zrender": "4.3.0"
}
},
"editor.md": {
@@ -12317,9 +12317,9 @@
"integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc="
},
"qs": {
- "version": "6.9.1",
- "resolved": "https://registry.npm.taobao.org/qs/download/qs-6.9.1.tgz",
- "integrity": "sha1-IAgsZct4IjY1qxqerKiHWim/jsk="
+ "version": "6.9.2",
+ "resolved": "https://registry.npm.taobao.org/qs/download/qs-6.9.2.tgz?cache=0&sync_timestamp=1584892552959&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fqs%2Fdownload%2Fqs-6.9.2.tgz",
+ "integrity": "sha1-ontpUAZUSgS/DmxqfoEgd4km1b0="
},
"query-string": {
"version": "4.3.4",
@@ -12899,9 +12899,9 @@
}
},
"react": {
- "version": "16.13.0",
- "resolved": "https://registry.npm.taobao.org/react/download/react-16.13.0.tgz",
- "integrity": "sha1-0EbqvN9k5Fe77tHnkuI14bmTTPc=",
+ "version": "16.13.1",
+ "resolved": "https://registry.npm.taobao.org/react/download/react-16.13.1.tgz?cache=0&sync_timestamp=1584650109083&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freact%2Fdownload%2Freact-16.13.1.tgz",
+ "integrity": "sha1-LoGIIvGpdDEiwGPWQQ2FweOv5I4=",
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
@@ -12974,9 +12974,9 @@
}
},
"react-codemirror2": {
- "version": "6.0.0",
- "resolved": "https://registry.npm.taobao.org/react-codemirror2/download/react-codemirror2-6.0.0.tgz",
- "integrity": "sha1-GABl31emQCYCbN5WmpcI/fdlZSU="
+ "version": "6.0.1",
+ "resolved": "https://registry.npm.taobao.org/react-codemirror2/download/react-codemirror2-6.0.1.tgz",
+ "integrity": "sha1-faukB5XrKlJjeSa2/gtzpukJByM="
},
"react-content-loader": {
"version": "3.4.2",
@@ -13222,14 +13222,14 @@
}
},
"react-dom": {
- "version": "16.13.0",
- "resolved": "https://registry.npm.taobao.org/react-dom/download/react-dom-16.13.0.tgz",
- "integrity": "sha1-zd5UtI656KDKGz3JlD2btAm4GGY=",
+ "version": "16.13.1",
+ "resolved": "https://registry.npm.taobao.org/react-dom/download/react-dom-16.13.1.tgz",
+ "integrity": "sha1-wb03MxoEhsB47lTEdAcgmTsuDn8=",
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"prop-types": "^15.6.2",
- "scheduler": "^0.19.0"
+ "scheduler": "^0.19.1"
}
},
"react-error-overlay": {
@@ -13985,9 +13985,9 @@
}
},
"rsuite": {
- "version": "4.3.1",
- "resolved": "https://registry.npm.taobao.org/rsuite/download/rsuite-4.3.1.tgz",
- "integrity": "sha1-5e9YpDA7nB5jWXvi1eK/5zqeYUM=",
+ "version": "4.3.2",
+ "resolved": "https://registry.npm.taobao.org/rsuite/download/rsuite-4.3.2.tgz",
+ "integrity": "sha1-tnakesqRBC3GqNc7+n/Gm+PMUY0=",
"requires": {
"@babel/runtime": "^7.8.4",
"classnames": ">=2.0.0",
@@ -13999,15 +13999,15 @@
"react-lifecycles-compat": "^3.0.4",
"react-virtualized": "^9.21.0",
"recompose": "^0.30.0",
- "rsuite-table": "^3.9.3",
+ "rsuite-table": "^3.9.4",
"rsuite-utils": "^2.2.1",
"schema-typed": "^1.4.0"
}
},
"rsuite-table": {
- "version": "3.9.3",
- "resolved": "https://registry.npm.taobao.org/rsuite-table/download/rsuite-table-3.9.3.tgz",
- "integrity": "sha1-TEjh+ZqJy7C+9VOnTKI/2a91wBw=",
+ "version": "3.9.4",
+ "resolved": "https://registry.npm.taobao.org/rsuite-table/download/rsuite-table-3.9.4.tgz",
+ "integrity": "sha1-PUiCfFmO8ZeF5KEkc29Vdj8Tnp0=",
"requires": {
"@babel/runtime": "^7.8.4",
"classnames": "^2.2.5",
@@ -14150,9 +14150,9 @@
}
},
"scheduler": {
- "version": "0.19.0",
- "resolved": "https://registry.npm.taobao.org/scheduler/download/scheduler-0.19.0.tgz",
- "integrity": "sha1-pxXVYwLeQD33QvSpvhGXWzL1aY0=",
+ "version": "0.19.1",
+ "resolved": "https://registry.npm.taobao.org/scheduler/download/scheduler-0.19.1.tgz",
+ "integrity": "sha1-Tz4u0sGn1laB9MhU+oxaHMtA8ZY=",
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1"
@@ -18292,9 +18292,9 @@
"integrity": "sha1-JGRSGW/KnlgfCavtm5DJSv9gFOI="
},
"zrender": {
- "version": "4.2.0",
- "resolved": "https://registry.npm.taobao.org/zrender/download/zrender-4.2.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fzrender%2Fdownload%2Fzrender-4.2.0.tgz",
- "integrity": "sha1-0AEwLhVfKN4fn8f81cJUutKEcc8="
+ "version": "4.3.0",
+ "resolved": "https://registry.npm.taobao.org/zrender/download/zrender-4.3.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fzrender%2Fdownload%2Fzrender-4.3.0.tgz",
+ "integrity": "sha1-nwVhIbILuuREFNKHv2oRn/cEJmE="
}
}
}
diff --git a/public/react/package.json b/public/react/package.json
index 2a418d1e9..994267e69 100644
--- a/public/react/package.json
+++ b/public/react/package.json
@@ -11,8 +11,8 @@
"chalk": "1.1.3",
"classnames": "^2.2.5",
"clipboard": "^2.0.4",
- "codemirror": "^5.52.0",
- "echarts": "^4.2.0-rc.2",
+ "codemirror": "^5.52.2",
+ "echarts": "^4.7.0",
"editor.md": "^1.5.0",
"flvplayer": "^1.1.5",
"immutability-helper": "^3.0.1",
@@ -28,16 +28,16 @@
"object-assign": "4.1.1",
"promise": "8.0.1",
"prop-types": "^15.6.1",
- "qs": "^6.6.0",
+ "qs": "^6.9.2",
"quill": "^1.3.7",
"quill-delta-to-html": "^0.11.0",
- "react": "^16.13.0",
+ "react": "^16.13.1",
"react-beautiful-dnd": "^10.0.4",
- "react-codemirror2": "^6.0.0",
+ "react-codemirror2": "^6.0.1",
"react-content-loader": "^3.1.1",
"react-cookie": "^4.0.3",
"react-cookies": "^0.1.1",
- "react-dom": "^16.13.0",
+ "react-dom": "^16.13.1",
"react-infinite-scroller": "^1.2.4",
"react-player": "^1.11.1",
"react-redux": "5.0.7",
@@ -48,7 +48,7 @@
"react-url-query": "^1.4.0",
"redux": "^4.0.0",
"redux-thunk": "^2.3.0",
- "rsuite": "^4.0.1",
+ "rsuite": "^4.3.2",
"scroll-into-view": "^1.12.3",
"showdown": "^1.9.1",
"showdown-katex": "^0.6.0",
diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js
index 865011563..4c4f36ead 100644
--- a/public/react/src/AppConfig.js
+++ b/public/react/src/AppConfig.js
@@ -121,22 +121,9 @@ window._debugType = debugType;
export function initAxiosInterceptors(props) {
initOnlineOfflineListener()
- // TODO 避免重复的请求 https://github.com/axios/axios#cancellation
- // https://github.com/axios/axios/issues/1497
-
- // TODO 读取到package.json中的配置?
var proxy = "http://localhost:3000"
- // proxy = "http://testbdweb.trustie.net"
- // proxy = "http://testbdweb.educoder.net"
- // proxy = "https://testeduplus2.educoder.net"
- //proxy="http://47.96.87.25:48080"
proxy = "https://pre-newweb.educoder.net"
proxy = "https://test-newweb.educoder.net"
- // proxy="https://test-jupyterweb.educoder.net"
- // proxy="https://test-newweb.educoder.net"
- // proxy="https://test-jupyterweb.educoder.net"
- //proxy="https://test-jupyterweb.educoder.net/"
-
// 在这里使用requestMap控制,避免用户通过双击等操作发出重复的请求;
// 如果需要支持重复的请求,考虑config里面自定义一个allowRepeat参考来控制
@@ -212,10 +199,6 @@ export function initAxiosInterceptors(props) {
}
const config = response.config
if (response.data.status === -1) {
- // https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=cancel+request+in+response+interceptors+
- // https://github.com/axios/axios/issues/583
- // message.info(response.data.message || '服务端返回status -1,请联系管理员。');
- // props.showSnackbar( response.data.message || '服务器异常,请联系管理员。' )
if (window.location.pathname.startsWith('/tasks/')) {
props.showSnackbar(response.data.message || '服务器异常,请联系管理员。')
} else {
diff --git a/public/react/src/common/UrlTool.js b/public/react/src/common/UrlTool.js
index 65c6abbf0..f61f8fcb1 100644
--- a/public/react/src/common/UrlTool.js
+++ b/public/react/src/common/UrlTool.js
@@ -33,14 +33,6 @@ export function getUrl(path) {
}
export function getUrlmys(path, goTest) {
- // https://www.educoder.net
- // https://testbdweb.trustie.net
-
- // 如果想所有url定位到测试版,可以反注释掉下面这行
- //goTest = true
- // testbdweb.educoder.net testbdweb.trustie.net
- // const local = goTest ? 'https://testeduplus2.educoder.net' : 'http://localhost:3000'
- // const local = 'https://testeduplus2.educoder.net'
const local = 'https://test-jupyterweb.educoder.net'
if (isDev) {
return `${local}${path ? path : ''}`
diff --git a/public/react/src/modules/courses/coursesPublic/CoursesMarkdown.js b/public/react/src/modules/courses/coursesPublic/CoursesMarkdown.js
index 7b996480c..6972d4ecd 100644
--- a/public/react/src/modules/courses/coursesPublic/CoursesMarkdown.js
+++ b/public/react/src/modules/courses/coursesPublic/CoursesMarkdown.js
@@ -1,46 +1,25 @@
-import React, {Component} from 'react';
-
-import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal} from 'antd';
-
-import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom";
-
-// import "antd/dist/antd.css";
-
-import { getImageUrl, toPath, getUrl,getUploadActionUrl } from 'educoder';
-
-import axios from 'axios';
+import React, { Component } from 'react';
+import { getUrl, getUploadActionUrl } from 'educoder';
import "./makedown.css";
-let origin = getUrl();
-
let path = getUrl("/editormd/lib/")
const $ = window.$;
-let timeout;
-
-let currentValue;
-
-const Option = Select.Option;
-
-const RadioGroup = Radio.Group;
-
-
-
// 保存数据
-function md_add_data(k,mdu,d){
- window.sessionStorage.setItem(k+mdu,d);
+function md_add_data(k, mdu, d) {
+ window.sessionStorage.setItem(k + mdu, d);
}
// 清空保存的数据
-function md_clear_data(k,mdu,id){
- window.sessionStorage.removeItem(k+mdu);
- var id1 = "#e_tip_"+id;
- var id2 = "#e_tips_"+id;
- if(k == 'content'){
+function md_clear_data(k, mdu, id) {
+ window.sessionStorage.removeItem(k + mdu);
+ var id1 = "#e_tip_" + id;
+ var id2 = "#e_tips_" + id;
+ if (k == 'content') {
$(id2).html("");
- }else{
+ } else {
$(id1).html("");
}
}
@@ -49,23 +28,21 @@ function md_rec_data(k, mdu, id) {
if (window.sessionStorage.getItem(k + mdu) !== null) {
var editor = $("#e_tips_" + id).data('editor');
editor.setValue(window.sessionStorage.getItem(k + mdu));
- // debugger;
- // /shixuns/b5hjq9zm/challenges/3977/tab=3 setValue可能导致editor样式问题
md_clear_data(k, mdu, id);
}
}
window.md_rec_data = md_rec_data;
-function md_elocalStorage(editor,mdu,id){
- if (window.sessionStorage){
- var oc = window.sessionStorage.getItem('content'+mdu);
- if(oc !== null ){
- console.log("#e_tips_"+id)
- $("#e_tips_"+id).data('editor', editor);
- var h = '您上次有已保存的数据,是否恢复 ? / 不恢复';
- $("#e_tips_"+id).html(h);
+function md_elocalStorage(editor, mdu, id) {
+ if (window.sessionStorage) {
+ var oc = window.sessionStorage.getItem('content' + mdu);
+ if (oc !== null) {
+ console.log("#e_tips_" + id)
+ $("#e_tips_" + id).data('editor', editor);
+ var h = '您上次有已保存的数据,是否恢复 ? / 不恢复';
+ $("#e_tips_" + id).html(h);
}
- setInterval(function() {
+ setInterval(function () {
var d = new Date();
var h = d.getHours();
var m = d.getMinutes();
@@ -73,18 +50,18 @@ function md_elocalStorage(editor,mdu,id){
h = h < 10 ? '0' + h : h;
m = m < 10 ? '0' + m : m;
s = s < 10 ? '0' + s : s;
- if(editor.getValue().trim() != ""){
- md_add_data("content",mdu,editor.getValue());
- var id1 = "#e_tip_"+id;
- var id2 = "#e_tips_"+id;
+ if (editor.getValue().trim() != "") {
+ md_add_data("content", mdu, editor.getValue());
+ var id1 = "#e_tip_" + id;
+ var id2 = "#e_tips_" + id;
- $(id1).html(" 数据已于 " + h + ':' + m + ':' + s +" 保存 ");
+ $(id1).html(" 数据已于 " + h + ':' + m + ':' + s + " 保存 ");
$(id2).html("");
}
- },10000);
+ }, 10000);
- }else{
- $("#e_tip_"+id).after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!');
+ } else {
+ $("#e_tip_" + id).after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!');
}
}
@@ -94,7 +71,7 @@ function create_editorMD(id, width, high, placeholder, imageUrl, callback, initV
width: width,
height: high,
path: path, // "/editormd/lib/"
- markdown : initValue,
+ markdown: initValue,
syncScrolling: "single",
@@ -124,7 +101,7 @@ function create_editorMD(id, width, high, placeholder, imageUrl, callback, initV
imageUpload: true,
imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
imageUploadURL: imageUrl,//url
- onload: function() {
+ onload: function () {
let _id = this.id // 如果要使用this,这里不能使用箭头函数
let _editorName = this;
// this.previewing();
@@ -164,7 +141,7 @@ export default class CoursesMarkdown extends Component {
}
}
componentDidMount = () => {
- const { mdID, initValue ,placeholder} = this.props;
+ const { mdID, initValue, placeholder } = this.props;
// let initValue = 'initValue'
let _id = `mdEditor_${mdID}`
this.contentChanged = false;
@@ -181,11 +158,11 @@ export default class CoursesMarkdown extends Component {
}, 500)
if (initValue != undefined) {
- answers_editormd.setValue(initValue)
+ answers_editormd.setValue(initValue)
}
answers_editormd.cm.on("change", (_cm, changeObj) => {
- console.log('....contentChanged')
- this.contentChanged = true;
+ console.log('....contentChanged')
+ this.contentChanged = true;
})
}, initValue);
this.answers_editormd = answers_editormd;
@@ -208,7 +185,7 @@ export default class CoursesMarkdown extends Component {
{/* padding10-20 */}
diff --git a/public/react/src/modules/courses/exercise/new/NullEditor.js b/public/react/src/modules/courses/exercise/new/NullEditor.js
index dcb310396..de7558d2f 100644
--- a/public/react/src/modules/courses/exercise/new/NullEditor.js
+++ b/public/react/src/modules/courses/exercise/new/NullEditor.js
@@ -1,24 +1,15 @@
-import React,{ Component } from "react";
-
-import {
- Form, Input, InputNumber, Switch, Radio,
- Slider, Button, Upload, Icon, Rate, Checkbox, message,
- Row, Col, Select, Modal, Tooltip
-} from 'antd';
-import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
+import React, { Component } from "react";
+
+import { InputNumber, Checkbox, } from 'antd';
import axios from 'axios'
import update from 'immutability-helper'
import { qNameArray } from './common'
import NullMDEditor from './NullMDEditor'
import NullChildEditor from './NullChildEditor'
-import {getUrl, ActionBtn, DMDEditor} from 'educoder';
-const { TextArea } = Input;
-const confirm = Modal.confirm;
-const $ = window.$
-const { Option } = Select;
-
-class NullEditor extends Component{
- constructor(props){
+import { ActionBtn } from 'educoder';
+
+class NullEditor extends Component {
+ constructor(props) {
super(props);
/**
choice_id: 32076
@@ -28,7 +19,7 @@ class NullEditor extends Component{
standard_answer: [{choice_id: 1, answer_text: ["2", "22"]}]
*/
- const {question_choices, standard_answer} = this.props;
+ const { question_choices, standard_answer } = this.props;
let _standard_answers = undefined;
if (standard_answer) {
_standard_answers = []
@@ -38,7 +29,7 @@ class NullEditor extends Component{
answers.answer_text.forEach((item, itemIndex) => {
_standard_answers[index].push(item)
})
-
+
})
}
this.state = {
@@ -50,25 +41,25 @@ class NullEditor extends Component{
}
}
on_is_ordered_change = (e) => {
- this.setState({ is_ordered: e.target.checked})
+ this.setState({ is_ordered: e.target.checked })
}
-
+
onSave = () => {
- const {question_title, question_score, question_type, question_choices, standard_answers, is_ordered } = this.state;
+ const { question_title, question_score, question_type, question_choices, standard_answers, is_ordered } = this.state;
const { question_id_to_insert_after, question_id } = this.props
- let newis_ordered= is_ordered;
+ let newis_ordered = is_ordered;
- if(newis_ordered===true){
- if(standard_answers.length===1){
- newis_ordered=false
+ if (newis_ordered === true) {
+ if (standard_answers.length === 1) {
+ newis_ordered = false
}
}
// TODO check
// const answerArray = standard_answers.map((item, index) => { return item == true ? index+1 : -1 }).filter(item => item != -1);
let answerArray = []
- if(!question_title) {
+ if (!question_title) {
this.refs['titleEditor'].showError()
this.props.showNotification('题目:不能为空'); return;
@@ -76,53 +67,37 @@ class NullEditor extends Component{
const intScore = parseFloat(question_score)
if (intScore == 0) {
this.props.showNotification('分值:必须大于0'); return;
- } else if(!question_score || intScore == NaN) {
+ } else if (!question_score || intScore == NaN) {
this.props.showNotification('分值:不能为空'); return;
- }
-
+ }
+
let isEmpty = false;
standard_answers.forEach((answers, index) => {
answerArray.push({
"choice_id": index + 1,
- "answer_text":[]
+ "answer_text": []
})
answers.forEach((item, itemIndex) => {
answerArray[index].answer_text.push(item)
- if(!item) {
+ if (!item) {
this.refs[`nullChildEditor${index}`].showError(itemIndex)
// this.props.showNotification(`请先输入第${index+1}个填空的第${itemIndex+1}参考答案。`);
- this.props.showNotification(`答案:不能为空`);
+ this.props.showNotification(`答案:不能为空`);
isEmpty = true;
}
})
})
- if (isEmpty == true) {
+ if (isEmpty == true) {
return;
}
- if(!question_title) {
+ if (!question_title) {
this.refs['titleEditor'].showError()
this.props.showNotification('题目:不能为空'); return;
}
- /**
- {
- "question_title":"社会主义核心价值观(),(),()...",
- "question_type":3,
- "question_score":5,
- "standard_answers":[
- {"choice_id":1,
- "answer_text":["abbc","xxx","sssss"]
- },
- {"choice_id":2,
- "answer_text":["abbc","xxx","sssss"]
- }
- ]
- "is_ordered":true
-}
- }*/
- const Id = this.props.match.params.Id
+ const Id = this.props.match.params.Id
if (question_id) {
const editUrl = this.props.getEditQuestionUrl(question_id);
axios.put(editUrl, {
@@ -132,21 +107,21 @@ class NullEditor extends Component{
question_choices,
standard_answers: answerArray,
insert_id: question_id_to_insert_after || undefined,
- is_ordered:newis_ordered,
+ is_ordered: newis_ordered,
}).then((response) => {
- if (response.data.status == 0) {
- this.props.addSuccess()
- }else if(response.data.status == 3){
- // 已发布试卷编辑保存
- this.props.changeScore(question_id,answerArray);
- }
- })
+ if (response.data.status == 0) {
+ this.props.addSuccess()
+ } else if (response.data.status == 3) {
+ // 已发布试卷编辑保存
+ this.props.changeScore(question_id, answerArray);
+ }
+ })
.catch(function (error) {
console.log(error);
});
} else {
const url = this.props.getAddQuestionUrl();
-
+
axios.post(url, {
exercise_bank_id: Id,
question_title,
@@ -155,7 +130,7 @@ class NullEditor extends Component{
question_choices,
standard_answers: answerArray,
insert_id: question_id_to_insert_after || undefined,
- is_ordered:newis_ordered,
+ is_ordered: newis_ordered,
})
.then((response) => {
if (response.data.status == 0) {
@@ -165,13 +140,13 @@ class NullEditor extends Component{
.catch(function (error) {
console.log(error);
});
- }
+ }
}
onCancel = () => {
this.props.onEditorCancel()
}
componentDidMount = () => {
-
+
}
on_question_score_change = (e) => {
this.setState({ question_score: e })
@@ -186,7 +161,7 @@ class NullEditor extends Component{
new_standard_answers.splice(placeholderCountBefore, placeholderCountInRange)
}
if (totalPlaceholderCount) {
- for(let i = 0; i < totalPlaceholderCount; i++) {
+ for (let i = 0; i < totalPlaceholderCount; i++) {
new_standard_answers.splice(placeholderCountBefore + i, 0, [""])
}
}
@@ -195,35 +170,36 @@ class NullEditor extends Component{
this.mdReactObject.toShowMode()
}
})
-
+
}
-
+
onAnswerChange = (index, itemIndex, val) => {
if (this.state.standard_answers[index]) {
- this.setState(
- (prevState) => ({
- standard_answers : update(prevState.standard_answers
- , {[index]: {$splice: [[itemIndex, 1, val]]}}),
+ this.setState(
+ (prevState) => ({
+ standard_answers: update(prevState.standard_answers
+ , { [index]: { $splice: [[itemIndex, 1, val]] } }),
})
)
}
}
addChildAnswer = (index) => {
this.setState(
- (prevState) => ({
- standard_answers : update(prevState.standard_answers
- , {[index]: {$push: ['']}}),
- })
- )
+ (prevState) => ({
+ standard_answers: update(prevState.standard_answers
+ , { [index]: { $push: [''] } }),
+ })
+ )
}
deleteChildAnswer = (index, childIndex) => {
- if(!this.state.standard_answers[index][childIndex]) {
+ if (!this.state.standard_answers[index][childIndex]) {
this.setState(
(prevState) => ({
- standard_answers : update(prevState.standard_answers,
- {[index]:
- {$splice: [[childIndex, 1]]}
+ standard_answers: update(prevState.standard_answers,
+ {
+ [index]:
+ { $splice: [[childIndex, 1]] }
}
)
})
@@ -235,9 +211,10 @@ class NullEditor extends Component{
onOk: () => {
this.setState(
(prevState) => ({
- standard_answers : update(prevState.standard_answers,
- {[index]:
- {$splice: [[childIndex, 1]]}
+ standard_answers: update(prevState.standard_answers,
+ {
+ [index]:
+ { $splice: [[childIndex, 1]] }
}
)
})
@@ -258,28 +235,21 @@ class NullEditor extends Component{
}
this.mdReactObject = that;
}
-
+
render() {
let { question_title, question_score, question_type, question_choices, standard_answers
, is_ordered } = this.state;
let { question_id, index, exerciseIsPublish,
- // question_title,
- // question_type,
- // question_score,
- isNew } = this.props;
-
- // const { getFieldDecorator } = this.props.form;
-
- const isAdmin = this.props.isAdmin()
- const courseId=this.props.match.params.coursesId;
- const isEdit = !!this.props.question_id
+ isNew } = this.props;
+
+
const qNumber = `question_${index}`;
// console.log(this.state.showtype)
// const answerTagArray = standard_answers.map((item, index) => { return item == true ? tagArray[index] : -1 }).filter(item => item != -1);
- return(
-
-
-
{/*!question_id ? '新建' : '编辑'*/}
- {qNameArray[question_type]}
- (客观题,由系统自动评分,允许手动调分,请设置标准答案 ;支持最多5个空,每空得分按照本题的总分平均计算)
-
-
-
this.setState({ question_title: val})}
- onPlaceholderChange={this.onPlaceholderChange} showNullButton={exerciseIsPublish ? false : true}
- ref="titleEditor"
- >
-
-
- {
- standard_answers.map((answers, index) => {
-
- return
- // answer.map((item, itemIndex) => {
- // return this.onAnswerChange(index, itemIndex, val)}
- // >
- // })
- })
- }
-
-
-
-
- {standard_answers.length>1?
-
- 多个填空的答案有顺序要求
- (选中,每个填空的答案顺序必须与参考答案一致)
- :""}
-
-
- 分值:
-
分
-
-
+
{/*!question_id ? '新建' : '编辑'*/}
+ {qNameArray[question_type]}
+ (客观题,由系统自动评分,允许手动调分,请设置标准答案 ;支持最多5个空,每空得分按照本题的总分平均计算)
+
+
+
this.setState({ question_title: val })}
+ onPlaceholderChange={this.onPlaceholderChange} showNullButton={exerciseIsPublish ? false : true}
+ ref="titleEditor"
+ >
+
+
+ {
+ standard_answers.map((answers, index) => {
+
+ return
+ })
+ }
+
+
+
+
+ {standard_answers.length > 1 ?
+
+ 多个填空的答案有顺序要求
+ (选中,每个填空的答案顺序必须与参考答案一致)
+ : ""}
+
+
+ 分值:
+
分
+
+
- 取消
- 保存
-
-
-
-
+
取消
+
保存
+
+
- )
- }
+
+
+ )
+ }
}
-// RouteHOC()
-export default (NullEditor);
\ No newline at end of file
+export default NullEditor;
\ No newline at end of file
diff --git a/public/react/src/modules/projectPackages/MDEditors.js b/public/react/src/modules/projectPackages/MDEditors.js
deleted file mode 100644
index 363eefabd..000000000
--- a/public/react/src/modules/projectPackages/MDEditors.js
+++ /dev/null
@@ -1,317 +0,0 @@
-import React, { Component } from 'react'
-
-import { getUploadActionUrl, getUrl } from 'educoder';
-let path = getUrl("/editormd/lib/")
-const $ = window.$;
-
-// 保存数据
-function md_add_data(k, mdu, d) {
- window.sessionStorage.setItem(k + mdu, d);
-}
-
-// 清空保存的数据
-function md_clear_data(k, mdu, id) {
- window.sessionStorage.removeItem(k + mdu);
- var id1 = "#e_tip_" + id;
- var id2 = "#e_tips_" + id;
- if (k == 'content') {
- $(id2).html(" ");
- } else {
- $(id1).html(" ");
- }
-}
-window.md_clear_data = md_clear_data
-// editor 存在了jquery对象上,应用不需要自己写md_rec_data方法了
-function md_rec_data(k, mdu, id) {
- if (window.sessionStorage.getItem(k + mdu) !== null) {
- var editor = $("#e_tips_" + id).data('editor');
- editor.setValue(window.sessionStorage.getItem(k + mdu));
- // debugger;
- // /shixuns/b5hjq9zm/challenges/3977/tab=3 setValue可能导致editor样式问题
- md_clear_data(k, mdu, id);
- }
-}
-window.md_rec_data = md_rec_data;
-
-function md_elocalStorage(editor, mdu, id) {
- if (window.sessionStorage) {
- var oc = window.sessionStorage.getItem('content' + mdu);
- if (oc !== null) {
- console.log("#e_tips_" + id)
- $("#e_tips_" + id).data('editor', editor);
- var h = '您上次有已保存的数据,是否
恢复 ? /
不恢复';
- $("#e_tips_" + id).html(h);
- }
- setInterval(function () {
- var d = new Date();
- var h = d.getHours();
- var m = d.getMinutes();
- var s = d.getSeconds();
- h = h < 10 ? '0' + h : h;
- m = m < 10 ? '0' + m : m;
- s = s < 10 ? '0' + s : s;
- if (editor.getValue().trim() != "") {
- md_add_data("content", mdu, editor.getValue());
- var id1 = "#e_tip_" + id;
- var id2 = "#e_tips_" + id;
-
- var textStart = " 数据已于 "
- var text = textStart + h + ':' + m + ':' + s + " 保存 ";
- // 占位符
- var oldHtml = $(id2).html();
- if (oldHtml && oldHtml != ' ' && oldHtml.startsWith(textStart) == false) {
- $(id2).html(oldHtml.split(' (')[0] + ` (${text})`);
- } else {
- $(id2).html(text);
- }
- // $(id2).html("");
- }
- }, 10000);
-
- } else {
- $("#e_tip_" + id).after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!');
- }
-}
-
-
-function create_editorMD(id, width, high, placeholder, imageUrl, callback, initValue,
- onchange, watch, { noStorage, showNullButton }, that) {
- // 还是出现了setting只有一份,被共用的问题
-
- var editorName = window.editormd(id, {
- width: width,
- height: high === undefined ? 400 : high,
- path: path, // "/editormd/lib/"
- markdown: initValue,
-
- dialogLockScreen: false,
- watch: watch === undefined ? true : watch,
- syncScrolling: "single",
- tex: true,
- tocm: true,
- emoji: true,
- taskList: true,
- codeFold: true,
- searchReplace: true,
- htmlDecode: "style,script,iframe",
- sequenceDiagram: true,
- autoFocus: false,
-
- // mine
-
- toolbarIcons: function (mdEditor) {
- //
- // let react_id = `react_${id}`;
- // const __that = window[react_id]
-
- // Or return editormd.toolbarModes[name]; // full, simple, mini
- // Using "||" set icons align right.
- const icons = ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"];
- // if (__that.props.showNullButton) {
- // icons.push('nullBtton')
- // }
- return icons
-
-
- },
- toolbarCustomIcons: {
- testIcon: "
",
- testIcon1: "
",
- nullBtton: "
点击插入填空项",
- },
- //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。
- saveHTMLToTextarea: true,
- // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标
- dialogMaskOpacity: 0.6,
- placeholder: placeholder,
- imageUpload: true,
- imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
- imageUploadURL: imageUrl,//url
- onchange: onchange,
- onload: function () {
- let _id = this.id // 如果要使用this,这里不能使用箭头函数
- let _editorName = this;
- let react_id = `react_${_editorName.id}`;
- const __that = window[react_id]
-
- // this.previewing();
- // let _id = id;
- $("#" + _id + " [type=\"latex\"]").bind("click", function () {
- _editorName.cm.replaceSelection("```latex");
- _editorName.cm.replaceSelection("\n");
- _editorName.cm.replaceSelection("\n");
- _editorName.cm.replaceSelection("```");
- var __Cursor = _editorName.cm.getDoc().getCursor();
- _editorName.cm.setCursor(__Cursor.line - 1, 0);
- });
-
- $("#" + _id + " [type=\"inline\"]").bind("click", function () {
- _editorName.cm.replaceSelection("`$$$$`");
- var __Cursor = _editorName.cm.getDoc().getCursor();
- _editorName.cm.setCursor(__Cursor.line, __Cursor.ch - 3);
- _editorName.cm.focus();
- });
- $("[type=\"inline\"]").attr("title", "行内公式");
- $("[type=\"latex\"]").attr("title", "多行公式");
-
- if (__that.props.showNullButton) {
- const NULL_CH = '▁'
- // const NULL_CH = '〇'
- // const NULL_CH = '🈳'
-
- $("#" + _id + " [type=\"nullBtton\"]").bind("click", function () {
- _editorName.cm.replaceSelection(NULL_CH);
- // var __Cursor = _editorName.cm.getDoc().getCursor();
- // _editorName.cm.setCursor(__Cursor.line - 1, 0);
- });
- }
-
- if (noStorage == true) {
-
- } else {
- md_elocalStorage(_editorName, `MDEditor__${_id}`, _id);
- }
-
- callback && callback(_editorName)
- }
- });
- return editorName;
-}
-
-
-export default class MDEditors extends Component {
- constructor(props) {
- super(props)
- this.state = {
- initValue: ''
- }
- }
- componentDidUpdate(prevProps, prevState) {
- // 不能加,影响了试卷填空题
- // if (this.props.initValue != prevProps.initValue) {
- // this.answers_editormd.setValue(this.props.initValue)
- // }
- }
-
- // react_mdEditor_
- componentDidMount = () => {
- const { mdID, initValue, placeholder, showNullButton } = this.props;
-
- let _id = `mdEditor_${mdID}`
- this.contentChanged = false;
- const _placeholder = placeholder || "";
- // amp;
- // 编辑时要传memoId
- const imageUrl = `${getUploadActionUrl()}`;
- // 创建editorMd
- let react_id = `react_${_id}`;
-
- window[react_id] = this
- const answers_editormd = create_editorMD(_id, '100%', this.props.height, _placeholder, imageUrl, (__editorName) => {
- react_id = `react_${__editorName.id}`;
- const that = window[react_id]
-
- setTimeout(() => {
- console.log('timeout', __editorName.id)
- __editorName.resize()
- __editorName.cm && __editorName.cm.refresh()
- }, that.props.refreshTimeout || 500)
- if (that.props.initValue != undefined && that.props.initValue != '') {
- __editorName.setValue(that.props.initValue)
- }
- if (that.state.initValue) {
- __editorName.setValue(that.state.initValue)
- }
- __editorName.cm.on("change", (_cm, changeObj) => {
- that.contentChanged = true;
- if (that.state.showError) {
- that.setState({ showError: false })
- }
- that.onEditorChange()
- })
- that.props.onCMBlur && __editorName.cm.on('blur', () => {
- that.props.onCMBlur()
- })
- that.props.onCMBeforeChange && __editorName.cm.on('beforeChange', (cm, change) => {
- that.props.onCMBeforeChange(cm, change)
- })
- that.answers_editormd = __editorName;
- window[_id] = __editorName;
- }, initValue, this.onEditorChange, this.props.watch, {
- noStorage: this.props.noStorage,
- showNullButton: this.props.showNullButton
- }, this);
-
- }
- showError = () => {
- this.setState({ showError: true })
- }
- onEditorChange = () => {
- this.props.setcheckoutcontent()
- if (!this.answers_editormd) return;
- const val = this.answers_editormd.getValue();
- try {
- this.props.onChange && this.props.onChange(val)
- } catch (e) {
- // http://localhost:3007/courses/1309/common_homeworks/6566/setting
- // 从这个页面,跳转到编辑页面,再在编辑页面点击返回的时候,这里会报错
- console.error('出错')
- console.error(e)
- }
- }
- resize = () => {
- if (!this.answers_editormd) { // 还未初始化
- return;
- }
- this.answers_editormd.resize()
- this.answers_editormd.cm && this.answers_editormd.cm.refresh()
- this.answers_editormd.cm.focus()
- }
-
- getValue = () => {
- try {
- return this.answers_editormd.getValue()
- } catch (e) {
- return ''
- }
- }
- setValue = (val) => {
- try {
- this.answers_editormd.setValue(val)
- } catch (e) {
- // TODO 这里多实例的时候,前一个实例的state会被后面这个覆盖 参考NewWork.js http://localhost:3007/courses/1309/homework/9300/edit/1
- // 未初始化
- this.setState({ initValue: val })
- }
- }
-
- render() {
-
- let {
- showError
- } = this.state;
- let { mdID, className, noStorage } = this.props;
- let _style = {}
- if (showError) {
- _style.border = '1px solid red'
- }
- return (
-
-
- {/* padding10-20 */}
-
-
-
- {noStorage == true ? ' ' :
}
- {/* {noStorage == true ? ' ' :
} */}
-
-
- )
- }
-}
-
-
diff --git a/public/react/src/modules/projectPackages/PackageIndexNewandEdit/PackageIndexNEIBannerConcent.js b/public/react/src/modules/projectPackages/PackageIndexNewandEdit/PackageIndexNEIBannerConcent.js
index 1cde267c5..5d53f1324 100644
--- a/public/react/src/modules/projectPackages/PackageIndexNewandEdit/PackageIndexNEIBannerConcent.js
+++ b/public/react/src/modules/projectPackages/PackageIndexNewandEdit/PackageIndexNEIBannerConcent.js
@@ -1,11 +1,10 @@
import React, { Component } from 'react';
import axios from 'axios';
-import { Input, Spin, Icon, Button, Pagination, DatePicker } from 'antd';
+import { Input, Spin, Button, DatePicker } from 'antd';
import { handleDateString, getUrl, setmiyah } from 'educoder';
-import locale from 'antd/lib/date-picker/locale/zh_CN';
-import MDEditors from '../MDEditors';
import moment from 'moment';
import '../packageconcnet.css';
+import MDEditors from '../../tpm/challengesnew/TPMMDEditor';
const { Search } = Input;
const $ = window.$;
let origin = getUrl();
diff --git a/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js b/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js
index 13b1f61f8..b67b9dfd5 100644
--- a/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js
+++ b/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js
@@ -5,9 +5,6 @@ import '../../courses/css/Courses.css'
import './css/TPMchallengesnew.css';
require('codemirror/lib/codemirror.css');
-
-let path = '/editormd/lib/'
-path = getUrl("/editormd/lib/")
const $ = window.$;
@@ -191,13 +188,6 @@ export default class TPMMDEditor extends Component {
initValue: ''
}
}
- componentDidUpdate(prevProps, prevState) {
- // 不能加,影响了试卷填空题
- // if (this.props.initValue != prevProps.initValue) {
- // this.answers_editormd.setValue(this.props.initValue)
- // }
- }
-
// react_mdEditor_
componentDidMount = () => {
const { mdID, initValue, placeholder, showNullButton } = this.props;