diff --git a/app/services/users/shixun_service.rb b/app/services/users/shixun_service.rb
index 9460d3a88..aeaac6a2c 100644
--- a/app/services/users/shixun_service.rb
+++ b/app/services/users/shixun_service.rb
@@ -41,8 +41,6 @@ class Users::ShixunService
def user_policy_filter(relations)
# 只有自己或者管理员才有过滤筛选及查看全部状态下实训功能
- Rails.logger.info("self_or_admin?: #{self_or_admin?}")
- Rails.logger.info("user: #{user.id}")
if self_or_admin?
relations = relations.where.not(status: -1)
status_filter(relations)
diff --git a/public/react/src/modules/developer/DeveloperHome.js b/public/react/src/modules/developer/DeveloperHome.js
index 9746fe4cc..646e21704 100644
--- a/public/react/src/modules/developer/DeveloperHome.js
+++ b/public/react/src/modules/developer/DeveloperHome.js
@@ -15,6 +15,7 @@ import actions from '../../redux/actions';
import MultipTags from './components/multiptags';
import { Link } from 'react-router-dom';
import CONST from '../../constants';
+import { withRouter } from 'react-router';
const {tagBackground, diffText} = CONST;
const { Search } = Input;
@@ -96,66 +97,67 @@ const testMaps = {
}
}
-/**
- * 表格列
- */
-const options = {
- title: '操作',
- key: 'action',
- fixed: 'right',
- width: 100,
- render: (text, record) => (
-
-
-
- ),
-}
-const columns = [
- {
- title: '标题',
- dataIndex: 'name',
- render: (name, record) => {name}
- },
- {
- title: '分类',
- dataIndex: 'category',
- width: '20%',
- align: 'center',
- render: (category) => {category ? testMaps['category'][+category] : '-'}
- },
- {
- title: '难度',
- dataIndex: 'difficult',
- align: 'center',
- width: '15%',
- render: (difficult) => {
- if (difficult) {
- return {diffText[+difficult]}
- } else {
- return '-';
+class DeveloperHome extends React.PureComponent {
+ /**
+ * 表格列
+ */
+ options = {
+ title: '操作',
+ key: 'action',
+ fixed: 'right',
+ width: 100,
+ render: (text, record) => (
+
+
+
+ ),
+ }
+
+ columns = [
+ {
+ title: '标题',
+ dataIndex: 'name',
+ render: (name, record) =>
+ },
+ {
+ title: '分类',
+ dataIndex: 'category',
+ width: '20%',
+ align: 'center',
+ render: (category) => {category ? testMaps['category'][+category] : '-'}
+ },
+ {
+ title: '难度',
+ dataIndex: 'difficult',
+ align: 'center',
+ width: '15%',
+ render: (difficult) => {
+ if (difficult) {
+ return {diffText[+difficult]}
+ } else {
+ return '-';
+ }
}
- }
- },
- {
- title: '热度',
- dataIndex: 'hack_user_lastest_codes_count',
- sorter: true,
- align: 'center',
- width: '10%'
- },
- {
- title: '通过率',
- dataIndex: 'passed_rate',
- sorter: true,
- align:'right',
- width: '10%',
- render: val => {`${val}%`}
- },
-];
+ },
+ {
+ title: '热度',
+ dataIndex: 'hack_user_lastest_codes_count',
+ sorter: true,
+ align: 'center',
+ width: '10%'
+ },
+ {
+ title: '通过率',
+ dataIndex: 'passed_rate',
+ sorter: true,
+ align:'right',
+ width: '10%',
+ render: val => {`${val}%`}
+ },
+ ];
-class DeveloperHome extends React.PureComponent {
state = {
data: [],
loading: false,
@@ -170,7 +172,7 @@ class DeveloperHome extends React.PureComponent {
page: 1, // 当前页数
limit: 10 // 每页显示条件
},
- columns: columns,
+ columns: this.columns,
searchInfo: []
};
@@ -179,7 +181,7 @@ class DeveloperHome extends React.PureComponent {
const { isMySource } = this.props;
if (isMySource) {
this.handleFilterSearch({come_from: 'mine'});
- let _columns = columns.concat([options]);
+ let _columns = this.columns.concat([this.options]);
this.setState({
columns: _columns
});
@@ -309,13 +311,13 @@ class DeveloperHome extends React.PureComponent {
this.handleFilterSearch({come_from: item.key === 'all' ? '' : item.key});
if (item.key !== 'all') {
- let _columns = columns.concat([options]);
+ let _columns = this.columns.concat([this.options]);
this.setState({
columns: _columns
});
} else {
this.setState({
- columns: columns
+ columns: this.columns
})
}
}
@@ -333,10 +335,19 @@ class DeveloperHome extends React.PureComponent {
});
if (info.type === 'come_from' && info.key === 'mine') {
this.setState({
- columns: columns
+ columns: this.columns
});
}
}
+
+ // 点击name
+
+ handleNameClick = (record) => {
+ console.log('name has click', record);
+ // 先调用start接口获取返回的 identifier, 再跳转到开启编辑
+ this.props.startProgramQuestion(record.identifier, this.props);
+ }
+
render () {
// const { testReducer, handleClick } = this.props;
const {
@@ -453,10 +464,11 @@ const mapDispatchToProps = (dispatch) => ({
handleClick: () => dispatch(actions.toggleTodo()),
fetchOJList: (params) => dispatch(actions.getOJList(params)),
changePaginationInfo: (obj) => dispatch(actions.changePaginationInfo(obj)),
+ startProgramQuestion: (id, props) => dispatch(actions.startProgramQuestion(id, props))
});
-export default connect(
+export default withRouter(connect(
mapStateToProps,
mapDispatchToProps
-)(DeveloperHome);
+)(DeveloperHome));
// export default DeveloperHome;
diff --git a/public/react/src/modules/developer/index.scss b/public/react/src/modules/developer/index.scss
index 6b10550b1..8c9b141b0 100644
--- a/public/react/src/modules/developer/index.scss
+++ b/public/react/src/modules/developer/index.scss
@@ -72,4 +72,8 @@
color: #fff;
}
}
+ .oj_item_name{
+ color: #459be5;
+ cursor: pointer;
+ }
}
diff --git a/public/react/src/modules/developer/quillEditor/index.js b/public/react/src/modules/developer/quillEditor/index.js
index da8fda7d1..57fd9f2a4 100644
--- a/public/react/src/modules/developer/quillEditor/index.js
+++ b/public/react/src/modules/developer/quillEditor/index.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-25 09:46:03
* @LastEditors: tangjiang
- * @LastEditTime: 2019-11-29 14:45:27
+ * @LastEditTime: 2019-11-29 15:04:12
*/
import 'quill/dist/quill.core.css';
import 'quill/dist/quill.bubble.css';
diff --git a/public/react/src/modules/developer/studentStudy/index.js b/public/react/src/modules/developer/studentStudy/index.js
index e0eccf444..d3c11df91 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-11-29 08:56:18
+ * @LastEditTime: 2019-11-29 20:00:34
*/
import './index.scss';
import React, { useEffect } from 'react';
@@ -20,9 +20,10 @@ import actions from '../../../redux/actions';
const StudentStudy = (props) => {
useEffect(() => {
- const { match: { params }, startProgramQuestion } = props;
+ const { match: { params }, getUserProgramDetail } = props;
let { id } = params;
- startProgramQuestion(id);
+ // startProgramQuestion(id);
+ getUserProgramDetail(id);
}, []);
return (
@@ -61,7 +62,9 @@ const mapStateToProps = (state) => ({});
const mapDispatchToProps = (dispatch) => ({
// 调用开启编辑
- startProgramQuestion: (id) => dispatch(actions.startProgramQuestion(id))
+ // startProgramQuestion: (id) => dispatch(actions.startProgramQuestion(id))
+ // 调用编程题详情
+ getUserProgramDetail: (id) => dispatch(actions.getUserProgramDetail(id))
});
export default connect(
diff --git a/public/react/src/modules/page/component/TPICodeMirror.js b/public/react/src/modules/page/component/TPICodeMirror.js
index 86f705478..9bfb714d4 100644
--- a/public/react/src/modules/page/component/TPICodeMirror.js
+++ b/public/react/src/modules/page/component/TPICodeMirror.js
@@ -33,13 +33,15 @@ function getModeByMirrorName(mirror_name) {
return mode;
}
const _extraKeys = {"Alt-/": "autocomplete"};
-function createCMOptions(mirror_name) {
+function createCMOptions(mirror_name, theme) {
let mode = getModeByMirrorName(mirror_name)
let cmOptions = {
lineNumbers: true,
mode: mode,
- theme: "railscasts",
+ // theme: "railscasts",
+ // theme: "vs-dark",
+ theme: theme,
indentUnit:4,
matchBrackets: true,
autoRefresh: true,
@@ -97,6 +99,7 @@ class TPICodeMirror extends Component {
super(props)
this.state = {
cmFontSize: fromStore('cmFontSize', 16),
+ cmCodeMode: fromStore('cmCodeMode', 'vs-dark'),
autoCompleteSwitch: fromStore('autoCompleteSwitch', true),
}
}
@@ -114,7 +117,7 @@ class TPICodeMirror extends Component {
}
}
componentDidMount() {
- let cmOptions = createCMOptions(this.props.mirror_name)
+ let cmOptions = createCMOptions(this.props.mirror_name, this.state.cmCodeMode)
extend_editor = window.CodeMirror.fromTextArea(window.$('#extend-challenge-file-edit')[0]
, cmOptions);
@@ -241,6 +244,12 @@ class TPICodeMirror extends Component {
this.setState({ cmFontSize: value });
}
+ onCodeModeChange = (value) => {
+ toStore('cmCodeMode', value);
+ this.setState({ cmCodeMode: value });
+ window.monaco.editor.setTheme(value);
+ }
+
render() {
const { repositoryCode, showSettingDrawer, settingDrawerOpen } = this.props;
const { cmFontSize } = this.state;
@@ -259,6 +268,7 @@ class TPICodeMirror extends Component {
>
diff --git a/public/react/src/modules/page/component/TPICodeSetting.js b/public/react/src/modules/page/component/TPICodeSetting.js
index 51a9f390c..10ed976ae 100644
--- a/public/react/src/modules/page/component/TPICodeSetting.js
+++ b/public/react/src/modules/page/component/TPICodeSetting.js
@@ -18,12 +18,12 @@ class TPICodeSetting extends Component {
render() {
const { autoCompleteSwitch, onAutoCompleteSwitchChange, onFontSizeChange
- , cmFontSize,
+ , cmFontSize, cmCodeMode,
+ onCodeModeChange,
shixun } = this.props;
const task_pass = shixun.task_pass
const forbid_copy = shixun.forbid_copy
const test_set_permission = shixun.test_set_permission
-
return (