From eada0a6f795027cd8ae38e2db440948f404fb9ff Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Mon, 30 Dec 2019 09:21:01 +0800
Subject: [PATCH 01/21] update edit page
---
public/react/src/constants/index.js | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/public/react/src/constants/index.js b/public/react/src/constants/index.js
index 3e7aceab0..c0e6074fc 100644
--- a/public/react/src/constants/index.js
+++ b/public/react/src/constants/index.js
@@ -3,8 +3,8 @@
* @Author: tangjiang
* @Github:
* @Date: 2019-11-20 23:10:48
- * @LastEditors: tangjiang
- * @LastEditTime: 2019-12-06 15:53:27
+ * @LastEditors : tangjiang
+ * @LastEditTime : 2019-12-30 09:19:52
*/
const CONST = {
jcLabel: {
@@ -12,9 +12,10 @@ const CONST = {
language: '编程语言',
description: '描述',
difficult: '难易度',
- category: '分类',
+ category: '课程',
openOrNot: '公开程序',
- timeLimit: '时间限制'
+ timeLimit: '时间限制',
+ // knowledge: '知识点'
},
fontSetting: {
title: '代码格式',
From bbc079b7036e61483a1c3f5c3018f7efd869c515 Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Mon, 30 Dec 2019 11:09:01 +0800
Subject: [PATCH 02/21] add course question
---
.../newOrEditTask/leftpane/editorTab/index.js | 92 +++++++++++++++++--
.../modules/developer/split_pane_resizer.scss | 4 +
public/react/src/redux/actions/actionTypes.js | 2 +
public/react/src/redux/actions/index.js | 3 +
public/react/src/redux/actions/ojForm.js | 23 ++++-
.../react/src/redux/reducers/ojFormReducer.js | 8 +-
public/react/src/services/ojService.js | 8 +-
7 files changed, 127 insertions(+), 13 deletions(-)
diff --git a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
index d4fc12b9c..8172a7778 100644
--- a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
+++ b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
@@ -4,12 +4,12 @@
* @Github:
* @Date: 2019-11-20 10:35:40
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-27 14:30:55
+ * @LastEditTime : 2019-12-30 11:05:14
*/
import './index.scss';
// import 'katex/dist/katex.css';
import React from 'react';
-import { Form, Input, Select, InputNumber, Button } from 'antd';
+import { Form, Input, Select, InputNumber, Button, Cascader } from 'antd';
import { connect } from 'react-redux';
import AddTestDemo from './AddTestDemo';
// import QuillEditor from '../../../quillEditor';
@@ -77,6 +77,10 @@ class EditTab extends React.Component {
}, () => {
this.state.scrollEl.addEventListener('scroll', this.handleScroll, false);
});
+ // 获取题库
+ this.props.getQuestion({
+ source: 'question'
+ });
}
componentWillUnmount () {
@@ -127,7 +131,8 @@ class EditTab extends React.Component {
}
// 改变分类
handleChangeCategory = (value) => {
- this.props.validateOjCategory(value);
+ console.log(value);
+ // this.props.validateOjCategory(value);
}
// 改变公开程序
handleChangeOpenOrNot = (value) => {
@@ -146,7 +151,8 @@ class EditTab extends React.Component {
addTestCase, // 添加测试用例
deleteTestCase, // 删除测试用例
testCasesValidate,
- openTestCodeIndex = []
+ openTestCodeIndex = [],
+ courseQuestions
} = this.props;
// 表单label
const myLabel = (name, subTitle) => {
@@ -244,6 +250,59 @@ class EditTab extends React.Component {
['image', 'formula'], // 数学公式、图片、视频
['clean'], // 清除格式
];
+
+ const renderCourseQuestion = (arrs) => {
+ const tempArr = [];
+ function loop (arrs, tempArr) {
+ arrs.forEach(item => {
+ const obj = {};
+ obj.value = item.id;
+ obj.label = item.name;
+ // 当item下还有子元素时,递归调用
+ if (item.sub_disciplines || item.tag_disciplines) {
+ arrs = item.sub_disciplines || item.tag_disciplines;
+ obj.children = [];
+ loop(arrs, obj.children);
+ }
+ tempArr.push(obj);
+ });
+ }
+ loop(arrs, tempArr);
+ // arrs.forEach(item => {
+ // const obj = Object.create(null);
+ // obj.value = item.id;
+ // obj.label = item.name;
+ // if (item.sub_disciplines) {
+ // obj.children = [];
+ // item.sub_disciplines.forEach(sub => {
+ // const subObj = Object.create(null);
+ // subObj.value = sub.id;
+ // subObj.label = sub.name;
+
+ // if (sub.tag_disciplines) {
+ // subObj.children = [];
+ // sub.tag_disciplines.forEach(tag => {
+ // const tabObj = Object.create(null);
+ // tabObj.value = tag.id;
+ // tabObj.label = tag.name;
+ // subObj.children.push(tabObj);
+ // });
+ // }
+ // obj.children.push(subObj);
+ // })
+ // }
+ // tempArr.push(obj);
+ // });
+ console.log(tempArr);
+ return (
+
+ )
+ }
return (
@@ -262,14 +321,24 @@ class EditTab extends React.Component {
{myLabel(jcLabel['category'], '合理的分类有利于快速检索')}}
+ label={{myLabel(jcLabel['category'], '合理的课程分类有利于快速检索')}}
validateStatus={ojFormValidate.category.validateStatus}
help={ojFormValidate.category.errMsg}
colon={ false }
>
- */}
+ {/* */}
+ { renderCourseQuestion(courseQuestions)}
+
+
+
+
{
testCases,
openTestCodeIndex,
testCasesValidate,
- ojFormValidate} = ojFormReducer;
+ ojFormValidate,
+ courseQuestions
+ } = ojFormReducer;
return {
ojForm,
testCases,
testCasesValidate,
ojFormValidate,
position,
- openTestCodeIndex
+ openTestCodeIndex,
+ courseQuestions
};
};
@@ -390,6 +462,8 @@ const mapDispatchToProps = (dispatch) => ({
addTestCase: (value) => dispatch(actions.addTestCase(value)),
// 删除测试用例
deleteTestCase: (value) => dispatch(actions.deleteTestCase(value)),
+ // 获取题库
+ getQuestion: (params) => dispatch(actions.getQuestion(params))
});
export default connect(
diff --git a/public/react/src/modules/developer/split_pane_resizer.scss b/public/react/src/modules/developer/split_pane_resizer.scss
index 8fc8b525f..26fc21479 100644
--- a/public/react/src/modules/developer/split_pane_resizer.scss
+++ b/public/react/src/modules/developer/split_pane_resizer.scss
@@ -23,6 +23,8 @@
}
.header_title{
+ font-size: 16px;
+ font-weight: bold;
text-align: center;
}
@@ -82,6 +84,8 @@
bottom: 0;
top: 0;
text-align: center;
+ font-size: 16px;
+ font-weight: bold;
}
}
}
diff --git a/public/react/src/redux/actions/actionTypes.js b/public/react/src/redux/actions/actionTypes.js
index 73e3ea0b2..e3ae7044b 100644
--- a/public/react/src/redux/actions/actionTypes.js
+++ b/public/react/src/redux/actions/actionTypes.js
@@ -32,6 +32,8 @@ const types = {
TEST_CASE_INPUT_CHANGE: 'TEST_CASE_INPUT_CHANGE', // 测试用例输入值改变时
TEST_CASE_OUTPUT_CHANGE: 'TEST_CASE_OUTPUT_CHANGE', // 测试用例输出值改变时
DEBUGGER_CODE: 'DEBUGGER_CODE', // 调试代码
+ GET_COURSE_QUESTION: 'GET_COURSE_QUESTION', // 获取编辑题
+ // study
SAVE_USER_PROGRAM_ID: 'SAVE_USER_PROGRAM_ID',// 保存用户编程题id值
USER_PROGRAM_DETAIL: 'USER_PROGRAM_DETAIL', // 用户编程题详情
SHOW_OR_HIDE_CONTROL: 'SHOW_OR_HIDE_CONTROL', // 显示或隐藏控制台
diff --git a/public/react/src/redux/actions/index.js b/public/react/src/redux/actions/index.js
index 988a0a469..263e367df 100644
--- a/public/react/src/redux/actions/index.js
+++ b/public/react/src/redux/actions/index.js
@@ -32,6 +32,7 @@ import {
updateTestAndValidate,
updateOpenTestCaseIndex,
handleClickCancelPublish,
+ getQuestion
} from './ojForm';
import {
@@ -110,6 +111,8 @@ export default {
validateOjCategory,
validateOpenOrNot,
handleClickCancelPublish,
+ getQuestion,
+ //
addTestCase,
deleteTestCase,
testCaseInputChange,
diff --git a/public/react/src/redux/actions/ojForm.js b/public/react/src/redux/actions/ojForm.js
index 118295802..401c4f203 100644
--- a/public/react/src/redux/actions/ojForm.js
+++ b/public/react/src/redux/actions/ojForm.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 16:35:46
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-27 22:19:15
+ * @LastEditTime : 2019-12-30 09:56:39
*/
import types from './actionTypes';
import CONST from '../../constants';
@@ -12,7 +12,8 @@ import {
fetchPostOjForm,
fetchGetOjById,
publishTask,
- cancelPublicTask
+ cancelPublicTask,
+ fetchQuestion
} from '../../services/ojService';
import { Base64 } from 'js-base64';
import { notification } from 'antd';
@@ -644,3 +645,21 @@ export const updateOpenTestCaseIndex = (value) => {
payload: value
}
}
+
+// 获取课程题库
+export const getQuestion = (params) => {
+ // return {
+ // type: types.GET_COURSE_QUESTION,
+ // }
+ return (dispatch) => {
+ fetchQuestion(params).then(res => {
+ const { data = {} } = res;
+ const { disciplines = [] } = data;
+ console.log('获取课程题库成功: ', res);
+ dispatch({
+ type: types.GET_COURSE_QUESTION,
+ payload: disciplines
+ })
+ })
+ }
+}
diff --git a/public/react/src/redux/reducers/ojFormReducer.js b/public/react/src/redux/reducers/ojFormReducer.js
index 952919aca..5beba6653 100644
--- a/public/react/src/redux/reducers/ojFormReducer.js
+++ b/public/react/src/redux/reducers/ojFormReducer.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 16:40:32
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-27 20:00:26
+ * @LastEditTime : 2019-12-30 09:55:37
*/
import { Base64 } from 'js-base64';
import types from '../actions/actionTypes';
@@ -67,6 +67,7 @@ const init = {
testCodeStatus: 'default', // 调试代码状态 default(默认值) | loading(加载中) | loaded(加载完成) | userCase(用户自定义测试用例) | finish(测试完成)
openTestCodeIndex: [0], // 展开的测试用例: 数组, 当出错时,展开所有出错的测试用例, 默认展开第一个
isPublish: 0, // 是否是发布状态: 0 未发布 1 已发布
+ courseQuestions: [], // 课程题库
}
const tcValidateObj = {
@@ -306,6 +307,11 @@ const ojFormReducer = (state = initialState, action) => {
...state,
openTestCodeIndex: tempArr
}
+ case types.GET_COURSE_QUESTION:
+ return {
+ ...state,
+ courseQuestions: action.payload
+ }
default:
return state;
}
diff --git a/public/react/src/services/ojService.js b/public/react/src/services/ojService.js
index 04fde2224..59151e687 100644
--- a/public/react/src/services/ojService.js
+++ b/public/react/src/services/ojService.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 10:55:38
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-27 11:06:27
+ * @LastEditTime : 2019-12-30 09:44:56
*/
import axios from 'axios';
@@ -142,4 +142,10 @@ export async function fetchUploadImageUrl (id) {
export async function fetchAddNotes (identifier, params) {
const url = `/myproblems/${identifier}/add_notes.json`;
return axios.post(url, params);
+}
+
+// 获取课程体系
+export async function fetchQuestion (params) {
+ const url = `/disciplines.json`;
+ return axios.get(url, { params });
}
\ No newline at end of file
From 1075b49f6acc0a27accc16bbeae3fd1e9b60ab58 Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Mon, 30 Dec 2019 14:23:40 +0800
Subject: [PATCH 03/21] add selector
---
.../developer/components/knowledge/index.js | 47 +++++++++++++++++++
.../developer/components/knowledge/index.scss | 0
2 files changed, 47 insertions(+)
create mode 100644 public/react/src/modules/developer/components/knowledge/index.js
create mode 100644 public/react/src/modules/developer/components/knowledge/index.scss
diff --git a/public/react/src/modules/developer/components/knowledge/index.js b/public/react/src/modules/developer/components/knowledge/index.js
new file mode 100644
index 000000000..b4328376d
--- /dev/null
+++ b/public/react/src/modules/developer/components/knowledge/index.js
@@ -0,0 +1,47 @@
+/*
+ * @Description: 知识点
+ * @Author: tangjiang
+ * @Github:
+ * @Date: 2019-12-30 13:51:19
+ * @LastEditors : tangjiang
+ * @LastEditTime : 2019-12-30 14:20:50
+ */
+import './index.scss';
+import React, { useState } from 'react';
+import { Select } from 'antd';
+
+function KnowLedge (props) {
+
+ const {
+ options = [], // 下拉选项
+ values = [], // 已选择的下拉项
+ } = props;
+
+ // 显示的下拉项
+ const [selectOptions, setSelectOptions] = useState(options);
+ // 已选择的下拉项
+ const [selectValue, setSelectValue] = useState(values);
+
+ // 渲染下拉选项
+ // 渲染下拉列表
+ const renderSelect = (options, values) => {
+ return (
+
+
+
+ )
+ }
+
+ return (
+
+ { renderSelect(selectOptions, selectValue) }
+
+
+
+
+ );
+}
+
+export default KnowLedge;
diff --git a/public/react/src/modules/developer/components/knowledge/index.scss b/public/react/src/modules/developer/components/knowledge/index.scss
new file mode 100644
index 000000000..e69de29bb
From 9a97db2893bfbc6c35c7cc9d0660ba0f023af0fe Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Mon, 30 Dec 2019 14:31:13 +0800
Subject: [PATCH 04/21] add selector
---
.../modules/developer/components/knowledge/index.js | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/public/react/src/modules/developer/components/knowledge/index.js b/public/react/src/modules/developer/components/knowledge/index.js
index b4328376d..81e9f770a 100644
--- a/public/react/src/modules/developer/components/knowledge/index.js
+++ b/public/react/src/modules/developer/components/knowledge/index.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-12-30 13:51:19
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-30 14:20:50
+ * @LastEditTime : 2019-12-30 14:28:17
*/
import './index.scss';
import React, { useState } from 'react';
@@ -23,13 +23,22 @@ function KnowLedge (props) {
const [selectValue, setSelectValue] = useState(values);
// 渲染下拉选项
+ const renderOptions = () => {
+
+ }
+ const handleSelectChange = (value) => {
+ console.log(value);
+ }
+
// 渲染下拉列表
const renderSelect = (options, values) => {
return (
-
+ {renderOptions(options)}
)
}
From 8ac904a82d24f640b7f39e211556ad3fd5f7b785 Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Mon, 30 Dec 2019 16:58:10 +0800
Subject: [PATCH 05/21] add selector
---
public/react/src/constants/index.js | 4 +-
.../developer/components/knowledge/index.js | 14 +++++--
.../newOrEditTask/leftpane/editorTab/index.js | 41 ++++++++++++++-----
3 files changed, 44 insertions(+), 15 deletions(-)
diff --git a/public/react/src/constants/index.js b/public/react/src/constants/index.js
index c0e6074fc..623cff362 100644
--- a/public/react/src/constants/index.js
+++ b/public/react/src/constants/index.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 23:10:48
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-30 09:19:52
+ * @LastEditTime : 2019-12-30 14:44:45
*/
const CONST = {
jcLabel: {
@@ -15,7 +15,7 @@ const CONST = {
category: '课程',
openOrNot: '公开程序',
timeLimit: '时间限制',
- // knowledge: '知识点'
+ knowledge: '知识点'
},
fontSetting: {
title: '代码格式',
diff --git a/public/react/src/modules/developer/components/knowledge/index.js b/public/react/src/modules/developer/components/knowledge/index.js
index 81e9f770a..63d99b762 100644
--- a/public/react/src/modules/developer/components/knowledge/index.js
+++ b/public/react/src/modules/developer/components/knowledge/index.js
@@ -4,12 +4,14 @@
* @Github:
* @Date: 2019-12-30 13:51:19
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-30 14:28:17
+ * @LastEditTime : 2019-12-30 16:54:30
*/
import './index.scss';
import React, { useState } from 'react';
import { Select } from 'antd';
+const { Option } = Select;
+
function KnowLedge (props) {
const {
@@ -23,8 +25,11 @@ function KnowLedge (props) {
const [selectValue, setSelectValue] = useState(values);
// 渲染下拉选项
- const renderOptions = () => {
-
+ const renderOptions = (options = []) => {
+ console.log('下拉选择: ', options);
+ return options.map((opt, i) => (
+
+ ));
}
const handleSelectChange = (value) => {
console.log(value);
@@ -34,9 +39,12 @@ function KnowLedge (props) {
const renderSelect = (options, values) => {
return (
{renderOptions(options)}
diff --git a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
index 8172a7778..4672a3be7 100644
--- a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
+++ b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 10:35:40
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-30 11:05:14
+ * @LastEditTime : 2019-12-30 16:42:36
*/
import './index.scss';
// import 'katex/dist/katex.css';
@@ -18,6 +18,7 @@ import CONST from '../../../../../constants';
import { toStore } from 'educoder'; // 保存和读取store值
// import Wrapper from '../../../../../common/reactQuill';
import QuillForEditor from '../../../../../common/quillForEditor';
+import KnowLedge from '../../../components/knowledge';
const scrollIntoView = require('scroll-into-view');
const {jcLabel} = CONST;
const FormItem = Form.Item;
@@ -59,7 +60,8 @@ class EditTab extends React.Component {
scrollHeight: 0, // 滚动元素的高度
top: 500,
bottom: 20,
- offsetTop: 0
+ offsetTop: 0,
+ knowledges: ['HTML', 'CSS', 'JS', 'REACT']
}
}
@@ -131,8 +133,21 @@ class EditTab extends React.Component {
}
// 改变分类
handleChangeCategory = (value) => {
- console.log(value);
- // this.props.validateOjCategory(value);
+ // 课程下拉值变化时, 同步更新知识点
+ const { courseQuestions } = this.props;
+ courseQuestions.forEach(item => {
+ if (value[0] && item.id === value[0]) {
+ item.sub_disciplines && item.sub_disciplines.forEach(c => {
+ if (value[1] && c.id === value[1]) {
+ // tempArr = c.tag_disciplines || [];
+ console.log('+++++', c.tag_disciplines);
+ this.setState({
+ knowledges: c.tag_disciplines || []
+ });
+ }
+ });
+ }
+ });
}
// 改变公开程序
handleChangeOpenOrNot = (value) => {
@@ -154,6 +169,7 @@ class EditTab extends React.Component {
openTestCodeIndex = [],
courseQuestions
} = this.props;
+ const {knowledges} = this.state;
// 表单label
const myLabel = (name, subTitle) => {
if (subTitle) {
@@ -259,8 +275,8 @@ class EditTab extends React.Component {
obj.value = item.id;
obj.label = item.name;
// 当item下还有子元素时,递归调用
- if (item.sub_disciplines || item.tag_disciplines) {
- arrs = item.sub_disciplines || item.tag_disciplines;
+ if (item.sub_disciplines) {
+ arrs = item.sub_disciplines;
obj.children = [];
loop(arrs, obj.children);
}
@@ -297,7 +313,6 @@ class EditTab extends React.Component {
return (
@@ -337,10 +352,16 @@ class EditTab extends React.Component {
{ renderCourseQuestion(courseQuestions)}
-
-
+ {myLabel(jcLabel['knowledge'])}}
+ >
+
-
+
{myLabel(jcLabel['timeLimit'], '程序允许时间限制时长,单位:秒')}}
From f7f4c413719265b125a0bd78f678384f1a954dcd Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Mon, 30 Dec 2019 18:28:27 +0800
Subject: [PATCH 06/21] add selector
---
.../src/modules/developer/components/knowledge/index.js | 9 +++------
.../modules/developer/components/knowledge/index.scss | 5 +++++
.../developer/newOrEditTask/leftpane/editorTab/index.js | 2 +-
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/public/react/src/modules/developer/components/knowledge/index.js b/public/react/src/modules/developer/components/knowledge/index.js
index 63d99b762..17cf11624 100644
--- a/public/react/src/modules/developer/components/knowledge/index.js
+++ b/public/react/src/modules/developer/components/knowledge/index.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-12-30 13:51:19
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-30 16:54:30
+ * @LastEditTime : 2019-12-30 18:02:20
*/
import './index.scss';
import React, { useState } from 'react';
@@ -33,6 +33,8 @@ function KnowLedge (props) {
}
const handleSelectChange = (value) => {
console.log(value);
+ const _result = selectOptions.filter(item => item !== value);
+ setSelectOptions(_result);
}
// 渲染下拉列表
@@ -43,8 +45,6 @@ function KnowLedge (props) {
placeholder="请选择"
style={{ width: '100%' }}
onChange={handleSelectChange}
- autoClearSearchValue={true}
- maxTagCount={0}
>
{renderOptions(options)}
@@ -54,9 +54,6 @@ function KnowLedge (props) {
return (
{ renderSelect(selectOptions, selectValue) }
-
-
-
);
}
diff --git a/public/react/src/modules/developer/components/knowledge/index.scss b/public/react/src/modules/developer/components/knowledge/index.scss
index e69de29bb..a38f42c70 100644
--- a/public/react/src/modules/developer/components/knowledge/index.scss
+++ b/public/react/src/modules/developer/components/knowledge/index.scss
@@ -0,0 +1,5 @@
+.knowledge-select-area{
+ .ant-select-selection__rendered{
+ margin-bottom: 0 !important;
+ }
+}
diff --git a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
index 4672a3be7..4c5d89dce 100644
--- a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
+++ b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 10:35:40
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-30 16:42:36
+ * @LastEditTime : 2019-12-30 17:53:18
*/
import './index.scss';
// import 'katex/dist/katex.css';
From f7fc049d7e51d7523a3cd114fb255db28227eaeb Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Mon, 30 Dec 2019 19:30:56 +0800
Subject: [PATCH 07/21] add
---
public/react/src/AppConfig.js | 13 +++++++------
.../modules/developer/components/knowledge/index.js | 12 ++++++++----
.../developer/components/knowledge/index.scss | 4 ++++
.../newOrEditTask/leftpane/editorTab/index.js | 2 +-
4 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js
index 859b5f579..4e91938c8 100644
--- a/public/react/src/AppConfig.js
+++ b/public/react/src/AppConfig.js
@@ -63,11 +63,11 @@ export function initAxiosInterceptors(props) {
const requestMap = {};
window.railsgettimes = function(proxy) {
- $.ajax({url:`${proxy}/api/main/first_stamp.json`,async:false,success:function(data,status){
- if(data.status===0){
- return data.message;
- }
- }});
+ // $.ajax({url:`${proxy}/api/main/first_stamp.json`,async:false,success:function(data,status){
+ // if(data.status===0){
+ // return data.message;
+ // }
+ // }});
}
window.setfalseInRequestMap = function(keyName) {
@@ -101,8 +101,9 @@ export function initAxiosInterceptors(props) {
}
}
if(`${config[0]}`!=`true`){
+ let timestamp = Date.parse(new Date())/1000;
if (window.location.port === "3007") {
- let timestamp=railsgettimes(proxy);
+ // let timestamp=railsgettimes(proxy);
console.log(timestamp)
let newopens=md5(opens+timestamp)
config.url = `${proxy}${url}`;
diff --git a/public/react/src/modules/developer/components/knowledge/index.js b/public/react/src/modules/developer/components/knowledge/index.js
index 17cf11624..5677d3630 100644
--- a/public/react/src/modules/developer/components/knowledge/index.js
+++ b/public/react/src/modules/developer/components/knowledge/index.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-12-30 13:51:19
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-30 18:02:20
+ * @LastEditTime : 2019-12-30 19:21:56
*/
import './index.scss';
import React, { useState } from 'react';
@@ -23,6 +23,8 @@ function KnowLedge (props) {
const [selectOptions, setSelectOptions] = useState(options);
// 已选择的下拉项
const [selectValue, setSelectValue] = useState(values);
+ //
+ const [value] = useState([]);
// 渲染下拉选项
const renderOptions = (options = []) => {
@@ -32,8 +34,9 @@ function KnowLedge (props) {
));
}
const handleSelectChange = (value) => {
- console.log(value);
- const _result = selectOptions.filter(item => item !== value);
+ console.log('过滤结果Start=====》》》》》', selectOptions, value);
+ const _result = selectOptions.filter(item => item !== value.join(''));
+ console.log('过滤结果=====》》》》》', _result, selectOptions);
setSelectOptions(_result);
}
@@ -41,7 +44,8 @@ function KnowLedge (props) {
const renderSelect = (options, values) => {
return (
Date: Mon, 30 Dec 2019 19:36:26 +0800
Subject: [PATCH 08/21] add
---
public/react/src/AppConfig.js | 14 --------------
.../developer/components/knowledge/index.js | 7 ++++++-
2 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js
index 055f6ae92..ba700794e 100644
--- a/public/react/src/AppConfig.js
+++ b/public/react/src/AppConfig.js
@@ -86,17 +86,6 @@ export function initAxiosInterceptors(props) {
// 如果需要支持重复的请求,考虑config里面自定义一个allowRepeat参考来控制
const requestMap = {};
-<<<<<<< HEAD
- window.railsgettimes = function(proxy) {
- // $.ajax({url:`${proxy}/api/main/first_stamp.json`,async:false,success:function(data,status){
- // if(data.status===0){
- // return data.message;
- // }
- // }});
- }
-
-=======
->>>>>>> dev_aliyun
window.setfalseInRequestMap = function(keyName) {
requestMap[keyName] = false;
}
@@ -131,12 +120,9 @@ export function initAxiosInterceptors(props) {
if(`${config[0]}`!=`true`){
let timestamp = Date.parse(new Date())/1000;
if (window.location.port === "3007") {
-<<<<<<< HEAD
// let timestamp=railsgettimes(proxy);
console.log(timestamp)
-=======
railsgettimes(`${proxy}/api/main/first_stamp.json`);
->>>>>>> dev_aliyun
let newopens=md5(opens+timestamp)
config.url = `${proxy}${url}`;
if (config.url.indexOf('?') == -1) {
diff --git a/public/react/src/modules/developer/components/knowledge/index.js b/public/react/src/modules/developer/components/knowledge/index.js
index 5677d3630..491b9cb87 100644
--- a/public/react/src/modules/developer/components/knowledge/index.js
+++ b/public/react/src/modules/developer/components/knowledge/index.js
@@ -35,7 +35,12 @@ function KnowLedge (props) {
}
const handleSelectChange = (value) => {
console.log('过滤结果Start=====》》》》》', selectOptions, value);
- const _result = selectOptions.filter(item => item !== value.join(''));
+ const _result = selectOptions.filter(item => {
+ if (item === value) {
+
+ }
+ return item !== value;
+ });
console.log('过滤结果=====》》》》》', _result, selectOptions);
setSelectOptions(_result);
}
From ec9a306f92209f6152503dd23f57c8a08143aa2e Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Mon, 30 Dec 2019 19:58:49 +0800
Subject: [PATCH 09/21] add
---
.../developer/newOrEditTask/leftpane/editorTab/index.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
index fac58fe86..88e5a8bde 100644
--- a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
+++ b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 10:35:40
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-30 19:20:50
+ * @LastEditTime : 2019-12-30 19:57:46
*/
import './index.scss';
// import 'katex/dist/katex.css';
@@ -61,7 +61,7 @@ class EditTab extends React.Component {
top: 500,
bottom: 20,
offsetTop: 0,
- knowledges: ['HTML', 'CSS', 'JS', 'REACT']
+ knowledges: []
}
}
From 36fd6d98aee7784d6fa063fb3e4886b26b91620e Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Mon, 30 Dec 2019 20:12:03 +0800
Subject: [PATCH 10/21] add
---
.../developer/components/knowledge/index.js | 11 ++++++++---
.../newOrEditTask/leftpane/editorTab/index.js | 14 ++++++++++----
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/public/react/src/modules/developer/components/knowledge/index.js b/public/react/src/modules/developer/components/knowledge/index.js
index 491b9cb87..36060e8e8 100644
--- a/public/react/src/modules/developer/components/knowledge/index.js
+++ b/public/react/src/modules/developer/components/knowledge/index.js
@@ -4,10 +4,10 @@
* @Github:
* @Date: 2019-12-30 13:51:19
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-30 19:21:56
+ * @LastEditTime : 2019-12-30 20:08:09
*/
import './index.scss';
-import React, { useState } from 'react';
+import React, { useState, useEffect } from 'react';
import { Select } from 'antd';
const { Option } = Select;
@@ -19,6 +19,10 @@ function KnowLedge (props) {
values = [], // 已选择的下拉项
} = props;
+ useEffect(() => {
+ setSelectOptions(options || []);
+ }, [props]);
+
// 显示的下拉项
const [selectOptions, setSelectOptions] = useState(options);
// 已选择的下拉项
@@ -30,7 +34,7 @@ function KnowLedge (props) {
const renderOptions = (options = []) => {
console.log('下拉选择: ', options);
return options.map((opt, i) => (
-
+
));
}
const handleSelectChange = (value) => {
@@ -47,6 +51,7 @@ function KnowLedge (props) {
// 渲染下拉列表
const renderSelect = (options, values) => {
+ console.log('==========>>>>>>>>', options);
return (
{
if (value[1] && c.id === value[1]) {
- // tempArr = c.tag_disciplines || [];
- console.log('+++++', c.tag_disciplines);
this.setState({
- knowledges: c.tag_disciplines || []
+ knowledges: [...c.tag_disciplines]
+ });
+ } else {
+ this.setState({
+ knowledges: []
});
}
});
+ } else {
+ this.setState({
+ knowledges: []
+ });
}
});
}
From a2e80d190ca8c310ff12aae3af942309592f542a Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Mon, 30 Dec 2019 20:47:08 +0800
Subject: [PATCH 11/21] add
---
.../developer/components/knowledge/index.js | 33 +++++++++++++------
.../newOrEditTask/leftpane/editorTab/index.js | 11 +++----
2 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/public/react/src/modules/developer/components/knowledge/index.js b/public/react/src/modules/developer/components/knowledge/index.js
index 36060e8e8..5d21b1420 100644
--- a/public/react/src/modules/developer/components/knowledge/index.js
+++ b/public/react/src/modules/developer/components/knowledge/index.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-12-30 13:51:19
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-30 20:08:09
+ * @LastEditTime : 2019-12-30 20:44:38
*/
import './index.scss';
import React, { useState, useEffect } from 'react';
@@ -32,26 +32,35 @@ function KnowLedge (props) {
// 渲染下拉选项
const renderOptions = (options = []) => {
- console.log('下拉选择: ', options);
return options.map((opt, i) => (
));
}
+ // 过滤下拉列表项
const handleSelectChange = (value) => {
- console.log('过滤结果Start=====》》》》》', selectOptions, value);
+ value = +value.join('');
+ const tempArr = [...selectValue];
const _result = selectOptions.filter(item => {
- if (item === value) {
-
+ if (item.id === value && tempArr.findIndex(t => t.id === value) === -1) {
+ tempArr.push(item);
}
- return item !== value;
+ return item.id !== value;
});
- console.log('过滤结果=====》》》》》', _result, selectOptions);
+ console.log(tempArr)
+ setSelectValue(tempArr);
setSelectOptions(_result);
}
+ // 渲染下拉结果
+ const renderResult = (arrs) => {
+ return arrs.map(item => (
+
+
+
+ ));
+ }
// 渲染下拉列表
- const renderSelect = (options, values) => {
- console.log('==========>>>>>>>>', options);
+ const renderSelect = (options) => {
return (
- { renderSelect(selectOptions, selectValue) }
+ { renderSelect(selectOptions) }
+ {/* 渲染下拉选择项 */}
+
+ { renderResult(selectValue) }
+
);
}
diff --git a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
index ed142e53a..969d4df9e 100644
--- a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
+++ b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 10:35:40
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-30 20:09:30
+ * @LastEditTime : 2019-12-30 20:18:20
*/
import './index.scss';
// import 'katex/dist/katex.css';
@@ -135,6 +135,9 @@ class EditTab extends React.Component {
handleChangeCategory = (value) => {
// 课程下拉值变化时, 同步更新知识点
const { courseQuestions } = this.props;
+ this.setState({
+ knowledges: []
+ });
courseQuestions.forEach(item => {
if (value[0] && item.id === value[0]) {
item.sub_disciplines && item.sub_disciplines.forEach(c => {
@@ -142,16 +145,12 @@ class EditTab extends React.Component {
this.setState({
knowledges: [...c.tag_disciplines]
});
- } else {
+ } else if (!value[1]) {
this.setState({
knowledges: []
});
}
});
- } else {
- this.setState({
- knowledges: []
- });
}
});
}
From e54a85f4211804d1a3bb665110ef5c20b5394fd3 Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Tue, 31 Dec 2019 09:15:28 +0800
Subject: [PATCH 12/21] add
---
.../developer/components/knowledge/index.js | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/public/react/src/modules/developer/components/knowledge/index.js b/public/react/src/modules/developer/components/knowledge/index.js
index 5d21b1420..6cd3d89ef 100644
--- a/public/react/src/modules/developer/components/knowledge/index.js
+++ b/public/react/src/modules/developer/components/knowledge/index.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-12-30 13:51:19
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-30 20:44:38
+ * @LastEditTime : 2019-12-31 09:06:44
*/
import './index.scss';
import React, { useState, useEffect } from 'react';
@@ -46,16 +46,15 @@ function KnowLedge (props) {
}
return item.id !== value;
});
- console.log(tempArr)
setSelectValue(tempArr);
setSelectOptions(_result);
}
// 渲染下拉结果
const renderResult = (arrs) => {
- return arrs.map(item => (
-
-
+ return arrs.map((item) => (
+
+ {item.name}
));
}
@@ -79,7 +78,11 @@ function KnowLedge (props) {
{ renderSelect(selectOptions) }
{/* 渲染下拉选择项 */}
- { renderResult(selectValue) }
+ {/* { renderResult(selectValue) } */}
+ {/*
1111
*/}
+
+ JAVA
+
);
From 5c0d2de5be68dd8d3db64fe98e22094a7fd9600e Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Tue, 31 Dec 2019 11:49:21 +0800
Subject: [PATCH 13/21] add knowledge
---
.../developer/components/knowledge/index.js | 44 ++++++++++++++-----
.../developer/components/knowledge/index.scss | 33 ++++++++++++++
.../newOrEditTask/leftpane/editorTab/index.js | 38 +++++++++++-----
.../leftpane/editorTab/index.scss | 6 +++
.../modules/developer/split_pane_resizer.scss | 15 ++++++-
public/react/src/redux/actions/ojForm.js | 5 ++-
6 files changed, 117 insertions(+), 24 deletions(-)
diff --git a/public/react/src/modules/developer/components/knowledge/index.js b/public/react/src/modules/developer/components/knowledge/index.js
index 6cd3d89ef..ded8b3b1f 100644
--- a/public/react/src/modules/developer/components/knowledge/index.js
+++ b/public/react/src/modules/developer/components/knowledge/index.js
@@ -4,11 +4,11 @@
* @Github:
* @Date: 2019-12-30 13:51:19
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-31 09:06:44
+ * @LastEditTime : 2019-12-31 10:42:51
*/
import './index.scss';
import React, { useState, useEffect } from 'react';
-import { Select } from 'antd';
+import { Select, notification } from 'antd';
const { Option } = Select;
@@ -17,6 +17,7 @@ function KnowLedge (props) {
const {
options = [], // 下拉选项
values = [], // 已选择的下拉项
+ onChange // 获取选择的值
} = props;
useEffect(() => {
@@ -46,16 +47,43 @@ function KnowLedge (props) {
}
return item.id !== value;
});
+ if (tempArr.length > 50) {
+ notification.warning({
+ message: '提示',
+ description: '知识点不能超过50个'
+ });
+ return;
+ }
setSelectValue(tempArr);
setSelectOptions(_result);
+ // 将选择值返回
+ onChange && onChange(tempArr);
+ }
+
+ // 删除
+ const handleRemoveResult = (item) => {
+ // console.log('点击了删除按钮===>>>>', item);
+ // 将删除的值重新加入到列表中
+ const tempOptions = [...selectOptions];
+ const tempValue = selectValue.filter(t => t.id !== item.id);
+ // console.log(selectValue);
+ tempOptions.push(item);
+ setSelectOptions(tempOptions);
+ setSelectValue(tempValue);
+ // 将选择值返回
+ onChange && onChange(tempValue);
}
// 渲染下拉结果
const renderResult = (arrs) => {
return arrs.map((item) => (
-
- {item.name}
-
+
+ {item.name}
+ handleRemoveResult(item)}
+ className="iconfont icon-roundclose knowledge-close"
+ >
+
));
}
// 渲染下拉列表
@@ -78,11 +106,7 @@ function KnowLedge (props) {
{ renderSelect(selectOptions) }
{/* 渲染下拉选择项 */}
- {/* { renderResult(selectValue) } */}
- {/*
1111
*/}
-
- JAVA
-
+ { renderResult(selectValue) }
);
diff --git a/public/react/src/modules/developer/components/knowledge/index.scss b/public/react/src/modules/developer/components/knowledge/index.scss
index 28676b286..5bd0f5f61 100644
--- a/public/react/src/modules/developer/components/knowledge/index.scss
+++ b/public/react/src/modules/developer/components/knowledge/index.scss
@@ -6,4 +6,37 @@
margin-left: 5px;
margin-top: 2px;
}
+
+ .knowledge-result{
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+ // margin-top: 15px;
+
+ .knowledge-item{
+ position: relative;
+ border: 1px solid #DDDDDD;
+ border-radius: 3px;
+ padding: 10px;
+ background: #fff;
+ margin-right: 10px;
+ margin-top: 10px;
+ // margin-bottom: 10px;
+
+ .knowledge-close{
+ display: none;
+ position: absolute;
+ right: -10px;
+ top: -10px;
+ background-color: rgba(250,250,250,1);
+ cursor: pointer;
+ }
+
+ &:hover{
+ .knowledge-close{
+ display: block;
+ }
+ }
+ }
+ }
}
diff --git a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
index 969d4df9e..b7f0f568a 100644
--- a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
+++ b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js
@@ -4,12 +4,12 @@
* @Github:
* @Date: 2019-11-20 10:35:40
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-30 20:18:20
+ * @LastEditTime : 2019-12-31 10:49:21
*/
import './index.scss';
// import 'katex/dist/katex.css';
import React from 'react';
-import { Form, Input, Select, InputNumber, Button, Cascader } from 'antd';
+import { Form, Input, Select, InputNumber, Button, Cascader, notification } from 'antd';
import { connect } from 'react-redux';
import AddTestDemo from './AddTestDemo';
// import QuillEditor from '../../../quillEditor';
@@ -138,6 +138,7 @@ class EditTab extends React.Component {
this.setState({
knowledges: []
});
+ // 获取当前分类下的知识点
courseQuestions.forEach(item => {
if (value[0] && item.id === value[0]) {
item.sub_disciplines && item.sub_disciplines.forEach(c => {
@@ -153,6 +154,7 @@ class EditTab extends React.Component {
});
}
});
+ this.props.validateOjCategory(value[1] || '');
}
// 改变公开程序
handleChangeOpenOrNot = (value) => {
@@ -176,10 +178,10 @@ class EditTab extends React.Component {
} = this.props;
const {knowledges} = this.state;
// 表单label
- const myLabel = (name, subTitle) => {
+ const myLabel = (name, subTitle, nostar) => {
if (subTitle) {
return (
-
+
{name}
({subTitle})
@@ -188,7 +190,7 @@ class EditTab extends React.Component {
)
} else {
return (
- {name}
+ {name}
)
}
};
@@ -224,7 +226,14 @@ class EditTab extends React.Component {
};
// 添加测试用例
const handleAddTest = () => {
- const {position} = this.props;
+ const {position, testCases = []} = this.props;
+ if (testCases.length >= 50) {
+ notification.warning({
+ message: '提示',
+ description: '测试用例不能超过50个'
+ });
+ return;
+ }
const obj = { // 测试用例参数
input: '',
output: '',
@@ -324,6 +333,15 @@ class EditTab extends React.Component {
)
}
+ // 知识点
+ const handleKnowledgeChange = (values= []) => {
+ const _result = [];
+ values.forEach(v => {
+ _result.push(v.id);
+ });
+ console.log('下拉选择的值:===>>>', _result);
+ }
+
return (