import React, {Component} from "react";
import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn, getImageUrl, markdownToHTML} from 'educoder';
import axios from 'axios';
import {
	notification,
	Spin,
	Table,
	Pagination,
	Drawer,
	Input,
	Button,
	Breadcrumb,
	Radio
} from "antd";
import Itembankstop from "./component/Itembankstop";
import NoneData from './component/NoneData';
import './questioncss/questioncom.css';
import '../tpm/newshixuns/css/Newshixuns.css';
import QuillForEditor from "../../common/quillForEditor";
import QuestionModalPicture from "./component/QuestionModalPicture";

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．'
]

//单选题
//Paperlibraryseeid_items.js Listjihe.js
class Paperreview_single extends Component {
	constructor(props) {
		super(props);

		this.state = {
			questions: 0,
			totalscore: 0,
			total: 0,
			url: ""

		}

	}

	//初始化
	componentDidMount() {


	}


	getdata = (data) => {

	}

	preservation = () => {


	}


	setitem_type = (item_type) => {


	}
	showparagraph = (indexx) => {


	}
	Singlemagaziness = () => {

	}
	handleShowUploadImage = (url) => {
		// console.log('==============>>>>>>>>>>>>',url);
		// setUrl(url);
		this.setState({
			url:url
		})
	}
	handleClose=()=>{
		this.setState({
			url:'',
		})
	}
	render() {
		let {questions, totalscore, total, items,url} = this.state;
		let {objectsingle, indexx, paperreviewsingleindex, indexxy,name} = this.props;


		var itemssname="";
		try {
			itemssname= JSON.parse(objectsingle.name);
		}catch (e) {
			itemssname=objectsingle.name;
		}
		if(itemssname===undefined){
			itemssname=objectsingle.name
		}

		var itemsnamesy="";
		try {
			itemsnamesy= JSON.parse(objectsingle&&objectsingle.program_attr&&objectsingle.program_attr.description);

		}catch (e) {
			itemsnamesy=objectsingle&&objectsingle.program_attr&&objectsingle.program_attr.description;
		}
		var  fenshul=(objectsingle.score+"分");
		const options = [
			'bold', // 加粗
		]

		try {
			if(itemsnamesy.constructor === Object){
				// console.log("是对象");
				// console.log(itemsnamesy);
			}else {
				// console.log("不是对象");
				// console.log(itemsnamesy);
				itemsnamesy=itemsnamesy+"";
			}
		}catch (e) {

		}
		return (
			<div key={indexxy}
					 className={ "w100s borderwdswuh   mb20  pd20 "}
					 onMouseEnter={() => this.props.showparagraphs(indexxy,name)} style={{
				minHeight: "114px",
			}}>
				{url?
					<QuestionModalPicture  {...this.props} {...this.state} handleClose={()=>this.handleClose()}></QuestionModalPicture>
					:
					""
				}
				<style>{
					`
						.programquill .ql-editor{
							  padding-left: 0px !important;
								padding-top: 0px !important;
						}
						
						.programquill .ql-editor p{
						line-height: 28px;
					
						}
						.programquills .ql-editor{
		           	padding-left: 0px !important;
								padding-top: 0px !important;
						}
						
						.programquills .ql-editor p{
						line-height: 20px;
					
						}
					`
				}</style>
				{/*顶部*/}
				<div className="w100s sortinxdirection ">
					<div className=" sortinxdirection ">
						<p className="cretitlecolrlis lh28" style={{fontWeight:"bold"}}>{indexx}</p>、
					</div>
					<style>
						{
							`
					.markdown-body{
					   color: #333333;
             font-size: 14px !important;
                 line-height: 28px;

					}
						
					.markdown-body p {
					 color: #333333;
					 font-size: 14px !important;
					     line-height: 28px;
					      font-weight: bold;

					}
					.bodyysls .ql-editor p span{
							   font-weight: bold;
						}
				
					`
						}
					</style>
					{
						objectsingle.item_type==="PROGRAM"?
						   <div className="w100s sortinxdirection">
								 <div className=" tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{wordBreak: "break-word",
									 minWidth:"32px",fontWeight:"bold"
								 }}
								 >
									 ({objectsingle.score}分)
								 </div>

								 <div id={"titessone"} className="ml10 lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{wordBreak: "break-word",fontWeight:"bold"}}
											dangerouslySetInnerHTML={{__html: markdownToHTML(fenshul+objectsingle.name).replace(/▁/g, "▁▁▁")}}>

								 </div>
							 </div>
							:
							<div className="w100s sortinxdirection titesstwos">
								<div id={"titesstwo"} className="tites  titesstwostest lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{wordBreak: "break-word",
									minWidth:"32px",fontWeight:"bold"
								}}
								>
									({objectsingle.score}分)
								</div>
							<div className={objectsingle.score<10?" lh28 listjihetixingstit text-indents40 bodyysls cretitlecolrlist programquill":objectsingle.score<100?" lh28 listjihetixingstit text-indents44 bodyysls cretitlecolrlist programquill":" lh28 listjihetixingstit text-indents50 bodyysls cretitlecolrlist programquill" }style={{wordBreak: "break-word",fontWeight:"bold"}}
		          >
								{
									itemssname===null|| itemssname===undefined?
										""
										:
										<QuillForEditor
											readOnly={true}
											value={itemssname}
											showUploadImage={this.handleShowUploadImage}
										/>
								}


							</div>
							</div>
					}

				</div>
				{/*内容*/}
				<div className="w100s sortinxdirection">


					{
						objectsingle.item_type === "JUDGMENT" ?
							<p className="w100s listjihetixingstits sortinxdirection ">
								{
									objectsingle === undefined || objectsingle === null ? "" : objectsingle.choices.map((object, index) => {
										return (
											<p className={index === 1 ? "sortinxdirection  ml10" : "sortinxdirection  "}>
												<Radio  disabled={true}>
													{object.choice_text}
												</Radio>
											</p>
										)
									})
								}
							</p>
							:
							objectsingle.item_type === "PROGRAM" ?
								<p className="w100s listjihetixingstitssy sortinxdirection ">
									<p className={"sortinxdirection  mt15"}>
										{
											objectsingle&&objectsingle.program_attr&&objectsingle.program_attr.description?
										<p className="programquill " style={{wordBreak: "break-word"}}
										>
											{
												itemsnamesy===null || itemsnamesy===undefined?
                          ""
													:
													<QuillForEditor
														readOnly={true}
														value={itemsnamesy}
														showUploadImage={this.handleShowUploadImage}
													/>
											}

									</p>
											:
												""}
									</p>
								</p>
								:
								<p className="w100s listjihetixingstits verticallayout ">
									{
										objectsingle === undefined || objectsingle === null ? "" : objectsingle.choices.map((object, index) => {
											 var string=""
											try {
												string=JSON.parse(object.choice_text);
											}catch (e) {
												string=object.choice_text;
											}

											return (
												<p key={index} className={index === 0 ? "sortinxdirection" : "sortinxdirection  mt15"}>
													{tagArray[index]}
													<p className="programquills" style={{wordBreak: "break-word"}}>
														{object ?
															object.choice_text === undefined || object.choice_text=== null || object.choice_text === "" ?
																""
																:
																object.choice_text.length>0?
																	<QuillForEditor
																		readOnly={true}
																		value={string}
																		showUploadImage={this.handleShowUploadImage}
																	/>
																	:""
															:
															""
														}
													</p>
												</p>
											)
										})
									}
								</p>
					}


				</div>


			</div>
		)

	}


}

export default Paperreview_single


