From cfb7fc728015dc0f475192fbaca798e91a7ceb6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Fri, 30 Aug 2019 15:45:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../groupjobbank/Groupjobquesanswer.js | 8 +- .../react/src/modules/courses/poll/PollNew.js | 30 ++- .../modules/courses/poll/PollNewQuestbank.js | 220 ++++++++++-------- 3 files changed, 153 insertions(+), 105 deletions(-) diff --git a/public/react/src/modules/courses/groupjobbank/Groupjobquesanswer.js b/public/react/src/modules/courses/groupjobbank/Groupjobquesanswer.js index f0b2be9cd..374aca841 100644 --- a/public/react/src/modules/courses/groupjobbank/Groupjobquesanswer.js +++ b/public/react/src/modules/courses/groupjobbank/Groupjobquesanswer.js @@ -10,6 +10,7 @@ import { Tooltip, notification, } from "antd"; +import AttachmentsList from '../..' import GroupPackage from './GroupPackage'; import GroupPackage2 from './GroupPackage2'; import './questionbanks.css'; @@ -63,11 +64,8 @@ class Groupjobquesanswer extends Component {
- {datas.attachments === undefined ? "" : datas.attachments.map((item, key) => { - return ( - - ) - })} + {datas.attachments === undefined ? "" : } +
diff --git a/public/react/src/modules/courses/poll/PollNew.js b/public/react/src/modules/courses/poll/PollNew.js index 171a27c5e..e269cd8e9 100644 --- a/public/react/src/modules/courses/poll/PollNew.js +++ b/public/react/src/modules/courses/poll/PollNew.js @@ -280,9 +280,13 @@ class PollNew extends Component { questionnair: true, left_banner_id:result.data.left_banner_id }) - // console.log(this.state.polls_nametest) - // console.log(this.state.polls_descriptiontest) - // } + if( result.data.poll.polls_name){ + if( result.data.poll.polls_name.length>0){ + this.setState({ + addonAfter: result.data.poll.polls_name.length, + }) + } + } }).catch((error) => { console.log(error) }) @@ -326,7 +330,13 @@ class PollNew extends Component { polls_descriptiontest: result.data.poll.polls_description, questionnair: true, }) - + if( result.data.poll.polls_name){ + if( result.data.poll.polls_name.length>0){ + this.setState({ + addonAfter: result.data.poll.polls_name.length, + }) + } + } // } }).catch((error) => { console.log(error) @@ -2454,8 +2464,9 @@ class PollNew extends Component { // console.log(this.state.projects===undefined?"":this.state.projects.poll_questions) var displaymysave = (mysave === true) ? "" : "display:none;"; + return ( -
+
{/*提示*/} {Modalstype && Modalstype === true ? : ""} -
+ +

