调整选用试卷试题栏

yslnewtiku
杨树林 5 years ago
parent 5ca733ccbb
commit 367b31a87b

@ -1,6 +1,6 @@
import React, {Component} from "react"; import React, {Component} from "react";
import {Link, NavLink} from 'react-router-dom'; import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn,SnackbarHOC,getImageUrl} from 'educoder'; import {WordsBtn, ActionBtn, SnackbarHOC, getImageUrl} from 'educoder';
import axios from 'axios'; import axios from 'axios';
import { import {
notification, notification,
@ -10,60 +10,67 @@ import {
Drawer, Drawer,
Input Input
} from "antd"; } from "antd";
import Headplugselection from "./component/Headplugselection"; import Headplugselection from "./component/Headplugselection";
import QuestionModal from "./component/QuestionModal"; import QuestionModal from "./component/QuestionModal";
import Contentpart from "./component/Contentpart"; import Contentpart from "./component/Contentpart";
import {TPMIndexHOC} from "../tpm/TPMIndexHOC"; import {TPMIndexHOC} from "../tpm/TPMIndexHOC";
import NoneData from './component/NoneData'; import NoneData from './component/NoneData';
import './questioncss/questioncom.css'; import './questioncss/questioncom.css';
import SiderBar from "../tpm/SiderBar"; import SiderBar from "../tpm/SiderBar";
class Question extends Component { class Question extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
page:1, page: 1,
limit:20, limit: 20,
count:50, count: 50,
defaultActiveKey:1, defaultActiveKey: 1,
Headertop:"", Headertop: "",
Footerdown:"", Footerdown: "",
visible: false, visible: false,
placement: 'right', placement: 'right',
modalsType:false, modalsType: false,
titilesm:"设为公开后,所有成员均可使用试题", titilesm: "设为公开后,所有成员均可使用试题",
titiless:"是否设置为公开?", titiless: "是否设置为公开?",
titbool:false, titbool: false,
Contentdata:[], Contentdata: [],
difficulty:null, difficulty: null,
visiblemys:false, visiblemys: false,
visiblemyss:false, visiblemyss: false,
item_type:null, item_type: null,
keyword:null, keyword: null,
timuid:null, timuid: null,
items_count:0, items_count: 0,
basket_list:[], 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,
} }
} }
//初始化 //初始化
componentDidMount(){ componentDidMount() {
let {defaultActiveKey}= this.state; let {defaultActiveKey} = this.state;
var data={ var data = {
public:defaultActiveKey public: defaultActiveKey
}; };
this.getdata(data); this.getdata(data);
let url=`/users/get_navigation_info.json`; let url = `/users/get_navigation_info.json`;
axios.get(url, { axios.get(url, {}).then((response) => {
}).then((response) => {
// //console.log("开始请求/get_navigation_info.json"); // //console.log("开始请求/get_navigation_info.json");
// //console.log(response); // //console.log(response);
if(response!=undefined){ if (response != undefined) {
if(response.status===200){ if (response.status === 200) {
this.setState({ this.setState({
Headertop:response.data.top, Headertop: response.data.top,
Footerdown:response.data.down Footerdown: response.data.down
}) })
} }
} }
@ -72,36 +79,36 @@ class Question extends Component {
this.getbasket_listdata(); this.getbasket_listdata();
} }
callback=(key)=>{ callback = (key) => {
this.setState({ this.setState({
defaultActiveKey:key, defaultActiveKey: key,
}) })
var data={ var data = {
public:key, public: key,
item_type:this.state.item_type, item_type: this.state.item_type,
difficulty:this.state.difficulty, difficulty: this.state.difficulty,
}; };
this.getdata(data); this.getdata(data);
} }
getdata =(data)=>{ getdata = (data) => {
const url=`/item_banks.json`; const url = `/item_banks.json`;
axios.get((url),{params:data}).then((response) => { axios.get((url), {params: data}).then((response) => {
if(response===null||response===undefined){ if (response === null || response === undefined) {
return return
} }
if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) {
}else{ } else {
} }
//console.log("item_banks"); //console.log("item_banks");
//console.log(response); //console.log(response);
this.setState({ this.setState({
Contentdata:response.data, Contentdata: response.data,
items_count:response.data.items_count, items_count: response.data.items_count,
}) })
}).catch((error) => { }).catch((error) => {
//console.log(error) //console.log(error)
@ -109,7 +116,7 @@ class Question extends Component {
}); });
} }
paginationonChange=()=>{ paginationonChange = () => {
} }
showDrawer = () => { showDrawer = () => {
@ -137,134 +144,133 @@ class Question extends Component {
this.container = container; this.container = container;
}; };
showmodels=(id)=>{ showmodels = (id) => {
this.setState({ this.setState({
modalsType:true, modalsType: true,
titilesm:"设为公开后,所有成员均可使用试题", titilesm: "设为公开后,所有成员均可使用试题",
titiless:"是否设置为公开?", titiless: "是否设置为公开?",
titbool:true, titbool: true,
timuid:id timuid: id
}) })
}; };
showmodelysl=(id)=>{ showmodelysl = (id) => {
this.setState({ this.setState({
modalsType:true, modalsType: true,
titilesm:"确认删除后,无法撤销", titilesm: "确认删除后,无法撤销",
titiless:"是否确认删除?", titiless: "是否确认删除?",
titbool:false, titbool: false,
timuid:id timuid: id
}) })
}; };
modalCancel = () => {
modalCancel=()=>{ this.setState({
this.setState({ modalsType: false
modalsType:false })
})
} }
setDownload=()=>{ setDownload = () => {
//确认 //确认
if(this.state.titbool===true){ if (this.state.titbool === true) {
//公开 //公开
this.publicopentimu(this.state.timuid); this.publicopentimu(this.state.timuid);
}else { } else {
// 删除 // 删除
this.deletetimu(this.state.timuid); this.deletetimu(this.state.timuid);
} }
this.setState({ this.setState({
modalsType:false modalsType: false
}) })
} }
setdifficulty=(difficulty)=>{ setdifficulty = (difficulty) => {
this.setState({ this.setState({
difficulty:difficulty, difficulty: difficulty,
visiblemys:false, visiblemys: false,
}) })
var data={ var data = {
public:this.state.defaultActiveKey, public: this.state.defaultActiveKey,
difficulty:difficulty, difficulty: difficulty,
item_type:this.state.item_type, item_type: this.state.item_type,
}; };
this.getdata(data); this.getdata(data);
} }
setitem_types=(item_type)=>{ setitem_types = (item_type) => {
this.setState({ this.setState({
item_type:item_type, item_type: item_type,
visiblemyss:false, visiblemyss: false,
}) })
var data={ var data = {
public:this.state.defaultActiveKey, public: this.state.defaultActiveKey,
difficulty:this.state.difficulty, difficulty: this.state.difficulty,
item_type:item_type, item_type: item_type,
}; };
this.getdata(data); this.getdata(data);
} }
handleVisibleChange=(boll)=>{ handleVisibleChange = (boll) => {
if(this.state.visiblemyss===true){ if (this.state.visiblemyss === true) {
this.setState({ this.setState({
visiblemys:boll, visiblemys: boll,
visiblemyss:false, visiblemyss: false,
}) })
}else{ } else {
this.setState({ this.setState({
visiblemys:boll, visiblemys: boll,
}) })
} }
} }
handleVisibleChanges=(boll)=>{ handleVisibleChanges = (boll) => {
if(this.state.visiblemys===true){ if (this.state.visiblemys === true) {
this.setState({ this.setState({
visiblemyss:boll, visiblemyss: boll,
visiblemys:false, visiblemys: false,
}) })
}else{ } else {
this.setState({ this.setState({
visiblemyss:boll, visiblemyss: boll,
}) })
} }
} }
setdatafunsval=(e)=>{ setdatafunsval = (e) => {
this.setState({ this.setState({
keywords:e.target.value keywords: e.target.value
}) })
var data={ var data = {
public:this.state.defaultActiveKey, public: this.state.defaultActiveKey,
difficulty:this.state.difficulty, difficulty: this.state.difficulty,
item_type:this.state.item_type, item_type: this.state.item_type,
keywords:e.target.value, keywords: e.target.value,
}; };
this.getdata(data); this.getdata(data);
} }
setdatafuns =(value)=>{ setdatafuns = (value) => {
this.setState({ this.setState({
keywords:value, keywords: value,
}) })
var data={ var data = {
public:this.state.defaultActiveKey, public: this.state.defaultActiveKey,
difficulty:this.state.difficulty, difficulty: this.state.difficulty,
item_type:this.state.item_type, item_type: this.state.item_type,
keywords:value, keywords: value,
}; };
this.getdata(data); this.getdata(data);
} }
deletetimu=(id)=>{ deletetimu = (id) => {
const url = `/item_banks/${id}.json`; const url = `/item_banks/${id}.json`;
axios.delete(url) axios.delete(url)
@ -272,11 +278,11 @@ class Question extends Component {
if (response.data.status == 0) { if (response.data.status == 0) {
this.props.showNotification('删除试题成功') this.props.showNotification('删除试题成功')
// props.history.push(response.data.right_url) // props.history.push(response.data.right_url)
var data={ var data = {
public:this.state.defaultActiveKey, public: this.state.defaultActiveKey,
difficulty:this.state.difficulty, difficulty: this.state.difficulty,
item_type:this.state.item_type, item_type: this.state.item_type,
keywords:this.state.keywords, keywords: this.state.keywords,
}; };
this.getdata(data); this.getdata(data);
} }
@ -285,18 +291,18 @@ class Question extends Component {
console.log(error); console.log(error);
}); });
} }
publicopentimu=(id)=>{ publicopentimu = (id) => {
const url = `/item_banks/${id}/set_public.json`; const url = `/item_banks/${id}/set_public.json`;
axios.post(url) axios.post(url)
.then((result) => { .then((result) => {
if (result.data.status == 0) { if (result.data.status == 0) {
this.props.showNotification(`公开题目成功`); this.props.showNotification(`公开题目成功`);
var data={ var data = {
public:this.state.defaultActiveKey, public: this.state.defaultActiveKey,
difficulty:this.state.difficulty, difficulty: this.state.difficulty,
item_type:this.state.item_type, item_type: this.state.item_type,
keywords:this.state.keywords, keywords: this.state.keywords,
}; };
this.getdata(data); this.getdata(data);
} }
@ -305,23 +311,35 @@ class Question extends Component {
}) })
} }
getbasket_listdata=()=>{ getbasket_listdata = () => {
// 获取试题篮展开的数据 // 获取试题篮展开的数据
const url ="/item_baskets/basket_list.json"; const url = "/item_baskets/basket_list.json";
axios.post(url) axios.get(url)
.then((result) => { .then((result) => {
if (result.data.status == 0) { if (result.data.status == 0) {
console.log("getbasket_listdata"); console.log("getbasket_listdata");
console.log(result.data); console.log(result.data);
this.setState({ this.setState({
basket_list:result.data, 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,
}) })
} }
}).catch((error) => { }).catch((error) => {
console.log(error); console.log(error);
this.setState({ this.setState({
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,
}) })
}) })
@ -329,28 +347,41 @@ class Question extends Component {
render() { render() {
let {page,limit,count,Headertop,visible,placement,modalsType,basket_list}=this.state; let {
page, limit, count, Headertop, visible, placement, modalsType, basket_list,
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;
return ( return (
<div className="newMain clearfix" ref={this.saveContainer}> <div className="newMain clearfix" ref={this.saveContainer}>
<QuestionModal {...this.props}{...this.state} modalsType={modalsType} modalCancel={()=>this.modalCancel()} setDownload={()=>this.setDownload()}></QuestionModal> <QuestionModal {...this.props}{...this.state} modalsType={modalsType} modalCancel={() => this.modalCancel()}
setDownload={() => this.setDownload()}></QuestionModal>
<SiderBar <SiderBar
{...this.props} {...this.props}
{...this.state} {...this.state}
showDrawer={()=>this.showDrawer()} showDrawer={() => this.showDrawer()}
Headertop={Headertop}/> Headertop={Headertop}/>
{/*顶部*/} {/*顶部*/}
<Headplugselection ></Headplugselection> <Headplugselection></Headplugselection>
{/*头部*/} {/*头部*/}
<Contentpart {...this.state} {...this.props} <Contentpart {...this.state} {...this.props}
setdatafuns={(e)=>this.setdatafuns(e)} setdatafuns={(e) => this.setdatafuns(e)}
setdatafunsval={(e)=>this.setdatafunsval(e)} setdatafunsval={(e) => this.setdatafunsval(e)}
handleVisibleChanges={(e)=>this.handleVisibleChanges(e)} handleVisibleChanges={(e) => this.handleVisibleChanges(e)}
setitem_types={(e)=>this.setitem_types(e)} setitem_types={(e) => this.setitem_types(e)}
handleVisibleChange={(e)=>this.handleVisibleChange(e)} handleVisibleChange={(e) => this.handleVisibleChange(e)}
setdifficulty={(e)=>this.setdifficulty(e)} setdifficulty={(e) => this.setdifficulty(e)}
showmodels={(e)=>this.showmodels(e)} showmodels={(e) => this.showmodels(e)}
showmodelysl={(e)=>this.showmodelysl(e)} showmodelysl={(e) => this.showmodelysl(e)}
callback={(e)=>this.callback(e)}></Contentpart> callback={(e) => this.callback(e)}></Contentpart>
{/*分页*/} {/*分页*/}
{/*<div className="clearfix mt5">*/} {/*<div className="clearfix mt5">*/}
{/*<div className="educontent mt10 pb20 w1200s">*/} {/*<div className="educontent mt10 pb20 w1200s">*/}
@ -379,31 +410,105 @@ class Question extends Component {
getContainer={this.getContainer} getContainer={this.getContainer}
placement={placement} placement={placement}
closable={false} closable={false}
onClose={()=>this.onClose()} onClose={() => this.onClose()}
visible={visible} visible={visible}
> >
{
basket_list&&basket_list.length===0?
<div className="drawernonedatadiv intermediatecenter">
<NoneData></NoneData>
</div>
:
<div>
<div className="mt25 mb26">
<Input placeholder="未命名试卷" />
</div>
<div className="sortinxdirection">
<p className="w50s intermediatecenterysls sortinxdirection font-14">单选题</p>
<p className="w50s intermediatecenterysls xaxisreverseorder"><i className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor "></i></p>
</div>
<div className="intermediatecenter verticallayout mt42"> {Datacount && Datacount > 0 ?
<div className="drawerbutton"> <div>
试卷预览 <div className="mt25 mb26">
<Input placeholder="未命名试卷"/>
</div>
{
single_questions_count === 0 ?
""
: <div className="sortinxdirection">
<p
className="w50s intermediatecenterysls sortinxdirection font-14">单选题{'('}{single_questions_count}{')'}</p>
<p className="w50s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor "></i></p>
</div>
}
{
multiple_questions_count === 0 ?
""
:
<div className="sortinxdirection">
<p
className="w50s intermediatecenterysls sortinxdirection font-14">多选题{'('}{multiple_questions_count}{')'}</p>
<p className="w50s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor "></i></p>
</div>
}
{
judgement_questions_count === 0 ?
""
:
<div className="sortinxdirection">
<p
className="w50s intermediatecenterysls sortinxdirection font-14">判断题{'('}{judgement_questions_count}{')'}</p>
<p className="w50s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor "></i></p>
</div>
}
{
completion_questions_count === 0 ?
""
:
<div className="sortinxdirection">
<p
className="w50s intermediatecenterysls sortinxdirection font-14">填空题{'('}{completion_questions_count}{')'}</p>
<p className="w50s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor "></i></p>
</div>
}
{
subjective_questions_count === 0 ?
""
:
<div className="sortinxdirection">
<p
className="w50s intermediatecenterysls sortinxdirection font-14">简答题{'('}{subjective_questions_count}{')'}</p>
<p className="w50s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor "></i></p>
</div>
}
{
practical_questions_count === 0 ?
""
:
<div className="sortinxdirection">
<p
className="w50s intermediatecenterysls sortinxdirection font-14">实训题{'('}{practical_questions_count}{')'}</p>
<p className="w50s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor "></i></p>
</div> </div>
}
{
program_questions_count === 0 ?
""
:
<div className="sortinxdirection">
<p
className="w50s intermediatecenterysls sortinxdirection font-14">编程题{'('}{program_questions_count}{')'}</p>
<p className="w50s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor "></i></p>
</div>
}
<div className="intermediatecenter verticallayout mt42">
<div className="drawerbutton">
试卷预览
</div> </div>
</div> </div>
</div>
:
<div className="drawernonedatadiv intermediatecenter">
<NoneData></NoneData>
</div>
} }
</Drawer> </Drawer>
@ -413,6 +518,7 @@ class Question extends Component {
} }
} }
export default SnackbarHOC() (TPMIndexHOC ( Question ));
export default SnackbarHOC()(TPMIndexHOC(Question));

Loading…
Cancel
Save