试卷样式

dev_new_shixunsrepository
杨树林 5 years ago
parent bf3b01fb54
commit b5d951ab07

@ -1,129 +1,135 @@
import React,{ Component } from "react"; import React,{ Component } from "react";
import { import {
Form, Input, InputNumber, Switch, Radio, Form, Input, InputNumber, Switch, Radio,
Slider, Button, Upload, Icon, Rate, Checkbox, message, Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Tooltip Row, Col, Select, Modal, Tooltip
} from 'antd'; } from 'antd';
import axios from 'axios' import axios from 'axios'
import QestionDisplayHeader from './QestionDisplayHeader' import QestionDisplayHeader from './QestionDisplayHeader'
import {getUrl, ActionBtn, markdownToHTML, MarkdownToHtml} from 'educoder'; import {getUrl, ActionBtn, markdownToHTML, MarkdownToHtml} from 'educoder';
const { TextArea } = Input; const { TextArea } = Input;
const confirm = Modal.confirm; const confirm = Modal.confirm;
const $ = window.$ const $ = window.$
const { Option } = Select; const { Option } = Select;
const tagArray = [ const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
] ]
const qNameArray = [ const qNameArray = [
'单选题', '单选题',
'多选题', '多选题',
'判断题', '判断题',
'填空题', '填空题',
'简答题', '简答题',
'实训题', '实训题',
] ]
class SingleDisplay extends Component{ class SingleDisplay extends Component{
constructor(props){ constructor(props){
super(props); super(props);
this.state = { this.state = {
question_choices: ['', '', '', ''], question_choices: ['', '', '', ''],
standard_answers: [false, false, false, false] standard_answers: [false, false, false, false]
} }
} }
componentDidMount = () => { componentDidMount = () => {
const Id = this.props.match.params.Id const Id = this.props.match.params.Id
this.isEdit = !!Id this.isEdit = !!Id
if (Id) { if (Id) {
const url = `/exercises/${Id}/edit.json` const url = `/exercises/${Id}/edit.json`
// axios.get(url) // axios.get(url)
// .then((response) => { // .then((response) => {
// if (response.data.status == 0) { // if (response.data.status == 0) {
// } // }
// }) // })
// .catch(function (error) { // .catch(function (error) {
// console.log(error); // console.log(error);
// }); // });
} }
} }
render() { render() {
let { question_title, question_score, question_type, question_choices, standard_answer, let { question_title, question_score, question_type, question_choices, standard_answer,
question_id, question_number, index, displayCount, showActionButton question_id, question_number, index, displayCount, showActionButton
} = this.props; } = this.props;
// const { getFieldDecorator } = this.props.form; // const { getFieldDecorator } = this.props.form;
const isAdmin = this.props.isAdmin() const isAdmin = this.props.isAdmin()
const courseId=this.props.match.params.coursesId; const courseId=this.props.match.params.coursesId;
const isEdit = this.isEdit const isEdit = this.isEdit
const qNumber = `question_${index}`; const qNumber = `question_${index}`;
// TODO show模式 isNew为false isEdit为false // TODO show模式 isNew为false isEdit为false
// [true, false, true] -> [0, 2] // [true, false, true] -> [0, 2]
// const answerTagArray = standard_answer.map((item, index) => { return item == true ? tagArray[index] : -1 }).filter(item => item != -1); // const answerTagArray = standard_answer.map((item, index) => { return item == true ? tagArray[index] : -1 }).filter(item => item != -1);
let length = 5; let length = 5;
const qName = qNameArray[question_type] const qName = qNameArray[question_type]
const isPreviewPage = showActionButton == false const isPreviewPage = showActionButton == false
return( return(
<div className="bor-bottom-greyE padding20-30 singleDisplay" id={qNumber} _id={question_id}> <div className="bor-bottom-greyE padding20-30 singleDisplay" id={qNumber} _id={question_id}>
<style>{` <style>{`
.optionMdEditor { .optionMdEditor {
flex: 0 0 800px flex: 0 0 800px
} }
.optionRow { .optionRow {
margin: 2px; margin: 2px;
} }
.actionBtns { .actionBtns {
height: 28px height: 28px
} }
`}</style> `}</style>
<QestionDisplayHeader {...this.props}></QestionDisplayHeader> <QestionDisplayHeader {...this.props}></QestionDisplayHeader>
{/* 单选 or 多选 */} {/* 单选 or 多选 */}
<div className="options"> <div className="options">
{ question_choices.map((item, optionIndex) => { { question_choices.map((item, optionIndex) => {
let prefix = undefined let prefix = undefined
// if (!isPreviewPage) { // if (!isPreviewPage) {
prefix = `${tagArray[optionIndex]}.` prefix = `${tagArray[optionIndex]}.`
// } // }
if (question_type == 0) { // 单选 if (question_type == 0) { // 单选
return ( return (
<div className="mb10 clearfix" key={optionIndex}> <div className="mb10 clearfix " style={{
<Radio disabled className="fl lineh-25" checked={item.standard_boolean}>{prefix}</Radio> display: "flex",
<MarkdownToHtml content={item.choice_text} selector={'single_' + (index + 1) + '' + (optionIndex + 1)} style={{ float: 'left', display: 'inline-block' }} flexDirection:"row",
}} key={optionIndex}>
></MarkdownToHtml> <Radio disabled className="fl lineh-25" checked={item.standard_boolean}>{prefix}</Radio>
{/* <span style={{ display: 'inline-block'}} className="markdown-body fl" <MarkdownToHtml content={item.choice_text} selector={'single_' + (index + 1) + '' + (optionIndex + 1)} style={{ float: 'left', display: 'inline-block' }}
dangerouslySetInnerHTML={{__html: markdownToHTML1(item.choice_text)}}></span> */}
</div>) ></MarkdownToHtml>
} else { {/* <span style={{ display: 'inline-block'}} className="markdown-body fl"
dangerouslySetInnerHTML={{__html: markdownToHTML1(item.choice_text)}}></span> */}
return ( </div>)
<div className="mb10 clearfix" key={optionIndex}> } else {
<Checkbox disabled className="fl lineh-25 mr8" checked={item.standard_boolean}>{prefix}</Checkbox>
<MarkdownToHtml content={item.choice_text} selector={'single_' + (index + 1)+ '' + (optionIndex + 1)} style={{ float: 'left', display: 'inline-block' }} return (
<div className="mb10 clearfix" style={{
></MarkdownToHtml> display: "flex",
{/* <span style={{ display: 'inline-block'}} className="markdown-body fl" flexDirection:"row",
dangerouslySetInnerHTML={{__html: markdownToHTML1(item.choice_text)}}></span> */} }} key={optionIndex}>
</div>) <Checkbox disabled className="fl lineh-25 mr8" checked={item.standard_boolean}>{prefix}</Checkbox>
} <MarkdownToHtml content={item.choice_text} selector={'single_' + (index + 1)+ '' + (optionIndex + 1)} style={{ float: 'left', display: 'inline-block' }}
})}
></MarkdownToHtml>
</div> {/* <span style={{ display: 'inline-block'}} className="markdown-body fl"
</div> dangerouslySetInnerHTML={{__html: markdownToHTML1(item.choice_text)}}></span> */}
) </div>)
} }
} })}
// RouteHOC()
export default (SingleDisplay); </div>
</div>
)
}
}
// RouteHOC()
export default (SingleDisplay);

Loading…
Cancel
Save