save oj init value

dev_jupyter
tangjiang 5 years ago
parent 0b45789cd5
commit 478caa7f7e

@ -67,9 +67,8 @@ const NewOrEditTask = (props) => {
props.getOJFormById(id); props.getOJFormById(id);
} else { } else {
// 清空store中的测试用例集合 // 清空store中的测试用例集合
props.clearOJFormStore(); // props.clearOJFormStore();
} }
return () => {} return () => {}
}, []); }, []);

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-20 10:35:40 * @Date: 2019-11-20 10:35:40
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2020-01-03 11:28:26 * @LastEditTime : 2020-01-03 17:35:45
*/ */
import './index.scss'; import './index.scss';
// import 'katex/dist/katex.css'; // import 'katex/dist/katex.css';
@ -179,9 +179,10 @@ class EditTab extends React.Component {
tag_discipline_id, tag_discipline_id,
knowledges knowledges
} = this.props; } = this.props;
console.log('knowledge======>>>>>>', knowledges); // console.log('knowledge======>>>>>>', knowledges);
// const {knowledges} = this.state; // const {knowledges} = this.state;
// 表单label // 表单label
// console.log('props=====>>>>', this.props);
const myLabel = (name, subTitle, nostar) => { const myLabel = (name, subTitle, nostar) => {
if (subTitle) { if (subTitle) {
return ( return (
@ -313,7 +314,7 @@ class EditTab extends React.Component {
// debugger; // debugger;
if (sub_id && t.children) { if (sub_id && t.children) {
t.children.forEach(c => { t.children.forEach(c => {
if (c.value === sub_id) { if (c.value === +sub_id) {
choid_ids = [t.value, c.value]; choid_ids = [t.value, c.value];
// tempKnowledges = c.children || []; // tempKnowledges = c.children || [];
} }

@ -20,7 +20,8 @@ import SingleEditor from "./component/SingleEditor";
import ChoquesEditor from "./component/ChoquesEditor" import ChoquesEditor from "./component/ChoquesEditor"
import JudquestionEditor from "./component/JudquestionEditor"; import JudquestionEditor from "./component/JudquestionEditor";
import Bottomsubmit from "../../modules/modals/Bottomsubmit"; import Bottomsubmit from "../../modules/modals/Bottomsubmit";
import { connect } from 'react-redux';
import actions from "../../redux/actions";
class Questionitem_banks extends Component { class Questionitem_banks extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
@ -93,7 +94,11 @@ class Questionitem_banks extends Component {
} }
// this.props.setOjInitialValue({
// difficult: 1,
// sub_discipline_id: '3',
// tag_discipline_id: [3, 4]
// });
let urls = `/disciplines.json`; let urls = `/disciplines.json`;
axios.get(urls, { axios.get(urls, {
params: { params: {
@ -565,7 +570,14 @@ class Questionitem_banks extends Component {
} }
const mapStateToProps = (state) => ({});
const mapDispatchToProps = (dispatch) => ({
setOjInitialValue: (params) => dispatch(actions.setOjInitialValue(params))
});
export default SnackbarHOC()(TPMIndexHOC(Questionitem_banks)); export default connect(
mapStateToProps,
mapDispatchToProps
)(SnackbarHOC()(TPMIndexHOC(Questionitem_banks)));

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-20 16:35:46 * @Date: 2019-11-20 16:35:46
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2020-01-03 16:40:54 * @LastEditTime : 2020-01-03 17:39:32
*/ */
import types from './actionTypes'; import types from './actionTypes';
import CONST from '../../constants'; import CONST from '../../constants';
@ -675,14 +675,31 @@ export const updateOpenTestCaseIndex = (value) => {
// 获取课程题库 // 获取课程题库
export const getQuestion = (params) => { export const getQuestion = (params) => {
return (dispatch) => { return (dispatch, getState) => {
fetchQuestion(params).then(res => { const {ojForm: {sub_discipline_id}} = getState().ojFormReducer;
fetchQuestion(params, ).then(res => {
const { data = {} } = res; const { data = {} } = res;
const { disciplines = [] } = data; const { disciplines = [] } = data;
dispatch({ dispatch({
type: types.GET_COURSE_QUESTION, type: types.GET_COURSE_QUESTION,
payload: disciplines payload: disciplines
}) });
let temp_knowledges = [];
// console.log('选择的课程: =====>>>>>>', sub_discipline_id);
disciplines.forEach(c => {
if (sub_discipline_id && c.sub_disciplines) {
c.sub_disciplines.forEach(sub => {
if (+sub.id === +sub_discipline_id) {
temp_knowledges = sub.tag_disciplines || [];
}
});
}
});
dispatch({
type: types.CHANGE_KNOWLEDGES,
payload: temp_knowledges
});
}) })
} }
} }

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-20 16:40:32 * @Date: 2019-11-20 16:40:32
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2020-01-03 16:39:09 * @LastEditTime : 2020-01-03 17:38:50
*/ */
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
import types from '../actions/actionTypes'; import types from '../actions/actionTypes';
@ -231,7 +231,7 @@ const ojFormReducer = (state = initialState, action) => {
courseQuestions.forEach(c => { courseQuestions.forEach(c => {
if (sub_discipline_id && c.sub_disciplines) { if (sub_discipline_id && c.sub_disciplines) {
c.sub_disciplines.forEach(sub => { c.sub_disciplines.forEach(sub => {
if (+sub.id === sub_discipline_id) { if (+sub.id === +sub_discipline_id) {
temp_knowledges = sub.tag_disciplines || []; temp_knowledges = sub.tag_disciplines || [];
} }
}); });

Loading…
Cancel
Save