From ae4a4a2f9927413f76017926c6588939e55e015f Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Thu, 12 Dec 2019 08:49:50 +0800 Subject: [PATCH 01/10] add author --- public/react/src/modules/developer/DeveloperHome.js | 10 ++++++++-- .../react/src/modules/developer/studentStudy/index.js | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/developer/DeveloperHome.js b/public/react/src/modules/developer/DeveloperHome.js index 178e13ef5..6ca297f80 100644 --- a/public/react/src/modules/developer/DeveloperHome.js +++ b/public/react/src/modules/developer/DeveloperHome.js @@ -421,6 +421,7 @@ class DeveloperHome extends React.PureComponent { // const { testReducer, handleClick } = this.props; const { ojListReducer: {hacks_list, top_data, hacks_count}, + user, pagination } = this.props; const {passed_count = 0, simple_count = 0, medium_count = 0, diff_count = 0} = top_data; @@ -443,7 +444,11 @@ class DeveloperHome extends React.PureComponent { >{ctx} )}); }; - + // console.log('=====>>>>>>>>>.', this.props); + + const newBtnStyle = user && (user.admin || (user.is_teacher && user.professional_certification) || user.business) + ? { display: 'block'} + : { display: 'none'}; return (
@@ -457,7 +462,8 @@ class DeveloperHome extends React.PureComponent {
-
diff --git a/public/react/src/modules/developer/studentStudy/index.js b/public/react/src/modules/developer/studentStudy/index.js index e218092a0..91ad6778f 100644 --- a/public/react/src/modules/developer/studentStudy/index.js +++ b/public/react/src/modules/developer/studentStudy/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-23 10:53:19 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-10 19:16:18 + * @LastEditTime: 2019-12-11 17:35:49 */ import './index.scss'; import React, { useEffect } from 'react'; @@ -70,7 +70,7 @@ const StudentStudy = (props) => {
{/* to={`/problems/${_hack_id}/edit`} */} - + 编辑 {/* to="/problems" */} From a99b4d3aac095c0932922a0ac4399d9b0fc669f8 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Thu, 12 Dec 2019 20:10:57 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/developer/studentStudy/index.js | 54 +++++++++++++++++-- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/developer/studentStudy/index.js b/public/react/src/modules/developer/studentStudy/index.js index 91ad6778f..923017ffa 100644 --- a/public/react/src/modules/developer/studentStudy/index.js +++ b/public/react/src/modules/developer/studentStudy/index.js @@ -4,10 +4,10 @@ * @Github: * @Date: 2019-11-23 10:53:19 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-11 17:35:49 + * @LastEditTime: 2019-12-12 19:08:24 */ import './index.scss'; -import React, { useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import { connect } from 'react-redux'; import SplitPane from 'react-split-pane'; import LeftPane from './leftpane'; @@ -15,18 +15,22 @@ import RightPane from './rightpane'; // import { Link } from 'react-router-dom'; // import { getImageUrl } from 'educoder' // import RightPane from '../newOrEditTask/rightpane'; -import { Icon } from 'antd'; +import { Icon, Modal } from 'antd'; import UserInfo from '../components/userInfo'; import actions from '../../../redux/actions'; import { fromStore} from 'educoder'; import { withRouter } from 'react-router'; -const StudentStudy = (props) => { +function StudentStudy (props) { const { userInfo, hack_identifier } = props; + + // 是否更新 + const [isUpdate, setIsUpdate] = useState(true); + useEffect(() => { const { match: { params }, @@ -35,13 +39,53 @@ const StudentStudy = (props) => { } = props; let { id } = params; - // console.log(id); // 保存当前的id saveUserProgramIdentifier(id); // startProgramQuestion(id); getUserProgramDetail(id); }, []); + useEffect(() => { + console.log('=======>>>>>>>>'); + const { hack = {} } = props; + if (!hack.modify_code && isUpdate) { // 代码更改,提示是否需要更新代码 + setIsUpdate(false); + Modal.confirm({ + title: '提示', + content: ( +

+ 代码文件有更新啦
+ 还未提交的代码,请自行保存 +

+ ), + okText: '立即更新', + cancelText: '稍后再说', + onOk () { + console.log('更新代码....'); + } + }); + } + }, [props]); + // useEffect(() => { + // const {hack} = props; + // if (!hack.modify_code) { // 代码更改,提示是否需要更新代码 + // Modal.confirm({ + // title: '提示', + // content: ( + //

+ // 代码文件有更新啦
+ // 还未提交的代码,请自行保存 + //

