From 3571c9771f04f9219b85292a5d7a1da83b509722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 26 Jun 2019 10:07:12 +0800 Subject: [PATCH 01/27] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/courses/css/Courses.css | 8 +++++ .../courses/shixunHomework/CommitSummary.js | 16 ++++----- .../shixunHomework/Trainingjobsetting.js | 34 +++++++++++++++++-- public/stylesheets/educoder/edu-main.css | 2 +- 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/public/react/src/modules/courses/css/Courses.css b/public/react/src/modules/courses/css/Courses.css index 8720dd860..197082dbe 100644 --- a/public/react/src/modules/courses/css/Courses.css +++ b/public/react/src/modules/courses/css/Courses.css @@ -837,6 +837,14 @@ a.white-btn.use_scope-btn:hover{ font-weight: 400; margin-left: 28px; } +.commitcontentsysl{ + width: 43px; + height: 15px; + font-size: 16px; + font-family: MicrosoftYaHei; + font-weight: 400; + margin-left: -4px; +} /*列表状态*/ diff --git a/public/react/src/modules/courses/shixunHomework/CommitSummary.js b/public/react/src/modules/courses/shixunHomework/CommitSummary.js index 3e12e2bb6..64f975446 100644 --- a/public/react/src/modules/courses/shixunHomework/CommitSummary.js +++ b/public/react/src/modules/courses/shixunHomework/CommitSummary.js @@ -119,10 +119,10 @@ class CommitSummary extends Component{
-

+

{data === undefined ? "" :data.course_name===undefined?"": data.course_name} > @@ -135,23 +135,23 @@ class CommitSummary extends Component{

-

提交总结

- 返回 +

提交总结

+ 返回
{/*educontentbox*/}
-
+
- - * + + * 内容
-
+
{getFieldDecorator('description', { rules: [{ required: true, message: '请输入帖子内容', diff --git a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js index 6a3379222..bece9862f 100644 --- a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js +++ b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js @@ -750,12 +750,42 @@ class Trainingjobsetting extends Component { srorelength++ } } + //算下面值是否是奇数 + var srbool=false; + if( srorelength%2 ==0 ){ + // 偶数 + srbool=false; + }else{ + // 奇数 + srbool=true; + } //计算平均值 Proportion= Proportion/srorelength; + var intkk=0; + if(srbool==true){ + var exams = Math.round(Proportion) + var intk = srorelength*exams; + intkk=100 - intk; + + } + var mact=0; + //给每到题目赋平均值 for (var i=0;i 关卡名称(选中的关卡将计入评分计算范围,暂时不支持跳关选择)分值

-
+
{this.state.challenge_settings === undefined ? "" : this.state.challenge_settings.map((object, index) => { return (
  • diff --git a/public/stylesheets/educoder/edu-main.css b/public/stylesheets/educoder/edu-main.css index 074c4ed89..4c9bc616a 100644 --- a/public/stylesheets/educoder/edu-main.css +++ b/public/stylesheets/educoder/edu-main.css @@ -101,7 +101,7 @@ a.decoration{text-decoration: underline} /*通用内外边距*/ .mt-10{ margin-top:-10px;}.mt-3{ margin-top:-3px;}.mt0{ margin-top:0px!important;} .mt1{ margin-top:1px;}.mt2{ margin-top:2px;}.mt3{ margin-top:3px;}.mt4{ margin-top:4px;}.mt5{ margin-top:5px!important;}.mt6{ margin-top:6px;}.mt7{ margin-top:7px!important;}.mt8{ margin-top:8px;}.mt9{ margin-top:9px;}.mt10{ margin-top:10px!important;}.mt12{ margin-top:12px;}.mt13{ margin-top:13px;}.mt14{ margin-top:14px;}.mt15{ margin-top:15px!important;}.mt16{ margin-top:16px;}.mt17{ margin-top:17px;}.mt18{ margin-top:18px;}.mt20{ margin-top:20px!important;}.mt22{ margin-top:22px!important;}.mt23{ margin-top:23px!important;}.mt24{ margin-top:24px!important;}.mt25{ margin-top:25px;}.mt28{ margin-top:28px;}.mt30{ margin-top:30px!important;}.mt34{ margin-top:34px!important;}.mt35{ margin-top:35px!important;}.mt36{ margin-top:36px!important;}.mt40{ margin-top:40px;}.mt45{ margin-top:45px;}.mt46{ margin-top:46px;}.mt50{ margin-top:50px;!important;}.mt56{ margin-top:56px;!important;}.mt60{ margin-top:60px;}.mt70{ margin-top:70px;}.mt80{ margin-top:80px;}.mt95{ margin-top:95px;}.mt100{ margin-top:100px;}.mt110{ margin-top:110px;}.mt120{ margin-top:120px;}.mt130{ margin-top:130px;}.mt140{ margin-top:140px;}.mt150{ margin-top:150px;}.mt160{ margin-top:160px;} .mb0{margin-bottom: 0px!important;}.mb3{ margin-bottom: 3px;}.mb5{ margin-bottom: 5px;}.mb7{ margin-bottom: 7px;}.mb10{ margin-bottom: 10px;}.mb11{ margin-bottom: 11px;}.mb14{ margin-bottom: 14px;}.mb15{ margin-bottom: 15px;}.mb16{ margin-bottom: 16px;}.mb20{ margin-bottom: 20px!important;}.mb25{ margin-bottom: 25px;}.mb26{ margin-bottom: 26px;}.mb28{ margin-bottom: 28px;}.mb30{ margin-bottom: 30px!important;}.mb40{ margin-bottom: 40px!important;}.mb50{ margin-bottom: 50px!important;}.mb60{ margin-bottom: 60px!important;}.mb70{ margin-bottom: 70px!important;}.mb80{ margin-bottom: 80px!important;}.mb90{ margin-bottom: 90px!important;}.mb100{ margin-bottom: 100px!important;}.mb110{ margin-bottom: 110px;} -.ml-3{ margin-left: -3px;}.ml1{margin-left: 1px;}.ml2{margin-left: 2px;}.ml3{margin-left: 3px;}.ml4{margin-left: 4px;}.ml5{ margin-left: 5px;}.ml6{ margin-left: 6px;}.ml10{ margin-left: 10px;}.ml12{ margin-left:12px!important;}.ml13{ margin-left:13px!important;}.ml15{ margin-left: 15px;}.ml18{ margin-left: 18px;}.ml20{ margin-left: 20px;}.ml22{ margin-left: 22px;}.ml25{ margin-left: 25px;}.ml30{ margin-left: 30px;}.ml33{ margin-left: 33px;}.ml35{ margin-left:35px;}.ml40{margin-left:40px;}.ml42{margin-left:42px;}.ml45{ margin-left: 45px;}.ml50{ margin-left: 50px;}.ml55{ margin-left: 55px;}.ml60{ margin-left: 60px;}.ml72{ margin-left: 72px;}.ml73{ margin-left: 73px;}.ml75{ margin-left: 75px;}.ml80{ margin-left: 80px;}.ml85{margin-left:85px;}.ml95{ margin-left: 95px;}.ml115{margin-left: 115px}.ml123{ margin-left: 123px;}.ml150{ margin-left: 150px;}.ml180{ margin-left: 180px;}.ml230{ margin-left: 230px;}.ml240{margin-left: 240px;}.ml250{ margin-left: 250px;}.ml290{ margin-left: 290px;} +.ml-3{ margin-left: -3px;}.ml1{margin-left: 1px;}.ml2{margin-left: 2px;}.ml3{margin-left: 3px;}.ml4{margin-left: 4px;}.ml5{ margin-left: 5px;}.ml6{ margin-left: 6px;}.ml10{ margin-left: 10px;}.ml12{ margin-left:12px!important;}.ml13{ margin-left:13px!important;}.ml15{ margin-left: 15px;}.ml18{ margin-left: 18px;}.ml20{ margin-left: 20px;}.ml22{ margin-left: 22px;}.ml25{ margin-left: 25px;}.ml29{margin-left: 29px;}.ml30{ margin-left: 30px;}.ml33{ margin-left: 33px;}.ml35{ margin-left:35px;}.ml40{margin-left:40px;}.ml42{margin-left:42px;}.ml45{ margin-left: 45px;}.ml50{ margin-left: 50px;}.ml55{ margin-left: 55px;}.ml60{ margin-left: 60px;}.ml72{ margin-left: 72px;}.ml73{ margin-left: 73px;}.ml75{ margin-left: 75px;}.ml80{ margin-left: 80px;}.ml85{margin-left:85px;}.ml95{ margin-left: 95px;}.ml115{margin-left: 115px}.ml123{ margin-left: 123px;}.ml150{ margin-left: 150px;}.ml180{ margin-left: 180px;}.ml230{ margin-left: 230px;}.ml240{margin-left: 240px;}.ml250{ margin-left: 250px;}.ml290{ margin-left: 290px;} .mr3{margin-right: 3px}.mr4{margin-right: 4px}.mr5{ margin-right: 5px;}.mr8{ margin-right: 8px;}.mr10{ margin-right: 10px;}.mr12{ margin-right:12px!important;}.mr15{ margin-right: 15px;}.mr18{ margin-right: 18px;}.mr20{ margin-right: 20px;}.mr24{ margin-right: 24px;}.mr25{ margin-right: 25px;}.mr30{ margin-right:30px;}.mr35{margin-right:35px;}.mr40{margin-right:40px;}.mr45{margin-right:45px;}.mr50{ margin-right: 50px;}.mr60{ margin-right:60px;}.mr70{ margin-right: 70px;}.mr75{ margin-right: 75px;}.mr80{ margin-right:80px;}.mr90{ margin-right:90px;}.mr100{ margin-right: 100px;}.mr110{ margin-right:110px;}.mr350{ margin-right:350px;} .pt1{ padding-top:1px;}.pt3{ padding-top:3px!important;}.pt5{ padding-top:5px!important;}.pt10{ padding-top:10px;}.pt15{ padding-top:15px;}.pt17{ padding-top:17px;}.pt20{ padding-top:20px!important;}.pt25{ padding-top:25px;}.pt30{ padding-top:30px;}.pt35{ padding-top:35px;}.pt37{ padding-top:37px;}.pt40{ padding-top:40px;}.pt47{ padding-top:47px;}.pt49{ padding-top:49px;}.pt50{ padding-top:50px;}.pt60{ padding-top:60px;}.pt70{ padding-top:70px;}.pt80{ padding-top:80px;}.pt90{ padding-top:90px;}.pt100{padding-top:100px;}.pt110{ padding-top:110px;}.pt120{ padding-top:120px;}.pt130{padding-top:130px;} From 6e91761cce9be04d0a31646e0fc0eef8e96cc020 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Wed, 26 Jun 2019 11:29:34 +0800 Subject: [PATCH 02/27] css --- .../modules/courses/boards/BoardsListItem.js | 3 +- .../react/src/modules/courses/boards/index.js | 4 +- .../courses/busyWork/CommonWorkDetailIndex.js | 2 +- .../courses/busyWork/CommonWorkList.js | 58 +++++++++++-------- .../courses/busyWork/CommonWorkSetting.js | 3 + .../busyWork/common/TabRightComponents.js | 1 + 6 files changed, 43 insertions(+), 28 deletions(-) diff --git a/public/react/src/modules/courses/boards/BoardsListItem.js b/public/react/src/modules/courses/boards/BoardsListItem.js index 2a6aaae2f..cf667dc6d 100644 --- a/public/react/src/modules/courses/boards/BoardsListItem.js +++ b/public/react/src/modules/courses/boards/BoardsListItem.js @@ -48,8 +48,9 @@ class BoardsListItem extends Component{
    onItemClick(discussMessage)}>
    {} : () => this.onTitleClick(discussMessage)} + title={`${discussMessage.subject.length > 40 ? discussMessage.subject : ''}`} >{discussMessage.subject} { !!discussMessage.sticky && 置顶 } { diff --git a/public/react/src/modules/courses/boards/index.js b/public/react/src/modules/courses/boards/index.js index 10c8accea..cc761cd5d 100644 --- a/public/react/src/modules/courses/boards/index.js +++ b/public/react/src/modules/courses/boards/index.js @@ -446,7 +446,9 @@ class Boards extends Component{

    } */} - {pagination.total_count > 15 && } + {pagination.total_count > 15 && } ) diff --git a/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js b/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js index da4a92be1..4e3214e50 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js @@ -150,7 +150,7 @@ class CommonWorkDetailIndex extends Component{ ]}>
    - + 36 ? homework_name : ''}`}> {homework_name} {/* {homework_name} */} diff --git a/public/react/src/modules/courses/busyWork/CommonWorkList.js b/public/react/src/modules/courses/busyWork/CommonWorkList.js index 25ddaa146..ebec66b94 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkList.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkList.js @@ -1,5 +1,5 @@ import React,{Component} from "React"; -import { Form, Select, Input, Button,Checkbox,Upload,Icon,message,Modal, Table, Divider, Tag,DatePicker,Radio,Tooltip,Spin} from "antd"; +import { Form, Select, Input, Button,Checkbox,Upload,Icon,message,Modal, Table, Divider, Tag,DatePicker,Radio,Tooltip,Spin, Pagination} from "antd"; import {Link} from 'react-router-dom'; import locale from 'antd/lib/date-picker/locale/zh_CN'; import { WordsBtn, ConditionToolTip, queryString,getImageUrl, on, off} from 'educoder'; @@ -77,7 +77,8 @@ function buildColumns(that, student_works) { overflow: 'hidden', textOverflow: 'ellipsis', - whiteSpace: 'nowrap' + whiteSpace: 'nowrap', + maxWidth: '98px' }} title={text}> {/* */} @@ -94,7 +95,10 @@ function buildColumns(that, student_works) { render: (text, record) => ( - {record.student_id} + {record.student_id} ), }) @@ -330,7 +334,7 @@ const orderMap = { } const PAGE_SIZE = 50 // 类似页面 http://localhost:3007/courses/1309/graduation/graduation_tasks/48/76/setting -class CommonWorkSetting extends Component{ +class CommonWorkList extends Component{ constructor(props){ super(props) @@ -355,8 +359,8 @@ class CommonWorkSetting extends Component{ category: {}, } } - onTablePagination = (pageInfo) => { - this.setState({ page: pageInfo.current }, () => { + onTablePagination = (page) => { + this.setState({ page: page }, () => { this.fetchList() }) @@ -706,7 +710,7 @@ class CommonWorkSetting extends Component{ } -
    +
    - - {/**/} - - -
    - - -
    - - -
    -
    - ) - } - - - - - - -} -const Homeworddescriptions = Form.create({name: 'taskPollNew'})(Homeworddescription); +import React, {Component} from "react"; +import { + Form, + Select, + Input, + Button, + Checkbox, + Upload, + Icon, + message, + Modal, + Table, + Divider, + InputNumber, + Tag, + DatePicker, + Radio, + Tooltip, + notification +} from "antd"; +import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; +import {Link, Switch, Route, Redirect} from 'react-router-dom'; +import axios from 'axios'; +import '../css/members.css' +import "../common/formCommon.css" +import '../css/Courses.css' +import '../css/members.css' +import "../common/formCommon.css" +import '../css/Courses.css' +import moment from 'moment'; +import '../css/members.css' +import "../common/formCommon.css" +import './style.css' +import Workquestionandanswer from "./Workquestionandanswer"; +const { TextArea } = Input; + + +class Homeworddescription extends Component { + + constructor(props) { + super(props); + this.state = { + props: props, + description:undefined, + } + + + } + + componentDidMount() { + + + } + //取消操作 + clickcancel =()=>{ + this.props.NOReleaseNotes(); + } + //确认操作 + onSaveExercise=()=>{ + if(this.state.description === "" || this.state.description===undefined || this.state.description === null){ + this.props.showNotification("请输入作业说明"); + return + } + this.props.ReleaseNotes(this.state.description); + } + //获取输入框 + settextarea=(e)=>{ + this.setState({ + description:e + }) + } + render() { + return ( +
    +
    + + + {/**/} + + +
    + + +
    + + +
    +
    + ) + } + + + + + + +} +const Homeworddescriptions = Form.create({name: 'taskPollNew'})(Homeworddescription); export default Homeworddescriptions; \ No newline at end of file diff --git a/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js b/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js index 272ac6418..a21d6f977 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js @@ -334,7 +334,7 @@ class ShixunhomeWorkItem extends Component{ {discussMessage.commit_count===undefined?"":{discussMessage.commit_count} 已交} {discussMessage.uncommit_count===undefined?"":{discussMessage.uncommit_count} 未交} {/*{discussMessage.replies_count} 3 未评*/} - 0?"剩余时间":""} placement="bottom"> + {discussMessage.status_time} @@ -349,7 +349,7 @@ class ShixunhomeWorkItem extends Component{ {this.props.isAdmin?:""} diff --git a/public/react/src/modules/courses/shixunHomework/Workquestionandanswer.js b/public/react/src/modules/courses/shixunHomework/Workquestionandanswer.js index 7ebbeb473..438babfea 100644 --- a/public/react/src/modules/courses/shixunHomework/Workquestionandanswer.js +++ b/public/react/src/modules/courses/shixunHomework/Workquestionandanswer.js @@ -429,27 +429,36 @@ class Workquestionandanswer extends Component { {jobsettingsdata === undefined|| jobsettingsdata.data.description===null? "无" :
    +
    {/* /!*{}}>
    {/* /!*{jobsettingsdata.data.description}*!/*/} - {/* */} + {/* */}
    - {/*
    */} - {/*

    */} - {/* /!*{ChallengesDataList === undefined ? "" :ChallengesDataList.description===null?""*!/*/} - {/* */} - {/* /!*}*!/*/} - {/*

    */} - - {/*
    */} + {/*
    */} + {/*

    */} + {/* /!*{ChallengesDataList === undefined ? "" :ChallengesDataList.description===null?""*!/*/} + {/* */} + {/* /!*}*!/*/} + {/*

    */} + + {/*
    */}
    } diff --git a/public/react/src/modules/courses/shixunHomework/shixunHomework.js b/public/react/src/modules/courses/shixunHomework/shixunHomework.js index 70acf0f80..c3be53486 100644 --- a/public/react/src/modules/courses/shixunHomework/shixunHomework.js +++ b/public/react/src/modules/courses/shixunHomework/shixunHomework.js @@ -827,8 +827,8 @@ class ShixunHomework extends Component{ this.setState({ Modalstype:true, - Modalstopval:"公开后非课堂成员也可以访问查看", - ModalsBottomval:"是否确认公开?", + Modalstopval:"设为公开后,非课堂成员也可以访问查看", + ModalsBottomval:"是否确认设为公开?", ModalCancel:this.cancelmodel, ModalSave:this.saveonOpen, }) @@ -1190,6 +1190,7 @@ class ShixunHomework extends Component{ isAdmin={this.props.isAdmin()} isStudent={this.props.isStudent()} isNotMember={this.props.isNotMember()} + isClassManagement={this.props.isClassManagement()} checkBox={this.props.isAdmin()?:""} match={this.props.match} coursedata={this.props.coursedata} diff --git a/public/react/src/modules/paths/ShixunPathCard.js b/public/react/src/modules/paths/ShixunPathCard.js index e2c529aea..2d1090820 100644 --- a/public/react/src/modules/paths/ShixunPathCard.js +++ b/public/react/src/modules/paths/ShixunPathCard.js @@ -1,78 +1,80 @@ -import React, { Component } from 'react'; -import {getImageUrl} from 'educoder'; -import { BrowserRouter as Router, Route, Link } from "react-router-dom"; -import { Tooltip } from 'antd'; -import axios from 'axios'; - - -class ShixunPathCard extends Component{ - constructor(props) { - super(props) - } - render(){ - let {pathList}=this.props; - return( -
    - { - pathList && pathList.length > 0 ? - ( -
    - { - pathList && pathList.map((item,key)=>{ - - return( -
    - { - item.tag_name === null ? "" : -
    - {item.tag_name} - -
    - } - - -
    - -

    非试用内容,需要授权

    -
    - - 13?1543211263 - -
    -

    - {item.name} -

    -

    - - - {item.stages_count} - - - {/**/} - {/*{item.shixuns_count}*/} - {/**/} - - - {item.members_count} - -

    -
    -
    - ) - }) - } -
    - ):( -
    - -

    暂无数据哦~

    -
    - ) - } - -
    - ) - } -} +import React, { Component } from 'react'; +import {getImageUrl} from 'educoder'; +import { BrowserRouter as Router, Route, Link } from "react-router-dom"; +import { Tooltip } from 'antd'; +import axios from 'axios'; + + +class ShixunPathCard extends Component{ + constructor(props) { + super(props) + } + render(){ + let {pathList}=this.props; + return( +
    + { + pathList && pathList.length > 0 ? + ( +
    + { + pathList && pathList.map((item,key)=>{ + + return( +
    + { + item.tag_name === null ? "" : +
    + {item.tag_name} + +
    + } + + +
    + +

    非试用内容,需要授权

    +
    + + {/*target="_blank"*/} + 13?1543211263 + +
    +

    + {item.name} + {/*target="_blank"*/} +

    +

    + + + {item.stages_count} + + + {/**/} + {/*{item.shixuns_count}*/} + {/**/} + + + {item.members_count} + +

    +
    +
    + ) + }) + } +
    + ):( +
    + +

    暂无数据哦~

    +
    + ) + } + +
    + ) + } +} export default ShixunPathCard; \ No newline at end of file diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js index 66d3d9273..1bdc505c3 100644 --- a/public/react/src/modules/tpm/TPMIndexHOC.js +++ b/public/react/src/modules/tpm/TPMIndexHOC.js @@ -183,7 +183,12 @@ export function TPMIndexHOC(WrappedComponent) { // return false return this.state.coursedata&&this.state.coursedata.course_identity === 0 } - // 管理员等 + // 课堂管理等 + isClassManagement = () => { + // return this.state.coursedata&&this.state.coursedata.course_identity >= 0 && + return this.state.coursedata&&this.state.coursedata.course_identity < 2 + } + //老师等 isAdminOrCreator = () => { // return this.state.coursedata&&this.state.coursedata.course_identity >= 0 && return this.state.coursedata&&this.state.coursedata.course_identity < 3 @@ -279,7 +284,7 @@ export function TPMIndexHOC(WrappedComponent) { const common = { isSuperAdmin:this.isSuperAdmin, isAdminOrCreator:this.isAdminOrCreator, - + isClassManagement:this.isClassManagement, isAdmin: this.isAdmin, isAdminOrTeacher: this.isAdminOrTeacher, isStudent: this.isStudent, diff --git a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js index 85275e620..b60b641e0 100644 --- a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js +++ b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js @@ -324,7 +324,7 @@ export default class TPMsettings extends Component { opening_time:response.data.shixun.opening_time, newuse_scope:response.data.shixun.use_scope, scope_partments: response.data.shixun.scope_partment.length, - shixunmemoMDvalue:response.data.shixun.evaluate_script + shixunmemoMDvalue:response.data.shixun.evaluate_script, }) // if(response.data.status===403){ @@ -598,7 +598,7 @@ export default class TPMsettings extends Component { evaluate_script, exec_time, webssh, use_scope, trainee, can_copy, task_pass, test_set_permission, hide_code, code_hidden, forbid_copy, vnc,multi_webssh, opening_time, pod_exist_time,shixunmemoMDvalue } = this.state; - let operateauthority=this.props.identity<4&&this.props.status==0||this.props.identity===1&&this.props.status==2||this.props.identity===1&&this.props.status==1; + let operateauthority=this.props.identity<4&&this.state.status==0||this.props.identity===1&&this.state.status==2||this.props.identity===1&&this.state.status==1; const description_editormd = this.description_editormd.getValue(); @@ -1084,7 +1084,7 @@ export default class TPMsettings extends Component { } const dateFormat = 'YYYY-MM-DD HH:mm:ss'; - let operateauthority=this.props.identity===1?true:this.props.identity<4&&this.props.status==0; + let operateauthority=this.props.identity===1?true:this.props.identity<4&&this.state.status==0?true:false; return (
  • ) diff --git a/public/react/src/modules/tpm/shixuns/ShixunCard.js b/public/react/src/modules/tpm/shixuns/ShixunCard.js index 7237f9e35..e0850143c 100644 --- a/public/react/src/modules/tpm/shixuns/ShixunCard.js +++ b/public/react/src/modules/tpm/shixuns/ShixunCard.js @@ -1,174 +1,177 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames'; - -// import { Rating,Loading} from '@icedesign/base'; - -import {getImageUrl,setImagesUrl, toPath} from 'educoder'; - -// import { Pagination,Row,Col } from 'antd'; - -import 'antd/lib/pagination/style/index.css'; - -import './shixunCss/shixunCard.css'; - -import Rating from '@icedesign/base/lib/rating'; - -import Pagination from '@icedesign/base/lib/pagination'; - -// import Loading from '@icedesign/base/lib/loading'; - -// 引入业务组件样式 -import '@icedesign/base/lib/pagination/style.js'; - -import '@icedesign/base/lib/rating/style.js'; - -import { Tooltip } from 'antd'; - -// import '@icedesign/base/lib/loading/style.js'; - -import axios from 'axios'; - -const $ = window.$; - -class ShixunCard extends Component { - constructor(props) { - super(props) - - this.state = { - startValue:[], - order_by:"", - page:1, - limit:16, - keyword:"", - status:0, - diff:0, - hideme:false, - tag_level:3, - tag_id:'' - } - - } - - PaginationonChange=(pageNumber)=> { - this.props.shixunsPage(pageNumber); - } - - render() { - let {middleshixundata, pagination, typepvisible, pages, totalcount} = this.props; - return ( -
    - {/**/} - -
    -
    -
    - -

    暂无数据哦~

    -
    -
    -
    -
    -
      - -
    -
    -
    -
    -
    - -
    -
    -
    - { middleshixundata===undefined?" ":middleshixundata.map((item,key)=>{ - return( -
    - { - item.tag_name === null ? "": -
    - {item.tag_name} - -
    - } -
    - -

    非试用内容,需要授权

    -
    - - - {/**/} - - - -
    -

    - - {item.name} - -

    - -

    - - - - {item.score_info===null?"5分":item.score_info+"分"} -

    - -

    - - - {item.challenges_count} - - - - {/**/} - {/**/} - {/*{item.exp}*/} - {/**/} - {/**/} - - - - {item.stu_num} - - - - {item.level} -

    - -
    -
    - ) - }) - } - -
    - -
    - {/*totalcount*/} -
    - {/**/} - {/* 不加参数请求的时候,没返回总数了。加了个比较大的数字,让他可以翻页 */} - -
    - -
    - -
    - {/*
    */} -
    - ) - } -} - -export default ShixunCard; +import React, { Component } from 'react'; +import { Redirect } from 'react-router'; + +import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; + +import PropTypes from 'prop-types'; + +import classNames from 'classnames'; + +// import { Rating,Loading} from '@icedesign/base'; + +import {getImageUrl,setImagesUrl, toPath} from 'educoder'; + +// import { Pagination,Row,Col } from 'antd'; + +import 'antd/lib/pagination/style/index.css'; + +import './shixunCss/shixunCard.css'; + +import Rating from '@icedesign/base/lib/rating'; + +import Pagination from '@icedesign/base/lib/pagination'; + +// import Loading from '@icedesign/base/lib/loading'; + +// 引入业务组件样式 +import '@icedesign/base/lib/pagination/style.js'; + +import '@icedesign/base/lib/rating/style.js'; + +import { Tooltip } from 'antd'; + +// import '@icedesign/base/lib/loading/style.js'; + +import axios from 'axios'; + +const $ = window.$; + +class ShixunCard extends Component { + constructor(props) { + super(props) + + this.state = { + startValue:[], + order_by:"", + page:1, + limit:16, + keyword:"", + status:0, + diff:0, + hideme:false, + tag_level:3, + tag_id:'' + } + + } + + PaginationonChange=(pageNumber)=> { + this.props.shixunsPage(pageNumber); + } + + render() { + let {middleshixundata, pagination, typepvisible, pages, totalcount} = this.props; + return ( +
    + {/**/} + +
    +
    +
    + +

    暂无数据哦~

    +
    +
    +
    +
    +
      + +
    +
    +
    +
    +
    + +
    +
    +
    + { middleshixundata===undefined?" ":middleshixundata.map((item,key)=>{ + return( +
    + { + item.tag_name === null ? "": +
    + {item.tag_name} + +
    + } +
    + +

    非试用内容,需要授权

    +
    + + + {/**/} + + + {/*target="_blank"*/} + +
    +

    + + {item.name} + +

    + + {/*target="_blank"*/} + +

    + + + + {item.score_info===null?"5分":item.score_info+"分"} +

    + +

    + + + {item.challenges_count} + + + + {/**/} + {/**/} + {/*{item.exp}*/} + {/**/} + {/**/} + + + + {item.stu_num} + + + + {item.level} +

    + +
    +
    + ) + }) + } + +
    + +
    + {/*totalcount*/} +
    + {/**/} + {/* 不加参数请求的时候,没返回总数了。加了个比较大的数字,让他可以翻页 */} + +
    + +
    + +
    + {/*
    */} +
    + ) + } +} + +export default ShixunCard; From 2d8b2ef96f0fd45d519f9dce443a2723c919f910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 26 Jun 2019 11:35:00 +0800 Subject: [PATCH 05/27] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/shixunHomework/Listofworks.js | 16 ++++++---- .../src/modules/login/Trialapplication.js | 32 +++++++++---------- public/react/src/modules/tpm/NewHeader.js | 2 +- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/public/react/src/modules/courses/shixunHomework/Listofworks.js b/public/react/src/modules/courses/shixunHomework/Listofworks.js index 6d19b13ef..98ba43e55 100644 --- a/public/react/src/modules/courses/shixunHomework/Listofworks.js +++ b/public/react/src/modules/courses/shixunHomework/Listofworks.js @@ -75,7 +75,7 @@ class Listofworks extends Component { teacherlist: undefined, searchtext: "", course_groupysls: undefined, - course_groupyslstwo: undefined, + course_groupyslstwo: [], visible: false, userid: 0, course_group: null, @@ -1164,7 +1164,7 @@ class Listofworks extends Component { // console.log(checkedValues); this.setState({ unlimited: 0, - course_groupyslstwo: undefined, + course_groupyslstwo: [], loadingstate: true, }) @@ -1172,7 +1172,7 @@ class Listofworks extends Component { } else if (checkedValues.length === data.length) { this.setState({ unlimited: 0, - course_groupyslstwo: undefined, + course_groupyslstwo: [], loadingstate: true, }) this.Startsorting(this.state.order, checkedValues, this.state.checkedValuesineinfo, this.state.searchtext, this.state.page, this.state.limit); @@ -1198,6 +1198,7 @@ class Listofworks extends Component { this.setState({ unlimitedtwo: 1, course_groupysls: undefined, + checkedValuesineinfo:[], loadingstate: true, }) @@ -1206,6 +1207,7 @@ class Listofworks extends Component { this.setState({ unlimitedtwo: 1, course_groupysls: undefined, + checkedValuesineinfo:[], loadingstate: true, }) this.Startsorting(this.state.order, this.state.checcourse_groupyslstwokedValuesine, checkedValues, this.state.searchtext, this.state.page, this.state.limit); @@ -1485,22 +1487,22 @@ class Listofworks extends Component { notlimiteds = () => { this.setState({ checkedValuesine: undefined, - course_groupyslstwo: undefined, + course_groupyslstwo: [], unlimited: 0, loadingstate: true, }) - this.Startsorting(this.state.order, null, this.state.checkedValuesineinfo, this.state.searchtext, this.state.page, this.state.limit); + this.Startsorting(this.state.order, [], this.state.checkedValuesineinfo, this.state.searchtext, this.state.page, this.state.limit); } notlimitedst = () => { // console.log(this.state.course_group_info); this.setState({ unlimitedtwo: 1, - checkedValuesineinfo: undefined, + checkedValuesineinfo: [], course_groupysls: undefined, loadingstate: true, }) - this.Startsorting(this.state.order, this.state.course_groupyslstwo, undefined, this.state.searchtext, this.state.page, this.state.limit); + this.Startsorting(this.state.order, this.state.course_groupyslstwo, [], this.state.searchtext, this.state.page, this.state.limit); } //立即截止确定按钮 coursetaskend = () => { diff --git a/public/react/src/modules/login/Trialapplication.js b/public/react/src/modules/login/Trialapplication.js index e5bc75466..846971e82 100644 --- a/public/react/src/modules/login/Trialapplication.js +++ b/public/react/src/modules/login/Trialapplication.js @@ -30,7 +30,7 @@ class Trialapplication extends Component { Phonenumberisnotco: undefined, Phonenumberisnotcobool: false, readonlyInput: true, - user_phone_binded: false, + user_phone_binded: props.user_phone_binded, showTrial: false, user: undefined, } @@ -383,7 +383,7 @@ class Trialapplication extends Component { { isRenders === false ? "" : -
    +
    + {this.props.isAdmin()?
  • + 导出 + +
  • :""} {this.props.isAdmin() ? teacherdata && teacherdata.end_immediately === true ? 立即截止 : "" From df742dbbfabe515ea6bd19c1fb0f03f936932486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 26 Jun 2019 15:55:28 +0800 Subject: [PATCH 21/27] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/courses/shixunHomework/Listofworks.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/public/react/src/modules/courses/shixunHomework/Listofworks.js b/public/react/src/modules/courses/shixunHomework/Listofworks.js index 697ff92e4..5a7aa56ae 100644 --- a/public/react/src/modules/courses/shixunHomework/Listofworks.js +++ b/public/react/src/modules/courses/shixunHomework/Listofworks.js @@ -94,8 +94,6 @@ class Listofworks extends Component { boolgalist:true, challenges_count:0, experience:0, - exportResultUrl:"", - exportUrl:"", columns: [ { title: '序号', @@ -1599,7 +1597,7 @@ class Listofworks extends Component { render() { // console.log("Listofworks.js000") - let {columns, page, boolgalist,limit,exportUrl, exportResultUrl,experience,course_groupysls, course_groupyslstwo, unlimited, unlimitedtwo, loadingstate, viewtrainingdata, game_list, data, course_group_info, order, teacherdata, task_status, checkedValuesine, searchtext, teacherlist, visible, visibles, jobsettingsdata} = this.state; + let {columns, page, boolgalist,limit,experience,course_groupysls, course_groupyslstwo, unlimited, unlimitedtwo, loadingstate, viewtrainingdata, game_list, data, course_group_info, order, teacherdata, task_status, checkedValuesine, searchtext, teacherlist, visible, visibles, jobsettingsdata} = this.state; // // console.log(teacherdata&&teacherdata.shixun_identifier) // console.log(course_group_info) From 02a4009821abe49d61facc2469bd54c8f035e24a Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Wed, 26 Jun 2019 16:33:34 +0800 Subject: [PATCH 22/27] =?UTF-8?q?=E6=88=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/busyWork/CommonWorkAnswer.js | 2 +- .../modules/courses/busyWork/CommonWorkList.js | 6 ++++-- .../src/modules/courses/common/courseMessage.css | 1 + .../src/modules/courses/members/studentsList.js | 16 +++++++++++----- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/public/react/src/modules/courses/busyWork/CommonWorkAnswer.js b/public/react/src/modules/courses/busyWork/CommonWorkAnswer.js index 51031de17..d7614459c 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkAnswer.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkAnswer.js @@ -86,7 +86,7 @@ class CommonWorkAnswer extends Component{ {/* 内容区 */}
    {reference_answer ? : - reference_answer === undefined ? '' : } + reference_answer === undefined ? '' : ((!attachments || attachments.length == 0) && )} { attachments && attachments.map((item) => { return (
    diff --git a/public/react/src/modules/courses/busyWork/CommonWorkList.js b/public/react/src/modules/courses/busyWork/CommonWorkList.js index 28de13fe7..31532f78e 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkList.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkList.js @@ -64,7 +64,9 @@ function buildColumns(that, student_works) { key: 'id', render: (text, record, index) => { return ( - {(that.state.page - 1) * PAGE_SIZE + index + 1} + + {record.isMine == true ? '我' : (that.state.page - 1) * PAGE_SIZE + index + 1} + )}, }, { title: '姓名', @@ -547,7 +549,7 @@ class CommonWorkList extends Component{ StudentData=isStudent ? [{ id, user_name, user_login, student_id, group_name, work_status, update_time, teacher_score, teaching_asistant_score, student_score, ultimate_score, work_score, student_comment_count, appeal_all_count, appeal_deal_count, late_penalty, absence_penalty, appeal_penalty, - work_group: '' }] : [] + work_group: '', isMine: true }] : [] } let params = this._getRequestParams() let exportUrl = `/api/homework_commons/${workId}/works_list.zip?${queryString.stringify(params)}`; diff --git a/public/react/src/modules/courses/common/courseMessage.css b/public/react/src/modules/courses/common/courseMessage.css index c219df018..fede51ded 100644 --- a/public/react/src/modules/courses/common/courseMessage.css +++ b/public/react/src/modules/courses/common/courseMessage.css @@ -40,6 +40,7 @@ .course-message .comment_item_cont:last-child { /* 作品评阅需要 */ border-bottom: none; + padding-bottom: 0px; } .course-message .memoMore { diff --git a/public/react/src/modules/courses/members/studentsList.js b/public/react/src/modules/courses/members/studentsList.js index d997592ef..9c6254cbd 100644 --- a/public/react/src/modules/courses/members/studentsList.js +++ b/public/react/src/modules/courses/members/studentsList.js @@ -46,24 +46,30 @@ const buildColumns = (that) => { key: 'login', align:'center', className:"color-grey-6", - // render: (name, record) => { - // return {name} - // } + render: (name, record) => { + return {name} + } }, { title: '姓名', dataIndex: 'name', key: 'name', align:'center', + width:"10%", className:"color-grey-6", render: (name, record) => { - return {name} + return {name} } }, { title: '学号', dataIndex: 'student_id', key: 'student_id', align:'center', - className:"color-grey-6" + className:"color-grey-6", + render: (student_id, record) => { + return {student_id} + } }, { title: '分班', dataIndex: 'course_group_name', From 26023201bb1e0b97b21ee4de90d838c07d017b99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 26 Jun 2019 16:39:39 +0800 Subject: [PATCH 23/27] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/shixunHomework/Listofworks.js | 2 +- .../shixunHomework/Listofworksstudentone.js | 2 +- .../TraineetraininginformationModal.js | 1 + .../src/modules/tpm/newshixuns/Newshixuns.js | 2386 +++++++++-------- 4 files changed, 1198 insertions(+), 1193 deletions(-) diff --git a/public/react/src/modules/courses/shixunHomework/Listofworks.js b/public/react/src/modules/courses/shixunHomework/Listofworks.js index 5a7aa56ae..8a9a0a53f 100644 --- a/public/react/src/modules/courses/shixunHomework/Listofworks.js +++ b/public/react/src/modules/courses/shixunHomework/Listofworks.js @@ -1377,7 +1377,7 @@ class Listofworks extends Component { classroom: game_list[i].score, complete_status: game_list[i].complete_status, }) - experience=game_list[i].complete_status+experience; + experience=game_list[i].score+experience; if(game_list[i].complete_status === 2 || game_list[i].complete_status===3){ boolgalist=false; diff --git a/public/react/src/modules/courses/shixunHomework/Listofworksstudentone.js b/public/react/src/modules/courses/shixunHomework/Listofworksstudentone.js index d0628930f..29af983e5 100644 --- a/public/react/src/modules/courses/shixunHomework/Listofworksstudentone.js +++ b/public/react/src/modules/courses/shixunHomework/Listofworksstudentone.js @@ -394,7 +394,7 @@ class Listofworksstudentone extends Component { classroom: game_list[i].score, complete_status: game_list[i].complete_status, }) - experience=game_list[i].complete_status+experience; + experience=game_list[i].score+experience; if(game_list[i].complete_status === 2 || game_list[i].complete_status===3){ boolgalist=false; diff --git a/public/react/src/modules/courses/shixunHomework/TraineetraininginformationModal.js b/public/react/src/modules/courses/shixunHomework/TraineetraininginformationModal.js index 61b066580..735e3f396 100644 --- a/public/react/src/modules/courses/shixunHomework/TraineetraininginformationModal.js +++ b/public/react/src/modules/courses/shixunHomework/TraineetraininginformationModal.js @@ -52,6 +52,7 @@ class TraineetraininginformationModal extends Component { // this.seacthdata(); } + LimitNumber=(txt)=> { var str = txt; if(str.length>25){ diff --git a/public/react/src/modules/tpm/newshixuns/Newshixuns.js b/public/react/src/modules/tpm/newshixuns/Newshixuns.js index 895b5dd7f..aa5b62a0a 100644 --- a/public/react/src/modules/tpm/newshixuns/Newshixuns.js +++ b/public/react/src/modules/tpm/newshixuns/Newshixuns.js @@ -1,1191 +1,1195 @@ -import React, {Component} from 'react'; - -import {TPMIndexHOC} from '../TPMIndexHOC'; - -import {SnackbarHOC} from 'educoder'; - -import {Input, Select, Radio, Checkbox, Modal, Icon, DatePicker,Upload,Button,message,Form} from 'antd'; - -// import "antd/dist/antd.css"; - -import locale from 'antd/lib/date-picker/locale/zh_CN'; - -import axios from 'axios'; - -import './css/Newshixuns.css'; - -import {getUrl} from 'educoder' - -let path = getUrl("/editormd/lib/") - -const $ = window.$; - -let timeout; - -let currentValue; - -const Option = Select.Option; - -const RadioGroup = Radio.Group; -const confirm = Modal.confirm; -// 恢复数据 -function md_rec_data(k, mdu, id, editor) { - if (window.sessionStorage.getItem(k + mdu) !== null) { - editor.setValue(window.sessionStorage.getItem(k + mdu)); - md_clear_data(k, mdu, id); - } -} - -// 保存数据 -function md_add_data(k, mdu, d) { - window.sessionStorage.setItem(k + mdu, d); -} - -// 清空保存的数据 -function md_clear_data(k, mdu, id) { - window.sessionStorage.removeItem(k + mdu); - var id1 = "#e_tip_" + id; - var id2 = "#e_tips_" + id; - if (k == 'content') { - $(id2).html(""); - } else { - $(id1).html(""); - } -} - -function md_elocalStorage(editor, mdu, id) { - if (window.sessionStorage) { - var oc = window.sessionStorage.getItem('content' + mdu); - if (oc !== null) { - $("#e_tips_" + id).data('editor', editor); - var h = '您上次有已保存的数据,是否恢复 ? / 不恢复'; - $("#e_tips_" + id).html(h); - } - setInterval(function () { - var d = new Date(); - var h = d.getHours(); - var m = d.getMinutes(); - var s = d.getSeconds(); - h = h < 10 ? '0' + h : h; - m = m < 10 ? '0' + m : m; - s = s < 10 ? '0' + s : s; - if (editor.getValue().trim() != "") { - md_add_data("content", mdu, editor.getValue()); - var id1 = "#e_tip_" + id; - var id2 = "#e_tips_" + id; - - $(id1).html(" 数据已于 " + h + ':' + m + ':' + s + " 保存 "); - $(id2).html(""); - } - }, 10000); - - } else { - $("#e_tip_" + id).after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!'); - } -} - - -function create_editorMD(id, width, high, placeholder, imageUrl, callback) { - var editorName = window.editormd(id, { - width: width, - height: high, - path: path, // "/editormd/lib/" - - syncScrolling: "single", - tex: true, - tocm: true, - emoji: true, - taskList: true, - codeFold: true, - searchReplace: true, - htmlDecode: "style,script,iframe", - sequenceDiagram: true, - autoFocus: false, - toolbarIcons: function () { - // Or return editormd.toolbarModes[name]; // full, simple, mini - // Using "||" set icons align right. - return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"] - }, - toolbarCustomIcons: { - testIcon: "
    ", - testIcon1: "
    " - }, - //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 - saveHTMLToTextarea: true, - // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标 - dialogMaskOpacity: 0.6, - placeholder: placeholder, - imageUpload: true, - imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], - imageUploadURL: imageUrl,//url - onload: function () { - // this.previewing(); - $("#" + id + " [type=\"latex\"]").bind("click", function () { - editorName.cm.replaceSelection("```latex"); - editorName.cm.replaceSelection("\n"); - editorName.cm.replaceSelection("\n"); - editorName.cm.replaceSelection("```"); - var __Cursor = editorName.cm.getDoc().getCursor(); - editorName.cm.setCursor(__Cursor.line - 1, 0); - }); - - $("#" + id + " [type=\"inline\"]").bind("click", function () { - editorName.cm.replaceSelection("$$$$"); - var __Cursor = editorName.cm.getDoc().getCursor(); - editorName.cm.setCursor(__Cursor.line, __Cursor.ch - 2); - editorName.cm.focus(); - }); - $("[type=\"inline\"]").attr("title", "行内公式"); - $("[type=\"latex\"]").attr("title", "多行公式"); - - md_elocalStorage(editorName, `memoNew_${id}`, "memoNew"); - - callback && callback() - } - }); - return editorName; -} - - -class Newshixuns extends Component { - constructor(props) { - super(props) - this.state = { - fileList: [], - newshixunlist: undefined, - departmentslist: undefined, - name: "", - main_type: "", - small_type: "", - trainee: "", - webssh: 0, - use_scope: 0, - can_copy: "", - scope_partment: undefined, - vnc: "", - scopetype: false, - postapplyvisible: false, - sendsure_applyvalue: undefined, - postapplytitle: false, - shixun_nametype: false, - main_types: false, - trainee_types: false, - SelectTheCommandtype: false, - opers: false, - operss: false, - TimePickervalue: "", - opensmail: false, - onSearchvalue: "", - scope_partmenttype: false, - languagewrite: undefined, - systemenvironment:undefined, - testcoderunmode:undefined, - file:undefined, - } - } - - initMD(initValue) { - this.contentChanged = false; - const placeholder = ""; - // amp; - // 编辑时要传memoId - const imageUrl = `/api/attachments.json`; - // 创建editorMd - - const taskpass_editormd = create_editorMD("memoMD", '100%', 400, placeholder, imageUrl, () => { - setTimeout(() => { - taskpass_editormd.resize() - taskpass_editormd.cm && taskpass_editormd.cm.refresh() - }, 500) - - if (initValue) { - taskpass_editormd.setValue(initValue) - } - taskpass_editormd.cm.on("change", (_cm, changeObj) => { - // console.log('....contentChanged') - this.contentChanged = true; - }) - }); - this.taskpass_editormd = taskpass_editormd; - window.taskpass_editormd = taskpass_editormd; - - } - - componentDidMount() { - let newshixunUrl = `/shixuns/new.json`; - axios.get(newshixunUrl).then((response) => { - if (response.status === 200) { - if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) { - - } else { - this.setState({ - newshixunlist: response.data - }); - this.initMD(response.data.sample[0][1]); - } - - } - }).catch((error) => { - console.log(error) - }); - - let departmentsUrl = `/shixuns/departments.json`; - axios.get(departmentsUrl).then((response) => { - if (response.status === 200) { - this.setState({ - departmentslist: response.data.shools_name - }); - } - }).catch((error) => { - console.log(error) - }); - } - - setlanguagewrite = (e)=>{ - this.setState({ - languagewrite: e.target.value - }) - } - - setsystemenvironment = (e) => { - this.setState({ - systemenvironment: e.target.value - }) - } - settestcoderunmode = (e) => { - this.setState({ - testcoderunmode: e.target.value - }) - - } - shixunname = (e) => { - this.setState({ - name: e.target.value, - shixun_nametype: false - }); - } - - bigClass = (value) => { - this.setState({ - main_type: value - }) - } - - littleClass = (value) => { - this.setState({ - small_type: value - }) - } - - Selectthestudent = (value) => { - this.setState({ - trainee: value - }) - } - - SelectTheCommand = (e) => { - this.setState({ - webssh: e.target.value, - }); - - if (e.target.value === 2) { - this.setState({ - SelectTheCommandtype: true, - multi_webssh: false - }); - } else { - this.setState({ - SelectTheCommandtype: false, - multi_webssh: false - }); - } - } - - Selectpublic = (e) => { - this.setState({ - scopetype: false, - use_scope: e.target.value, - }); - if (e.target.value === 1) { - this.setState({ - scopetype: true - }); - } - - } - - Teacherscopy = (e) => { - let sum = "" - if (e.target.checked === false) { - sum = 0 - } else if (e.target.checked === true) { - sum = 1 - } - this.setState({ - can_copy: sum, - }); - } - - TeachersUbuntu = (e) => { - let sum = "" - if (e.target.checked === false) { - sum = 0 - } else if (e.target.checked === true) { - sum = 1 - } - this.setState({ - vnc: sum, - }); - } - - adduse_scopeinput = () => { - let {scope_partment} = this.state; - let array = scope_partment; - let newarray = "" - array.push(newarray) - this.setState({ - scope_partment: array, - }); - } - - shixunScopeInput = (e, id) => { - let {scope_partment} = this.state; - let datalist = scope_partment; - if (datalist === undefined) { - datalist = [] - } - datalist.push(e) - // else{ - // datalist[id]=e - // } - - this.setState({ - scope_partment: datalist, - onSearchvalue: "" - }); - } - - deleteScopeInput = (key) => { - let {scope_partment} = this.state; - let datalist = scope_partment; - datalist.splice(key, 1); - this.setState({ - scope_partment: datalist - }); - } - - //提交数据 - submit_new_shixun = () => { - const mdVal = this.taskpass_editormd.getValue(); - let {can_copy, main_type, name, scope_partment, small_type, trainee, use_scope, vnc, webssh, multi_webssh, TimePickervalue} = this.state; - let Url = `/shixuns.json` - if (name === "") { - this.setState({ - shixun_nametype: true - }) - this.props.showSnackbar("实训名称为空"); - $('html').animate({ - scrollTop: 10 - }, 1000); - return - } - if (main_type === "") { - this.setState({ - main_types: true - }) - $('html').animate({ - scrollTop: 700 - }, 1000); - this.props.showSnackbar("请选择技术平台大类别"); - - return - } - - if (use_scope === 1) { - if (scope_partment === undefined || scope_partment.length === 0) { - this.setState({ - scope_partmenttype: true - }) - $('html').animate({ - scrollTop: 900 - }, 1000); - this.props.showSnackbar("公开程度,指定单位为空"); - return - } - } - if (trainee === "") { - this.setState({ - trainee_types: true - }) - // $('html').animate({ - // scrollTop: 700 - // }, 1000); - this.props.showSnackbar("请选择发布信息"); - return - } - let newmulti_webssh = multi_webssh; - if (newmulti_webssh === true) { - newmulti_webssh = 1 - } else { - newmulti_webssh = "" - } - axios.post(Url, { - name: name, - can_copy: can_copy, - description: mdVal, - main_type: main_type, - scope_partment: scope_partment, - small_type: small_type, - trainee: trainee, - use_scope: use_scope, - vnc: vnc, - webssh: webssh, - multi_webssh: newmulti_webssh, - task_pass: 1, - opening_time: TimePickervalue - } - ).then((response) => { - if (response.status === 200) { - window.location.href = "/shixuns/" + response.data.shixun_identifier + "/challenges"; - // window.open("/shixuns/"+response.data.shixun_identifier+"/challenges"); - } - }).catch((error) => { - console.log(error) - }) - } - - - shixunsfetch = (value, callback) => { - if (timeout) { - clearTimeout(timeout); - timeout = null; - } - currentValue = value; - - function fake() { - let departmentsUrl = `/shixuns/departments.json?q=` + currentValue; - axios.get(departmentsUrl).then((response) => { - callback(response.data.shools_name); - }).catch((error) => { - console.log(error) - }); - } - - timeout = setTimeout(fake, 300); - } - - shixunHandleSearch = (value) => { - this.shixunsfetch(value, departmentslist => this.setState({departmentslist})); - this.setState({ - onSearchvalue: "" - }) - } - - post_apply = () => { - this.setState({ - postapplyvisible: true - }) - } - sendsure_apply = () => { - let {languagewrite,systemenvironment,testcoderunmode} = this.state; - // console.log("点击确定") - // console.log("languagewrite"+languagewrite); - // console.log("systemenvironment"+systemenvironment); - // console.log("testcoderunmode"+testcoderunmode); - - // let attachment_ids = undefined - // if (this.state.fileList) { - // attachment_ids = this.state.fileList.map(item => { - // return item.response ? item.response.id : item.id - // }) - // } - if(languagewrite === undefined || languagewrite === "" ){ - this.props.showNotification(`请填写该镜像是基于什么语言`); - - return - } - if(systemenvironment === undefined || systemenvironment === ""){ - this.props.showNotification(`请填写该镜像是基于什么语言系统环境`); - - return; - - } - if(testcoderunmode === undefined || testcoderunmode === "") { - this.props.showNotification(`请填写该镜像中测试代码运行方式`); - - return; - - } - var attachment_ids=undefined; - if (this.state.fileList) { - attachment_ids = this.state.fileList.map(item => { - return item.response ? item.response.id : item.id - }) - } - if( attachment_ids === undefined || attachment_ids.length===0){ - this.props.showNotification(`请上传附件`); - - return; - } - // console.log("attachment_ids"+attachment_ids); - - // alert(languagewrite +" "+systemenvironment +" "+testcoderunmode + " "+attachment_ids); - - var data={ - language:languagewrite, - runtime:systemenvironment, - run_method:testcoderunmode, - attachment_id:attachment_ids[0], - } - var url =`/shixuns/apply_shixun_mirror.json`; - axios.post(url,data - ).then((response) => { - - try { - if (response.data) { - // const { id } = response.data; - // if (id) { - if(this.state.file !== undefined){ - this.deleteAttachment(this.state.file); - this.setState({ - file:undefined, - languagewrite:"", - systemenvironment:"", - testcoderunmode:"", - }) - }else { - this.setState({ - file:undefined, - languagewrite:"", - systemenvironment:"", - testcoderunmode:"", - }) - } - this.props.showNotification('提交成功!'); - // this.props.history.push(`/courses/${cid}/graduation_topics`); - // } - } - }catch (e) { - - } - - }) - - } - sendhideModaly = () => { - this.setState({ - postapplyvisible: false, - }) - if(this.state.file !== undefined){ - this.deleteAttachment(this.state.file); - this.setState({ - file:undefined, - languagewrite:"", - systemenvironment:"", - testcoderunmode:"", - }) - }else { - this.setState({ - file:undefined, - languagewrite:"", - systemenvironment:"", - testcoderunmode:"", - }) - } - } - sendsure_applyvalues = (e) => { - this.setState({ - sendsure_applyvalue: e.target.value - }) - } - yeshidemodel = () => { - this.setState({ - postapplytitle: false - }) - } - - SelectTheCommandonChange = (e) => { - this.setState({ - multi_webssh: e.target.checked - }) - } - - - bigopen = () => { - this.setState({ - opers: true - }) - } - - bigopens = () => { - this.setState({ - opers: false, - operss: false, - opensmail: false - }) - - } - - bigopensmal = () => { - this.setState({ - opensmail: true - }) - } - - sbigopen = () => { - this.setState({ - operss: true - }) - } - - // sbigopens=()=>{ - // this.setState({ - // operss:false - // }) - // } - - onChangeTimePicker = (value, dateString) => { - this.setState({ - TimePickervalue: dateString - }) - } - // 附件相关 START - handleChange = (info) => { - console.log("handleChange1"); - let fileList = info.fileList; - this.setState({ fileList }); - } - onAttachmentRemove = (file) => { - confirm({ - title: '确定要删除这个附件吗?', - okText: '确定', - cancelText: '取消', - // content: 'Some descriptions', - onOk: () => { - this.deleteAttachment(file) - }, - onCancel() { - console.log('Cancel'); - }, - }); - return false; - } - deleteAttachment = (file) => { - // console.log(file); - let id=file.response ==undefined ? file.id : file.response.id - const url = `/attachments/${id}.json` - axios.delete(url, { - }) - .then((response) => { - if (response.data) { - const { status } = response.data; - if (status == 0) { - // console.log('--- success') - - this.setState((state) => { - const index = state.fileList.indexOf(file); - const newFileList = state.fileList.slice(); - newFileList.splice(index, 1); - return { - fileList: newFileList, - }; - }); - } - } - }) - .catch(function (error) { - console.log(error); - }); - } - - - handleSubmit=()=>{ - // console.log(this.state.languagewrite) - // console.log(this.state.systemenvironment) - // console.log(this.state.testcoderunmode) - var attachment_ids; - if (this.state.fileList) { - attachment_ids = this.state.fileList.map(item => { - return item.response ? item.response.id : item.id - }) - } - // console.log(attachment_ids); - // var data={ - // language:"", - // runtime:"", - // run_method:"", - // attachment_id:"", - // } - // axios.post(url,data - // ).then((response) => { - // if (response.data) { - // // const { id } = response.data; - // // if (id) { - // this.props.showNotification('提交成功!'); - // // this.props.history.push(`/courses/${cid}/graduation_topics`); - // // } - // } - // }) - - - - } - render() { - const { getFieldDecorator } = this.props.form; - const thiss=this; - let {testcoderunmode ,systemenvironment,languagewrite, fileList,TimePickervalue, scope_partmenttype, opensmail, newshixunlist, name, scope_partment, departmentslist, postapplyvisible, sendsure_applyvalue, postapplytitle, shixun_nametype, main_types, trainee_types, SelectTheCommandtype, opers, operss, onSearchvalue} = this.state; - let options - if (departmentslist != undefined) { - options = this.state.departmentslist.map((d, k) => { - return ( - - ) - }) - } - const uploadProps = { - width: 600, - fileList, - multiple: true, - // https://github.com/ant-design/ant-design/issues/15505 - // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 - // showUploadList: false, - action: `${getUrl()}/api/attachments.json`, - onChange: this.handleChange, - onRemove: this.onAttachmentRemove, - beforeUpload: (file) => { - // console.log('beforeUpload', file.name); - const isLt150M = file.size / 1024 / 1024 < 50; - if (!isLt150M) { - this.props.showNotification(`文件大小必须小于50MB`); - - } - if(thiss.state.file !== undefined){ - thiss.deleteAttachment(thiss.state.file); - thiss.setState({ - file:file - }) - }else { - thiss.setState({ - file:file - }) - } - - console.log("handleChange2"); - return isLt150M; - }, - } - // const uploadProps = { - // width: 600, - // fileList, - // multiple: true, - // // https://github.com/ant-design/ant-design/issues/15505 - // // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 - // // showUploadList: false, - // action: `${getUrl()}/api/attachments.json`, - // onChange: this.handleChange, - // onRemove: this.onAttachmentRemove, - // beforeUpload: (file) => { - // // console.log('beforeUpload', file.name); - // const isLt50M = file.size / 1024 / 1024 < 50; - // if (!isLt50M) { - // message.error('文件大小必须小于150MB!'); - // } - // return isLt50M; - // }, - // }; - return ( - -
    -
    -
    - -
    -

    - 创建实训 - 实训制作指南 -

    - -
    -

    实训名称

    -
    - * -
    - - - 必填项 - -
    - -
    -
    - -
    - - -
    - -

    简介

    - -
    -
    - -
    -
    -

    -

    -
    - -
    -

    技术平台

    -
    - * -
    - -

    - 列表中没有? - 申请新建 -

    - - - {/**/} -
    -
  • - - -
  • -
  • - - -
  • - -
  • - - - -
  • - -
  • - -
    - {/**/} - {/* {*/} - {/* getFieldDecorator('file',{*/} - {/* rules:[{*/} - {/* }]*/} - {/* })(*/} - - - 上传附件 - (单个文件50M以内) - - - {/* )*/} - {/* }*/} - {/**/} -
    - -
  • -
  • - - - this.sendhideModaly()} - >取消 - - -
  • -
    -
    - {/**/} -
    - - -
    -

    新建申请已提交,请等待管理员的审核

    -
  • 我们将在1-2个工作日内与您联系 -
  • -
    -
    - 知道啦 -
    -
    -
    -
    -
    - -
    -

    请在配置页面完成后续的评测脚本设置操作

    -
    - 必填项 -
    -
    -
    - - -
    -

    命令行

    -
    - - 无命令行窗口 (选中则不给学员的实践任务提供命令窗口) - 命令行练习窗口 (选中则给学员提供用于练习操作的命令行窗口) - 命令行评测窗口 (选中则给学员提供用于关卡评测的命令行窗口) - - 多个命令行窗口(选中则允许学员同时开启多个命令行窗口) - - -
    -
    - - -
    -

    公开程度

    -
    - - 对所有公开 (选中则所有已被试用授权的用户可以学习) - 对指定单位公开 (选中则下方指定单位的已被试用授权的用户可以学习) - - -
    -
    -
    -
    -
    - -
    - (搜索选中添加单位名称) - {/*+ 添加*/} -
    -
    - -
    -
    - { - scope_partment === undefined ? "" : scope_partment.map((item, key) => { - return ( -
  • {item} - this.deleteScopeInput(key)}>× -
  • - ) - }) - } -
    - {/*{*/} - {/*scope_partment===undefined?"":scope_partment.map((item,key)=>{*/} - {/*return(*/} - {/*
    */} - {/*this.deleteScopeInput(key)} style={{ color: 'rgba(0,0,0,.25)' }} />}*/} - {/*value={item}*/} - {/*/>*/} - {/*
    */} - - {/*)*/} - {/*})*/} - {/*}*/} -
    - - - - 请选择需要公开的单位 - -
    -
    -
    -
    - - -
    -

    发布信息

    -
    -
    - *面向学员: -
    - -
    - 实训难易度定位,不限定用户群体 -
    - 必填项 -
    -
    -
    -
  • - 复制: - - -
  • -
    - 开启时间: -
  • - - -
  • -
    -
    - {/*
    */} - {/*

    VNC图形化

    */} - {/*
  • */} - {/**/} - {/**/} - {/*
  • */} - {/*
    */} - - -
    - 提交 - 取消 -
    - - -
    -
    -
    - - ); - } -} -const NewshixunsNew = Form.create({ name: 'newshixunsnew' })(Newshixuns); -export default SnackbarHOC()(TPMIndexHOC(NewshixunsNew)); - - - - - - +import React, {Component} from 'react'; + +import {TPMIndexHOC} from '../TPMIndexHOC'; + +import {SnackbarHOC} from 'educoder'; + +import {Input, Select, Radio, Checkbox, Modal, Icon, DatePicker,Upload,Button,message,Form} from 'antd'; + +// import "antd/dist/antd.css"; + +import locale from 'antd/lib/date-picker/locale/zh_CN'; + +import axios from 'axios'; + +import './css/Newshixuns.css'; + +import {getUrl} from 'educoder' + +let path = getUrl("/editormd/lib/") + +const $ = window.$; + +let timeout; + +let currentValue; + +const Option = Select.Option; + +const RadioGroup = Radio.Group; +const confirm = Modal.confirm; +// 恢复数据 +function md_rec_data(k, mdu, id, editor) { + if (window.sessionStorage.getItem(k + mdu) !== null) { + editor.setValue(window.sessionStorage.getItem(k + mdu)); + md_clear_data(k, mdu, id); + } +} + +// 保存数据 +function md_add_data(k, mdu, d) { + window.sessionStorage.setItem(k + mdu, d); +} + +// 清空保存的数据 +function md_clear_data(k, mdu, id) { + window.sessionStorage.removeItem(k + mdu); + var id1 = "#e_tip_" + id; + var id2 = "#e_tips_" + id; + if (k == 'content') { + $(id2).html(""); + } else { + $(id1).html(""); + } +} + +function md_elocalStorage(editor, mdu, id) { + if (window.sessionStorage) { + var oc = window.sessionStorage.getItem('content' + mdu); + if (oc !== null) { + $("#e_tips_" + id).data('editor', editor); + var h = '您上次有已保存的数据,是否恢复 ? / 不恢复'; + $("#e_tips_" + id).html(h); + } + setInterval(function () { + var d = new Date(); + var h = d.getHours(); + var m = d.getMinutes(); + var s = d.getSeconds(); + h = h < 10 ? '0' + h : h; + m = m < 10 ? '0' + m : m; + s = s < 10 ? '0' + s : s; + if (editor.getValue().trim() != "") { + md_add_data("content", mdu, editor.getValue()); + var id1 = "#e_tip_" + id; + var id2 = "#e_tips_" + id; + + $(id1).html(" 数据已于 " + h + ':' + m + ':' + s + " 保存 "); + $(id2).html(""); + } + }, 10000); + + } else { + $("#e_tip_" + id).after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!'); + } +} + + +function create_editorMD(id, width, high, placeholder, imageUrl, callback) { + var editorName = window.editormd(id, { + width: width, + height: high, + path: path, // "/editormd/lib/" + + syncScrolling: "single", + tex: true, + tocm: true, + emoji: true, + taskList: true, + codeFold: true, + searchReplace: true, + htmlDecode: "style,script,iframe", + sequenceDiagram: true, + autoFocus: false, + toolbarIcons: function () { + // Or return editormd.toolbarModes[name]; // full, simple, mini + // Using "||" set icons align right. + return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"] + }, + toolbarCustomIcons: { + testIcon: "
    ", + testIcon1: "
    " + }, + //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 + saveHTMLToTextarea: true, + // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标 + dialogMaskOpacity: 0.6, + placeholder: placeholder, + imageUpload: true, + imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], + imageUploadURL: imageUrl,//url + onload: function () { + // this.previewing(); + $("#" + id + " [type=\"latex\"]").bind("click", function () { + editorName.cm.replaceSelection("```latex"); + editorName.cm.replaceSelection("\n"); + editorName.cm.replaceSelection("\n"); + editorName.cm.replaceSelection("```"); + var __Cursor = editorName.cm.getDoc().getCursor(); + editorName.cm.setCursor(__Cursor.line - 1, 0); + }); + + $("#" + id + " [type=\"inline\"]").bind("click", function () { + editorName.cm.replaceSelection("$$$$"); + var __Cursor = editorName.cm.getDoc().getCursor(); + editorName.cm.setCursor(__Cursor.line, __Cursor.ch - 2); + editorName.cm.focus(); + }); + $("[type=\"inline\"]").attr("title", "行内公式"); + $("[type=\"latex\"]").attr("title", "多行公式"); + + md_elocalStorage(editorName, `memoNew_${id}`, "memoNew"); + + callback && callback() + } + }); + return editorName; +} + + +class Newshixuns extends Component { + constructor(props) { + super(props) + this.state = { + fileList: [], + newshixunlist: undefined, + departmentslist: undefined, + name: "", + main_type: "", + small_type: "", + trainee: "", + webssh: 0, + use_scope: 0, + can_copy: "", + scope_partment: undefined, + vnc: "", + scopetype: false, + postapplyvisible: false, + sendsure_applyvalue: undefined, + postapplytitle: false, + shixun_nametype: false, + main_types: false, + trainee_types: false, + SelectTheCommandtype: false, + opers: false, + operss: false, + TimePickervalue: "", + opensmail: false, + onSearchvalue: "", + scope_partmenttype: false, + languagewrite: undefined, + systemenvironment:undefined, + testcoderunmode:undefined, + file:undefined, + } + } + + initMD(initValue) { + this.contentChanged = false; + const placeholder = ""; + // amp; + // 编辑时要传memoId + const imageUrl = `/api/attachments.json`; + // 创建editorMd + + const taskpass_editormd = create_editorMD("memoMD", '100%', 400, placeholder, imageUrl, () => { + setTimeout(() => { + taskpass_editormd.resize() + taskpass_editormd.cm && taskpass_editormd.cm.refresh() + }, 500) + + if (initValue) { + taskpass_editormd.setValue(initValue) + } + taskpass_editormd.cm.on("change", (_cm, changeObj) => { + // console.log('....contentChanged') + this.contentChanged = true; + }) + }); + this.taskpass_editormd = taskpass_editormd; + window.taskpass_editormd = taskpass_editormd; + + } + + componentDidMount() { + let newshixunUrl = `/shixuns/new.json`; + axios.get(newshixunUrl).then((response) => { + if (response.status === 200) { + if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) { + + } else { + this.setState({ + newshixunlist: response.data + }); + this.initMD(response.data.sample[0][1]); + } + + } + }).catch((error) => { + console.log(error) + }); + + let departmentsUrl = `/shixuns/departments.json`; + axios.get(departmentsUrl).then((response) => { + if (response.status === 200) { + this.setState({ + departmentslist: response.data.shools_name + }); + } + }).catch((error) => { + console.log(error) + }); + } + + setlanguagewrite = (e)=>{ + this.setState({ + languagewrite: e.target.value + }) + } + + setsystemenvironment = (e) => { + this.setState({ + systemenvironment: e.target.value + }) + } + settestcoderunmode = (e) => { + this.setState({ + testcoderunmode: e.target.value + }) + + } + shixunname = (e) => { + this.setState({ + name: e.target.value, + shixun_nametype: false + }); + } + + bigClass = (value) => { + this.setState({ + main_type: value + }) + } + + littleClass = (value) => { + this.setState({ + small_type: value + }) + } + + Selectthestudent = (value) => { + this.setState({ + trainee: value + }) + } + + SelectTheCommand = (e) => { + this.setState({ + webssh: e.target.value, + }); + + if (e.target.value === 2) { + this.setState({ + SelectTheCommandtype: true, + multi_webssh: false + }); + } else { + this.setState({ + SelectTheCommandtype: false, + multi_webssh: false + }); + } + } + + Selectpublic = (e) => { + this.setState({ + scopetype: false, + use_scope: e.target.value, + }); + if (e.target.value === 1) { + this.setState({ + scopetype: true + }); + } + + } + + Teacherscopy = (e) => { + let sum = "" + if (e.target.checked === false) { + sum = 0 + } else if (e.target.checked === true) { + sum = 1 + } + this.setState({ + can_copy: sum, + }); + } + + TeachersUbuntu = (e) => { + let sum = "" + if (e.target.checked === false) { + sum = 0 + } else if (e.target.checked === true) { + sum = 1 + } + this.setState({ + vnc: sum, + }); + } + + adduse_scopeinput = () => { + let {scope_partment} = this.state; + let array = scope_partment; + let newarray = "" + array.push(newarray) + this.setState({ + scope_partment: array, + }); + } + + shixunScopeInput = (e, id) => { + let {scope_partment} = this.state; + let datalist = scope_partment; + if (datalist === undefined) { + datalist = [] + } + datalist.push(e) + // else{ + // datalist[id]=e + // } + + this.setState({ + scope_partment: datalist, + onSearchvalue: "" + }); + } + + deleteScopeInput = (key) => { + let {scope_partment} = this.state; + let datalist = scope_partment; + datalist.splice(key, 1); + this.setState({ + scope_partment: datalist + }); + } + + //提交数据 + submit_new_shixun = () => { + const mdVal = this.taskpass_editormd.getValue(); + let {can_copy, main_type, name, scope_partment, small_type, trainee, use_scope, vnc, webssh, multi_webssh, TimePickervalue} = this.state; + let Url = `/shixuns.json` + if (name === "") { + this.setState({ + shixun_nametype: true + }) + this.props.showSnackbar("实训名称为空"); + $('html').animate({ + scrollTop: 10 + }, 1000); + return + } + if (main_type === "") { + this.setState({ + main_types: true + }) + $('html').animate({ + scrollTop: 700 + }, 1000); + this.props.showSnackbar("请选择技术平台大类别"); + + return + } + + if (use_scope === 1) { + if (scope_partment === undefined || scope_partment.length === 0) { + this.setState({ + scope_partmenttype: true + }) + $('html').animate({ + scrollTop: 900 + }, 1000); + this.props.showSnackbar("公开程度,指定单位为空"); + return + } + } + if (trainee === "") { + this.setState({ + trainee_types: true + }) + // $('html').animate({ + // scrollTop: 700 + // }, 1000); + this.props.showSnackbar("请选择发布信息"); + return + } + let newmulti_webssh = multi_webssh; + if (newmulti_webssh === true) { + newmulti_webssh = 1 + } else { + newmulti_webssh = "" + } + axios.post(Url, { + name: name, + can_copy: can_copy, + description: mdVal, + main_type: main_type, + scope_partment: scope_partment, + small_type: small_type, + trainee: trainee, + use_scope: use_scope, + vnc: vnc, + webssh: webssh, + multi_webssh: newmulti_webssh, + task_pass: 1, + opening_time: TimePickervalue + } + ).then((response) => { + if (response.status === 200) { + window.location.href = "/shixuns/" + response.data.shixun_identifier + "/challenges"; + // window.open("/shixuns/"+response.data.shixun_identifier+"/challenges"); + } + }).catch((error) => { + console.log(error) + }) + } + + + shixunsfetch = (value, callback) => { + if (timeout) { + clearTimeout(timeout); + timeout = null; + } + currentValue = value; + + function fake() { + let departmentsUrl = `/shixuns/departments.json?q=` + currentValue; + axios.get(departmentsUrl).then((response) => { + callback(response.data.shools_name); + }).catch((error) => { + console.log(error) + }); + } + + timeout = setTimeout(fake, 300); + } + + shixunHandleSearch = (value) => { + this.shixunsfetch(value, departmentslist => this.setState({departmentslist})); + this.setState({ + onSearchvalue: "" + }) + } + + post_apply = () => { + this.setState({ + postapplyvisible: true + }) + } + sendsure_apply = () => { + let {languagewrite,systemenvironment,testcoderunmode} = this.state; + // console.log("点击确定") + // console.log("languagewrite"+languagewrite); + // console.log("systemenvironment"+systemenvironment); + // console.log("testcoderunmode"+testcoderunmode); + + // let attachment_ids = undefined + // if (this.state.fileList) { + // attachment_ids = this.state.fileList.map(item => { + // return item.response ? item.response.id : item.id + // }) + // } + if(languagewrite === undefined || languagewrite === "" ){ + this.props.showNotification(`请填写该镜像是基于什么语言`); + + return + } + if(systemenvironment === undefined || systemenvironment === ""){ + this.props.showNotification(`请填写该镜像是基于什么语言系统环境`); + + return; + + } + if(testcoderunmode === undefined || testcoderunmode === "") { + this.props.showNotification(`请填写该镜像中测试代码运行方式`); + + return; + + } + var attachment_ids=undefined; + if (this.state.fileList) { + attachment_ids = this.state.fileList.map(item => { + return item.response ? item.response.id : item.id + }) + } + if( attachment_ids === undefined || attachment_ids.length===0){ + this.props.showNotification(`请上传附件`); + + return; + } + // console.log("attachment_ids"+attachment_ids); + + // alert(languagewrite +" "+systemenvironment +" "+testcoderunmode + " "+attachment_ids); + + var data={ + language:languagewrite, + runtime:systemenvironment, + run_method:testcoderunmode, + attachment_id:attachment_ids[0], + } + var url =`/shixuns/apply_shixun_mirror.json`; + axios.post(url,data + ).then((response) => { + + try { + if (response.data) { + // const { id } = response.data; + // if (id) { + if(this.state.file !== undefined){ + console.log("549"); + this.deleteAttachment(this.state.file); + this.setState({ + file:undefined, + languagewrite:"", + systemenvironment:"", + testcoderunmode:"", + }) + }else { + this.setState({ + file:undefined, + languagewrite:"", + systemenvironment:"", + testcoderunmode:"", + }) + } + this.props.showNotification('提交成功!'); + // this.props.history.push(`/courses/${cid}/graduation_topics`); + // } + } + }catch (e) { + + } + + }) + + } + sendhideModaly = () => { + this.setState({ + postapplyvisible: false, + }) + if(this.state.file !== undefined){ + console.log("580"); + this.deleteAttachment(this.state.file); + this.setState({ + file:undefined, + languagewrite:"", + systemenvironment:"", + testcoderunmode:"", + }) + }else { + this.setState({ + file:undefined, + languagewrite:"", + systemenvironment:"", + testcoderunmode:"", + }) + } + } + sendsure_applyvalues = (e) => { + this.setState({ + sendsure_applyvalue: e.target.value + }) + } + yeshidemodel = () => { + this.setState({ + postapplytitle: false + }) + } + + SelectTheCommandonChange = (e) => { + this.setState({ + multi_webssh: e.target.checked + }) + } + + + bigopen = () => { + this.setState({ + opers: true + }) + } + + bigopens = () => { + this.setState({ + opers: false, + operss: false, + opensmail: false + }) + + } + + bigopensmal = () => { + this.setState({ + opensmail: true + }) + } + + sbigopen = () => { + this.setState({ + operss: true + }) + } + + // sbigopens=()=>{ + // this.setState({ + // operss:false + // }) + // } + + onChangeTimePicker = (value, dateString) => { + this.setState({ + TimePickervalue: dateString + }) + } + // 附件相关 START + handleChange = (info) => { + console.log("handleChange1"); + let fileList = info.fileList; + this.setState({ fileList }); + } + onAttachmentRemove = (file) => { + confirm({ + title: '确定要删除这个附件吗?', + okText: '确定', + cancelText: '取消', + // content: 'Some descriptions', + onOk: () => { + console.log("665") + this.deleteAttachment(file) + }, + onCancel() { + console.log('Cancel'); + }, + }); + return false; + } + deleteAttachment = (file) => { + console.log(file); + let id=file.response ==undefined ? file.id : file.response.id + const url = `/attachments/${id}.json` + axios.delete(url, { + }) + .then((response) => { + if (response.data) { + const { status } = response.data; + if (status == 0) { + // console.log('--- success') + + this.setState((state) => { + const index = state.fileList.indexOf(file); + const newFileList = state.fileList.slice(); + newFileList.splice(index, 1); + return { + fileList: newFileList, + }; + }); + } + } + }) + .catch(function (error) { + console.log(error); + }); + } + + + handleSubmit=()=>{ + // console.log(this.state.languagewrite) + // console.log(this.state.systemenvironment) + // console.log(this.state.testcoderunmode) + var attachment_ids; + if (this.state.fileList) { + attachment_ids = this.state.fileList.map(item => { + return item.response ? item.response.id : item.id + }) + } + // console.log(attachment_ids); + // var data={ + // language:"", + // runtime:"", + // run_method:"", + // attachment_id:"", + // } + // axios.post(url,data + // ).then((response) => { + // if (response.data) { + // // const { id } = response.data; + // // if (id) { + // this.props.showNotification('提交成功!'); + // // this.props.history.push(`/courses/${cid}/graduation_topics`); + // // } + // } + // }) + + + + } + render() { + const { getFieldDecorator } = this.props.form; + const thiss=this; + let {testcoderunmode ,systemenvironment,languagewrite, fileList,TimePickervalue, scope_partmenttype, opensmail, newshixunlist, name, scope_partment, departmentslist, postapplyvisible, sendsure_applyvalue, postapplytitle, shixun_nametype, main_types, trainee_types, SelectTheCommandtype, opers, operss, onSearchvalue} = this.state; + let options + if (departmentslist != undefined) { + options = this.state.departmentslist.map((d, k) => { + return ( + + ) + }) + } + const uploadProps = { + width: 600, + fileList, + multiple: true, + // https://github.com/ant-design/ant-design/issues/15505 + // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 + // showUploadList: false, + action: `${getUrl()}/api/attachments.json`, + onChange: this.handleChange, + onRemove: this.onAttachmentRemove, + beforeUpload: (file) => { + // console.log('beforeUpload', file.name); + const isLt150M = file.size / 1024 / 1024 < 50; + if (!isLt150M) { + this.props.showNotification(`文件大小必须小于50MB`); + + } + if(thiss.state.file !== undefined){ + console.log("763") + thiss.deleteAttachment(thiss.state.file); + thiss.setState({ + file:file + }) + }else { + thiss.setState({ + file:file + }) + } + + console.log("handleChange2"); + return isLt150M; + }, + } + // const uploadProps = { + // width: 600, + // fileList, + // multiple: true, + // // https://github.com/ant-design/ant-design/issues/15505 + // // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 + // // showUploadList: false, + // action: `${getUrl()}/api/attachments.json`, + // onChange: this.handleChange, + // onRemove: this.onAttachmentRemove, + // beforeUpload: (file) => { + // // console.log('beforeUpload', file.name); + // const isLt50M = file.size / 1024 / 1024 < 50; + // if (!isLt50M) { + // message.error('文件大小必须小于150MB!'); + // } + // return isLt50M; + // }, + // }; + return ( + +
    +
    +
    + +
    +

    + 创建实训 + 实训制作指南 +

    + +
    +

    实训名称

    +
    + * +
    + + + 必填项 + +
    + +
    +
    + +
    + + +
    + +

    简介

    + +
    +
    + +
    +
    +

    +

    +
    + +
    +

    技术平台

    +
    + * +
    + +

    + 列表中没有? + 申请新建 +

    + + + {/*
    */} +
    +
  • + + +
  • +
  • + + +
  • + +
  • + + + +
  • + +
  • + +
    + {/**/} + {/* {*/} + {/* getFieldDecorator('file',{*/} + {/* rules:[{*/} + {/* }]*/} + {/* })(*/} + + + 上传附件 + (单个文件50M以内) + + + {/* )*/} + {/* }*/} + {/**/} +
    + +
  • +
  • + + + this.sendhideModaly()} + >取消 + + +
  • +
    +
    + {/*
    */} +
    + + +
    +

    新建申请已提交,请等待管理员的审核

    +
  • 我们将在1-2个工作日内与您联系 +
  • +
    +
    + 知道啦 +
    +
    +
    +
    +
    + +
    +

    请在配置页面完成后续的评测脚本设置操作

    +
    + 必填项 +
    +
    +
    + + +
    +

    命令行

    +
    + + 无命令行窗口 (选中则不给学员的实践任务提供命令窗口) + 命令行练习窗口 (选中则给学员提供用于练习操作的命令行窗口) + 命令行评测窗口 (选中则给学员提供用于关卡评测的命令行窗口) + + 多个命令行窗口(选中则允许学员同时开启多个命令行窗口) + + +
    +
    + + +
    +

    公开程度

    +
    + + 对所有公开 (选中则所有已被试用授权的用户可以学习) + 对指定单位公开 (选中则下方指定单位的已被试用授权的用户可以学习) + + +
    +
    +
    +
    +
    + +
    + (搜索选中添加单位名称) + {/*+ 添加*/} +
    +
    + +
    +
    + { + scope_partment === undefined ? "" : scope_partment.map((item, key) => { + return ( +
  • {item} + this.deleteScopeInput(key)}>× +
  • + ) + }) + } +
    + {/*{*/} + {/*scope_partment===undefined?"":scope_partment.map((item,key)=>{*/} + {/*return(*/} + {/*
    */} + {/*this.deleteScopeInput(key)} style={{ color: 'rgba(0,0,0,.25)' }} />}*/} + {/*value={item}*/} + {/*/>*/} + {/*
    */} + + {/*)*/} + {/*})*/} + {/*}*/} +
    + + + + 请选择需要公开的单位 + +
    +
    +
    +
    + + +
    +

    发布信息

    +
    +
    + *面向学员: +
    + +
    + 实训难易度定位,不限定用户群体 +
    + 必填项 +
    +
    +
    +
  • + 复制: + + +
  • +
    + 开启时间: +
  • + + +
  • +
    +
    + {/*
    */} + {/*

    VNC图形化

    */} + {/*
  • */} + {/**/} + {/**/} + {/*
  • */} + {/*
    */} + + +
    + 提交 + 取消 +
    + + +
    +
    +
    + + ); + } +} +const NewshixunsNew = Form.create({ name: 'newshixunsnew' })(Newshixuns); +export default SnackbarHOC()(TPMIndexHOC(NewshixunsNew)); + + + + + + From b1a27b3e2c03826fc152aee9d7c800ecff4dc1ed Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Wed, 26 Jun 2019 17:04:39 +0800 Subject: [PATCH 24/27] width --- .../src/modules/courses/busyWork/CommonWorkAppraise.js | 2 +- public/react/src/modules/courses/busyWork/CommonWorkList.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/courses/busyWork/CommonWorkAppraise.js b/public/react/src/modules/courses/busyWork/CommonWorkAppraise.js index 472cf57b5..5d4a34f6f 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkAppraise.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkAppraise.js @@ -190,7 +190,7 @@ class CommonWorkAppraise extends Component{
    内容
    -
    +
    {attachments.map((item,key)=>{ diff --git a/public/react/src/modules/courses/busyWork/CommonWorkList.js b/public/react/src/modules/courses/busyWork/CommonWorkList.js index 31532f78e..2243310a2 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkList.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkList.js @@ -80,7 +80,7 @@ function buildColumns(that, student_works) { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', - maxWidth: '98px' + width: '98px' }} title={text}> {/* */} @@ -99,7 +99,7 @@ function buildColumns(that, student_works) { {record.student_id} ), @@ -234,7 +234,7 @@ function buildColumns(that, student_works) { + isNiPing ? `你的评阅分数:${record.student_score}分` :
    {record.student_comment_count &&
    {`${record.student_comment_count}名学生进行了匿评`}
    }
    有效平均分:{record.student_score}分
    From fa26030c9233770c59b18ae82799ab467cdf88ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 26 Jun 2019 17:35:57 +0800 Subject: [PATCH 25/27] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/courses/poll/PollNew.js | 5686 ++++++++--------- .../TraineetraininginformationModal.js | 21 +- 2 files changed, 2863 insertions(+), 2844 deletions(-) diff --git a/public/react/src/modules/courses/poll/PollNew.js b/public/react/src/modules/courses/poll/PollNew.js index 7b936a0b6..392acf57c 100644 --- a/public/react/src/modules/courses/poll/PollNew.js +++ b/public/react/src/modules/courses/poll/PollNew.js @@ -1,2844 +1,2844 @@ -import React, {Component} from "react"; -import {Form, Input, Tooltip, Checkbox, Radio, Select, message, Modal, Button} from 'antd' -import {WordsBtn, ActionBtn} from 'educoder' -import '../css/members.css' -import "../common/formCommon.css" - -import './pollStyle.css' -import '../css/Courses.css' -import axios from 'axios' -import moment from "../new/CoursesNew"; -import Modals from "../../modals/Modals"; - - -const TextArea = Input.TextArea -const RadioGroup = Radio.Group -const CheckboxGroup = Checkbox.Group -const Option = Select.Option; -const maps = {1: "未发布", 2: "提交中", 3: "已截止"} -const confirm = Modal.confirm; - -class PollNew extends Component { - // 问卷新建和编辑 - // - // * addonAfter 字数限制 - // * q_counts 题目总数 - // * mysingles 单选题数量 - // * mydoubles 多选题数量 - // * mymainsint 主观题数量 - // * adddom 添加编辑的数据 页面点击新增题目 - // * editentry 编辑条目 新增的题目点击到条目中 - //* questionnair 问卷是否存在 默认不存在 - // * - - constructor(props) { - super(props); - this.state = { - visible: false, - poll_questions: [], - user_permission: "", - addonAfter: 60, - addonAftertwo: 100, - mysingles: 0, - mydoubles: 0, - mymainsint: 0, - adddom: [], - editentry: [], - questionnair: false, - polls_name: undefined, - polls_nametest: "", - polls_description: "", - polls_descriptiontest: "", - storagedesc:"", - storagedesctwo:"", - coursesId: "", - pollid: undefined, - polls_status: undefined, - q_countst: 0, - Newedit: true, - Insertposition: undefined, - Modalstype: false, - mysave: false, - readOnlys: "readOnly", - problemtopic: null, - problemtopicbool: false, - newoption: false, - cancellation: false, - } - // console.log("试卷新建和编辑"); - // console.log(JSON.stringify(props)); - - } - - changeTopicName = (e) => { - let num = 60 - parseInt(e.target.value.length); - this.setState({ - addonAfter: num < 0 ? 0 : num - }) - this.setState({ - polls_nametest: e.target.value - }) - } - - - changeTopicNametwo = (e) => { - // console.log("获取的值" + e.target.value); - let num = 100 - parseInt(e.target.value.length); - this.setState({ - addonAftertwo: num < 0 ? 0 : num - }) - this.setState({ - polls_descriptiontest: e.target.value - }) - } - - // 初始化数据 - componentDidMount = () => { - console.log("componentDidMount 50") - if (this.props.match.params.news !== undefined) { - if (this.props.match.params.news === "new") { - this.state.Newedit === true; - this.setState({ - Newedit: true, - mysave: true, - readOnlys: "", - cancellation: true, - }) - } else { - this.Initializatio_data(); - this.state.Newedit === false; - this.setState({ - Newedit: false, - mysave: false, - readOnlys: "readOnly", - }) - } - } - - - // this.getPollInfo(); - - } - //获取权限 - // getPollInfo(){ - // // console.log(this.props.match); - // let pollId=this.props.match.params.pollId; - // let url=`/polls/${pollId}/common_header.json` - // axios.get(url).then((result)=>{ - // if(result.status==200){ - // this.setState({ - // pollDetail:result.data, - // user_permission:result.data.user_permission - // }) - // } - // }).catch((error)=>{ - // console.log(error); - // }) - // } - //初始化请求网络 - Initializatio_data = () => { - console.log("Initializatio_data 582") - //课堂id - let coursesId = this.props.match.params.coursesId; - //时间id - let pollid = this.props.match.params.pollid; - console.log(pollid); - // let coursesId = 557; - if (pollid === undefined) { - // console.log("没有问卷新建问卷~~~") - // let coursesId=this.props.match.params.coursesId; - // // to={`/courses/${coursesId}/polls/new`} - // - // const urll = `/courses/${coursesId}/polls/new.json` - // axios.get(urll).then((result) => { - // if (result.status === 200) { - // console.log(urll) - // console.log("问卷新建成功") - // console.log(JSON.stringify(result)) - // // var path=`/courses/${coursesId}/polls/new`; - // // - // // this.props.history.push({ pathname: path, state: { } }); - // } - // }).catch((error) => { - // console.log(error) - // }) - - // const urlls = `/courses/${coursesId}/polls.json` - // axios.post(urlls,{ - // polls_name: "这是标题", - // polls_description:"这是标题须知" - // }).then((result)=>{ - // console.log("创建问卷++++++") - // console.log(result) - // try { - // if(result.data.status===0){ - // console.log("创建问卷") - // console.log(JSON.stringify(result.data)) - // } - // }catch (e) { - // - // } - // - // }) - //没有问卷 - this.setState({ - projects: [], - polls_name: "", - polls_description: "", - poll_questions: [], - question_types: [], - pollid: undefined, - mysingles: 0, - mydoubles: 0, - mymainsint: 0, - polls_nametest: "", - polls_descriptiontest: "", - coursesId: 0, - questionnair: false - }) - } else { - const url = `/polls/${pollid}/edit.json`; - axios.get(url).then((result) => { - if (result !== undefined) - - // console.log("有问卷~~~") - // if (result.status === 200) { - // console.log(JSON.stringify(result.data)) - this.props.form.setFieldsValue({ - polls_nametest: result.data.poll.polls_name, - polls_descriptiontest: result.data.poll.polls_description, - }); - 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, - }) - console.log(this.state.polls_nametest) - console.log(this.state.polls_descriptiontest) - // } - }).catch((error) => { - console.log(error) - }) - } - - } - - //重新获取数据 - thisinitializationdatanew = () => { - var pollidsy = null; - if (this.state.pollid !== undefined) { - pollidsy = this.state.pollid; - if (pollidsy === null || pollidsy === undefined) { - pollidsy = this.props.match.params.pollid; - } - } - - if (pollidsy === null || pollidsy === undefined) { - return - } - - const url = `/polls/${pollidsy}/edit.json`; - axios.get(url).then((result) => { - if (result !== undefined) - - // console.log("有问卷~~~") - // if (result.status === 200) { - // console.log(JSON.stringify(result.data)) - 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) => { - console.log(error) - }) - } - //新建问卷 - newword = () => { - 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.data.status === 0) { - this.state.Newedit === false; - // this.props.showNotification(`试卷创建成功`); - this.setState({ - pollid: result.data.data.id, - Newedit: false, - }) - this.props.history.push(`/courses/${this.props.match.params.coursesId}/polls/${result.data.data.id}/detail?tab=2`) - } - }) - } - //添加单选题目 - addmysingles = () => { - - if (this.state.newoption === true) { - this.setState({ - newoption: false - }) - } - - var Insertposition = this.state.poll_questions.length; - // console.log(JSON.stringify(this.state.poll_questions)); - for (var i = 0; i < this.state.poll_questions.length; i++) { - if (this.state.poll_questions[i].question.question_type === 1) { - Insertposition = i; - } - - } - this.addMytopic(1, this.state.pollid, Insertposition, false, 0); - // } - } - - //添加多选题目 - addmydoubles = () => { - console.log("addmymainsint 70") - if (this.state.newoption === true) { - this.setState({ - newoption: false - }) - } - - var Insertposition = this.state.poll_questions.length; - // console.log(JSON.stringify(this.state.poll_questions)); - for (var i = 0; i < this.state.poll_questions.length; i++) { - if (this.state.poll_questions[i].question.question_type === 2) { - Insertposition = i; - } - - - } - this.addMytopic(2, this.state.pollid, Insertposition, false, 0); - - // } - } - - //添加主观题目 - addmymainsint = () => { - - var Insertposition = this.state.poll_questions.length; - // console.log(JSON.stringify(this.state.poll_questions)); - for (var i = 0; i < this.state.poll_questions.length; i++) { - if (this.state.poll_questions[i].question.question_type === 3) { - Insertposition = i; - } - - - } - - this.addMytopic(3, this.state.pollid, Insertposition, false, 0); - // } - } - - //编辑方法 - adddomedit = (object) => { - console.log("adddomedit 76"); - if (this.state.q_countst > 0) { - this.props.showNotification(`不能同时编辑两题`); - - return; - } - var anserbool = false; - this.setState({ - q_countst: 1, - }) - window.scrollTo(0, this.refs.targetElement.offsetTop) - let {adddom} = this.state; - // var arr =new Object(objects); - // console.log(arr) - // adddom.push(arr); - var question = {}; - var Insertposition = this.state.poll_questions.length; - if (object.question.question_type === 1) { - var answers = []; - var questiontwo = {}; - ///////////////////////////daying - for (var y = 0; y < object.question.answers.length; y++) { - var answerstwo; - if (object.question.answers[y].answer_text === "其他") { - answerstwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - anserbool = true; - } else { - answerstwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - } - answers.push(answerstwo); - - - } - // 插入单选题 - questiontwo = { - // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, - "id": object.question.id, - "is_necessary": object.question.is_necessary, - "question_number": 1, - "question_title": object.question.question_title, - "question_type": 1, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - adddom.push(question); - for (var i = 0; i < this.state.poll_questions.length; i++) { - if (this.state.poll_questions[i].question.question_type === 1) { - Insertposition = i; - } - } - } else if (object.question.question_type === 2) { - //插入多选题 - var answers = []; - var questiontwo = {}; - - for (var y = 0; y < object.question.answers.length; y++) { - if (object.question.answers[y].answer_text === "其他") { - answerstwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - anserbool = true; - } else { - answerstwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - } - answers.push(answerstwo); - } - questiontwo = { - "id": object.question.id, - "is_necessary": object.question.is_necessary, - "question_number": 2, - "question_title": object.question.question_title, - "question_type": 2, - "max_choices": object.question.max_choices, - "min_choices": object.question.min_choices, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - adddom.push(question); - for (var i = 0; i < this.state.poll_questions.length; i++) { - if (this.state.poll_questions[i].question.question_type === 2) { - Insertposition = i; - } - } - } else if (object.question.question_type === 3) { - //插入主观题 - var answers = []; - var questiontwo = {}; - - if (object.question.answers.length > 0) { - for (var y = 0; y < object.question.answers.length; y++) { - var answerstwo; - if (object.question.answers[y].answer_text === "其他") { - answerstwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - } else { - answerstwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - } - answers.push(answerstwo); - } - } - questiontwo = { - "id": object.question.id, - "is_necessary": object.question.is_necessary, - "question_number": 3, - "question_title": object.question.question_title, - "question_type": 3, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - adddom.push(question); - for (var i = 0; i < this.state.poll_questions.length; i++) { - if (this.state.poll_questions[i].question.question_type === 3) { - Insertposition = i; - } - } - } - this.setState({ - adddom: adddom, - newoption: anserbool, - Insertposition: Insertposition - }) - - } - - //新增添加题目 有new - addMytopic = (index, pollid, Insertposition, Whether, id) => { - //Whether 是否插入 - // console.log("id") - // console.log(id) - // console.log("Whether") - // console.log(Whether) - console.log("addMytopic 90") - if (this.state.q_countst > 0) { - this.props.showNotification(`不能同时编辑两题`); - - return; - } - this.state.Insertposition = Insertposition; - var Whethername = null; - if (Whether === true) { - Whethername = id; - } - this.setState({ - Insertposition: Insertposition, - q_countst: 1, - }) - window.scrollTo(0, this.refs.targetElement.offsetTop) - var arrr = this.state.adddom; - let newarrr = [...arrr]; - - var arr = this.state.poll_questions; - let newarr = [...arr]; - - if (newarr.length > 0) { - if (index === 1) { - // 插入单选题 - // console.log(this.state.poll_questions[newarr.length - 1].question.id); - var question = {} - var questiontwo = { - // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, - "id": this.state.poll_questions[newarr.length - 1].question.id + 1, - "is_necessary": 1, - "question_number": 1, - "question_title": "", - "question_type": 1, - "new": "new", - "answers": [ - {"answer_id": 1, "answer_position": 1, "answer_text": ""}, - {"answer_id": 2, "answer_position": 2, "answer_text": ""}, - {"answer_id": 3, "answer_position": 3, "answer_text": ""}, - {"answer_id": 4, "answer_position": 4, "answer_text": ""}, - // {"answer_id": 5, "answer_position": 5, "answer_text": "其他"}, - ] - }; - question = {"question": questiontwo}; - newarrr.push(question); - - this.setState({ - adddom: newarrr, - problemtopic: Whethername, - problemtopicbool: Whether, - }) - - } else if (index === 2) { - //插入多选题 - var question = {} - var questiontwo = { - "id": this.state.poll_questions[newarr.length - 1].question.id + 1, - "is_necessary": 1, - "question_number": 2, - "question_title": "", - "question_type": 2, - "max_choices": 0, - "min_choices": 0, - "new": "new", - "answers": [ - {"answer_id": 1, "answer_position": 1, "answer_text": ""}, - {"answer_id": 2, "answer_position": 2, "answer_text": ""}, - {"answer_id": 3, "answer_position": 3, "answer_text": ""}, - {"answer_id": 4, "answer_position": 4, "answer_text": ""}, - // {"answer_id": 5, "answer_position": 5, "answer_text": "其他"}, - ] - }; - question = {"question": questiontwo}; - newarrr.push(question); - - this.setState({ - adddom: newarrr, - problemtopic: Whethername, - problemtopicbool: Whether, - }) - - } else if (index === 3) { - //插入主观题 - // console.log(this.state.poll_questions[newarr.length - 1].question.id); - var question = {} - var questiontwo = { - "id": this.state.poll_questions[newarr.length - 1].question.id + 1, - "is_necessary": 1, - "question_number": 3, - "question_title": "", - "question_type": 3, - "new": "new", - "answers": [] - }; - question = {"question": questiontwo}; - newarrr.push(question); - this.setState({ - adddom: newarrr, - problemtopic: Whethername, - problemtopicbool: Whether, - }) - - } - } else { - /////上面视图全部删除后 要加载的 - if (index === 1) { - // 插入单选题 - var id; - try { - id = this.state.poll_questions[newarr.length - 1].question.id + 1 - } catch (e) { - id = 1; - } - var questiontwo = { - // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, - "id": id, - "is_necessary": 1, - "question_number": 1, - "question_title": "", - "question_type": 1, - "new": "new", - "answers": [ - {"answer_id": 1, "answer_position": 1, "answer_text": ""}, - {"answer_id": 2, "answer_position": 2, "answer_text": ""}, - {"answer_id": 3, "answer_position": 3, "answer_text": ""}, - {"answer_id": 4, "answer_position": 4, "answer_text": ""}, - // {"answer_id": 5, "answer_position": 5, "answer_text": "其他"}, - ] - }; - question = {"question": questiontwo}; - newarrr.push(question); - - this.setState({ - adddom: newarrr, - problemtopic: Whethername, - problemtopicbool: Whether, - }) - - } else if (index === 2) { - //插入多选题 - var id; - try { - id = this.state.poll_questions[newarr.length - 1].question.id + 1 - } catch (e) { - id = 1; - } - var questiontwo = { - "id": id, - "is_necessary": 1, - "question_number": 2, - "question_title": "", - "question_type": 2, - "max_choices": 0, - "min_choices": 0, - "new": "new", - "answers": [ - {"answer_id": 1, "answer_position": 1, "answer_text": ""}, - {"answer_id": 2, "answer_position": 2, "answer_text": ""}, - {"answer_id": 3, "answer_position": 3, "answer_text": ""}, - {"answer_id": 4, "answer_position": 4, "answer_text": ""}, - // {"answer_id": 5, "answer_position": 5, "answer_text": "其他"}, - ] - }; - question = {"question": questiontwo}; - newarrr.push(question); - - this.setState({ - adddom: newarrr, - problemtopic: Whethername, - problemtopicbool: Whether, - }) - - } else if (index === 3) { - //插入主观题 - var id; - try { - id = this.state.poll_questions[newarr.length - 1].question.id + 1 - } catch (e) { - id = 1; - } - var questiontwo = { - "id": id, - "is_necessary": 1, - "question_number": 3, - "question_title": "", - "question_type": 3, - "new": "new", - "answers": [] - }; - question = {"question": questiontwo}; - newarrr.push(question); - this.setState({ - adddom: newarrr, - problemtopic: Whethername, - problemtopicbool: Whether, - }) - } - } - } - - //删除指定条目 - deleteadddom = (indexo) => { - console.log("deleteadddom 259") - var arr = this.state.adddom; - let newarr = [...arr]; - - newarr.splice(indexo, 1); - this.setState({ - adddom: newarr, - q_countst: 0, - problemtopic: null, - problemtopicbool: false, - }) - } - //保存并继续 - //保存并继续,即提交本题的新建并继续创建一个相同的题(该新题处于编辑模式,题目和选项不要清空) - deleteadddomtwo = (indexo, object) => { - var thiss = this; - this.setState({ - q_countst: 1, - }) - var poll_questionslength = this.state.poll_questions.length; - // console.log("deleteadddomtwo|||||||||||||||||||||||||||||||||||||||||\\"); - // console.log(indexo); - // console.log(object); - // console.log(object.question.question_type); - let arr = this.state.adddom; - let arrpoll = this.state.poll_questions; - let newarr = [...arr]; - let newarrpoll = [...arrpoll]; - - //选项内容不能为空 - let max = 0; - let maxtie = newarr[indexo].question.answers.length; - for (var k = 0; k < newarr[indexo].question.answers.length; k++) { - try { - if (newarr[indexo].question.answers[k].answer_text != undefined) { - if (newarr[indexo].question.answers[k].answer_text === "") { - max = max + 1; - } - } - } catch (e) { - console.log("PollNew281") - console.log(e) - } - } - if (newarr[indexo].question.question_title === "") { - this.props.showNotification(`题目不能为空`); - - return - } - if (max > 0) { - if (object.question.question_type === 1) { - this.props.showNotification(`选项内容不能为空`); - - return - } else if (object.question.question_type === 2) { - this.props.showNotification(`选项内容不能为空`); - - return - } - - } - if (maxtie < 2) { - if (object.question.question_type === 1) { - this.props.showNotification(`选项不能少于2个!`); - - return - } else if (object.question.question_type === 2) { - this.props.showNotification(`选项不能少于2个!`); - - return - } - - - } - - if (object.question.question_type === 2) { - if (object.question.max_choices > 0) { - if (object.question.min_choices < 2) { - this.props.showNotification(`可选最小不能少于2个`); - - return; - - } - } - - } - if (object.question.new === "new") { - // 根据数组里面的new 来确定是否是新增还是 修改 - //添加道数组上 - //不能共用数组 所以自己写个新数组 然后push 上面卷子中 - var question = {}; - if (object.question.question_type === 1) { - - var questiontwo = {}; - var other = []; - var option = []; - var answerstwos = []; - var answerstwoss = []; - ///////////////////////////daying - // 这个是装选项和其他的 - for (var y = 0; y < object.question.answers.length; y++) { - if (object.question.answers[y].answer_text === "其他") { - var dataone = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - other.push(object.question.answers[y].answer_text); - answerstwos.push(dataone); - } else { - var datatwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - option.push(object.question.answers[y].answer_text) - answerstwoss.push(datatwo); - } - - - } - - var arrc = option.concat(other); - var answers = answerstwoss.concat(answerstwos); - // 插入单选题 - // var id - // try { - // id = newarrpoll[newarrpoll.length - 1].question.id + 1; - // } catch (e) { - // id = 1; - // } - questiontwo = { - // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, - "id": null, - "is_necessary": object.question.is_necessary, - "question_number": 1, - "question_title": object.question.question_title, - "question_type": 1, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - var insindex = null; - // if (poll_questionslength !== thiss.state.Insertposition) { - // insindex = newarrpoll[thiss.state.Insertposition].question.id; - // } - if (this.state.problemtopicbool === true) { - insindex = this.state.problemtopic; - } - this.createquestionsandanswers(object, 1, arrc, null, 0, 0, insindex); - // newarrpoll.push(question); - newarrpoll.splice(thiss.state.Insertposition, 0, question); - - } else if (object.question.question_type === 2) { - //插入多选题 - if (object.question.max_choices < object.question.min_choices) { - this.props.showNotification(`可选的最大限制不能小于最小限制`); - - return; - } - - var questiontwo = {}; - var other = []; - var option = []; - var answerstwos = []; - var answerstwoss = []; - for (var y = 0; y < object.question.answers.length; y++) { - if (object.question.answers[y].answer_text === "其他") { - var dataone = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - other.push(object.question.answers[y].answer_text); - answerstwos.push(dataone); - } else { - var datatwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - option.push(object.question.answers[y].answer_text) - answerstwoss.push(datatwo); - } - } - var arrc = option.concat(other); - var answers = answerstwoss.concat(answerstwos); - // var id - // try { - // id = newarrpoll[newarrpoll.length - 1].question.id + 1; - // } catch (e) { - // id = 1; - // } - questiontwo = { - "id": null, - "is_necessary": object.question.is_necessary, - "question_number": 2, - "question_title": object.question.question_title, - "question_type": 2, - "max_choices": object.question.max_choices, - "min_choices": object.question.min_choices, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - var insindex = null; - if (this.state.problemtopicbool === true) { - insindex = this.state.problemtopic; - } - this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, insindex); - //插入多选题 - // if (object.question.max_choices > arrc.length) { - // // console.log("选择题的最大可选项不能大于选项数") - // this.props.showNotification(`选择题的最大可选项不能大于选项数`); - // - // return; - // } - // if (object.question.min_choices === 0) { - // // console.log("选择题的最大可选项不能小于2项目") - // this.props.showNotification(`选择题的最大可选项不能小于2项目`); - // - // return; - // - // } - // newarrpoll.push(question); - newarrpoll.splice(thiss.state.Insertposition, 0, question); - } else if (object.question.question_type === 3) { - //插入主观题 - var answers = []; - var questiontwo = {}; - var answerstwos = []; - var answerstwoss = []; - if (object.question.answers.length > 0) { - for (var y = 0; y < object.question.answers.length; y++) { - var answerstwo; - if (object.question.answers[y].answer_text === "其他") { - var dataone = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - answerstwos.push(dataone); - } else { - var datatwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - answerstwoss.push(datatwo); - } - } - } - - answers = answerstwoss.concat(answerstwos); - // var id - // try { - // id = newarrpoll[newarrpoll.length - 1].question.id + 1; - // } catch (e) { - // id = 1; - // } - questiontwo = { - "id": null, - "is_necessary": object.question.is_necessary, - "question_number": 3, - "question_title": object.question.question_title, - "question_type": 3, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - // var insindex = null; - // if (poll_questionslength !== thiss.state.Insertposition) { - // insindex = newarrpoll[thiss.state.Insertposition].question.id; - // } - //主观题不需要可选选项 - var insindex = null; - if (this.state.problemtopicbool === true) { - insindex = this.state.problemtopic; - } - this.createquestionsandanswers(object, 3, null, null, 0, 0, insindex); - // newarrpoll.push(question); - newarrpoll.splice(thiss.state.Insertposition, 0, question); - } - //////////////////////////////////////////////////////////////////////////////////////////////////// 上面是新增 - } else { - ///////////////////////////////////////////////////////////////////////////////////////////////////修改点了编辑 - console.log("点了编辑") - var uuk = -1 - //这个地方判断 点了编辑上面题目又把他删除了 保存的时候就只能是插入新增了 - for (var uk = 0; uk < newarrpoll.length; uk++) { - if (object.question.id === newarrpoll[uk].question.id) { - uuk = uk; - } - } - - - var question = {}; - if (object.question.question_type === 1) { - var questiontwo = {}; - var other = []; - var option = []; - var answerstwos = []; - var answerstwoss = []; - ///////////////////////////daying - //这个装选项和其他的 - for (var y = 0; y < object.question.answers.length; y++) { - if (object.question.answers[y].answer_text === "其他") { - var dataone = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - other.push(object.question.answers[y].answer_text); - answerstwos.push(dataone); - } else { - var datatwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - option.push(object.question.answers[y].answer_text) - answerstwoss.push(datatwo); - } - - - } - var arrc = option.concat(other); - var answers = answerstwoss.concat(answerstwos); - // 插入单选题 - questiontwo = { - // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, - "id": object.question.id, - "is_necessary": object.question.is_necessary, - "question_number": 1, - "question_title": object.question.question_title, - "question_type": 1, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - if (uuk !== -1) { - // console.log("修改") - this.edittotheserver(object, 1, arrc, null, 0, 0); - newarrpoll.splice(uuk, 1, question); - } else { - // console.log("他原来的删除掉了") - this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id); - newarrpoll.push(question); - } - newarr[indexo].question.new = "new" - // console.log(newarrpoll) - } else if (object.question.question_type === 2) { - //插入多选题 - - if (object.question.max_choices < object.question.min_choices) { - this.props.showNotification('可选的最大限制不能小于最小限制!'); - - return; - } - var questiontwo = {}; - var other = []; - var option = []; - var answerstwos = []; - var answerstwoss = []; - for (var y = 0; y < object.question.answers.length; y++) { - if (object.question.answers[y].answer_text === "其他") { - var dataone = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - other.push(object.question.answers[y].answer_text); - answerstwos.push(dataone); - } else { - var datatwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - option.push(object.question.answers[y].answer_text) - answerstwoss.push(datatwo); - } - } - var arrc = option.concat(other); - var answers = answerstwoss.concat(answerstwos); - questiontwo = { - "id": object.question.id, - "is_necessary": object.question.is_necessary, - "question_number": 2, - "question_title": object.question.question_title, - "question_type": 2, - "max_choices": object.question.max_choices, - "min_choices": object.question.min_choices, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - //插入多选题 - // if (object.question.max_choices > arrc.length) { - // // console.log("选择题的最大可选项不能大于答案数") - // this.props.showNotification('选择题的最大可选项不能大于选项数!'); - // - // return; - // } - // if (object.question.min_choices === 0) { - // // console.log("选择题的最大可选项不能小于2项目") - // this.props.showNotification('选择题的最大可选项不能小于2项目!'); - // - // return; - // - // } - if (uuk !== -1) { - console.log("修改") - this.edittotheserver(object, 2, arrc, null, object.question.max_choices, object.question.min_choices); - newarrpoll.splice(uuk, 1, question); - } else { - console.log("删除") - this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, object.question.id); - newarrpoll.push(question); - } - console.log(newarrpoll) - newarr[indexo].question.new = "new" - } else if (object.question.question_type === 3) { - //插入主观题 - var answers = []; - var questiontwo = {}; - - if (object.question.answers.length > 0) { - for (var y = 0; y < object.question.answers.length; y++) { - var answerstwo; - if (object.question.answers[y].answer_text === "其他") { - answerstwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - } else { - answerstwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - } - answers.push(answerstwo); - } - } - questiontwo = { - "id": object.question.id, - "is_necessary": object.question.is_necessary, - "question_number": 3, - "question_title": object.question.question_title, - "question_type": 3, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - - if (uuk !== -1) { - console.log("修改") - this.edittotheserver(object, 3, null, null, 0, 0); - newarrpoll.splice(uuk, 1, question); - } else { - console.log("删除") - this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id); - newarrpoll.push(question); - } - console.log(newarrpoll) - newarr[indexo].question.new = "new" - } - - } - - - //添加到上面列表中 - //改变题目总数 - if (object.question.question_type === 1) { - //单选题 - this.state.mysingles = this.state.mysingles + 1; - } else if (object.question.question_type === 2) { - //多选题 - this.state.mydoubles = this.state.mydoubles + 1; - } else if (object.question.question_type === 3) { - //主观题 - this.state.mymainsint = this.state.mymainsint + 1; - - } - this.setState({ - // poll_questions: newarrpoll, - adddom: newarr, - problemtopic: null, - problemtopicbool: false, - // mysingles: this.state.mysingles, - // mydoubles: this.state.mydoubles, - // mymainsint: this.state.mymainsint - }) - - } - - - //保存 后期可以考虑和保存并继续 合并 - //保存,即完成新建并退出本题编辑 - // indexo 第几个数组 - //object 单个数组数据 - deleteadddomthree = (indexo, object) => { - // console.log("deleteadddom 349") - var thiss = this; - let arr = this.state.adddom; - let arrpoll = this.state.poll_questions; - let newarr = [...arr]; - let newarrpoll = [...arrpoll]; - var poll_questionslength = this.state.poll_questions.length; //获取单前问题最大长度 - //选项内容不能为空 - let max = 0; - let maxtie = newarr[indexo].question.answers.length; - //判断选项值是否不为空 - for (var k = 0; k < newarr[indexo].question.answers.length; k++) { - try { - if (newarr[indexo].question.answers[k].answer_text != undefined) { - if (newarr[indexo].question.answers[k].answer_text === "") { - max = max + 1; - } - } - } catch (e) { - // console.log("PollNew281") - // console.log(e) - } - } - if (newarr[indexo].question.question_title === "") { - this.props.showNotification('题目不能为空!'); - return - } - if (max > 0) { - if (object.question.question_type === 1) { - this.props.showNotification('选项内容不能为空!'); - return - } else if (object.question.question_type === 2) { - this.props.showNotification('选项内容不能为空!'); - return - } - - } - if (maxtie < 2) { - if (object.question.question_type === 1) { - this.props.showNotification('选项不能少于2个!'); - return - } else if (object.question.question_type === 2) { - this.props.showNotification('选项不能少于2个!'); - return - } - - - } - - if (object.question.question_type === 2) { - if (object.question.max_choices > 0) { - if (object.question.min_choices < 2) { - this.props.showNotification(`可选最小不能少于2个`); - return; - } - } - } - if (object.question.new === "new") { - ///////////////////////////////////////////////////////////////////新增模式 - // 根据数组里面的new 来确定是否是新增还是 修改 - //添加道数组上 - //不能共用数组 所以自己写个新数组 然后push 上面卷子中 - var question = {}; - if (object.question.question_type === 1) { - var questiontwo = {}; - var other = []; - var option = []; - var answerstwos = []; - var answerstwoss = []; - ///////////////////////////daying - // 这个是装选项和其他的 - for (var y = 0; y < object.question.answers.length; y++) { - if (object.question.answers[y].answer_text === "其他") { - var dataone = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - other.push(object.question.answers[y].answer_text); - answerstwos.push(dataone); - } else { - var datatwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - option.push(object.question.answers[y].answer_text) - answerstwoss.push(datatwo); - } - } - var arrc = option.concat(other); - var answers = answerstwoss.concat(answerstwos); - // 插入单选题' - // var id; - // try { - // id = newarrpoll[newarrpoll.length - 1].question.id + 1 - // } catch (e) { - // id = 1; - // } - questiontwo = { - // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, - "id": null, - "is_necessary": object.question.is_necessary, - "question_number": 1, - "question_title": object.question.question_title, - "question_type": 1, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - //获取指定id 号 用来插入,如果不是就是在最后添加 - - //执行新增操作 - var insindex = null; - if (this.state.problemtopicbool === true) { - insindex = this.state.problemtopic; - } - this.createquestionsandanswers(object, 1, arrc, null, 0, 0, insindex); - newarrpoll.splice(thiss.state.Insertposition, 0, question); - } else if (object.question.question_type === 2) { - //插入多选题 - if (object.question.max_choices < object.question.min_choices) { - this.props.showNotification(`可选的最大限制不能小于最小限制`); - - return; - } - - var questiontwo = {}; - var other = []; - var option = []; - var answerstwos = []; - var answerstwoss = []; - for (var y = 0; y < object.question.answers.length; y++) { - if (object.question.answers[y].answer_text === "其他") { - var dataone = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - other.push(object.question.answers[y].answer_text); - answerstwos.push(dataone); - } else { - var datatwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - option.push(object.question.answers[y].answer_text) - answerstwoss.push(datatwo); - } - } - var arrc = option.concat(other); - var answers = answerstwoss.concat(answerstwos); - - questiontwo = { - "id": null, - "is_necessary": object.question.is_necessary, - "question_number": 2, - "question_title": object.question.question_title, - "question_type": 2, - "max_choices": object.question.max_choices, - "min_choices": object.question.min_choices, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - - var insindex = null; - if (this.state.problemtopicbool === true) { - insindex = this.state.problemtopic; - } - this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, insindex); - //插入多选题 - // if (object.question.max_choices > arrc.length) { - - newarrpoll.splice(thiss.state.Insertposition, 0, question); - } else if (object.question.question_type === 3) { - //插入主观题 - var answers = []; - var questiontwo = {}; - var answerstwos = []; - var answerstwoss = []; - if (object.question.answers.length > 0) { - for (var y = 0; y < object.question.answers.length; y++) { - if (object.question.answers[y].answer_text === "其他") { - var dataone = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - answerstwos.push(dataone); - } else { - var datatwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - answerstwoss.push(datatwo); - } - } - } - answers = answerstwoss.concat(answerstwos); - - questiontwo = { - "id": null, - "is_necessary": object.question.is_necessary, - "question_number": 3, - "question_title": object.question.question_title, - "question_type": 3, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - //主观题不需要可选选项 - - var insindex = null; - if (this.state.problemtopicbool === true) { - insindex = this.state.problemtopic; - } - this.createquestionsandanswers(object, 3, null, null, 0, 0, insindex); - // newarrpoll.push(question); - newarrpoll.splice(thiss.state.Insertposition, 0, question); - } - ///////////////////////////////////////////////////////////////////新增模式 - } else { - //////////////////////////////////////////////////////////////////////////////修改模式 - //修改 - var uuk = -1 - for (var uk = 0; uk < newarrpoll.length; uk++) { - if (object.question.id === newarrpoll[uk].question.id) { - uuk = uk; - console.log("删除了数据=-09876543234567890-111111111111") - } - } - - - var question = {}; - if (object.question.question_type === 1) { - var questiontwo = {}; - var other = []; - var option = []; - var answerstwos = []; - var answerstwoss = []; - ///////////////////////////daying - //这个装选项和其他的 - for (var y = 0; y < object.question.answers.length; y++) { - if (object.question.answers[y].answer_text === "其他") { - var dataone = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - other.push(object.question.answers[y].answer_text); - answerstwos.push(dataone); - } else { - var datatwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - option.push(object.question.answers[y].answer_text) - answerstwoss.push(datatwo); - } - } - var arrc = option.concat(other); - var answers = answerstwoss.concat(answerstwos); - // 插入单选题 - questiontwo = { - // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, - "id": object.question.id, - "is_necessary": object.question.is_necessary, - "question_number": 1, - "question_title": object.question.question_title, - "question_type": 1, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - if (uuk !== -1) { - console.log("修改") - this.edittotheserver(object, 1, arrc, null, 0, 0); - newarrpoll.splice(uuk, 1, question); - } else { - console.log("删除") - this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id); - newarrpoll.push(question); - } - console.log(newarrpoll) - } else if (object.question.question_type === 2) { - //插入多选题 - if (object.question.max_choices < object.question.min_choices) { - this.props.showNotification(`可选的最大限制不能小于最小限制`); - - return; - } - var questiontwo = {}; - var other = []; - var option = []; - var answerstwos = []; - var answerstwoss = []; - for (var y = 0; y < object.question.answers.length; y++) { - if (object.question.answers[y].answer_text === "其他") { - var dataone = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - other.push(object.question.answers[y].answer_text); - answerstwos.push(dataone); - } else { - var datatwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - option.push(object.question.answers[y].answer_text) - answerstwoss.push(datatwo); - } - } - var arrc = option.concat(other); - var answers = answerstwoss.concat(answerstwos); - questiontwo = { - "id": object.question.id, - "is_necessary": object.question.is_necessary, - "question_number": 2, - "question_title": object.question.question_title, - "question_type": 2, - "max_choices": object.question.max_choices, - "min_choices": object.question.min_choices, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - //插入多选题 - if (uuk !== -1) { - console.log("修改") - this.edittotheserver(object, 2, arrc, null, object.question.max_choices, object.question.min_choices); - newarrpoll.splice(uuk, 1, question); - } else { - console.log("删除") - this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, object.question.id); - newarrpoll.push(question); - } - console.log(newarrpoll) - - } else if (object.question.question_type === 3) { - //插入主观题 - var answers = []; - var questiontwo = {}; - - if (object.question.answers.length > 0) { - for (var y = 0; y < object.question.answers.length; y++) { - var answerstwo; - if (object.question.answers[y].answer_text === "其他") { - answerstwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - } else { - answerstwo = { - "answer_id": object.question.answers[y].answer_id, - "answer_position": object.question.answers[y].answer_position, - "answer_text": object.question.answers[y].answer_text - } - } - answers.push(answerstwo); - } - } - questiontwo = { - "id": object.question.id, - "is_necessary": object.question.is_necessary, - "question_number": 3, - "question_title": object.question.question_title, - "question_type": 3, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - if (uuk !== -1) { - console.log("修改") - this.edittotheserver(object, 3, null, null, 0, 0); - newarrpoll.splice(uuk, 1, question); - } else { - console.log("删除") - this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id); - newarrpoll.push(question); - } - console.log(newarrpoll) - - } - - } - - - //添加到上面列表中 - //改变题目总数 - if (object.question.question_type === 1) { - //单选题 - this.state.mysingles = this.state.mysingles + 1; - } else if (object.question.question_type === 2) { - //多选题 - this.state.mydoubles = this.state.mydoubles + 1; - } else if (object.question.question_type === 3) { - //主观题 - this.state.mymainsint = this.state.mymainsint + 1; - - } - - //这里更新数据 - if (this.state.q_countst == 1) { - this.setState({ - q_countst: 0, - }) - } - this.deleteadddom(indexo); - // console.log(indexo) - } - - - ////新增到服务器中 - createquestionsandanswers = (object, number, option, other, max_choices, min_choices, insert_id) => { - var thiss = this; - var poll_id = this.state.pollid; - var urlly = `/polls/${poll_id}/poll_questions.json` - var max_choicess = null; - var min_choicess = null; - if (max_choices === 0 && min_choices === 0) { - max_choicess = null; - min_choicess = null; - } else { - max_choicess = max_choices; - min_choicess = min_choices; - } - axios.post(urlly, { - question_title: object.question.question_title, - question_type: number, - is_necessary: object.question.is_necessary, - max_choices: max_choicess, - min_choices: min_choicess, - question_answers: option, - question_other_answer: null, - insert_id: insert_id - }).then((result) => { - // try { - if (result !== undefined) { - if (result.data.status === 0) { - this.props.showNotification(`已完成`); - thiss.thisinitializationdatanew(); - // console.log("确认创建问题") - // console.log(result) - // try { - // if (result.data.status === 0) { - // console.log("确认创建问题") - // console.log(JSON.stringify(result.data)) - // } - // } catch (e) { - // - // } - } - } - // } catch (e) { - // - // } - - }) - - - } - ///编辑修改到服务器当中 - edittotheserver = (object, number, option, other, max_choices, min_choices) => { - console.log("调用了edittotheserver") - var url = `/poll_questions/${object.question.id}.json` - var thiss = this; - axios.put(url, { - // debug: true, - question_title: object.question.question_title, - question_type: number, - is_necessary: object.question.is_necessary, - max_choices: max_choices, - min_choices: min_choices, - question_answers: option, - question_other_answer: null, - }).then((result) => { - try { - if (result.data.status === 0) { - this.props.showNotification(`编辑题目成功`); - thiss.thisinitializationdatanew(); - } - } catch (e) { - // console.log("调用了edittotheserver") - console.log(e) - } - }) - } - - //删除到服务器当中 - eletetoserver = (pollid, newarr, type, index) => { - console.log("调用了eletetoserver") - var id = pollid; - var url = `/poll_questions/${id}.json` - let {mysingles, mydoubles, mymainsint} = this.state - var thiss = this; - - axios - .delete(url, {}) - .then(function (response) { - console.log(response) - if (response === undefined) { - return; - } - if (response.data.message === "删除成功") { - thiss.props.showNotification(`删除成功`); - - newarr.splice(index, 1); - if (type === 1) { - mysingles = mysingles - 1; - } else if (type === 2) { - mydoubles = mydoubles - 1; - - } else if (type === 3) { - mymainsint = mymainsint - 1; - - } - // thiss.setState({ - // poll_questions: newarr, - // mysingles: mysingles, - // mydoubles: mydoubles, - // mymainsint: mymainsint - // }); - thiss.thisinitializationdatanew(); - } - }) - } - - //上移到服务器中 - Upanddownmovementof = (bool, poll_question_id) => { - // console.log("调用了Upanddownmovementofr") - // console.log(poll_question_id) - var thiss = this; - if (bool === true) { - var url = `/poll_questions/${poll_question_id}/up_down.json`; - 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) - } - - }) - } 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) - } - }) - } - - } - - //删除编辑新增条目 - //id 条目的唯一id - //i 为要删除的子条目 - deleteentrys = (id, i, stirngname) => { - console.log(id) - console.log(stirngname); - var arrtwoy = this.state.adddom; - let newarrtwoy = [...arrtwoy]; - for (var k = 0; k < newarrtwoy.length; k++) { - if (newarrtwoy[k] != undefined) { - if (newarrtwoy[k].question.id === id) { - for (var c = 0; c < newarrtwoy[k].question.answers.length; c++) { - if (c === i) { - // console.log("删除了") - // console.log(c) - newarrtwoy[k].question.answers.splice(c, 1); - } - } - } - } - } - if (stirngname === true) { - console.log(stirngname); - this.setState({ - newoption: false, - adddom: newarrtwoy, - - }) - } else { - console.log(stirngname); - this.setState({ - adddom: newarrtwoy, - }); - } - - - } - - - // 新增选项 - ewoption = (id, object) => { - console.log("ewoption 440") - console.log("是否是新建题目还是编辑") - // console.log(object.question.new) - - - let arrtwo = this.state.adddom; - let newarrtwo = [...arrtwo]; - - - for (var k = 0; k < newarrtwo.length; k++) { - // console.log(arrtwo[k].question.id); - if (newarrtwo[k] != undefined) { - if (newarrtwo[k].question.id === id) { - var data = { - "answer_id": newarrtwo[k].question.answers.length + 1, - "answer_position": newarrtwo[k].question.answers.length + 1, - "answer_text": "" - }; - //向头部添加元素 - // newarrtwo[k].question.answers.unshift(data); - //如果有其他这一项就删除掉 - if (newarrtwo[k].question.answers.length > 0) { - for (var o = 0; o < newarrtwo[k].question.answers.length; o++) { - if (newarrtwo[k].question.answers[o].answer_text != undefined) { - if (newarrtwo[k].question.answers[o].answer_text === "其他") { - newarrtwo[k].question.answers.splice(o, 0, data); - this.setState({ - adddom: newarrtwo - }) - return - } else { - if (o === newarrtwo[k].question.answers.length - 1) { - newarrtwo[k].question.answers.push(data); - this.setState({ - adddom: newarrtwo - }) - return - } - } - } - } - } else { - newarrtwo[k].question.answers.push(data); - this.setState({ - adddom: newarrtwo - }) - } - - } - } - } - - } - - - swapArray = (arr, index1, index2) => { - arr[index1] = arr.splice(index2, 1, arr[index1])[0]; - return arr; - } - - //新增其他选项 - addanotheroption = (id) => { - console.log("addanotheroption 457") - let arrtwo = this.state.adddom; - let newarrtwo = [...arrtwo]; - console.log(newarrtwo) - for (var k = 0; k < newarrtwo.length; k++) { - if (newarrtwo[k] != undefined) { - if (newarrtwo[k].question.id === id) { - var data = { - "answer_id": newarrtwo[k].question.answers.length + 1, - "answer_position": newarrtwo[k].question.answers.length + 1, - "answer_text": "其他" - }; - newarrtwo[k].question.answers.push(data); - } - } - } - this.setState({ - adddom: newarrtwo, - newoption: true, - }) - } - - - //点击向上排序按钮事件 - handleClickBySortUp = (index, object) => { - console.log("handleClickBySortUp 521") - 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, - }); - } - } - - //点击向下排序按钮事件 - handleClickBySortDown = (index, object) => { - console.log("handleClickBySortDown 536") - let arr = this.state.poll_questions; - let newarr = [...arr]; - // - 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, - }); - } else { - console.log("2222index==arr.length"); - console.log(this.state.poll_questions); - } - } - - //点击删除按钮事件 - handleClickByDelete = (type, index, object) => { - console.log("handleClickByDelete 556") - console.log("object.question.id") - console.log(object.question.id) - let arr = this.state.poll_questions; - let newarr = [...arr]; - this.eletetoserver(object.question.id, newarr, type, index) - - } - - // 数字输入监听 - //e为获取组件对象 - //i外层数组 - //k为内层数组 - handleInputChanges = (e, i, k) => { - console.log("handleInputChanges 612") - - let value = e.target.value;//取到input的数据 - console.log("handleInputChanges value is :" + value); - console.log(k); - let arr = this.state.adddom; - let newarr = [...arr]; - - newarr[i].question.answers[k].answer_text = value - this.setState({ - adddom: newarr - }) - - } - - //标题输入监听 - handleInputTopic = (e, i) => { - console.log("handleInputTopic 633") - - let value = e.target.value;//取到input的数据 - console.log("handleInputTopic value is :" + value); - console.log(i); - let arr = this.state.adddom; - let newarr = [...arr]; - newarr[i].question.question_title = value - this.setState({ - adddom: newarr - }) - } - - //最小值 - handleGradationGroupChangee = (value, index, max, length) => { - - debugger - var minbool = false; - var maxbool = false; - let arr = this.state.adddom; - if (parseInt(value) === 0 || parseInt(value) === "0" || parseInt(value) === null || parseInt(value) === undefined || parseInt(value) < 1) { - minbool = true; - } - if (max === 0 || max === "0" || max === null || max === undefined) { - maxbool = true; - } - - if (minbool === true && maxbool === true) { - for (var i = 0; i < arr.length; i++) { - if (index === i) { - arr[i].question.min_choices = parseInt(value); - } - } - this.setState({ - adddom: arr - }) - } else { - for (var i = 0; i < arr.length; i++) { - if (index === i) { - arr[i].question.min_choices = parseInt(value); - arr[i].question.max_choices = length; - } - } - this.setState({ - adddom: arr - }) - } - - } - - //最大值 - handleGradationGroupChangeee = (value, index) => { - - let arr = this.state.adddom; - for (var i = 0; i < arr.length; i++) { - if (index === i) { - arr[i].question.max_choices = parseInt(value); - } - } - this.setState({ - adddom: arr - }) - // console.log(this.state.adddom); - } - - //提交题目//没有就创建新的题库,新建问题和保存题目不一样不能同时保存 这里只是新建 和编辑 标题和须知 - submitQuestionnaire = () => { - console.log("调用了submitQuestionnaire") - if (this.state.Newedit === true) { - - this.newword(); - - } else { - if (this.state.polls_nametest === undefined || this.state.polls_nametest === "") { - this.props.showNotification("请输入标题"); - return - } - - if (this.state.polls_descriptiontest.length > 100) { - - } - var pollid; - if (this.state.pollid === undefined) { - pollid = this.props.match.params.pollid; - } else { - pollid = this.state.pollid; - } - - - var url = `/polls/${pollid}.json`; - axios.put(url, { - polls_name: this.state.polls_nametest, - polls_description: this.state.polls_descriptiontest - }).then((result) => { - try { - // console.log(JSON.stringify(result)) - if (result.data.status === 0) { - // console.log("更新题目成功") - // this.props.showNotification("保存成功"); - this.props.history.push(`/courses/${this.props.match.params.coursesId}/polls/${pollid}/detail?tab=2`) - } - } catch (e) { - - } - }) - } - } - - cancelmodel = () => { - - this.setState({ - Modalstype: false, - Modalstopval: "", - ModalsBottomval: "", - }) - - } - savedelete = (question_type, index, item) => { - console.log("savedelete"); - this.handleClickByDelete(question_type, index, item); - this.setState({ - Modalstype: false, - Modalstopval: "", - ModalsBottomval: "", - }) - } - // 问题的类型,1单选题,2为多选题,3为主观题 - showDeleteConfirm = (question_type, index, item) => { - this.setState({ - Modalstype: true, - Modalstopval: "是否确认删除?", - ModalsBottomval: "", - ModalCancel: this.cancelmodel, - ModalSave: () => this.savedelete(question_type, index, item), - }) - - } - //必答选项 - onCheckAllChange = (e, index) => { - console.log("onCheckAllChange"); - console.log(e.target.checked); - // console.log(e.target.value); - let arr = this.state.adddom; - for (var i = 0; i < arr.length; i++) { - if (index === i) { - if (e.target.checked === true) { - arr[i].question.is_necessary = 1; - - } else { - arr[i].question.is_necessary = 0; - } - } - } - this.setState({ - adddom: arr - }) - } - - //重新编辑标题和须知 - adddomeditit = () => { - if (this.state.mysave === true) { - this.setState({ - mysave: false, - readOnlys: "readOnly", - storagedesc:this.state.polls_nametest, - storagedesctwo:this.state.polls_descriptiontest, - }) - } else if (this.state.mysave === false) { - this.setState({ - mysave: true, - readOnlys: "", - storagedesc:this.state.polls_nametest, - storagedesctwo:this.state.polls_descriptiontest, - }) - } - } - //取消保存 - onSaveExercisetwo = () => { - if (this.state.mysave === true) { - this.setState({ - mysave: false, - Newedit: false, - readOnlys: "readOnly", - polls_nametest:this.state.storagedesc, - polls_descriptiontest:this.state.storagedesctwo, - }) - } else { - this.setState({ - mysave: false, - Newedit: false, - readOnlys: "readOnly", - polls_nametest:this.state.storagedesc, - polls_descriptiontest:this.state.storagedesctwo, - }) - } - } - // 创建问卷 - 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, - }) - - - }) - } else { - if (this.state.polls_nametest === undefined || this.state.polls_nametest === "") { - this.props.showNotification("请输入标题"); - return - } - - var pollid; - if (this.state.pollid === undefined) { - pollid = this.props.match.params.pollid; - } else { - pollid = this.state.pollid; - } - - - var url = `/polls/${pollid}.json`; - axios.put(url, { - polls_name: this.state.polls_nametest, - polls_description: this.state.polls_descriptiontest - }).then((result) => { - if (result !== undefined) { - this.props.showNotification(`问卷更新成功!`); - this.setState({ - mysave: false, - readOnlys: "readOnly", - }) - } - - }) - } - - } - - //试图 - render() { - let { - addonAfter, - user_permission, - polls_status, - Modalstype, - mysave, - readOnlys, - newoption, - cancellation, - } = this.state - //获取老师权限 - // console.log("[`${maps[polls_status && polls_status]}`]]"); - // console.log(polls_status); - // console.log([[`${maps[polls_status && polls_status]}`]] + ""); - - const IsAdmin = this.props.isAdmin(); - const {getFieldDecorator} = this.props.form; - const formItemLayout = { - labelCol: { - xs: {span: 24}, - // sm: { span: 8 }, - sm: {span: 24}, - }, - wrapperCol: { - xs: {span: 24}, - // sm: { span: 16 }, - sm: {span: 24}, - }, - }; - - const radioStyle = { - display: 'block', - height: '30px', - lineHeight: '30px', - }; - - // console.log(this.state.projects===undefined?"":this.state.projects.poll_questions) - var displaymysave = (mysave === true) ? "" : "display:none;"; - return ( -
    - {/*提示*/} - {Modalstype && Modalstype === true ? : ""} -
    -

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

    -
    -

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

    - 返回 -
    - - {/*
    */} -
    -
    - - -
    -
    *问卷标题 -
    - { - this.props.match.params.news === undefined ? "" : this.props.match.params.news === "new" ? - ( - this.state.mysave === false ? - - : "") - : - - } - -
    - - - -
    -
    - - -
    问卷须知
    - - - { - this.state.Newedit === true || this.state.mysave === true ? -
    - - {cancellation === false ? - - : ""} - -
    - : "" - } - -
    - -
    -

    - - - { - this.state.mysingles + this.state.mydoubles + this.state.mymainsint === 0 ? "" : -

    - - {this.state.mysingles === 0 ? "" : 单选题{this.state.mysingles === undefined ? "" : this.state.mysingles} 题} - - {this.state.mydoubles === 0 ? "" : - 多选题{this.state.mydoubles === undefined ? "" : this.state.mydoubles}题} - {this.state.mymainsint === 0 ? "" : - - 主观题{this.state.mymainsint === undefined ? "" : this.state.mymainsint}题 - - } - - - 合计 {this.state.mysingles === undefined ? "" : this.state.mydoubles === undefined ? "" : this.state.mymainsint === undefined ? "" : this.state.mysingles + this.state.mydoubles + this.state.mymainsint} -
    - - } - -

    -
    - - {/*自动生成修改好的获取到的*/} - {/**************************************************************************/} - {this.state.poll_questions === undefined ? "" : this.state.poll_questions.map((item, index) => { - // console.log('打印this.state.poll_questions') - // console.log(item.question) - let resultDom; - resultDom =
    -

    - 第{index + 1}题: - {item.question.question_type === 1 ? "(单选题)" : item.question.question_type === 2 ? "(多选题)" : "(主观题)"} - {item.question.is_necessary === 1 ? "必答" : item.question.question_type === 2 ? "选答" : "选答"} - {(item.question.min_choices === undefined && item.question.max_choices === undefined ? "" : item.question.min_choices === null && item.question.max_choices === null ? "" : item.question.min_choices === 0 && item.question.max_choices === 0 ? "" : "可选" + item.question.min_choices + "-" + item.question.max_choices + "项")} - { - polls_status === undefined || polls_status === 1 ? - - this.showDeleteConfirm(item.question.question_type, index, item)}> - {index === 0 ? "" : - this.handleClickBySortUp(index, item)}>} - {index === this.state.poll_questions.length - 1 ? "" : - this.handleClickBySortDown(index, item)}>} - this.addMytopic(item.question.question_type, this.state.pollid, index + 1, true, item.question.id)}> - this.adddomedit(item)}> - : this.adddomedit(item)}> - } - -

    -

    {item.question.question_title}

    - {/*
    {item.question.question_title}
    */} - {item.question.question_type === 1 ? - ( - {item.question.answers === undefined ? "" : item.question.answers.map((items, i) => { - return ( -
    - - {/*
    {items.answer_text}
    */} - {/*
    {items.answer_text}
    */} - {items.answer_text} - -
    - ) - })} -
    ) - : item.question.question_type === 2 ? - ( - {item.question.answers === undefined ? "" : item.question.answers.map((items, i) => { - return ( -
    - - {items.answer_text} - - {/*{items.answer_text}*/} -
    - ) - })} -
    ) - : item.question.question_type === 3 ? (
    ) : (
    )} -
    - - return ( -
    - {resultDom} -
    - ) - })} - {/**************************************************************************/} - {/*编辑用的新增用的*/} - {/**************************************************************************/} - - {this.state.adddom === undefined ? "" : this.state.adddom.map((itemo, indexo) => { - // console.log('打印this.state.adddom') - // console.log(itemo.question) - let arrid = itemo.question.id; - let resultDomtwo; - resultDomtwo = -
    - {itemo.question.question_type === 1 ? "单选题" : itemo.question.question_type === 2 ? "多选题" : "主观题"} - this.onCheckAllChange(e, indexo)} - className="lineh-40" - style={{"marginLeft": "20px"}}>必答 - - - - - {itemo.question.answers === undefined ? "" : itemo.question.answers.map((itemt, indext) => { - return ( -
    - {itemt.answer_text === undefined ? ( -
    ) : itemt.answer_text === "其他" ? ( -

    - 其它 - - - {polls_status === undefined || polls_status === 1 ? - this.deleteentrys(arrid, indext, true)}> - : ""} -

    ) : (

    - 选项 - - - {polls_status === undefined || polls_status === 1 ? - this.deleteentrys(arrid, indext, false)}> - : ""} -

    )} -
    - ) - })} - -
    - {itemo.question.question_type === 1 ? ( -
    -
    - {polls_status === undefined || polls_status === 1 ? - this.ewoption(itemo.question.id, itemo)}>新增选项 - - : ""} - {polls_status === undefined || polls_status === 1 ? - - (newoption === false ? - this.addanotheroption(itemo.question.id)}>新增其他选项 - : "") - : ""} - - this.deleteadddom(indexo)}>取消 - this.deleteadddomthree(indexo, itemo)}>保存 - this.deleteadddomtwo(indexo, itemo)}>保存并继续 - -
    -
    - - - ) - - - : itemo.question.question_type === 2 ? ( - //////////////////////////////////////////// 可选 -
    -
    -
    - 可选 -
    - {/*可选最小*/} - - - ~ - {/*可选最大*/} - - - (学生答题时,系统对其选择的选项个数进行限制,--表示不限制) -
    - -
    -
    -
    - ) - - : (
    ) - - } -
    -
    - {itemo.question.question_type === 2 ? - ( - polls_status === undefined || polls_status === 1 ? -
    - -
    this.ewoption(itemo.question.id, itemo)}>新增选项 - - { - newoption === false ? this.addanotheroption(itemo.question.id)}>新增其他选项 : "" - } - -
    - - - - this.deleteadddom(indexo)}>取消 - this.deleteadddomthree(indexo, itemo)}>保存 - this.deleteadddomtwo(indexo, itemo)}>保存并继续 - -
    - - - : "" - ) - - : itemo.question.question_type === 3 ? -
    - - this.deleteadddom(indexo)}>取消 - this.deleteadddomthree(indexo, itemo)}>保存 - this.deleteadddomtwo(indexo, itemo)}>保存并继续 - -
    - : - ""} - - -
    -
    - - - return ( -
    - {resultDomtwo} -
    - ) - })} - {/**************************************************************************/} - - {polls_status === undefined || polls_status === 1 ? -
    - { - this.props.match.params.news === "new" ? - this.state.Newedit === false ? -
    -
    - -
    - this.addmysingles()}>单选题 - this.addmydoubles()}>多选题 - this.addmymainsint()}>主观题 -
    -
    - - : "" - : -
    -
    -
    - this.addmysingles()}>单选题 - this.addmydoubles()}>多选题 - this.addmymainsint()}>主观题 -
    -
    - } -
    - :
    } -
    - { - this.props.match.params.news === "new" ? - (this.state.Newedit === false ? - - - : "") - : - - } - - {/**/} -
    -
    -
    - ) - } - -} - -const WrappedPollNew = Form.create({name: 'taskPollNew'})(PollNew); -// RouteHOC() +import React, {Component} from "react"; +import {Form, Input, Tooltip, Checkbox, Radio, Select, message, Modal, Button} from 'antd' +import {WordsBtn, ActionBtn} from 'educoder' +import '../css/members.css' +import "../common/formCommon.css" + +import './pollStyle.css' +import '../css/Courses.css' +import axios from 'axios' +import moment from "../new/CoursesNew"; +import Modals from "../../modals/Modals"; + + +const TextArea = Input.TextArea +const RadioGroup = Radio.Group +const CheckboxGroup = Checkbox.Group +const Option = Select.Option; +const maps = {1: "未发布", 2: "提交中", 3: "已截止"} +const confirm = Modal.confirm; + +class PollNew extends Component { + // 问卷新建和编辑 + // + // * addonAfter 字数限制 + // * q_counts 题目总数 + // * mysingles 单选题数量 + // * mydoubles 多选题数量 + // * mymainsint 主观题数量 + // * adddom 添加编辑的数据 页面点击新增题目 + // * editentry 编辑条目 新增的题目点击到条目中 + //* questionnair 问卷是否存在 默认不存在 + // * + + constructor(props) { + super(props); + this.state = { + visible: false, + poll_questions: [], + user_permission: "", + addonAfter: 60, + addonAftertwo: 100, + mysingles: 0, + mydoubles: 0, + mymainsint: 0, + adddom: [], + editentry: [], + questionnair: false, + polls_name: undefined, + polls_nametest: "", + polls_description: "", + polls_descriptiontest: "", + storagedesc:"", + storagedesctwo:"", + coursesId: "", + pollid: undefined, + polls_status: undefined, + q_countst: 0, + Newedit: true, + Insertposition: undefined, + Modalstype: false, + mysave: false, + readOnlys: "readOnly", + problemtopic: null, + problemtopicbool: false, + newoption: false, + cancellation: false, + } + // console.log("试卷新建和编辑"); + // console.log(JSON.stringify(props)); + + } + + changeTopicName = (e) => { + let num = 60 - parseInt(e.target.value.length); + this.setState({ + addonAfter: num < 0 ? 0 : num + }) + this.setState({ + polls_nametest: e.target.value + }) + } + + + changeTopicNametwo = (e) => { + // console.log("获取的值" + e.target.value); + let num = 100 - parseInt(e.target.value.length); + this.setState({ + addonAftertwo: num < 0 ? 0 : num + }) + this.setState({ + polls_descriptiontest: e.target.value + }) + } + + // 初始化数据 + componentDidMount = () => { + console.log("componentDidMount 50") + if (this.props.match.params.news !== undefined) { + if (this.props.match.params.news === "new") { + this.state.Newedit === true; + this.setState({ + Newedit: true, + mysave: true, + readOnlys: "", + cancellation: true, + }) + } else { + this.Initializatio_data(); + this.state.Newedit === false; + this.setState({ + Newedit: false, + mysave: false, + readOnlys: "readOnly", + }) + } + } + + + // this.getPollInfo(); + + } + //获取权限 + // getPollInfo(){ + // // console.log(this.props.match); + // let pollId=this.props.match.params.pollId; + // let url=`/polls/${pollId}/common_header.json` + // axios.get(url).then((result)=>{ + // if(result.status==200){ + // this.setState({ + // pollDetail:result.data, + // user_permission:result.data.user_permission + // }) + // } + // }).catch((error)=>{ + // console.log(error); + // }) + // } + //初始化请求网络 + Initializatio_data = () => { + console.log("Initializatio_data 582") + //课堂id + let coursesId = this.props.match.params.coursesId; + //时间id + let pollid = this.props.match.params.pollid; + console.log(pollid); + // let coursesId = 557; + if (pollid === undefined) { + // console.log("没有问卷新建问卷~~~") + // let coursesId=this.props.match.params.coursesId; + // // to={`/courses/${coursesId}/polls/new`} + // + // const urll = `/courses/${coursesId}/polls/new.json` + // axios.get(urll).then((result) => { + // if (result.status === 200) { + // console.log(urll) + // console.log("问卷新建成功") + // console.log(JSON.stringify(result)) + // // var path=`/courses/${coursesId}/polls/new`; + // // + // // this.props.history.push({ pathname: path, state: { } }); + // } + // }).catch((error) => { + // console.log(error) + // }) + + // const urlls = `/courses/${coursesId}/polls.json` + // axios.post(urlls,{ + // polls_name: "这是标题", + // polls_description:"这是标题须知" + // }).then((result)=>{ + // console.log("创建问卷++++++") + // console.log(result) + // try { + // if(result.data.status===0){ + // console.log("创建问卷") + // console.log(JSON.stringify(result.data)) + // } + // }catch (e) { + // + // } + // + // }) + //没有问卷 + this.setState({ + projects: [], + polls_name: "", + polls_description: "", + poll_questions: [], + question_types: [], + pollid: undefined, + mysingles: 0, + mydoubles: 0, + mymainsint: 0, + polls_nametest: "", + polls_descriptiontest: "", + coursesId: 0, + questionnair: false + }) + } else { + const url = `/polls/${pollid}/edit.json`; + axios.get(url).then((result) => { + if (result !== undefined) + + // console.log("有问卷~~~") + // if (result.status === 200) { + // console.log(JSON.stringify(result.data)) + this.props.form.setFieldsValue({ + polls_nametest: result.data.poll.polls_name, + polls_descriptiontest: result.data.poll.polls_description, + }); + 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, + }) + console.log(this.state.polls_nametest) + console.log(this.state.polls_descriptiontest) + // } + }).catch((error) => { + console.log(error) + }) + } + + } + + //重新获取数据 + thisinitializationdatanew = () => { + var pollidsy = null; + if (this.state.pollid !== undefined) { + pollidsy = this.state.pollid; + if (pollidsy === null || pollidsy === undefined) { + pollidsy = this.props.match.params.pollid; + } + } + + if (pollidsy === null || pollidsy === undefined) { + return + } + + const url = `/polls/${pollidsy}/edit.json`; + axios.get(url).then((result) => { + if (result !== undefined) + + // console.log("有问卷~~~") + // if (result.status === 200) { + // console.log(JSON.stringify(result.data)) + 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) => { + console.log(error) + }) + } + //新建问卷 + newword = () => { + 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.data.status === 0) { + this.state.Newedit === false; + // this.props.showNotification(`试卷创建成功`); + this.setState({ + pollid: result.data.data.id, + Newedit: false, + }) + this.props.history.push(`/courses/${this.props.match.params.coursesId}/polls/${result.data.data.id}/detail?tab=2`) + } + }) + } + //添加单选题目 + addmysingles = () => { + + if (this.state.newoption === true) { + this.setState({ + newoption: false + }) + } + + var Insertposition = this.state.poll_questions.length; + // console.log(JSON.stringify(this.state.poll_questions)); + for (var i = 0; i < this.state.poll_questions.length; i++) { + if (this.state.poll_questions[i].question.question_type === 1) { + Insertposition = i; + } + + } + this.addMytopic(1, this.state.pollid, Insertposition, false, 0); + // } + } + + //添加多选题目 + addmydoubles = () => { + console.log("addmymainsint 70") + if (this.state.newoption === true) { + this.setState({ + newoption: false + }) + } + + var Insertposition = this.state.poll_questions.length; + // console.log(JSON.stringify(this.state.poll_questions)); + for (var i = 0; i < this.state.poll_questions.length; i++) { + if (this.state.poll_questions[i].question.question_type === 2) { + Insertposition = i; + } + + + } + this.addMytopic(2, this.state.pollid, Insertposition, false, 0); + + // } + } + + //添加主观题目 + addmymainsint = () => { + + var Insertposition = this.state.poll_questions.length; + // console.log(JSON.stringify(this.state.poll_questions)); + for (var i = 0; i < this.state.poll_questions.length; i++) { + if (this.state.poll_questions[i].question.question_type === 3) { + Insertposition = i; + } + + + } + + this.addMytopic(3, this.state.pollid, Insertposition, false, 0); + // } + } + + //编辑方法 + adddomedit = (object) => { + console.log("adddomedit 76"); + if (this.state.q_countst > 0) { + this.props.showNotification(`不能同时编辑两题`); + + return; + } + var anserbool = false; + this.setState({ + q_countst: 1, + }) + window.scrollTo(0, this.refs.targetElement.offsetTop) + let {adddom} = this.state; + // var arr =new Object(objects); + // console.log(arr) + // adddom.push(arr); + var question = {}; + var Insertposition = this.state.poll_questions.length; + if (object.question.question_type === 1) { + var answers = []; + var questiontwo = {}; + ///////////////////////////daying + for (var y = 0; y < object.question.answers.length; y++) { + var answerstwo; + if (object.question.answers[y].answer_text === "其他") { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + anserbool = true; + } else { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + } + answers.push(answerstwo); + + + } + // 插入单选题 + questiontwo = { + // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 1, + "question_title": object.question.question_title, + "question_type": 1, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + adddom.push(question); + for (var i = 0; i < this.state.poll_questions.length; i++) { + if (this.state.poll_questions[i].question.question_type === 1) { + Insertposition = i; + } + } + } else if (object.question.question_type === 2) { + //插入多选题 + var answers = []; + var questiontwo = {}; + + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + anserbool = true; + } else { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + } + answers.push(answerstwo); + } + questiontwo = { + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 2, + "question_title": object.question.question_title, + "question_type": 2, + "max_choices": object.question.max_choices, + "min_choices": object.question.min_choices, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + adddom.push(question); + for (var i = 0; i < this.state.poll_questions.length; i++) { + if (this.state.poll_questions[i].question.question_type === 2) { + Insertposition = i; + } + } + } else if (object.question.question_type === 3) { + //插入主观题 + var answers = []; + var questiontwo = {}; + + if (object.question.answers.length > 0) { + for (var y = 0; y < object.question.answers.length; y++) { + var answerstwo; + if (object.question.answers[y].answer_text === "其他") { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + } else { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + } + answers.push(answerstwo); + } + } + questiontwo = { + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 3, + "question_title": object.question.question_title, + "question_type": 3, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + adddom.push(question); + for (var i = 0; i < this.state.poll_questions.length; i++) { + if (this.state.poll_questions[i].question.question_type === 3) { + Insertposition = i; + } + } + } + this.setState({ + adddom: adddom, + newoption: anserbool, + Insertposition: Insertposition + }) + + } + + //新增添加题目 有new + addMytopic = (index, pollid, Insertposition, Whether, id) => { + //Whether 是否插入 + // console.log("id") + // console.log(id) + // console.log("Whether") + // console.log(Whether) + console.log("addMytopic 90") + if (this.state.q_countst > 0) { + this.props.showNotification(`不能同时编辑两题`); + + return; + } + this.state.Insertposition = Insertposition; + var Whethername = null; + if (Whether === true) { + Whethername = id; + } + this.setState({ + Insertposition: Insertposition, + q_countst: 1, + }) + window.scrollTo(0, this.refs.targetElement.offsetTop) + var arrr = this.state.adddom; + let newarrr = [...arrr]; + + var arr = this.state.poll_questions; + let newarr = [...arr]; + + if (newarr.length > 0) { + if (index === 1) { + // 插入单选题 + // console.log(this.state.poll_questions[newarr.length - 1].question.id); + var question = {} + var questiontwo = { + // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, + "id": this.state.poll_questions[newarr.length - 1].question.id + 1, + "is_necessary": 1, + "question_number": 1, + "question_title": "", + "question_type": 1, + "new": "new", + "answers": [ + {"answer_id": 1, "answer_position": 1, "answer_text": ""}, + {"answer_id": 2, "answer_position": 2, "answer_text": ""}, + {"answer_id": 3, "answer_position": 3, "answer_text": ""}, + {"answer_id": 4, "answer_position": 4, "answer_text": ""}, + // {"answer_id": 5, "answer_position": 5, "answer_text": "其他"}, + ] + }; + question = {"question": questiontwo}; + newarrr.push(question); + + this.setState({ + adddom: newarrr, + problemtopic: Whethername, + problemtopicbool: Whether, + }) + + } else if (index === 2) { + //插入多选题 + var question = {} + var questiontwo = { + "id": this.state.poll_questions[newarr.length - 1].question.id + 1, + "is_necessary": 1, + "question_number": 2, + "question_title": "", + "question_type": 2, + "max_choices": 0, + "min_choices": 0, + "new": "new", + "answers": [ + {"answer_id": 1, "answer_position": 1, "answer_text": ""}, + {"answer_id": 2, "answer_position": 2, "answer_text": ""}, + {"answer_id": 3, "answer_position": 3, "answer_text": ""}, + {"answer_id": 4, "answer_position": 4, "answer_text": ""}, + // {"answer_id": 5, "answer_position": 5, "answer_text": "其他"}, + ] + }; + question = {"question": questiontwo}; + newarrr.push(question); + + this.setState({ + adddom: newarrr, + problemtopic: Whethername, + problemtopicbool: Whether, + }) + + } else if (index === 3) { + //插入主观题 + // console.log(this.state.poll_questions[newarr.length - 1].question.id); + var question = {} + var questiontwo = { + "id": this.state.poll_questions[newarr.length - 1].question.id + 1, + "is_necessary": 1, + "question_number": 3, + "question_title": "", + "question_type": 3, + "new": "new", + "answers": [] + }; + question = {"question": questiontwo}; + newarrr.push(question); + this.setState({ + adddom: newarrr, + problemtopic: Whethername, + problemtopicbool: Whether, + }) + + } + } else { + /////上面视图全部删除后 要加载的 + if (index === 1) { + // 插入单选题 + var id; + try { + id = this.state.poll_questions[newarr.length - 1].question.id + 1 + } catch (e) { + id = 1; + } + var questiontwo = { + // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, + "id": id, + "is_necessary": 1, + "question_number": 1, + "question_title": "", + "question_type": 1, + "new": "new", + "answers": [ + {"answer_id": 1, "answer_position": 1, "answer_text": ""}, + {"answer_id": 2, "answer_position": 2, "answer_text": ""}, + {"answer_id": 3, "answer_position": 3, "answer_text": ""}, + {"answer_id": 4, "answer_position": 4, "answer_text": ""}, + // {"answer_id": 5, "answer_position": 5, "answer_text": "其他"}, + ] + }; + question = {"question": questiontwo}; + newarrr.push(question); + + this.setState({ + adddom: newarrr, + problemtopic: Whethername, + problemtopicbool: Whether, + }) + + } else if (index === 2) { + //插入多选题 + var id; + try { + id = this.state.poll_questions[newarr.length - 1].question.id + 1 + } catch (e) { + id = 1; + } + var questiontwo = { + "id": id, + "is_necessary": 1, + "question_number": 2, + "question_title": "", + "question_type": 2, + "max_choices": 0, + "min_choices": 0, + "new": "new", + "answers": [ + {"answer_id": 1, "answer_position": 1, "answer_text": ""}, + {"answer_id": 2, "answer_position": 2, "answer_text": ""}, + {"answer_id": 3, "answer_position": 3, "answer_text": ""}, + {"answer_id": 4, "answer_position": 4, "answer_text": ""}, + // {"answer_id": 5, "answer_position": 5, "answer_text": "其他"}, + ] + }; + question = {"question": questiontwo}; + newarrr.push(question); + + this.setState({ + adddom: newarrr, + problemtopic: Whethername, + problemtopicbool: Whether, + }) + + } else if (index === 3) { + //插入主观题 + var id; + try { + id = this.state.poll_questions[newarr.length - 1].question.id + 1 + } catch (e) { + id = 1; + } + var questiontwo = { + "id": id, + "is_necessary": 1, + "question_number": 3, + "question_title": "", + "question_type": 3, + "new": "new", + "answers": [] + }; + question = {"question": questiontwo}; + newarrr.push(question); + this.setState({ + adddom: newarrr, + problemtopic: Whethername, + problemtopicbool: Whether, + }) + } + } + } + + //删除指定条目 + deleteadddom = (indexo) => { + console.log("deleteadddom 259") + var arr = this.state.adddom; + let newarr = [...arr]; + + newarr.splice(indexo, 1); + this.setState({ + adddom: newarr, + q_countst: 0, + problemtopic: null, + problemtopicbool: false, + }) + } + //保存并继续 + //保存并继续,即提交本题的新建并继续创建一个相同的题(该新题处于编辑模式,题目和选项不要清空) + deleteadddomtwo = (indexo, object) => { + var thiss = this; + this.setState({ + q_countst: 1, + }) + var poll_questionslength = this.state.poll_questions.length; + // console.log("deleteadddomtwo|||||||||||||||||||||||||||||||||||||||||\\"); + // console.log(indexo); + // console.log(object); + // console.log(object.question.question_type); + let arr = this.state.adddom; + let arrpoll = this.state.poll_questions; + let newarr = [...arr]; + let newarrpoll = [...arrpoll]; + + //选项内容不能为空 + let max = 0; + let maxtie = newarr[indexo].question.answers.length; + for (var k = 0; k < newarr[indexo].question.answers.length; k++) { + try { + if (newarr[indexo].question.answers[k].answer_text != undefined) { + if (newarr[indexo].question.answers[k].answer_text === "") { + max = max + 1; + } + } + } catch (e) { + console.log("PollNew281") + console.log(e) + } + } + if (newarr[indexo].question.question_title === "") { + this.props.showNotification(`题目不能为空`); + + return + } + if (max > 0) { + if (object.question.question_type === 1) { + this.props.showNotification(`选项内容不能为空`); + + return + } else if (object.question.question_type === 2) { + this.props.showNotification(`选项内容不能为空`); + + return + } + + } + if (maxtie < 2) { + if (object.question.question_type === 1) { + this.props.showNotification(`选项不能少于2个!`); + + return + } else if (object.question.question_type === 2) { + this.props.showNotification(`选项不能少于2个!`); + + return + } + + + } + + if (object.question.question_type === 2) { + if (object.question.max_choices > 0) { + if (object.question.min_choices < 2) { + this.props.showNotification(`可选最小不能少于2个`); + + return; + + } + } + + } + if (object.question.new === "new") { + // 根据数组里面的new 来确定是否是新增还是 修改 + //添加道数组上 + //不能共用数组 所以自己写个新数组 然后push 上面卷子中 + var question = {}; + if (object.question.question_type === 1) { + + var questiontwo = {}; + var other = []; + var option = []; + var answerstwos = []; + var answerstwoss = []; + ///////////////////////////daying + // 这个是装选项和其他的 + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + other.push(object.question.answers[y].answer_text); + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + option.push(object.question.answers[y].answer_text) + answerstwoss.push(datatwo); + } + + + } + + var arrc = option.concat(other); + var answers = answerstwoss.concat(answerstwos); + // 插入单选题 + // var id + // try { + // id = newarrpoll[newarrpoll.length - 1].question.id + 1; + // } catch (e) { + // id = 1; + // } + questiontwo = { + // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, + "id": null, + "is_necessary": object.question.is_necessary, + "question_number": 1, + "question_title": object.question.question_title, + "question_type": 1, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + var insindex = null; + // if (poll_questionslength !== thiss.state.Insertposition) { + // insindex = newarrpoll[thiss.state.Insertposition].question.id; + // } + if (this.state.problemtopicbool === true) { + insindex = this.state.problemtopic; + } + this.createquestionsandanswers(object, 1, arrc, null, 0, 0, insindex); + // newarrpoll.push(question); + newarrpoll.splice(thiss.state.Insertposition, 0, question); + + } else if (object.question.question_type === 2) { + //插入多选题 + if (object.question.max_choices < object.question.min_choices) { + this.props.showNotification(`可选的最大限制不能小于最小限制`); + + return; + } + + var questiontwo = {}; + var other = []; + var option = []; + var answerstwos = []; + var answerstwoss = []; + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + other.push(object.question.answers[y].answer_text); + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + option.push(object.question.answers[y].answer_text) + answerstwoss.push(datatwo); + } + } + var arrc = option.concat(other); + var answers = answerstwoss.concat(answerstwos); + // var id + // try { + // id = newarrpoll[newarrpoll.length - 1].question.id + 1; + // } catch (e) { + // id = 1; + // } + questiontwo = { + "id": null, + "is_necessary": object.question.is_necessary, + "question_number": 2, + "question_title": object.question.question_title, + "question_type": 2, + "max_choices": object.question.max_choices, + "min_choices": object.question.min_choices, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + var insindex = null; + if (this.state.problemtopicbool === true) { + insindex = this.state.problemtopic; + } + this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, insindex); + //插入多选题 + // if (object.question.max_choices > arrc.length) { + // // console.log("选择题的最大可选项不能大于选项数") + // this.props.showNotification(`选择题的最大可选项不能大于选项数`); + // + // return; + // } + // if (object.question.min_choices === 0) { + // // console.log("选择题的最大可选项不能小于2项目") + // this.props.showNotification(`选择题的最大可选项不能小于2项目`); + // + // return; + // + // } + // newarrpoll.push(question); + newarrpoll.splice(thiss.state.Insertposition, 0, question); + } else if (object.question.question_type === 3) { + //插入主观题 + var answers = []; + var questiontwo = {}; + var answerstwos = []; + var answerstwoss = []; + if (object.question.answers.length > 0) { + for (var y = 0; y < object.question.answers.length; y++) { + var answerstwo; + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + answerstwoss.push(datatwo); + } + } + } + + answers = answerstwoss.concat(answerstwos); + // var id + // try { + // id = newarrpoll[newarrpoll.length - 1].question.id + 1; + // } catch (e) { + // id = 1; + // } + questiontwo = { + "id": null, + "is_necessary": object.question.is_necessary, + "question_number": 3, + "question_title": object.question.question_title, + "question_type": 3, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + // var insindex = null; + // if (poll_questionslength !== thiss.state.Insertposition) { + // insindex = newarrpoll[thiss.state.Insertposition].question.id; + // } + //主观题不需要可选选项 + var insindex = null; + if (this.state.problemtopicbool === true) { + insindex = this.state.problemtopic; + } + this.createquestionsandanswers(object, 3, null, null, 0, 0, insindex); + // newarrpoll.push(question); + newarrpoll.splice(thiss.state.Insertposition, 0, question); + } + //////////////////////////////////////////////////////////////////////////////////////////////////// 上面是新增 + } else { + ///////////////////////////////////////////////////////////////////////////////////////////////////修改点了编辑 + console.log("点了编辑") + var uuk = -1 + //这个地方判断 点了编辑上面题目又把他删除了 保存的时候就只能是插入新增了 + for (var uk = 0; uk < newarrpoll.length; uk++) { + if (object.question.id === newarrpoll[uk].question.id) { + uuk = uk; + } + } + + + var question = {}; + if (object.question.question_type === 1) { + var questiontwo = {}; + var other = []; + var option = []; + var answerstwos = []; + var answerstwoss = []; + ///////////////////////////daying + //这个装选项和其他的 + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + other.push(object.question.answers[y].answer_text); + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + option.push(object.question.answers[y].answer_text) + answerstwoss.push(datatwo); + } + + + } + var arrc = option.concat(other); + var answers = answerstwoss.concat(answerstwos); + // 插入单选题 + questiontwo = { + // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 1, + "question_title": object.question.question_title, + "question_type": 1, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + if (uuk !== -1) { + // console.log("修改") + this.edittotheserver(object, 1, arrc, null, 0, 0); + newarrpoll.splice(uuk, 1, question); + } else { + // console.log("他原来的删除掉了") + this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id); + newarrpoll.push(question); + } + newarr[indexo].question.new = "new" + // console.log(newarrpoll) + } else if (object.question.question_type === 2) { + //插入多选题 + + if (object.question.max_choices < object.question.min_choices) { + this.props.showNotification('可选的最大限制不能小于最小限制!'); + + return; + } + var questiontwo = {}; + var other = []; + var option = []; + var answerstwos = []; + var answerstwoss = []; + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + other.push(object.question.answers[y].answer_text); + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + option.push(object.question.answers[y].answer_text) + answerstwoss.push(datatwo); + } + } + var arrc = option.concat(other); + var answers = answerstwoss.concat(answerstwos); + questiontwo = { + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 2, + "question_title": object.question.question_title, + "question_type": 2, + "max_choices": object.question.max_choices, + "min_choices": object.question.min_choices, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + //插入多选题 + // if (object.question.max_choices > arrc.length) { + // // console.log("选择题的最大可选项不能大于答案数") + // this.props.showNotification('选择题的最大可选项不能大于选项数!'); + // + // return; + // } + // if (object.question.min_choices === 0) { + // // console.log("选择题的最大可选项不能小于2项目") + // this.props.showNotification('选择题的最大可选项不能小于2项目!'); + // + // return; + // + // } + if (uuk !== -1) { + console.log("修改") + this.edittotheserver(object, 2, arrc, null, object.question.max_choices, object.question.min_choices); + newarrpoll.splice(uuk, 1, question); + } else { + console.log("删除") + this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, object.question.id); + newarrpoll.push(question); + } + console.log(newarrpoll) + newarr[indexo].question.new = "new" + } else if (object.question.question_type === 3) { + //插入主观题 + var answers = []; + var questiontwo = {}; + + if (object.question.answers.length > 0) { + for (var y = 0; y < object.question.answers.length; y++) { + var answerstwo; + if (object.question.answers[y].answer_text === "其他") { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + } else { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + } + answers.push(answerstwo); + } + } + questiontwo = { + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 3, + "question_title": object.question.question_title, + "question_type": 3, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + + if (uuk !== -1) { + console.log("修改") + this.edittotheserver(object, 3, null, null, 0, 0); + newarrpoll.splice(uuk, 1, question); + } else { + console.log("删除") + this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id); + newarrpoll.push(question); + } + console.log(newarrpoll) + newarr[indexo].question.new = "new" + } + + } + + + //添加到上面列表中 + //改变题目总数 + if (object.question.question_type === 1) { + //单选题 + this.state.mysingles = this.state.mysingles + 1; + } else if (object.question.question_type === 2) { + //多选题 + this.state.mydoubles = this.state.mydoubles + 1; + } else if (object.question.question_type === 3) { + //主观题 + this.state.mymainsint = this.state.mymainsint + 1; + + } + this.setState({ + // poll_questions: newarrpoll, + adddom: newarr, + problemtopic: null, + problemtopicbool: false, + // mysingles: this.state.mysingles, + // mydoubles: this.state.mydoubles, + // mymainsint: this.state.mymainsint + }) + + } + + + //保存 后期可以考虑和保存并继续 合并 + //保存,即完成新建并退出本题编辑 + // indexo 第几个数组 + //object 单个数组数据 + deleteadddomthree = (indexo, object) => { + // console.log("deleteadddom 349") + var thiss = this; + let arr = this.state.adddom; + let arrpoll = this.state.poll_questions; + let newarr = [...arr]; + let newarrpoll = [...arrpoll]; + var poll_questionslength = this.state.poll_questions.length; //获取单前问题最大长度 + //选项内容不能为空 + let max = 0; + let maxtie = newarr[indexo].question.answers.length; + //判断选项值是否不为空 + for (var k = 0; k < newarr[indexo].question.answers.length; k++) { + try { + if (newarr[indexo].question.answers[k].answer_text != undefined) { + if (newarr[indexo].question.answers[k].answer_text === "") { + max = max + 1; + } + } + } catch (e) { + // console.log("PollNew281") + // console.log(e) + } + } + if (newarr[indexo].question.question_title === "") { + this.props.showNotification('题目不能为空!'); + return + } + if (max > 0) { + if (object.question.question_type === 1) { + this.props.showNotification('选项内容不能为空!'); + return + } else if (object.question.question_type === 2) { + this.props.showNotification('选项内容不能为空!'); + return + } + + } + if (maxtie < 2) { + if (object.question.question_type === 1) { + this.props.showNotification('选项不能少于2个!'); + return + } else if (object.question.question_type === 2) { + this.props.showNotification('选项不能少于2个!'); + return + } + + + } + + if (object.question.question_type === 2) { + if (object.question.max_choices > 0) { + if (object.question.min_choices < 2) { + this.props.showNotification(`可选最小不能少于2个`); + return; + } + } + } + if (object.question.new === "new") { + ///////////////////////////////////////////////////////////////////新增模式 + // 根据数组里面的new 来确定是否是新增还是 修改 + //添加道数组上 + //不能共用数组 所以自己写个新数组 然后push 上面卷子中 + var question = {}; + if (object.question.question_type === 1) { + var questiontwo = {}; + var other = []; + var option = []; + var answerstwos = []; + var answerstwoss = []; + ///////////////////////////daying + // 这个是装选项和其他的 + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + other.push(object.question.answers[y].answer_text); + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + option.push(object.question.answers[y].answer_text) + answerstwoss.push(datatwo); + } + } + var arrc = option.concat(other); + var answers = answerstwoss.concat(answerstwos); + // 插入单选题' + // var id; + // try { + // id = newarrpoll[newarrpoll.length - 1].question.id + 1 + // } catch (e) { + // id = 1; + // } + questiontwo = { + // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, + "id": null, + "is_necessary": object.question.is_necessary, + "question_number": 1, + "question_title": object.question.question_title, + "question_type": 1, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + //获取指定id 号 用来插入,如果不是就是在最后添加 + + //执行新增操作 + var insindex = null; + if (this.state.problemtopicbool === true) { + insindex = this.state.problemtopic; + } + this.createquestionsandanswers(object, 1, arrc, null, 0, 0, insindex); + newarrpoll.splice(thiss.state.Insertposition, 0, question); + } else if (object.question.question_type === 2) { + //插入多选题 + if (object.question.max_choices < object.question.min_choices) { + this.props.showNotification(`可选的最大限制不能小于最小限制`); + + return; + } + + var questiontwo = {}; + var other = []; + var option = []; + var answerstwos = []; + var answerstwoss = []; + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + other.push(object.question.answers[y].answer_text); + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + option.push(object.question.answers[y].answer_text) + answerstwoss.push(datatwo); + } + } + var arrc = option.concat(other); + var answers = answerstwoss.concat(answerstwos); + + questiontwo = { + "id": null, + "is_necessary": object.question.is_necessary, + "question_number": 2, + "question_title": object.question.question_title, + "question_type": 2, + "max_choices": object.question.max_choices, + "min_choices": object.question.min_choices, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + + var insindex = null; + if (this.state.problemtopicbool === true) { + insindex = this.state.problemtopic; + } + this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, insindex); + //插入多选题 + // if (object.question.max_choices > arrc.length) { + + newarrpoll.splice(thiss.state.Insertposition, 0, question); + } else if (object.question.question_type === 3) { + //插入主观题 + var answers = []; + var questiontwo = {}; + var answerstwos = []; + var answerstwoss = []; + if (object.question.answers.length > 0) { + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + answerstwoss.push(datatwo); + } + } + } + answers = answerstwoss.concat(answerstwos); + + questiontwo = { + "id": null, + "is_necessary": object.question.is_necessary, + "question_number": 3, + "question_title": object.question.question_title, + "question_type": 3, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + //主观题不需要可选选项 + + var insindex = null; + if (this.state.problemtopicbool === true) { + insindex = this.state.problemtopic; + } + this.createquestionsandanswers(object, 3, null, null, 0, 0, insindex); + // newarrpoll.push(question); + newarrpoll.splice(thiss.state.Insertposition, 0, question); + } + ///////////////////////////////////////////////////////////////////新增模式 + } else { + //////////////////////////////////////////////////////////////////////////////修改模式 + //修改 + var uuk = -1 + for (var uk = 0; uk < newarrpoll.length; uk++) { + if (object.question.id === newarrpoll[uk].question.id) { + uuk = uk; + console.log("删除了数据=-09876543234567890-111111111111") + } + } + + + var question = {}; + if (object.question.question_type === 1) { + var questiontwo = {}; + var other = []; + var option = []; + var answerstwos = []; + var answerstwoss = []; + ///////////////////////////daying + //这个装选项和其他的 + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + other.push(object.question.answers[y].answer_text); + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + option.push(object.question.answers[y].answer_text) + answerstwoss.push(datatwo); + } + } + var arrc = option.concat(other); + var answers = answerstwoss.concat(answerstwos); + // 插入单选题 + questiontwo = { + // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 1, + "question_title": object.question.question_title, + "question_type": 1, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + if (uuk !== -1) { + console.log("修改") + this.edittotheserver(object, 1, arrc, null, 0, 0); + newarrpoll.splice(uuk, 1, question); + } else { + console.log("删除") + this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id); + newarrpoll.push(question); + } + console.log(newarrpoll) + } else if (object.question.question_type === 2) { + //插入多选题 + if (object.question.max_choices < object.question.min_choices) { + this.props.showNotification(`可选的最大限制不能小于最小限制`); + + return; + } + var questiontwo = {}; + var other = []; + var option = []; + var answerstwos = []; + var answerstwoss = []; + for (var y = 0; y < object.question.answers.length; y++) { + if (object.question.answers[y].answer_text === "其他") { + var dataone = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + other.push(object.question.answers[y].answer_text); + answerstwos.push(dataone); + } else { + var datatwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + option.push(object.question.answers[y].answer_text) + answerstwoss.push(datatwo); + } + } + var arrc = option.concat(other); + var answers = answerstwoss.concat(answerstwos); + questiontwo = { + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 2, + "question_title": object.question.question_title, + "question_type": 2, + "max_choices": object.question.max_choices, + "min_choices": object.question.min_choices, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + //插入多选题 + if (uuk !== -1) { + console.log("修改") + this.edittotheserver(object, 2, arrc, null, object.question.max_choices, object.question.min_choices); + newarrpoll.splice(uuk, 1, question); + } else { + console.log("删除") + this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, object.question.id); + newarrpoll.push(question); + } + console.log(newarrpoll) + + } else if (object.question.question_type === 3) { + //插入主观题 + var answers = []; + var questiontwo = {}; + + if (object.question.answers.length > 0) { + for (var y = 0; y < object.question.answers.length; y++) { + var answerstwo; + if (object.question.answers[y].answer_text === "其他") { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + } else { + answerstwo = { + "answer_id": object.question.answers[y].answer_id, + "answer_position": object.question.answers[y].answer_position, + "answer_text": object.question.answers[y].answer_text + } + } + answers.push(answerstwo); + } + } + questiontwo = { + "id": object.question.id, + "is_necessary": object.question.is_necessary, + "question_number": 3, + "question_title": object.question.question_title, + "question_type": 3, + "new": "", + "answers": answers + }; + question = {"question": questiontwo}; + if (uuk !== -1) { + console.log("修改") + this.edittotheserver(object, 3, null, null, 0, 0); + newarrpoll.splice(uuk, 1, question); + } else { + console.log("删除") + this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id); + newarrpoll.push(question); + } + console.log(newarrpoll) + + } + + } + + + //添加到上面列表中 + //改变题目总数 + if (object.question.question_type === 1) { + //单选题 + this.state.mysingles = this.state.mysingles + 1; + } else if (object.question.question_type === 2) { + //多选题 + this.state.mydoubles = this.state.mydoubles + 1; + } else if (object.question.question_type === 3) { + //主观题 + this.state.mymainsint = this.state.mymainsint + 1; + + } + + //这里更新数据 + if (this.state.q_countst == 1) { + this.setState({ + q_countst: 0, + }) + } + this.deleteadddom(indexo); + // console.log(indexo) + } + + + ////新增到服务器中 + createquestionsandanswers = (object, number, option, other, max_choices, min_choices, insert_id) => { + var thiss = this; + var poll_id = this.state.pollid; + var urlly = `/polls/${poll_id}/poll_questions.json` + var max_choicess = null; + var min_choicess = null; + if (max_choices === 0 && min_choices === 0) { + max_choicess = null; + min_choicess = null; + } else { + max_choicess = max_choices; + min_choicess = min_choices; + } + axios.post(urlly, { + question_title: object.question.question_title, + question_type: number, + is_necessary: object.question.is_necessary, + max_choices: max_choicess, + min_choices: min_choicess, + question_answers: option, + question_other_answer: null, + insert_id: insert_id + }).then((result) => { + // try { + if (result !== undefined) { + if (result.data.status === 0) { + this.props.showNotification(`已完成`); + thiss.thisinitializationdatanew(); + // console.log("确认创建问题") + // console.log(result) + // try { + // if (result.data.status === 0) { + // console.log("确认创建问题") + // console.log(JSON.stringify(result.data)) + // } + // } catch (e) { + // + // } + } + } + // } catch (e) { + // + // } + + }) + + + } + ///编辑修改到服务器当中 + edittotheserver = (object, number, option, other, max_choices, min_choices) => { + console.log("调用了edittotheserver") + var url = `/poll_questions/${object.question.id}.json` + var thiss = this; + axios.put(url, { + // debug: true, + question_title: object.question.question_title, + question_type: number, + is_necessary: object.question.is_necessary, + max_choices: max_choices, + min_choices: min_choices, + question_answers: option, + question_other_answer: null, + }).then((result) => { + try { + if (result.data.status === 0) { + this.props.showNotification(`编辑题目成功`); + thiss.thisinitializationdatanew(); + } + } catch (e) { + // console.log("调用了edittotheserver") + console.log(e) + } + }) + } + + //删除到服务器当中 + eletetoserver = (pollid, newarr, type, index) => { + console.log("调用了eletetoserver") + var id = pollid; + var url = `/poll_questions/${id}.json` + let {mysingles, mydoubles, mymainsint} = this.state + var thiss = this; + + axios + .delete(url, {}) + .then(function (response) { + console.log(response) + if (response === undefined) { + return; + } + if (response.data.message === "删除成功") { + thiss.props.showNotification(`删除成功`); + + newarr.splice(index, 1); + if (type === 1) { + mysingles = mysingles - 1; + } else if (type === 2) { + mydoubles = mydoubles - 1; + + } else if (type === 3) { + mymainsint = mymainsint - 1; + + } + // thiss.setState({ + // poll_questions: newarr, + // mysingles: mysingles, + // mydoubles: mydoubles, + // mymainsint: mymainsint + // }); + thiss.thisinitializationdatanew(); + } + }) + } + + //上下移到服务器中 + Upanddownmovementof = (bool, poll_question_id) => { + // console.log("调用了Upanddownmovementofr") + // console.log(poll_question_id) + var thiss = this; + if (bool === true) { + var url = `/poll_questions/${poll_question_id}/up_down.json`; + 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) + } + + }) + } 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) + } + }) + } + + } + + //删除编辑新增条目 + //id 条目的唯一id + //i 为要删除的子条目 + deleteentrys = (id, i, stirngname) => { + console.log(id) + console.log(stirngname); + var arrtwoy = this.state.adddom; + let newarrtwoy = [...arrtwoy]; + for (var k = 0; k < newarrtwoy.length; k++) { + if (newarrtwoy[k] != undefined) { + if (newarrtwoy[k].question.id === id) { + for (var c = 0; c < newarrtwoy[k].question.answers.length; c++) { + if (c === i) { + // console.log("删除了") + // console.log(c) + newarrtwoy[k].question.answers.splice(c, 1); + } + } + } + } + } + if (stirngname === true) { + console.log(stirngname); + this.setState({ + newoption: false, + adddom: newarrtwoy, + + }) + } else { + console.log(stirngname); + this.setState({ + adddom: newarrtwoy, + }); + } + + + } + + + // 新增选项 + ewoption = (id, object) => { + console.log("ewoption 440") + console.log("是否是新建题目还是编辑") + // console.log(object.question.new) + + + let arrtwo = this.state.adddom; + let newarrtwo = [...arrtwo]; + + + for (var k = 0; k < newarrtwo.length; k++) { + // console.log(arrtwo[k].question.id); + if (newarrtwo[k] != undefined) { + if (newarrtwo[k].question.id === id) { + var data = { + "answer_id": newarrtwo[k].question.answers.length + 1, + "answer_position": newarrtwo[k].question.answers.length + 1, + "answer_text": "" + }; + //向头部添加元素 + // newarrtwo[k].question.answers.unshift(data); + //如果有其他这一项就删除掉 + if (newarrtwo[k].question.answers.length > 0) { + for (var o = 0; o < newarrtwo[k].question.answers.length; o++) { + if (newarrtwo[k].question.answers[o].answer_text != undefined) { + if (newarrtwo[k].question.answers[o].answer_text === "其他") { + newarrtwo[k].question.answers.splice(o, 0, data); + this.setState({ + adddom: newarrtwo + }) + return + } else { + if (o === newarrtwo[k].question.answers.length - 1) { + newarrtwo[k].question.answers.push(data); + this.setState({ + adddom: newarrtwo + }) + return + } + } + } + } + } else { + newarrtwo[k].question.answers.push(data); + this.setState({ + adddom: newarrtwo + }) + } + + } + } + } + + } + + + swapArray = (arr, index1, index2) => { + arr[index1] = arr.splice(index2, 1, arr[index1])[0]; + return arr; + } + + //新增其他选项 + addanotheroption = (id) => { + console.log("addanotheroption 457") + let arrtwo = this.state.adddom; + let newarrtwo = [...arrtwo]; + console.log(newarrtwo) + for (var k = 0; k < newarrtwo.length; k++) { + if (newarrtwo[k] != undefined) { + if (newarrtwo[k].question.id === id) { + var data = { + "answer_id": newarrtwo[k].question.answers.length + 1, + "answer_position": newarrtwo[k].question.answers.length + 1, + "answer_text": "其他" + }; + newarrtwo[k].question.answers.push(data); + } + } + } + this.setState({ + adddom: newarrtwo, + newoption: true, + }) + } + + + //点击向上排序按钮事件 + handleClickBySortUp = (index, object) => { + console.log("handleClickBySortUp 521") + 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, + }); + } + } + + //点击向下排序按钮事件 + handleClickBySortDown = (index, object) => { + console.log("handleClickBySortDown 536") + let arr = this.state.poll_questions; + let newarr = [...arr]; + // + 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, + }); + } else { + console.log("2222index==arr.length"); + console.log(this.state.poll_questions); + } + } + + //点击删除按钮事件 + handleClickByDelete = (type, index, object) => { + console.log("handleClickByDelete 556") + console.log("object.question.id") + console.log(object.question.id) + let arr = this.state.poll_questions; + let newarr = [...arr]; + this.eletetoserver(object.question.id, newarr, type, index) + + } + + // 数字输入监听 + //e为获取组件对象 + //i外层数组 + //k为内层数组 + handleInputChanges = (e, i, k) => { + console.log("handleInputChanges 612") + + let value = e.target.value;//取到input的数据 + console.log("handleInputChanges value is :" + value); + console.log(k); + let arr = this.state.adddom; + let newarr = [...arr]; + + newarr[i].question.answers[k].answer_text = value + this.setState({ + adddom: newarr + }) + + } + + //标题输入监听 + handleInputTopic = (e, i) => { + console.log("handleInputTopic 633") + + let value = e.target.value;//取到input的数据 + console.log("handleInputTopic value is :" + value); + console.log(i); + let arr = this.state.adddom; + let newarr = [...arr]; + newarr[i].question.question_title = value + this.setState({ + adddom: newarr + }) + } + + //最小值 + handleGradationGroupChangee = (value, index, max, length) => { + + debugger + var minbool = false; + var maxbool = false; + let arr = this.state.adddom; + if (parseInt(value) === 0 || parseInt(value) === "0" || parseInt(value) === null || parseInt(value) === undefined || parseInt(value) < 1) { + minbool = true; + } + if (max === 0 || max === "0" || max === null || max === undefined) { + maxbool = true; + } + + if (minbool === true && maxbool === true) { + for (var i = 0; i < arr.length; i++) { + if (index === i) { + arr[i].question.min_choices = parseInt(value); + } + } + this.setState({ + adddom: arr + }) + } else { + for (var i = 0; i < arr.length; i++) { + if (index === i) { + arr[i].question.min_choices = parseInt(value); + arr[i].question.max_choices = length; + } + } + this.setState({ + adddom: arr + }) + } + + } + + //最大值 + handleGradationGroupChangeee = (value, index) => { + + let arr = this.state.adddom; + for (var i = 0; i < arr.length; i++) { + if (index === i) { + arr[i].question.max_choices = parseInt(value); + } + } + this.setState({ + adddom: arr + }) + // console.log(this.state.adddom); + } + + //提交题目//没有就创建新的题库,新建问题和保存题目不一样不能同时保存 这里只是新建 和编辑 标题和须知 + submitQuestionnaire = () => { + console.log("调用了submitQuestionnaire") + if (this.state.Newedit === true) { + + this.newword(); + + } else { + if (this.state.polls_nametest === undefined || this.state.polls_nametest === "") { + this.props.showNotification("请输入标题"); + return + } + + if (this.state.polls_descriptiontest.length > 100) { + + } + var pollid; + if (this.state.pollid === undefined) { + pollid = this.props.match.params.pollid; + } else { + pollid = this.state.pollid; + } + + + var url = `/polls/${pollid}.json`; + axios.put(url, { + polls_name: this.state.polls_nametest, + polls_description: this.state.polls_descriptiontest + }).then((result) => { + try { + // console.log(JSON.stringify(result)) + if (result.data.status === 0) { + // console.log("更新题目成功") + // this.props.showNotification("保存成功"); + this.props.history.push(`/courses/${this.props.match.params.coursesId}/polls/${pollid}/detail?tab=2`) + } + } catch (e) { + + } + }) + } + } + + cancelmodel = () => { + + this.setState({ + Modalstype: false, + Modalstopval: "", + ModalsBottomval: "", + }) + + } + savedelete = (question_type, index, item) => { + console.log("savedelete"); + this.handleClickByDelete(question_type, index, item); + this.setState({ + Modalstype: false, + Modalstopval: "", + ModalsBottomval: "", + }) + } + // 问题的类型,1单选题,2为多选题,3为主观题 + showDeleteConfirm = (question_type, index, item) => { + this.setState({ + Modalstype: true, + Modalstopval: "是否确认删除?", + ModalsBottomval: "", + ModalCancel: this.cancelmodel, + ModalSave: () => this.savedelete(question_type, index, item), + }) + + } + //必答选项 + onCheckAllChange = (e, index) => { + console.log("onCheckAllChange"); + console.log(e.target.checked); + // console.log(e.target.value); + let arr = this.state.adddom; + for (var i = 0; i < arr.length; i++) { + if (index === i) { + if (e.target.checked === true) { + arr[i].question.is_necessary = 1; + + } else { + arr[i].question.is_necessary = 0; + } + } + } + this.setState({ + adddom: arr + }) + } + + //重新编辑标题和须知 + adddomeditit = () => { + if (this.state.mysave === true) { + this.setState({ + mysave: false, + readOnlys: "readOnly", + storagedesc:this.state.polls_nametest, + storagedesctwo:this.state.polls_descriptiontest, + }) + } else if (this.state.mysave === false) { + this.setState({ + mysave: true, + readOnlys: "", + storagedesc:this.state.polls_nametest, + storagedesctwo:this.state.polls_descriptiontest, + }) + } + } + //取消保存 + onSaveExercisetwo = () => { + if (this.state.mysave === true) { + this.setState({ + mysave: false, + Newedit: false, + readOnlys: "readOnly", + polls_nametest:this.state.storagedesc, + polls_descriptiontest:this.state.storagedesctwo, + }) + } else { + this.setState({ + mysave: false, + Newedit: false, + readOnlys: "readOnly", + polls_nametest:this.state.storagedesc, + polls_descriptiontest:this.state.storagedesctwo, + }) + } + } + // 创建问卷 + 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, + }) + + + }) + } else { + if (this.state.polls_nametest === undefined || this.state.polls_nametest === "") { + this.props.showNotification("请输入标题"); + return + } + + var pollid; + if (this.state.pollid === undefined) { + pollid = this.props.match.params.pollid; + } else { + pollid = this.state.pollid; + } + + + var url = `/polls/${pollid}.json`; + axios.put(url, { + polls_name: this.state.polls_nametest, + polls_description: this.state.polls_descriptiontest + }).then((result) => { + if (result !== undefined) { + this.props.showNotification(`问卷更新成功!`); + this.setState({ + mysave: false, + readOnlys: "readOnly", + }) + } + + }) + } + + } + + //试图 + render() { + let { + addonAfter, + user_permission, + polls_status, + Modalstype, + mysave, + readOnlys, + newoption, + cancellation, + } = this.state + //获取老师权限 + // console.log("[`${maps[polls_status && polls_status]}`]]"); + // console.log(polls_status); + // console.log([[`${maps[polls_status && polls_status]}`]] + ""); + + const IsAdmin = this.props.isAdmin(); + const {getFieldDecorator} = this.props.form; + const formItemLayout = { + labelCol: { + xs: {span: 24}, + // sm: { span: 8 }, + sm: {span: 24}, + }, + wrapperCol: { + xs: {span: 24}, + // sm: { span: 16 }, + sm: {span: 24}, + }, + }; + + const radioStyle = { + display: 'block', + height: '30px', + lineHeight: '30px', + }; + + // console.log(this.state.projects===undefined?"":this.state.projects.poll_questions) + var displaymysave = (mysave === true) ? "" : "display:none;"; + return ( +
    + {/*提示*/} + {Modalstype && Modalstype === true ? : ""} +
    +

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

    +
    +

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

    + 返回 +
    + + {/*
    */} +
    + +
    + + +
    问卷须知
    + + + { + this.state.Newedit === true || this.state.mysave === true ? +
    + + {cancellation === false ? + + : ""} + +
    + : "" + } + +
    + +
    +

    + + + { + this.state.mysingles + this.state.mydoubles + this.state.mymainsint === 0 ? "" : +

    + + {this.state.mysingles === 0 ? "" : 单选题{this.state.mysingles === undefined ? "" : this.state.mysingles} 题} + + {this.state.mydoubles === 0 ? "" : + 多选题{this.state.mydoubles === undefined ? "" : this.state.mydoubles}题} + {this.state.mymainsint === 0 ? "" : + + 主观题{this.state.mymainsint === undefined ? "" : this.state.mymainsint}题 + + } + + + 合计 {this.state.mysingles === undefined ? "" : this.state.mydoubles === undefined ? "" : this.state.mymainsint === undefined ? "" : this.state.mysingles + this.state.mydoubles + this.state.mymainsint} +
    + + } + +

    +
    + + {/*自动生成修改好的获取到的*/} + {/**************************************************************************/} + {this.state.poll_questions === undefined ? "" : this.state.poll_questions.map((item, index) => { + // console.log('打印this.state.poll_questions') + // console.log(item.question) + let resultDom; + resultDom =
    +

    + 第{index + 1}题: + {item.question.question_type === 1 ? "(单选题)" : item.question.question_type === 2 ? "(多选题)" : "(主观题)"} + {item.question.is_necessary === 1 ? "必答" : item.question.question_type === 2 ? "选答" : "选答"} + {(item.question.min_choices === undefined && item.question.max_choices === undefined ? "" : item.question.min_choices === null && item.question.max_choices === null ? "" : item.question.min_choices === 0 && item.question.max_choices === 0 ? "" : "可选" + item.question.min_choices + "-" + item.question.max_choices + "项")} + { + polls_status === undefined || polls_status === 1 ? + + this.showDeleteConfirm(item.question.question_type, index, item)}> + {index === 0 ? "" : + this.handleClickBySortUp(index, item)}>} + {index === this.state.poll_questions.length - 1 ? "" : + this.handleClickBySortDown(index, item)}>} + this.addMytopic(item.question.question_type, this.state.pollid, index + 1, true, item.question.id)}> + this.adddomedit(item)}> + : this.adddomedit(item)}> + } + +

    +

    {item.question.question_title}

    + {/*
    {item.question.question_title}
    */} + {item.question.question_type === 1 ? + ( + {item.question.answers === undefined ? "" : item.question.answers.map((items, i) => { + return ( +
    + + {/*
    {items.answer_text}
    */} + {/*
    {items.answer_text}
    */} + {items.answer_text} + +
    + ) + })} +
    ) + : item.question.question_type === 2 ? + ( + {item.question.answers === undefined ? "" : item.question.answers.map((items, i) => { + return ( +
    + + {items.answer_text} + + {/*{items.answer_text}*/} +
    + ) + })} +
    ) + : item.question.question_type === 3 ? (
    ) : (
    )} +
    + + return ( +
    + {resultDom} +
    + ) + })} + {/**************************************************************************/} + {/*编辑用的新增用的*/} + {/**************************************************************************/} + + {this.state.adddom === undefined ? "" : this.state.adddom.map((itemo, indexo) => { + // console.log('打印this.state.adddom') + // console.log(itemo.question) + let arrid = itemo.question.id; + let resultDomtwo; + resultDomtwo = +
    + {itemo.question.question_type === 1 ? "单选题" : itemo.question.question_type === 2 ? "多选题" : "主观题"} + this.onCheckAllChange(e, indexo)} + className="lineh-40" + style={{"marginLeft": "20px"}}>必答 + + + + + {itemo.question.answers === undefined ? "" : itemo.question.answers.map((itemt, indext) => { + return ( +
    + {itemt.answer_text === undefined ? ( +
    ) : itemt.answer_text === "其他" ? ( +

    + 其它 + + + {polls_status === undefined || polls_status === 1 ? + this.deleteentrys(arrid, indext, true)}> + : ""} +

    ) : (

    + 选项 + + + {polls_status === undefined || polls_status === 1 ? + this.deleteentrys(arrid, indext, false)}> + : ""} +

    )} +
    + ) + })} + +
    + {itemo.question.question_type === 1 ? ( +
    +
    + {polls_status === undefined || polls_status === 1 ? + this.ewoption(itemo.question.id, itemo)}>新增选项 + + : ""} + {polls_status === undefined || polls_status === 1 ? + + (newoption === false ? + this.addanotheroption(itemo.question.id)}>新增其他选项 + : "") + : ""} + + this.deleteadddom(indexo)}>取消 + this.deleteadddomthree(indexo, itemo)}>保存 + this.deleteadddomtwo(indexo, itemo)}>保存并继续 + +
    +
    + + + ) + + + : itemo.question.question_type === 2 ? ( + //////////////////////////////////////////// 可选 +
    +
    +
    + 可选 +
    + {/*可选最小*/} + + + ~ + {/*可选最大*/} + + + (学生答题时,系统对其选择的选项个数进行限制,--表示不限制) +
    + +
    +
    +
    + ) + + : (
    ) + + } +
    +
    + {itemo.question.question_type === 2 ? + ( + polls_status === undefined || polls_status === 1 ? +
    + +
    this.ewoption(itemo.question.id, itemo)}>新增选项 + + { + newoption === false ? this.addanotheroption(itemo.question.id)}>新增其他选项 : "" + } + +
    + + + + this.deleteadddom(indexo)}>取消 + this.deleteadddomthree(indexo, itemo)}>保存 + this.deleteadddomtwo(indexo, itemo)}>保存并继续 + +
    + + + : "" + ) + + : itemo.question.question_type === 3 ? +
    + + this.deleteadddom(indexo)}>取消 + this.deleteadddomthree(indexo, itemo)}>保存 + this.deleteadddomtwo(indexo, itemo)}>保存并继续 + +
    + : + ""} + + +
    +
    + + + return ( +
    + {resultDomtwo} +
    + ) + })} + {/**************************************************************************/} + + {polls_status === undefined || polls_status === 1 ? +
    + { + this.props.match.params.news === "new" ? + this.state.Newedit === false ? +
    +
    + +
    + this.addmysingles()}>单选题 + this.addmydoubles()}>多选题 + this.addmymainsint()}>主观题 +
    +
    + + : "" + : +
    +
    +
    + this.addmysingles()}>单选题 + this.addmydoubles()}>多选题 + this.addmymainsint()}>主观题 +
    +
    + } +
    + :
    } +
    + { + this.props.match.params.news === "new" ? + (this.state.Newedit === false ? + + + : "") + : + + } + + {/*
    */} +
    +
    +
    + ) + } + +} + +const WrappedPollNew = Form.create({name: 'taskPollNew'})(PollNew); +// RouteHOC() export default (WrappedPollNew); \ No newline at end of file diff --git a/public/react/src/modules/courses/shixunHomework/TraineetraininginformationModal.js b/public/react/src/modules/courses/shixunHomework/TraineetraininginformationModal.js index 735e3f396..7d34eb9a1 100644 --- a/public/react/src/modules/courses/shixunHomework/TraineetraininginformationModal.js +++ b/public/react/src/modules/courses/shixunHomework/TraineetraininginformationModal.js @@ -52,7 +52,26 @@ class TraineetraininginformationModal extends Component { // this.seacthdata(); } + componentWillReceiveProps(nextProps) { + // console.log("46"); + // console.log(nextProps); + // console.log(this.props); + if (nextProps.boolgalist != this.props.boolgalist) { + // console.log("50"); + // console.log(nextProps.user); + if (nextProps.boolgalist !== undefined) { + // console.log("53"); + // console.log(nextProps.user); + this.setState({ + boolgalist: nextProps.boolgalist, + }) + } + + } + + + } LimitNumber=(txt)=> { var str = txt; if(str.length>25){ @@ -62,7 +81,7 @@ class TraineetraininginformationModal extends Component { } render() { var columns; - if(this.props.boolgalis&&this.props.boolgalist === true) { + if(this.state.boolgalist&&this.state.boolgalist === true) { columns = [ { title: '关卡', From f2e7ebb3768d97f5b95c5a1ab6e9691085d66508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Wed, 26 Jun 2019 17:43:18 +0800 Subject: [PATCH 26/27] =?UTF-8?q?=20=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/public/index.html | 8 +- public/react/public/index.test.html | 2 +- public/react/src/common/UrlTool.js | 101 +- .../page/component/monaco/TPIMonaco.js | 1017 +++++++++-------- public/react/src/modules/page/main/Webssh.js | 149 +-- public/react/src/modules/tpm/TPMIndexHOC.js | 11 +- 6 files changed, 644 insertions(+), 644 deletions(-) diff --git a/public/react/public/index.html b/public/react/public/index.html index 028b1cb68..bafefaf47 100755 --- a/public/react/public/index.html +++ b/public/react/public/index.html @@ -55,7 +55,7 @@ - + @@ -148,12 +148,12 @@ (function() { // Scoping function to avoid globals var href = location.href; if (href.indexOf('/tasks/') != -1) { - document.write('