import React, { Component } from "react";
import { Radio } from "antd";
import '../testioncss/testioncss.css';
import '../../tpm/newshixuns/css/Newshixuns.css';
import QuestionModalPicture from "../../question/component/QuestionModalPicture";
import RenderHtml from "../../../components/render-html";

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

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

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

	}

	//初始化
	handleShowUploadImage = (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 = objectsingle.name

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


		var itemsnamesy = objectsingle && objectsingle.program_attr && objectsingle.program_attr.description;
		if (itemsnamesy) {
			try {
				itemsnamesy = JSON.parse(itemsnamesy);
			} catch (e) {
				itemsnamesy = objectsingle && objectsingle.program_attr && objectsingle.program_attr.description;
			}

		}

		return (
			<div key={indexxy}
				className={"w100s borderwdswuh   mb20  pd20 "}
				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>
						{
							`
					.listjihetixingstit{
					   color: #333333;
             font-size: 14px !important;
                 line-height: 28px;

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

					}
					
						.bodyysls .ql-editor p span{
							    font-weight: bold;
						}
					.markdown-body .ql-editor p {
							     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>
								<RenderHtml className="ml10 lh28 listjihetixingstit cretitlecolrlist " value={itemssname} />
							</div>
							:
							<div className="w100s sortinxdirection">
								<div className="tites  lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{
									wordBreak: "break-word",
									minWidth: "32px", fontWeight: "bold"
								}}
								>
									({objectsingle.score}分)
								</div>
								{
									itemssname === null || itemssname === undefined ?
										""
										:
										<RenderHtml className="ml10 lh28 listjihetixingstit cretitlecolrlist " value={itemssname} />
								}


							</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 ?
															null
															:
															<RenderHtml value={itemsnamesy} />
													}
												</p>
												:
												null}
									</p>
								</p>
								:
								<p className="w100s listjihetixingstits verticallayout ">
									{
										objectsingle === undefined || objectsingle === null ? "" : objectsingle.choices.map((object, index) => {
											var string = object.choice_text;

											if (string) {
												try {
													string = JSON.parse(string);
												} catch (e) {
													string = object.choice_text;
												}

											}
											return (
												<p 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 === "" ?
																null
																:
																object.choice_text.length > 0 ?
																	<RenderHtml value={string} />
																	: ""
															:
															""
														}
													</p>
												</p>
											)
										})
									}
								</p>
					}

				</div>


			</div>
		)

	}


}

export default Paperlibraryseeid_items


