From 09ccb438a179d2496c521e1cd395bc43fab537c8 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Tue, 7 Jan 2020 13:38:45 +0800 Subject: [PATCH 1/3] update style --- .../common/components/comment/CommentForm.js | 13 ++++++------ .../src/common/quillForEditor/index.scss | 2 ++ .../developer/components/knowledge/index.js | 21 ++++++++++++++++--- .../developer/components/knowledge/index.scss | 8 +++++++ .../studentStudy/leftpane/comment/index.scss | 2 +- .../studentStudy/leftpane/index.scss | 14 ++++++++++--- public/react/src/modules/page/VNCContainer.js | 7 +++++++ 7 files changed, 54 insertions(+), 13 deletions(-) diff --git a/public/react/src/common/components/comment/CommentForm.js b/public/react/src/common/components/comment/CommentForm.js index 484940807..3f1e16170 100644 --- a/public/react/src/common/components/comment/CommentForm.js +++ b/public/react/src/common/components/comment/CommentForm.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-12-17 17:32:55 * @LastEditors : tangjiang - * @LastEditTime : 2019-12-27 16:50:43 + * @LastEditTime : 2020-01-06 18:42:09 */ import './index.scss'; import React, { useState } from 'react'; @@ -28,11 +28,12 @@ function CommentForm (props) { const [focus, setFocus] = useState(false); const options = [ - ['bold', 'italic', 'underline'], - [{header: [1,2,3,false]}], - ['blockquote', 'code-block'], - ['link', 'image'], - ['formula'] + // ['bold', 'italic', 'underline'], + // [{header: [1,2,3,false]}], + 'code-block', + 'link', + 'image', + 'formula' ]; // const { form: { getFieldDecorator } } = props; const [showQuill, setShowQuill] = useState(false); diff --git a/public/react/src/common/quillForEditor/index.scss b/public/react/src/common/quillForEditor/index.scss index eca8c4485..dd4eb0349 100644 --- a/public/react/src/common/quillForEditor/index.scss +++ b/public/react/src/common/quillForEditor/index.scss @@ -1,4 +1,6 @@ .quill_editor_for_react_area{ + // background: #fff; + // margin: 0 15px; .ql-editing{ left: 0 !important; } diff --git a/public/react/src/modules/developer/components/knowledge/index.js b/public/react/src/modules/developer/components/knowledge/index.js index 680229b2d..3a588ba89 100644 --- a/public/react/src/modules/developer/components/knowledge/index.js +++ b/public/react/src/modules/developer/components/knowledge/index.js @@ -4,12 +4,13 @@ * @Github: * @Date: 2019-12-30 13:51:19 * @LastEditors : tangjiang - * @LastEditTime : 2020-01-03 18:56:36 + * @LastEditTime : 2020-01-07 11:08:58 */ import './index.scss'; import React, { useState, useEffect } from 'react'; import { Select, notification } from 'antd'; - +import { CNotificationHOC} from 'educoder'; +// import {} from 'antd'; const { Option } = Select; function KnowLedge (props) { @@ -114,15 +115,29 @@ function KnowLedge (props) { ) } + // 添加知识点 + const handleAddKnowledge = () => { + + }; + + const _styles = { + display: selectOptions.length > 0 || selectValue.length > 0 ? 'inline-block' : 'none' + }; + return (
{ renderSelect(selectOptions) } {/* 渲染下拉选择项 */}
+ { renderResult(selectValue) }
); } -export default KnowLedge; +export default CNotificationHOC()(KnowLedge); diff --git a/public/react/src/modules/developer/components/knowledge/index.scss b/public/react/src/modules/developer/components/knowledge/index.scss index 5bd0f5f61..acd17e91c 100644 --- a/public/react/src/modules/developer/components/knowledge/index.scss +++ b/public/react/src/modules/developer/components/knowledge/index.scss @@ -38,5 +38,13 @@ } } } + + .icon-add-knowledge{ + line-height: 36px; + margin-top: 10px; + margin-right: 10px; + // cursor: ; + color: rgb(78, 188, 126) + } } } diff --git a/public/react/src/modules/developer/studentStudy/leftpane/comment/index.scss b/public/react/src/modules/developer/studentStudy/leftpane/comment/index.scss index b09eb849b..9ac89b21a 100644 --- a/public/react/src/modules/developer/studentStudy/leftpane/comment/index.scss +++ b/public/react/src/modules/developer/studentStudy/leftpane/comment/index.scss @@ -3,7 +3,7 @@ flex-direction: column; justify-content: space-between; background: #fff; - padding: 20px 30px 0; + padding: 0px 20px 0; height: calc(100vh - 177px); box-sizing: border-box; overflow-y: auto; diff --git a/public/react/src/modules/developer/studentStudy/leftpane/index.scss b/public/react/src/modules/developer/studentStudy/leftpane/index.scss index 441c1ad66..e47c4b458 100644 --- a/public/react/src/modules/developer/studentStudy/leftpane/index.scss +++ b/public/react/src/modules/developer/studentStudy/leftpane/index.scss @@ -53,6 +53,7 @@ .commit_record_area{ padding: 0 20px; + background: #fff; // height: calc(100vh - 178px); } .task_description_area{ @@ -61,7 +62,8 @@ .task_desc_area{ height: calc(100vh - 242px); overflow-y: auto; - padding: 0 0 0 15px; + // padding: 0 0 0 15px; + background: #fff; } .desc_area_header{ display: flex; @@ -69,14 +71,20 @@ align-items: center; height: 64px; padding: 0 20px; + background: #fff; + box-sizing: border-box; + border-bottom: 1px solid #f4f4f4; + .header_flex{ font-size: 14px; .flex_label{ - color: #999999; + color: #888888; margin-right: 10px; } .flex_value{ - font-weight: bold; + font-weight: 500; + color: #333; + // color: green; } } } diff --git a/public/react/src/modules/page/VNCContainer.js b/public/react/src/modules/page/VNCContainer.js index 61a8e1f6b..55a991ae8 100644 --- a/public/react/src/modules/page/VNCContainer.js +++ b/public/react/src/modules/page/VNCContainer.js @@ -278,6 +278,8 @@ class VNCContainer extends Component { .vncDrawer .ant-drawer-body { padding: 0px; } + + .vncDrawer .rc-tree { padding: 16px; max-width: 220px; @@ -286,6 +288,7 @@ class VNCContainer extends Component { .vncDrawer .ant-drawer-wrapper-body { background: #242324; + height: 100%; } .codeInDrawer .ant-drawer-wrapper-body { background: #1D1C1D; @@ -294,6 +297,10 @@ class VNCContainer extends Component { .vncDrawer .ant-drawer-header, .codeInDrawer .ant-drawer-header { border-bottom: 0; } + .codeInDrawer .ant-drawer-header, + .codeInDrawer .ant-drawer-content{ + background: rgb(28, 28, 28) !important; + } .vncDrawer > div:nth-child(1) { opacity: 1 !important; From 6a377c17c5f45be441a2187a7cc0427ffade4526 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Tue, 7 Jan 2020 14:20:10 +0800 Subject: [PATCH 2/3] add knowledge --- .../developer/components/knowledge/index.js | 83 +++++++++++++++---- .../developer/components/knowledge/index.scss | 6 ++ public/react/src/services/ojService.js | 7 +- 3 files changed, 76 insertions(+), 20 deletions(-) diff --git a/public/react/src/modules/developer/components/knowledge/index.js b/public/react/src/modules/developer/components/knowledge/index.js index 3a588ba89..ccbf0719b 100644 --- a/public/react/src/modules/developer/components/knowledge/index.js +++ b/public/react/src/modules/developer/components/knowledge/index.js @@ -4,13 +4,12 @@ * @Github: * @Date: 2019-12-30 13:51:19 * @LastEditors : tangjiang - * @LastEditTime : 2020-01-07 11:08:58 + * @LastEditTime : 2020-01-07 14:19:39 */ import './index.scss'; import React, { useState, useEffect } from 'react'; -import { Select, notification } from 'antd'; -import { CNotificationHOC} from 'educoder'; -// import {} from 'antd'; +import { Select, notification, Modal, Form, Input, Button } from 'antd'; + const { Option } = Select; function KnowLedge (props) { @@ -18,7 +17,8 @@ function KnowLedge (props) { const { options = [], // 下拉选项 values = [], // 已选择的下拉项 - onChange // 获取选择的值 + onChange, // 获取选择的值 + form } = props; useEffect(() => { @@ -39,9 +39,12 @@ function KnowLedge (props) { const [selectOptions, setSelectOptions] = useState(options); // 已选择的下拉项 const [selectValue, setSelectValue] = useState([]); + const [visible, setVisible] = useState(false); // const [value] = useState([]); + const { getFieldDecorator } = form; + const FormItem = Form.Item; // 渲染下拉选项 const renderOptions = (options = []) => { return options.map((opt, i) => ( @@ -117,27 +120,71 @@ function KnowLedge (props) { // 添加知识点 const handleAddKnowledge = () => { - + setVisible(true); }; + const handleResetForm = () => { + form.resetFields(); + setVisible(false); + } + + const handleSubmitForm = (e) => { + e.preventDefault(); + form.validateFieldsAndScroll((err, values) => { + if (err) { + return; + } + setVisible(false); + console.log(values); + }) + } + const _styles = { display: selectOptions.length > 0 || selectValue.length > 0 ? 'inline-block' : 'none' }; return ( -
- { renderSelect(selectOptions) } - {/* 渲染下拉选择项 */} -
- - { renderResult(selectValue) } + +
+ { renderSelect(selectOptions) } + {/* 渲染下拉选择项 */} +
+ {/* */} + { renderResult(selectValue) } +
-
+ + +
+ + { + getFieldDecorator('name', { + rules: [{ + required: true, message: '知识点名称不能为空' + }] + })( + + ) + } + + + + + +
+
+ + ); } -export default CNotificationHOC()(KnowLedge); +export default Form.create()(KnowLedge); diff --git a/public/react/src/modules/developer/components/knowledge/index.scss b/public/react/src/modules/developer/components/knowledge/index.scss index acd17e91c..9a457acf9 100644 --- a/public/react/src/modules/developer/components/knowledge/index.scss +++ b/public/react/src/modules/developer/components/knowledge/index.scss @@ -48,3 +48,9 @@ } } } + +.knowledge-form{ + .ant-form-explain{ + padding: 0; + } +} diff --git a/public/react/src/services/ojService.js b/public/react/src/services/ojService.js index 59151e687..62ebf9dbb 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-30 09:44:56 + * @LastEditTime : 2020-01-07 14:19:24 */ import axios from 'axios'; @@ -148,4 +148,7 @@ export async function fetchAddNotes (identifier, params) { export async function fetchQuestion (params) { const url = `/disciplines.json`; return axios.get(url, { params }); -} \ No newline at end of file +} + +// 新增选题 +export async function fetchExaminationItems () {} \ No newline at end of file From 9540b348ddb0057ce52b979c45b192cfed6657db Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Tue, 7 Jan 2020 15:24:13 +0800 Subject: [PATCH 3/3] add knowledge --- .../developer/components/knowledge/index.js | 16 ++++--- .../newOrEditTask/leftpane/editorTab/index.js | 33 +++++++++---- public/react/src/redux/actions/index.js | 4 +- public/react/src/redux/actions/ojForUser.js | 6 +-- public/react/src/redux/actions/ojForm.js | 46 +++++++++++++++++-- .../react/src/redux/reducers/commonReducer.js | 6 +-- public/react/src/services/ojService.js | 9 ++-- 7 files changed, 92 insertions(+), 28 deletions(-) diff --git a/public/react/src/modules/developer/components/knowledge/index.js b/public/react/src/modules/developer/components/knowledge/index.js index ccbf0719b..f443e4975 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 : 2020-01-07 14:19:39 + * @LastEditTime : 2020-01-07 15:04:51 */ import './index.scss'; import React, { useState, useEffect } from 'react'; @@ -18,7 +18,9 @@ function KnowLedge (props) { options = [], // 下拉选项 values = [], // 已选择的下拉项 onChange, // 获取选择的值 - form + form, + showAdd, // 显示新增图标 + addKnowledge // 调用新增知识点接口 } = props; useEffect(() => { @@ -135,12 +137,14 @@ function KnowLedge (props) { return; } setVisible(false); - console.log(values); + form.resetFields(); + // console.log(values); + addKnowledge && addKnowledge(values); }) } const _styles = { - display: selectOptions.length > 0 || selectValue.length > 0 ? 'inline-block' : 'none' + display: showAdd ? 'inline-block' : 'none' }; return ( @@ -149,11 +153,11 @@ function KnowLedge (props) { { 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 f8b92361b..02d953afd 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 : 2020-01-06 16:17:22 + * @LastEditTime : 2020-01-07 15:21:19 */ import './index.scss'; // import 'katex/dist/katex.css'; @@ -61,6 +61,7 @@ class EditTab extends React.Component { top: 500, bottom: 20, offsetTop: 0, + showAdd: false // knowledges: [], // coursers: [] // 选中的课程 } @@ -147,13 +148,15 @@ class EditTab extends React.Component { item.sub_disciplines && item.sub_disciplines.forEach(c => { if (value[1] && c.id === value[1]) { saveKnowledge(c.tag_disciplines) - console.log(c.tag_disciplines); } else if (!value[1]) { saveKnowledge([]); } }); } }); + this.setState({ + showAdd: value[1] ? true : false + }); // this.props.validateOjCategory(value[1] || ''); this.props.validateOjSubDisciplineId(value[1] || ''); } @@ -167,6 +170,7 @@ class EditTab extends React.Component { } render () { + const { showAdd } = this.state; const { ojForm, ojFormValidate, @@ -177,9 +181,10 @@ class EditTab extends React.Component { openTestCodeIndex = [], courseQuestions, tag_discipline_id, - knowledges + knowledges, + tagDisciplines, } = this.props; - console.log('knowledge======>>>>>>', knowledges); + // console.log('knowledge======>>>>>>', knowledges); // const {knowledges} = this.state; // 表单label const myLabel = (name, subTitle, nostar) => { @@ -321,7 +326,7 @@ class EditTab extends React.Component { } }); - console.log(choid_ids); + // console.log(choid_ids); return ( { _result.push(v.id); }); - console.log('下拉选择的值:===>>>', _result); + // console.log('下拉选择的值:===>>>', _result); // 保存选择的知识点 this.props.saveTagDisciplineId(_result); } + + // 新增知识点 + const handleAddKnowledge = (values) => { + // console.log('调用了新增知识点并返回了结果: ', values); + // 获取课程id + const {sub_discipline_id} = this.props.ojForm; + const obj = Object.assign({}, values, {sub_discipline_id}) + tagDisciplines(obj); + } return (
@@ -383,10 +397,12 @@ class EditTab extends React.Component { className='input_area flex_100' label={{myLabel(jcLabel['knowledge'], '', 'nostar')}} > - @@ -514,7 +530,8 @@ const mapDispatchToProps = (dispatch) => ({ addTestCase: (value) => dispatch(actions.addTestCase(value)), // 删除测试用例 deleteTestCase: (value) => dispatch(actions.deleteTestCase(value)), - saveKnowledge: (value) => dispatch(actions.saveKnowledge(value)) + saveKnowledge: (value) => dispatch(actions.saveKnowledge(value)), + tagDisciplines: (params) => dispatch(actions.tagDisciplines(params)) // 获取题库 // getQuestion: (params) => dispatch(actions.getQuestion(params)) }); diff --git a/public/react/src/redux/actions/index.js b/public/react/src/redux/actions/index.js index efce336c9..0376b529d 100644 --- a/public/react/src/redux/actions/index.js +++ b/public/react/src/redux/actions/index.js @@ -36,7 +36,8 @@ import { handleClickCancelPublish, getQuestion, saveKnowledge, - setOjInitialValue + setOjInitialValue, + tagDisciplines } from './ojForm'; import { @@ -125,6 +126,7 @@ export default { getQuestion, saveKnowledge, setOjInitialValue, + tagDisciplines, // addTestCase, deleteTestCase, diff --git a/public/react/src/redux/actions/ojForUser.js b/public/react/src/redux/actions/ojForUser.js index 99c759996..718aad09f 100644 --- a/public/react/src/redux/actions/ojForUser.js +++ b/public/react/src/redux/actions/ojForUser.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-27 13:42:11 * @LastEditors : tangjiang - * @LastEditTime : 2020-01-02 14:17:49 + * @LastEditTime : 2020-01-07 14:45:52 */ import types from "./actionTypes"; import { Base64 } from 'js-base64'; @@ -18,7 +18,7 @@ import { fetchUpdateCode, fetchUserCodeSubmit, fetchRestoreInitialCode, - fetchAddNotes + fetchAddNotes, } from "../../services/ojService"; import { notification } from "antd"; @@ -523,4 +523,4 @@ export const addNotes = (identifier, params, cb) => { }); }) } -} \ No newline at end of file +} diff --git a/public/react/src/redux/actions/ojForm.js b/public/react/src/redux/actions/ojForm.js index 6d2da50a3..097b2a6af 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 : 2020-01-03 16:40:54 + * @LastEditTime : 2020-01-07 14:58:05 */ import types from './actionTypes'; import CONST from '../../constants'; @@ -13,7 +13,8 @@ import { fetchGetOjById, publishTask, cancelPublicTask, - fetchQuestion + fetchQuestion, + fetchTagDisciplines } from '../../services/ojService'; import { Base64 } from 'js-base64'; import { notification } from 'antd'; @@ -675,14 +676,32 @@ export const updateOpenTestCaseIndex = (value) => { // 获取课程题库 export const getQuestion = (params) => { - return (dispatch) => { + return (dispatch, getState) => { + const {ojForm: {sub_discipline_id}} = getState().ojFormReducer; fetchQuestion(params).then(res => { const { data = {} } = res; const { disciplines = [] } = data; dispatch({ type: types.GET_COURSE_QUESTION, payload: disciplines - }) + }); + // 如果课程id号存在, 同步更新知识点 + if (sub_discipline_id) { + let temp_knowledges = []; + disciplines.forEach(c => { + if (sub_discipline_id && c.sub_disciplines) { + c.sub_disciplines.forEach(sub => { + if (+sub.id === sub_discipline_id) { + temp_knowledges = sub.tag_disciplines || []; + } + }); + } + }); + dispatch({ + type: types.CHANGE_KNOWLEDGES, + payload: temp_knowledges + }) + } }) } } @@ -710,3 +729,22 @@ export const setOjInitialValue = (params) => { payload: params } } + +// 新增知识点 +export const tagDisciplines = (params) => { + return (dispatch) => { + fetchTagDisciplines(params).then(res => { + console.log('新增知识点成功======>>>>', res); + if (res.data.status === 0) { + notification.success({ + message: '提示', + description: '新增知识点成功' + }); + // 重新调用获取课程列表接口 + dispatch(getQuestion({ + source: 'question' + })); + } + }); + } +} diff --git a/public/react/src/redux/reducers/commonReducer.js b/public/react/src/redux/reducers/commonReducer.js index 12c64c28f..e34cd884b 100644 --- a/public/react/src/redux/reducers/commonReducer.js +++ b/public/react/src/redux/reducers/commonReducer.js @@ -3,8 +3,8 @@ * @Author: tangjiang * @Github: * @Date: 2019-11-27 16:27:09 - * @LastEditors: tangjiang - * @LastEditTime: 2019-12-12 17:36:51 + * @LastEditors : tangjiang + * @LastEditTime : 2020-01-07 15:23:39 */ import types from "../actions/actionTypes"; @@ -22,7 +22,7 @@ const initialState = { } const commonReducer = (state = initialState, action) => { - console.log(action) + // console.log(action) switch (action.type) { case types.SHOW_OR_HIDE_CONTROL: return { diff --git a/public/react/src/services/ojService.js b/public/react/src/services/ojService.js index 62ebf9dbb..d0d0ae0ae 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 : 2020-01-07 14:19:24 + * @LastEditTime : 2020-01-07 15:23:19 */ import axios from 'axios'; @@ -71,7 +71,7 @@ export async function fetchUserProgramDetail (identifier) { // 获取提交记录 export async function fetchUserCommitRecord (identifier, params) { - console.log('identifier=====', identifier); + // console.log('identifier=====', identifier); const url = `/myproblems/${identifier}/submit_records.json`; return axios.get(url, { params }); } @@ -151,4 +151,7 @@ export async function fetchQuestion (params) { } // 新增选题 -export async function fetchExaminationItems () {} \ No newline at end of file +export async function fetchTagDisciplines (params) { + const url = `/tag_disciplines.json`; + return axios.post(url, params); +} \ No newline at end of file