this.gotohome()}>{this.props.coursedata.name} > diff --git a/public/react/src/modules/courses/poll/PollNewQuestbank.js b/public/react/src/modules/courses/poll/PollNewQuestbank.js index de9d461dc..0f5d56677 100644 --- a/public/react/src/modules/courses/poll/PollNewQuestbank.js +++ b/public/react/src/modules/courses/poll/PollNewQuestbank.js @@ -243,39 +243,51 @@ class PollNewQuestbank extends Component { } else { const url = `/exercise_banks/${pollid}.json`; axios.get(url).then((result) => { - if (result) - console.log("247"); - console.log(result); - - // if(result.data){ - // if(result.data.poll){ - // if(result.data.poll.polls_name){ - // let num = parseInt(result.data.poll.polls_name.length); - // this.setState({ - // addonAfter: num < 0 ? 0 : num - // }) - // } - // } - // - // } - // - // this.setState({ - // projects: result.data, - // pollid: pollid, - // polls_status: result.data.poll.polls_status, - // polls_name: result.data.poll.polls_name, - // polls_description: result.data.poll.polls_description, - // poll_questions: result.data.poll_questions, - // question_types: result.data.question_types, - // mysingles: result.data.question_types.q_singles, - // mydoubles: result.data.question_types.q_doubles, - // mymainsint: result.data.question_types.q_mains, - // polls_nametest: result.data.poll.polls_name, - // polls_descriptiontest: result.data.poll.polls_description, - // questionnair: true, - // left_banner_id:result.data.left_banner_id - // }) + if (result){ + console.log("247"); + console.log(result); + + + } + + + if(result.data){ + if(result.data.poll){ + if(result.data.poll.polls_name){ + let num = parseInt(result.data.poll.polls_name.length); + this.setState({ + addonAfter: num < 0 ? 0 : num + }) + } + } + + } + + this.setState({ + projects: result.data, + pollid: pollid, + polls_status: 1, + polls_name: result.data.poll.name, + polls_description: result.data.poll.description, + poll_questions: result.data.questions, + question_types: result.data.question_types, + mysingles: result.data.question_types.q_singles, + mydoubles: result.data.question_types.q_doubles, + mymainsint: result.data.question_types.q_mains, + q_counts: result.data.question_types.q_counts, + polls_nametest: result.data.poll.name, + polls_descriptiontest: result.data.poll.description, + questionnair: true, + left_banner_id:result.data.left_banner_id + }) + if(result.data.poll.name){ + if(result.data.poll.name.length>0){ + this.setState({ + addonAfter:result.data.poll.name.length, + }) + } + } }).catch((error) => { console.log(error) }) @@ -300,26 +312,40 @@ class PollNewQuestbank extends Component { const url = `/exercise_banks/${pollidsy}.json`; axios.get(url).then((result) => { if (result !== undefined){ + this.setState({ + projects: result.data, + pollid: pollid, + polls_status: 1, + polls_name: result.data.poll.name, + polls_description: result.data.poll.description, + poll_questions: result.data.questions, + question_types: result.data.question_types, + mysingles: result.data.question_types.q_singles, + mydoubles: result.data.question_types.q_doubles, + mymainsint: result.data.question_types.q_mains, + q_counts: result.data.question_types.q_counts, + polls_nametest: result.data.poll.name, + polls_descriptiontest: result.data.poll.description, + questionnair: true, + left_banner_id:result.data.left_banner_id + }); + + + + + if(result.data.poll.name){ + if(result.data.poll.name.length>0){ + this.setState({ + addonAfter:result.data.poll.name.length, + }) + } + } } // console.log("有问卷~~~") - // this.setState({ - // projects: result.data, - // pollid: pollidsy, - // polls_status: result.data.poll.polls_status, - // polls_name: result.data.poll.polls_name, - // polls_description: result.data.poll.polls_description, - // poll_questions: result.data.poll_questions, - // question_types: result.data.question_types, - // mysingles: result.data.question_types.q_singles, - // mydoubles: result.data.question_types.q_doubles, - // mymainsint: result.data.question_types.q_mains, - // polls_nametest: result.data.poll.polls_name, - // polls_descriptiontest: result.data.poll.polls_description, - // questionnair: true, - // }) + // } }).catch((error) => { @@ -2326,41 +2352,41 @@ class PollNewQuestbank extends Component { } // 创建问卷 onSaveExercise = () => { - if (this.state.Newedit === true) { - - if (this.state.polls_nametest === undefined || this.state.polls_nametest === "") { - this.props.showNotification(`请输入标题`); - return - } - let coursesId = this.props.match.params.coursesId; - const urlls = `/courses/${coursesId}/polls.json` - axios.post(urlls, { - polls_name: this.state.polls_nametest, - polls_description: this.state.polls_descriptiontest - }).then((result) => { - if (result === undefined) { - return; - } - this.state.Newedit === false; - this.props.showNotification(`问卷创建成功!`); - this.setState({ - pollid: result.data.data.id, - Newedit: false, - mysave: false, - readOnlys: "readOnly", - cancellation: false, - }); - // var currenturl = window.location.href; - // var newUrl = (currenturl.split("?"))[0]; - // var newr=(newUrl.slice("new"))[0]; - // console.log(newUrl); - // console.log("2301"); - // console.log(newr); - // window.history.pushState('','',newUrl+'?tab='+e); - window.location.href = `/courses/${coursesId}/polls/${result.data.data.id}/edit`; - - }) - } else { + // if (this.state.Newedit === true) { + // + // if (this.state.polls_nametest === undefined || this.state.polls_nametest === "") { + // this.props.showNotification(`请输入标题`); + // return + // } + // let coursesId = this.props.match.params.coursesId; + // const urlls = `/courses/${coursesId}/polls.json` + // axios.post(urlls, { + // polls_name: this.state.polls_nametest, + // polls_description: this.state.polls_descriptiontest + // }).then((result) => { + // if (result === undefined) { + // return; + // } + // this.state.Newedit === false; + // this.props.showNotification(`问卷创建成功!`); + // this.setState({ + // pollid: result.data.data.id, + // Newedit: false, + // mysave: false, + // readOnlys: "readOnly", + // cancellation: false, + // }); + // // var currenturl = window.location.href; + // // var newUrl = (currenturl.split("?"))[0]; + // // var newr=(newUrl.slice("new"))[0]; + // // console.log(newUrl); + // // console.log("2301"); + // // console.log(newr); + // // window.history.pushState('','',newUrl+'?tab='+e); + // // window.location.href = `/courses/${coursesId}/polls/${result.data.data.id}/edit`; + // + // }) + // } else { if (this.state.polls_nametest === undefined || this.state.polls_nametest === "") { this.props.showNotification("请输入标题"); return @@ -2374,10 +2400,10 @@ class PollNewQuestbank extends Component { } - var url = `/polls/${pollid}.json`; + var url = `/exercise_banks/${pollid}.json`; axios.put(url, { - polls_name: this.state.polls_nametest, - polls_description: this.state.polls_descriptiontest + exercise_name: this.state.polls_nametest, + exercise_description: this.state.polls_descriptiontest }).then((result) => { if (result !== undefined) { this.props.showNotification(`问卷更新成功!`); @@ -2388,7 +2414,7 @@ class PollNewQuestbank extends Component { } }) - } + // } } gotohome=()=>{ @@ -2449,7 +2475,7 @@ class PollNewQuestbank extends Component { // console.log(this.state.projects===undefined?"":this.state.projects.poll_questions) var displaymysave = (mysave === true) ? "" : "display:none;"; return ( -

+
{/*提示*/} {Modalstype && Modalstype === true ? : ""} -
+ +

this.gotohome()}>{this.props.coursedata.name} > @@ -2479,21 +2512,21 @@ class PollNewQuestbank extends Component {

{/*

{this.props.match.params.news === undefined ? "新建问卷" : this.props.match.params.news === "new" ? "新建问卷" : "编辑问卷"}

*/} -

编辑问卷

+

编辑

{/*{*/} {/* this.props.match.params.news === "new" ?*/} {/* 返回*/} {/* :*/} 返回 + className=" fr font-16"> {/*}*/}
{/*
*/} { this.state.mysave === false ? -
+
{this.state.polls_nametest} @@ -2558,7 +2591,7 @@ class PollNewQuestbank extends Component {
合计 {this.state.mysingles === undefined ? "" : this.state.mydoubles === undefined ? "" : this.state.mymainsint === undefined ? "" : this.state.mysingles + this.state.mydoubles + this.state.mymainsint} + style={{color:"#FF6800"}}>{this.state.q_counts === undefined ? "" :this.state.q_counts} 题
} @@ -2641,7 +2674,6 @@ class PollNewQuestbank extends Component { {polls_status === undefined || polls_status === 1 ?
-
this.addmysingles()}>单选题