From 8d8a48e75d3cc96aa449066cc06eab845c1e616a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Sat, 26 Oct 2019 14:38:38 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E9=81=97=E7=95=99=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=982=20=E8=B0=83=E6=95=B4=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E7=9C=8B=E5=88=B0=E7=9A=84=E9=97=AE=E5=8D=B7=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/poll/PollDetailTabThird.js | 7 + .../courses/poll/PollDetailTabThirdInfo.js | 179 +++++++++--------- .../src/modules/courses/poll/PollInfo.js | 6 +- .../user/usersInfo/banks/PollBanksContent.js | 11 +- 4 files changed, 116 insertions(+), 87 deletions(-) diff --git a/public/react/src/modules/courses/poll/PollDetailTabThird.js b/public/react/src/modules/courses/poll/PollDetailTabThird.js index ee3befe1b..32d35818d 100644 --- a/public/react/src/modules/courses/poll/PollDetailTabThird.js +++ b/public/react/src/modules/courses/poll/PollDetailTabThird.js @@ -20,6 +20,13 @@ class PollDetailTabThird extends Component{ let url=`/polls/${pollId}.json`; axios.get(url).then((result)=>{ if(result.status==200){ + if (result.data.status === 401) { + //未登入 + this.setState({ + pollDetail: undefined + }) + return + } this.setState({ pollDetail:result.data }) diff --git a/public/react/src/modules/courses/poll/PollDetailTabThirdInfo.js b/public/react/src/modules/courses/poll/PollDetailTabThirdInfo.js index 23023409c..526f32aa9 100644 --- a/public/react/src/modules/courses/poll/PollDetailTabThirdInfo.js +++ b/public/react/src/modules/courses/poll/PollDetailTabThirdInfo.js @@ -14,107 +14,116 @@ class PollDetailTabThirdInfo extends Component{ } render(){ let { pollDetail }=this.props; + console.log("pollDetailpollDetail"); + console.log(pollDetail); return( -
- { - pollDetail && pollDetail.poll.polls_description && -

{ pollDetail.poll.polls_description }

- } -

- { !pollDetail || !pollDetail.question_types || pollDetail.question_types.q_counts===0 ? "" : - +

+ { + pollDetail !== undefined ? + +
+ { + pollDetail !== pollDetail.poll.polls_description && +

{ pollDetail.poll.polls_description }

+ } +

+ { !pollDetail || !pollDetail.question_types || pollDetail.question_types.q_counts===0 ? "" : + { pollDetail && pollDetail.question_types && pollDetail.question_types.q_counts > 0 && 合计{pollDetail.question_types && pollDetail.question_types.q_counts}题: } - { - pollDetail && pollDetail.question_types.q_singles > 0 && - 单选题{pollDetail.question_types.q_singles}题 - } - { - pollDetail && pollDetail.question_types.q_doubles > 0 && - 多选题{pollDetail.question_types.q_doubles}题 - } - { - pollDetail && pollDetail.question_types.q_mains > 0 && - 主观题{pollDetail.question_types.q_mains}题 - } + { + pollDetail && pollDetail.question_types.q_singles > 0 && + 单选题{pollDetail.question_types.q_singles}题 + } + { + pollDetail && pollDetail.question_types.q_doubles > 0 && + 多选题{pollDetail.question_types.q_doubles}题 + } + { + pollDetail && pollDetail.question_types.q_mains > 0 && + 主观题{pollDetail.question_types.q_mains}题 + } - } -

+ } +

- { - pollDetail && pollDetail.questions && pollDetail.questions.map((item,key)=>{ - return( -
-

- {item.question.question_number}、{map[item.question.question_type]} - { item.question.is_necessary==1 ? 必答:选答 } - { item.question.question_type == 2 && item.question.min_choices != undefined && item.question.min_choices != null && item.question.max_choices != undefined && item.question.max_choices != null ? - + { + pollDetail && pollDetail.questions && pollDetail.questions.map((item,key)=>{ + return( +

+

+ {item.question.question_number}、{map[item.question.question_type]} + { item.question.is_necessary==1 ? 必答:选答 } + { item.question.question_type == 2 && item.question.min_choices != undefined && item.question.min_choices != null && item.question.max_choices != undefined && item.question.max_choices != null ? + { item.question.min_choices == item.question.max_choices ? "可选"+item.question.max_choices+"项" : - "可选"+item.question.min_choices+"-"+item.question.max_choices+"项" + "可选"+item.question.min_choices+"-"+item.question.max_choices+"项" } :"" - } -

-

{item.question.question_title}

- { - // 单选题 - item.question.question_type==1 && - + } +

+

{item.question.question_title}

+ { + // 单选题 + item.question.question_type==1 && + + { + item.question.answers.map((index,k)=>{ + return( +
  • + + {index.answer_text} + { + index.answer_text=="其他" ?

    :"" + } + +
  • + ) + }) + } +
    + } { - item.question.answers.map((index,k)=>{ - return( -
  • - - {index.answer_text} - { - index.answer_text=="其他" ?

    :"" - } - -
  • - ) - }) + // 多选题 + item.question.question_type==2 && + + { + item.question.answers.map((index,k)=>{ + return( +
  • + + {index.answer_text} + { + index.answer_text=="其他" ?

    :"" + } +
  • + ) + }) + } +
    } -
    - } - { - // 多选题 - item.question.question_type==2 && - { - item.question.answers.map((index,k)=>{ - return( -
  • - - {index.answer_text} - { - index.answer_text=="其他" ?

    :"" - } -
  • - ) - }) + // 主观题 + item.question.question_type == 3 && +
    + +
    } -
    - } - { - // 主观题 - item.question.question_type == 3 && -
    -
    - } -
    - ) - }) - } -
    + ) + }) + } +
    + : "" + } +
    ) } } diff --git a/public/react/src/modules/courses/poll/PollInfo.js b/public/react/src/modules/courses/poll/PollInfo.js index b7d0a59dd..1d039f0dc 100644 --- a/public/react/src/modules/courses/poll/PollInfo.js +++ b/public/react/src/modules/courses/poll/PollInfo.js @@ -392,7 +392,11 @@ class PollInfo extends Component{ :"" }
    -
  • {item.question.question_title}
  • +

    {item.question.question_title}

    { //单选 item.question.question_type==1 && diff --git a/public/react/src/modules/user/usersInfo/banks/PollBanksContent.js b/public/react/src/modules/user/usersInfo/banks/PollBanksContent.js index be6bd5e2c..5c08b1249 100644 --- a/public/react/src/modules/user/usersInfo/banks/PollBanksContent.js +++ b/public/react/src/modules/user/usersInfo/banks/PollBanksContent.js @@ -18,7 +18,8 @@ class PollBanksContent extends Component{ let url = `/exercise_banks/${bankId}.json` axios.get(url).then((result)=>{ if(result){ - let pollDetail = { + if (result.status == 200) { + let pollDetail = { poll:{ id: result.data.poll && result.data.poll.id , polls_description: result.data.poll && result.data.poll.description, @@ -48,9 +49,17 @@ class PollBanksContent extends Component{ authorize:result && result.data && result.data.authorize, } this.props.initPublic(crumbData,menuData,result.data); + if (result.data.status === 401) { + //未登入 + this.setState({ + pollDetail: undefined + }) + return + } this.setState({ pollDetail }) + } } }).catch((error)=>{ console.log(error);