add commit pass score tip

dev_static
tangjiang 5 years ago
parent 30390ddfba
commit 54f6f124c6

@ -64,6 +64,7 @@ const types = {
CHANGE_RECORD_PAGINATION_PAGE: 'CHANGE_RECORD_PAGINATION_PAGE', // 改变提交分页
UPDATE_OJ_FOR_USER_COMMENT_COUNT: 'UPDATE_OJ_FOR_USER_COMMENT_COUNT', // 更新 hack 中的评论数,
UPDATE_NOTE_CONTENT: 'UPDATE_NOTE_CONTENT', // 更新笔记内容
UPDATE_HACK_PASSED: 'UPDATE_HACK_PASSED',
/*** jupyter */
GET_JUPYTER_DATA_SETS: 'GET_JUPYTER_DATA_SETS', // jupyter 数据集
GET_JUPYTER_TPI_URL: 'GET_JUPYTER_TPI_URL', // 获取 jupyter url

@ -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({

@ -4,11 +4,7 @@
* @Github:
* @Date: 2019-11-20 16:35:46
* @LastEditors : tangjiang
<<<<<<< HEAD
* @LastEditTime : 2020-01-07 15:27:22
=======
* @LastEditTime : 2020-01-03 17:39:32
>>>>>>> dev_aliyun
* @LastEditTime : 2020-01-07 16:45:34
*/
import types from './actionTypes';
import CONST from '../../constants';

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 13:41:48
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-02 14:24:09
* @LastEditTime : 2020-01-07 17:26:19
*/
import types from "../actions/actionTypes";
import { Base64 } from 'js-base64';
@ -228,6 +228,13 @@ const ojForUserReducer = (state = initialState, action) => {
...state,
hack: _hack1
}
// 修改 hack passed值
case types.UPDATE_HACK_PASSED:
const _hack2 = Object.assign({}, state.hack, {passed: action.payload });
return {
...state,
hack: _hack2
}
default:
return state;
}

Loading…
Cancel
Save