dev_aliyun2
harry 5 years ago
parent 67c313e8e4
commit 8dcffab574

@ -1,6 +1,5 @@
import React, { Component } from "react";
import { SnackbarHOC } from 'educoder';
import React, {Component} from "react";
import { SnackbarHOC} from 'educoder';
import axios from 'axios';
import {
Pagination,
@ -24,7 +23,7 @@ class Question extends Component {
super(props);
this.state = {
count: 50,
defaultActiveKey: "1",
defaultActiveKey:"1",
Headertop: "",
Footerdown: "",
visible: false,
@ -34,7 +33,7 @@ class Question extends Component {
modalsTypes:false,
titilesm: "在平台审核后,所有成员均可使用试题",
titiless: "是否设置为公开?",
titilesms: "单选题",
titilesms:"单选题",
titbool: false,
Contentdata: [],
difficulty: null,
@ -52,17 +51,17 @@ class Question extends Component {
program_questions_count: 0,
single_questions_count: 0,
subjective_questions_count: 0,
page: 1,
per_page: 10,
disciplinesdata: [],
discipline_id: null,
sub_discipline_id: null,
tag_discipline_id: null,
booljupyterurls: false,
disciplinesdatakc: 0,
disciplinesdatazsd: 0,
selectallquestionsonthispages: false,
oj_status: null,
page:1,
per_page:10,
disciplinesdata:[],
discipline_id:null,
sub_discipline_id:null,
tag_discipline_id:null,
booljupyterurls:false,
disciplinesdatakc:0,
disciplinesdatazsd:0,
selectallquestionsonthispages:false,
oj_status:null,
isVisible: false,
selectionbools:false,
chakanjiexiboolindex:"无",
@ -75,23 +74,23 @@ class Question extends Component {
}
chakanjiexibool = (index) => {
if (this.state.chakanjiexiboolindex === index) {
chakanjiexibool=(index)=>{
if(this.state.chakanjiexiboolindex===index){
this.setState({
chakanjiexiboolindex: "无",
chakanjiexiboolindex:"无",
})
return
}
this.setState({
chakanjiexiboolindex: index,
chakanjiexiboolindex:index,
})
}
setmychakanjiexibool = (str) => {
setmychakanjiexibool=(str)=>{
this.setState({
chakanjiexiboolindex: str,
chakanjiexiboolindex:str,
})
}
setdiscipline_id = (discipline_id) => {
setdiscipline_id=(discipline_id)=>{
this.setState({
discipline_id:discipline_id,
sub_discipline_id:null,
@ -102,22 +101,22 @@ class Question extends Component {
oj_status:null
})
var data = {
discipline_id: discipline_id,
sub_discipline_id: null,
tag_discipline_id: null,
discipline_id:discipline_id,
sub_discipline_id:null,
tag_discipline_id:null,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keyword: null,
page: this.state.page,
per_page: 10,
oj_status: null
per_page:10,
oj_status:null
};
this.getdata(data);
}
setsub_discipline_id = (discipline_id, sub_discipline_id) => {
setsub_discipline_id=(discipline_id,sub_discipline_id)=>{
this.setState({
sub_discipline_id:sub_discipline_id,
discipline_id:discipline_id,
@ -128,21 +127,21 @@ class Question extends Component {
oj_status:null
})
var data = {
discipline_id: discipline_id,
sub_discipline_id: sub_discipline_id,
tag_discipline_id: null,
discipline_id:discipline_id,
sub_discipline_id:sub_discipline_id,
tag_discipline_id:null,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keyword:null,
page: 1,
per_page: 10,
oj_status: null
per_page:10,
oj_status:null
};
this.getdata(data);
}
settag_discipline_id = (tag_discipline_id) => {
settag_discipline_id=(tag_discipline_id)=>{
this.setState({
tag_discipline_id:tag_discipline_id,
keyword:"",
@ -151,16 +150,16 @@ class Question extends Component {
oj_status:null
})
var data = {
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: tag_discipline_id,
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keyword: null,
page: 1,
per_page: 10,
oj_status: null
per_page:10,
oj_status:null
};
this.getdata(data);
}
@ -181,39 +180,37 @@ class Question extends Component {
this.getbasket_listdata();
//获取题库筛选资料
let urls = `/disciplines.json`;
axios.get(urls, {
params: {
source: "question"
}
}).then((response) => {
axios.get(urls, {params: {
source:"question"
}}).then((response) => {
//console.log("Questiondisciplines");
//console.log(response.data);
if (response) {
this.setState({
disciplinesdata: response.data.disciplines,
})
this.setState({
disciplinesdata: response.data.disciplines,
})
}
});
}
//公共和我的
//公共和我的
callback = (key) => {
this.setState({
defaultActiveKey: key,
selectallquestionsonthispages: false,
difficulty: null,
page: 1,
oj_status: null
selectallquestionsonthispages:false,
difficulty:null,
page:1,
oj_status:null
})
var data = {
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: key,
item_type: this.state.item_type,
difficulty: null,
page: 1,
per_page: 10,
oj_status: null
per_page:10,
oj_status:null
};
this.getdata(data);
@ -256,7 +253,7 @@ class Question extends Component {
}).catch((error) => {
//////console.log(error)
this.setState({
booljupyterurls: false,
booljupyterurls:false,
})
});
}
@ -264,13 +261,13 @@ class Question extends Component {
//不刷新加载
getdatasy = (data) => {
const url = `/item_banks.json`;
this.setState({
selectionbools: false,
this.setState({
selectionbools:false,
})
axios.get((url), { params: data }).then((response) => {
setTimeout(() => {
axios.get((url), {params: data}).then((response) => {
setTimeout(()=>{
}, 1000);
},1000);
if (response === null || response === undefined) {
return
@ -305,9 +302,9 @@ class Question extends Component {
for(let data of arr) {
if(data.item_type==="PROGRAM"){
//编程题
if (data.choosed === true) {
if(data.choosed===true){
} else {
}else{
//未选用
if(data.program_attr.status===1){
//已发布1 未发布0
@ -318,13 +315,13 @@ class Question extends Component {
}
} else {
}else{
//不是编程题
if (data.choosed === true) {
if(data.choosed===true){
} else {
}else{
//未选用
contes = contes + 1;
contes=contes+1;
}
}
@ -364,27 +361,27 @@ class Question extends Component {
page: pageNumber,
})
var data = {
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keyword: this.state.keywords,
page: pageNumber,
per_page: 10,
oj_status: this.state.oj_status
per_page:10,
oj_status:this.state.oj_status
};
this.getdata(data);
this.setmychakanjiexibool("无")
}
showDrawer = () => {
if (this.state.visible === true) {
if(this.state.visible===true){
this.setState({
visible: false,
});
} else {
}else{
this.setState({
visible: true,
});
@ -454,19 +451,19 @@ class Question extends Component {
modalsType: false
})
}
modalCancels = () => {
modalCancels=()=>{
this.setState({
modalsTypes: false
})
}
showQuestionModals = (item_type) => {
showQuestionModals =(item_type)=>{
this.setState({
modalsTypes: true,
titilesms: item_type,
titilesms:item_type,
})
}
setDownloads = (item_type) => {
setDownloads=(item_type)=>{
this.Deletebigquestiontype(item_type);
this.setState({
modalsTypes: false
@ -497,9 +494,9 @@ class Question extends Component {
})
var data = {
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: difficulty,
item_type: this.state.item_type,
@ -523,9 +520,9 @@ class Question extends Component {
})
var data = {
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: item_type,
@ -577,16 +574,16 @@ class Question extends Component {
keyword: value,
})
var data = {
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keyword: value,
page: this.state.page,
per_page: 10,
oj_status: this.state.oj_status
per_page:10,
oj_status:this.state.oj_status
};
this.getdata(data);
@ -601,15 +598,15 @@ class Question extends Component {
// this.props.showNotification('删除试题成功')
// props.history.push(response.data.right_url)
var data = {
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keyword: this.state.keywords,
page: this.state.page,
per_page: 10,
per_page:10,
};
this.getdata(data,true);
}
@ -626,21 +623,21 @@ class Question extends Component {
if (result.data.status == 0) {
// this.props.showNotification(`公开题目成功`);
var data = {
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keyword: this.state.keywords,
page: this.state.page,
per_page: 10,
per_page:10,
};
this.getdata(data,true);
}
}).catch((error) => {
////console.log(error);
})
////console.log(error);
})
}
getbasket_listdata = () => {
@ -662,17 +659,15 @@ class Question extends Component {
// Undoclickable=true;
}).catch((error) => {
// ////console.log(error);
this.setState({
completion_questions_count: 0,
judgement_questions_count: 0,
multiple_questions_count: 0,
practical_questions_count: 0,
program_questions_count: 0,
single_questions_count: 0,
subjective_questions_count: 0,
})
// Undoclickable=true;
// ////console.log(error);
this.setState({
completion_questions_count: 0,
judgement_questions_count: 0,
multiple_questions_count: 0,
practical_questions_count: 0,
program_questions_count: 0,
single_questions_count: 0,
subjective_questions_count: 0,
})
// Undoclickable=true;
})
@ -687,15 +682,15 @@ class Question extends Component {
if (result.data.status == 0) {
// this.props.showNotification(`选用成功`);
var data = {
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keyword: this.state.keywords,
page: this.state.page,
per_page: 10,
per_page:10,
};
this.getdatasy(data);
this.getbasket_listdata();
@ -704,8 +699,8 @@ class Question extends Component {
// })
}
}).catch((error) => {
////console.log(error);
})
////console.log(error);
})
}
//选用 NewMyShixunModel.js 页面也有个
@ -718,15 +713,15 @@ class Question extends Component {
if (result.data.status == 0) {
// this.props.showNotification(`选用成功`);
var data = {
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keyword: this.state.keywords,
page: this.state.page,
per_page: 10,
per_page:10,
};
this.getdatasy(data);
this.getbasket_listdata();
@ -735,51 +730,8 @@ class Question extends Component {
// })
}
}).catch((error) => {
////console.log(error);
})
}
// 撤销
getitem_basketss = (id) => {
if (Undoclickable === true) {
Undoclickable = false;
//选用题型可以上传单个 或者多个题型
let url = `/item_baskets/${id}.json`;
axios.delete(url)
.then((result) => {
if (result.data.status == 0) {
// this.props.showNotification(`撤销成功`);
var data = {
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keyword: this.state.keywords,
page: this.state.page,
per_page: 10,
};
this.getdatasy(data);
this.getbasket_listdata();
}
setTimeout(() => {
Undoclickable = true;
}, 1000);
}).catch((error) => {
////console.log(error);
setTimeout(() => {
Undoclickable = true;
}, 1000);
})
} else {
return
}
////console.log(error);
})
}
// 撤销
getitem_basketss=(id)=>{
@ -870,14 +822,14 @@ class Question extends Component {
}
}else{
//未选用
if (data.program_attr.status === 1) {
if(data.program_attr.status===1){
//已发布
item_idsdata.push(data.id);
}
}
} else {
}else{
//不是编程题
if(data.choosed===true){
item_idsdata.push(data.id);
@ -888,8 +840,8 @@ class Question extends Component {
}
}
const data = {
item_ids: item_idsdata
const data={
item_ids:item_idsdata
}
if(bool===false){
this.getitem_baskets(data);
@ -907,27 +859,25 @@ class Question extends Component {
//全选的状态
//删除大题型
Deletebigquestiontype = (item_type) => {
const url = `/item_baskets/delete_item_type.json`;
axios.delete((url), {
data: {
item_type: item_type
}
})
//删除大题型
Deletebigquestiontype =(item_type)=>{
const url=`/item_baskets/delete_item_type.json`;
axios.delete((url), { data: {
item_type:item_type
}})
.then((response) => {
if (response.data.status == 0) {
// this.props.showNotification('删除成功');
var data = {
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keyword: this.state.keywords,
page: this.state.page,
per_page: 10,
per_page:10,
};
this.getdata(data);
this.getbasket_listdata();
@ -974,24 +924,24 @@ class Question extends Component {
}
setoj_status = (oj_status) => {
setoj_status=(oj_status)=>{
//编程题发布未发布
this.setState({
selectallquestionsonthispages: false,
difficulty: null,
oj_status: oj_status
selectallquestionsonthispages:false,
difficulty:null,
oj_status:oj_status
})
var data = {
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keyword: this.state.keywords,
page: this.state.page,
per_page: 10,
oj_status: oj_status
per_page:10,
oj_status:oj_status
};
this.getdata(data);
}
@ -1001,7 +951,7 @@ class Question extends Component {
render() {
let {
page, per_page, items_count, Headertop, visible, placement, modalsType, modalsTypes, basket_list,
page, per_page, items_count, Headertop, visible, placement, modalsType, modalsTypes,basket_list,
completion_questions_count, judgement_questions_count, multiple_questions_count, practical_questions_count,
program_questions_count, single_questions_count, subjective_questions_count,selectionbools,
modalsTypeInaudit,mydisplay
@ -1083,7 +1033,7 @@ class Question extends Component {
`
}
</style>
: ""
:""
}
<div
@ -1091,22 +1041,16 @@ class Question extends Component {
marginTop: "81px"
}}></div>
{
modalsTypes === true ?
modalsTypes===true?
<QuestionModals {...this.props}{...this.state} modalsTypes={modalsTypes} modalCancels={() => this.modalCancels()}
setDownloads={(e) => this.setDownloads(e)}></QuestionModals>
: ""
setDownloads={(e) => this.setDownloads(e)}></QuestionModals>
:""
}
{
modalsType === true ?
modalsType===true?
<QuestionModal {...this.props}{...this.state} modalsType={modalsType} modalCancel={() => this.modalCancel()}
setDownload={() => this.setDownload()}></QuestionModal>
: ""
}
{
modalsTypeInaudit === true ?
<QuestionModalys {...this.props}{...this.state} modalsType={modalsTypeInaudit} modalCancel={() => this.modalsTypeInauditbool()}
setDownload={() => this.modalsTypeInauditbool()}></QuestionModalys>
: ""
setDownload={() => this.setDownload()}></QuestionModal>
:""
}
{
modalsTypeInaudit===true?
@ -1146,9 +1090,9 @@ class Question extends Component {
{...this.state}
setdifficulty={(e) => this.setdifficulty(e)}
setitem_types={(e) => this.setitem_types(e)}
setdiscipline_id={(e) => this.setdiscipline_id(e)}
setsub_discipline_id={(e, id) => this.setsub_discipline_id(e, id)}
settag_discipline_id={(e) => this.settag_discipline_id(e)}
setdiscipline_id={(e)=>this.setdiscipline_id(e)}
setsub_discipline_id={(e,id)=>this.setsub_discipline_id(e,id)}
settag_discipline_id={(e)=>this.settag_discipline_id(e)}
/>
{/*头部*/}
<Contentpart {...this.state} {...this.props}
@ -1173,13 +1117,13 @@ class Question extends Component {
></Contentpart>
{
items_count && items_count > 10 ?
items_count&&items_count>10?
<div className="mb30 clearfix educontent mt40 intermediatecenter">
<Pagination showQuickJumper current={page} onChange={this.paginationonChange}
pageSize={per_page}
total={items_count}></Pagination>
pageSize={per_page}
total={items_count}></Pagination>
</div>
: <div className="h30 clearfix educontent mt40 intermediatecenter">
:<div className="h30 clearfix educontent mt40 intermediatecenter">
</div>
}
@ -1312,7 +1256,7 @@ class Question extends Component {
<div className="intermediatecenter verticallayout mt42">
<div className="drawerbutton xiaoshou" onClick={() => this.gotopaperreview()}>
<div className="drawerbutton xiaoshou" onClick={()=>this.gotopaperreview()}>
试卷预览
</div>
</div>

Loading…
Cancel
Save