diff --git a/public/react/src/images/path/path.png b/public/react/src/images/path/path.png new file mode 100644 index 000000000..594358959 Binary files /dev/null and b/public/react/src/images/path/path.png differ diff --git a/public/react/src/modules/courses/poll/PollNew.js b/public/react/src/modules/courses/poll/PollNew.js index 4529ade6b..c95ff844e 100644 --- a/public/react/src/modules/courses/poll/PollNew.js +++ b/public/react/src/modules/courses/poll/PollNew.js @@ -70,6 +70,7 @@ class PollNew extends Component { Newdisplay:false, first_category_url:"", left_banner_id:"", + publishtimeid_int:0, } // console.log("试卷新建和编辑"); // console.log(JSON.stringify(props)); @@ -366,7 +367,12 @@ class PollNew extends Component { } //添加单选题目 addmysingles = () => { + if (this.state.q_countst > 0) { + this.scrollToAnchor("publishtimeid"+this.state.publishtimeid_int); + this.props.showNotification(`不能同时编辑两题`); + return; + } if (this.state.newoption === true) { this.setState({ newoption: false @@ -383,12 +389,18 @@ class PollNew extends Component { } } - this.addMytopic(1, this.state.pollid, Insertposition, false, 0); - // } + this.addMytopic(1, this.state.pollid, Insertposition, false, 0,0); + this.scrollToAnchor("publishtimeids"); } //添加多选题目 addmydoubles = () => { + if (this.state.q_countst > 0) { + this.scrollToAnchor("publishtimeid"+this.state.publishtimeid_int); + this.props.showNotification(`不能同时编辑两题`); + + return; + } // console.log("addmymainsint 70") if (this.state.newoption === true) { this.setState({ @@ -407,13 +419,17 @@ class PollNew extends Component { } - this.addMytopic(2, this.state.pollid, Insertposition, false, 0); - - // } + this.addMytopic(2, this.state.pollid, Insertposition, false, 0,0); + this.scrollToAnchor("publishtimeids"); } //添加主观题目 addmymainsint = () => { + if (this.state.q_countst > 0) { + this.scrollToAnchor("publishtimeid"+this.state.publishtimeid_int); + this.props.showNotification(`不能同时编辑两题`); + return; + } this.setState({ Newdisplay:true, }) @@ -427,22 +443,23 @@ class PollNew extends Component { } - this.addMytopic(3, this.state.pollid, Insertposition, false, 0); - // } + this.addMytopic(3, this.state.pollid, Insertposition, false, 0,0); + this.scrollToAnchor("publishtimeids"); } //编辑方法 - adddomedit = (object) => { + adddomedit = (object,indexysl) => { // console.log("adddomedit 76"); if (this.state.q_countst > 0) { this.props.showNotification(`不能同时编辑两题`); - + this.scrollToAnchor("publishtimeids"); return; } var anserbool = false; this.setState({ q_countst: 1, - bindingid:object.question.id + bindingid:object.question.id, + publishtimeid_int:indexysl }) // window.scrollTo(0, this.refs.targetElement.offsetTops) let {adddom} = this.state; @@ -581,9 +598,19 @@ class PollNew extends Component { }) } - + //滚动 + scrollToAnchor=(index)=>{ + // let name="Anchor_"+index; + console.log("scrollToAnchor"); + console.log(index); + if (index) { + let anchorElement = document.getElementById(index); + // if(anchorElement) { anchorElement.scrollIntoView(); } + $("html").animate({ scrollTop: $(anchorElement).offset().top - 150}) + } + } //新增添加题目 有new - addMytopic = (index, pollid, Insertposition, Whether, id) => { + addMytopic = (index, pollid, Insertposition, Whether, id,inty) => { //Whether 是否插入 // console.log("addMytopic 90") // console.log(index) @@ -593,10 +620,17 @@ class PollNew extends Component { console.log("addMytopic"); console.log(id); if (this.state.q_countst > 0) { + if(Whether===true){ + this.scrollToAnchor("publishtimeids"); + } this.props.showNotification(`不能同时编辑两题`); - return; } + if(Whether===true){ + this.setState({ + publishtimeid_int:inty, + }) + } this.state.Insertposition = Insertposition; var Whethername = null; if (Whether === true) { @@ -2081,32 +2115,67 @@ class PollNew extends Component { axios.post(url, { opr: "up", }).then((result) => { + // try { + // if (result.data.status === 0) { + // this.props.showNotification(`上移成功`); + // thiss.thisinitializationdatanew(); + // } + // // console.log(JSON.stringify(result)) + // } catch (e) { + // // console.log("上移题目成功 错误") + // console.log(e) + // } try { - if (result.data.status === 0) { - this.props.showNotification(`上移成功`); - thiss.thisinitializationdatanew(); + if(result){ + if(result.data){ + if (result.data.status === 0) { + this.props.showNotification(`上移成功`); + thiss.thisinitializationdatanew(); + }else{ + this.props.showNotification(`上移失败`); + } + } + }else { + this.props.showNotification(`上移失败`); } - // console.log(JSON.stringify(result)) } catch (e) { - // console.log("上移题目成功 错误") - console.log(e) - } + this.props.showNotification(`上移失败`); + } }) } else { var url = `/poll_questions/${poll_question_id}/up_down.json`; axios.post(url, { opr: "down", }).then((result) => { + // try { + // if (result.data.status === 0) { + // // message.success("下移题目成功", 1) + // this.props.showNotification(`下移成功`); + // thiss.thisinitializationdatanew(); + // } + // // console.log(JSON.stringify(result)) + // } catch (e) { + // // console.log("下移题目成功 错误") + // console.log(e) + // } + + try { - if (result.data.status === 0) { - // message.success("下移题目成功", 1) - this.props.showNotification(`下移成功`); - thiss.thisinitializationdatanew(); + if(result){ + if(result.data){ + if (result.data.status === 0) { + this.props.showNotification(`下移成功`); + thiss.thisinitializationdatanew(); + }else { + this.props.showNotification(`下移失败`); + } + }else { + this.props.showNotification(`上移失败`); + } } - // console.log(JSON.stringify(result)) } catch (e) { - // console.log("下移题目成功 错误") + this.props.showNotification(`上移失败`); console.log(e) } }) @@ -2243,17 +2312,17 @@ class PollNew extends Component { //点击向上排序按钮事件 handleClickBySortUp = (index, object) => { // console.log("handleClickBySortUp 521") - let arr = this.state.poll_questions; - let newarr = [...arr]; + // let arr = this.state.poll_questions; + // let newarr = [...arr]; // console.log(newarr) if (index != 0) { this.Upanddownmovementof(true, object.question.id); - let temp = newarr[index - 1]; - newarr[index - 1] = newarr[index]; - newarr[index] = temp; - this.setState({ - poll_questions: newarr, - }); + // let temp = newarr[index - 1]; + // newarr[index - 1] = newarr[index]; + // newarr[index] = temp; + // this.setState({ + // poll_questions: newarr, + // }); } } @@ -2265,12 +2334,12 @@ class PollNew extends Component { // if (index != newarr.length - 1) { this.Upanddownmovementof(false, object.question.id); - let temp = newarr[index + 1]; - newarr[index + 1] = newarr[index]; - newarr[index] = temp; - this.setState({ - poll_questions: newarr, - }); + // let temp = newarr[index + 1]; + // newarr[index + 1] = newarr[index]; + // newarr[index] = temp; + // this.setState({ + // poll_questions: newarr, + // }); } else { // console.log("2222index==arr.length"); // console.log(this.state.poll_questions); @@ -2897,12 +2966,12 @@ class PollNew extends Component { title="下移">} this.addMytopic(item.question.question_type, this.state.pollid, index + 1, true, item.question.id)}> this.addMytopic(item.question.question_type, this.state.pollid, index + 1, true, item.question.id,index)}> - this.adddomedit(item)}> this.adddomedit(item,index)}> - : this.adddomedit(item)}> : this.adddomedit(item,index)}> } @@ -2959,7 +3028,7 @@ class PollNew extends Component { let arrid = itemo.question.id; let resultDomtwo; resultDomtwo = -
+
{itemo.question.question_type === 1 ? "单选题" : itemo.question.question_type === 2 ? "多选题" : "主观题"} +
{itemo.question.question_type === 1 ? "单选题" : itemo.question.question_type === 2 ? "多选题" : "主观题"} +
{itemo.question.question_type === 1 ? "单选题" : itemo.question.question_type === 2 ? "多选题" : "主观题"}