import React, {Component} from "react"; import {Link, NavLink} from 'react-router-dom'; import {WordsBtn, ActionBtn, SnackbarHOC, getImageUrl, markdownToHTML} from 'educoder'; import axios from 'axios'; import { notification, Spin, Table, Pagination, Radio, Tooltip, Icon } from "antd"; import './../questioncss/questioncom.css'; import QuillForEditor from "../../../common/quillForEditor"; import Certifiedprofessional from "../../modals/Certifiedprofessional"; const tagArray = [ 'A.', 'B.', 'C.', 'D.', 'E.', 'F.', 'G.', 'H.', 'I.', 'J.', 'K.', 'L.', 'M.', 'N.', 'O.', 'P.', 'Q.', 'R.', 'S.', 'T.', 'U.', 'V.', 'W.', 'X.', 'Y.', 'Z.' ] const tagArrays = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' ] const questionType = [ { type:'SINGLE', color:'typeGreen', name:'单选题' }, { type:'MULTIPLE', color:'typeBlue', name:'多选题' }, { type:'JUDGMENT', color:'typeRed', name:'判断题' }, { type:'PROGRAM', color:'typeYellow', name:'编程题' } ] //Paperreview_single.js Paperlibraryseeid_items.js class Listjihe extends Component { constructor(props) { super(props); this.state = { page: 1, name: "单选题", nd: "简单", url: "", mydisplay:false, occupation:2, isysladmins:false, } } //初始化 componentDidMount() { 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; } } } this.setState({ isysladmins:isysladmins }) } handleShowUploadImage = (url) => { try { this.props.handleShowUploadImage(url); }catch (e) { } } handleClose=()=>{ try { this.props.handleClose(); }catch (e) { } } //选用 Selectingpracticaltraining = (id) => { try { if(this.props.Datacountbool){ if(this.props.Datacount===100){ this.props.showNotification(`已选100个试题(不能在选用更多试题)`); return; } } }catch (e) { } let data = {} if (this.props.exam_id === undefined) { data = { item_ids: [id] } } else { data = { item_ids: [id], exam_id: this.props.exam_id === undefined ? "" : parseInt(this.props.exam_id), } } if(this.props.current_user.professional_certification===false&&this.state.isysladmins===false){ this.HideAddcoursestypess(2); return } this.getitem_baskets(data); } getitem_baskets=(data)=>{ this.props.getitem_baskets(data); } //撤销 Selectingpracticaltrainings = (id) => { this.props.getitem_basketss(id); } seturls(url){ if(this.props.current_user.professional_certification===false&&this.state.isysladmins===false){ this.HideAddcoursestypess(2); return } this.props.history.replace(url); } HideAddcoursestypess=(i)=>{ console.log("调用了"); this.setState({ mydisplay:true, occupation:i, }) } mydisplayHidedel=()=>{ this.setState({ mydisplay:false, }) } render() { let {page, name, nd,url,mydisplay} = this.state; let {defaultActiveKey, items, listjihe, chakanjiexiboolindex, keindex} = this.props; // 编程答案 var rightkey = null var MULTIPLEkey = null; if (items) { if (items.item_type) { if (items.item_type === "PROGRAM") { } else { if (items.item_type === "JUDGMENT") { //多选题 if (items.choices) { if (items.choices.length > 0) { var arr = items.choices; for (let data of arr) { if (data.is_answer === true) { rightkey = data.choice_text; break; } } } } } else { // 单选题和判断题 if(items.item_type === "MULTIPLE"){ if (items.choices) { if (items.choices.length > 0) { var arr = items.choices; for (var i = 0; i < arr.length; i++) { if (arr[i].is_answer === true) { if(MULTIPLEkey===null){ MULTIPLEkey = tagArrays[i]; }else{ MULTIPLEkey =MULTIPLEkey+ tagArrays[i]; } } } } } }else{ if (items.choices) { if (items.choices.length > 0) { var arr = items.choices; for (var i = 0; i < arr.length; i++) { if (arr[i].is_answer === true) { rightkey = i; break; } } } } } } } } } var itemssname=""; try { itemssname= JSON.parse(items.name); }catch (e) { } if(itemssname===undefined){ itemssname=items.name+"" } var itemsnamesy=""; try { itemsnamesy= JSON.parse(items&&items.program_attr&&items.program_attr.description); }catch (e) { itemsnamesy=items&&items.program_attr&&items.program_attr.description+""; } var analysisnames=""; try { analysisnames= JSON.parse(items&&items.analysis); }catch (e) { analysisnames=items&&items.analysis+""; } // console.log(items.name); // console.log(itemsnamesy); // // console.log(analysisnames); const options = [ 'bold', // 加粗 ] try { if(itemsnamesy.constructor === Object){ // console.log("是对象"); // console.log(itemsnamesy); }else { // console.log("不是对象"); // console.log(itemsnamesy); itemsnamesy=itemsnamesy+""; } }catch (e) { } const types = questionType.filter(item=>item.type === items.item_type); let Periofters = false; let Perioftersbols=false; if (this.props) { if (this.props.current_user) { if (this.props.current_user.admin) { Periofters = true; } else if (this.props.current_user.business) { Perioftersbols = true; } } } // console.log(this.props); // console.log("PerioftersPerioftersbols"); // console.log(Periofters); // console.log(Perioftersbols); return (
) :
{ items === undefined || items === null ? "" : items.choices.map((object, index) => { return (
{ items&&items.program_attr&&items.program_attr.description?
{
itemsnamesy===null || itemsnamesy===undefined?
""
:
{ items === undefined || items === null ? "" : items.choices.map((object, index) => { var string="" try { string=JSON.parse(object.choice_text); }catch (e) { string=object.choice_text; } return (
{tagArray[index]}
{object ?
object.choice_text === undefined || object.choice_text=== null || object.choice_text === "" ?
""
:
object.choice_text.length>0?
难度:{items.difficulty === 1 ? "简单" : items.difficulty === 2 ? "适中" : items.difficulty === 3 ? "困难" : ""}
题型:{items.item_type === "SINGLE" ? "单选题" : items.item_type === "MULTIPLE" ? "多选题" : items.item_type === "JUDGMENT" ? "判断题" : items.item_type === "PROGRAM" ? "编程题" : ""}
更新时间:{items.update_time}
{ this.props.defaultActiveKey === "0" || this.props.defaultActiveKey === 0 ? "" :创建者:{items.author.name}
} { items.item_type === "PROGRAM" ?编程语言:{items.program_attr.language}
: "" } { items.item_type === "PROGRAM" ? items.program_attr.status === 0 ?未发布
: "" : "" }this.Selectingpracticaltrainings(items.id)}> {/**/} 撤销
: items.item_type === "PROGRAM" ? items.program_attr.status === 0 ?选用
this.Selectingpracticaltraining(items.id)}> 选用
:this.Selectingpracticaltraining(items.id)}> 选用
} { defaultActiveKey === 0 || defaultActiveKey === "0" ?this.props.showmodelysl(items.id)}> 删除
{ items.item_type === "PROGRAM" ? this.props.Isitapopup&&this.props.Isitapopup==="true"? "" : this.seturls(`/problems/${items.program_attr.identifier}/edit`)}>编辑
: this.props.Isitapopup&&this.props.Isitapopup==="true"? "" : this.seturls(`/problemset/edit/${items.id}`)}>编辑
} { items.public === false ? items.item_type === "PROGRAM" ? ( items.program_attr.status === 0 ? "" : items.apply===false?this.props.showmodels(items.id)}> 公开
: ( items.public==true?已公开
:this.props.showmodelsInaudit(e)}> 公开审核中
) ) :items.apply===false?this.props.showmodels(items.id)}> 公开
: ( items.public==true? "" :this.props.showmodelsInaudit(e)}> 公开审核中
) :已公开
}this.props.showmodelysl(items.id)}> 删除
{ items.item_type === "PROGRAM" ? this.props.Isitapopup&&this.props.Isitapopup==="true"? "" : this.seturls(`/problems/${items.program_attr.identifier}/edit`)}>编辑
: this.props.Isitapopup&&this.props.Isitapopup==="true"? "" : this.seturls(`/problemset/edit/${items.id}`)}>编辑
}编辑
: this.props.Isitapopup&&this.props.Isitapopup==="true"? "" : this.seturls(`/problemset/edit/${items.id}`)}>编辑
}this.props.chakanjiexibool(keindex)}> 查看解析
}: items.item_type === "MULTIPLE"?
:
}
解析:
{items ?
items.analysis=== undefined || items.analysis=== null || items.analysis === "" ?
"暂无解析"
:
items.analysis.length>0?
analysisnames===null || analysisnames===undefined?"":