diff --git a/app/controllers/concerns/git_helper.rb b/app/controllers/concerns/git_helper.rb index 7f2024830..0d8604aac 100644 --- a/app/controllers/concerns/git_helper.rb +++ b/app/controllers/concerns/git_helper.rb @@ -46,10 +46,15 @@ module GitHelper end # 添加目录 - def add_git_folder(folder_path, author_name, author_email, message) + def git_add_folder(folder_path, author_name, author_email, message) GitService.add_tree(file_path: folder_path, message: message, author_name: author_name, author_email: author_email) end + # 删除文件 + def git_delete_file(file_path, author_name, author_email, message) + GitService.delete_file(file_path: file_path, message: message, author_name: author_name, author_email: author_email) + end + # 版本库Fork功能 def project_fork(container, original_rep_path, username) raise Educoder::TipException.new("fork源路径为空,fork失败!") if original_rep_path.blank? diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 37c72db97..7b3cb7588 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -901,12 +901,14 @@ class ShixunsController < ApplicationController def upload_git_folder author_name = current_user.real_name author_email = current_user.git_mail - add_git_folder(@path, author_name, author_email, "upload folder by browser") + git_add_folder(@path, author_name, author_email, "upload folder by browser") render_ok end def delete_git_file - + author_name = current_user.real_name + author_email = current_user.git_mail + git_delete_file(@path, author_name, author_email, "delete filer by browser") render_ok end diff --git a/app/services/git_service.rb b/app/services/git_service.rb index f5a74f244..7867d063e 100644 --- a/app/services/git_service.rb +++ b/app/services/git_service.rb @@ -6,7 +6,7 @@ class GitService class << self - ['add_repository', 'fork_repository', 'delete_repository', 'file_tree', 'update_file', 'file_content', 'commits', 'add_tree'].each do |method| + ['add_repository', 'fork_repository', 'delete_repository', 'file_tree', 'update_file', 'file_content', 'commits', 'add_tree', 'delete_file'].each do |method| define_method method do |params| post(method, params) end diff --git a/public/react/src/modules/developer/newOrEditTask/index.js b/public/react/src/modules/developer/newOrEditTask/index.js index eb894d1d0..24d2ebd7d 100644 --- a/public/react/src/modules/developer/newOrEditTask/index.js +++ b/public/react/src/modules/developer/newOrEditTask/index.js @@ -67,9 +67,8 @@ const NewOrEditTask = (props) => { props.getOJFormById(id); } else { // 清空store中的测试用例集合 - props.clearOJFormStore(); + // props.clearOJFormStore(); } - return () => {} }, []); diff --git a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js index 250437bcd..1ef2c66e6 100644 --- a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js +++ b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-20 10:35:40 * @LastEditors : tangjiang - * @LastEditTime : 2020-01-03 11:28:26 + * @LastEditTime : 2020-01-03 17:35:45 */ import './index.scss'; // import 'katex/dist/katex.css'; @@ -179,9 +179,10 @@ class EditTab extends React.Component { tag_discipline_id, knowledges } = this.props; - console.log('knowledge======>>>>>>', knowledges); + // console.log('knowledge======>>>>>>', knowledges); // const {knowledges} = this.state; // 表单label + // console.log('props=====>>>>', this.props); const myLabel = (name, subTitle, nostar) => { if (subTitle) { return ( @@ -313,7 +314,7 @@ class EditTab extends React.Component { // debugger; if (sub_id && t.children) { t.children.forEach(c => { - if (c.value === sub_id) { + if (c.value === +sub_id) { choid_ids = [t.value, c.value]; // tempKnowledges = c.children || []; } diff --git a/public/react/src/modules/question/Questionitem_banks.js b/public/react/src/modules/question/Questionitem_banks.js index f5c3307e2..472c7043a 100644 --- a/public/react/src/modules/question/Questionitem_banks.js +++ b/public/react/src/modules/question/Questionitem_banks.js @@ -14,18 +14,14 @@ import { } from "antd"; import {TPMIndexHOC} from "../tpm/TPMIndexHOC"; import Itembankstop from "./component/Itembankstop"; -import NoneData from './component/NoneData'; import './questioncss/questioncom.css'; import '../tpm/newshixuns/css/Newshixuns.css'; -import Choicequestion from './component/Choicequestion'; import SingleEditor from "./component/SingleEditor"; import ChoquesEditor from "./component/ChoquesEditor" import JudquestionEditor from "./component/JudquestionEditor"; import Bottomsubmit from "../../modules/modals/Bottomsubmit"; -// var itembankstop=null; -// var singleEditor=null; -// var Judquestio=null; -// var Choques=null; +import { connect } from 'react-redux'; +import actions from "../../redux/actions"; class Questionitem_banks extends Component { constructor(props) { super(props); @@ -98,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`; axios.get(urls, { params: { @@ -212,13 +212,6 @@ class Questionitem_banks extends Component { } preservation = () => { - //////console.log("preservation"); - // //////console.log(this.contentMdRef); - // //////console.log(this.answerMdRef); - //////console.log("preservation222"); - //////console.log(this.contentMdRef.Getdatas()); - //////console.log("preservation3333"); - //////console.log(this.answerMdRef.onSave()); const params = this.props && this.props.match && this.props.match.params; var url = ""; var boolnew = true; @@ -232,20 +225,17 @@ class Questionitem_banks extends Component { // "编辑" } - if (this.contentMdRef.Getdatas().length === 0) { - this.scrollToAnchor("Itembankstopid"); - return; - } - + if (this.contentMdRef.Getdatas().length === 0) { + this.scrollToAnchor("Itembankstopid"); + return; + } - console.log("preservation"); - console.log(this.contentMdRef.Getdatas()); - var Getdatasdata=this.contentMdRef.Getdatas(); - if (this.state.item_type === null) { + var Getdatasdata=this.contentMdRef.Getdatas(); + if (this.state.item_type === null) { + return + } - return - } if (this.state.item_type === "SINGLE") { if (this.answerMdRef != null) { //单选题 @@ -464,8 +454,18 @@ class Questionitem_banks extends Component { } if (this.state.item_type === "PROGRAM") { //编程题 跳转到 oj 中创建 - this.props.history.replace('/problems/new'); + var myrbkc=[]; + var Getdatasdatas=Getdatasdata[2].rbzsd; + for(let myda of Getdatasdatas) { + myrbkc.push(myda.id); + } + this.props.setOjInitialValue({ + difficult: Getdatasdata[0].rbnd, + sub_discipline_id: Getdatasdata[3].rbkc[1], + tag_discipline_id: myrbkc, + }); + this.props.history.replace('/problems/new'); } @@ -578,6 +578,14 @@ class Questionitem_banks extends Component { } -export default SnackbarHOC()(TPMIndexHOC(Questionitem_banks)); +const mapStateToProps = (state) => ({}); +const mapDispatchToProps = (dispatch) => ({ + setOjInitialValue: (params) => dispatch(actions.setOjInitialValue(params)) +}); + +export default connect( + mapStateToProps, + mapDispatchToProps +)(SnackbarHOC()(TPMIndexHOC(Questionitem_banks))); diff --git a/public/react/src/modules/question/component/Itembankstop.js b/public/react/src/modules/question/component/Itembankstop.js index 2c149c86e..bb847a118 100644 --- a/public/react/src/modules/question/component/Itembankstop.js +++ b/public/react/src/modules/question/component/Itembankstop.js @@ -16,7 +16,7 @@ import { Col, Row, InputNumber, DatePicker, AutoComplete, Button, Tag } from "antd"; import './../questioncss/questioncom.css'; - +import Newknledpots from './Newknledpots' const InputGroup = Input.Group; const {Option} = Select; const options = [ @@ -53,6 +53,7 @@ class Itembankstop extends Component { rbkc: undefined, knowledgepoints: [], options: [], + NewknTypedel:false } } @@ -86,6 +87,7 @@ class Itembankstop extends Component { } componentDidUpdate(prevProps) { + //编辑的时候 if (prevProps.item_banksedit !== this.props.item_banksedit) { if (this.props.item_banksedit.item_type) { @@ -236,6 +238,11 @@ class Itembankstop extends Component { //课程 ////console.log("课程"); ////console.log(value); + // console.log("handleFormkechen"); + if(this.state.Knowpoints.length>4){ + this.props.showNotification(`知识点最多选择5个`); + return + } var valuename = undefined; this.props.form.setFieldsValue({ rbzsd: value, @@ -377,9 +384,59 @@ class Itembankstop extends Component { } + NewknTypedeldel=(bool)=>{ + this.setState({ + NewknTypedel:bool + }) + + + } + + NewknTypedeltyoedel=(value)=>{ + + if(value===null||value===""){ + this.props.showNotification(`请输入知识点`); + return + } + + if(value.length===0){ + this.props.showNotification(`请输入知识点`); + return + } + + if(this.state.rbkc===undefined || this.state.rbkc===null || this.state.rbkc===""){ + this.props.showNotification(`请选择课程方向`); + return; + } + var data={ + name:value, + sub_discipline_id:this.state.rbkc[1] + } + const url="/tag_disciplines.json"; + axios.post(url,data) + .then((result) => { + if (result.data.status === 0) { + this.props.showNotification(`新增知识点成功!`); + var leydata={ + id: result.data.tag_discipline_id, + name:value, + } + this.state.knowledgepoints.push(leydata); + this.setState({ + knowledgepoints:this.state.knowledgepoints + }) + } + }).catch((error) => { + //console.log(error); + }) + + this.setState({ + NewknTypedel:false + }) + } render() { - let {page, options} = this.state; + let {page, options,NewknTypedel} = this.state; const {getFieldDecorator} = this.props.form; //console.log("renderrenderrender"); //console.log(this.props.item_banksedit); @@ -418,6 +475,15 @@ class Itembankstop extends Component { }
+ { + NewknTypedel? +