+ // ), + // okText: '立即更新', + // cancelText: '稍后再说', + // onOk () { + // console.log('更新代码....'); + // } + // }); + // } + // }, [props]); + const _hack_id = hack_identifier || fromStore('hack_identifier'); // 处理编辑 From 806630e1e46ceee14a4099eaa901196e22fe01cb Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Fri, 13 Dec 2019 10:55:35 +0800 Subject: [PATCH 03/10] add author --- .../src/common/components/ModalConfirm.js | 30 +++++ .../src/modules/developer/DeveloperHome.js | 24 +++- .../modules/developer/newOrEditTask/index.js | 70 +++++++----- public/react/src/redux/actions/index.js | 2 + public/react/src/redux/actions/ojForm.js | 104 ++++++++++-------- public/react/src/services/ojService.js | 8 +- 6 files changed, 160 insertions(+), 78 deletions(-) create mode 100644 public/react/src/common/components/ModalConfirm.js diff --git a/public/react/src/common/components/ModalConfirm.js b/public/react/src/common/components/ModalConfirm.js new file mode 100644 index 000000000..bb29fed03 --- /dev/null +++ b/public/react/src/common/components/ModalConfirm.js @@ -0,0 +1,30 @@ +/* + * @Description: + * @Author: tangjiang + * @Github: + * @Date: 2019-12-13 10:28:15 + * @LastEditors: tangjiang + * @LastEditTime: 2019-12-13 10:37:17 + */ +import { Modal } from 'antd'; + +export function ModalConfirm ( + title, + content, + handleOk, + handleCancel +) { + + Modal.confirm({ + title, + content, + okText: '确定', + cancelText: '取消', + onOk () { + handleOk && handleOk(); + }, + onCancel () { + handleCancel && handleCancel(); + } + }); +} diff --git a/public/react/src/modules/developer/DeveloperHome.js b/public/react/src/modules/developer/DeveloperHome.js index 6ca297f80..5f787659e 100644 --- a/public/react/src/modules/developer/DeveloperHome.js +++ b/public/react/src/modules/developer/DeveloperHome.js @@ -44,6 +44,13 @@ const maps = { 'value': '2' } ], + 'languageMenu': [ + { + 'key': 'c', + 'name': 'C语言', + 'value': 'c' + } + ], 'difficultMenu': [ { 'key': '1', @@ -119,15 +126,14 @@ class DeveloperHome extends React.PureComponent { > {/* */} - ), @@ -197,7 +203,6 @@ class DeveloperHome extends React.PureComponent { componentDidMount() { // 是否是我的,如果是我的 显示编辑按钮 const { isMySource } = this.props; - console.log(this.props); if (isMySource) { this.handleFilterSearch({come_from: 'mine'}); let _columns = this.columns.concat([this.options]); @@ -346,6 +351,14 @@ class DeveloperHome extends React.PureComponent { }); this.handleFilterSearch({category: +item.key === 0 ? '' : +item.key}); } + // 下拉语言 + handleLanguageMenuClick = (item) => { + this.addShowFilterCtx({ + type: 'language', + key: item.key + }); + this.handleFilterSearch({language: item.key}) + } // 难度下拉 handleHardMenuClick = (item) => { this.addShowFilterCtx({ @@ -474,6 +487,9 @@ class DeveloperHome extends React.PureComponent { 分类 + + 语言 + 难度 diff --git a/public/react/src/modules/developer/newOrEditTask/index.js b/public/react/src/modules/developer/newOrEditTask/index.js index 6ffe46985..e750cee0a 100644 --- a/public/react/src/modules/developer/newOrEditTask/index.js +++ b/public/react/src/modules/developer/newOrEditTask/index.js @@ -9,7 +9,7 @@ import './index.scss'; import React, { useEffect } from 'react'; import { connect } from 'react-redux'; import SplitPane from 'react-split-pane';// import { Form } from 'antd'; -import { Button } from 'antd'; +import { Button, Modal } from 'antd'; import LeftPane from './leftpane'; import RightPane from './rightpane'; import { withRouter } from 'react-router'; @@ -17,6 +17,7 @@ import { toStore } from 'educoder'; import UserInfo from '../components/userInfo'; // import RightPane from './rightpane/index'; import actions from '../../../redux/actions'; +import {ModalConfirm} from '../../../common/components/ModalConfirm'; const NewOrEditTask = (props) => { const { @@ -32,17 +33,18 @@ const NewOrEditTask = (props) => { changePublishLoadingStatus, startProgramQuestion, getUserInfoForNew, + handleCancelPublish, // updateTestAndValidate, } = props; // 表单提交 const handleSubmitForm = () => { + // 改变loading状态 + changeSubmitLoadingStatus(true); // 调用输入表单验证功能 if (props.identifier) { props.handleUpdateOjForm(props); } else { - // 改变loading状态 - changeSubmitLoadingStatus(true); props.handleFormSubmit(props); // 提交表单 } }; @@ -66,6 +68,9 @@ const NewOrEditTask = (props) => { }, []); // 模拟挑战 + const imitationChallenge = () => { + } + // 开始挑战 const startChallenge = () => { // 调用 start 接口, 成功后跳转到模拟页面 startProgramQuestion(identifier, props); @@ -84,9 +89,20 @@ const NewOrEditTask = (props) => { // 发布 const handleClickPublish = () => { - // console.log('public has click'); - changePublishLoadingStatus(true); - handlePublish(props, 'publish'); + ModalConfirm('提示', (

