Merge branch 'dev_tj' into dev_aliyun

merge oj
dev_static
tangjiang 5 years ago
commit 36aab91c45

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-12-17 17:32:55
* @LastEditors : tangjiang
* @LastEditTime : 2019-12-27 16:50:43
* @LastEditTime : 2020-01-06 18:42:09
*/
import './index.scss';
import React, { useState } from 'react';
@ -28,11 +28,12 @@ function CommentForm (props) {
const [focus, setFocus] = useState(false);
const options = [
['bold', 'italic', 'underline'],
[{header: [1,2,3,false]}],
['blockquote', 'code-block'],
['link', 'image'],
['formula']
// ['bold', 'italic', 'underline'],
// [{header: [1,2,3,false]}],
'code-block',
'link',
'image',
'formula'
];
// const { form: { getFieldDecorator } } = props;
const [showQuill, setShowQuill] = useState(false);

@ -1,4 +1,6 @@
.quill_editor_for_react_area{
// background: #fff;
// margin: 0 15px;
.ql-editing{
left: 0 !important;
}

@ -4,11 +4,11 @@
* @Github:
* @Date: 2019-12-30 13:51:19
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-03 18:56:36
* @LastEditTime : 2020-01-07 15:04:51
*/
import './index.scss';
import React, { useState, useEffect } from 'react';
import { Select, notification } from 'antd';
import { Select, notification, Modal, Form, Input, Button } from 'antd';
const { Option } = Select;
@ -17,7 +17,10 @@ function KnowLedge (props) {
const {
options = [], // 下拉选项
values = [], // 已选择的下拉项
onChange // 获取选择的值
onChange, // 获取选择的值
form,
showAdd, // 显示新增图标
addKnowledge // 调用新增知识点接口
} = props;
useEffect(() => {
@ -38,9 +41,12 @@ function KnowLedge (props) {
const [selectOptions, setSelectOptions] = useState(options);
// 已选择的下拉项
const [selectValue, setSelectValue] = useState([]);
const [visible, setVisible] = useState(false);
//
const [value] = useState([]);
const { getFieldDecorator } = form;
const FormItem = Form.Item;
// 渲染下拉选项
const renderOptions = (options = []) => {
return options.map((opt, i) => (
@ -114,15 +120,75 @@ function KnowLedge (props) {
)
}
// 添加知识点
const handleAddKnowledge = () => {
setVisible(true);
};
const handleResetForm = () => {
form.resetFields();
setVisible(false);
}
const handleSubmitForm = (e) => {
e.preventDefault();
form.validateFieldsAndScroll((err, values) => {
if (err) {
return;
}
setVisible(false);
form.resetFields();
// console.log(values);
addKnowledge && addKnowledge(values);
})
}
const _styles = {
display: showAdd ? 'inline-block' : 'none'
};
return (
<div className="knowledge-select-area">
{ renderSelect(selectOptions) }
{/* 渲染下拉选择项 */}
<div className="knowledge-result">
{ renderResult(selectValue) }
<React.Fragment>
<div className="knowledge-select-area">
{ renderSelect(selectOptions) }
{/* 渲染下拉选择项 */}
<div className="knowledge-result">
<i
style={_styles}
className="iconfont icon-roundaddfill icon-add-knowledge"
onClick={handleAddKnowledge}
></i>
{ renderResult(selectValue) }
</div>
</div>
</div>
<Modal
closable={false}
title="新增知识点"
visible={visible}
footer={null}
>
<Form className="knowledge-form">
<FormItem>
{
getFieldDecorator('name', {
rules: [{
required: true, message: '知识点名称不能为空'
}]
})(
<Input />
)
}
</FormItem>
<FormItem style={{ textAlign: 'center' }}>
<Button style={{ marginRight: '20px' }} onClick={handleResetForm}>取消</Button>
<Button type="primary" onClick={handleSubmitForm}>确定</Button>
</FormItem>
</Form>
</Modal>
</React.Fragment>
);
}
export default KnowLedge;
export default Form.create()(KnowLedge);

@ -38,5 +38,19 @@
}
}
}
.icon-add-knowledge{
line-height: 36px;
margin-top: 10px;
margin-right: 10px;
// cursor: ;
color: rgb(78, 188, 126)
}
}
}
.knowledge-form{
.ant-form-explain{
padding: 0;
}
}

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 10:35:40
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-06 16:17:22
* @LastEditTime : 2020-01-07 15:29:18
*/
import './index.scss';
// import 'katex/dist/katex.css';
@ -61,6 +61,7 @@ class EditTab extends React.Component {
top: 500,
bottom: 20,
offsetTop: 0,
showAdd: false
// knowledges: [],
// coursers: [] // 选中的课程
}
@ -147,13 +148,15 @@ class EditTab extends React.Component {
item.sub_disciplines && item.sub_disciplines.forEach(c => {
if (value[1] && c.id === value[1]) {
saveKnowledge(c.tag_disciplines)
console.log(c.tag_disciplines);
} else if (!value[1]) {
saveKnowledge([]);
}
});
}
});
this.setState({
showAdd: value[1] ? true : false
});
// this.props.validateOjCategory(value[1] || '');
this.props.validateOjSubDisciplineId(value[1] || '');
}
@ -167,6 +170,8 @@ class EditTab extends React.Component {
}
render () {
const { showAdd } = this.state;
const {
ojForm,
ojFormValidate,
@ -177,9 +182,10 @@ class EditTab extends React.Component {
openTestCodeIndex = [],
courseQuestions,
tag_discipline_id,
knowledges
knowledges,
tagDisciplines,
} = this.props;
console.log('knowledge======>>>>>>', knowledges);
// console.log('knowledge======>>>>>>', knowledges);
// const {knowledges} = this.state;
// 表单label
const myLabel = (name, subTitle, nostar) => {
@ -321,7 +327,6 @@ class EditTab extends React.Component {
}
});
console.log(choid_ids);
return (
<Cascader
placeholder="请选择"
@ -340,11 +345,20 @@ class EditTab extends React.Component {
values.forEach(v => {
_result.push(v.id);
});
console.log('下拉选择的值:===>>>', _result);
// console.log('下拉选择的值:===>>>', _result);
// 保存选择的知识点
this.props.saveTagDisciplineId(_result);
}
// 新增知识点
const handleAddKnowledge = (values) => {
// console.log('调用了新增知识点并返回了结果: ', values);
// 获取课程id
const {sub_discipline_id} = this.props.ojForm;
const obj = Object.assign({}, values, {sub_discipline_id})
tagDisciplines(obj);
}
return (
<div className={'editor_area'} id="textCase">
<Form className={'editor_form'}>
@ -384,9 +398,11 @@ class EditTab extends React.Component {
label={<span>{myLabel(jcLabel['knowledge'], '', 'nostar')}</span>}
>
<KnowLedge
showAdd={showAdd}
options={knowledges}
values={tag_discipline_id}
onChange={handleKnowledgeChange}
addKnowledge={handleAddKnowledge}
/>
</FormItem>
@ -514,7 +530,8 @@ const mapDispatchToProps = (dispatch) => ({
addTestCase: (value) => dispatch(actions.addTestCase(value)),
// 删除测试用例
deleteTestCase: (value) => dispatch(actions.deleteTestCase(value)),
saveKnowledge: (value) => dispatch(actions.saveKnowledge(value))
saveKnowledge: (value) => dispatch(actions.saveKnowledge(value)),
tagDisciplines: (params) => dispatch(actions.tagDisciplines(params))
// 获取题库
// getQuestion: (params) => dispatch(actions.getQuestion(params))
});

@ -3,7 +3,7 @@
flex-direction: column;
justify-content: space-between;
background: #fff;
padding: 20px 30px 0;
padding: 0px 20px 0;
height: calc(100vh - 177px);
box-sizing: border-box;
overflow-y: auto;

@ -53,6 +53,7 @@
.commit_record_area{
padding: 0 20px;
background: #fff;
// height: calc(100vh - 178px);
}
.task_description_area{
@ -61,7 +62,8 @@
.task_desc_area{
height: calc(100vh - 242px);
overflow-y: auto;
padding: 0 0 0 15px;
// padding: 0 0 0 15px;
background: #fff;
}
.desc_area_header{
display: flex;
@ -69,14 +71,20 @@
align-items: center;
height: 64px;
padding: 0 20px;
background: #fff;
box-sizing: border-box;
border-bottom: 1px solid #f4f4f4;
.header_flex{
font-size: 14px;
.flex_label{
color: #999999;
color: #888888;
margin-right: 10px;
}
.flex_value{
font-weight: bold;
font-weight: 500;
color: #333;
// color: green;
}
}
}

@ -278,6 +278,8 @@ class VNCContainer extends Component {
.vncDrawer .ant-drawer-body {
padding: 0px;
}
.vncDrawer .rc-tree {
padding: 16px;
max-width: 220px;
@ -286,6 +288,7 @@ class VNCContainer extends Component {
.vncDrawer .ant-drawer-wrapper-body {
background: #242324;
height: 100%;
}
.codeInDrawer .ant-drawer-wrapper-body {
background: #1D1C1D;
@ -294,6 +297,10 @@ class VNCContainer extends Component {
.vncDrawer .ant-drawer-header, .codeInDrawer .ant-drawer-header {
border-bottom: 0;
}
.codeInDrawer .ant-drawer-header,
.codeInDrawer .ant-drawer-content{
background: rgb(28, 28, 28) !important;
}
.vncDrawer > div:nth-child(1) {
opacity: 1 !important;

@ -36,7 +36,8 @@ import {
handleClickCancelPublish,
getQuestion,
saveKnowledge,
setOjInitialValue
setOjInitialValue,
tagDisciplines
} from './ojForm';
import {
@ -125,6 +126,7 @@ export default {
getQuestion,
saveKnowledge,
setOjInitialValue,
tagDisciplines,
//
addTestCase,
deleteTestCase,

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 13:42:11
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-02 14:17:49
* @LastEditTime : 2020-01-07 14:45:52
*/
import types from "./actionTypes";
import { Base64 } from 'js-base64';
@ -18,7 +18,7 @@ import {
fetchUpdateCode,
fetchUserCodeSubmit,
fetchRestoreInitialCode,
fetchAddNotes
fetchAddNotes,
} from "../../services/ojService";
import { notification } from "antd";
@ -523,4 +523,4 @@ export const addNotes = (identifier, params, cb) => {
});
})
}
}
}

@ -4,7 +4,11 @@
* @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
*/
import types from './actionTypes';
import CONST from '../../constants';
@ -13,7 +17,8 @@ import {
fetchGetOjById,
publishTask,
cancelPublicTask,
fetchQuestion
fetchQuestion,
fetchTagDisciplines
} from '../../services/ojService';
import { Base64 } from 'js-base64';
import { notification } from 'antd';
@ -677,30 +682,46 @@ export const updateOpenTestCaseIndex = (value) => {
export const getQuestion = (params) => {
return (dispatch, getState) => {
const {ojForm: {sub_discipline_id}} = getState().ojFormReducer;
fetchQuestion(params, ).then(res => {
fetchQuestion(params).then(res => {
const { data = {} } = res;
const { disciplines = [] } = data;
dispatch({
type: types.GET_COURSE_QUESTION,
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
});
})
// 如果课程id号存在 同步更新知识点
if (sub_discipline_id) {
let temp_knowledges = [];
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
})
}
// 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
// });
});
}
}
@ -727,3 +748,22 @@ export const setOjInitialValue = (params) => {
payload: params
}
}
// 新增知识点
export const tagDisciplines = (params) => {
return (dispatch) => {
fetchTagDisciplines(params).then(res => {
// console.log('新增知识点成功======>>>>', res);
if (res.data.status === 0) {
notification.success({
message: '提示',
description: '新增知识点成功'
});
// 重新调用获取课程列表接口
dispatch(getQuestion({
source: 'question'
}));
}
});
}
}

@ -3,8 +3,8 @@
* @Author: tangjiang
* @Github:
* @Date: 2019-11-27 16:27:09
* @LastEditors: tangjiang
* @LastEditTime: 2019-12-12 17:36:51
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-07 15:23:39
*/
import types from "../actions/actionTypes";
@ -22,7 +22,7 @@ const initialState = {
}
const commonReducer = (state = initialState, action) => {
console.log(action)
// console.log(action)
switch (action.type) {
case types.SHOW_OR_HIDE_CONTROL:
return {

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 10:55:38
* @LastEditors : tangjiang
* @LastEditTime : 2019-12-30 09:44:56
* @LastEditTime : 2020-01-07 15:23:19
*/
import axios from 'axios';
@ -71,7 +71,7 @@ export async function fetchUserProgramDetail (identifier) {
// 获取提交记录
export async function fetchUserCommitRecord (identifier, params) {
console.log('identifier=====', identifier);
// console.log('identifier=====', identifier);
const url = `/myproblems/${identifier}/submit_records.json`;
return axios.get(url, { params });
}
@ -148,4 +148,10 @@ export async function fetchAddNotes (identifier, params) {
export async function fetchQuestion (params) {
const url = `/disciplines.json`;
return axios.get(url, { params });
}
// 新增选题
export async function fetchTagDisciplines (params) {
const url = `/tag_disciplines.json`;
return axios.post(url, params);
}
Loading…
Cancel
Save