diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index d4f9bd3c8..ac26b740c 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -1096,4 +1096,13 @@ private end end + def file_ext(file_name) + ext = '' + exts = file_name.split(".") + if exts.size > 1 + ext = ".#{exts.last}" + end + ext + end + end diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index a38489385..86cf39bac 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/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/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)}*/} diff --git a/public/react/src/modules/developer/DeveloperHome.js b/public/react/src/modules/developer/DeveloperHome.js index 178e13ef5..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({ @@ -421,6 +434,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 +457,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 +475,8 @@ class DeveloperHome extends React.PureComponent {
-
@@ -468,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..bc905fdf7 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,20 +123,43 @@ const NewOrEditTask = (props) => { } // 发布/模拟挑战 const renderPubOrFight = () => { - const pubButton = isPublish ? '' : (); + const pubButton = isPublish + ? () + : (); + // 未发布: 模拟挑战 已发布: 开始挑战 + const challengeBtn = isPublish ? ( + + ) : ( + + ); + + // 更新 + // const updateBtn = isPublish + // ? '' + // : ( + // + // ); return ( - + {pubButton} - + {challengeBtn} ) } @@ -142,24 +181,9 @@ const NewOrEditTask = (props) => { return (
- {/* - 后退 - */}

{props.name || ''}

{ renderQuit() } - {/* 退出 */} - {/* */}
@@ -206,6 +230,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/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 { +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'); // 处理编辑 @@ -70,7 +114,7 @@ const StudentStudy = (props) => {
{/* to={`/problems/${_hack_id}/edit`} */} - + 编辑 {/* to="/problems" */} diff --git a/public/react/src/modules/tpm/TPMBanner.js b/public/react/src/modules/tpm/TPMBanner.js index bf33f94a8..19e1acfa8 100644 --- a/public/react/src/modules/tpm/TPMBanner.js +++ b/public/react/src/modules/tpm/TPMBanner.js @@ -398,7 +398,7 @@ class TPMBanner extends Component { hidenpublic=()=>{ this.setState({ Modalstype: true, - Modalstopval: "是否确认撤销公开?", + Modalstopval: "是否确认撤销申请公开?", modalsMidval:" ", ModalsBottomval:" ", ModalCancel: this.ModalCancel, @@ -1080,7 +1080,7 @@ class TPMBanner extends Component { content={
                   
申请公开成功后,您的实训将会展示实训列表
-
平台审核通过,您将获得 1000 金币~
+
您将获得关卡对应的经验值和金币
} @@ -1095,8 +1095,8 @@ class TPMBanner extends Component { } {shixunsDetails.shixun_status === 2 && shixunsDetails.public===1 && this.props.identity < 5 ? - : "" } @@ -1199,7 +1199,7 @@ class TPMBanner extends Component { } - {this.props.identity < 8 && shixunsDetails.shixun_status != -1 ? + {this.props.identity < 8 && shixunsDetails.shixun_status != -1 && shixunsDetails.shixun_status != 0?
diff --git a/public/react/src/modules/tpm/TPMsettings/LearningSettings.js b/public/react/src/modules/tpm/TPMsettings/LearningSettings.js index dfcdda5ba..81de06cfb 100644 --- a/public/react/src/modules/tpm/TPMsettings/LearningSettings.js +++ b/public/react/src/modules/tpm/TPMsettings/LearningSettings.js @@ -127,7 +127,7 @@ export default class Shixuninformation extends Component { } Checkvnc = () => { - console.log(this.state.vnc) + if (this.state.vnc === false) { this.setState({ hide_code: false, @@ -193,7 +193,8 @@ export default class Shixuninformation extends Component { } else { this.setState({ multi_webssh: false, - opensshRadio: null + opensshRadio: null, + hide_code:false }) } this.setState({ @@ -274,7 +275,7 @@ export default class Shixuninformation extends Component { : ""}
: ""} - {this.state.vnc === true ? "" :
+ {this.state.vnc === true||this.state.websshshow === false ? "" :
隐藏代码窗口: { return (
  • - + {item.title} diff --git a/public/react/src/redux/actions/index.js b/public/react/src/redux/actions/index.js index 465ab1385..ad33061ba 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 { @@ -89,6 +90,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/redux/reducers/ojFormReducer.js b/public/react/src/redux/reducers/ojFormReducer.js index ce89bce9a..c2ba0f4d8 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-09 16:30:46 + * @LastEditTime: 2019-12-13 11:54:35 */ import { Base64 } from 'js-base64'; import types from '../actions/actionTypes'; @@ -146,12 +146,16 @@ const ojFormReducer = (state = initialState, action) => { 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; 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`;