-
+ {/*
{(mygetHelmetapi &&mygetHelmetapi.name) || ''}
-
+
*/}
+
乘积最大序列
-
@@ -70,7 +85,14 @@ const StudentStudy = (props) => {
)
}
-const mapStateToProps = (state) => ({});
+const mapStateToProps = (state) => {
+ const { userInfo } = state.userReducer;
+ const { hack_identifier } = state.ojForUserReducer;
+ return {
+ userInfo,
+ hack_identifier
+ };
+};
const mapDispatchToProps = (dispatch) => ({
// 调用开启编辑
diff --git a/public/react/src/modules/developer/studentStudy/index.scss b/public/react/src/modules/developer/studentStudy/index.scss
index 3b9868608..bbf66aebb 100644
--- a/public/react/src/modules/developer/studentStudy/index.scss
+++ b/public/react/src/modules/developer/studentStudy/index.scss
@@ -1,4 +1,7 @@
@import '../split_pane_resizer.scss';
+.split-pane-area{
+ height: calc(100vh - 65px);
+}
.right_pane_code_wrap{
position: relative;
diff --git a/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.scss b/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.scss
index d409b8cef..596e9abe7 100644
--- a/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.scss
+++ b/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.scss
@@ -1,5 +1,6 @@
.commit_record_area{
- padding: 20px 30px;
+ // padding: 20px 30px;
+ padding: 0 30px;
.record_header{
display: flex;
// justify-content: space-between;
diff --git a/public/react/src/modules/developer/studentStudy/leftpane/index.js b/public/react/src/modules/developer/studentStudy/leftpane/index.js
index f1327e006..69f49b9b1 100644
--- a/public/react/src/modules/developer/studentStudy/leftpane/index.js
+++ b/public/react/src/modules/developer/studentStudy/leftpane/index.js
@@ -4,10 +4,10 @@
* @Github:
* @Date: 2019-11-23 11:33:41
* @LastEditors: tangjiang
- * @LastEditTime: 2019-12-03 14:13:19
+ * @LastEditTime: 2019-12-09 19:57:21
// */
import './index.scss';
-import React, { useState, useEffect } from 'react';
+import React, { useState, useEffect, useMemo } from 'react';
import { Tabs, Divider } from 'antd';
import { connect } from 'react-redux';
import Comment from './comment';
@@ -15,13 +15,14 @@ import CommitRecord from './commitRecord';
import TaskDescription from './taskDescription';
import TextNumber from './../../components/textNumber';
import actions from '../../../../redux/actions';
-const { TabPane } = Tabs;
+// const { TabPane } = Tabs;
const LeftPane = (props) => {
const { hack, userCodeTab, changeUserCodeTab } = props;
const { pass_count, submit_count } = hack;
const [defaultActiveKey, setDefaultActiveKey] = useState('task');
+
console.log(pass_count, submit_count);
const tabArrs = [
{ title: '任务描述', key: 'task', content: (
) },
@@ -29,25 +30,58 @@ const LeftPane = (props) => {
// { title: '评论', key: 'comment', content: (
) },
];
+ const navItem = [
+ {
+ title: '任务描述',
+ key: 'task'
+ },
+ {
+ title: '提交记录',
+ key: 'record'
+ }
+ ];
+
+ const Comp = {
+ task: (
),
+ record: (
)
+ };
+
useEffect(() => {
setDefaultActiveKey(userCodeTab);
}, [userCodeTab])
- const tabs = tabArrs.map((tab) => {
- const Comp = tab.content;
+ // const tabs = tabArrs.map((tab) => {
+ // const Comp = tab.content;
+ // return (
+ //
+ // { Comp }
+ //
+ // )
+ // });
+
+ // // tab切换时
+ // const handleTabChange = (key) => {
+ // // setDefaultActiveKey(key);
+ // changeUserCodeTab(key);
+ // }
+
+ const renderComp = useMemo(() => {
+ return Comp[defaultActiveKey];
+ }, [defaultActiveKey]);
+
+ const renderNavItem = navItem.map((item) => {
+ const _classes = item.key === defaultActiveKey ? 'add_editor_item active' : 'add_editor_item';
return (
-
- { Comp }
-
+
setDefaultActiveKey(item.key)}
+ >
+ {item.title}
+
)
});
- // tab切换时
- const handleTabChange = (key) => {
- // setDefaultActiveKey(key);
- changeUserCodeTab(key);
- }
-
// 点击消息
const handleClickMessage = () => {
console.log('点击的消息图标---------');
@@ -65,9 +99,27 @@ const LeftPane = (props) => {
return (
-
+ {/*
{ tabs }
+ */}
+
+
+ { renderComp }
+
diff --git a/public/react/src/modules/developer/studentStudy/leftpane/index.scss b/public/react/src/modules/developer/studentStudy/leftpane/index.scss
index 19d2703c9..9e6f019f6 100644
--- a/public/react/src/modules/developer/studentStudy/leftpane/index.scss
+++ b/public/react/src/modules/developer/studentStudy/leftpane/index.scss
@@ -15,7 +15,8 @@
width: 100%;
// background: pink;
padding: 0 30px;
- background-color: rgba(250,250,250,1);
+ // background-color: rgba(250,250,250,1);
+ background: #fff;
.flex_count,
.flex_info{
@@ -28,18 +29,23 @@
}
}
-.task_description_area,
.commit_record_area{
padding: 0 30px;
- height: calc(100vh - 166px);
- overflow-y: auto;
+ // height: calc(100vh - 178px);
+ // overflow-y: auto;
}
.task_description_area{
+
+ .task_desc_area{
+ height: calc(100vh - 242px);
+ padding: 0 0 0 15px;
+ }
.desc_area_header{
display: flex;
justify-content: space-between;
align-items: center;
height: 64px;
+ padding: 0 30px;
.header_flex{
font-size: 14px;
.flex_label{
@@ -51,4 +57,26 @@
}
}
}
+}
+
+.student_study_header{
+ .study_quit{
+ position: absolute;
+ right: 30px;
+ }
+ .quit-btn{
+ cursor: pointer;
+ margin-left: 30px;
+ color: #888888;
+ transition: all .3s;
+ &:hover{
+ color: #5091FF;
+ }
+ // &:last-child{
+ // color: #888888;
+ // }
+ .quit-icon{
+ margin-right: 5px;
+ }
+ }
}
\ No newline at end of file
diff --git a/public/react/src/modules/developer/studentStudy/leftpane/taskDescription/index.js b/public/react/src/modules/developer/studentStudy/leftpane/taskDescription/index.js
index c2fc4c636..28fe51765 100644
--- a/public/react/src/modules/developer/studentStudy/leftpane/taskDescription/index.js
+++ b/public/react/src/modules/developer/studentStudy/leftpane/taskDescription/index.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 09:49:30
* @LastEditors: tangjiang
- * @LastEditTime: 2019-11-29 13:46:11
+ * @LastEditTime: 2019-12-09 19:21:55
*/
import '../index.scss';
import React from 'react';
@@ -39,12 +39,18 @@ const TaskDescription = (props) => {
{username}
-
+
+
+ {/*
+ style={{ backgroundColor: 'gold' }}
+ /> */}
{/* */}
)
diff --git a/public/react/src/modules/developer/studentStudy/rightpane/index.js b/public/react/src/modules/developer/studentStudy/rightpane/index.js
index 691f540e6..f1153ba17 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-06 18:48:52
+ * @LastEditTime: 2019-12-10 08:53:06
*/
import React, { useState, useEffect } from 'react';
import {connect} from 'react-redux';
@@ -49,7 +49,7 @@ const RightPane = (props) => {
timer = setInterval(() => {
clearInterval(timer);
timer = null;
- saveUserCodeForInterval(identifier, code);
+ saveUserCodeForInterval && saveUserCodeForInterval(identifier, code);
}, 3000);
}
// 保存用户代码块
diff --git a/public/react/src/redux/actions/actionTypes.js b/public/react/src/redux/actions/actionTypes.js
index 4850fc794..0f33b435c 100644
--- a/public/react/src/redux/actions/actionTypes.js
+++ b/public/react/src/redux/actions/actionTypes.js
@@ -48,6 +48,8 @@ const types = {
GET_COMMIT_RECORD_DETAIL_BY_ID: 'GET_COMMIT_RECORD_DETAIL_BY_ID', // 根据id号获取提交记录详情
RESTORE_INITIAL_CODE: 'RESTORE_INITIAL_CODE', // 恢复初始代码
SAVE_USER_INFO: 'SAVE_USER_INFO', // 只在用户信息
+ SAVE_HACK_IDENTIFIER: 'SAVE_HACK_IDENTIFIER', // 用户界面跑到编辑界面需要用的id值
+ SAVE_EDITOR_CODE: 'SAVE_EDITOR_CODE', // 保存详情页面中编辑时的代码
}
export default types;
diff --git a/public/react/src/redux/actions/index.js b/public/react/src/redux/actions/index.js
index 2e113032d..55ee1ab54 100644
--- a/public/react/src/redux/actions/index.js
+++ b/public/react/src/redux/actions/index.js
@@ -41,6 +41,8 @@ import {
getUserProgramDetail,
saveUserProgramIdentifier,
restoreInitialCode,
+ saveUserCodeForInterval,
+ saveEditorCodeForDetail,
// isUpdateCodeCtx
} from './ojForUser';
@@ -52,6 +54,10 @@ import {
isMyPublish,
} from './common';
+import {
+ getUserInfoForNew
+} from './user';
+
export default {
toggleTodo,
getOJList,
@@ -90,5 +96,8 @@ export default {
updateOpenTestCaseIndex,
saveUserProgramIdentifier,
restoreInitialCode,
+ getUserInfoForNew,
+ saveUserCodeForInterval,
+ saveEditorCodeForDetail
// 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 9b7d7ec87..2347e85f7 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-06 17:56:02
+ * @LastEditTime: 2019-12-10 10:11:50
*/
import types from "./actionTypes";
import { Base64 } from 'js-base64';
@@ -31,6 +31,11 @@ export const startProgramQuestion = (id, props) => {
type: types.SAVE_USER_PROGRAM_ID,
payload: identifier
});
+ // 保存id值
+ dispatch({
+ type: types.SAVE_HACK_IDENTIFIER,
+ payload: id
+ });
// 跳转至开启编程
if (identifier) {
// let data = Object.assign({}, props);
@@ -74,8 +79,13 @@ export const getUserProgramDetail = (identifier, type) => {
dispatch({
type: types.GET_COMMIT_RECORD_DETAIL_BY_ID,
payload: data
- })
+ });
}
+ // 保存用户登录信息
+ dispatch({
+ type: types.SAVE_USER_INFO,
+ payload: data.user
+ });
}
});
}
@@ -277,10 +287,12 @@ export const getUserCommitRecordDetail = (identifier) => {
return (dispatch) => {
fetchUserCommitRecordDetail(identifier).then(res => {
console.log('提交记录详情======》》》》', res);
+ const { data } = res;
+ if (data.status === 401) return;
dispatch({
type: types.GET_COMMIT_RECORD_DETAIL_BY_ID,
- payload: res.data
- })
+ payload: data
+ });
});
}
}
@@ -383,3 +395,10 @@ export const restoreInitialCode = (identifier) => {
}
}
+// 保存详情页面中的编辑代码
+export const saveEditorCodeForDetail = (code) => {
+ return {
+ type: types.SAVE_EDITOR_CODE,
+ payload: code
+ }
+}
diff --git a/public/react/src/redux/actions/ojForm.js b/public/react/src/redux/actions/ojForm.js
index a28a94b1f..0b9862c02 100644
--- a/public/react/src/redux/actions/ojForm.js
+++ b/public/react/src/redux/actions/ojForm.js
@@ -4,13 +4,13 @@
* @Github:
* @Date: 2019-11-20 16:35:46
* @LastEditors: tangjiang
- * @LastEditTime: 2019-12-06 20:24:11
+ * @LastEditTime: 2019-12-09 17:20:58
*/
import types from './actionTypes';
import CONST from '../../constants';
import { fetchPostOjForm, fetchGetOjById, publishTask } from '../../services/ojService';
import { Base64 } from 'js-base64';
-import { message, notification } from 'antd';
+import { message, notification, Modal } from 'antd';
import { toStore } from 'educoder';
const { jcLabel } = CONST;
// 表单字段映射
@@ -85,6 +85,7 @@ export const validateOjForm = (props, type) => {
return (dispatch, getState) => {
const {ojForm, testCases, identifier, code } = getState().ojFormReducer;
// console.log('code', code);
+ /** 表单验证开始 */
let keys = Object.keys(ojForm);
// 循环判断每个字段是否为空
let hasSuccess = true;
@@ -151,6 +152,8 @@ export const validateOjForm = (props, type) => {
payload: false
});
}
+ /** 表单验证结束 */
+ /** 表单验证通过后,调用保存 or 更新 or 发布 */
if (hasSuccess) {
// console.log('表单保存的数据为: ', getState());
const {ojFormReducer} = getState();
@@ -205,6 +208,7 @@ export const validateOjForm = (props, type) => {
paramsObj['identifier'] = identifier;
}
+ // 接口调用成功后,跳转至列表页
function linkToDev () {
toStore('oj_description', '');
dispatch({
@@ -216,51 +220,61 @@ export const validateOjForm = (props, type) => {
}, 1000);
}
- fetchPostOjForm(paramsObj).then(res => {
- // TODO
- if (res.status === 200) { // 保存成功后,重新跳转至列表页
- const {identifier} = res.data
- if (type === 'publish') { // 存在发布时,直接调用发布接口
- if (identifier) {
- 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
- });
+ // 调用保存或更新
+ 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
});
- } else {
+ }).catch(() => {
dispatch({
type: types.PUBLISH_LOADING_STATUS,
payload: false
});
- }
- } else {
+ });
+ },
+ onCancel () {
+ dispatch({
+ type: types.PUBLISH_LOADING_STATUS,
+ payload: false
+ });
+ }
+ });
+ } else {
+ // 调用更新
+ fetchPostOjForm(paramsObj).then(res => {
+ if (res.status === 200) { // 保存成功后,重新跳转至列表页
if (res.data.identifier) {
message.success('保存成功!');
linkToDev();
}
+ dispatch({
+ type: types.SUBMIT_LOADING_STATUS,
+ payload: false
+ });
+ }
+ }).catch(err => {
dispatch({
type: types.SUBMIT_LOADING_STATUS,
payload: false
});
}
- }
-
- }).catch(err => {
- dispatch({
- type: types.SUBMIT_LOADING_STATUS,
- payload: false
- });
- });
+ );
+ }
}
}
};
@@ -361,6 +375,11 @@ export const getOJFormById = (id) => {
type: types.SAVE_EDIT_OJ_FORM_AND_TEST_CASE,
payload: res.data
});
+ // 保存用户信息
+ dispatch({
+ type: types.SAVE_USER_INFO,
+ payload: res.data.user
+ });
});
}
}
@@ -371,7 +390,7 @@ export const saveOJFormId = (id) => {
payload: id
}
}
-// 清空测试用例集合
+// 清空值
export const clearOJFormStore = () => {
return {
type: types.CLEAR_JSFORM_STORE
diff --git a/public/react/src/redux/actions/user.js b/public/react/src/redux/actions/user.js
index 1b7c331c6..f7a0706e3 100644
--- a/public/react/src/redux/actions/user.js
+++ b/public/react/src/redux/actions/user.js
@@ -4,13 +4,24 @@
* @Github:
* @Date: 2019-12-06 15:09:22
* @LastEditors: tangjiang
- * @LastEditTime: 2019-12-06 15:15:00
+ * @LastEditTime: 2019-12-09 20:34:50
*/
import types from './actionTypes';
+import { fetchUserInfoForNew } from '../../services/ojService';
+
// 获取用户信息
-export default function getUserInfo () {
+export const getUserInfoForNew = () => {
return (dispatch) => {
// 调用获取用户信息, 如果没有登录直接调用登录,成功后保存当前用户信息
+ fetchUserInfoForNew().then(res => {
+ // console.log('获取用户信息成功: ', res);
+ const { data } = res;
+ if (data.status === 401) return;
+ dispatch({
+ type: types.SAVE_USER_INFO,
+ payload: data.user
+ });
+ })
}
}
\ No newline at end of file
diff --git a/public/react/src/redux/reducers/ojForUserReducer.js b/public/react/src/redux/reducers/ojForUserReducer.js
index f734fea06..6520f8954 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-05 13:37:17
+ * @LastEditTime: 2019-12-10 10:09:59
*/
import types from "../actions/actionTypes";
import { Base64 } from 'js-base64';
@@ -20,6 +20,8 @@ const initialState = {
userCodeTab: 'task', // 学员测评tab位置: task | record | comment
userTestInput: '', // 用户自定义输入值
recordDetail: {}, // 根据id号获取的记录详情
+ hack_identifier: '', // 用户界面编辑时
+ editor_code: '' // 保存编辑代码
};
const ojForUserReducer = (state = initialState, action) => {
@@ -109,6 +111,16 @@ const ojForUserReducer = (state = initialState, action) => {
...state,
hack: Object.assign({}, curHack)
}
+ case types.SAVE_HACK_IDENTIFIER:
+ return {
+ ...state,
+ hack_identifier: action.payload
+ }
+ case types.SAVE_EDITOR_CODE:
+ return {
+ ...state,
+ editor_code: action.payload
+ }
default:
return state;
}
diff --git a/public/react/src/redux/reducers/ojFormReducer.js b/public/react/src/redux/reducers/ojFormReducer.js
index dab218cb7..ce89bce9a 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-05 09:35:29
+ * @LastEditTime: 2019-12-09 16:30:46
*/
import { Base64 } from 'js-base64';
import types from '../actions/actionTypes';
@@ -16,8 +16,8 @@ const init = {
description: '',
difficult: 1,
category: 1,
- openOrNot: 1,
- timeLimit: ''
+ // openOrNot: 1,
+ timeLimit: 3
},
ojFormValidate: {
name: {
@@ -40,10 +40,10 @@ const init = {
validateStatus: '',
errMsg: ''
},
- openOrNot: {
- validateStatus: '',
- errMsg: ''
- },
+ // openOrNot: {
+ // validateStatus: '',
+ // errMsg: ''
+ // },
timeLimit: {
validateStatus: '',
errMsg: ''
@@ -64,7 +64,8 @@ const init = {
identifier: '', // OJ表单id
loading: false, // 僵尸loading标志
testCodeStatus: 'default', // 调试代码状态 default(默认值) | loading(加载中) | loaded(加载完成) | userCase(用户自定义测试用例) | finish(测试完成)
- openTestCodeIndex: [0] // 展开的测试用例: 数组, 当出错时,展开所有出错的测试用例, 默认展开第一个
+ openTestCodeIndex: [0], // 展开的测试用例: 数组, 当出错时,展开所有出错的测试用例, 默认展开第一个
+ isPublish: 0, // 是否是发布状态: 0 未发布 1 已发布
}
const tcValidateObj = {
@@ -167,7 +168,7 @@ const ojFormReducer = (state = initialState, action) => {
* 6. 更改测试用例状态
* 7. 添加测试用例验证
*/
- const { code = '', description, language, name, hack_sets = [], time_limit, difficult, category } = action.payload;
+ const { code = '', description, language, name, hack_sets = [], time_limit, difficult, category, status } = action.payload;
const currentOjForm = {
name, // 任务名称
language,
@@ -203,7 +204,8 @@ const ojFormReducer = (state = initialState, action) => {
code: cbcode,
testCases: curTestCases,
testCasesValidate: curTcValidates,
- testCodeStatus: hack_sets.length > 0 ? 'userCase' : 'default'
+ testCodeStatus: hack_sets.length > 0 ? 'userCase' : 'default',
+ isPublish: status
}
case types.CLEAR_JSFORM_STORE:
state = Object.assign({}, init);
diff --git a/public/react/src/services/ojService.js b/public/react/src/services/ojService.js
index 9c49073f3..6c5398b4b 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-04 18:05:10
+ * @LastEditTime: 2019-12-09 14:17:39
*/
import axios from 'axios';
@@ -106,3 +106,9 @@ export async function fetchRestoreInitialCode (identifier) {
const url = `/myproblems/${identifier}/restore_initial_code.json`;
return axios.post(url);
}
+
+// 新建时调用获取用户信息接口
+export async function fetchUserInfoForNew () {
+ const url = `/problems/new.json`;
+ return axios.get(url);
+}