forgeplus-react/src/modules/question/Question.js

1280 lines
32 KiB
JavaScript
Raw Normal View History

2020-04-28 17:23:34 +08:00
import React, { Component } from "react";
import { SnackbarHOC } from 'educoder';
2020-03-16 14:12:11 +08:00
import axios from 'axios';
2020-04-28 17:23:34 +08:00
import { Pagination, Drawer, } from "antd";
2020-03-16 14:12:11 +08:00
import Headplugselections from "./component/Headplugselections";
import QuestionModal from "./component/QuestionModal";
import QuestionModals from "./component/QuestionModals";
import Contentpart from "./component/Contentpart";
2020-04-28 17:23:34 +08:00
import { TPMIndexHOC } from "../tpm/TPMIndexHOC";
2020-03-16 14:12:11 +08:00
import NoneData from './component/NoneData';
import './questioncss/questioncom.css';
import SiderBars from "../question/component/SiderBars";
2020-04-28 17:23:34 +08:00
import QuestionModalys from "./component/QuestionModalys";
import Certifiedprofessional from "../modals/Certifiedprofessional";
import SiderBar from "../tpm/SiderBar";
2020-03-16 14:12:11 +08:00
2020-04-28 17:23:34 +08:00
var Undoclickable = true;
var myGrandtotal = false;
2020-03-16 14:12:11 +08:00
class Question extends Component {
constructor(props) {
super(props);
this.state = {
count: 50,
2020-04-28 17:23:34 +08:00
defaultActiveKey: "0",
2020-03-16 14:12:11 +08:00
Headertop: "",
Footerdown: "",
visible: false,
placement: 'right',
modalsType: false,
2020-04-28 17:23:34 +08:00
modalsTypeInaudit: false,
modalsTypes: false,
2020-03-16 14:12:11 +08:00
titilesm: "在平台审核后,所有成员均可使用试题",
titiless: "是否设置为公开?",
2020-04-28 17:23:34 +08:00
titilesms: "单选题",
2020-03-16 14:12:11 +08:00
titbool: false,
Contentdata: [],
difficulty: null,
visiblemys: false,
visiblemyss: false,
item_type: null,
keyword: null,
timuid: null,
items_count: 0,
basket_list: [],
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,
2020-04-28 17:23:34 +08:00
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,
2020-03-16 14:12:11 +08:00
isVisible: false,
2020-04-28 17:23:34 +08:00
selectionbools: false,
chakanjiexiboolindex: "无",
mydisplay: false,
occupation: 2,
myqyespull: true
2020-03-16 14:12:11 +08:00
}
}
2020-04-28 17:23:34 +08:00
chakanjiexibool = (index) => {
if (this.state.chakanjiexiboolindex === index) {
2020-03-16 14:12:11 +08:00
this.setState({
2020-04-28 17:23:34 +08:00
chakanjiexiboolindex: "无",
2020-03-16 14:12:11 +08:00
})
return
}
this.setState({
2020-04-28 17:23:34 +08:00
chakanjiexiboolindex: index,
2020-03-16 14:12:11 +08:00
})
}
2020-04-28 17:23:34 +08:00
setmychakanjiexibool = (str) => {
2020-03-16 14:12:11 +08:00
this.setState({
2020-04-28 17:23:34 +08:00
chakanjiexiboolindex: str,
2020-03-16 14:12:11 +08:00
})
}
2020-04-28 17:23:34 +08:00
setdiscipline_id = (discipline_id) => {
2020-03-16 14:12:11 +08:00
this.setState({
2020-04-28 17:23:34 +08:00
discipline_id: discipline_id,
sub_discipline_id: null,
tag_discipline_id: null,
keyword: "",
page: 1,
per_page: 10,
oj_status: null
2020-03-16 14:12:11 +08:00
})
var data = {
2020-04-28 17:23:34 +08:00
discipline_id: discipline_id,
sub_discipline_id: null,
tag_discipline_id: null,
2020-03-16 14:12:11 +08:00
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
2020-04-28 17:23:34 +08:00
keyword: null,
2020-03-16 14:12:11 +08:00
page: this.state.page,
2020-04-28 17:23:34 +08:00
per_page: 10,
oj_status: null
2020-03-16 14:12:11 +08:00
};
this.getdata(data);
}
2020-04-28 17:23:34 +08:00
setsub_discipline_id = (discipline_id, sub_discipline_id) => {
2020-03-16 14:12:11 +08:00
this.setState({
2020-04-28 17:23:34 +08:00
sub_discipline_id: sub_discipline_id,
discipline_id: discipline_id,
tag_discipline_id: null,
keyword: "",
page: 1,
per_page: 10,
oj_status: null
2020-03-16 14:12:11 +08:00
})
var data = {
2020-04-28 17:23:34 +08:00
discipline_id: discipline_id,
sub_discipline_id: sub_discipline_id,
tag_discipline_id: null,
2020-03-16 14:12:11 +08:00
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
2020-04-28 17:23:34 +08:00
keyword: null,
2020-03-16 14:12:11 +08:00
page: 1,
2020-04-28 17:23:34 +08:00
per_page: 10,
oj_status: null
2020-03-16 14:12:11 +08:00
};
this.getdata(data);
}
2020-04-28 17:23:34 +08:00
settag_discipline_id = (tag_discipline_id) => {
2020-03-16 14:12:11 +08:00
this.setState({
2020-04-28 17:23:34 +08:00
tag_discipline_id: tag_discipline_id,
keyword: "",
page: 1,
per_page: 10,
oj_status: null
2020-03-16 14:12:11 +08:00
})
var data = {
2020-04-28 17:23:34 +08:00
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: tag_discipline_id,
2020-03-16 14:12:11 +08:00
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
2020-04-28 17:23:34 +08:00
keyword: null,
2020-03-16 14:12:11 +08:00
page: 1,
2020-04-28 17:23:34 +08:00
per_page: 10,
oj_status: null
2020-03-16 14:12:11 +08:00
};
this.getdata(data);
}
//初始化
componentDidMount() {
let url = `/users/get_navigation_info.json`;
axios.get(url, {}).then((response) => {
if (response != undefined) {
if (response.status === 200) {
this.setState({
Headertop: response.data.top,
Footerdown: response.data.down
})
}
}
});
this.getbasket_listdata();
//获取题库筛选资料
let urls = `/disciplines.json`;
2020-04-28 17:23:34 +08:00
axios.get(urls, {
params: {
source: "question"
}
}).then((response) => {
2020-03-16 14:12:11 +08:00
if (response) {
2020-04-28 17:23:34 +08:00
this.setState({
disciplinesdata: response.data.disciplines,
})
2020-03-16 14:12:11 +08:00
}
});
}
2020-04-28 17:23:34 +08:00
//公共和我的
2020-03-16 14:12:11 +08:00
callback = (key) => {
this.setState({
defaultActiveKey: key,
2020-04-28 17:23:34 +08:00
selectallquestionsonthispages: false,
difficulty: null,
page: 1,
oj_status: null
2020-03-16 14:12:11 +08:00
})
var data = {
2020-04-28 17:23:34 +08:00
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
2020-03-16 14:12:11 +08:00
public: key,
item_type: this.state.item_type,
difficulty: null,
page: 1,
2020-04-28 17:23:34 +08:00
per_page: 10,
oj_status: null
2020-03-16 14:12:11 +08:00
};
this.getdata(data);
}
//刷新加载
2020-04-28 17:23:34 +08:00
getdata = (data, bool) => {
2020-03-16 14:12:11 +08:00
const url = `/item_banks.json`;
2020-04-28 17:23:34 +08:00
if (bool) {
this.setState({
selectionbools: false,
})
} else {
this.setState({
booljupyterurls: true,
selectionbools: false,
})
}
axios.get((url), { params: data }).then((response) => {
this.setState({
booljupyterurls: false,
})
2020-03-16 14:12:11 +08:00
if (response === null || response === undefined) {
return
}
if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) {
} else {
}
this.setState({
Contentdata: response.data,
items_count: response.data.items_count,
})
this.getdataslen(response.data.items);
}).catch((error) => {
this.setState({
2020-04-28 17:23:34 +08:00
booljupyterurls: false,
2020-03-16 14:12:11 +08:00
})
});
}
//不刷新加载
getdatasy = (data) => {
const url = `/item_banks.json`;
2020-04-28 17:23:34 +08:00
this.setState({
selectionbools: false,
2020-03-16 14:12:11 +08:00
})
2020-04-28 17:23:34 +08:00
axios.get((url), { params: data }).then((response) => {
2020-03-16 14:12:11 +08:00
if (response === null || response === undefined) {
return
}
this.setState({
Contentdata: response.data,
items_count: response.data.items_count,
})
this.getdataslen(response.data.items);
2020-04-28 17:23:34 +08:00
2020-03-16 14:12:11 +08:00
}).catch((error) => {
});
}
//计算
2020-04-28 17:23:34 +08:00
getdataslen = (arr) => {
myGrandtotal = false;
let contes = 0;
let Grandtotal = 0;
for (let data of arr) {
if (data.item_type === "PROGRAM") {
2020-03-16 14:12:11 +08:00
//编程题
2020-04-28 17:23:34 +08:00
if (data.choosed === true) {
2020-03-16 14:12:11 +08:00
2020-04-28 17:23:34 +08:00
} else {
2020-03-16 14:12:11 +08:00
//未选用
2020-04-28 17:23:34 +08:00
if (data.program_attr.status === 1) {
//已发布1 未发布0
contes = contes + 1;
} else {
Grandtotal = Grandtotal + 1;
2020-03-16 14:12:11 +08:00
}
}
2020-04-28 17:23:34 +08:00
} else {
2020-03-16 14:12:11 +08:00
//不是编程题
2020-04-28 17:23:34 +08:00
if (data.choosed === true) {
2020-03-16 14:12:11 +08:00
2020-04-28 17:23:34 +08:00
} else {
2020-03-16 14:12:11 +08:00
//未选用
2020-04-28 17:23:34 +08:00
contes = contes + 1;
2020-03-16 14:12:11 +08:00
}
}
}
2020-04-28 17:23:34 +08:00
if (contes > 0) {
2020-03-16 14:12:11 +08:00
this.setState({
2020-04-28 17:23:34 +08:00
selectionbools: false,
selectallquestionsonthispages: false,
2020-03-16 14:12:11 +08:00
})
2020-04-28 17:23:34 +08:00
} else {
try {
if (arr.length === Grandtotal) {
myGrandtotal = true;
this.setState({
selectionbools: false,
selectallquestionsonthispages: false,
})
} else {
this.setState({
selectionbools: true,
selectallquestionsonthispages: true,
})
}
} catch (e) {
this.setState({
selectionbools: true,
selectallquestionsonthispages: true,
})
}
2020-03-16 14:12:11 +08:00
}
}
paginationonChange = (pageNumber) => {
this.setState({
page: pageNumber,
})
var data = {
2020-04-28 17:23:34 +08:00
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
2020-03-16 14:12:11 +08:00
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
2020-04-28 17:23:34 +08:00
keyword: this.state.keywords,
2020-03-16 14:12:11 +08:00
page: pageNumber,
2020-04-28 17:23:34 +08:00
per_page: 10,
oj_status: this.state.oj_status
2020-03-16 14:12:11 +08:00
};
this.getdata(data);
this.setmychakanjiexibool("无")
}
showDrawer = () => {
2020-04-28 17:23:34 +08:00
if (this.state.visible === true) {
2020-03-16 14:12:11 +08:00
this.setState({
visible: false,
});
2020-04-28 17:23:34 +08:00
} else {
2020-03-16 14:12:11 +08:00
this.setState({
visible: true,
});
this.getbasket_listdata();
}
};
onClose = () => {
this.setState({
visible: false,
});
};
onChange = e => {
this.setState({
placement: e.target.value,
});
};
getContainer = () => {
return this.container;
};
saveContainer = container => {
this.container = container;
};
showmodels = (id) => {
this.setState({
modalsType: true,
titilesm: "在平台审核后,所有成员均可使用试题",
titiless: "是否设置为公开?",
titbool: true,
2020-04-28 17:23:34 +08:00
timuid: id,
myqyespull: true
2020-03-16 14:12:11 +08:00
})
};
2020-04-28 17:23:34 +08:00
setasprivates = (id) => {
this.setState({
modalsType: true,
titilesm: "设为私有后,试题仅您自己可见",
titiless: "是否设置为私有?",
titbool: true,
timuid: id,
myqyespull: false
})
};
showmodelsInaudit = (e) => {
this.setState({
modalsTypeInaudit: true,
titilesm: "公开申请已提交,请等待管理员的审核",
titiless: "我们将在1-2个工作日内完成审核",
})
};
2020-03-16 14:12:11 +08:00
showmodelysl = (id) => {
this.setState({
modalsType: true,
titilesm: "确认删除后,无法撤销",
titiless: "是否确认删除?",
titbool: false,
timuid: id
})
};
2020-04-28 17:23:34 +08:00
modalsTypeInauditbool = () => {
this.setState({
modalsTypeInaudit: false,
})
}
2020-03-16 14:12:11 +08:00
modalCancel = () => {
this.setState({
modalsType: false
})
}
2020-04-28 17:23:34 +08:00
modalCancels = () => {
2020-03-16 14:12:11 +08:00
this.setState({
modalsTypes: false
})
}
2020-04-28 17:23:34 +08:00
showQuestionModals = (item_type) => {
2020-03-16 14:12:11 +08:00
this.setState({
modalsTypes: true,
2020-04-28 17:23:34 +08:00
titilesms: item_type,
2020-03-16 14:12:11 +08:00
})
}
2020-04-28 17:23:34 +08:00
setDownloads = (item_type) => {
2020-03-16 14:12:11 +08:00
this.Deletebigquestiontype(item_type);
this.setState({
modalsTypes: false
})
}
setDownload = () => {
//确认
if (this.state.titbool === true) {
//公开
2020-04-28 17:23:34 +08:00
if (this.state.myqyespull === true) {
this.publicopentimu(this.state.timuid);
} else {
this.Setasprivate(this.state.timuid);
}
2020-03-16 14:12:11 +08:00
} else {
// 删除
this.deletetimu(this.state.timuid);
}
this.setState({
modalsType: false
})
}
setdifficulty = (difficulty) => {
this.setState({
difficulty: difficulty,
visiblemys: false,
page: 1,
2020-04-28 17:23:34 +08:00
per_page: 10,
keyword: "",
oj_status: null
2020-03-16 14:12:11 +08:00
})
var data = {
2020-04-28 17:23:34 +08:00
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
2020-03-16 14:12:11 +08:00
public: this.state.defaultActiveKey,
difficulty: difficulty,
item_type: this.state.item_type,
2020-04-28 17:23:34 +08:00
keyword: null,
page: 1,
per_page: 10,
oj_status: null
2020-03-16 14:12:11 +08:00
};
this.getdata(data);
}
setitem_types = (item_type) => {
this.setState({
item_type: item_type,
visiblemyss: false,
page: 1,
2020-04-28 17:23:34 +08:00
per_page: 10,
keyword: "",
oj_status: null
2020-03-16 14:12:11 +08:00
})
var data = {
2020-04-28 17:23:34 +08:00
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
2020-03-16 14:12:11 +08:00
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: item_type,
page: 1,
2020-04-28 17:23:34 +08:00
per_page: 10,
keyword: null,
oj_status: null
2020-03-16 14:12:11 +08:00
};
this.getdata(data);
}
handleVisibleChange = (boll) => {
if (this.state.visiblemyss === true) {
this.setState({
visiblemys: boll,
visiblemyss: false,
})
} else {
this.setState({
visiblemys: boll,
})
}
}
handleVisibleChanges = (boll) => {
if (this.state.visiblemys === true) {
this.setState({
visiblemyss: boll,
visiblemys: false,
})
} else {
this.setState({
visiblemyss: boll,
})
}
}
setdatafunsval = (e) => {
this.setState({
2020-04-28 17:23:34 +08:00
keyword: e.target.value
2020-03-16 14:12:11 +08:00
})
}
setdatafuns = (value) => {
2020-04-28 17:23:34 +08:00
2020-03-16 14:12:11 +08:00
this.setState({
2020-04-28 17:23:34 +08:00
keyword: value,
2020-03-16 14:12:11 +08:00
})
var data = {
2020-04-28 17:23:34 +08:00
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
2020-03-16 14:12:11 +08:00
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
2020-04-28 17:23:34 +08:00
keyword: value,
page: 1,
per_page: 10,
oj_status: this.state.oj_status
2020-03-16 14:12:11 +08:00
};
this.getdata(data);
}
deletetimu = (id) => {
const url = `/item_banks/${id}.json`;
axios.delete(url)
.then((response) => {
if (response.data.status == 0) {
var data = {
2020-04-28 17:23:34 +08:00
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
2020-03-16 14:12:11 +08:00
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
2020-04-28 17:23:34 +08:00
keyword: this.state.keywords,
2020-03-16 14:12:11 +08:00
page: this.state.page,
2020-04-28 17:23:34 +08:00
per_page: 10,
2020-03-16 14:12:11 +08:00
};
2020-04-28 17:23:34 +08:00
this.getdata(data, true);
2020-03-16 14:12:11 +08:00
}
})
.catch(function (error) {
});
}
2020-04-28 17:23:34 +08:00
//设为公开
2020-03-16 14:12:11 +08:00
publicopentimu = (id) => {
const url = `/item_banks/${id}/set_public.json`;
axios.post(url)
.then((result) => {
if (result.data.status == 0) {
var data = {
2020-04-28 17:23:34 +08:00
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
2020-03-16 14:12:11 +08:00
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
2020-04-28 17:23:34 +08:00
keyword: this.state.keywords,
2020-03-16 14:12:11 +08:00
page: this.state.page,
2020-04-28 17:23:34 +08:00
per_page: 10,
2020-03-16 14:12:11 +08:00
};
2020-04-28 17:23:34 +08:00
this.getdata(data, true);
2020-03-16 14:12:11 +08:00
}
}).catch((error) => {
2020-04-28 17:23:34 +08:00
////console.log(error);
})
}
//设为私有
Setasprivate = (id) => {
const url = `/item_banks/${id}/set_private.json`;
axios.post(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.getdata(data, true);
}
}).catch((error) => {
////console.log(error);
})
}
//跳转道描点的地方
scrollToAnchor = (anchorName) => {
if (anchorName) {
// 找到锚点
let anchorElement = document.getElementById(anchorName);
// 如果对应id的锚点存在就跳转到锚点
if (anchorElement) {
anchorElement.scrollIntoView();
}
}
2020-03-16 14:12:11 +08:00
}
getbasket_listdata = () => {
// 获取试题篮展开的数据
const url = "/item_baskets/basket_list.json";
axios.get(url)
.then((result) => {
2020-04-28 17:23:34 +08:00
this.setState({
completion_questions_count: result.data.completion_questions_count,
judgement_questions_count: result.data.judgement_questions_count,
multiple_questions_count: result.data.multiple_questions_count,
practical_questions_count: result.data.practical_questions_count,
program_questions_count: result.data.program_questions_count,
single_questions_count: result.data.single_questions_count,
subjective_questions_count: result.data.subjective_questions_count,
})
2020-03-16 14:12:11 +08:00
}).catch((error) => {
2020-04-28 17:23:34 +08:00
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,
})
2020-03-16 14:12:11 +08:00
})
}
2020-04-28 17:23:34 +08:00
// 不选用 NewMyShixunModel.js 页面也有个
NOgetitem_baskets = (data) => {
let url = "/examination_banks/cancel_items.json";
2020-03-16 14:12:11 +08:00
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
// this.props.showNotification(`选用成功`);
var data = {
2020-04-28 17:23:34 +08:00
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
2020-03-16 14:12:11 +08:00
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
2020-04-28 17:23:34 +08:00
keyword: this.state.keywords,
2020-03-16 14:12:11 +08:00
page: this.state.page,
2020-04-28 17:23:34 +08:00
per_page: 10,
2020-03-16 14:12:11 +08:00
};
this.getdatasy(data);
this.getbasket_listdata();
}
}).catch((error) => {
2020-04-28 17:23:34 +08:00
////console.log(error);
})
2020-03-16 14:12:11 +08:00
}
2020-04-28 17:23:34 +08:00
//选用 NewMyShixunModel.js 页面也有个
getitem_baskets = (data) => {
2020-03-16 14:12:11 +08:00
//选用题型可以上传单个 或者多个题型
2020-04-28 17:23:34 +08:00
let url = "/item_baskets.json";
2020-03-16 14:12:11 +08:00
2020-04-28 17:23:34 +08:00
axios.post(url, data)
2020-03-16 14:12:11 +08:00
.then((result) => {
if (result.data.status == 0) {
2020-04-28 17:23:34 +08:00
// this.props.showNotification(`选用成功`);
2020-03-16 14:12:11 +08:00
var data = {
2020-04-28 17:23:34 +08:00
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
2020-03-16 14:12:11 +08:00
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
2020-04-28 17:23:34 +08:00
keyword: this.state.keywords,
2020-03-16 14:12:11 +08:00
page: this.state.page,
2020-04-28 17:23:34 +08:00
per_page: 10,
2020-03-16 14:12:11 +08:00
};
this.getdatasy(data);
this.getbasket_listdata();
2020-04-28 17:23:34 +08:00
// this.setState({
// visible:true
// })
2020-03-16 14:12:11 +08:00
}
}).catch((error) => {
2020-04-28 17:23:34 +08:00
////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);
})
}
2020-03-16 14:12:11 +08:00
}
//全选试题库
2020-04-28 17:23:34 +08:00
selectallquestionsonthispage = (bool) => {
if (bool === true) {
//bool 是选中状态
let {
completion_questions_count, judgement_questions_count, multiple_questions_count, practical_questions_count,
program_questions_count, single_questions_count, subjective_questions_count,
} = this.state;
const Datacount = completion_questions_count + judgement_questions_count
+ multiple_questions_count + practical_questions_count
+ program_questions_count
+ single_questions_count
+ subjective_questions_count;
if (Datacount === 100) {
this.props.showNotification(`已选100个试题不能在选用更多试题`);
return;
}
}
if (myGrandtotal === true) {
this.props.showNotification(`本页全部试题未发布,不能选择`);
return
}
var item_idsdata = [];
var arr = this.state.Contentdata.items;
for (let data of arr) {
if (data.item_type === "PROGRAM") {
2020-03-16 14:12:11 +08:00
//编程题
2020-04-28 17:23:34 +08:00
if (data.choosed === true) {
if (data.program_attr.status === 1) {
//已发布
item_idsdata.push(data.id);
}
} else {
2020-03-16 14:12:11 +08:00
//未选用
2020-04-28 17:23:34 +08:00
if (data.program_attr.status === 1) {
2020-03-16 14:12:11 +08:00
//已发布
item_idsdata.push(data.id);
}
}
2020-04-28 17:23:34 +08:00
} else {
2020-03-16 14:12:11 +08:00
//不是编程题
2020-04-28 17:23:34 +08:00
if (data.choosed === true) {
item_idsdata.push(data.id);
} else {
2020-03-16 14:12:11 +08:00
//未选用
item_idsdata.push(data.id);
}
}
}
2020-04-28 17:23:34 +08:00
const data = {
item_ids: item_idsdata
}
if (bool === false) {
this.getitem_baskets(data);
this.setState({
selectallquestionsonthispages: true,
})
} else {
this.NOgetitem_baskets(data);
this.setState({
selectallquestionsonthispages: false,
})
2020-03-16 14:12:11 +08:00
}
2020-04-28 17:23:34 +08:00
}
2020-03-16 14:12:11 +08:00
//全选的状态
2020-04-28 17:23:34 +08:00
//删除大题型
Deletebigquestiontype = (item_type) => {
const url = `/item_baskets/delete_item_type.json`;
axios.delete((url), {
data: {
item_type: item_type
}
})
2020-03-16 14:12:11 +08:00
.then((response) => {
if (response.data.status == 0) {
// this.props.showNotification('删除成功');
var data = {
2020-04-28 17:23:34 +08:00
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
2020-03-16 14:12:11 +08:00
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
2020-04-28 17:23:34 +08:00
keyword: this.state.keywords,
2020-03-16 14:12:11 +08:00
page: this.state.page,
2020-04-28 17:23:34 +08:00
per_page: 10,
2020-03-16 14:12:11 +08:00
};
this.getdata(data);
this.getbasket_listdata();
}
})
.catch(function (error) {
////console.log(error);
});
}
2020-04-28 17:23:34 +08:00
HideAddcoursestypess = (i) => {
console.log("调用了");
this.setState({
mydisplay: true,
occupation: i,
})
}
2020-03-16 14:12:11 +08:00
2020-04-28 17:23:34 +08:00
mydisplayHidedel = () => {
this.setState({
mydisplay: false,
})
}
2020-03-16 14:12:11 +08:00
//跳转
2020-04-28 17:23:34 +08:00
gotopaperreview = () => {
let isysladmins = false;
if (this.props) {
if (this.props.current_user) {
if (this.props.current_user.admin) {
isysladmins = true;
}
else if (this.props.current_user.business) {
isysladmins = true;
}
}
}
2020-03-16 14:12:11 +08:00
this.props.history.replace("/paperreview/artificial");
}
2020-04-28 17:23:34 +08:00
setoj_status = (oj_status) => {
2020-03-16 14:12:11 +08:00
//编程题发布未发布
this.setState({
2020-04-28 17:23:34 +08:00
selectallquestionsonthispages: false,
difficulty: null,
oj_status: oj_status
2020-03-16 14:12:11 +08:00
})
var data = {
2020-04-28 17:23:34 +08:00
discipline_id: this.state.discipline_id,
sub_discipline_id: this.state.sub_discipline_id,
tag_discipline_id: this.state.tag_discipline_id,
2020-03-16 14:12:11 +08:00
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
2020-04-28 17:23:34 +08:00
keyword: this.state.keywords,
2020-03-16 14:12:11 +08:00
page: this.state.page,
2020-04-28 17:23:34 +08:00
per_page: 10,
oj_status: oj_status
2020-03-16 14:12:11 +08:00
};
this.getdata(data);
}
render() {
let {
2020-04-28 17:23:34 +08:00
page, per_page, items_count, Headertop, visible, placement, modalsType, modalsTypes, basket_list,
2020-03-16 14:12:11 +08:00
completion_questions_count, judgement_questions_count, multiple_questions_count, practical_questions_count,
2020-04-28 17:23:34 +08:00
program_questions_count, single_questions_count, subjective_questions_count, selectionbools,
modalsTypeInaudit, mydisplay
2020-03-16 14:12:11 +08:00
} = this.state;
const Datacount = completion_questions_count + judgement_questions_count
+ multiple_questions_count + practical_questions_count
+ program_questions_count
+ single_questions_count
+ subjective_questions_count;
2020-04-28 17:23:34 +08:00
let isysladmins = false;
const is_teacher = this.props && this.props.current_user && this.props.current_user.is_teacher ? this.props.current_user.is_teacher : false;
const professional_certification = this.props && this.props.current_user && this.props.current_user.professional_certification ? this.props.current_user.professional_certification : false;
try {
if (this.props) {
if (this.props.current_user) {
if (this.props.current_user.admin) {
isysladmins = true;
}
else if (this.props.current_user.business) {
isysladmins = true;
}
}
}
} catch (e) {
2020-03-16 14:12:11 +08:00
2020-04-28 17:23:34 +08:00
}
let Periofters = false;
if (this.props) {
if (this.props.current_user) {
if (this.props.current_user.admin) {
Periofters = true;
}
else if (this.props.current_user.business) {
Periofters = true;
}
else if (this.props.current_user.is_shixun_marker) {
Periofters = true;
}
else if (this.props.current_user.is_teacher) {
Periofters = true;
} else if (this.props.current_user.user_identity !== "学生") {
Periofters = true;
}
}
}
2020-03-16 14:12:11 +08:00
return (
2020-04-28 17:23:34 +08:00
<div className="newMain clearfix" ref={this.saveContainer}>
{
mydisplay === true ?
<Certifiedprofessional {...this.props} {...this.state} ModalCancelsy={this.mydisplayHidedel} />
: ""
}
{
mydisplay === true ?
<style>
{
`
body{
overflow:hidden!important;
}
`
}
</style>
: ""
}
{
visible === true ?
<style>
{
`
2020-03-16 14:12:11 +08:00
.ant-drawer {
z-index: 800 !important;
}
.ant-notification{
position: fixed;
z-index: 1500 !important;
}
2020-04-28 17:23:34 +08:00
2020-03-16 14:12:11 +08:00
`
}
</style>
2020-04-28 17:23:34 +08:00
: ""
2020-03-16 14:12:11 +08:00
}
2020-04-28 17:23:34 +08:00
2020-03-16 14:12:11 +08:00
<div
2020-04-28 17:23:34 +08:00
style={{
marginTop: "81px"
}}></div>
2020-03-16 14:12:11 +08:00
{
2020-04-28 17:23:34 +08:00
modalsTypes === true ?
2020-03-16 14:12:11 +08:00
<QuestionModals {...this.props}{...this.state} modalsTypes={modalsTypes} modalCancels={() => this.modalCancels()}
2020-04-28 17:23:34 +08:00
setDownloads={(e) => this.setDownloads(e)}></QuestionModals>
: ""
2020-03-16 14:12:11 +08:00
}
{
2020-04-28 17:23:34 +08:00
modalsType === true ?
2020-03-16 14:12:11 +08:00
<QuestionModal {...this.props}{...this.state} modalsType={modalsType} modalCancel={() => this.modalCancel()}
2020-04-28 17:23:34 +08:00
setDownload={() => this.setDownload()}></QuestionModal>
: ""
}
{
modalsTypeInaudit === true ?
<QuestionModalys {...this.props}{...this.state} modalsType={modalsTypeInaudit} modalCancel={() => this.modalsTypeInauditbool()}
setDownload={() => this.modalsTypeInauditbool()}></QuestionModalys>
: ""
2020-03-16 14:12:11 +08:00
}
<style>
{
`
.-task-sidebar{
height: 30%;
}
`
}
</style>
{
2020-04-28 17:23:34 +08:00
Periofters === false ?
<SiderBar
{...this.props}
{...this.state}
showDrawer={() => this.showDrawer()}
Headertop={Headertop} />
:
2020-03-16 14:12:11 +08:00
<SiderBars
Datacount={Datacount}
myvisible={visible}
{...this.props}
{...this.state}
showDrawer={() => this.showDrawer()}
Headertop={Headertop}
/>
}
{/*顶部*/}
2020-04-28 17:23:34 +08:00
<div id={"questionid"}></div>
2020-03-16 14:12:11 +08:00
<Headplugselections
disciplinesdata={this.state.disciplinesdata}
{...this.props}
{...this.state}
setdifficulty={(e) => this.setdifficulty(e)}
setitem_types={(e) => this.setitem_types(e)}
2020-04-28 17:23:34 +08:00
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)}
2020-03-16 14:12:11 +08:00
/>
{/*头部*/}
<Contentpart {...this.state} {...this.props}
2020-04-28 17:23:34 +08:00
pages={this.state.page}
Isitapopup={"false"}
Datacount={Datacount}
Datacountbool={true}
chakanjiexiboolindex={this.state.chakanjiexiboolindex}
chakanjiexibool={(e) => this.chakanjiexibool(e)}
getitem_basketss={(id) => this.getitem_basketss(id)}
selectallquestionsonthispage={(bool) => this.selectallquestionsonthispage(bool)}
getitem_baskets={(e) => this.getitem_baskets(e)}
setdatafuns={(e) => this.setdatafuns(e)}
setdatafunsval={(e) => this.setdatafunsval(e)}
handleVisibleChanges={(e) => this.handleVisibleChanges(e)}
handleVisibleChange={(e) => this.handleVisibleChange(e)}
showmodels={(e) => this.showmodels(e)}
showmodelysl={(e) => this.showmodelysl(e)}
callback={(e) => this.callback(e)}
setoj_status={(e) => this.setoj_status(e)}
showmodelsInaudit={(e) => this.showmodelsInaudit(e)}
setasprivates={(e) => this.setasprivates(e)}
></Contentpart>
2020-03-16 14:12:11 +08:00
{
2020-04-28 17:23:34 +08:00
items_count && items_count > 10 ?
<div className="mb60 clearfix educontent mt40 intermediatecenter">
2020-03-16 14:12:11 +08:00
<Pagination showQuickJumper current={page} onChange={this.paginationonChange}
2020-04-28 17:23:34 +08:00
pageSize={per_page}
total={items_count}></Pagination>
2020-03-16 14:12:11 +08:00
</div>
2020-04-28 17:23:34 +08:00
: <div className="h30 clearfix educontent mt40 intermediatecenter">
2020-03-16 14:12:11 +08:00
</div>
}
{/*抽屉效果*/}
<style>
{
`
.ant-drawer-content-wrapper{
2020-04-28 17:23:34 +08:00
width: 160px !important;
2020-03-16 14:12:11 +08:00
overflowhidden;
margin-top: 62px;
}
.ant-drawer-body{
height: 100%;
background:rgba(234,234,234,1);
}
.ant-drawer-close{
height: 40px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color:#ffffff;
}
.ant-drawer-close:hover{
color:#ffffff;
}
.ant-drawer-close:active{
color:#ffffff;
}
`
}
</style>
<Drawer
className="drawercontainer"
placement={placement}
closable={false}
onClose={() => this.onClose()}
visible={visible}
mask={false}
>
{Datacount && Datacount > 0 ?
<div>
<div className="shitilang">
试题篮
</div>
<div className="mt25 mb26">
</div>
{
single_questions_count === 0 ?
""
: <div className="sortinxdirection " >
<p
2020-04-28 17:23:34 +08:00
className="w80s intermediatecenterysls sortinxdirection font-14 xiaoshou xiaoshoums">单选题{'('}{single_questions_count}{')'}</p>
<p className="w20s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor " onClick={() => this.showQuestionModals("SINGLE")}></i></p>
2020-03-16 14:12:11 +08:00
</div>
}
{
multiple_questions_count === 0 ?
""
:
<div className="sortinxdirection" >
<p
2020-04-28 17:23:34 +08:00
className="w80s intermediatecenterysls sortinxdirection font-14 xiaoshou xiaoshoums">多选题{'('}{multiple_questions_count}{')'}</p>
<p className="w20s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor " onClick={() => this.showQuestionModals("MULTIPLE")}></i></p>
2020-03-16 14:12:11 +08:00
</div>
}
{
judgement_questions_count === 0 ?
""
:
<div className="sortinxdirection" >
<p
2020-04-28 17:23:34 +08:00
className="w80s intermediatecenterysls sortinxdirection font-14 xiaoshou xiaoshoums">判断题{'('}{judgement_questions_count}{')'}</p>
<p className="w20s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor " onClick={() => this.showQuestionModals("JUDGMENT")}></i></p>
2020-03-16 14:12:11 +08:00
</div>
}
{
completion_questions_count === 0 ?
""
:
<div className="sortinxdirection" >
<p
2020-04-28 17:23:34 +08:00
className="w80s intermediatecenterysls sortinxdirection font-14 xiaoshou xiaoshoums">填空题{'('}{completion_questions_count}{')'}</p>
<p className="w20s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor " onClick={() => this.showQuestionModals("COMPLETION")}></i></p>
2020-03-16 14:12:11 +08:00
</div>
}
{
subjective_questions_count === 0 ?
""
:
<div className="sortinxdirection" >
<p
2020-04-28 17:23:34 +08:00
className="w80s intermediatecenterysls sortinxdirection font-14 xiaoshou xiaoshoums">简答题{'('}{subjective_questions_count}{')'}</p>
<p className="w20s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor " onClick={() => this.showQuestionModals("SUBJECTIVE")}></i></p>
2020-03-16 14:12:11 +08:00
</div>
}
{
practical_questions_count === 0 ?
""
:
<div className="sortinxdirection">
<p
2020-04-28 17:23:34 +08:00
className="w80s intermediatecenterysls sortinxdirection font-14 xiaoshou xiaoshoums">实训题{'('}{practical_questions_count}{')'}</p>
<p className="w20s intermediatecenterysls xaxisreverseorder"><i
2020-03-16 14:12:11 +08:00
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor "></i></p>
</div>
}
{
program_questions_count === 0 ?
""
:
<div className="sortinxdirection" >
<p
2020-04-28 17:23:34 +08:00
className="w80s intermediatecenterysls sortinxdirection font-14 xiaoshou xiaoshoums">编程题{'('}{program_questions_count}{')'}</p>
<p className="w20s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor " onClick={() => this.showQuestionModals("PROGRAM")}></i></p>
2020-03-16 14:12:11 +08:00
</div>
}
<div className="intermediatecenter verticallayout mt42">
2020-04-28 17:23:34 +08:00
<div className="drawerbutton xiaoshou" onClick={() => this.gotopaperreview()}>
2020-03-16 14:12:11 +08:00
试卷预览
</div>
</div>
</div>
:
<div className="drawernonedatadiv intermediatecenter">
<NoneData></NoneData>
</div>
}
</Drawer>
</div>
)
}
}
export default SnackbarHOC()(TPMIndexHOC(Question));