diff --git a/public/react/src/modules/developer/studentStudy/rightpane/index.js b/public/react/src/modules/developer/studentStudy/rightpane/index.js
index 216deffdb..f146e6e6b 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-03 09:31:59
+ * @LastEditTime: 2019-12-04 10:57:49
*/
import React from 'react';
import {connect} from 'react-redux';
@@ -20,7 +20,8 @@ const RightPane = (props) => {
submitUserCode,
input,
updateCode,
- saveUserInputCode
+ saveUserInputCode,
+ restoreInitialCode
} = props;
const handleSubmitForm = () => {
@@ -33,7 +34,7 @@ const RightPane = (props) => {
// 代码块内容变化时
const handleCodeChange = (code) => {
// 保存用户提交的代码块
- console.log(code);
+ // console.log(code);
// 保存用户代码块
saveUserInputCode(code);
}
@@ -42,13 +43,19 @@ const RightPane = (props) => {
// 调用保存代码块接口,成功后,调用调试接口
updateCode(identifier, value, 'debug');
}
+ // 恢复初始代码
+ const handleRestoreInitialCode = () => {
+ restoreInitialCode(identifier);
+ }
return (
-
({
updateCode: (identifier, inputValue, type) => dispatch(actions.updateCode(identifier, inputValue, type)),
// 保存用户代码块
saveUserInputCode: (code) => dispatch(actions.saveUserInputCode(code)),
+ // 恢复初始代码
+ restoreInitialCode: (identifier) => dispatch(actions.restoreInitialCode(identifier)),
});
export default connect(
diff --git a/public/react/src/modules/tpm/TPMIndex.js b/public/react/src/modules/tpm/TPMIndex.js
index 9b3308e04..7fd389197 100644
--- a/public/react/src/modules/tpm/TPMIndex.js
+++ b/public/react/src/modules/tpm/TPMIndex.js
@@ -148,7 +148,7 @@ class TPMIndex extends Component {
componentDidMount = () => {
let id = this.props.match.params.shixunId;
-
+ console.log('props', this.props);
// let collaborators = `/shixuns/` + id + `/propaedeutics.json`;
//
// axios.get(collaborators).then((response) => {
diff --git a/public/react/src/redux/actions/actionTypes.js b/public/react/src/redux/actions/actionTypes.js
index c6c50bce6..f6bc7f3b9 100644
--- a/public/react/src/redux/actions/actionTypes.js
+++ b/public/react/src/redux/actions/actionTypes.js
@@ -45,6 +45,8 @@ const types = {
CHANGE_PAGINATION_INFO: 'CHANGE_PAGINATION_INFO', // 改变分页数据
UPDATE_TEST_AND_VALIDATE: 'UPDATE_TEST_AND_VALIDATE', // 更新测试用例及验证值
UPDATE_OPEN_TESTCASE_INDEX: 'UPDATE_OPEN_TESTCASE_INDEX', // 更新测试用例索引
+ GET_COMMIT_RECORD_DETAIL_BY_ID: 'GET_COMMIT_RECORD_DETAIL_BY_ID', // 根据id号获取提交记录详情
+ RESTORE_INITIAL_CODE: 'RESTORE_INITIAL_CODE' // 恢复初始代码
}
export default types;
diff --git a/public/react/src/redux/actions/index.js b/public/react/src/redux/actions/index.js
index 212ff81e8..2e113032d 100644
--- a/public/react/src/redux/actions/index.js
+++ b/public/react/src/redux/actions/index.js
@@ -40,6 +40,7 @@ import {
submitUserCode,
getUserProgramDetail,
saveUserProgramIdentifier,
+ restoreInitialCode,
// isUpdateCodeCtx
} from './ojForUser';
@@ -87,6 +88,7 @@ export default {
getUserProgramDetail,
updateTestAndValidate,
updateOpenTestCaseIndex,
- saveUserProgramIdentifier
+ saveUserProgramIdentifier,
+ restoreInitialCode,
// isUpdateCodeCtx
}
\ No newline at end of file
diff --git a/public/react/src/redux/actions/ojForUser.js b/public/react/src/redux/actions/ojForUser.js
index e1c318a62..1ca7f3b32 100644
--- a/public/react/src/redux/actions/ojForUser.js
+++ b/public/react/src/redux/actions/ojForUser.js
@@ -4,18 +4,20 @@
* @Github:
* @Date: 2019-11-27 13:42:11
* @LastEditors: tangjiang
- * @LastEditTime: 2019-12-03 20:44:47
+ * @LastEditTime: 2019-12-04 10:54:50
*/
import types from "./actionTypes";
import { Base64 } from 'js-base64';
import {
fetchStartProgram,
fetchUserProgramDetail,
- fetchDebuggerCode, fetchCodeSubmit,
+ fetchDebuggerCode,
+ fetchCodeSubmit,
fetchUserCommitRecord,
fetchUserCommitRecordDetail,
fetchUpdateCode,
- fetchUserCodeSubmit
+ fetchUserCodeSubmit,
+ fetchRestoreInitialCode
} from "../../services/ojService";
// 进入编程页面时,首先调用开启编程题接口
@@ -46,16 +48,23 @@ export const saveUserProgramIdentifier = (identifier) => {
}
// 获取用户编程题详情
-export const getUserProgramDetail = (identifier) => {
+export const getUserProgramDetail = (identifier, type) => {
// 调用用户编程详情接口
return (dispatch) => {
fetchUserProgramDetail(identifier).then(res => {
const { status, data = {} } = res;
if (status === 200) {
- dispatch({
- type: types.USER_PROGRAM_DETAIL,
- payload: data
- });
+ if (!type) {
+ dispatch({
+ type: types.USER_PROGRAM_DETAIL,
+ payload: data
+ });
+ } else {
+ dispatch({
+ type: types.GET_COMMIT_RECORD_DETAIL_BY_ID,
+ payload: data
+ })
+ }
}
});
}
@@ -227,9 +236,9 @@ export const getUserCommitRecord = (identifier) => {
}
}
// 获取提交记录详情
-export const getUserCommitRecordDetail = () => {
+export const getUserCommitRecordDetail = (identifier) => {
return (dispatch) => {
- fetchUserCommitRecordDetail().then(res => {
+ fetchUserCommitRecordDetail(identifier).then(res => {
console.log('提交记录详情======》》》》', res);
});
}
@@ -302,3 +311,11 @@ export const submitUserCode = (identifier, inputValue, type) => {
}
}
+export const restoreInitialCode = (identifier) => {
+ return (dispatch) => {
+ fetchRestoreInitialCode(identifier).then(res => {
+ console.log('恢复初始代码====》》》》', res);
+ });
+ }
+}
+
diff --git a/public/react/src/redux/reducers/ojForUserReducer.js b/public/react/src/redux/reducers/ojForUserReducer.js
index 3aea19e61..8f6fe4b0c 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-03 20:00:26
+ * @LastEditTime: 2019-12-04 09:02:30
*/
import types from "../actions/actionTypes";
import { Base64 } from 'js-base64';
@@ -13,12 +13,13 @@ const initialState = {
user_program_identifier: '', // 开启OJ题的唯一标题
hack: {}, // 编程题主要内容
test_case: {}, // 测试用例
- commitRecordDetail: {}, // 提交记录详情
+ commitRecordDetail: {}, // 提交成功后记录提交的详情
commitRecord: [], // 提交记录
userCode: '', // 保存当前用户输入的代码
isUpdateCode: false, // 是否更新了代码内容
userCodeTab: 'task', // 学员测评tab位置: task | record | comment
userTestInput: '', // 用户自定义输入值
+ recordDetail: {}, // 根据id号获取的记录详情
};
const ojForUserReducer = (state = initialState, action) => {
@@ -78,6 +79,11 @@ const ojForUserReducer = (state = initialState, action) => {
...state,
userCodeTab: action.payload
}
+ case types.GET_COMMIT_RECORD_DETAIL_BY_ID:
+ return {
+ ...state,
+ recordDetail: action.payload
+ }
default:
return state;
}
diff --git a/public/react/src/services/ojService.js b/public/react/src/services/ojService.js
index f8d888890..1f3ba0ad6 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-03 14:10:13
+ * @LastEditTime: 2019-12-04 10:53:41
*/
import axios from 'axios';
@@ -71,9 +71,11 @@ export async function fetchUserCommitRecord (identifier) {
}
// 获取提交记录详情
-export async function fetchUserCommitRecordDetail () {
+export async function fetchUserCommitRecordDetail (identifier) {
const url = `/myproblems/record_detail.json`;
- return axios.get(url);
+ debugger;
+ const params = {id: identifier};
+ return axios.get(url, {params});
}
// 恢复初始代码
@@ -99,3 +101,9 @@ export async function fetchUserCodeSubmit (identifier) {
const url = `/myproblems/${identifier}/code_submit.json`;
return axios.get(url);
}
+
+// 恢复初始代码
+export async function fetchRestoreInitialCode (identifier) {
+ const url = `/myproblems/${identifier}/restore_initial_code.json`;
+ return axios.post(url);
+}