From e67b131f5c5bd0b3f4cc979916c533dc16a22fff Mon Sep 17 00:00:00 2001
From: harry
Date: Sat, 14 Mar 2020 21:37:04 +0800
Subject: [PATCH] fix
---
public/react/src/modules/question/Question.js | 331 +++++++++---------
1 file changed, 167 insertions(+), 164 deletions(-)
diff --git a/public/react/src/modules/question/Question.js b/public/react/src/modules/question/Question.js
index fb87641e3..26fec6831 100644
--- a/public/react/src/modules/question/Question.js
+++ b/public/react/src/modules/question/Question.js
@@ -1,7 +1,11 @@
+
import React, { Component } from "react";
import { SnackbarHOC } from 'educoder';
import axios from 'axios';
-import { Pagination, Drawer } from "antd";
+import {
+ Pagination,
+ Drawer,
+} from "antd";
import Headplugselections from "./component/Headplugselections";
import QuestionModal from "./component/QuestionModal";
import QuestionModals from "./component/QuestionModals";
@@ -13,8 +17,8 @@ import SiderBars from "../question/component/SiderBars";
import QuestionModalys from "./component/QuestionModalys";
import Certifiedprofessional from "../modals/Certifiedprofessional";
-var Undoclickable=true;
-var myGrandtotal=false;
+var Undoclickable = true;
+var myGrandtotal = false;
class Question extends Component {
constructor(props) {
super(props);
@@ -60,10 +64,10 @@ class Question extends Component {
selectallquestionsonthispages: false,
oj_status: null,
isVisible: false,
- selectionbools:false,
- chakanjiexiboolindex:"无",
- mydisplay:false,
- occupation:2,
+ selectionbools: false,
+ chakanjiexiboolindex: "无",
+ mydisplay: false,
+ occupation: 2,
@@ -115,13 +119,13 @@ class Question extends Component {
setsub_discipline_id = (discipline_id, sub_discipline_id) => {
this.setState({
- sub_discipline_id:sub_discipline_id,
- discipline_id:discipline_id,
- tag_discipline_id:null,
- keyword:"",
- page:1,
- per_page:10,
- oj_status:null
+ sub_discipline_id: sub_discipline_id,
+ discipline_id: discipline_id,
+ tag_discipline_id: null,
+ keyword: "",
+ page: 1,
+ per_page: 10,
+ oj_status: null
})
var data = {
discipline_id: discipline_id,
@@ -229,11 +233,10 @@ class Question extends Component {
})
}
- axios.get((url), {params: data}).then((response) => {
- this.setState({
- booljupyterurls: false,
- })
- },500);
+ axios.get((url), { params: data }).then((response) => {
+ this.setState({
+ booljupyterurls: false,
+ })
if (response === null || response === undefined) {
return
@@ -295,22 +298,22 @@ class Question extends Component {
}
//计算
- getdataslen=(arr)=>{
- myGrandtotal=false;
- let contes=0;
- let Grandtotal=0;
- for(let data of arr) {
- if(data.item_type==="PROGRAM"){
+ getdataslen = (arr) => {
+ myGrandtotal = false;
+ let contes = 0;
+ let Grandtotal = 0;
+ for (let data of arr) {
+ if (data.item_type === "PROGRAM") {
//编程题
if (data.choosed === true) {
} else {
//未选用
- if(data.program_attr.status===1){
+ if (data.program_attr.status === 1) {
//已发布1 未发布0
- contes=contes+1;
- }else{
- Grandtotal=Grandtotal+1;
+ contes = contes + 1;
+ } else {
+ Grandtotal = Grandtotal + 1;
}
}
@@ -334,22 +337,22 @@ class Question extends Component {
})
} else {
try {
- if(arr.length===Grandtotal){
- myGrandtotal=true;
+ if (arr.length === Grandtotal) {
+ myGrandtotal = true;
this.setState({
- selectionbools:false,
- selectallquestionsonthispages:false,
+ selectionbools: false,
+ selectallquestionsonthispages: false,
})
- }else{
+ } else {
this.setState({
- selectionbools:true,
- selectallquestionsonthispages:true,
+ selectionbools: true,
+ selectallquestionsonthispages: true,
})
}
- }catch (e) {
+ } catch (e) {
this.setState({
- selectionbools:true,
- selectallquestionsonthispages:true,
+ selectionbools: true,
+ selectallquestionsonthispages: true,
})
}
@@ -645,17 +648,17 @@ class Question extends Component {
const url = "/item_baskets/basket_list.json";
axios.get(url)
.then((result) => {
- // ////console.log("getbasket_listdata");
- // ////console.log(result.data);
- 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,
- })
+ // ////console.log("getbasket_listdata");
+ // ////console.log(result.data);
+ 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,
+ })
// Undoclickable=true;
}).catch((error) => {
@@ -669,29 +672,28 @@ class Question extends Component {
single_questions_count: 0,
subjective_questions_count: 0,
})
+ // Undoclickable=true;
})
- // Undoclickable=true;
- })
}
- // 不选用 NewMyShixunModel.js 页面也有个
- NOgetitem_baskets=(data)=>{
- let url="/examination_banks/cancel_items.json";
+ // 不选用 NewMyShixunModel.js 页面也有个
+ NOgetitem_baskets = (data) => {
+ let url = "/examination_banks/cancel_items.json";
axios.post(url, data)
.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,
+ 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();
@@ -700,12 +702,12 @@ class Question extends Component {
// })
}
}).catch((error) => {
- ////console.log(error);
- })
+ ////console.log(error);
+ })
}
- //选用 NewMyShixunModel.js 页面也有个
- getitem_baskets=(data)=>{
+ //选用 NewMyShixunModel.js 页面也有个
+ getitem_baskets = (data) => {
//选用题型可以上传单个 或者多个题型
let url = "/item_baskets.json";
@@ -734,52 +736,52 @@ class Question extends Component {
////console.log(error);
})
}
- // 撤销
- getitem_basketss=(id)=>{
- if(Undoclickable===true){
- Undoclickable=false;
+ // 撤销
+ getitem_basketss = (id) => {
+ if (Undoclickable === true) {
+ Undoclickable = false;
//选用题型可以上传单个 或者多个题型
- let url=`/item_baskets/${id}.json`;
+ 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,
+ 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();
}
- setTimeout(()=>{
- Undoclickable=true;
- },1000);
+ setTimeout(() => {
+ Undoclickable = true;
+ }, 1000);
}).catch((error) => {
- ////console.log(error);
- setTimeout(()=>{
- Undoclickable=true;
- },1000);
+ ////console.log(error);
+ setTimeout(() => {
+ Undoclickable = true;
+ }, 1000);
- })
+ })
- }else{
+ } else {
- return
+ return
}
}
//全选试题库
- selectallquestionsonthispage=(bool)=>{
- if(bool===true){
+ selectallquestionsonthispage = (bool) => {
+ if (bool === true) {
//bool 是选中状态
let {
completion_questions_count, judgement_questions_count, multiple_questions_count, practical_questions_count,
@@ -793,7 +795,7 @@ class Question extends Component {
+ subjective_questions_count;
- if(Datacount===100){
+ if (Datacount === 100) {
this.props.showNotification(`已选100个试题(不能在选用更多试题)`);
return;
}
@@ -802,7 +804,7 @@ class Question extends Component {
- if(myGrandtotal===true){
+ if (myGrandtotal === true) {
this.props.showNotification(`本页全部试题未发布,不能选择`);
return
}
@@ -810,18 +812,18 @@ class Question extends Component {
- var item_idsdata=[];
+ var item_idsdata = [];
var arr = this.state.Contentdata.items;
for (let data of arr) {
if (data.item_type === "PROGRAM") {
//编程题
- if(data.choosed===true){
- if(data.program_attr.status===1){
+ if (data.choosed === true) {
+ if (data.program_attr.status === 1) {
//已发布
item_idsdata.push(data.id);
}
- }else{
+ } else {
//未选用
if (data.program_attr.status === 1) {
//已发布
@@ -832,9 +834,9 @@ class Question extends Component {
} else {
//不是编程题
- if(data.choosed===true){
+ if (data.choosed === true) {
item_idsdata.push(data.id);
- }else{
+ } else {
//未选用
item_idsdata.push(data.id);
}
@@ -844,15 +846,15 @@ class Question extends Component {
const data = {
item_ids: item_idsdata
}
- if(bool===false){
+ if (bool === false) {
this.getitem_baskets(data);
this.setState({
- selectallquestionsonthispages:true,
+ selectallquestionsonthispages: true,
})
- }else{
+ } else {
this.NOgetitem_baskets(data);
this.setState({
- selectallquestionsonthispages:false,
+ selectallquestionsonthispages: false,
})
}
@@ -891,35 +893,35 @@ class Question extends Component {
});
}
- HideAddcoursestypess=(i)=>{
+ HideAddcoursestypess = (i) => {
console.log("调用了");
this.setState({
- mydisplay:true,
- occupation:i,
+ mydisplay: true,
+ occupation: i,
})
}
- mydisplayHidedel=()=>{
+ mydisplayHidedel = () => {
this.setState({
- mydisplay:false,
+ mydisplay: false,
})
}
//跳转
- gotopaperreview=()=>{
- let isysladmins=false;
- if(this.props){
- if(this.props.current_user){
- if(this.props.current_user.admin){
- isysladmins=true;
+ 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;
+ else if (this.props.current_user.business) {
+ isysladmins = true;
}
}
}
- if(this.props.current_user.professional_certification===false&&isysladmins===false){
+ if (this.props.current_user.professional_certification === false && isysladmins === false) {
this.HideAddcoursestypess(2);
return
}
@@ -956,8 +958,8 @@ class Question extends Component {
let {
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
+ program_questions_count, single_questions_count, subjective_questions_count, selectionbools,
+ modalsTypeInaudit, mydisplay
} = this.state;
const Datacount = completion_questions_count + judgement_questions_count
@@ -965,26 +967,26 @@ class Question extends Component {
+ program_questions_count
+ single_questions_count
+ subjective_questions_count;
- 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;
+ 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;
+ 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;
+ else if (this.props.current_user.business) {
+ isysladmins = true;
}
}
}
- }catch (e) {
+ } catch (e) {
}
return (
-
+
{
- mydisplay===true?
-
+ mydisplay === true ?
+
- :""
+ : ""
}
{
- mydisplay===true?
+ mydisplay === true ?
- :""
+ : ""
}
{
- visible===true?
+ visible === true ?
-
this.showDrawer()}
- Headertop={Headertop}
- />
+ this.showDrawer()}
+ Headertop={Headertop}
+
+ />
{/*顶部*/}
@@ -1098,24 +1101,24 @@ class Question extends Component {
/>
{/*头部*/}
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)}
+ 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)}
>
{
@@ -1186,7 +1189,7 @@ class Question extends Component {
单选题{'('}{single_questions_count}{')'}
this.showQuestionModals("SINGLE")}>
+ className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor " onClick={() => this.showQuestionModals("SINGLE")}>
}
{
@@ -1197,7 +1200,7 @@ class Question extends Component {
多选题{'('}{multiple_questions_count}{')'}
this.showQuestionModals("MULTIPLE")}>
+ className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor " onClick={() => this.showQuestionModals("MULTIPLE")}>
}
{
@@ -1208,7 +1211,7 @@ class Question extends Component {
判断题{'('}{judgement_questions_count}{')'}
this.showQuestionModals("JUDGMENT")}>
+ className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor " onClick={() => this.showQuestionModals("JUDGMENT")}>
}
{
@@ -1219,7 +1222,7 @@ class Question extends Component {
填空题{'('}{completion_questions_count}{')'}
this.showQuestionModals("COMPLETION")}>
+ className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor " onClick={() => this.showQuestionModals("COMPLETION")}>
}
{
@@ -1230,7 +1233,7 @@ class Question extends Component {
简答题{'('}{subjective_questions_count}{')'}
this.showQuestionModals("SUBJECTIVE")}>
+ className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor " onClick={() => this.showQuestionModals("SUBJECTIVE")}>
}
{
@@ -1252,7 +1255,7 @@ class Question extends Component {
编程题{'('}{program_questions_count}{')'}
this.showQuestionModals("PROGRAM")}>
+ className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor " onClick={() => this.showQuestionModals("PROGRAM")}>
}