Merge branch 'dev_item_bank' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_item_bank

dev_jupyter
cxt 5 years ago
commit 9f196d32c3

@ -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?

@ -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

@ -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

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

@ -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 || [];
}

@ -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)));

@ -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 {
}
</style>
<div className="h12"></div>
{
NewknTypedel?
<Newknledpots {...this.state} {...this.props}
NewknTypedeldel={(bool)=>this.NewknTypedeldel(bool)}
NewknTypedeltyoedel={(value)=>this.NewknTypedeltyoedel(value)}
></Newknledpots>
:""
}
<Form onSubmit={this.handleSubmit}>
<Form.Item
@ -474,7 +540,7 @@ class Itembankstop extends Component {
</InputGroup>
<img className=" ml22 zjzsdian xiaoshou" src={getImageUrl("/images/educoder/zjzsd.png")}/>
<img className=" ml22 zjzsdian xiaoshou" src={getImageUrl("/images/educoder/zjzsd.png")} onClick={()=>this.NewknTypedeldel(true)}/>
<div className="sortinxdirection" style={{

@ -38,8 +38,8 @@ class PaperDeletModel extends Component {
<Input onInput={this.handleChange} />
</div>
<div className="clearfix mt30 edu-txt-center">
<a className="task-btn mr30 w80" onClick={()=>this.props.setmodalsTypedel()}>取消</a>
<a className="task-btn task-btn-orange w80" onClick={()=>this.props.setmodalsTypedel(this.state.newkntypeinput)}>确定</a>
<a className="task-btn mr30 w80" onClick={()=>this.props.NewknTypedeldel(false)}>取消</a>
<a className="task-btn task-btn-orange w80" onClick={()=>this.props.NewknTypedeltyoedel(this.state.newkntypeinput)}>确定</a>
</div>
</div>
</Modal>

@ -36,6 +36,7 @@ const types = {
DEBUGGER_CODE: 'DEBUGGER_CODE', // 调试代码
GET_COURSE_QUESTION: 'GET_COURSE_QUESTION', // 获取编辑题
CHANGE_KNOWLEDGES: 'CHANGE_KNOWLEDGES', // 保存所选择的知识点
SET_OJ_INITIAL_VALUE: 'SET_OJ_INITIAL_VALUE', // 设置初始值
// study
SAVE_USER_PROGRAM_ID: 'SAVE_USER_PROGRAM_ID',// 保存用户编程题id值
USER_PROGRAM_DETAIL: 'USER_PROGRAM_DETAIL', // 用户编程题详情

@ -35,7 +35,8 @@ import {
updateOpenTestCaseIndex,
handleClickCancelPublish,
getQuestion,
saveKnowledge
saveKnowledge,
setOjInitialValue
} from './ojForm';
import {
@ -123,6 +124,7 @@ export default {
handleClickCancelPublish,
getQuestion,
saveKnowledge,
setOjInitialValue,
//
addTestCase,
deleteTestCase,

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 16:35:46
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-02 17:38:12
* @LastEditTime : 2020-01-03 17:39:32
*/
import types from './actionTypes';
import CONST from '../../constants';
@ -675,14 +675,31 @@ export const updateOpenTestCaseIndex = (value) => {
// 获取课程题库
export const getQuestion = (params) => {
return (dispatch) => {
fetchQuestion(params).then(res => {
return (dispatch, getState) => {
const {ojForm: {sub_discipline_id}} = getState().ojFormReducer;
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
});
})
}
}
@ -694,3 +711,19 @@ export const saveKnowledge = (values) => {
payload: values
}
}
/**
* 新增时跳转到OJ时带的默认参数:
* @param {}} params
* {
* difficult: '', // 难易度
* sub_discipline_id: '' // 课程方向
* tag_discipline_id [] 知识点
* }
*/
export const setOjInitialValue = (params) => {
return {
type: types.SET_OJ_INITIAL_VALUE,
payload: params
}
}

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 16:40:32
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-02 17:36:40
* @LastEditTime : 2020-01-03 17:38:50
*/
import { Base64 } from 'js-base64';
import types from '../actions/actionTypes';
@ -231,7 +231,7 @@ const ojFormReducer = (state = initialState, action) => {
courseQuestions.forEach(c => {
if (sub_discipline_id && c.sub_disciplines) {
c.sub_disciplines.forEach(sub => {
if (+sub.id === sub_discipline_id) {
if (+sub.id === +sub_discipline_id) {
temp_knowledges = sub.tag_disciplines || [];
}
});
@ -348,6 +348,13 @@ const ojFormReducer = (state = initialState, action) => {
knowledges: action.payload
}
}
case types.SET_OJ_INITIAL_VALUE:
const _p = action.payload;
return {
...state,
ojForm: Object.assign({}, state.ojForm, {difficult: _p.difficult, sub_discipline_id: _p.sub_discipline_id}),
tag_discipline_id: _p.tag_discipline_id || []
}
default:
return state;
}

Loading…
Cancel
Save