yslnewtiku
杨树林 5 years ago
parent 6cca98e349
commit 3ee56c241d

@ -48,8 +48,8 @@ class Question extends Component {
axios.get(url, {
}).then((response) => {
// console.log("开始请求/get_navigation_info.json");
// console.log(response);
// //console.log("开始请求/get_navigation_info.json");
// //console.log(response);
if(response!=undefined){
if(response.status===200){
this.setState({
@ -79,10 +79,10 @@ class Question extends Component {
}else{
}
console.log("item_banks");
console.log(response);
//console.log("item_banks");
//console.log(response);
}).catch((error) => {
console.log(error)
//console.log(error)
});
}

@ -17,14 +17,19 @@ import NoneData from './component/NoneData';
import './questioncss/questioncom.css';
import Choicequestion from './component/Choicequestion';
import SingleEditor from "./component/SingleEditor";
import ChoquesEditor from "./component/ChoquesEditor"
import JudquestionEditor from "./component/JudquestionEditor";
var itembankstop=null;
var singleEditor=null;
var Judquestio=null;
var Choques=null;
class Questionitem_banks extends Component {
constructor(props) {
super(props);
this.contentMdRef = React.createRef();
this.answerMdRef = React.createRef();
this.state = {
item_type:null
}
@ -41,8 +46,8 @@ class Questionitem_banks extends Component {
// axios.get(url, {
//
// }).then((response) => {
// // console.log("开始请求/get_navigation_info.json");
// // console.log(response);
// // ////console.log("开始请求/get_navigation_info.json");
// // ////console.log(response);
// if(response!=undefined){
// if(response.status===200){
// this.setState({
@ -67,10 +72,10 @@ class Questionitem_banks extends Component {
// }else{
//
// }
// console.log("item_banks");
// console.log(response);
// ////console.log("item_banks");
// ////console.log(response);
// }).catch((error) => {
// console.log(error)
// ////console.log(error)
//
// });
}
@ -81,21 +86,83 @@ class Questionitem_banks extends Component {
getanswerMdRef=(Ref)=>{
this.answerMdRef=Ref;
}
getJudquestio=(Ref)=>{
debugger
this.Judquestio=Ref;
}
getChoquesEditor=(Ref)=>{
this.Choques=Ref;
}
preservation=()=>{
console.log("preservation");
// console.log(this.contentMdRef);
// console.log(this.answerMdRef);
console.log("preservation222");
console.log(this.contentMdRef.Getdatas());
console.log("preservation3333");
console.log(this.answerMdRef.onSave());
////console.log("preservation");
// ////console.log(this.contentMdRef);
// ////console.log(this.answerMdRef);
////console.log("preservation222");
////console.log(this.contentMdRef.Getdatas());
////console.log("preservation3333");
////console.log(this.answerMdRef.onSave());
if(this.contentMdRef !=null){
console.log(this.contentMdRef.Getdatas());
}
if(this.state.item_type===null ||this.state.item_type==="PROGRAM"){
return
}
if(this.state.item_type==="SINGLE"){
if( this.answerMdRef!=null){
//单选题
console.log(this.answerMdRef.onSave());
}
}
if(this.state.item_type==="MULTIPLE"){
if(this.Choques!=null){
//多选题
console.log(this.Choques.onSave());
}
}
if(this.state.item_type==="JUDGMENT"){
if( this.Judquestio !=null){
//判断题
console.log(this.Judquestio.onSave());
}
}
}
setitem_type=(item_type)=>{
this.setState({
item_type:item_type
})
}
render() {
let {page,limit,count,Headertop,visible,placement,modalsType}=this.state;
let {page,limit,count,Headertop,visible,placement,modalsType,item_type}=this.state;
{/*<Option value="SINGLE">单选题</Option>*/}
{/*<Option value="MULTIPLE">多选题</Option>*/}
{/*<Option value="JUDGMENT">判断题</Option>*/}
{/*<Option value="PROGRAM">编程题</Option>*/}
////console.log("塞选的数据");
////console.log(item_type);
return (
<div className="newMain clearfix intermediatecenter "
style={{
position: "relative"
}}
>
@ -120,29 +187,67 @@ class Questionitem_banks extends Component {
{...this.state}
{...this.props}
getcontentMdRef={(ref)=>this.getcontentMdRef(ref)}
setitem_type={(item)=>this.setitem_type(item)}
>
</Itembankstop>
{
item_type&&item_type==="SINGLE"?
<div className=" clearfix educontent Contentquestionbankstyle w100s w1200fpx mt19" >
<SingleEditor
{...this.state}
{...this.props}
getanswerMdRef={(ref)=>this.getanswerMdRef(ref)}
>
<div className=" clearfix educontent Contentquestionbankstyle w100s w1200fpx mt19" >
<SingleEditor
{...this.state}
{...this.props}
getanswerMdRef={(ref)=>this.getanswerMdRef(ref)}
>
</SingleEditor>
</div>
:item_type&&item_type==="MULTIPLE"?
<div className=" clearfix educontent Contentquestionbankstyle w100s w1200fpx mt19" >
<ChoquesEditor
{...this.state}
{...this.props}
getanswerMdRef={(ref)=>this.getChoquesEditor(ref)}
>
</ChoquesEditor>
</div>
:item_type&&item_type==="JUDGMENT"?
<div className=" clearfix educontent Contentquestionbankstyle w100s w1200fpx mt19" >
<JudquestionEditor
{...this.state}
{...this.props}
getanswerMdRef={(ref)=>this.getJudquestio(ref)}
>
</JudquestionEditor>
</div>
:item_type&&item_type==="PROGRAM"?"":""
}
</SingleEditor>
</div>
</div>
<div className="bottomdivs sortinxdirection intermediatecenter mt50" style={{
position:"absolute",
bottom: "0px",
}} >
<div className="divquxiao mr20 xiaoshou"><p className="divquxiaotest" >取消</p></div>
<div className="divbaocun xiaoshou"><p className="divbaocuntests" onClick={()=>this.preservation()}>保存</p></div>
</div>
{
item_type===null?
""
:
<div className="bottomdivs sortinxdirection intermediatecenter mt50" style={{
position:"absolute",
bottom: "0px",
}} >
<div className="divquxiao mr20 xiaoshou"><p className="divquxiaotest" >取消</p></div>
<div className="divbaocun xiaoshou"><p className="divbaocuntests" onClick={()=>this.preservation()}>保存</p></div>
</div>
}

@ -0,0 +1,327 @@
import React,{ Component } from "react";
import {
Form, Input, InputNumber, Switch, Radio,
Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Tooltip
} from 'antd';
import TPMMDEditor from '../../../modules/tpm/challengesnew/TPMMDEditor';
import axios from 'axios'
import update from 'immutability-helper'
import './../questioncss/questioncom.css';
import {getUrl, ActionBtn, DMDEditor, ConditionToolTip} from 'educoder';
const { TextArea } = Input;
const confirm = Modal.confirm;
const $ = window.$
const { Option } = Select;
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'
]
//题库的试卷 多选题 组件
class ChoquesEditor extends Component{
constructor(props){
super(props);
/**
choice_id: 32076
choice_position: 1
choice_text: "1"
standard_boolean: true
*/
const {question_choices} = this.props;
let _standard_answers = undefined;
let _question_choices = undefined;
if (question_choices) {
_standard_answers = []
_question_choices = []
question_choices.forEach((item, index) => {
_standard_answers.push(item.standard_boolean)
_question_choices.push(item.choice_text)
})
}
this.state = {
question_choices: _question_choices || ['', '', '', ''],
standard_answers: _standard_answers || [false, false, false, false],
question_title: this.props.question_title || '',
question_type: this.props.question_type || 0,
question_score: this.props.question_score || this.props.init_question_score,
question_titles:this.props.question_titles||'',
}
}
addOption = () => {
const { question_choices, standard_answers } = this.state;
// //console.log("addOption");
// //console.log(question_choices);
// //console.log(standard_answers);
question_choices.push('')
standard_answers.push(false)
this.setState({ question_choices, standard_answers })
}
deleteOption = (index) => {
let {question_choices}=this.state;
// //console.log("deleteOption");
// //console.log(question_choices);
if(question_choices[index]===""){
// repeat code
this.toMDMode(null)
this.setState(
(prevState) => ({
question_choices : update(prevState.question_choices, {$splice: [[index, 1]]}),
standard_answers : update(prevState.standard_answers, {$splice: [[index, 1]]})
})
)
}else{
this.props.confirm({
content: `确认要删除这个选项吗?`,
onOk: () => {
this.toMDMode(null)
this.setState(
(prevState) => ({
question_choices : update(prevState.question_choices, {$splice: [[index, 1]]}),
standard_answers : update(prevState.standard_answers, {$splice: [[index, 1]]})
})
)
}
})
}
}
onSave = () => {
var editordata=[];
const {question_title, question_score, question_type,question_titles, question_choices, standard_answers } = this.state;
const { question_id_to_insert_after, question_id } = this.props
// TODO check
const answerArray = standard_answers.map((item, index) => { return item == true ? index+1 : -1 }).filter(item => item != -1);
if(!question_title) {
this.refs['titleEditor'].showError()
this.props.showNotification('请您输入题干');
return editordata;
}
if(!answerArray || answerArray.length == 0) {
this.props.showNotification('请先点击选择本选择题的正确选项');
return editordata;
}
for(let i = 0; i < question_choices.length; i++) {
if (!question_choices[i]) {
this.refs[`optionEditor${i}`].showError()
this.props.showNotification(`请先输入 ${tagArray[i]} 选项的内容`);
return editordata;
}
}
if(!question_titles) {
this.refs['titleEditor2'].showError()
this.props.showNotification('请您输入题目解析');
return editordata;
}
/**
{
"question_title":"同学朋友间常用的沟通工具是什么?",
"question_type":1,
"question_score":5,
"question_choices":["a答案","b答案","c答案","d答案"],
"standard_answers":[1]
}*/
editordata=[question_title,answerArray,question_choices,question_titles];
// question_title,
// question_type: answerArray.length > 1 ? 1 : 0,
// question_score,
// question_choices,
// standard_answers: answerArray,
// insert_id: question_id_to_insert_after || undefined
return editordata;
}
onCancel = () => {
this.props.onEditorCancel()
}
componentDidMount = () => {
try {
this.props.getanswerMdRef(this);
}catch (e) {
}
}
onOptionClick = (index) => {
let standard_answers = this.state.standard_answers.slice(0)
standard_answers[index] = !standard_answers[index]
this.setState({ standard_answers })
}
onOptionContentChange = (value, index) => {
if (index >= this.state.question_choices.length) {
// TODO 新建然后删除CD选项再输入题干会调用到这里且index是3
return;
}
let question_choices = this.state.question_choices.slice(0);
question_choices[index] = value;
this.setState({ question_choices })
}
on_question_score_change = (e) => {
this.setState({ question_score: e })
}
toMDMode = (that) => {
if (this.mdReactObject) {
let mdReactObject = this.mdReactObject;
this.mdReactObject = null
mdReactObject.toShowMode()
}
this.mdReactObject = that;
}
toShowMode = () => {
}
render() {
let { question_title, question_score, question_type, question_choices, standard_answers,question_titles} = this.state;
let { question_id, index, exerciseIsPublish,
// question_title,
// question_type,
// question_score,
isNew } = this.props;
// const { getFieldDecorator } = this.props.form;
// const isAdmin = this.props.isAdmin()
// const courseId=this.props.match.params.coursesId;
// const isEdit = !!this.props.question_id
const qNumber = `question_`;
// TODO show模式 isNew为false isEdit为false
// [true, false, true] -> [0, 2]
const answerTagArray = standard_answers.map((item, index) => { return item == true ? tagArray[index] : -1 }).filter(item => item != -1);
// //console.log("xuanzheshijuan");
// //console.log(answerTagArray);
// //console.log(!exerciseIsPublish);
return(
<div className="padding20-30 bor-bottom-greyE signleEditor duoxuano" id={qNumber}>
<style>{`
.optionMdEditor {
flex:1
}
.optionRow {
margin:0px!important;
/* margin-bottom: 20px!important; */
}
.signleEditor .content_editorMd_show{
display: flex;
margin-top:0px!important;
border-radius:2px;
max-width: 1056px;
word-break:break-all;
}
#e_tips_mdEditor_question_undefined4{
display: none;
}
`}</style>
<p className="mb10 clearfix">
{/* {!question_id ? '新建' : '编辑'} */}
<span className="xingcolor font-16 fl mr4">*</span>
<span className="xingtigan fl">题干</span>
</p>
<TPMMDEditor mdID={qNumber} placeholder="请您输入题干" height={155} className=" mt10"
initValue={question_title} onChange={(val) => this.setState({ question_title: val})}
ref="titleEditor"
></TPMMDEditor>
<div className="mb10 sortinxdirection">
{/* {!question_id ? '新建' : '编辑'} */}
<span className="xingcolor font-16 fl mr4">*</span>
<span className="xingtigans fl"><span className="xingtigan">答案选项</span></span>
</div>
{question_choices.map( (item, index) => {
const bg = standard_answers[index] ? 'check-option-bg' : ''
return <div className="df optionRow " >
{/* 点击设置答案 */}
{/* TODO 加了tooltip后会丢失掉span的class */}
{/* <Tooltip title={standard_answers[index] ? '点击取消标准答案设置' : '点击设置为标准答案'}> */}
<span class={`option-item fr mr10 color-grey select-choice ${bg} `}
name="option_span" onClick={() => this.onOptionClick(index)} style={{flex: '0 0 38px'}}>
<ConditionToolTip title={standard_answers[index] ? '点击取消标准答案设置' : '点击设置为标准答案'} placement="left" condition={true}>
<div style={{width: '100%', height: '100%'}}>{tagArray[index]}</div>
</ConditionToolTip>
</span>
{/* </Tooltip> */}
<div style={{ flex: '0 0 1038px'}}>
<DMDEditor
ref={`optionEditor${index}`}
toMDMode={this.toMDMode} toShowMode={this.toShowMode}
height={166} className={'optionMdEditor'} noStorage={true}
mdID={qNumber + index} placeholder="" onChange={(value) => this.onOptionContentChange(value, index)}
initValue={item}
></DMDEditor>
</div>
{exerciseIsPublish || index<=2?
<i className=" font-18 ml15 mr20"></i>
:<Tooltip title="删除">
<i className="iconfont icon-htmal5icon19 font-18 color-grey-c ml15" onClick={() => this.deleteOption(index)}></i>
</Tooltip> }
{ !exerciseIsPublish && index<7 && <Tooltip title={`新增参考答案`}>
<i className="color-green font-16 iconfont icon-roundaddfill ml6"
onClick={() => this.addOption()}
style={{float: 'right', visibility: index == question_choices.length - 1 ? '' : 'hidden', marginTop: '2px'}}
></i>
</Tooltip>}
</div>
}) }
<div>
<p className="mb10 clearfix">
{/* {!question_id ? '新建' : '编辑'} */}
<span className="xingcolor font-16 fl mr4">*</span>
<span className="xingtigan fl">题目解析</span>
</p>
<style>{`
.optionMdEditor {
flex:1
}
.optionRow {
margin:0px!important;
/* margin-bottom: 20px!important; */
}
.signleEditor .content_editorMd_show{
display: flex;
margin-top:0px!important;
border-radius:2px;
max-width: 1056px;
word-break:break-all;
}
`}</style>
<TPMMDEditor mdID={qNumber+question_choices.length} placeholder="请您输入题目解析" height={155} className=" mt10"
initValue={question_titles} onChange={(val) => this.setState({ question_titles: val})}
ref="titleEditor2"
></TPMMDEditor>
</div>
</div>
)
}
}
// RouteHOC()
export default (ChoquesEditor);

@ -71,8 +71,8 @@ class Contentpart extends Component {
);
const buttonWidth = 70;
console.log("Contentpart");
console.log(this.props);
//console.log("Contentpart");
//console.log(this.props);
return (
<div className=" clearfix mt5">
<div className="educontent mt10 pb20 w1200s">

@ -20,9 +20,9 @@ class Contentquestionbank extends Component {
}
//初始化
componentDidMount(){
console.log("componentDidMount");
console.log(this.state);
console.log(this.props);
//console.log("componentDidMount");
//console.log(this.state);
//console.log(this.props);
// let homeworkid = this.props.match.params.homeworkid;
// let url = "/homework_commons/" + homeworkid + "/end_groups.json";
// axios.get(url).then((response) => {
@ -30,12 +30,12 @@ class Contentquestionbank extends Component {
// this.setState({})
// }
// }).catch((error) => {
// console.log(error)
// //console.log(error)
// });
}
onChange=(e)=> {
console.log(`checked = ${e.target.checked}`);
//console.log(`checked = ${e.target.checked}`);
}
render() {

@ -58,7 +58,7 @@ class Itembankstop extends Component {
this.contentMdRef = React.createRef()
this.state = {
page:1,
Knowpoints:[]
Knowpoints:[],
}
}
//初始化
@ -68,9 +68,9 @@ class Itembankstop extends Component {
}catch (e) {
}
console.log("componentDidMount");
console.log(this.state);
console.log(this.props);
//console.log("componentDidMount");
//console.log(this.state);
//console.log(this.props);
// let homeworkid = this.props.match.params.homeworkid;
// let url = "/homework_commons/" + homeworkid + "/end_groups.json";
// axios.get(url).then((response) => {
@ -78,12 +78,12 @@ class Itembankstop extends Component {
// this.setState({})
// }
// }).catch((error) => {
// console.log(error)
// //console.log(error)
// });
}
onChange=(e)=> {
console.log(`checked = ${e.target.checked}`);
//console.log(`checked = ${e.target.checked}`);
}
Getdatas=()=>{
return this.handleSubmits();
@ -93,8 +93,8 @@ class Itembankstop extends Component {
this.props.form.validateFields((err, values) => {
data=[]
if (!err) {
// console.log("获取的form 数据");
// console.log(values);
// //console.log("获取的form 数据");
// //console.log(values);
data= values;
}
});
@ -106,8 +106,8 @@ class Itembankstop extends Component {
e.preventDefault();
this.props.form.validateFields((err, values) => {
if (!err) {
console.log("获取的form 数据");
console.log(values);
//console.log("获取的form 数据");
//console.log(values);
}
@ -117,8 +117,8 @@ class Itembankstop extends Component {
handleFormLayoutChange=(value)=>{
//难度塞选
console.log("难度塞选");
console.log(value);
//console.log("难度塞选");
//console.log(value);
this.props.form.setFieldsValue({
rbnd:value,
});
@ -126,8 +126,8 @@ class Itembankstop extends Component {
}
handleFormkechen=(value)=>{
//课程
console.log("课程");
console.log(value);
//console.log("课程");
//console.log(value);
this.props.form.setFieldsValue({
rbkc:value,
});
@ -136,8 +136,8 @@ class Itembankstop extends Component {
handleFormzhishidian=(value)=>{
//知识点
console.log("知识点");
console.log(value);
//console.log("知识点");
//console.log(value);
this.props.form.setFieldsValue({
rbzsd:value,
});
@ -148,16 +148,16 @@ class Itembankstop extends Component {
handleFormtixing=(value)=>{
//题型
console.log("题型");
console.log(value);
//console.log("题型");
//console.log(value);
this.props.form.setFieldsValue({
rbtx:value,
});
this.props.setitem_type(value);
}
preventDefault=(e)=> {
e.preventDefault();
console.log('Clicked! But prevent default.');
//console.log('Clicked! But prevent default.');
}
deletesobject=(item,index)=>{
var tmp = JSON.parse(JSON.stringify(this.state.Knowpoints));
@ -175,13 +175,16 @@ class Itembankstop extends Component {
Knowpoints:this.state.Knowpoints,
})
// console.log("deletesobject");
// console.log(item);
// console.log(index);
// console.log(this.state.Knowpoints);
// console.log("tmp");
// console.log(tmp);
// //console.log("deletesobject");
// //console.log(item);
// //console.log(index);
// //console.log(this.state.Knowpoints);
// //console.log("tmp");
// //console.log(tmp);
}
render() {
let {page}=this.state;
const { getFieldDecorator } = this.props.form;
@ -210,6 +213,10 @@ class Itembankstop extends Component {
.ant-input {
height: 33px !important;
}
.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):focus-within {
outline: 0px solid rgba(24, 144, 255, 0.06) !important;
}
`
}
@ -280,8 +287,10 @@ class Itembankstop extends Component {
)(
<InputGroup compact>
<Select style={{ width: '258px' }} onChange={this.handleFormtixing} placeholder="请选择...">
<Option value="Home">Home</Option>
<Option value="Company">Company</Option>
<Option value="SINGLE">单选题</Option>
<Option value="MULTIPLE">多选题</Option>
<Option value="JUDGMENT">判断题</Option>
<Option value="PROGRAM">编程题</Option>
</Select>
</InputGroup>
)}
@ -349,9 +358,9 @@ class Itembankstop extends Component {
)(
<Radio.Group onChange={this.handleFormLayoutChange} >
<Radio.Button value="0">简单</Radio.Button>
<Radio.Button value="1">适中</Radio.Button>
<Radio.Button value="2">困难</Radio.Button>
<Radio.Button value="1">简单</Radio.Button>
<Radio.Button value="2">适中</Radio.Button>
<Radio.Button value="3">困难</Radio.Button>
</Radio.Group>,
)}
</Form.Item>

@ -0,0 +1,318 @@
import React,{ Component } from "react";
import {
Form, Input, InputNumber, Switch, Radio,
Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Tooltip
} from 'antd';
import TPMMDEditor from '../../../modules/tpm/challengesnew/TPMMDEditor';
import axios from 'axios'
import update from 'immutability-helper'
import './../questioncss/questioncom.css';
import {getUrl, ActionBtn, DMDEditor, ConditionToolTip} from 'educoder';
const { TextArea } = Input;
const confirm = Modal.confirm;
const $ = window.$
const { Option } = Select;
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'
]
//题库的试卷 判断题 组件
class JudquestionEditor extends Component{
constructor(props){
super(props);
/**
choice_id: 32076
choice_position: 1
choice_text: "1"
standard_boolean: true
*/
const {question_choices} = this.props;
let _standard_answers = undefined;
let _question_choices = undefined;
if (question_choices) {
_standard_answers = []
_question_choices = []
question_choices.forEach((item, index) => {
_standard_answers.push(item.standard_boolean)
_question_choices.push(item.choice_text)
})
}
this.state = {
question_choices: _question_choices || ['', '', '', ''],
standard_answers: _standard_answers || [false, false, false, false],
question_title: this.props.question_title || '',
question_type: this.props.question_type || 0,
question_score: this.props.question_score || this.props.init_question_score,
question_titles:this.props.question_titles||'',
zqda:null
}
}
addOption = () => {
const { question_choices, standard_answers } = this.state;
// ////console.log("addOption");
// ////console.log(question_choices);
// ////console.log(standard_answers);
question_choices.push('')
standard_answers.push(false)
this.setState({ question_choices, standard_answers })
}
deleteOption = (index) => {
let {question_choices}=this.state;
// ////console.log("deleteOption");
// ////console.log(question_choices);
if(question_choices[index]===""){
// repeat code
this.toMDMode(null)
this.setState(
(prevState) => ({
question_choices : update(prevState.question_choices, {$splice: [[index, 1]]}),
standard_answers : update(prevState.standard_answers, {$splice: [[index, 1]]})
})
)
}else{
this.props.confirm({
content: `确认要删除这个选项吗?`,
onOk: () => {
this.toMDMode(null)
this.setState(
(prevState) => ({
question_choices : update(prevState.question_choices, {$splice: [[index, 1]]}),
standard_answers : update(prevState.standard_answers, {$splice: [[index, 1]]})
})
)
}
})
}
}
onSave = () => {
var editordata=[];
const {question_title, question_score, question_type,question_titles, zqda,question_choices, standard_answers } = this.state;
const { question_id_to_insert_after, question_id } = this.props
// TODO check
const answerArray = standard_answers.map((item, index) => { return item == true ? index+1 : -1 }).filter(item => item != -1);
if(!question_title) {
this.refs['titleEditor'].showError()
this.props.showNotification('请您输入题干');
return editordata;
}
if(zqda===null) {
this.props.showNotification('请先点击选择本选择题的正确选项');
return editordata;
}
if(!question_titles) {
this.refs['titleEditor2'].showError()
this.props.showNotification('请您输入题目解析');
return editordata;
}
/**
{
"question_title":"同学朋友间常用的沟通工具是什么?",
"question_type":1,
"question_score":5,
"question_choices":["a答案","b答案","c答案","d答案"],
"standard_answers":[1]
}*/
editordata=[question_title,zqda,question_titles];
// question_title,
// question_type: answerArray.length > 1 ? 1 : 0,
// question_score,
// question_choices,
// standard_answers: answerArray,
// insert_id: question_id_to_insert_after || undefined
return editordata;
}
onCancel = () => {
this.props.onEditorCancel()
}
componentDidMount = () => {
try {
this.props.getanswerMdRef(this);
}catch (e) {
}
}
onOptionClick = (index) => {
let standard_answers = this.state.standard_answers.slice(0);
// ////console.log("onOptionClick");
// ////console.log(standard_answers);
// ////console.log(standard_answers[index]);
// ////console.log(!standard_answers[index]);
for (var i=0;i<standard_answers.length;i++){
if(index===i){
standard_answers[index] = true;
}else{
standard_answers[i] = false;
}
}
// standard_answers[index] = !standard_answers[index];
this.setState({ standard_answers })
}
onOptionContentChange = (value, index) => {
if (index >= this.state.question_choices.length) {
// TODO 新建然后删除CD选项再输入题干会调用到这里且index是3
return;
}
let question_choices = this.state.question_choices.slice(0);
question_choices[index] = value;
this.setState({ question_choices })
}
on_question_score_change = (e) => {
this.setState({ question_score: e })
}
toMDMode = (that) => {
if (this.mdReactObject) {
let mdReactObject = this.mdReactObject;
this.mdReactObject = null
mdReactObject.toShowMode()
}
this.mdReactObject = that;
}
toShowMode = () => {
}
handleFormLayoutChange=(e)=>{
////console.log("难度塞选");
////console.log(value);
this.setState({
zqda:e.target.value,
})
}
render() {
let { question_title, question_score, question_type, question_choices, standard_answers,question_titles} = this.state;
let { question_id, index, exerciseIsPublish,
// question_title,
// question_type,
// question_score,
isNew } = this.props;
// const { getFieldDecorator } = this.props.form;
// const isAdmin = this.props.isAdmin()
// const courseId=this.props.match.params.coursesId;
// const isEdit = !!this.props.question_id
const qNumber = `question_`;
// TODO show模式 isNew为false isEdit为false
// [true, false, true] -> [0, 2]
const answerTagArray = standard_answers.map((item, index) => { return item == true ? tagArray[index] : -1 }).filter(item => item != -1);
// ////console.log("xuanzheshijuan");
// ////console.log(answerTagArray);
// ////console.log(!exerciseIsPublish);
return(
<div className="padding20-30 bor-bottom-greyE signleEditor danxuano" id={qNumber}>
<style>{`
.optionMdEditor {
flex:1
}
.optionRow {
margin:0px!important;
/* margin-bottom: 20px!important; */
}
.signleEditor .content_editorMd_show{
display: flex;
margin-top:0px!important;
border-radius:2px;
max-width: 1056px;
word-break:break-all;
}
#e_tips_mdEditor_question_undefined4{
display: none;
}
`}</style>
<p className="mb10 clearfix">
{/* {!question_id ? '新建' : '编辑'} */}
<span className="xingcolor font-16 fl mr4">*</span>
<span className="xingtigan fl">题干</span>
</p>
<TPMMDEditor mdID={qNumber} placeholder="请您输入题干" height={155} className=" mt10"
initValue={question_title} onChange={(val) => this.setState({ question_title: val})}
ref="titleEditor"
></TPMMDEditor>
<div className="mb10 sortinxdirection">
{/* {!question_id ? '新建' : '编辑'} */}
<span className="xingcolor font-16 fl mr4">*</span>
<span className="xingtigans fl"><span className="xingtigan">答案选项</span></span>
</div>
<div className="mb10 sortinxdirection">
<Radio.Group buttonStyle="solid" onChange={this.handleFormLayoutChange}>
<Radio.Button value="0">正确</Radio.Button>
<Radio.Button value="1">错误</Radio.Button>
</Radio.Group>
</div>
<div>
<p className="mb10 clearfix">
{/* {!question_id ? '新建' : '编辑'} */}
<span className="xingcolor font-16 fl mr4">*</span>
<span className="xingtigan fl">题目解析</span>
</p>
<style>{`
.optionMdEditor {
flex:1
}
.optionRow {
margin:0px!important;
/* margin-bottom: 20px!important; */
}
.signleEditor .content_editorMd_show{
display: flex;
margin-top:0px!important;
border-radius:2px;
max-width: 1056px;
word-break:break-all;
}
`}</style>
<TPMMDEditor mdID={qNumber+question_choices.length} placeholder="请您输入题目解析" height={155} className=" mt10"
initValue={question_titles} onChange={(val) => this.setState({ question_titles: val})}
ref="titleEditor2"
></TPMMDEditor>
</div>
</div>
)
}
}
// RouteHOC()
export default (JudquestionEditor);

@ -42,8 +42,8 @@ class Listjihe extends Component {
let {page,name,nd,chakanjiexibool}=this.state;
let {defaultActiveKey}=this.props;
console.log("Listjihe");
console.log(this.props);
//console.log("Listjihe");
//console.log(this.props);
return (
<div className={chakanjiexibool===true?"w100s borderwds283 pd20 mb20":"w100s borderwds pd20 mb20"}>
{/*顶部*/}

@ -53,7 +53,13 @@ class SingleEditor extends Component{
}
}
addOption = () => {
const { question_choices, standard_answers } = this.state;
// //console.log("addOption");
// //console.log(question_choices);
// //console.log(standard_answers);
question_choices.push('')
standard_answers.push(false)
this.setState({ question_choices, standard_answers })
@ -61,8 +67,8 @@ class SingleEditor extends Component{
deleteOption = (index) => {
let {question_choices}=this.state;
// console.log("deleteOption");
// console.log(question_choices);
// //console.log("deleteOption");
// //console.log(question_choices);
if(question_choices[index]===""){
// repeat code
@ -152,10 +158,10 @@ class SingleEditor extends Component{
onOptionClick = (index) => {
let standard_answers = this.state.standard_answers.slice(0);
// console.log("onOptionClick");
// console.log(standard_answers);
// console.log(standard_answers[index]);
// console.log(!standard_answers[index]);
// //console.log("onOptionClick");
// //console.log(standard_answers);
// //console.log(standard_answers[index]);
// //console.log(!standard_answers[index]);
for (var i=0;i<standard_answers.length;i++){
if(index===i){
standard_answers[index] = true;
@ -210,12 +216,12 @@ class SingleEditor extends Component{
// [true, false, true] -> [0, 2]
const answerTagArray = standard_answers.map((item, index) => { return item == true ? tagArray[index] : -1 }).filter(item => item != -1);
// console.log("xuanzheshijuan");
// console.log(answerTagArray);
// console.log(!exerciseIsPublish);
// //console.log("xuanzheshijuan");
// //console.log(answerTagArray);
// //console.log(!exerciseIsPublish);
return(
<div className="padding20-30 bor-bottom-greyE signleEditor" id={qNumber}>
<div className="padding20-30 bor-bottom-greyE signleEditor danxuano" id={qNumber}>
<style>{`
.optionMdEditor {
flex:1
@ -280,7 +286,7 @@ class SingleEditor extends Component{
:<Tooltip title="删除">
<i className="iconfont icon-htmal5icon19 font-18 color-grey-c ml15" onClick={() => this.deleteOption(index)}></i>
</Tooltip> }
{ !exerciseIsPublish && <Tooltip title={`新增参考答案`}>
{ !exerciseIsPublish && index<7 && <Tooltip title={`新增参考答案`}>
<i className="color-green font-16 iconfont icon-roundaddfill ml6"
onClick={() => this.addOption()}
style={{float: 'right', visibility: index == question_choices.length - 1 ? '' : 'hidden', marginTop: '2px'}}

@ -506,3 +506,33 @@
background:rgba(76,172,255,1);
border-radius:4px;
}
.sortzhenque{
width:49px;
height:33px;
border-radius:2px;
border:1px solid rgba(221,221,221,1);
}
.sortzhenquetest{
width:100%;
height:33px;
font-size:14px;
color:rgba(51,51,51,1);
line-height:33px;
}
.sortquxiao{
width:49px;
height:33px;
border-radius:2px;
border:1px solid rgba(221,221,221,1);
}
.sortquxiaotest{
width:100%;
height:33px;
font-size:14px;
color:rgba(51,51,51,1);
line-height:33px;
}

Loading…
Cancel
Save