发布后即可应用到自己管理的课堂
是否确认发布?

), () => { + changePublishLoadingStatus(true); + handlePublish(props, 'publish'); + }); + + + } + // 撤销发布 + const handleClickCancelPublish = () => { + ModalConfirm('提示', (

是否确认撤销发布?

), () => { + changePublishLoadingStatus(true); + handleCancelPublish(props, identifier); + }); + } // 取消保存/取消按钮 @@ -107,11 +123,23 @@ const NewOrEditTask = (props) => { } // 发布/模拟挑战 const renderPubOrFight = () => { - const pubButton = isPublish ? '' : (); + const pubButton = isPublish + ? () + : (); + // 未发布: 模拟挑战 已发布: 开始挑战 + const challengeBtn = isPublish ? ( + + ) : ( + + ); return ( {pubButton} - + {challengeBtn} + {/* */} ) } @@ -142,24 +171,9 @@ const NewOrEditTask = (props) => { return (
- {/* - 后退 - */}

{props.name || ''}

{ renderQuit() } - {/* 退出 */} - {/* */}
@@ -206,6 +220,8 @@ const mapDispatchToProps = (dispatch) => ({ handleFormSubmit: (props) => dispatch(actions.validateOjForm(props)), // 发布表单 handlePublish: (props, type) => dispatch(actions.validateOjForm(props, type)), + // 撤销发布 + handleCancelPublish: (props, identifier) => dispatch(actions.handleClickCancelPublish(props, identifier)), // 更新OJForm handleUpdateOjForm: (props) => dispatch(actions.validateOjForm(props)), // 根据id号获取表单信息 diff --git a/public/react/src/redux/actions/index.js b/public/react/src/redux/actions/index.js index e52b88fc5..c19fa7e41 100644 --- a/public/react/src/redux/actions/index.js +++ b/public/react/src/redux/actions/index.js @@ -31,6 +31,7 @@ import { testCaseOutputChange, updateTestAndValidate, updateOpenTestCaseIndex, + handleClickCancelPublish, } from './ojForm'; import { @@ -79,6 +80,7 @@ export default { validateOjTimeLimit, validateOjCategory, validateOpenOrNot, + handleClickCancelPublish, addTestCase, deleteTestCase, testCaseInputChange, diff --git a/public/react/src/redux/actions/ojForm.js b/public/react/src/redux/actions/ojForm.js index c49e628f3..b7fbd6e80 100644 --- a/public/react/src/redux/actions/ojForm.js +++ b/public/react/src/redux/actions/ojForm.js @@ -4,11 +4,16 @@ * @Github: * @Date: 2019-11-20 16:35:46 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-10 19:54:56 + * @LastEditTime: 2019-12-13 10:46:15 */ import types from './actionTypes'; import CONST from '../../constants'; -import { fetchPostOjForm, fetchGetOjById, publishTask } from '../../services/ojService'; +import { + fetchPostOjForm, + fetchGetOjById, + publishTask, + cancelPublicTask +} from '../../services/ojService'; import { Base64 } from 'js-base64'; import { message, notification, Modal } from 'antd'; import { toStore } from 'educoder'; @@ -80,6 +85,18 @@ const payloadInfo = (key, value, errMsg, validateInfo) => ({ } }); +// 接口调用成功后,跳转至列表页 +function linkToDev (dispatch, props) { + toStore('oj_description', ''); + dispatch({ + type: types.IS_MY_SOURCE, + payload: true + }); + setTimeout(() => { + props.history.push('/problems'); + }, 1000); +} + // 表单提交验证 export const validateOjForm = (props, type) => { return (dispatch, getState) => { @@ -229,59 +246,31 @@ export const validateOjForm = (props, type) => { paramsObj['identifier'] = identifier; } - // 接口调用成功后,跳转至列表页 - function linkToDev () { - toStore('oj_description', ''); - dispatch({ - type: types.IS_MY_SOURCE, - payload: true - }); - setTimeout(() => { - props.history.push('/problems'); - }, 1000); - } - // 调用保存或更新 if (type === 'publish') { // 提示发布信息 - Modal.confirm({ - title: '提示', - content: ` - 发布后即可应用到自己管理的课堂, - 是否确定发布?`, - okText: '确定', - cancelText: '取消', - onOk () { - publishTask(identifier).then(res => { - if (res.data.status === 0) { - message.success('发布成功!'); - linkToDev(); - } - dispatch({ - type: types.PUBLISH_LOADING_STATUS, - payload: false - }); - }).catch(() => { - dispatch({ - type: types.PUBLISH_LOADING_STATUS, - payload: false - }); - }); - }, - onCancel () { - dispatch({ - type: types.PUBLISH_LOADING_STATUS, - payload: false - }); + publishTask(identifier).then(res => { + if (res.data.status === 0) { + message.success('发布成功!'); + linkToDev(dispatch, props); } + dispatch({ + type: types.PUBLISH_LOADING_STATUS, + payload: false + }); + }).catch(() => { + dispatch({ + type: types.PUBLISH_LOADING_STATUS, + payload: false + }); }); } else { // 调用更新 fetchPostOjForm(paramsObj).then(res => { if (res.status === 200) { // 保存成功后,重新跳转至列表页 - if (res.data.identifier) { - message.success('保存成功!'); - linkToDev(); + if (res.data.status === 0) { + message.success(paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功'); + linkToDev(dispatch, props); } dispatch({ type: types.SUBMIT_LOADING_STATUS, @@ -299,6 +288,29 @@ export const validateOjForm = (props, type) => { } } }; +// 撤销发布 +export const handleClickCancelPublish = (props, identifier) => { + return (dispatch) => { + cancelPublicTask(identifier).then(res => { + dispatch({ + type: types.PUBLISH_LOADING_STATUS, + payload: false + }); + if (res.status = 200) { + const { data} = res; + if (data.status === 0) { + message.success('撤销发布成功!'); + linkToDev(dispatch, props); + } + } + }).catch(() => { + dispatch({ + type: types.PUBLISH_LOADING_STATUS, + payload: false + }); + }) + } +} // 保存提交的代码 export const saveOjFormCode = (value) => { return { diff --git a/public/react/src/services/ojService.js b/public/react/src/services/ojService.js index 74c243379..9700f7031 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-10 20:46:16 + * @LastEditTime: 2019-12-13 10:09:12 */ import axios from 'axios'; @@ -95,6 +95,12 @@ export async function publishTask (identifier) { return axios.post(url); } +// 撤销发布 +export async function cancelPublicTask (identifier) { + const url = `/problems/${identifier}/cancel_publish.json`; + return axios.post(url); +} + // 更新用户编辑代码 export async function fetchUpdateCode (identifier, params) { const url = `/myproblems/${identifier}/update_code.json`; From 74586f166adccffc701d2906042e7ea6e933d149 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Fri, 13 Dec 2019 13:30:55 +0800 Subject: [PATCH 04/10] update test cases --- .../modules/developer/newOrEditTask/index.js | 22 ++++++++++++++----- .../leftpane/editorTab/AddTestDemo.js | 6 ++--- .../newOrEditTask/leftpane/editorTab/index.js | 3 ++- .../react/src/redux/reducers/ojFormReducer.js | 12 ++++++---- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/public/react/src/modules/developer/newOrEditTask/index.js b/public/react/src/modules/developer/newOrEditTask/index.js index e750cee0a..bc905fdf7 100644 --- a/public/react/src/modules/developer/newOrEditTask/index.js +++ b/public/react/src/modules/developer/newOrEditTask/index.js @@ -140,16 +140,26 @@ const NewOrEditTask = (props) => { ) : ( ); + + // 更新 + // const updateBtn = isPublish + // ? '' + // : ( + // + // ); return ( - + {pubButton} {challengeBtn} - {/* */} ) } diff --git a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/AddTestDemo.js b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/AddTestDemo.js index d34efc080..4c4131fa9 100644 --- a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/AddTestDemo.js +++ b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/AddTestDemo.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-21 09:19:38 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-10 19:37:35 + * @LastEditTime: 2019-12-13 11:58:46 */ import './index.scss'; import React, { useState } from 'react'; @@ -16,7 +16,7 @@ const { TextArea } = Input; const FormItem = Form.Item; const AddTestDemo = (props) => { const { - // key, + key, onSubmitTest, onDeleteTest, testCase, @@ -138,7 +138,7 @@ const AddTestDemo = (props) => { return ( handleChangeCollapse()}> - +
输入} 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 7a3b3f486..762d1d3ba 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-09 10:22:03 + * @LastEditTime: 2019-12-13 11:39:52 */ import 'quill/dist/quill.core.css'; import 'quill/dist/quill.bubble.css'; @@ -185,6 +185,7 @@ class EditTab extends React.Component { }; const renderTestCase = () => { return this.props.testCases.map((item, i) => { + console.log(111); return { const { position } = action.payload; // 根据 position 去查找当前元素在数组中的位置 const index = state.testCases.findIndex((item) => item.position === position); + const tempTestCase = state.testCases || []; + const tempTestValicate = state.testCasesValidate || []; if (index > -1) { - state.testCases.splice(index, 1); // 删除当前元素 - state.testCasesValidate.splice(index, 1); // 删除测试用例对应的校验 + tempTestCase.splice(index, 1); // 删除当前元素 + tempTestValicate.splice(index, 1); // 删除测试用例对应的校验 } return { - ...state + ...state, + testCases: [...tempTestCase], + testCasesValidate: [...tempTestValicate] }; case types.SAVE_OJ_FORM_ID: state.identifier = action.payload; From cab666e9a5b5ae38d5e653f4c112d8597c6107cc Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Fri, 13 Dec 2019 16:19:09 +0800 Subject: [PATCH 05/10] update --- .../components/myMonacoEditor/index.js | 4 ++-- .../modules/developer/studentStudy/index.js | 24 ++----------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/public/react/src/modules/developer/components/myMonacoEditor/index.js b/public/react/src/modules/developer/components/myMonacoEditor/index.js index 85fee0efa..60f54ee0a 100644 --- a/public/react/src/modules/developer/components/myMonacoEditor/index.js +++ b/public/react/src/modules/developer/components/myMonacoEditor/index.js @@ -4,11 +4,11 @@ * @Github: * @Date: 2019-11-27 15:02:52 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-10 09:20:42 + * @LastEditTime: 2019-12-13 16:16:56 */ import './index.scss'; import React, { useState, useRef, useEffect } from 'react'; -import { Icon, Drawer, Modal } from 'antd'; +import { Drawer, Modal } from 'antd'; import { fromStore } from 'educoder'; import { connect } from 'react-redux'; import MonacoEditor from '@monaco-editor/react'; diff --git a/public/react/src/modules/developer/studentStudy/index.js b/public/react/src/modules/developer/studentStudy/index.js index 923017ffa..89e18223e 100644 --- a/public/react/src/modules/developer/studentStudy/index.js +++ b/public/react/src/modules/developer/studentStudy/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-23 10:53:19 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-12 19:08:24 + * @LastEditTime: 2019-12-13 16:15:45 */ import './index.scss'; import React, { useEffect, useState } from 'react'; @@ -46,7 +46,6 @@ function StudentStudy (props) { }, []); useEffect(() => { - console.log('=======>>>>>>>>'); const { hack = {} } = props; if (!hack.modify_code && isUpdate) { // 代码更改,提示是否需要更新代码 setIsUpdate(false); @@ -61,30 +60,11 @@ function StudentStudy (props) { okText: '立即更新', cancelText: '稍后再说', onOk () { - console.log('更新代码....'); + } }); } }, [props]); - // useEffect(() => { - // const {hack} = props; - // if (!hack.modify_code) { // 代码更改,提示是否需要更新代码 - // Modal.confirm({ - // title: '提示', - // content: ( - //

- // 代码文件有更新啦
- // 还未提交的代码,请自行保存 - //

- // ), - // okText: '立即更新', - // cancelText: '稍后再说', - // onOk () { - // console.log('更新代码....'); - // } - // }); - // } - // }, [props]); const _hack_id = hack_identifier || fromStore('hack_identifier'); From 2592cd39cf3800e12f43a8069b441a4b79fb118b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 13 Dec 2019 16:27:30 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/AppConfig.js | 2 +- .../modules/courses/shixunHomework/ShixunWorkReport.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 064c64db1..d88d5f05f 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -33,7 +33,7 @@ if (isDev) { // 超管 // debugType="admin"; // 老师 -// debugType="teacher"; +//ebugType="teacher"; // 学生 //debugType="student"; diff --git a/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js b/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js index 1bf7ac181..10b12eb0a 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js @@ -315,6 +315,7 @@ class ShixunWorkReport extends Component { // let showAppraiseModals=this.props&&this.props.isAdminOrTeacher()===true?work_comment===null||work_comment===undefined?false:true:work_comment===null||work_comment===undefined?false:true; let showAppraiseModals=work_comment===null||work_comment===undefined?false:true; document.title=data&&data.course_name; + return ( data===undefined?"": @@ -366,10 +367,15 @@ class ShixunWorkReport extends Component {

{data&&data.shixun_name}

{/*{this.props.isAdmin()?导出实训报告数据:""}*/} 返回 - this.confirmysl(`/student_works/${homeworkid}/export_shixun_work_report.pdf`)} - > 导出实训报告数据 + > 导出实训报告数据: + parseInt(this.props&&this.props.user.user_id)===parseInt(data&&data.user_id)?this.confirmysl(`/student_works/${homeworkid}/export_shixun_work_report.pdf`)} + > 导出实训报告数据:"" + } {/*{this.props.isAdmin() ?work_comment_hidden===true? "":this.showAppraiseModal(1)}*/} From b227563447e0de86d8f283b48bf51b59dabe19e7 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Fri, 13 Dec 2019 16:57:15 +0800 Subject: [PATCH 07/10] update tip info --- .../modules/developer/studentStudy/index.js | 32 +++++++++++-------- .../developer/studentStudy/rightpane/index.js | 6 ++-- public/react/src/redux/actions/ojForUser.js | 13 +++++--- public/react/src/redux/actions/ojForm.js | 20 +++++++++--- 4 files changed, 47 insertions(+), 24 deletions(-) diff --git a/public/react/src/modules/developer/studentStudy/index.js b/public/react/src/modules/developer/studentStudy/index.js index 89e18223e..f6f21f8fe 100644 --- a/public/react/src/modules/developer/studentStudy/index.js +++ b/public/react/src/modules/developer/studentStudy/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-23 10:53:19 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-13 16:15:45 + * @LastEditTime: 2019-12-13 16:46:31 */ import './index.scss'; import React, { useEffect, useState } from 'react'; @@ -25,20 +25,23 @@ function StudentStudy (props) { const { userInfo, - hack_identifier + hack_identifier, + user_program_identifier, + restoreInitialCode } = props; // 是否更新 const [isUpdate, setIsUpdate] = useState(true); - useEffect(() => { - const { - match: { params }, - getUserProgramDetail, - saveUserProgramIdentifier - } = props; + const { + match: { params }, + getUserProgramDetail, + saveUserProgramIdentifier + } = props; - let { id } = params; + let { id } = params; + + useEffect(() => { // 保存当前的id saveUserProgramIdentifier(id); // startProgramQuestion(id); @@ -60,7 +63,7 @@ function StudentStudy (props) { okText: '立即更新', cancelText: '稍后再说', onOk () { - + restoreInitialCode(id, '更新成功'); } }); } @@ -126,11 +129,12 @@ function StudentStudy (props) { const mapStateToProps = (state) => { const { userInfo } = state.userReducer; - const { hack_identifier } = state.ojForUserReducer; + const { hack_identifier, user_program_identifier } = state.ojForUserReducer; return { userInfo, + user_program_identifier, hack_identifier - }; + }; }; const mapDispatchToProps = (dispatch) => ({ @@ -139,7 +143,9 @@ const mapDispatchToProps = (dispatch) => ({ // 调用编程题详情 getUserProgramDetail: (id) => dispatch(actions.getUserProgramDetail(id)), saveUserProgramIdentifier: (id) => dispatch(actions.saveUserProgramIdentifier(id)), - saveEditorCodeForDetail: (code) => dispatch(actions.saveEditorCodeForDetail(code)) + saveEditorCodeForDetail: (code) => dispatch(actions.saveEditorCodeForDetail(code)), + // 恢复初始代码 + restoreInitialCode: (identifier, msg) => dispatch(actions.restoreInitialCode(identifier, msg)), }); export default withRouter(connect( diff --git a/public/react/src/modules/developer/studentStudy/rightpane/index.js b/public/react/src/modules/developer/studentStudy/rightpane/index.js index 39d42f749..669a8a693 100644 --- a/public/react/src/modules/developer/studentStudy/rightpane/index.js +++ b/public/react/src/modules/developer/studentStudy/rightpane/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-27 14:59:51 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-10 19:00:30 + * @LastEditTime: 2019-12-13 16:50:40 */ import React, { useState, useEffect } from 'react'; import {connect} from 'react-redux'; @@ -66,7 +66,7 @@ const RightPane = (props) => { } // 恢复初始代码 const handleRestoreInitialCode = () => { - restoreInitialCode(identifier); + restoreInitialCode(identifier, '恢复初始代码成功'); } return ( @@ -110,7 +110,7 @@ const mapDispatchToProps = (dispatch) => ({ // 保存用户代码至后台 saveUserCodeForInterval: (identifier, code) => dispatch(actions.saveUserCodeForInterval(identifier, code)), // 恢复初始代码 - restoreInitialCode: (identifier) => dispatch(actions.restoreInitialCode(identifier)), + restoreInitialCode: (identifier, msg) => dispatch(actions.restoreInitialCode(identifier, msg)), }); export default connect( diff --git a/public/react/src/redux/actions/ojForUser.js b/public/react/src/redux/actions/ojForUser.js index e3480a435..79e2045d6 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: 2019-12-10 19:05:36 + * @LastEditTime: 2019-12-13 16:49:42 */ import types from "./actionTypes"; import { Base64 } from 'js-base64'; @@ -19,6 +19,7 @@ import { fetchUserCodeSubmit, fetchRestoreInitialCode } from "../../services/ojService"; +import { notification } from "antd"; // 进入编程页面时,首先调用开启编程题接口 export const startProgramQuestion = (id, props) => { @@ -384,17 +385,21 @@ export const submitUserCode = (identifier, inputValue, type) => { } // 恢复初始代码 -export const restoreInitialCode = (identifier) => { +export const restoreInitialCode = (identifier, msg) => { return (dispatch) => { fetchRestoreInitialCode(identifier).then(res => { if (res.data.status === 401) return; - console.log('恢复初始代码====》》》》', res); + // console.log('恢复初始代码====》》》》', res); const {status, data} = res; if (status === 200) { dispatch({ type: types.RESTORE_INITIAL_CODE, payload: data.code - }) + }); + notification.success({ + message: '提示', + description: msg + }); } }); } diff --git a/public/react/src/redux/actions/ojForm.js b/public/react/src/redux/actions/ojForm.js index b7fbd6e80..3eaac9023 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-13 10:46:15 + * @LastEditTime: 2019-12-13 16:56:22 */ import types from './actionTypes'; import CONST from '../../constants'; @@ -251,7 +251,11 @@ export const validateOjForm = (props, type) => { // 提示发布信息 publishTask(identifier).then(res => { if (res.data.status === 0) { - message.success('发布成功!'); + // message.success('发布成功!'); + notification.success({ + message: '提示', + description: '发布成功!' + }); linkToDev(dispatch, props); } dispatch({ @@ -269,7 +273,11 @@ export const validateOjForm = (props, type) => { fetchPostOjForm(paramsObj).then(res => { if (res.status === 200) { // 保存成功后,重新跳转至列表页 if (res.data.status === 0) { - message.success(paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功'); + // message.success(paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功'); + notification.success({ + message: '提示', + description: paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功' + }); linkToDev(dispatch, props); } dispatch({ @@ -299,7 +307,11 @@ export const handleClickCancelPublish = (props, identifier) => { if (res.status = 200) { const { data} = res; if (data.status === 0) { - message.success('撤销发布成功!'); + // message.success('撤销发布成功!'); + notification.success({ + message: '提示', + description: '撤销发布成功!' + }); linkToDev(dispatch, props); } } From b740dddc9cdc048a56e1ab9458186a2893fd9fed Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 13 Dec 2019 17:03:07 +0800 Subject: [PATCH 08/10] 1 --- app/controllers/hack_user_lastest_codes_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/hack_user_lastest_codes_controller.rb b/app/controllers/hack_user_lastest_codes_controller.rb index b7ec6fb8e..814d16d51 100644 --- a/app/controllers/hack_user_lastest_codes_controller.rb +++ b/app/controllers/hack_user_lastest_codes_controller.rb @@ -23,7 +23,7 @@ class HackUserLastestCodesController < ApplicationController # 同步代码 def sync_code - @my_hack.update_attributes(code: @hack.code, modify_time: @hack.modify_time) + @my_hack.update_attributes(code: @hack.code, modify_time: Time.now) end # 调试代码 From 87e74dc839a48f414a930188ce7709682993b173 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Fri, 13 Dec 2019 17:20:07 +0800 Subject: [PATCH 09/10] restore code --- .../modules/developer/studentStudy/index.js | 20 +++++++++---------- public/react/src/services/ojService.js | 13 ++++++------ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/public/react/src/modules/developer/studentStudy/index.js b/public/react/src/modules/developer/studentStudy/index.js index f6f21f8fe..e4b296a20 100644 --- a/public/react/src/modules/developer/studentStudy/index.js +++ b/public/react/src/modules/developer/studentStudy/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-23 10:53:19 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-13 16:46:31 + * @LastEditTime: 2019-12-13 17:19:15 */ import './index.scss'; import React, { useEffect, useState } from 'react'; @@ -23,15 +23,14 @@ import { withRouter } from 'react-router'; function StudentStudy (props) { + const [hasUpdate, setHasUpdate] = useState(true); const { + // hack, userInfo, hack_identifier, - user_program_identifier, + // user_program_identifier, restoreInitialCode } = props; - - // 是否更新 - const [isUpdate, setIsUpdate] = useState(true); const { match: { params }, @@ -50,8 +49,8 @@ function StudentStudy (props) { useEffect(() => { const { hack = {} } = props; - if (!hack.modify_code && isUpdate) { // 代码更改,提示是否需要更新代码 - setIsUpdate(false); + if (hack.modify_code && hasUpdate) { // 代码更改,提示是否需要更新代码 + setHasUpdate(false); Modal.confirm({ title: '提示', content: ( @@ -67,7 +66,7 @@ function StudentStudy (props) { } }); } - }, [props]); + }, [props, hasUpdate, setHasUpdate]); const _hack_id = hack_identifier || fromStore('hack_identifier'); @@ -93,7 +92,7 @@ function StudentStudy (props) {
*/}
- 乘积最大序列 + 乘积最大序列 {hasUpdate}
{/* to={`/problems/${_hack_id}/edit`} */} @@ -129,8 +128,9 @@ function StudentStudy (props) { const mapStateToProps = (state) => { const { userInfo } = state.userReducer; - const { hack_identifier, user_program_identifier } = state.ojForUserReducer; + const { hack_identifier, user_program_identifier, hack } = state.ojForUserReducer; return { + hack, userInfo, user_program_identifier, hack_identifier diff --git a/public/react/src/services/ojService.js b/public/react/src/services/ojService.js index 9700f7031..e13b66397 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-13 10:09:12 + * @LastEditTime: 2019-12-13 17:03:47 */ import axios from 'axios'; @@ -84,10 +84,10 @@ export async function fetchUserCommitRecordDetail (identifier) { } // 恢复初始代码 -export async function restoreInitialCode (identifier) { - const url = `/myproblems/${identifier}/restore_initial_code.json`; - return axios.get(url); -} +// export async function restoreInitialCode (identifier) { +// const url = `/myproblems/${identifier}/restore_initial_code.json`; +// return axios.get(url); +// } // 发布任务 export async function publishTask (identifier) { @@ -115,7 +115,8 @@ export async function fetchUserCodeSubmit (identifier) { // 恢复初始代码 export async function fetchRestoreInitialCode (identifier) { - const url = `/myproblems/${identifier}/restore_initial_code.json`; + // const url = `/myproblems/${identifier}/restore_initial_code.json`; + const url = `/myproblems/${identifier}/sync_code.json`; return axios.post(url); } From 42d4207f05ab3991b8e77008153f59a4a7b0fd37 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Fri, 13 Dec 2019 17:42:00 +0800 Subject: [PATCH 10/10] update style --- .../modules/developer/components/controlSetting/index.js | 4 ++-- .../modules/developer/components/controlSetting/index.scss | 4 +++- .../src/modules/developer/components/initTabCtx/index.js | 3 ++- .../src/modules/developer/components/initTabCtx/index.scss | 7 +++++++ .../modules/developer/components/myMonacoEditor/index.scss | 4 +++- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/developer/components/controlSetting/index.js b/public/react/src/modules/developer/components/controlSetting/index.js index 690bbad36..587e1bee9 100644 --- a/public/react/src/modules/developer/components/controlSetting/index.js +++ b/public/react/src/modules/developer/components/controlSetting/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-27 16:02:36 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-10 09:30:27 + * @LastEditTime: 2019-12-13 17:32:33 */ import './index.scss'; import React, { useState, useRef } from 'react'; @@ -84,7 +84,7 @@ const ControlSetting = (props) => { diff --git a/public/react/src/modules/developer/components/controlSetting/index.scss b/public/react/src/modules/developer/components/controlSetting/index.scss index 4a2c221c1..97838ce5c 100644 --- a/public/react/src/modules/developer/components/controlSetting/index.scss +++ b/public/react/src/modules/developer/components/controlSetting/index.scss @@ -2,6 +2,7 @@ position: absolute; bottom: 0; width: 100%; + background:rgba(30,30,30,1); // height: 56px; .control_tab{ position: absolute; @@ -51,7 +52,8 @@ height: 56px; padding-right: 30px; padding-left: 10px; - background: #000; + // background: #000; + background:rgba(48,48,48,1); } .setting_drawer{ diff --git a/public/react/src/modules/developer/components/initTabCtx/index.js b/public/react/src/modules/developer/components/initTabCtx/index.js index 19f4230b1..3834a3e11 100644 --- a/public/react/src/modules/developer/components/initTabCtx/index.js +++ b/public/react/src/modules/developer/components/initTabCtx/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-27 19:46:14 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-10 09:31:00 + * @LastEditTime: 2019-12-13 17:38:42 */ import './index.scss'; import React, { useState, useEffect, useRef, useImperativeHandle, forwardRef } from 'react'; @@ -50,6 +50,7 @@ function InitTabCtx (props, ref) { ], initialValue: inputValue })(