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 Itembankstop from "./component/Itembankstop"; import NoneData from './component/NoneData'; import './questioncss/questioncom.css'; import '../tpm/newshixuns/css/Newshixuns.css'; import Paperreview_single from './Paperreview_single'; import {DragDropContext, Draggable, Droppable} from 'react-beautiful-dnd'; import PaperDeletModel from './component/PaperDeletModel'; import PaperDeletModels from './component/PaperDeletModels'; import Paperreview_itemModel from './component/Paperreview_itemModel'; import Paperreview_itemModels from './component/Paperreview_itemModels'; import Paperreview_items from './Paperreview_items'; const reorder = (list, startIndex, endIndex) => { const result = Array.from(list); const [removed] = result.splice(startIndex, 1); result.splice(endIndex, 0, removed); return result; }; class Paperreview_item 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 = `/item_baskets/${ids}/adjust_position.json` if(this.props.match.params.type==="Intelligence") { var data = { position: positions, exam_setting_id:this.props.match.params.id, } }else { 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 = `/item_baskets/${ids}/adjust_position.json` if(this.props.match.params.type==="Intelligence") { var data = { position: positions, exam_setting_id:this.props.match.params.id, } }else { 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 = `/item_baskets/${ids}/adjust_position.json` if(this.props.match.params.type==="Intelligence") { var data = { position: positions, exam_setting_id:this.props.match.params.id, } }else { 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 = `/item_baskets/${ids}/adjust_position.json` if(this.props.match.params.type==="Intelligence") { var data = { position: positions, exam_setting_id:this.props.match.params.id, } }else { 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) => { if(this.props.match.params.type==="Intelligence") { //智能选题 const url = "/item_baskets/batch_set_score.json"; var data = { score: fenshu, item_type: this.state.titilesm === "单选题" ? "SINGLE" : this.state.titilesm === "多选题" ? "MULTIPLE" : this.state.titilesm === "判断题" ? "JUDGMENT" : this.state.titilesm === "编程题" ? "PROGRAM" : '', exam_setting_id:this.props.match.params.id, } 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); }) }else{ const url = "/item_baskets/batch_set_score.json"; var data = { 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 = `/item_baskets/${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 }) if(this.props.match.params.type==="Intelligence") { //智能组卷 const url = `/item_baskets/delete_item_type.json`; axios.delete((url), { data: { item_type: names, exam_setting_id:this.props.match.params.id, } }) .then((response) => { if (response.data.status == 0) { // this.props.showNotification('大题删除成功'); this.props.getdata({}); this.setState({ titilesms: "" }) } }) .catch(function (error) { ////console.log(error); }); }else{ const url = `/item_baskets/delete_item_type.json`; axios.delete((url), { data: { 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 { //确定 if(this.props.match.params.type==="Intelligence"){ //智能组卷 const url = `/item_baskets/${this.state.item_bank_id}.json`; axios.delete(url, { data: { exam_setting_id: this.props.match.params.id, }}) .then((response) => { if (response.data.status == 0) { // this.props.showNotification('试题删除成功'); this.props.getdata({}); } }) .catch(function (error) { }); }else{ const url = `/item_baskets/${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("Paperreview_item"); 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; console.log("this.props"); console.log(this.props); return (
题数:{this.props.all_questions_count}
总分:{this.props.all_score}
一、单选题
(共{single_questions && single_questions.questions_count}题;共{single_questions && single_questions.questions_score}分)
{single_questions === null ? "一" : "二"}、多选题
(共{multiple_questions && multiple_questions.questions_count}题;共{multiple_questions && multiple_questions.questions_score}分)
{single_questions === null && multiple_questions === null ? "一" : single_questions === null && multiple_questions !== null ? "二" : single_questions !== null && multiple_questions === null ? "二" : "三"}、判断题
(共{judgement_questions && judgement_questions.questions_count}题;共{judgement_questions && judgement_questions.questions_score}分)
{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 ? "三" : "四"} 、编程题
(共{program_questions && program_questions.questions_count}题;共{program_questions && program_questions.questions_score}分)