diff --git a/public/react/src/modules/developer/components/controlSetting/index.js b/public/react/src/modules/developer/components/controlSetting/index.js
index 1d4d7834c..502f3ae09 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-19 19:47:32
+ * @LastEditTime: 2019-12-20 14:37:39
*/
import './index.scss';
import React, { useState, useRef, useEffect } from 'react';
@@ -24,7 +24,7 @@ const ControlSetting = (props) => {
identifier,
excuteState,
showOrHideControl,
- commitRecordDetail,
+ commitTestRecordDetail,
changeLoadingState,
changeSubmitLoadingStatus,
changeShowOrHideControl,
@@ -102,7 +102,7 @@ const ControlSetting = (props) => {
@@ -137,14 +137,14 @@ const ControlSetting = (props) => {
const mapStateToProps = (state) => {
const {commonReducer, ojForUserReducer} = state;
const {loading, excuteState, submitLoading, showOrHideControl } = commonReducer;
- const { commitRecordDetail } = ojForUserReducer;
+ const { commitTestRecordDetail } = ojForUserReducer;
return {
loading,
submitLoading,
excuteState,
showOrHideControl,
// identifier: user_program_identifier,
- commitRecordDetail // 提交详情
+ commitTestRecordDetail // 提交详情
};
};
// changeSubmitLoadingStatus
diff --git a/public/react/src/modules/developer/newOrEditTask/index.js b/public/react/src/modules/developer/newOrEditTask/index.js
index 1c451c669..b498abe0d 100644
--- a/public/react/src/modules/developer/newOrEditTask/index.js
+++ b/public/react/src/modules/developer/newOrEditTask/index.js
@@ -70,13 +70,13 @@ const NewOrEditTask = (props) => {
// 模拟挑战
const imitationChallenge = () => {
// 调用 start 接口, 成功后跳转到模拟页面
- startProgramQuestion(identifier, props);
+ identifier && startProgramQuestion(identifier, props);
}
// 开始挑战
const startChallenge = () => {
// 调用 start 接口, 成功后跳转到开启实战
// TODO
- startProgramQuestion(identifier, props);
+ identifier && startProgramQuestion(identifier, props);
}
// 取消
diff --git a/public/react/src/modules/developer/studentStudy/index.js b/public/react/src/modules/developer/studentStudy/index.js
index 15c87e64c..9039bf3ac 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-19 19:48:20
+ * @LastEditTime: 2019-12-20 14:54:39
*/
import './index.scss';
import React, { useEffect, useState } from 'react';
@@ -92,9 +92,12 @@ function StudentStudy (props) {
changeShowOrHideControl(false);
props.saveEditorCodeForDetail();
props.history.push(`/problems/${_hack_id}/edit`);
+ props.clearOjForUserReducer();
}
// 处理退出
const handleClickQuit = () => {
+ // 退出时,清空内容
+ props.clearOjForUserReducer();
// 将控制台关闭
changeShowOrHideControl(false);
props.saveEditorCodeForDetail();
@@ -116,7 +119,11 @@ function StudentStudy (props) {
{/* to={`/problems/${_hack_id}/edit`} */}
-
+
编辑
{/* to="/problems" */}
@@ -168,7 +175,8 @@ const mapDispatchToProps = (dispatch) => ({
saveEditorCodeForDetail: (code) => dispatch(actions.saveEditorCodeForDetail(code)),
// 恢复初始代码
restoreInitialCode: (identifier, msg) => dispatch(actions.restoreInitialCode(identifier, msg)),
- changeShowOrHideControl: (flag) => dispatch(actions.changeShowOrHideControl(flag))
+ changeShowOrHideControl: (flag) => dispatch(actions.changeShowOrHideControl(flag)),
+ clearOjForUserReducer: () => dispatch(actions.clearOjForUserReducer())
});
export default withRouter(connect(
diff --git a/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.js b/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.js
index 7b6cce9f8..90c486cca 100644
--- a/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.js
+++ b/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 09:49:33
* @LastEditors: tangjiang
- * @LastEditTime: 2019-12-20 11:44:22
+ * @LastEditTime: 2019-12-20 13:55:07
*/
import './index.scss';
import React, { useState, useEffect } from 'react';
@@ -73,6 +73,7 @@ const CommitRecord = (props) => {
commitRecord,
// excuteState,
language,
+ operateType,
commitRecordDetail,
getUserCommitRecord
} = props;
@@ -146,8 +147,10 @@ const CommitRecord = (props) => {
// 提交详情变化时,显示当前提交信息
useEffect(() => {
// setRecordDetail(commitRecordDetail);
- setRenderCtx(() => (renderRecordDetail))
- }, [commitRecordDetail]);
+ if (operateType === 'submit') {
+ setRenderCtx(() => (renderRecordDetail))
+ }
+ }, [commitRecordDetail, operateType]);
// 复制功能
let count = 0;
useEffect(() => {
@@ -198,7 +201,8 @@ const mapStateToProps = (state) => {
user_program_identifier,
commitRecordDetail,
commitRecord,
- hack
+ hack,
+ operateType
} = ojForUserReducer;
const { excuteState } = commonReducer;
return {
@@ -206,7 +210,8 @@ const mapStateToProps = (state) => {
commitRecordDetail,
commitRecord, // 提交记录
excuteState, // 代码执行状态
- language: hack.language
+ language: hack.language,
+ operateType
}
}
const mapDispatchToProps = (dispatch) => ({
diff --git a/public/react/src/modules/developer/studentStudy/rightpane/index.js b/public/react/src/modules/developer/studentStudy/rightpane/index.js
index af46d0aef..054997359 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-19 19:13:05
+ * @LastEditTime: 2019-12-20 14:01:57
*/
import React, { useState, useEffect } from 'react';
import {connect} from 'react-redux';
@@ -27,6 +27,7 @@ const RightPane = (props) => {
updateNotice,
saveUserInputCode,
restoreInitialCode,
+ saveOpacityType,
saveUserCodeForInterval
} = props;
@@ -43,6 +44,7 @@ const RightPane = (props) => {
const handleSubmitForm = () => {
// 提交时, 先调用提交接口,提交成功后,循环调用测评接口
+ // saveOpacityType('submit');
submitUserCode(identifier, submitInput, 'submit');
// // 提交时,先调用评测接口, 评测通过后才调用保存接口
// updateCode(identifier, submitInput, 'submit');
@@ -71,6 +73,7 @@ const RightPane = (props) => {
// 代码调试
const handleDebuggerCode = (value) => {
// 调用保存代码块接口,成功后,调用调试接口
+ // saveOpacityType('debug');
updateCode(identifier, value, 'debug');
}
// 恢复初始代码
@@ -137,6 +140,7 @@ const mapDispatchToProps = (dispatch) => ({
saveUserCodeForInterval: (identifier, code) => dispatch(actions.saveUserCodeForInterval(identifier, code)),
// 恢复初始代码
restoreInitialCode: (identifier, msg) => dispatch(actions.restoreInitialCode(identifier, msg)),
+ // saveOpacityType: (type) => dispatch(actions.saveOpacityType(type))
});
export default connect(
diff --git a/public/react/src/redux/actions/actionTypes.js b/public/react/src/redux/actions/actionTypes.js
index 1129a3235..144558c1d 100644
--- a/public/react/src/redux/actions/actionTypes.js
+++ b/public/react/src/redux/actions/actionTypes.js
@@ -51,6 +51,8 @@ const types = {
SAVE_USER_INFO: 'SAVE_USER_INFO', // 只在用户信息
SAVE_HACK_IDENTIFIER: 'SAVE_HACK_IDENTIFIER', // 用户界面跑到编辑界面需要用的id值
SAVE_EDITOR_CODE: 'SAVE_EDITOR_CODE', // 保存详情页面中编辑时的代码
+ CLICK_OPERATE_TYPE: 'CLICK_OPERATE_TYPE', // 点击类型
+ CLEAR_OJ_FOR_USER_REDUCER: 'CLEAR_OJ_FOR_USER_REDUCER', // 退出时清空 ojForUserReducer保存内容
/*** jupyter */
GET_JUPYTER_DATA_SETS: 'GET_JUPYTER_DATA_SETS', // jupyter 数据集
GET_JUPYTER_TPI_URL: 'GET_JUPYTER_TPI_URL', // 获取 jupyter url
diff --git a/public/react/src/redux/actions/index.js b/public/react/src/redux/actions/index.js
index b42c4c2b6..93a0788cf 100644
--- a/public/react/src/redux/actions/index.js
+++ b/public/react/src/redux/actions/index.js
@@ -48,6 +48,8 @@ import {
restoreInitialCode,
saveUserCodeForInterval,
saveEditorCodeForDetail,
+ saveOpacityType,
+ clearOjForUserReducer
// isUpdateCodeCtx
} from './ojForUser';
@@ -116,6 +118,8 @@ export default {
getUserInfoForNew,
saveUserCodeForInterval,
saveEditorCodeForDetail,
+ saveOpacityType,
+ clearOjForUserReducer,
// jupyter
getJupyterTpiDataSet,
getJupyterTpiUrl,
diff --git a/public/react/src/redux/actions/ojForUser.js b/public/react/src/redux/actions/ojForUser.js
index 994830280..89d826e69 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-20 10:25:42
+ * @LastEditTime: 2019-12-20 14:47:26
*/
import types from "./actionTypes";
import { Base64 } from 'js-base64';
@@ -208,7 +208,10 @@ export const codeEvaluate = (dispatch, identifier, type, time_limit) => {
// 返回评测结果
dispatch({
type: types.COMMIT_RECORD_DETAIL,
- payload: returnData
+ payload: {
+ type,
+ data: returnData
+ }
});
if (!type || type === 'debug') {
dispatch({ // 改变 loading 值
@@ -233,6 +236,7 @@ export const codeEvaluate = (dispatch, identifier, type, time_limit) => {
});
// 重新调用一下提交记录接口
dispatch(getUserCommitRecord(identifier));
+ dispatch(saveOpacityType(type));
}
}
}).catch(err => { // 评测异常时
@@ -454,5 +458,20 @@ export const saveEditorCodeForDetail = (code) => {
}
}
+// 保存操作类型: 提交或调试
+export const saveOpacityType = (type) => {
+ return {
+ type: types.CLICK_OPERATE_TYPE,
+ payload: type
+ }
+}
+
+
+export const clearOjForUserReducer = () => {
+ return {
+ type: types.CLEAR_OJ_FOR_USER_REDUCER
+ };
+}
+
// 更新通知状态
diff --git a/public/react/src/redux/reducers/ojForUserReducer.js b/public/react/src/redux/reducers/ojForUserReducer.js
index 0c7594dd2..7e3740c19 100644
--- a/public/react/src/redux/reducers/ojForUserReducer.js
+++ b/public/react/src/redux/reducers/ojForUserReducer.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 13:41:48
* @LastEditors: tangjiang
- * @LastEditTime: 2019-12-19 20:10:39
+ * @LastEditTime: 2019-12-20 14:46:07
*/
import types from "../actions/actionTypes";
import { Base64 } from 'js-base64';
@@ -13,6 +13,7 @@ const initialState = {
user_program_identifier: '', // 开启OJ题的唯一标题
hack: {}, // 编程题主要内容
test_case: {}, // 测试用例
+ commitTestRecordDetail: {}, // 调试代码执行结果
commitRecordDetail: {}, // 提交成功后记录提交的详情
commitRecord: [], // 提交记录
userCode: '', // 保存当前用户输入的代码
@@ -24,6 +25,7 @@ const initialState = {
editor_code: '', // 保存编辑代码
notice: false, // 通知
hadCodeUpdate: false, // 更新代码
+ operateType: '', // 点击类型: 调度或提交
};
const ojForUserReducer = (state = initialState, action) => {
@@ -51,7 +53,7 @@ const ojForUserReducer = (state = initialState, action) => {
test_case: Object.assign({}, test_case)
}
case types.COMMIT_RECORD_DETAIL:
- let result = action.payload;
+ let result = action.payload.data;
if (result['expected_output']) {
result['expected_output'] = Base64.decode(result['expected_output'])
}
@@ -63,10 +65,18 @@ const ojForUserReducer = (state = initialState, action) => {
} catch (e) {
console.log('错误信息:', e);
}
- return {
- ...state,
- commitRecordDetail: Object.assign({}, result)
+ if (action.payload.type === 'submit') {
+ return {
+ ...state,
+ commitRecordDetail: Object.assign({}, result)
+ }
+ } else {
+ return {
+ ...state,
+ commitTestRecordDetail: Object.assign({}, result)
+ }
}
+
case types.COMMIT_RECORD:
return {
...state,
@@ -144,6 +154,31 @@ const ojForUserReducer = (state = initialState, action) => {
...state,
hadCodeUpdate: action.payload
};
+ case types.CLICK_OPERATE_TYPE:
+ return {
+ ...state,
+ operateType: action.payload
+ }
+ case types.CLEAR_OJ_FOR_USER_REDUCER:
+ return {
+ ...state,
+ user_program_identifier: '', // 开启OJ题的唯一标题
+ hack: {}, // 编程题主要内容
+ test_case: {}, // 测试用例
+ commitTestRecordDetail: {}, // 调试代码执行结果
+ commitRecordDetail: {}, // 提交成功后记录提交的详情
+ commitRecord: [], // 提交记录
+ userCode: '', // 保存当前用户输入的代码
+ isUpdateCode: false, // 是否更新了代码内容
+ userCodeTab: 'task', // 学员测评tab位置: task | record | comment
+ userTestInput: '', // 用户自定义输入值
+ recordDetail: {}, // 根据id号获取的记录详情
+ hack_identifier: '', // 用户界面编辑时
+ editor_code: '', // 保存编辑代码
+ notice: false, // 通知
+ hadCodeUpdate: false, // 更新代码
+ operateType: '', // 点击类型: 调度或提交
+ };
default:
return state;
}