|
|
|
@ -4,7 +4,7 @@
|
|
|
|
|
* @Github:
|
|
|
|
|
* @Date: 2019-11-27 13:42:11
|
|
|
|
|
* @LastEditors : tangjiang
|
|
|
|
|
* @LastEditTime : 2020-01-07 16:21:53
|
|
|
|
|
* @LastEditTime : 2020-01-07 17:27:40
|
|
|
|
|
*/
|
|
|
|
|
import types from "./actionTypes";
|
|
|
|
|
import { Base64 } from 'js-base64';
|
|
|
|
@ -179,7 +179,7 @@ export const updateCode = (identifier, inputValue, type) => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 代码评测
|
|
|
|
|
export const codeEvaluate = (dispatch, identifier, type, time_limit) => {
|
|
|
|
|
export const codeEvaluate = (dispatch, identifier, type, time_limit, hackStatus, score, passed) => {
|
|
|
|
|
// 调试代码成功后,调用轮循接口, 注意: 代码执行的时间要小于设置的时间限制
|
|
|
|
|
const intervalTime = 500;
|
|
|
|
|
let count = 1;
|
|
|
|
@ -219,7 +219,7 @@ export const codeEvaluate = (dispatch, identifier, type, time_limit) => {
|
|
|
|
|
type,
|
|
|
|
|
data: returnData
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
if (!type || type === 'debug') {
|
|
|
|
|
dispatch({ // 改变 loading 值
|
|
|
|
|
type: types.LOADING_STATUS,
|
|
|
|
@ -244,6 +244,18 @@ export const codeEvaluate = (dispatch, identifier, type, time_limit) => {
|
|
|
|
|
// 重新调用一下提交记录接口
|
|
|
|
|
dispatch(getUserCommitRecord(identifier));
|
|
|
|
|
dispatch(saveOpacityType(type));
|
|
|
|
|
// 首次通过时,提示评测通过并获得金币
|
|
|
|
|
// console.log('hack status ===>>', hackStatus);
|
|
|
|
|
if (hackStatus === 1 && !passed) {
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.UPDATE_HACK_PASSED,
|
|
|
|
|
payload: true
|
|
|
|
|
});
|
|
|
|
|
notification.success({
|
|
|
|
|
message: '提示',
|
|
|
|
|
description: `恭喜您获得金币奖励: ${score}`
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}).catch(err => { // 评测异常时
|
|
|
|
@ -281,7 +293,7 @@ export const debuggerCode = (identifier,value, type) => {
|
|
|
|
|
// 调用之前 先保存 code
|
|
|
|
|
// TODO
|
|
|
|
|
// console.log(identifier, value);
|
|
|
|
|
const {hack: {time_limit = 0}} = getState().ojForUserReducer;
|
|
|
|
|
const { hack } = getState().ojForUserReducer;
|
|
|
|
|
if (!type || type === 'debug') {
|
|
|
|
|
dispatch({ // 加载中...
|
|
|
|
|
type: types.TEST_CODE_STATUS,
|
|
|
|
@ -301,7 +313,7 @@ export const debuggerCode = (identifier,value, type) => {
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
// 测评
|
|
|
|
|
codeEvaluate(dispatch, identifier, type, time_limit);
|
|
|
|
|
codeEvaluate(dispatch, identifier, type, hack.time_limit);
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
dispatch({
|
|
|
|
@ -387,7 +399,7 @@ export const changeUserCodeTab = (key) => {
|
|
|
|
|
*/
|
|
|
|
|
export const submitUserCode = (identifier, inputValue, type) => {
|
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
|
const { userCode, isUpdateCode, hack: {time_limit = 0} } = getState().ojForUserReducer;
|
|
|
|
|
const { userCode, isUpdateCode, hack} = getState().ojForUserReducer;
|
|
|
|
|
|
|
|
|
|
function userCodeSubmit () {
|
|
|
|
|
fetchUserCodeSubmit(identifier).then(res => {
|
|
|
|
@ -401,7 +413,8 @@ export const submitUserCode = (identifier, inputValue, type) => {
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
// 测评
|
|
|
|
|
codeEvaluate(dispatch, identifier, type, time_limit);
|
|
|
|
|
console.log('hack=====', hack);
|
|
|
|
|
codeEvaluate(dispatch, identifier, type, hack.time_limit, hack.status, hack.score, hack.passed);
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
dispatch({
|
|
|
|
|