You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/public/react/src/modules/testpaper/component/Paperlibraryseeid_itemss.js

792 lines
23 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import React, {Component} from "react";
import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn, getImageUrl} from 'educoder';
import axios from 'axios';
import {
notification,
Spin,
Table,
Pagination,
Drawer,
Input,
Button,
Breadcrumb
} from "antd";
import '../../question/questioncss/questioncom.css';
import '../../tpm/newshixuns/css/Newshixuns.css';
import {DragDropContext, Draggable, Droppable} from 'react-beautiful-dnd';
import PaperDeletModel from '../../question/component/PaperDeletModel';
import PaperDeletModels from '../../question/component/PaperDeletModels';
import Paperreview_itemModel from '../../question/component/Paperreview_itemModel';
import Paperreview_itemModels from '../../question/component/Paperreview_itemModels';
import Paperlibraryseeid_itemsss from './Paperlibraryseeid_itemsss';
const reorder = (list, startIndex, endIndex) => {
const result = Array.from(list);
const [removed] = result.splice(startIndex, 1);
result.splice(endIndex, 0, removed);
return result;
};
//这不是唯一的 试题库还有 Paperreview_item.js
class Paperlibraryseeid_itemss extends Component {
constructor(props) {
super(props);
this.state = {
questions: 0,
totalscore: 0,
total: 0,
modalsTypedel: false,
modalsTypey: false,
modalsTypeys: false,
modalsTypedels: false,
titilesm: "",
titilesms: "",
singlebool: false,
multiplebool: false,
judgmentbool: false,
programbool: false,
paperreviewsingleindex: "无",
set_scoreid:null,
item_bank_id:null
}
}
//初始化
componentDidMount() {
}
getdata = (data) => {
}
preservation = () => {
}
setitem_type = (item_type) => {
}
onDragEnd = (result) => {
const ids = this.props.single_questions.questions[result.source.index].id;
const positions = this.props.single_questions.questions[result.destination.index].position;
const url = `/examination_items/${ids}/adjust_position.json`;
var data = {
position: positions
}
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
// this.props.showNotification(`拖动成功`);
this.props.getdata({});
}
}).catch((error) => {
//console.log(error);
})
}
onDragEnds = (result) => {
const ids = this.props.multiple_questions.questions[result.source.index].id;
const positions = this.props.multiple_questions.questions[result.destination.index].position;
const url =`/examination_items/${ids}/adjust_position.json`;
var data = {
position: positions
}
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
// this.props.showNotification(`拖动成功`);
this.props.getdata({});
}
}).catch((error) => {
//console.log(error);
})
}
onDragEndss = (result) => {
const ids = this.props.judgement_questions.questions[result.source.index].id;
const positions = this.props.judgement_questions.questions[result.destination.index].position;
const url = `/examination_items/${ids}/adjust_position.json`;
var data = {
position: positions
}
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
// this.props.showNotification(`拖动成功`);
this.props.getdata({});
}
}).catch((error) => {
//console.log(error);
})
}
onDragEndsss = (result) => {
const ids = this.props.program_questions.questions[result.source.index].id;
const positions = this.props.program_questions.questions[result.destination.index].position;
const url = `/examination_items/${ids}/adjust_position.json`;
var data = {
position: positions
}
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
// this.props.showNotification(`拖动成功`);
this.props.getdata({});
}
}).catch((error) => {
//console.log(error);
})
}
Singlemagazine = (name, bool) => {
if (bool === true) {
this.setState({
modalsTypey: true,
titilesm: name
})
} else {
this.setState({
modalsTypey: false,
titilesm: ""
})
}
}
setDownloady = (fenshu) => {
const url = "/examination_items/batch_set_score.json";
var data = {
exam_id:this.props.match.params.id,
score: fenshu,
item_type: this.state.titilesm === "单选题" ? "SINGLE" : this.state.titilesm === "多选题" ? "MULTIPLE" : this.state.titilesm === "判断题" ? "JUDGMENT" : this.state.titilesm === "编程题" ? "PROGRAM" : '',
}
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
// this.props.showNotification(`调分成功`);
this.props.getdata({});
this.Singlemagazine("", false);
}
}).catch((error) => {
//console.log(error);
})
}
setDownloadys=(value)=>{
const url = `/examination_items/${this.state.set_scoreid}/set_score.json`;
var data = {
score: value,
}
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
// this.props.showNotification(`调分成功`);
this.props.getdata({});
this.Singlemagazines(false);
}
}).catch((error) => {
//console.log(error);
})
}
Singlemagazines=(bool,id,name)=>{
if(bool===true){
this.setState({
set_scoreid:id,
modalsTypeys:bool,
titilesm: name
})
}else{
this.setState({
modalsTypeys:bool,
set_scoreid:null,
titilesm: null
})
}
}
setmodalsTypedel = (bool, type, names) => {
if (type === 1) {
this.setState({
modalsTypedel: bool,
titilesms: names
})
} else {
this.setState({
modalsTypedel: bool,
titilesms: names
})
const url = `/examination_items/delete_item_type.json`;
axios.delete((url), {
data: {
exam_id:this.props.match.params.id,
item_type: names
}
})
.then((response) => {
if (response.data.status == 0) {
// this.props.showNotification('大题删除成功');
this.props.getdata({});
this.setState({
titilesms: ""
})
}
})
.catch(function (error) {
////console.log(error);
});
}
}
setmodalsTypedels = (bool, type) => {
if (type === 1) {
this.setState({
modalsTypedels: bool,
})
}else {
//确定
const url = `/examination_items/${this.state.item_bank_id}.json`;
axios.delete((url))
.then((response) => {
if (response.data.status == 0) {
// this.props.showNotification('试题删除成功');
this.props.getdata({});
}
})
.catch(function (error) {
});
this.setState({
modalsTypedels: bool,
})
}
}
showsetmodalsTypedels=(id,bool,type)=>{
console.log("Paperlibraryseeid_itemss");
this.setState({
item_bank_id:id,
})
this.setmodalsTypedels(bool,type);
}
hideparagraph = (name) => {
//console.log("hideparagraph");
}
hideparagraphs = () => {
this.setState({
singlebool: false,
multiplebool: false,
judgmentbool: false,
programbool: false,
})
}
showparagraph = (name) => {
//console.log("showparagraph");
if (name === "SINGLE") {
this.setState({
singlebool: true,
multiplebool: false,
judgmentbool: false,
programbool: false,
paperreviewsingleindex:"无",
paperreviewsinglename:"",
})
} else if (name === "MULTIPLE") {
this.setState({
singlebool: false,
multiplebool: true,
judgmentbool: false,
programbool: false,
paperreviewsingleindex:"无",
paperreviewsinglename:"",
})
} else if (name === "JUDGMENT") {
this.setState({
singlebool: false,
multiplebool: false,
judgmentbool: true,
programbool: false,
paperreviewsingleindex:"无",
paperreviewsinglename:"",
})
} else if (name === "PROGRAM") {
this.setState({
singlebool: false,
multiplebool: false,
judgmentbool: false,
programbool: true,
paperreviewsingleindex:"无",
paperreviewsinglename:"",
})
}
}
jixuxuantioncli = () => {
this.props.history.replace("/question");
}
showparagraphs = (e,name) => {
// //console.log("showparagraphs");
// //console.log(e);
this.setState({
paperreviewsingleindex: e,
paperreviewsinglename:name,
singlebool: false,
multiplebool: false,
judgmentbool: false,
programbool: false,
})
}
Setscore=(id)=>{
}
render() {
let {
questions, totalscore, total, modalsTypedel, modalsTypey, modalsTypedels,
singlebool,
multiplebool,
judgmentbool,
programbool,
paperreviewsingleindex,
modalsTypeys
} = this.state;
let {single_questions, multiple_questions, judgement_questions, program_questions, all_score} = this.props;
return (
<div className=" w100s ">
{
modalsTypedel === true ?
<PaperDeletModel {...this.state} {...this.props}
setmodalsTypedel={(bool, type, name) => this.setmodalsTypedel(bool, type, name)}></PaperDeletModel>
: ""
}
{
modalsTypey === true ?
<Paperreview_itemModel {...this.state} {...this.props} setDownloady={(fs) => this.setDownloady(fs)}
Singlemagazine={(name, bool) => this.Singlemagazine(name, bool)}></Paperreview_itemModel>
: ""
}
{
modalsTypeys === true ?
<Paperreview_itemModels {...this.state} {...this.props} setDownloadys={(value) => this.setDownloadys(value)}
Singlemagazines={(bool,id,name) => this.Singlemagazines(bool,id,name)}></Paperreview_itemModels>
: ""
}
{
modalsTypedels === true ?
<PaperDeletModels {...this.state} {...this.props}
setmodalsTypedels={(id,bool, type) => this.setmodalsTypedels(id,bool, type)}></PaperDeletModels>
: ""
}
<div className="w100s mt20 mb20 backgroudwhites" style={{
position: "relative",
}}>
{/*单选题*/}
{
single_questions && single_questions ?
<div className="backgroudwhites" style={{
position: "relative",
}}>
<div className="w100s mt20 mb20 postitonrelati">
<div
className={singlebool === true ? "w100s sortinxdirection borderwdswuhques intermediatecenterysls" : "w100s sortinxdirection intermediatecenterysls"}
onMouseEnter={() => this.showparagraph("SINGLE")} onMouseLeave={() => this.hideparagraph("SINGLE")}>
<p className={singlebool === true ? "ml18 yldxtit" : "yldxtit"}>单选题</p> <p
className="ml15 yldxtits">{single_questions && single_questions.questions_count}{single_questions && single_questions.questions_score}</p>
</div>
{
singlebool === true ?
<div className="postitonrelatiss xaxisreverseorder">
<div className="scd xiaoshou" onClick={() => this.setmodalsTypedel(true, 1, "SINGLE")}>删除</div>
<div className="szdfd xiaoshou" onClick={() => this.Singlemagazine("单选题", true)}>批量设置得分</div>
</div> : ""
}
<DragDropContext onDragEnd={this.onDragEnd}>
<Droppable droppableId={"0"}>
{(provided, snapshot) => (
<div
ref={provided.innerRef}
{...provided.droppableProps}
className={""}
onScroll={this.contentViewScrolledit}
>
{
single_questions && single_questions.questions.map((object, index) => {
return (
<Draggable
key={object.id}
draggableId={object.id}
index={index}
className={""}
>
{(provided, snapshot) => (
<div
key={index}
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
>
<Paperlibraryseeid_itemsss
key={index}
paperreviewsingleindex={this.state.paperreviewsingleindex}
paperreviewsinglename={this.state.paperreviewsinglename}
indexs={index}
typenames={"SINGLE"}
typenamesn={"单选题"}
showsetmodalsTypedels={(id,bool,type)=>this.showsetmodalsTypedels(id,bool,type)}
Singlemagazines={(bool,id,name)=>this.Singlemagazines(bool,id,name)}
showparagraphs={(e,name) => this.showparagraphs(e,name)}
object={object}
hideparagraphs={() => this.hideparagraphs()}
>
</Paperlibraryseeid_itemsss>
</div>
)}
</Draggable>
)
})
}
</div>
)}
</Droppable>
</DragDropContext>
</div>
</div>
: ""
}
{
multiple_questions && multiple_questions ?
<div className="backgroudwhites" style={{
position: "relative",
}}>
<div className="h20 lh20"></div>
<div className="w100s mb20 postitonrelati">
<div
className={multiplebool === true ? "w100s sortinxdirection mt10 borderwdswuhques intermediatecenterysls" : "w100s sortinxdirection intermediatecenterysls"}
onMouseEnter={() => this.showparagraph("MULTIPLE")}
onMouseLeave={() => this.hideparagraph("MULTIPLE")}>
<p
className={multiplebool === true ? "ml18 yldxtit" : "yldxtit"}>{single_questions === null ? "一" : "二"}多选题</p>
<p
className="ml15 yldxtits">{multiple_questions && multiple_questions.questions_count}{multiple_questions && multiple_questions.questions_score}</p>
</div>
{
multiplebool === true ?
<div className="postitonrelatisss xaxisreverseorder ">
<div className="scd xiaoshou" onClick={() => this.setmodalsTypedel(true, 1, "MULTIPLE")}>删除
</div>
<div className="szdfd xiaoshou" onClick={() => this.Singlemagazine("多选题", true)}>批量设置得分</div>
</div>
: ""
}
<DragDropContext onDragEnd={this.onDragEnds}>
<Droppable droppableId={"0"}>
{(provided, snapshot) => (
<div
ref={provided.innerRef}
{...provided.droppableProps}
className={""}
onScroll={this.contentViewScrolledit}
>
{
multiple_questions && multiple_questions.questions.map((object, index) => {
return (
<Draggable
key={object.id}
draggableId={object.id}
index={index}
className={""}
>
{(provided, snapshot) => (
<div
key={index}
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
>
<Paperlibraryseeid_itemsss
key={index}
paperreviewsingleindex={this.state.paperreviewsingleindex}
paperreviewsinglename={this.state.paperreviewsinglename}
indexs={index}
typenames={"MULTIPLE"}
typenamesn={"多选题"}
showsetmodalsTypedels={(id,bool,type)=>this.showsetmodalsTypedels(id,bool,type)}
Singlemagazines={(bool,id,name)=>this.Singlemagazines(bool,id,name)}
showparagraphs={(e,name) => this.showparagraphs(e,name)}
object={object}
hideparagraphs={() => this.hideparagraphs()}
>
</Paperlibraryseeid_itemsss>
</div>
)}
</Draggable>
)
})
}
</div>
)}
</Droppable>
</DragDropContext>
</div>
</div>
:
""
}
{
judgement_questions && judgement_questions ?
<div className={judgmentbool === true ? "backgroudwhites " : "backgroudwhites"} style={{
position: "relative",
}}>
<div className="h20 lh20"></div>
<div className="w100s mb20 postitonrelati">
<div
className={judgmentbool === true ? "w100s sortinxdirection borderwdswuhques mt10 intermediatecenterysls " : "w100s sortinxdirection intermediatecenterysls "}
onMouseEnter={() => this.showparagraph("JUDGMENT")}
onMouseLeave={() => this.hideparagraph("JUDGMENT")}>
<p
className={judgmentbool === true ? "ml18 yldxtit" : "yldxtit"}>{single_questions === null && multiple_questions === null ? "一" : single_questions === null && multiple_questions !== null ? "二"
: single_questions !== null && multiple_questions === null ? "二"
: "三"}判断题</p> <p
className="ml15 yldxtits">{judgement_questions && judgement_questions.questions_count}{judgement_questions && judgement_questions.questions_score}</p>
</div>
{
judgmentbool === true ?
<div className="postitonrelatiss xaxisreverseorder">
<div className="scd xiaoshou" onClick={() => this.setmodalsTypedel(true, 1, "JUDGMENT")}>删除
</div>
<div className="szdfd xiaoshou" onClick={() => this.Singlemagazine("判断题", true)}>批量设置得分</div>
</div>
: ""}
<DragDropContext onDragEnd={this.onDragEndss}>
<Droppable droppableId={"0"}>
{(provided, snapshot) => (
<div
ref={provided.innerRef}
{...provided.droppableProps}
className={""}
onScroll={this.contentViewScrolledit}
>
{
judgement_questions && judgement_questions.questions.map((object, index) => {
return (
<Draggable
key={object.id}
draggableId={object.id}
index={index}
className={""}
>
{(provided, snapshot) => (
<div
key={index}
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
>
<Paperlibraryseeid_itemsss
key={index}
paperreviewsingleindex={this.state.paperreviewsingleindex}
paperreviewsinglename={this.state.paperreviewsinglename}
indexs={index}
typenames={"JUDGMENT"}
typenamesn={"判断题"}
showsetmodalsTypedels={(id,bool,type)=>this.showsetmodalsTypedels(id,bool,type)}
Singlemagazines={(bool,id,name)=>this.Singlemagazines(bool,id,name)}
showparagraphs={(e,name) => this.showparagraphs(e,name)}
object={object}
hideparagraphs={() => this.hideparagraphs()}
>
</Paperlibraryseeid_itemsss>
</div>
)}
</Draggable>
)
})
}
</div>
)}
</Droppable>
</DragDropContext>
</div>
</div>
: ""
}
{
program_questions && program_questions ?
<div className={programbool === true ? "backgroudwhites " : "backgroudwhites"} style={{
position: "relative",
}}>
<div className="h20 lh20"></div>
<div className="w100s mb20 postitonrelati">
<div
className={programbool === true ? "w100s sortinxdirection mt10 borderwdswuhques intermediatecenterysls " : "w100s sortinxdirection intermediatecenterysls"}
onMouseEnter={() => this.showparagraph("PROGRAM")}
onMouseLeave={() => this.hideparagraph("PROGRAM")}>
<p className={programbool === true ? "ml18 yldxtit" : "yldxtit"}>
{single_questions === null && multiple_questions === null && program_questions === null ? "一"
: single_questions === null && multiple_questions === null && program_questions !== null ? "二"
: single_questions !== null && multiple_questions === null && program_questions === null ? "二"
: single_questions === null && multiple_questions !== null && program_questions === null ? "二"
: single_questions !== null && multiple_questions !== null && program_questions === null ? "三"
: single_questions === null && multiple_questions !== null && program_questions !== null ? "三"
: single_questions !== null && multiple_questions == null && program_questions !== null ? "三" :
"四"}
编程题</p> <p
className="ml15 yldxtits">{program_questions && program_questions.questions_count}{program_questions && program_questions.questions_score}</p>
</div>
{
programbool === true ?
<div className="postitonrelatiss xaxisreverseorder">
<div className="scd xiaoshou" onClick={() => this.setmodalsTypedel(true, 1, "PROGRAM")}>删除</div>
<div className="szdfd xiaoshou" onClick={() => this.Singlemagazine("编程题", true)}>批量设置得分</div>
</div>
: ""
}
<DragDropContext onDragEnd={this.onDragEndsss}>
<Droppable droppableId={"0"}>
{(provided, snapshot) => (
<div
ref={provided.innerRef}
{...provided.droppableProps}
className={""}
onScroll={this.contentViewScrolledit}
>
{
program_questions && program_questions.questions.map((object, index) => {
return (
<Draggable
key={object.id}
draggableId={object.id}
index={index}
className={""}
>
{(provided, snapshot) => (
<div
key={index}
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
>
<Paperlibraryseeid_itemsss
key={index}
paperreviewsingleindex={this.state.paperreviewsingleindex}
paperreviewsinglename={this.state.paperreviewsinglename}
indexs={index}
typenames={"PROGRAM"}
typenamesn={"编程题"}
showsetmodalsTypedels={(id,bool,type)=>this.showsetmodalsTypedels(id,bool,type)}
Singlemagazines={(bool,id,name)=>this.Singlemagazines(bool,id,name)}
showparagraphs={(e,name) => this.showparagraphs(e,name)}
object={object}
hideparagraphs={() => this.hideparagraphs()}
>
</Paperlibraryseeid_itemsss>
</div>
)}
</Draggable>
)
})
}
</div>
)}
</Droppable>
</DragDropContext>
</div>
</div>
:
""
}
</div>
</div>
)
}
}
export default Paperlibraryseeid_itemss