From 6932fe697c9180f9621850446da82f75706774e3 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Sat, 9 May 2020 15:04:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=AF=95=E5=8D=B7=E3=80=81?= =?UTF-8?q?=E9=97=AE=E5=8D=B7=E6=A8=A1=E5=9D=97=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/courses/Index.js | 1390 +++--- src/modules/courses/boards/AddDirModal.js | 89 - src/modules/courses/boards/BoardsListItem.js | 112 - src/modules/courses/boards/BoardsNew.js | 518 -- src/modules/courses/boards/BoardsNewTemp.js | 202 - src/modules/courses/boards/TopicDetail.css | 15 - src/modules/courses/boards/TopicDetail.js | 746 --- src/modules/courses/boards/board.css | 46 - src/modules/courses/boards/boardsListItem.css | 9 - src/modules/courses/boards/common.js | 66 - src/modules/courses/boards/index.js | 437 -- .../courses/exercise/Ecerciseallbackagain.js | 275 -- src/modules/courses/exercise/Ecercisemount.js | 247 - src/modules/courses/exercise/Exercise.js | 597 --- .../courses/exercise/ExerciseDisplay.js | 182 - .../courses/exercise/ExerciseListItem.js | 268 - src/modules/courses/exercise/ExerciseNew.js | 57 - .../courses/exercise/ExerciseNewCommon.js | 553 --- .../exercise/ExerciseReviewAndAnswer.js | 1048 ---- .../courses/exercise/Exercisesetting.js | 918 ---- .../exercise/Exercisestatisticalresult.js | 367 -- .../Exercisestatisticalresulttabel.js | 190 - .../courses/exercise/Exercisetablesmubu.js | 142 - .../exercise/Studentshavecompletedthelist.js | 3396 ------------- .../exercise/Testpapersettinghomepage.js | 532 -- .../exercise/exercise-new-form/index.jsx | 64 - .../exercise/exercise-new-form/index.scss | 43 - .../courses/exercise/new/JudgeDisplay.js | 44 - .../courses/exercise/new/JudgeEditor.js | 197 - .../courses/exercise/new/MainDisplay.js | 42 - .../courses/exercise/new/MainEditor.js | 189 - .../courses/exercise/new/NullChildEditor.js | 55 - .../courses/exercise/new/NullDisplay.js | 40 - .../courses/exercise/new/NullEditor.js | 367 -- .../courses/exercise/new/NullMDEditor.js | 58 - .../exercise/new/QestionDisplayHeader.js | 67 - .../courses/exercise/new/ShixunDisplay.js | 106 - .../courses/exercise/new/ShixunEditor.js | 288 -- .../courses/exercise/new/ShixunProgramming.js | 94 - .../courses/exercise/new/SingleDisplay.js | 60 - .../courses/exercise/new/SingleEditor.js | 321 -- src/modules/courses/exercise/new/common.css | 77 - src/modules/courses/exercise/new/common.js | 17 - .../courses/exercise/new/editorCommon.css | 0 .../courses/exercise/question/Progques.js | 58 - .../exercise/question/ShixunProgrDetail.js | 91 - .../exercise/question/ShowProgramming.js | 146 - .../courses/exercise/question/fillEmpty.js | 153 - .../courses/exercise/question/multiple.js | 94 - .../courses/exercise/question/shixunAnswer.js | 339 -- .../exercise/question/shixunAnswerDetail.js | 70 - .../courses/exercise/question/simpleAnswer.js | 88 - .../courses/exercise/question/single.js | 93 - .../courses/exercise/yslexercisetable.css | 62 - src/modules/courses/poll/Poll.js | 631 --- src/modules/courses/poll/PollDetailIndex.js | 306 -- .../courses/poll/PollDetailTabFirst.js | 422 -- .../courses/poll/PollDetailTabForth.js | 681 --- .../courses/poll/PollDetailTabForthRules.js | 534 -- .../courses/poll/PollDetailTabSecond.js | 197 - .../courses/poll/PollDetailTabThird.js | 58 - .../courses/poll/PollDetailTabThirdInfo.js | 138 - src/modules/courses/poll/PollInfo.js | 519 -- src/modules/courses/poll/PollListItem.js | 133 - src/modules/courses/poll/PollNew.js | 3960 --------------- src/modules/courses/poll/PollNewQuestbank.js | 4312 ----------------- .../poll/pollPublicBtn/CancelPublish.js | 205 - .../poll/pollPublicBtn/ImmediatelyEnd.js | 269 - .../poll/pollPublicBtn/ImmediatelyPublish.js | 413 -- src/modules/courses/poll/pollStyle.css | 382 -- 70 files changed, 619 insertions(+), 28266 deletions(-) delete mode 100644 src/modules/courses/boards/AddDirModal.js delete mode 100644 src/modules/courses/boards/BoardsListItem.js delete mode 100644 src/modules/courses/boards/BoardsNew.js delete mode 100644 src/modules/courses/boards/BoardsNewTemp.js delete mode 100644 src/modules/courses/boards/TopicDetail.css delete mode 100644 src/modules/courses/boards/TopicDetail.js delete mode 100644 src/modules/courses/boards/board.css delete mode 100644 src/modules/courses/boards/boardsListItem.css delete mode 100644 src/modules/courses/boards/common.js delete mode 100644 src/modules/courses/boards/index.js delete mode 100644 src/modules/courses/exercise/Ecerciseallbackagain.js delete mode 100644 src/modules/courses/exercise/Ecercisemount.js delete mode 100644 src/modules/courses/exercise/Exercise.js delete mode 100644 src/modules/courses/exercise/ExerciseDisplay.js delete mode 100644 src/modules/courses/exercise/ExerciseListItem.js delete mode 100644 src/modules/courses/exercise/ExerciseNew.js delete mode 100644 src/modules/courses/exercise/ExerciseNewCommon.js delete mode 100644 src/modules/courses/exercise/ExerciseReviewAndAnswer.js delete mode 100644 src/modules/courses/exercise/Exercisesetting.js delete mode 100644 src/modules/courses/exercise/Exercisestatisticalresult.js delete mode 100644 src/modules/courses/exercise/Exercisestatisticalresulttabel.js delete mode 100644 src/modules/courses/exercise/Exercisetablesmubu.js delete mode 100644 src/modules/courses/exercise/Studentshavecompletedthelist.js delete mode 100644 src/modules/courses/exercise/Testpapersettinghomepage.js delete mode 100644 src/modules/courses/exercise/exercise-new-form/index.jsx delete mode 100644 src/modules/courses/exercise/exercise-new-form/index.scss delete mode 100644 src/modules/courses/exercise/new/JudgeDisplay.js delete mode 100644 src/modules/courses/exercise/new/JudgeEditor.js delete mode 100644 src/modules/courses/exercise/new/MainDisplay.js delete mode 100644 src/modules/courses/exercise/new/MainEditor.js delete mode 100644 src/modules/courses/exercise/new/NullChildEditor.js delete mode 100644 src/modules/courses/exercise/new/NullDisplay.js delete mode 100644 src/modules/courses/exercise/new/NullEditor.js delete mode 100644 src/modules/courses/exercise/new/NullMDEditor.js delete mode 100644 src/modules/courses/exercise/new/QestionDisplayHeader.js delete mode 100644 src/modules/courses/exercise/new/ShixunDisplay.js delete mode 100644 src/modules/courses/exercise/new/ShixunEditor.js delete mode 100644 src/modules/courses/exercise/new/ShixunProgramming.js delete mode 100644 src/modules/courses/exercise/new/SingleDisplay.js delete mode 100644 src/modules/courses/exercise/new/SingleEditor.js delete mode 100644 src/modules/courses/exercise/new/common.css delete mode 100644 src/modules/courses/exercise/new/common.js delete mode 100644 src/modules/courses/exercise/new/editorCommon.css delete mode 100644 src/modules/courses/exercise/question/Progques.js delete mode 100644 src/modules/courses/exercise/question/ShixunProgrDetail.js delete mode 100644 src/modules/courses/exercise/question/ShowProgramming.js delete mode 100644 src/modules/courses/exercise/question/fillEmpty.js delete mode 100644 src/modules/courses/exercise/question/multiple.js delete mode 100644 src/modules/courses/exercise/question/shixunAnswer.js delete mode 100644 src/modules/courses/exercise/question/shixunAnswerDetail.js delete mode 100644 src/modules/courses/exercise/question/simpleAnswer.js delete mode 100644 src/modules/courses/exercise/question/single.js delete mode 100644 src/modules/courses/exercise/yslexercisetable.css delete mode 100644 src/modules/courses/poll/Poll.js delete mode 100644 src/modules/courses/poll/PollDetailIndex.js delete mode 100644 src/modules/courses/poll/PollDetailTabFirst.js delete mode 100644 src/modules/courses/poll/PollDetailTabForth.js delete mode 100644 src/modules/courses/poll/PollDetailTabForthRules.js delete mode 100644 src/modules/courses/poll/PollDetailTabSecond.js delete mode 100644 src/modules/courses/poll/PollDetailTabThird.js delete mode 100644 src/modules/courses/poll/PollDetailTabThirdInfo.js delete mode 100644 src/modules/courses/poll/PollInfo.js delete mode 100644 src/modules/courses/poll/PollListItem.js delete mode 100644 src/modules/courses/poll/PollNew.js delete mode 100644 src/modules/courses/poll/PollNewQuestbank.js delete mode 100644 src/modules/courses/poll/pollPublicBtn/CancelPublish.js delete mode 100644 src/modules/courses/poll/pollPublicBtn/ImmediatelyEnd.js delete mode 100644 src/modules/courses/poll/pollPublicBtn/ImmediatelyPublish.js delete mode 100644 src/modules/courses/poll/pollStyle.css diff --git a/src/modules/courses/Index.js b/src/modules/courses/Index.js index 7117f55f..e86d56aa 100644 --- a/src/modules/courses/Index.js +++ b/src/modules/courses/Index.js @@ -1,96 +1,96 @@ import React, { Component } from 'react'; import { SnackbarHOC } from 'educoder'; -import {BrowserRouter as Router,Route,Switch} from 'react-router-dom'; +import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; import { withRouter } from 'react-router' import Loadable from 'react-loadable'; import Loading from '../../Loading'; import axios from 'axios'; import { TPMIndexHOC } from '../tpm/TPMIndexHOC'; import { CNotificationHOC } from './common/CNotificationHOC' -import {ImageLayerOfCommentHOC} from '../page/layers/ImageLayerOfCommentHOC' +import { ImageLayerOfCommentHOC } from '../page/layers/ImageLayerOfCommentHOC' import "./css/Courses.css" //引入对应跳转的组件 //里面有资源 const ListPageIndex = Loadable({ - loader: () => import('./ListPageIndex'), - loading:Loading, + loader: () => import('./ListPageIndex'), + loading: Loading, }) //课堂首页 const CoursesHome = Loadable({ - loader: () => import('./coursesHome/CoursesHome'), - loading:Loading, + loader: () => import('./coursesHome/CoursesHome'), + loading: Loading, }) //课堂详情页 -const CoursesDetail= Loadable({ - loader: () => import('./coursesDetail/CoursesDetail'), - loading:Loading, +const CoursesDetail = Loadable({ + loader: () => import('./coursesDetail/CoursesDetail'), + loading: Loading, }) // 课堂讨论 -const BoardIndex = Loadable({ - loader: () => import('./BoardIndex'), - loading:Loading, -}) +// const BoardIndex = Loadable({ +// loader: () => import('./BoardIndex'), +// loading:Loading, +// }) -const GraduationTopics= Loadable({ - loader: () => import('./graduation/topics'), - loading: Loading, +const GraduationTopics = Loadable({ + loader: () => import('./graduation/topics'), + loading: Loading, }) -const GraduationTopicsDetail= Loadable({ - loader: () => import('./graduation/topics/GraduateTopicDetail'), - loading: Loading, +const GraduationTopicsDetail = Loadable({ + loader: () => import('./graduation/topics/GraduateTopicDetail'), + loading: Loading, }) -const GraduateTopicPostWorksNew= Loadable({ - loader: () => import('./graduation/topics/GraduateTopicPostWorksNew'), - loading: Loading, +const GraduateTopicPostWorksNew = Loadable({ + loader: () => import('./graduation/topics/GraduateTopicPostWorksNew'), + loading: Loading, }) -const GraduateTopicNew= Loadable({ - loader: () => import('./graduation/topics/GraduateTopicNew'), - loading: Loading, +const GraduateTopicNew = Loadable({ + loader: () => import('./graduation/topics/GraduateTopicNew'), + loading: Loading, }) -const GraduationTasks= Loadable({ - loader: () => import('./graduation/tasks'), - loading: Loading, +const GraduationTasks = Loadable({ + loader: () => import('./graduation/tasks'), + loading: Loading, }) // 资源 -const Resourcelist= Loadable({ - loader: () => import('./Resource/index'), - loading: Loading, +const Resourcelist = Loadable({ + loader: () => import('./Resource/index'), + loading: Loading, }) //新建实训 -const WrappedCoursesNewApp= Loadable({ - loader: () => import('./new/CoursesNew'), - loading: Loading, +const WrappedCoursesNewApp = Loadable({ + loader: () => import('./new/CoursesNew'), + loading: Loading, }) //新建精品课堂 -const WrappedCoursesNewAppGoldclass= Loadable({ +const WrappedCoursesNewAppGoldclass = Loadable({ loader: () => import('./new/Goldsubject'), loading: Loading, }) -const ShixunHomeworkPage =Loadable({ +const ShixunHomeworkPage = Loadable({ loader: () => import('./shixunHomework/ShixunHomeworkPage'), loading: Loading, }) //实训作业 -const ShixunHomework= Loadable({ - loader: () => import('./shixunHomework/shixunHomework'), - loading: Loading, +const ShixunHomework = Loadable({ + loader: () => import('./shixunHomework/shixunHomework'), + loading: Loading, }) //实训作业设置 -const Trainingjobsetting= Loadable({ - loader: () => import('./shixunHomework/Trainingjobsetting'), - loading: Loading, +const Trainingjobsetting = Loadable({ + loader: () => import('./shixunHomework/Trainingjobsetting'), + loading: Loading, }) //实训作业列表教师 @@ -100,108 +100,105 @@ const Trainingjobsetting= Loadable({ // loading: Loading, // }) //实训作业列表完成的 -const Studenthascompleted= Loadable({ - loader: () => import('./shixunHomework/Listofworksstudentone'), - loading: Loading, +const Studenthascompleted = Loadable({ + loader: () => import('./shixunHomework/Listofworksstudentone'), + loading: Loading, }) //实训作业提交总结 -const CommitSummary = Loadable({ - loader: () => import('./shixunHomework/CommitSummary'), - loading: Loading, +const CommitSummary = Loadable({ + loader: () => import('./shixunHomework/CommitSummary'), + loading: Loading, }) //实训作业设置 -const Workquestionandanswer= Loadable({ - loader: () => import('./shixunHomework/Workquestionandanswer'), - loading: Loading, +const Workquestionandanswer = Loadable({ + loader: () => import('./shixunHomework/Workquestionandanswer'), + loading: Loading, }) //实训报告 -const ShixunWorkReport= Loadable({ - loader: () => import('./shixunHomework/ShixunWorkReport'), - loading: Loading, +const ShixunWorkReport = Loadable({ + loader: () => import('./shixunHomework/ShixunWorkReport'), + loading: Loading, }) //实训查重 -const ShixunStudentWork= Loadable({ - loader: () => import('./shixunHomework/ShixunStudentWork'), - loading: Loading, +const ShixunStudentWork = Loadable({ + loader: () => import('./shixunHomework/ShixunStudentWork'), + loading: Loading, }) //实训查重详情 -const ShixunWorkDetails= Loadable({ - loader: () => import('./shixunHomework/ShixunWorkDetails'), - loading: Loading, +const ShixunWorkDetails = Loadable({ + loader: () => import('./shixunHomework/ShixunWorkDetails'), + loading: Loading, }) //问卷 -const Poll= Loadable({ - loader: () => import('./poll/Poll'), - loading: Loading, -}) +// const Poll = Loadable({ +// loader: () => import('./poll/Poll'), +// loading: Loading, +// }) //问卷新建 -const PollNew= Loadable({ - loader: () => import('./poll/PollNew'), - loading: Loading, -}) +// const PollNew = Loadable({ +// loader: () => import('./poll/PollNew'), +// loading: Loading, +// }) //问卷答题 -const PollInfo= Loadable({ - loader: () => import('./poll/PollInfo'), - loading: Loading, -}) +// const PollInfo = Loadable({ +// loader: () => import('./poll/PollInfo'), +// loading: Loading, +// }) //问卷详情 -const PollDetail= Loadable({ - loader: () => import('./poll/PollDetailIndex'), - loading: Loading, -}) +// const PollDetail = Loadable({ +// loader: () => import('./poll/PollDetailIndex'), +// loading: Loading, +// }) //试卷 -const Exercise= Loadable({ - loader: () => import('./exercise/Exercise'), - loading: Loading, -}) -const Testpapersettinghomepage =Loadable({ - loader: () => import('./exercise/Testpapersettinghomepage'), - loading: Loading, -}) -const ExerciseNew =Loadable({ - loader: () => import('./exercise/ExerciseNew'), - loading: Loading, -}) -const ExerciseReviewAndAnswer=Loadable({ - loader:() => import('./exercise/ExerciseReviewAndAnswer'), - loading: Loading, -}) + +// const Testpapersettinghomepage = Loadable({ +// loader: () => import('./exercise/Testpapersettinghomepage'), +// loading: Loading, +// }) +// const ExerciseNew = Loadable({ +// loader: () => import('./exercise/ExerciseNew'), +// loading: Loading, +// }) +// const ExerciseReviewAndAnswer = Loadable({ +// loader: () => import('./exercise/ExerciseReviewAndAnswer'), +// loading: Loading, +// }) //学生列表 -const Studentshavecompletedthelist = Loadable({ - loader: () => import('./exercise/Studentshavecompletedthelist'), - loading: Loading, +const Studentshavecompletedthelist = Loadable({ + loader: () => import('./exercise/Studentshavecompletedthelist'), + loading: Loading, }) //教师列表 -const TeacherList= Loadable({ - loader: () => import('./members/teacherList'), - loading: Loading, -}) -//学生列表 -const StudentsList= Loadable({ - loader: () => import('./members/studentsList'), - loading: Loading, -}) +// const TeacherList = Loadable({ +// loader: () => import('./members/teacherList'), +// loading: Loading, +// }) +// //学生列表 +// const StudentsList = Loadable({ +// loader: () => import('./members/studentsList'), +// loading: Loading, +// }) //普通作业 -const CommonWork= Loadable({ - loader: () => import('./busyWork/Index'), - loading: Loading, +const CommonWork = Loadable({ + loader: () => import('./busyWork/Index'), + loading: Loading, }) -const GroupWork= Loadable({ - loader: () => import('./busyWork/IndexGroup'), - loading: Loading, +const GroupWork = Loadable({ + loader: () => import('./busyWork/IndexGroup'), + loading: Loading, }) // @@ -212,160 +209,156 @@ const GroupWork= Loadable({ // }) //毕设任务列表新建 -const GraduationTaskseditApp= Loadable({ - loader: () => import('./graduation/tasks/GraduationTasksedit'), - loading: Loading, +const GraduationTaskseditApp = Loadable({ + loader: () => import('./graduation/tasks/GraduationTasksedit'), + loading: Loading, }) //毕设任务列表编辑 -const GraduationTasksnewApp= Loadable({ - loader: () => import('./graduation/tasks/GraduationTasksnew'), - loading: Loading, +const GraduationTasksnewApp = Loadable({ + loader: () => import('./graduation/tasks/GraduationTasksnew'), + loading: Loading, }) //毕设任务列表设置 -const GraduationTasksquestions= Loadable({ - loader: () => import('./graduation/tasks/GraduationTaskssettingquestions'), - loading: Loading, +const GraduationTasksquestions = Loadable({ + loader: () => import('./graduation/tasks/GraduationTaskssettingquestions'), + loading: Loading, }) //毕设任务列表 -const GraduationTaskssettinglist= Loadable({ - loader: () => import('./graduation/tasks/GraduationTaskDetail'), - loading: Loading, +const GraduationTaskssettinglist = Loadable({ + loader: () => import('./graduation/tasks/GraduationTaskDetail'), + loading: Loading, }) //毕业任务设置 -const GraduationTaskssetting=Loadable({ - loader: () => import('./graduation/tasks/GraduationTaskssetting'), - loading: Loading, -}) +// const GraduationTaskssetting = Loadable({ +// loader: () => import('./graduation/tasks/GraduationTaskssetting'), +// loading: Loading, +// }) // 评阅列表 -const GraduationTasksappraise=Loadable({ - loader: () => import('./graduation/tasks/GraduationTasksappraise'), - loading: Loading, +const GraduationTasksappraise = Loadable({ + loader: () => import('./graduation/tasks/GraduationTasksappraise'), + loading: Loading, }) //创建作品 -const GraduationTasksSubmitnewApp=Loadable({ - loader: () => import('./graduation/tasks/GraduationTasksSubmitnew'), - loading: Loading, +const GraduationTasksSubmitnewApp = Loadable({ + loader: () => import('./graduation/tasks/GraduationTasksSubmitnew'), + loading: Loading, }) //修改作品 -const GraduationTasksSubmiteditApp=Loadable({ - loader: () => import('./graduation/tasks/GraduationTasksSubmitedit'), - loading: Loading, +const GraduationTasksSubmiteditApp = Loadable({ + loader: () => import('./graduation/tasks/GraduationTasksSubmitedit'), + loading: Loading, }) //排序 -const Ordering=Loadable({ - loader: () => import('../../modules/courses/ordering/Ordering'), - loading: Loading, +const Ordering = Loadable({ + loader: () => import('../../modules/courses/ordering/Ordering'), + loading: Loading, }); -class CoursesIndex extends Component{ - constructor(props) { - super(props) - this.state={ - coursesids: undefined, - coursesidsfun:this.coursesidsfun, - updataleftNavfun:this.updataleftNav, - course_modules:undefined, - hidden_modules:[], - is_teacher:false, - isaloadtype:true, - coursesidtype:undefined, - locationNavfun:this.locationNav, - unlocationNavfun:this.unlocationNavfun - } +class CoursesIndex extends Component { + constructor(props) { + super(props) + this.state = { + coursesids: undefined, + coursesidsfun: this.coursesidsfun, + updataleftNavfun: this.updataleftNav, + course_modules: undefined, + hidden_modules: [], + is_teacher: false, + isaloadtype: true, + coursesidtype: undefined, + locationNavfun: this.locationNav, + unlocationNavfun: this.unlocationNavfun + } + } + + coursesidsfun = (id, type) => { + this.setState({ + coursesids: id, + coursesidtype: type + }) + } + + componentDidMount() { + this.historyArray = [window.location.pathname]; + + this.props.history.listen(location => { + this.historyArray.unshift(window.location.pathname); + this.historyArray.length = 2; + }); + } + //更新左边课堂导航 + updataleftNav = () => { + let query = this.props.location.pathname + let { isaloadtype } = this.state; + let types = isaloadtype === false ? true : false + const type = query.split('/'); + let id = parseInt(type[2]) + if (isNaN(id)) { + return } - coursesidsfun=(id,type)=>{ + const querys = this.props.location.search; + var dataqueryss = {} + try { + var foqus = this.foo(querys); + if (JSON.stringify(foqus) === "{}") { this.setState({ - coursesids:id, - coursesidtype:type - }) - } - - componentDidMount(){ - // this.updataleftNav() - this.historyArray = [window.location.pathname]; - - this.props.history.listen( location => { - this.historyArray.unshift(window.location.pathname); - this.historyArray.length = 2; - //Do your stuff here - }); - } - //更新左边课堂导航 - updataleftNav=()=>{ - let query=this.props.location.pathname - let {isaloadtype}=this.state; - let types=isaloadtype===false?true:false - const type = query.split('/'); - let id=parseInt(type[2]) - if(isNaN(id)){ - return - } - - const querys = this.props.location.search; - var dataqueryss={} - try { - var foqus=this.foo(querys); - if(JSON.stringify(foqus) ==="{}"){ - this.setState({ - dataquerys:{}, - }); - }else{ - this.setState({ - dataquerys:foqus, - }); - dataqueryss=foqus; - } - }catch (e) { + dataquerys: {}, + }); + } else { this.setState({ - dataquerys:{}, - }) + dataquerys: foqus, + }); + dataqueryss = foqus; } - // let id=this.props.match.params.coursesId; - let url ="/courses/"+id+"/left_banner.json" - axios.get(url, - {params: - dataqueryss - } - ).then((response) => { - if(response!=undefined){ - if(response.data&&response.data){ - this.setState({ - course_modules:response.data.course_modules, - hidden_modules:response.data.hidden_modules, - is_teacher:response.data.is_teacher, - isaloadtype:types - }) - this.locationNav(response.data.course_modules) - } - } - }) - }; - foo=(url)=> { + } catch (e) { + this.setState({ + dataquerys: {}, + }) + } + // let id=this.props.match.params.coursesId; + let url = "/courses/" + id + "/left_banner.json" + axios.get(url, + { + params: + dataqueryss + } + ).then((response) => { + if (response != undefined) { + if (response.data && response.data) { + this.setState({ + course_modules: response.data.course_modules, + hidden_modules: response.data.hidden_modules, + is_teacher: response.data.is_teacher, + isaloadtype: types + }) + this.locationNav(response.data.course_modules) + } + } + }) + }; + foo = (url) => { var json = {}; var regExp = /[\?\&](\w+)(=?)(\w*)/g; var arr; do { arr = regExp.exec(url); - // console.log(arr); // arr = [完整的字符串, key, 等号或'', value或''] - if (arr) { var key = arr[1]; var value = arr[3]; - // arr[2] === ''时, value = undefined if (!arr[2]) value = undefined; @@ -376,229 +369,108 @@ class CoursesIndex extends Component{ return json; }; - locationNav=(list)=>{ - if(list){ - let url=this.props.location.pathname; - const type = url.split('/'); - let filesId=parseInt(type[4]); - // let urls=this.props.match.url + locationNav = (list) => { + if (list) { + let url = this.props.location.pathname; + const type = url.split('/'); + let filesId = parseInt(type[4]); + var lists = list; - var lists=list; + lists.forEach((item, index) => { - lists.forEach((item,index)=>{ + if (url === item.category_url) { + this.setState({ + indexs: index, + mainurl: item.category_url + }) + this.coursesidsfun(item.id, "node") + } else { + if (item.second_category != undefined && item.second_category.length != 0) { + item.second_category.forEach((iem, key) => { + if (url === iem.second_category_url) { - if(url===item.category_url){ - this.setState({ - indexs:index, - mainurl:item.category_url - }) - this.coursesidsfun(item.id,"node") - }else{ - if(item.second_category!=undefined&&item.second_category.length!=0){ - item.second_category.forEach((iem,key)=>{ - if(url===iem.second_category_url){ - - if( parseInt(filesId)===iem.category_id||parseInt(filesId)===item.id){ - this.setState({ - indexs:index, - url:url, - mainurl:item.category_url - }) - } - this.coursesidsfun(item.id,"child") + if (parseInt(filesId) === iem.category_id || parseInt(filesId) === item.id) { + this.setState({ + indexs: index, + url: url, + mainurl: item.category_url + }) } - }) - } - + this.coursesidsfun(item.id, "child") + } + }) } - }) - } + } + }) } - unlocationNavfun=(val)=>{ - this.setState({ - indexs:val, - }) - } - // // 老师、管理员等 - // isAdmin = () => { - // return this.state.coursedata && this.state.coursedata.course_identity < 4 - // } - // // 学生 - // isStudent = () => { - // return this.state.coursedata && this.state.coursedata.course_identity === 4 - // } - // isAdminOrStudent = () => { - // return this.state.coursedata && this.state.coursedata.course_identity <= 4 - // } - // // 非课堂成员 - // isNotMember = () => { - // return this.state.coursedata && this.state.coursedata.course_identity === 5 - // } + } + unlocationNavfun = (val) => { + this.setState({ + indexs: val, + }) + } + render() { + const common = { + previousPathName: this.historyArray && this.historyArray[1] + } + return ( + + {/*排序*/} + () + } + > + {/*视频列表*/} + () + } + > + () + } + > + {/* 资源列表页 */} + () + } + > + () + } + > + {/* 作品评阅 https://www.trustie.net/issues/19981 */} + () + } + > - // isCourseidentity = () => { - // - // if(this.state.coursedata&&this.state.coursedata.course_identity < 4){ - // return "isAdmin" - // // 老师、管理员等 - // }else if(this.state.coursedata&&this.state.coursedata.course_identity === 4){ - // return "isStudent" - // // 学生 - // }else if(this.state.coursedata&&this.state.coursedata.course_identity === 5){ - // return "isNotMember" - // // 非课堂成员 - // } - // - // } + {/* 新建作品 */} + () + } + > + {/* 修改作品 */} + () + } + > - // componentDidMount(){ - // // console.log(this.props.location.pathname) - // let query=this.props.location.pathname; - // const type = query.split('/'); - // if (!type[2]) { - // return; - // } - // let id=parseInt(type[2]) - // - // let url="/courses/"+id+"/top_banner.json" - // axios.get(url).then((result)=>{ - // if(result.status===200){ - // let data=result.data; - // this.setState({ - // coursedata:data - // }) - // - // // console.log(data) - // } - // }).catch((error)=>{ - // console.log(error); - // }) + {/* 设置毕设任务 https://www.trustie.net/issues/19981 */} - // } - - render() { - const common = { - previousPathName: this.historyArray && this.historyArray[1] - // isAdmin: this.isAdmin, - // isStudent: this.isStudent, - // isAdminOrStudent: this.isAdminOrStudent, - - // isNotMember: this.isNotMember, - // isCourseidentity:this.isCourseidentity - } - // const commons = { - // admind: this.props.user, - // // isAdminOrStudent: this.isAdminOrStudent, - // - // // isNotMember: this.isNotMember, - // // isCourseidentity:this.isCourseidentity - // } - // console.log("commonscommons") - // console.log(commons) - return ( - - {/*排序*/} - () - } - > - {/*视频列表*/} - () - } - > - () - } - > - {/* 资源列表页 */} - () - } - > - () - } - > - () - } - > - {/*课堂讨论*/} - () - } - > - - {/* 毕业设计 */} - {/* 毕设问答 */} - () - } - > - - {/* 毕设选题新建页 */} - () - }> - {/* 毕设选题编辑页*/} - () - }> - - {/* 毕设选题详情页 */} - () - } - > - - {/* 毕设选题列表 */} - () - }> - - - {/*————————————————————————————————————————————————————————————————————————————————————*/} - {/* 作品评阅 https://www.trustie.net/issues/19981 */} - () - } - > - - {/* 新建作品 */} - () - } - > - - {/* 修改作品 */} - () - } - > - - {/* 设置毕设任务 https://www.trustie.net/issues/19981 */} - - {/* () } @@ -611,384 +483,360 @@ class CoursesIndex extends Component{ }> */} - () - } - > + () + } + > - {/* 修改毕设任务 https://www.trustie.net/issues/19981 */} - () - } - > + {/* 修改毕设任务 https://www.trustie.net/issues/19981 */} + () + } + > - {/* 新建毕设任务 https://www.trustie.net/issues/19981 */} - () - } - > + {/* 新建毕设任务 https://www.trustie.net/issues/19981 */} + () + } + > - {/* 毕设任务列表 https://www.trustie.net/issues/19981 */} - () - } - > + {/* 毕设任务列表 https://www.trustie.net/issues/19981 */} + () + } + > - {/*/!* 毕业设计主 https://www.trustie.net/issues/19981 *!/*/} - {/* ()*/} - {/*}*/} - {/*>*/} + {/*/!* 毕业设计主 https://www.trustie.net/issues/19981 *!/*/} + {/* ()*/} + {/*}*/} + {/*>*/} - {/*/!* 资源子目录 https://www.trustie.net/issues/19917 *!/*/} - {/* ()*/} - {/*}*/} - {/*>*/} - {/* 教师列表*/} - () - } - > - {/* 学生列表*/} - () - } - > - {/* 分班列表 */} - () - } - > - () - } - > + {/*/!* 资源子目录 https://www.trustie.net/issues/19917 *!/*/} + {/* ()*/} + {/*}*/} + {/*>*/} + {/* 教师列表*/} + () + } + > + {/* 学生列表*/} + () + } + > + {/* 分班列表 */} + () + } + > + () + } + > - {/* 普通作业 */} - () - } - > - {/* 子目录普通作业 */} - () - } - > - {/* 分组作业 */} - () - } - > - {/* 分组作业 */} - () - } - > + {/* 普通作业 */} + () + } + > + {/* 子目录普通作业 */} + () + } + > + {/* 分组作业 */} + () + } + > + {/* 分组作业 */} + () + } + > - {/* 普通作业 */} - () - } - > - {/* 子普通作业 */} - () - } - > + {/* 普通作业 */} + () + } + > + {/* 子普通作业 */} + () + } + > - {/* 分组作业 */} - () - } - > + {/* 分组作业 */} + () + } + > - {/* 分组作业 */} - () - } - > + {/* 分组作业 */} + () + } + > - {/* 问卷答题 */} - () - } - > + {/* 问卷答题 */} + {/* () + } + > */} - {/* 问卷详情 */} - () - } - > + {/* 问卷详情 */} + {/* () + } + > */} - {/* 问卷新建 */} - () - } - > - {/* 问卷 */} - () - } - > + {/* 问卷新建 */} + {/* () + } + > */} + {/* 问卷 */} + {/* () + } + > */} - {/* 试卷查看/评阅 */} - () - } - > + {/* 试卷查看/评阅 */} + {/* () + } + > */} - {/*试卷新建 */} - () - } - > - {/*试卷新建 */} - () - } - > + {/*试卷新建 */} + {/* () + } + > */} + {/*试卷新建 */} + {/* () + } + > */} - {/*试卷设置主页*/} + {/*试卷设置主页*/} - () - } - > + {/* () + } + > */} - {/*学生完成列表*/} - () - } - > - - {/* 试卷 */} - () - } - > + {/*学生完成列表*/} + () + } + > + + {/* 试卷 */} + {/* () + } + > */} - {/*实训查重详情*/} - () - } - > - () - } - > + {/*实训查重详情*/} + () + } + > + () + } + > - {/*实训查重列表*/} - () - } - > - () - } - > + {/*实训查重列表*/} + () + } + > + () + } + > - {/*实训报告*/} - () - } - > - () - } - > + {/*实训报告*/} + () + } + > + () + } + > - {/*教师列表*/} - () - } - > - () - } - > - {/*实训作业page*/} - () - } - > - {/*实训作业设置*/} - () - } - > - () - } - > - {/*/!*实训作品列表教师*!/*/} - {/*提交总结*/} - () - } - > - () - } - > - {/*实训作品列表学生未公布*/} - {/* ()*/} - {/* }*/} - {/*>*/} - {/*实训学生作品列表已公布*/} - {/* ()*/} - {/* }*/} - {/* >*/} - {/*/!*实训学生作品列表已公布*!/*/} - {/* ()*/} - {/* }*/} - {/*>*/} + {/*教师列表*/} + () + } + > + () + } + > + {/*实训作业page*/} + () + } + > + {/*实训作业设置*/} + () + } + > + () + } + > + {/*/!*实训作品列表教师*!/*/} + {/*提交总结*/} + () + } + > + () + } + > + {/*实训作业问答主目录*/} + () + } + > + {/*实训作业问答子目录*/} + () + } + > - {/*实训作业问答主目录*/} - () - } - > + {/*新建课堂*/} + () + } + > + {/*新建精品课堂*/} + () + } + > + {/*修改精品课堂*/} + () + } + > + {/*修改课堂*/} + () + } + > - {/*实训作业问答子目录*/} - () - } - > + {/* 实训作业子页面*/} + () + } + > - {/*新建课堂*/} - () - } - > - {/*新建精品课堂*/} - {/*coursesId 课堂id */} - {/*id 是否是私有或者公有*/} - () - } - > - {/*修改精品课堂*/} - () - } - > - {/*修改课堂*/} - () - } - > + {/* 实训作业页面*/} + () + } + > - {/* 实训作业子页面*/} - () - } - > + {/*课堂统计列表2019.10.29 */} + () + } + > - {/* 实训作业页面*/} - () - } - > + {/* 主签到 */} + () + } + > - {/*课堂统计列表2019.10.29 */} + {/*/!*实训作业and课堂详情页*!/*/} + () + } + > - () - } - > + {/*课堂首页*/} + () + } + > - {/* 主签到 */} - () - } - > - - {/*/!*实训作业and课堂详情页*!/*/} - () - } - > - - {/*课堂首页*/} - () - } - > - {/**/} - - - ) - } + + ) + } } -export default withRouter(ImageLayerOfCommentHOC({imgSelector: '.imageLayerParent img, .imageLayerParent .imageTarget', parentSelector: '.newMain'}) (CNotificationHOC() ( SnackbarHOC() ( TPMIndexHOC(CoursesIndex) )))); +export default withRouter(ImageLayerOfCommentHOC({ imgSelector: '.imageLayerParent img, .imageLayerParent .imageTarget', parentSelector: '.newMain' })(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC(CoursesIndex))))); diff --git a/src/modules/courses/boards/AddDirModal.js b/src/modules/courses/boards/AddDirModal.js deleted file mode 100644 index ddc430c1..00000000 --- a/src/modules/courses/boards/AddDirModal.js +++ /dev/null @@ -1,89 +0,0 @@ -import React,{ Component } from "react"; -import {Tooltip, Modal, Input } from 'antd' -import moment from 'moment' -import { getUrl, WordsBtn } from 'educoder' -import axios from 'axios' -class AddDirModal extends Component{ - constructor(props){ - super(props); - this.state = { - - } - } - onInput = (e) => { - this.setState({ - inputValue: e.target.value - }) - } - open = () => { - this.setState({ visible: true, inputValue: '' }) - } - onSave = () => { - let coursesId = this.props.match.params.coursesId; - const url = `/courses/${coursesId}/boards.json` - let { inputValue } = this.state; - if (!inputValue) { - this.setState({ errorMsg: '名称不能为空'}) - return; - } - if (inputValue.length > 20) { - this.setState({ errorMsg: '名称不能超过20个字'}) - return; - } - this.setState({ errorMsg: ''}) - - axios.post(url,{ - name: inputValue - }).then((response)=>{ - if (response.data.status == 0) { - this.onCancel() - this.props.showNotification('添加成功') - this.props.addSuccess && this.props.addSuccess() - } - }).catch((error)=>{ - console.log(error) - }) - } - onCancel = () => { - this.setState({ visible: false, inputValue: '', errorMsg: '' }) - } - render(){ - let { inputValue, visible, errorMsg } = this.state; - const { title } = this.props; - return( - -
-
{this.props.label}:
- -
- - {errorMsg && {errorMsg}} - - {/* {this.state.NavmodalValuetype===true? - {this.state.NavmodalValues} - :""} */} - - {/* this.state.NavmodalValuetype===true?"clearfix mt20 edu-txt-center": */} -
- 取消 - 确定 -
-
- ) - } -} -export default AddDirModal; \ No newline at end of file diff --git a/src/modules/courses/boards/BoardsListItem.js b/src/modules/courses/boards/BoardsListItem.js deleted file mode 100644 index 47b9182e..00000000 --- a/src/modules/courses/boards/BoardsListItem.js +++ /dev/null @@ -1,112 +0,0 @@ -import React, { Component } from "react"; -import { Tooltip } from 'antd' -import moment from 'moment' -import { getUrl, WordsBtn, ConditionToolTip } from 'educoder' -import './boardsListItem.css'; -class BoardsListItem extends Component { - constructor(props) { - super(props); - this.state = { - - } - } - onTitleClick = (discussMessage) => { - if (this.props.checkIfLogin() === false) { - this.props.showLoginDialog() - return - } - const isAdminOrStudent = this.props.isAdminOrStudent(); - if (!isAdminOrStudent && discussMessage.is_public == false) { - // 没有权限访问 - return; - } - const cid = this.props.match.params.coursesId - const board_id = this.props.match.params.boardId - this.props.toDetailPage(cid, board_id, discussMessage.id) - } - render() { - const isAdmin = this.props.isAdmin() - const isAdminOrStudent = this.props.isAdminOrStudent() - const { checkBox, discussMessage, onSticky, onItemClick, current_user } = this.props; - if (!discussMessage || !discussMessage.author) { - return ''; - } - let canNotLink = !isAdminOrStudent && discussMessage.is_public == false - - return ( -
- - {checkBox} - - 1?1529221779 - -
onItemClick(discussMessage)}> -
- {canNotLink ? {discussMessage.subject} : { } : () => this.onTitleClick(discussMessage)} - >{discussMessage.subject.length>=30?discussMessage.subject.slice(0,30)+"...":discussMessage.subject}} - {!!discussMessage.sticky && 置顶} - { - - discussMessage.is_public == false ? ( - - ) : "" - } - -
- -
- - {(isAdmin || discussMessage.author.login == current_user.login) && - { this.props.toEditPage(this.props.match.params.coursesId, this.props.match.params.boardId, discussMessage.id) }}>编辑} - - {isAdmin && { onSticky(discussMessage); e.cancelBubble = true; e.stopPropagation(); }}> - {discussMessage.sticky ? '取消置顶' : '置顶'}} - - {canNotLink ? "" : { } : () => this.onTitleClick(discussMessage)}>查看详情} - -
- -
-

- - {discussMessage.author.name} - - {discussMessage.total_replies_count != 0 && {discussMessage.total_replies_count} 回复} - {discussMessage.praises_count != 0 && {discussMessage.praises_count} 点赞} - {discussMessage.visits != 0 && {discussMessage.visits} 浏览} - - {moment(discussMessage.created_on).fromNow()} - -

- { - discussMessage.category_name && -
- - {
- 所属目录:{discussMessage.category_name} -
- } -
-
- } -
-
- ) - } -} -export default BoardsListItem; \ No newline at end of file diff --git a/src/modules/courses/boards/BoardsNew.js b/src/modules/courses/boards/BoardsNew.js deleted file mode 100644 index 8b63653d..00000000 --- a/src/modules/courses/boards/BoardsNew.js +++ /dev/null @@ -1,518 +0,0 @@ -import React, { Component } from "react"; - -import { - Form, Input, InputNumber, Switch, Radio, - Slider, Button, Upload, Icon, Rate, Checkbox, message, - Row, Col, Select, Modal, Divider, Tooltip -} from 'antd'; -import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; -import axios from 'axios' -import './board.css' -import "../common/formCommon.css" -import AddDirModal from './AddDirModal' -import { RouteHOC } from './common.js' -import CBreadcrumb from '../common/CBreadcrumb' -import { getUploadActionUrl, bytesToSize, uploadNameSizeSeperator, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll } from 'educoder'; -import styled from "styled-components"; - -const SubBtn = styled(Button)` - display: block; - border: 1px solid #4CACFF; - background-color: #4CACFF; - color: #fff !important; - width: 120px; - text-align: center; - line-height: 40px; - border-radius: 2px; - width: 130px; - height: 40px; - background: rgba(76, 172, 255, 1); - border-radius: 4px; - font-size: 16px; - font-family: MicrosoftYaHei; - font-weight: 400; - color: rgba(255, 255, 255, 1); -`; - -const confirm = Modal.confirm; -const $ = window.$ -const { Option } = Select; -const MAX_TITLE_LENGTH = 60 -// https://lanhuapp.com/web/#/item/project/board/detail?pid=a3bcd4b1-99ce-4e43-8ead-5b8b0a410807&project_id=a3bcd4b1-99ce-4e43-8ead-5b8b0a410807&image_id=71072679-b925-4824-aceb-4649535e3652 -class BoardsNew extends Component { - constructor(props) { - super(props); - - this.mdRef = React.createRef(); - - this.state = { - fileList: [], - boards: [], - title_num: 0, - email_notify: false, - isemail_notify: false, - isemail_notifys: false - } - } - addSuccess = () => { - this.fetchBoards() - } - fetchBoards = () => { - const isEdit = this.isEdit - const boardId = this.props.match.params.boardId - - const boardsUrl = `/courses/board_list.json?board_id=${boardId}` - axios.get(boardsUrl, {}) - .then((response) => { - if (response.data.status == 0) { - this.setState({ - boards: response.data.data.boards || [], - boardsdata: response.data.data, - course_id: response.data.data.course_id - }) - if (!isEdit) { - response.data.data.boards.forEach(board => { - if (board.id == boardId) { - this.setState({ board_name: board.name }) - } - }) - // board_name - } - } - }) - .catch(function (error) { - console.log(error); - }); - } - componentDidMount = () => { - - const topicId = this.props.match.params.topicId - const isEdit = !!topicId - this.isEdit = isEdit - - const boardId = this.props.match.params.boardId - - this.fetchBoards() - - if (isEdit) { - const url = `/messages/${topicId}.json` - axios.get(url, { - }) - .then((response) => { - if (response.data.status == 0) { - const { id, data } = response.data; - if (data) { - this.editTopic = data; - this.props.form.setFieldsValue({ - sticky: !!data.sticky, - content: data.content, - subject: data.subject, - select_board_id: data.board_id // TODO 没返回给前端 - }); - this.mdRef.current.setValue(data.content) - const _fileList = data.attachments.map(item => { - return { - id: item.id, - uid: item.id, - name: appendFileSizeToUploadFile(item), - url: item.url, - status: 'done' - } - }) - - this.setState({ fileList: _fileList, board_name: data.board_name, title_num: parseInt(data.subject.length), isemail_notifys: response.data.data.email_notify }) - } - } - }) - .catch(function (error) { - console.log(error); - }); - } else { - const boardId = this.props.match.params.boardId - - this.props.form.setFieldsValue({ - select_board_id: parseInt(boardId) - }); - } - } - handleSubmit = (e) => { - e.preventDefault(); - const cid = this.state.course_id - const boardId = this.props.match.params.boardId - - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - console.log('Received values of form: ', values); - if (this.isEdit == true) { - const editTopic = this.editTopic - const editUrl = `/messages/${editTopic.id}.json` - - let attachment_ids = undefined - if (this.state.fileList) { - attachment_ids = this.state.fileList.map(item => { - return item.response ? item.response.id : item.id - }) - } - axios.put(editUrl, { - subject: values.subject, - select_board_id: values.select_board_id, - content: values.content, - sticky: values.sticky, - email_notify: this.state.isemail_notify, - attachment_ids, - }) - .then((response) => { - if (response.data.status == 0) { - const { id } = response.data; - console.log('--- success') - - this.props.toDetailPage(cid, values.select_board_id, editTopic.id) - } - }) - .catch(function (error) { - console.log(error); - }); - } else { - const url = `/boards/${boardId}/messages.json` - let attachment_ids = undefined - if (this.state.fileList) { - attachment_ids = this.state.fileList.map(item => { - return item.response.id - }) - } - - axios.post(url, { - ...values, - email_notify: this.state.isemail_notify, - course_id: cid, - attachment_ids, - }) - .then((response) => { - if (response.data.data && response.data.status == 0) { - const { id } = response.data.data; - if (id) { - console.log('--- success') - this.props.toDetailPage(cid, values.select_board_id, id) - } - } - }) - .catch(function (error) { - console.log(error); - }); - } - } else { - $("html").animate({ scrollTop: $('html').scrollTop() - 100 }) - } - }); - } - // 附件相关 START - handleChange = (info) => { - if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') { - let fileList = info.fileList; - this.setState({ fileList: appendFileSizeToUploadFileAll(fileList) }); - } - } - onAttachmentRemove = (file) => { - if (!file.percent || file.percent == 100) { - this.props.confirm({ - // title: '确定要删除这个附件吗?', - content: '是否确认删除?', - - okText: '确定', - cancelText: '取消', - // content: 'Some descriptions', - onOk: () => { - this.deleteAttachment(file) - }, - onCancel() { - console.log('Cancel'); - }, - }); - - - return false; - } - - } - deleteAttachment = (file) => { - // 初次上传不能直接取uid - const url = `/attachments/${file.response ? file.response.id : file.uid}.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); - }); - } - // 附件相关 ------------ END - changeTitle = (e) => { - console.log(e.target.value.length); - this.setState({ - title_num: parseInt(e.target.value.length) - }) - } - goBack = () => { - // this.props.history.goBack() - const courseId = this.props.match.params.coursesId; - const boardId = this.props.match.params.boardId - this.props.toListPage(courseId, boardId) - } - - setemailchange = (e) => { - this.setState({ - isemail_notify: e.target.checked - }) - } - render() { - let { addGroup, fileList, course_id, title_num } = this.state; - const { getFieldDecorator } = this.props.form; - const { current_user } = this.props - - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - // sm: { span: 8 }, - sm: { span: 24 }, - }, - wrapperCol: { - xs: { span: 24 }, - // sm: { span: 16 }, - sm: { span: 24 }, - }, - }; - - const uploadProps = { - width: 600, - fileList, - multiple: true, - // https://github.com/ant-design/ant-design/issues/15505 - // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 - // showUploadList: false, - action: `${getUploadActionUrl()}`, - onChange: this.handleChange, - onRemove: this.onAttachmentRemove, - beforeUpload: (file) => { - console.log('beforeUpload', file.name); - const isLt150M = file.size / 1024 / 1024 < 150; - if (!isLt150M) { - this.props.showNotification('文件大小必须小于150MB!'); - } - return isLt150M; - }, - }; - const isAdmin = this.props.isAdmin() - const courseId = this.props.match.params.coursesId; - const boardId = this.props.match.params.boardId - const isCourseEnd = this.props.isCourseEnd(); - document.title = this.props.coursedata && this.props.coursedata.name; - - // console.log(this.state) - return ( -
- - -
- - -

- {this.isEdit ? "编辑" : "新建"}帖子 - - 返回 - -

- {/* notRequired */} -
-
- {this.state.boardsdata && this.state.boardsdata.email_notify === true ? this.props.isAdminOrTeacher() === true ? - 发送邮件提醒 - : "" : ""} - - {isAdmin && - - {getFieldDecorator('sticky', { - valuePropName: 'checked', - })( - isAdmin && 置顶 - )} - {/* checkbox 有个边距样式 .ant-checkbox-wrapper + span, */} - - - } - - - - {getFieldDecorator('subject', { - rules: [{ - required: true, message: '请输入标题', - }, { - max: MAX_TITLE_LENGTH, message: `最大限制为${MAX_TITLE_LENGTH}个字符`, - }], - })( - - )} - - - - {getFieldDecorator('select_board_id', { - // initialValue: '3779', - })( - - )} - - - - - {/* { isAdmin && - {getFieldDecorator('sticky', { - })( - 置顶 - )} - } */} -
- - - -
- - - {getFieldDecorator('content', { - rules: [{ - required: true, message: '请输入帖子内容', - }, { - max: 10000, message: '最大限制为10000个字符', - }], - })( - - )} - - - - - (单个文件150M以内) - -
- - -
- 提交 - this.isEdit ? - this.props.toDetailPage(Object.assign({}, this.props.match.params, { 'coursesId': course_id })) : - this.props.toListPage(Object.assign({}, this.props.match.params, { 'coursesId': course_id }))}>取消 -
-
- -
-
- ) - } -} - -const WrappedBoardsNew = Form.create({ name: 'boardsNew' })(BoardsNew); -export default RouteHOC()(WrappedBoardsNew); diff --git a/src/modules/courses/boards/BoardsNewTemp.js b/src/modules/courses/boards/BoardsNewTemp.js deleted file mode 100644 index 1f347673..00000000 --- a/src/modules/courses/boards/BoardsNewTemp.js +++ /dev/null @@ -1,202 +0,0 @@ -import React,{ Component } from "react"; - -import { - Form, Input, InputNumber, Switch, Radio, - Slider, Button, Upload, Icon, Rate, Checkbox, - Row, Col, Select -} from 'antd'; -const $ = window.$ -const { Option } = Select; - -// 红点在输入框前面的版本 -// https://lanhuapp.com/web/#/item/project/board/detail?pid=a3bcd4b1-99ce-4e43-8ead-5b8b0a410807&project_id=a3bcd4b1-99ce-4e43-8ead-5b8b0a410807&image_id=71072679-b925-4824-aceb-4649535e3652 -class BoardsNew extends Component{ - constructor(props){ - super(props); - this.state = { - - } - } - compareToFirstPassword = (rule, value, callback) => { - const form = this.props.form; - if (value && value !== form.getFieldValue('password')) { - callback('Two passwords that you enter is inconsistent!'); - } else { - callback(); - } - } - validateToNextPassword = (rule, value, callback) => { - const form = this.props.form; - if (value && this.state.confirmDirty) { - form.validateFields(['confirm'], { force: true }); - } - callback(); - } - handleConfirmBlur = (e) => { - const value = e.target.value; - this.setState({ confirmDirty: this.state.confirmDirty || !!value }); - } - handleSubmit = (e) => { - e.preventDefault(); - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - console.log('Received values of form: ', values); - } else { - $("html").animate({ scrollTop: $('html').scrollTop() - 100 }) - } - }); - } - render() { - let { addGroup } = this.state; - 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 tailFormItemLayout = { - wrapperCol: { - xs: { - span: 24, - offset: 0, - }, - sm: { - span: 16, - offset: 8, - }, - }, - }; - - - return( -
- -
-
- - {getFieldDecorator('email', { - rules: [{ - type: 'email', message: 'The input is not valid E-mail!', - }, { - required: true, message: 'Please input your E-mail!', - }], - })( - - )} - - - - {getFieldDecorator('prefix', { - initialValue: '86', - })( - - )} - - - - {getFieldDecorator('password', { - rules: [{ - required: true, message: 'Please input your password!', - }, { - validator: this.validateToNextPassword, - }], - })( - - )} - - - {getFieldDecorator('confirm', { - rules: [{ - required: true, message: 'Please confirm your password!', - }, { - validator: this.compareToFirstPassword, - }], - })( - - )} - - - - - -
-
-
- ) - } -} -const WrappedBoardsNew = Form.create({ name: 'boardsNew' })(BoardsNew); -export default WrappedBoardsNew; \ No newline at end of file diff --git a/src/modules/courses/boards/TopicDetail.css b/src/modules/courses/boards/TopicDetail.css deleted file mode 100644 index 7500268b..00000000 --- a/src/modules/courses/boards/TopicDetail.css +++ /dev/null @@ -1,15 +0,0 @@ -.edu-class-container { - width: 1200px; - margin: 10px auto 20px; -} -#forum_index_list { - margin-top: 90px; - margin-bottom: 320px; -} -#yslforum_index_list { - margin-top: 20px; - margin-bottom: 320px; -} -.uploadBtn { - margin-left: 0px; -} \ No newline at end of file diff --git a/src/modules/courses/boards/TopicDetail.js b/src/modules/courses/boards/TopicDetail.js deleted file mode 100644 index 0882cf75..00000000 --- a/src/modules/courses/boards/TopicDetail.js +++ /dev/null @@ -1,746 +0,0 @@ -import React, { Component } from 'react'; -import axios from 'axios' -import moment from 'moment' -import Comments from '../../comment/Comments' -import { ImageLayerOfCommentHOC } from '../../page/layers/ImageLayerOfCommentHOC' -import MemoDetailMDEditor from '../../forums/MemoDetailMDEditor' -import { RouteHOC } from './common.js' -import '../../forums/RightSection.css' -import './TopicDetail.css' -import '../common/courseMessage.css' -import { Pagination, Tooltip, Button } from 'antd' -import { bytesToSize, ConditionToolTip, markdownToHTML, MarkdownToHtml, setImagesUrl } from 'educoder' -import SendToCourseModal from '../coursesPublic/modal/SendToCourseModal' -import CBreadcrumb from '../common/CBreadcrumb' -import { - generateComments, generateChildComments, _findById, handleContentBeforeCreateNew, addNewComment - , addSecondLevelComment, NEED_TO_WRITE_CONTENT, handleContentBeforeCreateSecondLevelComment - , handleDeleteComment, handleCommentPraise, handleHiddenComment -} from '../common/CommentsHelper' - -const $ = window.$ -const REPLY_PAGE_COUNT = 10; -let setTime; -function urlStringify(params) { - let noParams = true; - let paramsUrl = ''; - for (let key in params) { - noParams = false; - paramsUrl += `${key}=${params[key]}&` - } - if (noParams) { - return ''; - } - paramsUrl = paramsUrl.substring(0, paramsUrl.length - 1); - return paramsUrl; -} -class TopicDetail extends Component { - constructor(props) { - super(props) - - this.state = { - memo: {}, - memoLoading: true, - hasMoreComments: false, - pageCount: 1, - comments: [], - goldRewardDialogOpen: false, - author: undefined, - commentstype: false - } - } - componentDidMount() { - window.$("html,body").animate({ "scrollTop": 0 }) - - const topicId = this.props.match.params.topicId - const bid = this.props.match.params.boardId - - const memoUrl = `/messages/${topicId}.json`; - this.setState({ - memoLoading: true - }) - axios.get(memoUrl, { - }) - .then((response) => { - - if (response.data.status === -1) { - setTimeout(() => { - this.props.showNotification('帖子不存在!') - }, 300) - // this.props.toListPage(response.data.data.course_id, bid) - return; - } else { - - this.setState({ - memo: Object.assign({}, { - ...response.data.data, - replies_count: response.data.data.total_replies_count - }, { ...this.state.memo }), - author: response.data.data.author - }, () => { - }) - - // const { memo_replies, memo } = response.data; - // let hasMoreComments = false; - // if (memo_replies && memo_replies.length === 10 && memo.total_replies_count > 10) { - // // 遍历一遍,计算下是否还有评论未加载 - // let totalCount = 10; - // memo_replies.forEach(item=>{ - // totalCount += item.children.length - // }) - // if (totalCount < memo.total_replies_count) { - // hasMoreComments = true; - // } - // } - // this.setState({ - // hasMoreComments, - // pageCount: 1, - // comments: memo_replies - // }) - // delete response.data.memo_replies; - // this.setState(response.data) - // const user = response.data.current_user; - // user.tidding_count = response.data.tidding_count; - // this.props.initCommonState(user) - } - this.setState({ - memoLoading: false - }) - - }).catch((error) => { - console.log(error) - }) - - this.fetchReplies() - - $('body>#root').on('onMemoDelete', (event) => { - // const val = $('body>#root').data('onMemoDelete') - const val = window.onMemoDelete; - this.onMemoDelete(JSON.parse(decodeURIComponent(val))) - }) - - - } - - onPaginationChange = (pageCount) => { - this.setState({ pageCount }, () => { - this.fetchReplies() - }) - } - - componentWillUnmount() { - $('body>#root').off('onMemoDelete') - } - onMemoDelete(memo) { - const deleteUrl = `/commons/delete.json`; - // 获取memo list - axios.delete(deleteUrl, { - data: { - object_id: memo.id, - object_type: 'message' - } - }) - .then((response) => { - const status = response.data.status - if (status === 0) { - - this.props.showNotification('删除成功'); - const props = Object.assign({}, this.props, {}) - this.props.toListPage(Object.assign({}, this.props.match.params, { 'coursesId': this.state.memo.course_id })) - - } else if (status === -1) { - this.props.showNotification('帖子已被删除'); - this.props.history.push(`/forums`) - } - }).catch((error) => { - console.log(error) - }) - } - - componentDidUpdate(prevProps, prevState, snapshot) { - // if (this.state.memo && this.state.memo.content - // && (!prevProps.memo || prevProps.memo.content != this.state.memo.content) ) { - if (this.state.memo && this.state.memo.content && prevState.memoLoading === true && this.state.memoLoading === false) { - // md渲染content,等xhr执行完(即memoLoading变化),memo.content更新后初始化md - - setTimeout(() => { - // var shixunDescr = window.editormd.markdownToHTML("memo_content_editorMd", { - // htmlDecode: "style,script,iframe", // you can filter tags decode - // taskList: true, - // tex: true, // 默认不解析 - // flowChart: true, // 默认不解析 - // sequenceDiagram: true // 默认不解析 - // }); - }, 200) - } - - } - - clickPraise() { - const { memo } = this.state; - // const url = `/api/v1/discusses/${memo.id}/plus`; - const url = memo.user_praise ? '/praise_tread/unlike.json' : `/praise_tread/like.json`; - const _method = memo.user_praise ? axios.delete : axios.post - let _data = { - object_id: memo.id, - object_type: 'message', //Discuss - } - if (memo.user_praise) { - _data = { - data: _data - } - } - _method(url, { - ..._data - }, - { - - } - ).then((response) => { - - const newMemo = Object.assign({}, this.state.memo) - newMemo.praises_count = newMemo.user_praise ? newMemo.praises_count - 1 : newMemo.praises_count + 1 - newMemo.total_praises_count = newMemo.user_praise ? newMemo.total_praises_count - 1 : newMemo.total_praises_count + 1 - newMemo.user_praise = !newMemo.user_praise - this.setState({ memo: newMemo }) - }).catch((error) => { - console.log(error) - }) - } - renderAttachment() { - const { memo } = this.state; - const attachments = [] - memo.attachments.forEach((item, index) => { - const ar = item.url.split('/') - const fileName = item.title || ar[ar.length - 1] - let filesize = 0 - if (item.filesize) { - filesize = item.filesize - // filesize = bytesToSize(item.filesize) - } - attachments.push( - //

- // - // - // {fileName && 30 }> - // {fileName} - // } - // {filesize? ` ${filesize.replace(' ', '')}` : ''} - // - //

- -
- - - - {/* {fileName && 30 }> } */} - 30 ? fileName : ''} - className="mr12 color9B9B overflowHidden1" length="58" style={{ maxWidth: '480px' }}> - {fileName} - - - - {item.filesize} - -
- ) - }) - return attachments; - } - // ------------------------------------------------------------------------------------------- comments START - // ------------------------------------------------------------------------------------------- comments START - transformReply = (reply, children = []) => { - const isAdmin = this.props.isAdmin() - const isSuperAdmin = this.props.isSuperAdmin() - return { - isSuperAdmin: isSuperAdmin, - admin: isAdmin, // - permission: true, // - children: children, - child_message_count: reply.total_count, - hidden: reply.is_hidden, - id: reply.id, - image_url: reply.author.image_url, - reward: null, // - time: moment(reply.created_on).fromNow(), - user_id: reply.author.id, - user_login: reply.author.login, - user_praise: reply.liked, - username: reply.author.name, - content: reply.content, - praise_count: reply.praises_count - } - } - - fetchReplies = () => { - const topicId = this.props.match.params.topicId - const url = `/messages/${topicId}/reply_list.json?page=${this.state.pageCount}&page_size=${REPLY_PAGE_COUNT}` - axios.get(url, { - }) - .then((response) => { - const { replies, liked, total_replies_count, total_count } = response.data.data - - const memo = Object.assign({}, this.state.memo) - memo.user_praise = liked - memo.total_replies_count = total_replies_count; - this.setState({ - memo, - comments: generateComments(replies, this.transformReply, 'replies'), - // : this.state.comments.concat(comments), - total_count: total_count - }) - }).catch((error) => { - console.log(error) - }) - } - - _getUser() { - const { current_user } = this.props; - current_user.user_url = `/users/${current_user.login}`; - return current_user; - } - _findById = _findById - replyComment = (commentContent, id, editor) => { - const { showNotification } = this.props; - // if (!commentContent || commentContent.length === 0) { - // showNotification(NEED_TO_WRITE_CONTENT) - // return; - // } - - if (this.state.memo.id === id) { // 回复帖子 - this.createNewComment(commentContent, id, editor); - return; - } - const url = `/messages/${id}/reply.json`; - - const { comments } = this.state; - const user = this._getUser(); - /* - 移除末尾的空行 - .replace(/(\n

\n\t
\n<\/p>)*$/g,''); - - */ - - commentContent = handleContentBeforeCreateSecondLevelComment(commentContent) - if (!commentContent) { - this.props.showNotification('不能为空') - return; - } - axios.post(url, { - content: commentContent - }, - { - } - ).then((response) => { - if (response.data.data.id) { - let newId = response.data.data.id; - const commentIndex = this._findById(id, comments); - const parentComment = comments[commentIndex] - - this.setState({ - // runTesting: false, - comments: addSecondLevelComment(comments, parentComment, commentIndex, newId, commentContent, user, editor) - }, () => { - // keditor代码美化 - editor.html && window.prettyPrint() - }) - - const newMemo2 = Object.assign({}, this.state.memo); - newMemo2.total_replies_count = newMemo2.total_replies_count + 1; - this.setState({ - memo: newMemo2 - }) - } - - }).catch((error) => { - console.log(error) - }) - } - // 公共接口 --- 删除回复 - deleteComment = (parrentComment, childCommentId) => { - handleDeleteComment(this, parrentComment, childCommentId, 'message') - - } - // 公共接口 --- 回复点赞 - commentPraise = (discussId) => { - handleCommentPraise(this, discussId, 'message', (old_user_praise) => { - const newMemo2 = Object.assign({}, this.state.memo); - - newMemo2.total_praises_count = old_user_praise - ? newMemo2.total_praises_count - 1 : newMemo2.total_praises_count + 1; - this.setState({ - memo: newMemo2 - }) - }) - } - // 公共接口 --- 隐藏回复 - hiddenComment = (item, childCommentId) => { - handleHiddenComment(this, item, childCommentId, 'message') - } - createNewComment = (commentContent, id, editor) => { - let content = handleContentBeforeCreateNew(commentContent); - const { memo } = this.props; - - const url = `/messages/${id}/reply.json`; - - // const url = `/api/v1/memos/${memo.id}/reply`; - let { comments } = this.state; - axios.post(url, { - content: content - }, - { - } - ).then((response) => { - if (response.data.status === -1) { - console.error('服务端异常') - return; - } - // this.props.showNotification('帖子发表成功') - - if (response.data) { - const _id = response.data.data.id; - // ke - editor.html && editor.html(''); - editor.afterBlur && editor.afterBlur() - // md - editor.setValue && editor.setValue('') - - - const user = this._getUser(); - this.setState({ - comments: addNewComment(comments, _id, content, user, this.props.isSuperAdmin(), this) - }) - const newMemo2 = Object.assign({}, this.state.memo); - newMemo2.total_replies_count = newMemo2.total_replies_count + 1; - this.setState({ - memo: newMemo2 - }) - this.refs.editor.showEditor(); - this.refs.editor.close(); - - - } - }).catch((error) => { - console.log(error) - }) - } - - /** - * parent.isAllChildrenLoaded 为 true的时候,表示已经没有更多子回复了 - */ - loadMoreChildComments = (parent) => { - const url = `/messages/${parent.id}/reply_list.json?page=1&page_size=500` - axios.get(url, { - }) - .then((response) => { - const { replies, liked, total_replies_count } = response.data.data - - // const memo = Object.assign({}, this.state.memo) - // memo.total_replies_count = total_replies_count; - this.setState({ - // memo, - comments: generateChildComments(replies, this.state.comments, parent, this.transformReply) - }) - }).catch((error) => { - console.log(error) - }) - } - // ------------------------------------------------------------------------------------------- comments END - // ------------------------------------------------------------------------------------------- comments END - // 置顶 - setTop(memo) { - // const params = { - // sticky: memo.sticky ? 0 : 1, - // } - // if (this.state.p_s_order) { - // params.order = this.state.p_s_order; - // } - // if (this.state.p_forum_id) { - // params.forum_id = this.state.p_forum_id; - // } - // let paramsUrl = urlStringify(params) - const set_top_or_down_Url = `/messages/${memo.id}/sticky_top.json`; - // 获取memo list - axios.put(set_top_or_down_Url, { - - }) - .then((response) => { - const status = response.data.status - if (status === 0) { - this.props.showNotification(memo.sticky ? '取消置顶成功' : '置顶成功'); - memo.sticky = memo.sticky ? false : true - this.setState({ - memo: Object.assign({}, memo) - }) - } - }).catch((error) => { - console.log(error) - }) - } - - setRewardDialogVisible = (visible) => { - this.setState({ - goldRewardDialogOpen: visible - }) - } - showRewardDialog = () => { - this.setState({ - goldRewardDialogOpen: true - }) - } - // --------------------------------------------------------------------------------------------帖子獎勵 END - showCommentInput = () => { - this.refs.editor.showEditor(); - } - initReply = (parent) => { - if (!parent.isAllChildrenLoaded) { - this.loadMoreChildComments(parent) - } - } - - startcomments = () => { - setTime = setInterval(() => { - this.fetchReplies() - }, 5000); - this.setState({ - commentstype: true - }) - } - - clearcomments = () => { - clearInterval(setTime); - this.setState({ - commentstype: false - }) - } - - render() { - const { match, history } = this.props - const { recommend_shixun, current_user, author_info } = this.props; - const { memo, comments, hasMoreComments, commentstype, pageCount, total_count, author } = this.state; - const messageId = match.params.topicId - if (this.state.memoLoading || !current_user) { - return

- } - current_user.user_url = `/users/${current_user.login}`; - const isCurrentUserTheAuthor = current_user.login == memo.author.login - const isAdmin = this.props.isAdmin() - // TODO 图片上传地址 - const courseId = this.props.match.params.coursesId; - const boardId = this.props.match.params.boardId; - const isCourseEnd = this.props.isCourseEnd(); - - document.title = this.props.coursedata && this.props.coursedata.name; - return ( -
{/* fl with100 */} - - - - -
-
-
-
- {memo.subject} - {!!memo.sticky && 置顶} - {!!memo.reward && - {memo.reward} - } - {/* || current_user.user_id === author_info.user_id */} - {current_user && (isAdmin || isCurrentUserTheAuthor) && - - } - -
-
- -
-
- {author && author.name} - {moment(memo.created_on).fromNow()} 发布 -
- -
- - {/* { current_user.admin && - - - - } */} - - - - {memo.visits || '1'} - - - {!!memo.total_replies_count && - - - - {memo.total_replies_count} - - - } - {!!memo.total_praises_count && - - - - {memo.total_praises_count} - - - } - - -
-
-
-
- - -
- {/* */} - {memo.is_md == true ? - - : -
- } -
-
-
- {/* ${memo.user_praise ? '' : ''} */} - -

{ this.clickPraise() }} > -
- {memo.praises_count} -

-
-
- - {memo.attachments && !!memo.attachments.length && -
- {this.renderAttachment()} -
- } -
- - {!isCourseEnd && } - - {/* onClick={ this.createNewComment } - enableReplyTo={true} - */} -
-
- {this.props.isAdmin() === true ? - {this.state.commentstype === false ? - : } - : ""} - - 全部回复 - ({memo.total_replies_count}) - -
- - - - - {/* { true ? : -
-
写评论
-
} */} -
- - -
- {total_count > REPLY_PAGE_COUNT && - - } - {!isCourseEnd &&
写评论
} -
- -
-
-
- - ); - } -} - -export default ImageLayerOfCommentHOC()(RouteHOC()(TopicDetail)); diff --git a/src/modules/courses/boards/board.css b/src/modules/courses/boards/board.css deleted file mode 100644 index 2d284a8c..00000000 --- a/src/modules/courses/boards/board.css +++ /dev/null @@ -1,46 +0,0 @@ - - - - -/*必填*/ -/* -.ant-form-item-required::before { - display: none; -} -.ant-form-item-control-wrapper.ant-col-xs-24.ant-col-sm-24::before { - display: inline-block; - margin-right: 8px; - color: #f5222d; - font-size: 14px; - font-family: SimSun, sans-serif; - line-height: 1; - content: '*'; -}*/ -/* -.ant-form-item-control { - display: inline-block; -}*/ -/* form 样式 --------------------------------------------- */ - - - -.topicTitle { - margin-bottom: 8px; -} -.topicTitle .ant-form-item-control-wrapper { - width: 100%; -} - - -.ant-pagination.coursePagination { - text-align: center; - margin-top: 16px; -} - -.setemail{ - margin-left: 20px; -} - -.setemail .ant-checkbox-wrapper{ - margin-top: 8px; -} \ No newline at end of file diff --git a/src/modules/courses/boards/boardsListItem.css b/src/modules/courses/boards/boardsListItem.css deleted file mode 100644 index 3a177134..00000000 --- a/src/modules/courses/boards/boardsListItem.css +++ /dev/null @@ -1,9 +0,0 @@ -.directory_style { - position: absolute; - right: 0; - bottom: 0; - maxSize: 20px; - overflow: hidden; - whiteSpace: nowrap; - textOverflow: ellipsis -} \ No newline at end of file diff --git a/src/modules/courses/boards/common.js b/src/modules/courses/boards/common.js deleted file mode 100644 index b8be4ebd..00000000 --- a/src/modules/courses/boards/common.js +++ /dev/null @@ -1,66 +0,0 @@ -import React, { Component } from 'react'; - -export function RouteHOC(options = {}) { - return function wrap(WrappedComponent) { - return class Wrapper extends Component { - constructor(props) { - super(props); - - this.state = { - - } - } - toDetailPage = (_courseId, boardId, topicId) => { - if (typeof _courseId == "object") { - const topicId = _courseId.topicId - const boardId = _courseId.boardId - const courseId = _courseId.coursesId - this.props.history.push(`/classrooms/${courseId}/boards/${boardId}/messages/${topicId}`) - } else { - this.props.history.push(`/classrooms/${_courseId}/boards/${boardId}/messages/${topicId}`) - } - - } - toEditPage = (_courseId, boardId, topicId) => { - if (typeof _courseId == "object") { - const topicId = _courseId.topicId - const boardId = _courseId.boardId - const courseId = _courseId.coursesId - this.props.history.push(`/classrooms/${courseId}/boards/${boardId}/messages/${topicId}/edit`) - } else { - this.props.history.push(`/classrooms/${_courseId}/boards/${boardId}/messages/${topicId}/edit`) - } - } - toNewPage = (courseId, boardId) => { - this.props.history.push(`/classrooms/${courseId}/boards/${boardId}/messages/new`) - } - toListPage = (_courseId, boardId) => { - if (typeof _courseId == "object") { - const boardId = _courseId.boardId - const courseId = _courseId.coursesId - this.props.history.push(`/classrooms/${courseId}/boards/${boardId}`) - } else { - this.props.history.push(`/classrooms/${_courseId}/boards${boardId ? '/' + boardId : ''}`) - } - } - - render() { - const { snackbarOpen} = this.state; - - - return ( - - - - - - ) - } - } - } -} diff --git a/src/modules/courses/boards/index.js b/src/modules/courses/boards/index.js deleted file mode 100644 index 0f133b19..00000000 --- a/src/modules/courses/boards/index.js +++ /dev/null @@ -1,437 +0,0 @@ -import React, { Component } from "react"; -import { Input, Checkbox, Pagination, Spin } from "antd"; - -import BoardsListItem from './BoardsListItem' - -import Titlesearchsection from '../common/titleSearch/TitleSearchSection' -import ColorCountText from '../common/titleSearch/ColorCountText' -import SendToCourseModal from '../coursesPublic/modal/SendToCourseModal' -import NoneData from "../coursesPublic/NoneData" - -import axios from 'axios' - -import _ from 'lodash' -import './board.css' -import '../css/members.css' -import { RouteHOC } from './common.js' -import { trigger, WordsBtn } from 'educoder' - -class Boards extends Component { - constructor(props) { - super(props); - this.state = { - searchValue: '', - checkAllValue: false, - checkBoxValues: [], - pagination: { - page: 1, - page_size: 15, - total_count: 0 - }, - messages: [ - ], - sort_type: 'time', - boardid: undefined, - isSpin: false - } - } - fetchAll = (searchText, page) => { - this.setState({ - isSpin: true - }) - const _serachText = searchText || this.state.searchValue - const _page = page || this.state.pagination.page - const bid = this.props.match.params.boardId - // - // hot - const sort_type = this.state.sort_type - // page_size - const url = `/boards/${bid}/messages.json?page_size=15&search=${_serachText || ''}&page=${_page}&sort=0&sort_type=${sort_type}` - axios.get(encodeURI(url)).then((response) => { - if (response.data.status == 0 && response.data.data) { - let _newBoards = response.data.data.messages - this.setState({ - messages: _newBoards, - boardName: response.data.data.name, - boardid: response.data.data.id, - parent_id: response.data.data.parent_id, - pagination: response.data.pagination || Object.assign({}, this.state.pagination - , { page: _page, total_count: response.data.data.total_count }), - isSpin: false - }) - } - }) - .catch(function (error) { - console.log(error); - this.setState({ - isSpin: false - }) - }); - } - fetchBoards = () => { - const boardId = this.props.match.params.boardId - const boardsUrl = `/courses/board_list.json?board_id=${boardId}` - axios.get(boardsUrl, {}) - .then((response) => { - if (response.data.status == 0) { - this.setState({ - boards: response.data.data.boards, - course_id: response.data.data.course_id - }) - } - }) - .catch(function (error) { - console.log(error); - }); - } - componentDidMount = () => { - this.setState({ - isSpin: true - }) - this.fetchBoards() - this.fetchAll() - } - - updateNavSuccess = () => { - this.fetchBoards() - if (this.props.match.params.boardId == this.state.boardid) { - this.fetchAll() - } - } - - componentDidUpdate = (prevProps) => { - if (prevProps.match.params.boardId !== this.props.match.params.boardId) { - this.setState({ - isSpin: true - }) - this.clearAllCheck() - this.fetchAll(null, 1) - } - } - moveTo = (board) => { - const len = this.state.checkBoxValues.length - if (len == 0) { - this.props.showNotification('请先在列表中选择要移动的帖子') - return; - } - - const bid = this.props.match.params.boardId - - const checkBoxValues = this.state.checkBoxValues - const url = `/boards/${bid}/messages/bulk_move.json` - axios.put(url, { - ids: checkBoxValues, - to_board_id: board.id - }) - .then((response) => { - if (response.data.status == 0) { - this.props.showNotification('帖子移动成功') - this.props.updataleftNavfun() - this.clearAllCheck() - this.fetchAll() - } - }) - .catch(function (error) { - console.log(error); - }); - } - onDelete = () => { - const len = this.state.checkBoxValues.length - if (len == 0) { - this.props.showNotification('请先选择要删除的帖子') - return; - } - this.props.confirm({ - content: `是否确认删除?`, - onOk: () => { - const bid = this.props.match.params.boardId - - const url = `/boards/${bid}/messages/bulk_delete.json` - axios.delete(url, { - data: { - ids: this.state.checkBoxValues - } - }) - .then((response) => { - if (response.data.status == 0) { - this.clearAllCheck() - this.fetchAll(null, 1) - this.props.updataleftNavfun() - } - }) - .catch(function (error) { - console.log(error); - }); - } - }) - - } - - onSticky = (message) => { - const cid = this.props.match.params.coursesId - const url = `/messages/${message.id}/sticky_top.json` - axios.put(url, { - course_id: cid, - }) - .then((response) => { - if (response.data.status == 0) { - this.fetchAll() - } - }) - .catch(function (error) { - console.log(error); - }); - } - onItemClick = (item) => { - const checkBoxValues = this.state.checkBoxValues.slice(0); - const index = checkBoxValues.indexOf(item.id); - if (index != -1) { - _.remove(checkBoxValues, (listItem) => listItem === item.id) - } else { - checkBoxValues.push(item.id) - } - this.onCheckBoxChange(checkBoxValues) - } - - onPressEnter = (e) => { - clearTimeout(this.timeoutHandler) - this.timeoutHandler = null; - - this.fetchAll(this.state.searchValue, 1) - } - onInputSearchChange = (e) => { - this.setState({ - searchValue: e.target.value - }) - - if (this.timeoutHandler) { - clearTimeout(this.timeoutHandler) - this.timeoutHandler = null; - } - this.timeoutHandler = setTimeout(() => { - this.fetchAll(this.state.searchValue, 1) - }, 1200) - } - addDir = () => { - let { boardid } = this.state; - trigger('boardAdd', parseInt(boardid)) - } - renameDir = () => { - const boardId = this.props.match.params.boardId - trigger('boardRename', { category_id: parseInt(boardId), category_name: this.state.boardName }) - } - onToBoardsNew = () => { - const courseId = this.state.course_id - const boardId = this.props.match.params.boardId - - this.props.toNewPage(courseId, boardId) - } - onCheckAll = (e) => { - this.setState({ - checkAllValue: e.target.checked - }) - const values = this.state.messages.map(item => { - return item.id - }) - if (e.target.checked) { - const concated = this.state.checkBoxValues.concat(values); - const sortedUniqed = _.uniq(concated) - this.setState({ - checkBoxValues: sortedUniqed - }) - } else { - this.setState({ - checkBoxValues: _.difference(this.state.checkBoxValues, values) - }) - } - } - clearAllCheck = () => { - this.setState({ - checkBoxValues: [], - checkAllValue: false - }) - } - onCheckBoxChange = (checkedValues) => { - this.setState({ - checkBoxValues: checkedValues, - checkAllValue: checkedValues.length == this.state.messages.length - }) - console.log('checked = ', checkedValues); - } - onPageChange = (pageNumber) => { - let { checkAllValue } = this.state; - if (checkAllValue === true) { - this.setState({ - checkBoxValues: [], - checkAllValue: false - }) - } else { - this.setState({ - checkBoxValues: [] - }) - } - - this.fetchAll(null, pageNumber) - } - - onSendToOtherCourse = () => { - const len = this.state.checkBoxValues.length - if (len == 0) { - this.props.showNotification('请先在列表中选择要发送的帖子') - return; - } - this.refs.sendToCourseModal.setVisible(true) - } - onSetToOpen = () => { - const { checkBoxValues } = this.state; - if (checkBoxValues.length == 0) { - this.props.showNotification('请先在列表中选择要公开的帖子') - return; - } - const boardId = this.props.match.params.boardId - const url = `/boards/${boardId}/messages/bulk_public.json` - axios.put(url, { - ids: checkBoxValues - }) - .then((response) => { - if (response.data.status == 0) { - this.props.showNotification('操作成功') - this.fetchAll() - } - }) - .catch(function (error) { - console.log(error); - }); - - } - onSortTypeChange = (sort_type) => { - this.setState({ sort_type }, () => { - this.fetchAll() - }) - - } - render() { - const isAdmin = this.props.isAdmin() - const isCourseEnd = this.props.isCourseEnd() - const isAdminOrStudent = this.props.isAdminOrStudent() - let { boardName, searchValue, boards, messages, checkBoxValues, - checkAllValue, pagination, sort_type, parent_id } = this.state; - const { coursedata } = this.props; - - const bid = this.props.match.params.boardId - return ( - - - = 10} - searchPlaceholder={'请输入帖子名称进行搜索'} - firstRowRight={ - - {!isCourseEnd && isAdmin && !parent_id && this.addDir()}>新建目录} - {isAdmin && !!parent_id && this.renameDir()}>目录重命名} - {!isCourseEnd && isAdminOrStudent && this.onToBoardsNew()}>我要发贴} - - } - secondRowLeft={ - pagination ? : '' - } - onPressEnter={this.onPressEnter} - > - - {messages && messages.length == 0 ? "" : isAdmin &&
-
- {isAdmin && 已选 {checkBoxValues.length} 个 (不支持跨页勾选)} -
- {!!isAdmin && - -
  • 删除
  • -
  • 发送
  • - {coursedata && !!coursedata.course_public &&
  • 设为公开
  • } - -
  • - 移动到目录 -
      - {boards && boards.length > 10 &&

      - { this.setState({ dirSearchValue: e.target.value }) }} /> -

      } - { - boards && boards.filter((item) => { - return item.id != bid && (!this.state.dirSearchValue || item.name.indexOf(this.state.dirSearchValue) != -1) - }).map((item, index) => { - return
    • this.moveTo(item)} title={item.name}>{item.name}
    • - }) - } - {isAdmin && !isCourseEnd && -

      - this.addDir()} - >新建目录... -

      - } -
    -
  • -
    - } - -
  • - {sort_type == 'time' ? '时间排序' : '热度排序'} -
      -
    • this.onSortTypeChange('time')}>时间排序
    • -
    • this.onSortTypeChange('hot')}>热度排序
    • -
    -
  • -
    -
    -
    - } - - -
    - - {messages.map((item, index) => { - return ( -
    - : ''} - onItemClick={this.onItemClick} - onSticky={this.onSticky} - > -
    - ) - }) - } -
    -
    -
    - { - (!this.state.isSpin && (!messages || messages.length == 0)) && - } - - {pagination.total_count > 15 && } - -
    - ) - } -} -export default RouteHOC()(Boards); \ No newline at end of file diff --git a/src/modules/courses/exercise/Ecerciseallbackagain.js b/src/modules/courses/exercise/Ecerciseallbackagain.js deleted file mode 100644 index f350d82b..00000000 --- a/src/modules/courses/exercise/Ecerciseallbackagain.js +++ /dev/null @@ -1,275 +0,0 @@ -import React,{ Component } from "react"; -import { Modal,Checkbox,notification} from "antd"; -import axios from 'axios'; - -class Ecerciseallbackagain extends Component{ - constructor(props){ - super(props); - this.state={ - data:undefined, - limit:10, - page:1, - datalist:undefined, - group_ids:undefined - } - } - componentDidMount() { - - let url="/exercises/"+this.props.match.params.Id+"/redo_modal.json"; - - axios.get(url,{params:{ - limit:10, - page:1, - } - }).then((response) => { - - this.setState({ - data:response.data, - datalist:response.data.exercise_users - }) - }).catch((error) => { - this.props.callback() - console.log(error) - }); - - - } - - //勾选实训 - shixunhomeworkedit=(checkedValues)=>{ - let{datalist}=this.state; - if(checkedValues.length===datalist.length){ - this.setState({ - onChangetype:true, - group_ids:checkedValues - }) - }else{ - this.setState({ - group_ids:checkedValues, - onChangetype:false - }) - } - } - - contentViewScroll=(e)=>{ - //滑动到底判断 - let newscrollTop=parseInt(e.currentTarget.scrollTop); - let allclientHeight=e.currentTarget.clientHeight+newscrollTop; - - if(e.currentTarget.scrollHeight-allclientHeight===0||e.currentTarget.scrollHeight-allclientHeight===1||e.currentTarget.scrollHeight-allclientHeight===-1){ - let {page,limit,datalist}=this.state; - let newpage=page+1; - let newdata=datalist; - - let url="/exercises/"+this.props.match.params.Id+"/redo_modal.json"; - - axios.get(url,{params:{ - limit:limit, - page:newpage, - } - }).then((response) => { - - response.data.exercise_users.map((item,key)=>{ - newdata.push(item) - }) - this.setState({ - datalist:newdata, - page:newpage - }) - }).catch((error) => { - console.log(error) - }); - - } - } - - onChange=(e)=>{ - let{datalist}=this.state; - if(e.target.checked===true){ - let id=[] - datalist.map((item,key)=>{ - id.push(item.user_id) - }) - - this.setState({ - group_ids:id, - onChangetype:e.target.checked - }) - }else{ - this.setState({ - group_ids:[], - onChangetype:e.target.checked - }) - } - } - - isSave=()=>{ - let{group_ids}=this.state; - if(group_ids===undefined||group_ids.length===0){ - notification.open({ - message:"提示", - description:"请先选择学生" - }); - return - } - let url="/exercises/"+this.props.match.params.Id+"/redo_exercise.json"; - axios.post(url, { - user_ids: group_ids, - }) - .then((response) => { - if (response.data.status === 0) { - this.props.callback(1) - notification.open({ - message:"提示", - description:response.data.message - }); - } - // else if(response.data.status === -1){ - // notification.open({ - // message: '参数错误', - // }); - // }else if(response.data.status === -2){ - // notification.open({ - // message: '当前作业不支持查重', - // }); - // }else if(response.data.status === -3){ - // notification.open({ - // message: '正在查重中', - // }); - // }else if(response.data.status === -4){ - // notification.open({ - // message: '查重异常', - // }); - // } - }) - .catch(function (error) { - console.log(error); - }); - } - - issCancel=()=>{ - this.props.callback() - } - - render(){ - let {datalist,group_ids,onChangetype}=this.state; - - console.log() - return( -
    - - -
    - - - -
    学生将得到一次重新答题的机会,现有的答题情况将被清空
    -
      -
    • 姓名
    • -
    • 学号
    • -
    • 成绩
    • -
    - - {datalist===undefined?"": -
      - - - { datalist.map((item,key)=>{ - return( -
      -
    • - - {item.user_name} - -
    • -
    • - {item.student_id} -
    • -
    • - {item.user_score} -
    • -
      - ) - })} - -
      -
    - } - -
    - {onChangetype===true?"清除":"全选"} -
    - -
    - 取消 - 确认 -
    - -
    -
    -
    - ) - } -} -export default Ecerciseallbackagain; diff --git a/src/modules/courses/exercise/Ecercisemount.js b/src/modules/courses/exercise/Ecercisemount.js deleted file mode 100644 index 94d29eec..00000000 --- a/src/modules/courses/exercise/Ecercisemount.js +++ /dev/null @@ -1,247 +0,0 @@ -import React,{Component} from "react"; -import { Form, Select, Input, Button,Checkbox,DatePicker} from "antd"; -import locale from 'antd/lib/date-picker/locale/zh_CN'; - -import "../css/Courses.css"; -import CoursesListType from '../coursesPublic/CoursesListType'; - -const { Option } = Select; -const CheckboxGroup = Checkbox.Group; - -class Ecercisemount extends Component{ - - constructor(props){ - super(props) - this.state={ - - } - } - - componentDidMount(){ - - } - handleSubmit = (e) => { - e.preventDefault(); - this.props.form.validateFields((err, values) => { - if (!err) { - console.log('Received values of form: ', values); - } - }); - } - - handleSelectChange = (value) => { - console.log(value); - this.props.form.setFieldsValue({ - note: `Hi, ${value === 'male' ? 'man' : 'lady'}!`, - }); - } - render(){ - const { getFieldDecorator } = this.props.form; - const dateFormat = 'YYYY-MM-DD HH:mm:ss'; - return( - - -
    -
    -
    - -
    -

    Java语言之控制语句

    - - - - this.props.history.goBack()} className="color-grey-6 fr font-16 ml20 mt18 mr20">返回 - 实训详情 -
    - -
    - -
    - -
    - {/*内容*/} -
    - - - - {getFieldDecorator("TestingProfile")( - 统一设置 - )} - (选中则所有分班使用相同的发布设置,否则各个分班单独设置) - -
    - 发布时间: - - {getFieldDecorator("startTime")( - - )} - (发布之前,学生不会收到问卷) - -
    - -
    - 截止时间: - - {getFieldDecorator("endTime")( - - )} - (截止时间点,系统将自动提交所有学生的答题,学生将不能继续答题) - - -
    - -
    - -
    - -
    - - - -
    - - 答题时长: - - {getFieldDecorator("TestingProfile" - , { - rules: [{ - pattern: /^[1-9]\d*$/, - message: '答题时长必须为正整数', - }], - })( - - )} - 分钟 - (选中则所有分班使用相同的发布设置,否则各个分班单独设置) - -
    - - -
    - - - -
    - - {getFieldDecorator("subject", { - valuePropName: 'checked', - })( - 题目顺序随机打乱 - )} - (选中则学生答题时,题目顺序按照题型随机显示) - -
    - -
    - - {getFieldDecorator("options", { - valuePropName: 'checked', - })( - 选项顺序随机打乱 - )} - (选中则学生答题时,选项顺序随机显示) - -
    -
    - -
    - -
    - - - -
    - - {getFieldDecorator("opergrdee", { - valuePropName: 'checked', - })( - 公开成绩 - )} - (选中则在截止时间之后对提交答题的课堂成员公开所有成绩,否则不公开) - -
    - -
    - - {getFieldDecorator("openanswer", { - valuePropName: 'checked', - })( - 公开答案 - )} - (选中则在截止时间之后对提交答题的课堂成员公开试卷题目的答案,否则不公开) - -
    - -
    - - {getFieldDecorator("openstatisticss", { - valuePropName: 'checked', - })( - 公开统计 - )} - (选中则在截止时间之后对提交答题的课堂成员公开答题统计,否则不公开) - -
    - -
    - -
    - - - - -
    - - {/*提交*/} - 取消 -
    -
    - -
    - -
    -
    -
    - -
    - - ) - } -} -const EcercisemountApp = Form.create({ name: 'coursesNew' })(Ecercisemount); -export default EcercisemountApp; diff --git a/src/modules/courses/exercise/Exercise.js b/src/modules/courses/exercise/Exercise.js deleted file mode 100644 index bb161e00..00000000 --- a/src/modules/courses/exercise/Exercise.js +++ /dev/null @@ -1,597 +0,0 @@ -import React,{ Component } from "react"; -import {Checkbox, Pagination,Menu,Spin } from "antd"; -import ExerciseListItem from './ExerciseListItem' -import axios from 'axios'; -import Modals from '../../modals/Modals'; -import '../css/members.css' -import { WordsBtn,on, publicSearchs } from 'educoder' -import '../css/busyWork.css' -import _ from 'lodash'; -import moment from 'moment' -import UseBank from "../busyWork/UseBank"; -import ImmediatelyPublish from "../poll/pollPublicBtn/ImmediatelyPublish"; -import ImmediatelyEnd from "../poll/pollPublicBtn/ImmediatelyEnd"; -import NoneData from "../coursesPublic/NoneData"; -import HomeworkModal from "../coursesPublic/HomeworkModal"; - -class Exercise extends Component{ - constructor(props){ - super(props); - this.state={ - modalname:undefined, - modaltype:undefined, - modalsBottomval:undefined, - visible:false, - Topval:undefined, - Topvalright:undefined, - Botvalleft:undefined, - Botval:undefined, - starttime:undefined, - endtime:undefined, - Cancelname:undefined, - Savesname:undefined, - Cancel:undefined, - Saves:undefined, - StudentList_value:undefined, - addname:undefined, - addnametype:false, - addnametab:undefined, - addcanner:undefined, - addsave:undefined, - type:undefined, - search:undefined, - page:1, - limit:15, - checkBoxValues:[], - Exercisetype:"exercise", - isSpin:false - } - } - - // 加载列表 - componentDidMount(){ - this.reloadList(); - on('updateNavSuccess', this.updateNavSuccess) - } - - updateNavSuccess=()=>{ - this.reloadList(); - } - - reloadList=()=>{ - this.setState({ - isSpin:true - }) - let{type,search,page,limit}=this.state - this.InitList(type,search,page,limit); - } - - // 获取列表数据 - InitList=(type,search,page,limit)=>{ - this.setState({ - isSpin:true - }) - let coursesId=this.props.match.params.coursesId; - let url='/courses/'+coursesId+'/exercises.json'; - - axios.get(url, - { - params: { - type:type, - search: search, - page: page, - limit: limit - } - } - ).then((result)=>{ - this.setState({ - exercises_counts:result.data.exercises_counts, - course_types:result.data.course_types, - exercises:result.data.exercises, - checkAllValue:false, - checkBoxValues:[], - isSpin:false, - page:page - }) - }).catch((error)=>{ - this.setState({ - isSpin:false, - }) - }) - } - - - inputStudent=(e)=>{ - this.setState({ - StudentList_value:e.target.value, - }) - } - // 搜索 - searchInfo=(value)=>{ - this.setState({ - type:undefined, - page:1, - StudentList_value:value - }) - let{type,limit}=this.state; - this.InitList(type,value,1,limit) - } - - - changeType=(e)=>{ - this.setState({ - type:e.key==="0"?undefined:e.key, - page:1, - checkAllValue:false, - checkBoxValues:[] - }) - let{StudentList_value,page,limit}=this.state; - this.InitList(e.key==="0"?undefined:e.key,StudentList_value,1,limit) - } - - //切换分页 - changePage=(pageNumber)=>{ - this.setState({ - page:pageNumber, - checkBoxValues:[] - }) - let{type,StudentList_value,limit}=this.state - this.InitList(type,StudentList_value,pageNumber,limit); - } - - onselectfifteen = () => { - this.setState({ - Modalstype:true, - Modalstopval:"选择条数不能大于15条", - ModalSave:this.cancelmodel, - modalsBottomval:"", - Loadtype:true - }) - } - - cancelmodel=()=>{ - - this.setState({ - Modalstype:false, - Loadtype:false, - Modalstopval:"", - modalsBottomval:"", - ModalCancel:"", - ModalSave:"", - - }) - - } - onCheckBoxChange = (checkedValues) => { - let {exercises}=this.state; - if( checkedValues.length>15){ - this.onselectfifteen() - return - } - - this.setState({ - checkBoxValues: checkedValues, - checkAllValue: checkedValues.length == exercises.length - }) - } - - - onItemClick = (item) => { - const checkBoxValues = this.state.checkBoxValues.slice(0); - const index = checkBoxValues.indexOf(item.id); - if (index != -1) { - _.remove(checkBoxValues, (listItem)=> listItem === item.id) - } else { - checkBoxValues.push(item.id) - } - this.onCheckBoxChange(checkBoxValues) - } - - // 全选or反选 - onCheckAll = (e) => { - this.setState({ - checkAllValue: e.target.checked - }) - const values = this.state.exercises.map(item => { - return item.id - }) - if (e.target.checked) { - const concated = this.state.checkBoxValues.concat(values); - const uniq=_.uniq(concated) - this.setState({ - checkBoxValues: uniq - }) - } else { - this.setState({ - checkBoxValues: _.difference(this.state.checkBoxValues, values) - }) - } - } - // 题库选用成功后刷新页面 - useBankSuccess=(checkValue,value)=>{ - - let{type,StudentList_value,page,limit}=this.state; - let coursesId=this.props.match.params.coursesId; - let url=`/courses/${coursesId}/exercises/publish_modal.json`; - axios.get(url,{ - params:{ - check_ids:value - } - }).then((response) => { - if(response.status===200){ - let list=[]; - if(response.data.course_info){ - for(var i=0;i 0 ? 1 : 2, - visible:true, - Topval:"学生将立即收到试卷", - // Botvalleft:"暂不发布", - Botval:`本操作只对"未发布"的试卷有效`, - starttime:"发布时间:"+moment(moment(new Date())).format("YYYY-MM-DD HH:mm"), - starttimes:this.props.getNowFormatDates(1), - endtime:"截止时间:"+this.props.getNowFormatDates(2), - Cancelname:"暂不发布", - Savesname:"立即发布", - Cancel:this.homeworkhide, - Saves:this.homeworkstartend, - course_groups:list, - checkBoxValues:value - }) - - - } - }).catch((error) => { - console.log(error) - }); - - } - - - //删除或者设为公开 - ActionPoll=(value)=>{ - - let CourseId=this.props.match.params.coursesId; - let{type,StudentList_value,page,limit}=this.state; - - //判断是否有选中数据 - if(this.state.checkBoxValues.length==0){ - // this.setState({ - // Modalstype:true, - // Modalstopval:"请先在列表中选择数据", - // Loadtype:true, - // ModalSave:this.cancelmodel, - // }) - this.props.showNotification("请先在列表中选择数据"); - }else{ - if(value != "bank"){ - this.setState({ - Modalstype:true, - Modalstopval:value=="delete"?"已提交作品将全部被删除,不可恢复":"公开后非课堂成员也可以访问查看", - modalsBottomval:value=="delete"?"是否确认删除?":"是否确认公开?", - Loadtype:false, - boxType:value, - ModalSave:this.ModalAction - }) - }else{ - - //加入题库 - let url=`/courses/${CourseId}/exercises/join_exercise_banks.json`; - axios.post((url), { - check_ids: this.state.checkBoxValues - }) - .then((result)=>{ - if(result.data.status==0){ - this.props.showNotification(`${result.data.message}`); - this.setState({ - Modalstype:false, - Modalstopval:"", - modalsBottomval:"", - Loadtype:false, - checkBoxValues:[] - }) - this.InitList(type,StudentList_value,page,limit) - this.props.updataleftNavfun() - } - }).catch((error)=>{ - console.log(error); - }) - } - } - } - //确定删除或者设为公开 - ModalAction=()=>{ - let CourseId=this.props.match.params.coursesId; - let{type,StudentList_value,page,limit}=this.state; - this.setState({ - Modalstypeloding:true - }) - if(this.state.checkBoxValues.length==0){ - this.setState({ - Modalstype:false, - Modalstopval:"", - modalsBottomval:"", - Loadtype:false, - checkBoxValues:[], - Modalstypeloding:false - }) - }else{ - if(this.state.boxType=="delete"){ - //删除 - let url=`/courses/${CourseId}/exercises/destroys.json`; - axios.post((url), { - check_ids: this.state.checkBoxValues - }) - .then((result)=>{ - if(result.data.status==0){ - this.props.showNotification(`${result.data.message}`); - this.setState({ - Modalstype:false, - Modalstopval:"", - modalsBottomval:"", - Loadtype:false, - checkBoxValues:[], - Modalstypeloding:false - }) - this.InitList(type,StudentList_value,page,limit); - this.props.updataleftNavfun(); - } - }).catch((error)=>{ - console.log(error); - }) - }else if(this.state.boxType=="public"){ - //设为公开 - - let url=`/courses/${CourseId}/exercises/set_public.json`; - axios.post((url), { - check_ids: this.state.checkBoxValues - }) - .then((result)=>{ - if(result.data.status==0){ - this.props.showNotification(`${result.data.message}`); - this.setState({ - Modalstype:false, - Modalstopval:"", - modalsBottomval:"", - Loadtype:false, - checkBoxValues:[] - }) - let{type,StudentList_value}=this.state - this.InitList(type,StudentList_value,1); - } - }).catch((error)=>{ - console.log(error); - }) - } - } - } - - //暂不发布 - homeworkhide=()=>{ - let {type,StudentList_value,page,limit}=this.state; - this.setState({ - modalname:undefined, - modaltype:undefined, - visible:false, - Topval:undefined, - Topvalright:undefined, - Botvalleft:undefined, - Botval:undefined, - starttime:undefined, - endtime:undefined, - Cancelname:undefined, - Savesname:undefined, - Cancel:undefined, - Saves:undefined, - StudentList_value:undefined, - addname:undefined, - addnametype:false, - addnametab:undefined - }) - - this.InitList(type,StudentList_value,page,limit) - } - - getcourse_groupslist=(id)=>{ - this.setState({ - chooseId:id - }) - } - - // 确定立即发布 - homeworkstartend=(idss,endtime)=> { - let {chooseId,checkBoxValues,type,StudentList_value,page,limit} = this.state; - - let coursesId = this.props.match.params.coursesId; - - let url = `/courses/${coursesId}/exercises/publish.json` - axios.post(url, { - check_ids: checkBoxValues, - group_ids: chooseId, - end_time:endtime - }).then((result) => { - if (result) { - this.props.showNotification(result.data.message); - this.homeworkhide(); - - // 调用父级公共头部的接口刷新 - // this.props.action() - this.InitList(type,StudentList_value,page,limit) - } - }).catch((error) => { - console.log(error); - }) - - } - - render(){ - let { - checkAllValue, - StudentList_value, - exercises_counts, - course_types, - exercises, - checkBoxValues, - - pageSize, - page, - }=this.state; - - let {child}=this.props; - - return( - - - {/* 公用的提示弹框 */} - - - this.getcourse_groupslist(id)} - /> - -
    -

    - {exercises_counts && exercises_counts.left_banner_name} - { - this.props.isAdmin()===true? -

  • -

    - {course_types&&course_types.course_status===0?新建:""} -
  • :"" - } - -

    -
    -

    - 共{exercises_counts && exercises_counts.exercises_total_counts}个试卷 - 已发布:{exercises_counts && exercises_counts.exercises_published_counts}个 - 未发布:{exercises_counts && exercises_counts.exercises_unpublish_counts}个 -

    -
    - {publicSearchs("请输入名称进行搜索",this.searchInfo,this.inputStudent,this.inputStudent)} -
    -
    -
    - - 全部 - 考试中 - {this.props.isAdmin()?未发布:""} - 已截止 - -
    -
    - - {this.props.isAdmin()?exercises && exercises.length ===0?"":
    -
    - 已选 {checkBoxValues.length} 个 (不支持跨页勾选) -
    -
  • this.ActionPoll("delete")}>删除
  • -
  • - -
  • -
  • - -
  • - { - course_types && course_types.course_is_public == 1 &&
  • this.ActionPoll("public")}>设为公开
  • - } - {this.props.user&&this.props.user.main_site===true?
  • this.ActionPoll("bank")}>加入题库
  • :""} -
    -
    - -
    :
    } - - - - { - exercises && exercises.length > 0 && - - -
    - { - exercises && exercises.map((item,key)=>{ - return( - } - > - ) - }) - } -
    -
    - - } -
    - { - exercises && exercises.length ===0 && - } - { - exercises_counts && exercises_counts.exercises_all_counts > 15 ? -
    - -
    - : - "" - } - - -
    - ) - } -} -export default Exercise; diff --git a/src/modules/courses/exercise/ExerciseDisplay.js b/src/modules/courses/exercise/ExerciseDisplay.js deleted file mode 100644 index 27b9bd9c..00000000 --- a/src/modules/courses/exercise/ExerciseDisplay.js +++ /dev/null @@ -1,182 +0,0 @@ -import React,{ Component } from "react"; -import axios from 'axios' - -import SingleDisplay from './new/SingleDisplay' -import JudgeDisplay from './new/JudgeDisplay' -import NullDisplay from './new/NullDisplay' -import MainDisplay from './new/MainDisplay' -import ShixunDisplay from './new/ShixunDisplay' -import ShixunProgramming from './new/ShixunProgramming' -import './new/common.css' - - -class ExerciseDisplay extends Component{ - constructor(props){ - super(props); - - - this.state = { - exercise_questions: [], - exercise_group_id:[], - page:1, - limit:10, - searchtext:"", - order: "end_at", - is_md:false - } - } - _getRequestParams() { - const { order, exercise_group_id,searchtext, page ,limit} = this.state - return { - page, - search:searchtext, - order, - limit: limit, - group_id:exercise_group_id, - } - } - componentDidMount = () => { - const Id = this.props.match.params.Id - if (Id) { - const url = `/${this.props.urlPath || 'exercises'}/${Id}.json` - axios.get(url) - .then((response) => { - if (response.data.exercise) { - response.data.exercise.exercise_description = response.data.exercise.exercise_description || response.data.exercise.description - response.data.exercise.exercise_name = response.data.exercise.exercise_name || response.data.exercise.name - response.data.exercise.exercise_status = response.data.exercise.exercise_status == undefined ? 1 : response.data.exercise.exercise_status - this.setState({...response.data}) - this.setState({ - is_md:response.data.exercise.is_md - }) - this.props.detailFetchCallback && this.props.detailFetchCallback(response); - } else { - this.props.detailFetchCallback && this.props.detailFetchCallback(response); - } - }) - .catch(function (error) { - console.log(error); - }); - } - try { - this.props.triggerRef(this); - }catch (e) { - - } - } - _getRequestParams() { - const { order, exercise_group_id,searchtext, page ,limit} = this.state - return { - page, - search:searchtext, - order, - limit: limit, - group_id:exercise_group_id, - } - } - render() { - const { exercise_questions,exercise,exercise_types} = this.state; - const commonHandler = {} - return( -
    -
    - -
    {exercise&&exercise.exercise_name}
    -
    {exercise&&exercise.exercise_description}
    -
    -
    -

    - { - exercise_types && exercise_types.q_singles > 0 && - 单选题 {exercise_types.q_singles} 题,共 {exercise_types && exercise_types.q_singles_scores} 分 - } - { - exercise_types && exercise_types.q_doubles > 0 && - 多选题 {exercise_types.q_doubles} 题,共 {exercise_types && exercise_types.q_doubles_scores} 分 - } - { - exercise_types && exercise_types.q_judges > 0 && - 判断题 {exercise_types.q_judges} 题,共 {exercise_types && exercise_types.q_judges_scores} 分 - } - { - exercise_types && exercise_types.q_nulls > 0 && - 填空题 {exercise_types.q_nulls} 题,共 {exercise_types && exercise_types.q_nulls_scores} 分 - } - { - exercise_types && exercise_types.q_mains > 0 && - 简答题 {exercise_types.q_mains} 题,共 {exercise_types && exercise_types.q_mains_scores} 分 - } - { - exercise_types && exercise_types.q_shixuns > 0 && - 实训题 {exercise_types.q_shixuns} 题,共 {exercise_types && exercise_types.q_shixuns_scores} 分 - } - { - exercise_types && exercise_types.q_pros > 0 && - 编程题 {exercise_types.q_pros} 题,共 {exercise_types && exercise_types.q_pros_scores} 分 - } - {exercise_types &&exercise_types.q_scores} - 合计 {exercise_types &&exercise_types.q_counts} 题: -

    -
    - { exercise_questions.map((item, index) => { - if (item.question_type == 0 || item.question_type == 1) { - - return - - } else if (item.question_type == 2) { - - - return - - } else if (item.question_type == 3) { - - - return - - } else if (item.question_type == 4) { - - // - return - - } else if (item.question_type == 5) { - - - return - - }else if (item.question_type == 6) { - - return - }else{ - return
    - } - - })} -
    - ) - } -} -// RouteHOC() -export default (ExerciseDisplay); diff --git a/src/modules/courses/exercise/ExerciseListItem.js b/src/modules/courses/exercise/ExerciseListItem.js deleted file mode 100644 index 9b1d6b29..00000000 --- a/src/modules/courses/exercise/ExerciseListItem.js +++ /dev/null @@ -1,268 +0,0 @@ -import React,{ Component } from "react"; - -import {Link} from 'react-router-dom'; -import moment from 'moment'; -import {Tooltip} from 'antd'; -import Modals from '../../modals/Modals'; -import CoursesListType from '../coursesPublic/CoursesListType'; -import { formatDuring ,handleDateString} from 'educoder'; - -import '../css/members.css'; -import '../css/busyWork.css'; -import CourseLayoutcomponent from "./Exercise"; - -const dataformat="YYYY-MM-DD HH:mm"; -const polls_status={1:"未发布",2:"提交中",3:"已截止",4:"已结束"} -class ExerciseListItem extends Component{ - constructor(props){ - super(props); - this.state={ - Modalstype:false - } - } - - setgameexercise=(url)=>{ - - let{item}=this.props; - if(item.time>0){ - this.setState({ - Modalstype:true, - ModalSave:()=>this.props.history.push(url), - Modalstopval:`答题时长限制${item.time}分钟,从首次答题开始实行不间断计时`, - modalsBottomval:'请确认是否有充足的答题时间?', - }); - }else{ - this.setState({ - Modalstype:true, - ModalSave:()=>this.props.history.push(url), - Modalstopval:"是否确认开始答题?", - modalsBottomval:' ', - }) - } - - } - - cancelmodel=()=>{ - this.setState({ - Modalstype:false, - ModalSave:' ', - Modalstopval:' ', - modalsBottomval:' ', - Loadtype:false - }) - } - - toDetailPage=(url)=>{ - - if(this.props.checkIfLogin()===false){ - this.props.showLoginDialog() - return - } - // if(this.props.checkIfProfileCompleted()===false){ - // this.setState({ - // AccountProfiletype:true - // }) - // return - // } - // if(this.props.checkIfProfessionalCertification()===false){ - // this.props.showProfileCompleteDialog() - // return - // } - - this.props.history.push(url); - } - render(){ - let{item,checkBox,index}=this.props; - let {coursesId,Id}=this.props.match.params - const IsAdmin =this.props.isAdmin(); - const isAssistant=this.props.isAssistant(); - - const IsStudent =this.props.isStudent(); - - return( -
    window.$(`.exerciseitem${index} input`).click() }> - { - IsAdmin && - - {checkBox} - - } - {/* 公用的提示弹框 */} - {this.state.Modalstype===true?:""} - -
    -

    - - {/*{item.exercise_name}*/} - { - this.props.isAdmin()? this.toDetailPage(`/classrooms/${coursesId}/exercises/${item.id}/student_exercise_list?tab=0`)}>{item.exercise_name}:"" - } - - { - this.props.isStudent()? - this.toDetailPage(`/classrooms/${coursesId}/exercises/${item.id}/student_exercise_list?tab=0`)}>{item.exercise_name}:"" - } - - { - this.props.isNotMember()? item.lock_status === 0 ? - {item.exercise_name} - : this.toDetailPage(`/classrooms/${coursesId}/exercises/${item.id}/student_exercise_list?tab=0`)}>{item.exercise_name}:"" - } - - { - item.lock_status === 0 ? - - - - :"" - } - - {/**/} - - - {/*未发布、提交中、补交中、已开启补交、未开启补交、评阅中、已结束*/} - - {/*

  • */} - {/**/} - {/*
      */} - {/*
    • 编辑
    • */} - {/*
    • 设置
    • */} - {/*
    */} - {/*
  • */} -

    -

    - { item.author && {item.author} } - {item.exercise_status===2||item.exercise_status===3?已提交人数:{item&&item.exercise_answer}/{item&&item.exercise_users} :""} - {item.exercise_status===2?考试中人数:{item&&item.exercise_answerings} :""} - {item.exercise_status===2||item.exercise_status===3?待评阅试卷:{item&&item.unreview_count} :""} - { - item.exercise_status ===2? - - {"考试剩余时间:"+item.exercise_left_time} - :"" - } - - {/* {item.exercise_status===1?"":{item.exercise_answer} 已答} - {item.exercise_status===1?"":{item.exercise_unanswer} 未答} - {item.unreview_count===null||item.exercise_status===1?"":{item.unreview_count} 未评数 } */} - - { - item.exercise_status ===1? item.publish_time ===null? - 创建于{moment(item.created_at).fromNow()} - : 将发布于{ - moment(item.publish_time).format('YYYY-MM-DD HH:mm') - } :"" - } - - - { - item.exercise_left_time===null?"":item.exercise_status ===3? - - {"截止剩余时间:"+item.exercise_left_time} - :"" - } - {/*{*/} - {/*item.exercise_status ==2?"":*/} - {/* 发布于{moment(item.exercise_left_time).fromNow()} */} - {/*}*/} - - - - - - { IsAdmin &&

    - { - isAssistant===true? - ( - item&&item.assistant_auth===true? - this.toDetailPage(`/classrooms/${coursesId}/exercises/${item.id}/student_exercise_list?tab=0`)}>查看详情 - : - this.toDetailPage(`/classrooms/${coursesId}/exercises/${item.id}/student_exercise_list?tab=0`)}>查看详情 - ) - : - this.toDetailPage(`/classrooms/${coursesId}/exercises/${item.id}/student_exercise_list?tab=0`)}>查看详情 - } - - { - isAssistant===true? - ( - item&&item.assistant_auth===true? - 编辑 - : - "" - ) - : - 编辑 - } - 设置 -
    } - -

    - {/*{*/} - {/*IsAdmin &&*/} - {/*
    */} - {/*
      */} - {/*
    • */} - {/**/} - {/*
        */} - {/*
      • 编辑
      • */} - {/*
      • 设置
      • */} - {/*
      */} - {/*
    • */} - {/*
    */} - {/*
    */} - {/*}*/} - - - { - IsStudent && -
    -
  • this.toDetailPage(`/classrooms/${coursesId}/exercises/${item.id}/student_exercise_list?tab=0`)}>查看详情
  • - {item.current_status ===0&&item.exercise_status>1?
  • 继续答题
  • : - item.current_status ===1&&item.exercise_status>1?
  • 查看答题
  • : - item.current_status ===2&&item.exercise_status>1?
  • this.setgameexercise(`/classrooms/${coursesId}/exercises/${item.id}/users/${this.props.current_user.login}`)}>开始答题
  • :""} -
    - } - - { - this.props.isNotMember()? item.lock_status === 0 ? - "" - :
    -
  • this.toDetailPage(`/classrooms/${coursesId}/exercises/${item.id}/student_exercise_list?tab=0`)}>查看详情
  • -
    :"" - } - -
    -
    - ) - } -} -export default ExerciseListItem diff --git a/src/modules/courses/exercise/ExerciseNew.js b/src/modules/courses/exercise/ExerciseNew.js deleted file mode 100644 index ab3ea814..00000000 --- a/src/modules/courses/exercise/ExerciseNew.js +++ /dev/null @@ -1,57 +0,0 @@ -import React, { Component } from "react"; - -import { CBreadcrumb } from 'educoder'; - -import './new/common.css' -import '../css/Courses.css' - -import ExerciseNewCommon from './ExerciseNewCommon' - -class ExerciceNew extends Component { - constructor(props) { - super(props); - this.state = { - left_banner_id: null - } - } - initData = (data) => { - this.setState({ left_banner_id: data.left_banner_id }) - } - componentDidMount() { - document.title = this.props.coursedata && this.props.coursedata.name; - } - render() { - let { left_banner_id } = this.state; - const { current_user } = this.props - const courseId = this.props.match.params.coursesId; - let pramsids = this.props.match.params.Id; - return ( -
    - -
    - {current_user && } - -

    - {pramsids && pramsids ? "编辑" : "新建"}试卷 - this.props.history.push(`/classrooms/${courseId}/exercises/${left_banner_id}`)}> - 返回 - -

    - - -
    -
    - ) - } -} -export default ExerciceNew; diff --git a/src/modules/courses/exercise/ExerciseNewCommon.js b/src/modules/courses/exercise/ExerciseNewCommon.js deleted file mode 100644 index cdc81bbe..00000000 --- a/src/modules/courses/exercise/ExerciseNewCommon.js +++ /dev/null @@ -1,553 +0,0 @@ -import React, { Component } from "react"; - -import { Tooltip } from 'antd' -import { Q_TYPE_SINGLE, Q_TYPE_JUDGE, Q_TYPE_NULL, Q_TYPE_MAIN, Q_TYPE_SHIXUN } from './new/common' -import axios from 'axios' -import "../common/formCommon.css" -import { ActionBtn } from 'educoder'; - -import SingleEditor from './new/SingleEditor' -import SingleDisplay from './new/SingleDisplay' -import JudgeEditor from './new/JudgeEditor' -import JudgeDisplay from './new/JudgeDisplay' -import NullEditor from './new/NullEditor' -import NullDisplay from './new/NullDisplay' -import MainEditor from './new/MainEditor' -import MainDisplay from './new/MainDisplay' -import ShixunEditor from './new/ShixunEditor' -import ShixunDisplay from './new/ShixunDisplay' -import ShixunProgramming from './new/ShixunProgramming' -import ShixunChooseModal from '../coursesPublic/ShixunChooseModal' -import ExerciseForm from './exercise-new-form' - -import update from 'immutability-helper' -import './new/common.css' -import '../css/Courses.css' -const $ = window.$ -class ExerciseNewCommon extends Component { - constructor(props) { - super(props); - - this.state = { - exercise_questions: [], - exercise_name: '', - is_md: true, - exercise_description: '', - exercise_types: {}, - editMode: !this.props.match.params.Id, - } - } - - // 已发布试卷编辑保存的确认弹框 - changeScore = (question_id, answerArray) => { - this.props.confirm({ - content: '修改了标准答案', - subContent: "是否重新计算学生答题的成绩?", - onOk: () => { - this.sureChangeScore(question_id, answerArray) - }, - onCancel: () => { - this.addSuccess(); - } - }) - } - - // 已发布试卷修改答案确认修改分数 - sureChangeScore = (question_id, answerArray) => { - let url = `/exercise_questions/${question_id}/update_scores.json` - axios.post((url), { - standard_answers: answerArray - }).then((result) => { - if (result) { - this.props.showNotification(`${result.data.message}`); - this.addSuccess(); - } - }).catch((error) => { - console.log(error); - }) - } - - fetchExercise = () => { - const Id = this.props.match.params.Id - this.isEdit = this.props.isEdit || !!Id - if (this.isEdit) { - const url = this.props.exercise_url ? `/${this.props.exercise_url}/${Id}.json` : `/exercises/${Id}/edit.json` - axios.get(url) - .then((response) => { - if (response.data.exercise) { - const { exercise, ...others } = response.data - this.setState({ - ...exercise, - ...others, - editMode: false - }) - this.props.initData && this.props.initData(response.data) - } - }) - .catch(function (error) { - console.log(error); - }); - } else { - const courseId = this.props.match.params.coursesId; - - const newUrl = `/courses/${courseId}/exercises/new.json` - axios.get(newUrl) - .then((response) => { - if (response.data.status == 0) { - this.setState({ - ...response.data - }) - } - }) - .catch(function (error) { - console.log(error); - }); - } - } - componentDidMount = () => { - this.fetchExercise() - } - - onSaveExercise = (data) => { - const exercise_id = this.props.match.params.Id - const courseId = this.props.match.params.coursesId - - if (this.isEdit) { - const editUrl = `/${this.props.exercise_url ? this.props.exercise_url : 'exercises'}/${exercise_id}.json` - axios.put(editUrl, { ...data }) - .then((response) => { - if (response.data.status == 0) { - this.setState({ ...data, editMode: false }) - this.props.showNotification('试卷编辑成功') - } - }) - .catch(function (error) { - console.log(error); - }); - } else { - const url = `/courses/${courseId}/exercises.json` - axios.post(url, { - ...data - }) - .then((response) => { - if (response.data.status == 0) { - this.setState({ ...data, editMode: false }) - this.props.showNotification('试卷新建成功') - const exercise_id = response.data.data.exercise_id; - this.isEdit = true; - this.props.history.replace(`/classrooms/${courseId}/exercises/${exercise_id}/edit`); - - } - }) - .catch(function (error) { - console.log(error); - }); - } - } - exercise_name_change = (e) => { - this.setState({ exercise_name: e.target.value }) - } - exercise_description_change = (e) => { - this.setState({ exercise_description: e.target.value }) - } - // #问题的类型,0为单选题,1为多选题,2为判断题,3为填空题,4为主观题,5为实训题 - _checkIsEditing = () => { - if (this.editingId && $(this.editingId).length) { - this.props.showNotification('请先保存或取消当前正在编辑的问题。') - $("html").animate({ scrollTop: $(this.editingId).offset().top - 100 }) - return true - } - return false - } - onEditorCancel = () => { - this.editingId = null; - // 找到编辑或新建的item,新建就删掉item,编辑就isNew改为false - const { exercise_questions } = this.state - let index = -1; - for (let i = 0; i < exercise_questions.length; i++) { - if (exercise_questions[i].isNew == true) { - index = i; - break; - } - } - if (exercise_questions[index].question_id) { // 编辑 - this.setState( - (prevState) => ({ - exercise_questions: update(prevState.exercise_questions, { [index]: { isNew: { $set: false } } }) - // update(prevState.exercise_questions, {$splice: [[index, 1]]}) - }) - ) - } else { // 新建 - this.setState( - (prevState) => ({ - exercise_questions: update(prevState.exercise_questions, { $splice: [[index, 1]] }) - }) - ) - } - } - addQuestion = (question_id_to_insert_after, type) => { - if (!this.isEdit) { - this.props.showNotification('请先输入试卷标题,并保存试卷') - return; - } - if (this._checkIsEditing()) { - return; - } - if (type == Q_TYPE_SHIXUN) { - this.addShixun(question_id_to_insert_after) - } else { - this.addEditingQuestion(type, question_id_to_insert_after) - } - } - chooseShixun = (array) => { - this.addEditingQuestion(Q_TYPE_SHIXUN, this.question_id_to_insert_after, { - shixun_id: array[0] - }) - } - chooseShixunSuccess = () => { - this.refs.shixunChooseModal.setVisible(false) - } - addShixun = (question_id_to_insert_after) => { - if (!this.isEdit) { - this.props.showNotification('请先输入试卷标题,并保存试卷') - return; - } - // TODO 弹框选择实训 - if (this._checkIsEditing()) { - return; - } - this.refs.shixunChooseModal.setVisible(true) - this.question_id_to_insert_after = question_id_to_insert_after; - return; - } - editQestion = (index, nprops) => { - // console.log(nprops.match.params.coursesId) - // console.log(nprops.match.params.Id) - if (nprops) { - if (this._checkIsEditing()) { - return; - } else { - if (nprops.question_type === 6) { - this.props.history.push(`/problems/${nprops.hack_identifier}/edit?classrooms=${nprops.match.params.coursesId}&exercises=${nprops.match.params.Id}`) - } else { - this.editingId = `#question_${index}` - - this.setState( - (prevState) => ({ - exercise_questions: update(prevState.exercise_questions, { [index]: { isNew: { $set: true } } }) - }) - ) - } - } - - } else { - - if (this._checkIsEditing()) { - return; - } - this.editingId = `#question_${index}` - - this.setState( - (prevState) => ({ - exercise_questions: update(prevState.exercise_questions, { [index]: { isNew: { $set: true } } }) - }) - ) - } - - } - onSort = (index, question_id, isUp) => { - if (this._checkIsEditing()) { - return; - } - - const url = `/${this.props.exercise_url_questions || 'exercise_questions'}/${question_id}/up_down.json` - axios.post(url, { opr: isUp ? 'up' : 'down' }) - .then((response) => { - if (response.data.status == 0) { - // this.props.showNotification('移动成功') - this.fetchExercise() - } - }) - .catch(function (error) { - console.log(error); - }); - } - onSortDown = (index, question_id) => { - this.onSort(index, question_id, false) - } - onSortUp = (index, question_id) => { - this.onSort(index, question_id, true) - } - getInitScore = (question_type, question_id_to_insert_after) => { - /** - 1.每个题型的首个题目默认值规则如下: - 选择题:5分 01 - 判断题:2分 2 - 填空题:2分 3 - 简答题:10分 4 - 实训题:每个关卡5分 5 - */ - let init_question_score = 0; - if (question_type == 0 || question_type == 1) { - init_question_score = 5 - } else if (question_type == 2) { - init_question_score = 2 - } else if (question_type == 3) { - init_question_score = 2 - } else if (question_type == 4) { - init_question_score = 10 - } else if (question_type == 5) { - init_question_score = 5 - } - const _indexBefore = question_id_to_insert_after ? this.findIndexById(question_id_to_insert_after) : this.state.exercise_questions.length - 1 - for (let i = _indexBefore; i >= 0; i--) { - if (this.state.exercise_questions[i].question_type == question_type) { - init_question_score = this.state.exercise_questions[i].question_score - break; - } - } - return init_question_score; - } - addEditingQuestion = (question_type, question_id_to_insert_after, otherAttributes) => { - - let init_question_score = this.getInitScore(question_type, question_id_to_insert_after) - - let questionObj = { - question_type: question_type, // 需要这个通过类型判断 - init_question_score: init_question_score, - isNew: true, // 新建或编辑,用是否有id区分是新建还是编辑 - question_id_to_insert_after, - ...otherAttributes - } - const { exercise_questions } = this.state; - let new_exercise_questions = exercise_questions.slice(0) - let newIndex = new_exercise_questions.length; - - if (question_id_to_insert_after) { - const _indexBefore = this.findIndexById(question_id_to_insert_after) - new_exercise_questions.splice(_indexBefore + 1, 0, questionObj) - newIndex = _indexBefore + 1 - } else { - new_exercise_questions.push(questionObj) - } - this.editingId = `#question_${newIndex}` - this.setState({ exercise_questions: new_exercise_questions }, () => { - setTimeout(() => { - $(this.editingId).length && $("html").animate({ scrollTop: $(this.editingId).offset().top - 100 }) - }, 500) - }) - } - findIndexById = (id) => { - const { exercise_questions } = this.state - for (let i = 0; i < exercise_questions.length; i++) { - if (exercise_questions[i].question_id == id) { - return i; - } - } - } - onQestionDelete = (question_id) => { - this.props.confirm({ - content: `确认要删除这个问题吗?`, - onOk: () => { - const url = `/${this.props.exercise_url_questions || 'exercise_questions'}/${question_id}.json` - axios.delete(url) - .then((response) => { - if (response.data.status == 0) { - this.props.showNotification('删除成功') - this.fetchExercise() - } - }) - .catch(function (error) { - console.log(error); - }); - } - }) - } - addSuccess = () => { - this.editingId = null; - this.fetchExercise() - } - goToPreview = () => { - const exercise_id = this.props.match.params.Id - const courseId = this.props.match.params.coursesId - this.props.history.push(`/classrooms/${courseId}/exercises/${exercise_id}/student_exercise_list?tab=2`) - } - getAddQuestionUrl = () => { - const Id = this.props.match.params.Id - const url = this.props.exercise_url_questions ? `/${this.props.exercise_url_questions}.json` : `/exercises/${Id}/exercise_questions.json` - return url; - } - getEditQuestionUrl = (question_id) => { - const editUrl = this.props.exercise_url_questions ? `/${this.props.exercise_url_questions}/${question_id}.json` : `/exercise_questions/${question_id}.json` - return editUrl; - } - onCancel = () => { - this.setState({ - editMode: false - }) - } - render() { - let { exercise_name, exercise_description, exercise_types, exercise_questions, is_md, editMode } = this.state; - const { q_counts, q_scores, q_doubles, q_doubles_scores, q_judges, q_judges_scores, - q_mains, q_mains_scores, q_nulls, q_nulls_scores, q_shixuns, q_shixuns_scores, q_singles, q_singles_scores, q_pros, q_pros_scores } = exercise_types; - - const exerciseFormOpt = { - exercise_name, - exercise_description, - is_md, - onCancel: this.onCancel, - isEdit: this.isEdit, - onSaveHandler: this.onSaveExercise - } - - const exercise_id = this.props.match.params.Id - - const commonHandler = { - onQestionDelete: this.onQestionDelete, - addSuccess: this.addSuccess, - addQuestion: this.addQuestion, - onEditorCancel: this.onEditorCancel, - changeScore: this.changeScore, - editQestion: this.editQestion, - onSortDown: this.onSortDown, - onSortUp: this.onSortUp, - displayCount: exercise_questions.length, - exercise_status: this.state.exercise_status, - exerciseIsPublish: this.state.exercise_status >= 2, - - getAddQuestionUrl: this.getAddQuestionUrl, - getEditQuestionUrl: this.getEditQuestionUrl, - exercise_url: this.props.exercise_url - } - return ( - - - - - - {!this.state.editMode &&
    -
    - {exercise_name} - { this.setState({ editMode: true }) }} style={{ lineHeight: '40px' }}> - - -
    -
    - -
    } - {this.state.editMode && } - - -

    - - {!!q_singles && 单选题{q_singles}题,共{q_singles_scores}分} - {!!q_doubles && 多选题{q_doubles}题,共{q_doubles_scores}分} - {!!q_judges && 判断题{q_judges}题,共{q_judges_scores}分} - {!!q_nulls && 填空题{q_nulls}题,共{q_nulls_scores}分} - {!!q_mains && 简答题{q_mains}题,共{q_mains_scores}分} - {!!q_shixuns && 实训题{q_shixuns}题,共{q_shixuns_scores}分} - {!!q_pros && 编程题{q_pros}题,共{q_pros_scores}分} - - - {!!q_counts && - - 合计 {q_counts} 题, - 共 100 ? 'color-red font-bd' : 'color-orange'}`}>{q_scores} 分 - - } - -

    -
    - {exercise_questions.map((item, index) => { - if (item.question_type == 0 || item.question_type == 1) { - if (item.isNew) { - return - } else { - return - } - } else if (item.question_type == 2) { - if (item.isNew) { - return - } else { - return - } - } else if (item.question_type == 3) { - if (item.isNew) { - return - } else { - return - } - } else if (item.question_type == 4) { - if (item.isNew) { - return - } else { - return - } - } else if (item.question_type == 5) { - if (item.isNew) { - return - } else { - return - } - } else if (item.question_type == 6) { - if (item.isNew) { - return - } else { - return - } - } - return
    - })} - - {!commonHandler.exerciseIsPublish &&
    - this.addQuestion(null, Q_TYPE_SINGLE)}> - 选择题 - - this.addQuestion(null, Q_TYPE_JUDGE)}> - 判断题 - - this.addQuestion(null, Q_TYPE_NULL)}> - 填空题 - - this.addQuestion(null, Q_TYPE_MAIN)}> - 简答题 - - this.addShixun(null)}> - 实训题 - - - {exercise_id && !this.props.hidePreviewButton && this.goToPreview()}> - 试卷预览 - } - - {this.props.bottomSection && this.props.bottomSection} -
    } -
    -
    - ) - } -} -export default ExerciseNewCommon; diff --git a/src/modules/courses/exercise/ExerciseReviewAndAnswer.js b/src/modules/courses/exercise/ExerciseReviewAndAnswer.js deleted file mode 100644 index 91958d48..00000000 --- a/src/modules/courses/exercise/ExerciseReviewAndAnswer.js +++ /dev/null @@ -1,1048 +0,0 @@ -import React, { Component } from "react"; -import { Input, InputNumber, Spin, Statistic, Modal } from "antd"; - -import '../css/members.css'; -import '../css/busyWork.css'; -import '../poll/pollStyle.css'; -import '../css/Courses.css'; - -import moment from 'moment'; -import { WordsBtn, ActionBtn, getImageUrl } from 'educoder'; -import Modals from '../../modals/Modals'; -import CoursesListType from '../coursesPublic/CoursesListType'; -import Multiple from './question/multiple'; -import Single from './question/single'; -import Progques from './question/Progques'; -import FillEmpty from './question/fillEmpty'; -import SimpleAnswer from './question/simpleAnswer'; -import ShixunAnswer from './question/shixunAnswer'; -import QuestionModalPicture from '../../question/component/QuestionModalPicture' - -import update from 'immutability-helper'; - -import axios from 'axios'; -import './new/common.css'; -import RenderHtml from "../../../components/render-html"; -const { Countdown } = Statistic; - -const Textarea = Input.TextArea -const tagArray = [ - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', - 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', - 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' -] -const $ = window.$; -const statudmap = { 1: "未发布", 2: "已发布", 3: "已截止" } - -const type = ["单选题", "多选题", "判断题", "填空题", "简答题", "实训题", "编程题"] - -const format = "YYYY-MM-DD HH:mm" -class ExerciseReviewAndAnswer extends Component { - constructor(props) { - super(props); - this.state = { - data: undefined, - questionPanelFixed: false, - e_ReviewInfo: undefined, - e_AnswerInfo: undefined, - courseName: undefined, - exercise: undefined, - question_types: undefined, - exercise_questions: undefined, - time: undefined, - hour: 0, - minute: 0, - second: 0, - Modalstype: false, - Modalstopval: undefined, - modalsBottomval: undefined, - ModalCancel: undefined, - ModalSave: undefined, - Loadtype: undefined, - // 问卷是否可以被编辑(老师/试卷已截止/问卷已提交为1) - user_exercise_status: undefined, - // 开始答题时间 - exercise_start_at: undefined, - //老师身份 - exercise_scores: undefined, - exercise_answer_user: undefined, - //学生身份 - question_status: undefined, - score: undefined, - setScoreReason: undefined, - setTip: "", - Id: undefined, - // 试卷总分 - exerciseTotalScore: undefined, - // 加载效果 - isSpin: false, - // 调分数组 - ajustSore: undefined, - //是否是md编辑器 - is_md: false, - url: "", - } - } - componentDidUpdate(prevProps) { - // 需要等get_user_info执行完才能getInfo - if (!prevProps.coursedata.name && this.props.coursedata.name) { - this.getInfo() - } - } - componentDidMount() { - if (this.props.coursedata.name) { - this.getInfo(); - } - } - handleShowUploadImage = (url) => { - this.setState({ - url: url - }) - } - handleClose = () => { - this.setState({ - url: '', - }) - } - - //自动交卷 - autoCommitExercise = () => { - let eId = this.props.match.params.Id; - let url = `/exercises/${eId}/commit_exercise.json`; - axios.post(url, { - commit_method: 2 - }).then((result) => { - if (result) { - if (result.data.status === 0) { - this.setState({ - Modalstype: true, - Modalstopval: '答题结束了,系统已自动提交试卷', - modalsBottomval: "不能再修改答题", - ModalCancel: undefined, - ModalSave: this.sureCommit, - Loadtype: true, - time: null, - }) - this.props.showNotification(`${result.data.message}`); - } - - if (result.data.status === -2) { - // this.remainTime(parseInt(result.data.message)) - this.setState({ - time: parseInt(result.data.mess) - }) - this.deadline(parseInt(result.data.message)) - } - } - }).catch((error) => { - console.log(error); - }) - } - - sureCommit = () => { - let coursesId = this.props.match.params.coursesId; - let eId = this.props.match.params.Id; - this.props.history.push(`/classrooms/${coursesId}/exercises/${eId}/student_exercise_list?tab=0`); - } - - // 滚动定位 - handleScroll = () => { - if (parseInt(window.scrollY) > 550) { - this.setState({ - questionPanelFixed: true - }) - } else { - this.setState({ - questionPanelFixed: false - }) - } - } - - getInfo = () => { - this.setState({ - courseName: this.props.current_user.course_name, - isSpin: true - }) - - let eId = this.props.match.params.Id; - let user_id = this.props.match.params.userId; - - let isAdmin = this.props.isAdmin(); - if (isAdmin) { - let url = `/exercises/${eId}/review_exercise.json` - axios.get((url), { - params: { - login: user_id - } - }).then((result) => { - if (result) { - this.setState({ - data: result.data, - e_ReviewInfo: result.data, - exercise: result.data.exercise, - is_md: result.data.exercise.is_md, - exercise_types: result.data.exercise_scores.exercise_types, - exercise_scores: result.data.exercise_scores, - exercise_start_at: result.data.exercise_answer_user.start_at, - exercise_answer_user: result.data.exercise_answer_user, - exercise_questions: result.data.exercise_questions, - user_exercise_status: 1, - Id: result.data.exercise_answer_user.user_id, - exerciseTotalScore: result.data.exercise_answer_user.score, - isSpin: false, - }) - // 先将未批的简答题放入到调分数组中 - let ajustSore = []; - result.data && result.data.exercise_questions.length > 0 && result.data.exercise_questions.map((item, key) => { - if (item.question_type == 4 && item.answer_status == 0) { - ajustSore.push({ - inputSore: 0, - desc: undefined, - id: item.question_id, - position: item.q_position, - setTip: "" - }) - } - }) - this.setState({ - ajustSore - }) - } - }).catch((error) => { - console.log(error); - }) - } else { - let url = `/exercises/${eId}/start_answer.json` - axios.get((url), { - params: { - login: user_id - } - }).then((result) => { - if (result.status == 200) { - this.setState({ - data: result.data, - e_AnswerInfo: result.data, - exercise: result.data.exercise, - exercise_types: result.data.exercise_types, - question_status: result.data.question_status, - exercise_start_at: result.data.exercise.exercise_start_at, - exercise_scores: result.data.exercise_scores, - exercise_questions: result.data.exercise_questions, - user_exercise_status: result.data.exercise.user_exercise_status, - time: result.data.exercise.left_time, - exerciseTotalScore: result.data.user_score, - is_md: result.data.exercise.is_md, - isSpin: false - }) - if (result.data.exercise.left_time != null) { - // this.remainTime(result.data.exercise.left_time); - this.deadline(result.data.exercise.left_time) - } - } - }).catch((error) => { - console.log(error); - }) - } - } - scrollToAnchor = (index) => { - let name = "Anchor_" + index; - // console.log($("#Anchor_"+index).scrollTop()); - if (index) { - // let anchorElement = document.getElementById(name); - // if(anchorElement) { anchorElement.scrollIntoView(); } - $("html").animate({ scrollTop: $("#Anchor_" + index).offset().top - 150 }) - } - } - - //答题后更改题目列表得状态 - changeQuestionStatus = (No, flag) => { - this.setState( - (prevState) => ({ - question_status: update(prevState.question_status, { [No]: { ques_status: { $set: flag } } }) - }) - ) - } - // 调分 - showSetScore = (key, flag, position, type, id) => { - - this.setState( - (prevState) => ({ - exercise_questions: update(prevState.exercise_questions, { [key]: { setScore: { $set: flag == undefined || flag == false ? true : false } } }) - }), () => { - if (position && type && (flag == undefined || flag == false)) { - $("#input_" + position + "_" + type).focus(); - $("html").animate({ scrollTop: $("#Anchor_" + position + "_" + type).offset().top - 150 }); - if (id) { - let { ajustSore } = this.state; - let obj = ajustSore.filter(obj => obj.id === id).length > 0; - if (!obj) { - ajustSore.push({ - id, - inputSore: 0, - desc: undefined, - position: position, - setTip: "" - }) - } - } - } - } - ) - // this.setState({ - // score:undefined - // }) - } - - inputScore = (value, id) => { - let { ajustSore } = this.state; - var index = ajustSore.map(function (item) { return item.id; }).indexOf(id); - let reg = /^[0-9]+.?[0-9]*$/; - if (reg.test(value) == false) { - // this.setState({ - // setTip:"请输入数字" - // }) - this.setState( - (prevState) => ({ - ajustSore: update(prevState.ajustSore, { [index]: { setTip: { $set: "请输入数字" } } }) - }) - ) - return; - } else { - // this.setState({ - // setTip:"", - // score:value - // }) - this.setState( - (prevState) => ({ - ajustSore: update(prevState.ajustSore, { [index]: { inputSore: { $set: value }, setTip: { $set: "" } } }) - }) - ) - } - } - changeScoreReasons = (e, id) => { - // console.log(e.target.value); - // this.setState({ - // setScoreReason:e.target.value - // }) - let value = e.target.value; - let { ajustSore } = this.state; - var index = ajustSore.map(function (item) { return item.id; }).indexOf(id); - this.setState( - (prevState) => ({ - ajustSore: update(prevState.ajustSore, { [index]: { desc: { $set: value } } }) - }) - ) - } - //确认调分 - setAction = (key, q_id, maxScore, oldScore) => { - let { ajustSore } = this.state; - let list = ajustSore.filter(obj => obj.id == q_id); - let index = ajustSore.map(function (item) { return item.id; }).indexOf(q_id); - - let score = list[0].inputSore; - let setScoreReason = list[0].desc; - let { setTip } = this.state; - if (!score && score != 0) { - this.setState( - (prevState) => ({ - ajustSore: update(prevState.ajustSore, { [index]: { setTip: { $set: "请输入分数" } } }) - }) - ) - return; - } - if (score < 0) { - this.setState( - (prevState) => ({ - ajustSore: update(prevState.ajustSore, { [index]: { setTip: { $set: "分数必须大于或者等于0" } } }) - }) - ) - return; - } - if (score > maxScore) { - this.setState( - (prevState) => ({ - ajustSore: update(prevState.ajustSore, { [index]: { setTip: { $set: "分数不能大于当前题目的分数" } } }) - }) - ) - return; - } - if (setTip == "") { - let url = `/exercise_questions/${q_id}/adjust_score.json` - axios.post((url), { - score: score, - user_id: this.state.Id, - comment: setScoreReason - }).then((result) => { - if (result.status == 200) { - this.props.showNotification('调分成功'); - this.getInfo(); - } - }).catch((error) => { - console.log(error); - }) - } - - } - - // 选择题,切换答案 - changeOption = (index, ids) => { - this.setState( - (prevState) => ({ - exercise_questions: update(prevState.exercise_questions, { [index]: { user_answer: { $set: ids } } }), - }) - ) - } - - //简答题 显示和隐藏答案 - changeA_flag = (index, status) => { - this.setState( - (prevState) => ({ - exercise_questions: update(prevState.exercise_questions, { [index]: { a_flag: { $set: status } } }) - }) - ) - } - - //交卷和保存前判断是否有题未答 - checkExerciseNumber = (index) => { - let url = `/exercises/${this.props.match.params.Id}/begin_commit.json`; - axios.get(url).then((result) => { - if (result) { - if (result.data.question_undo != 0 || result.data.oj_undo != 0) { - let tip = ""; - if (result.data.question_undo != 0 && result.data.oj_undo != 0) { - tip = `有 ${result.data.question_undo} 题未完成,包含 ${result.data.oj_undo} 个编程题`; - } else if (result.data.question_undo != 0 && result.data.oj_undo == 0) { - tip = `有 ${result.data.question_undo} 题未完成`; - } else if (result.data.question_undo == 0 && result.data.oj_undo != 0) { - tip = `有 ${result.data.oj_undo} 编程题未完成`; - } - - - this.setState({ - Modalstype: true, - Modalstopval: tip, - modalsBottomval: index === 0 ? `在${moment(result.data.end_time).format(format)}之前,允许修改答题` : `提交后无法再修改答题,是否确认提交?`, - ModalCancel: this.cancelCommit, - ModalSave: () => this.sureCommitOrSave(index), - Loadtype: index === 0 ? true : false - }) - } else { - this.setState({ - Modalstype: true, - Modalstopval: index === 0 ? `在${moment(result.data.end_time).format(format)}之前,允许修改答题` : `提交后无法再修改答题,是否确认提交?`, - modalsBottomval: undefined, - ModalCancel: this.cancelCommit, - ModalSave: () => this.sureCommitOrSave(index), - Loadtype: index === 0 ? true : false - }) - } - } - }).catch((error) => { - console.log(error); - }) - } - //交卷 - commitExercise = () => { - this.checkExerciseNumber(1); - } - //保存 - saveExercise = () => { - this.checkExerciseNumber(0); - } - - //确认交卷或者保存 - sureCommitOrSave = (index) => { - if (index === 0) { - //确认保存 - this.cancelCommit(); - this.sureCommit(); - } else { - //交卷 - let eId = this.props.match.params.Id; - let url = `/exercises/${eId}/commit_exercise.json`; - axios.post(url, { - commit_method: 1 - }).then((result) => { - if (result) { - this.setState({ - Modalstype: false, - Modalstopval: undefined, - modalsBottomval: undefined, - ModalCancel: undefined, - ModalSave: undefined, - Loadtype: undefined - }) - this.props.showNotification(`${result.data.message}`); - this.getInfo(); - } - }).catch((error) => { - console.log(error); - }) - } - } - cancelCommit = () => { - this.setState({ - Modalstype: false, - Modalstopval: undefined, - modalsBottomval: undefined, - ModalCancel: undefined, - ModalSave: undefined, - Loadtype: undefined - }) - } - // 打回重做 - RepeatExercise = () => { - let status = parseInt(this.state.exercise.exercise_status); - if (status === 3) { - this.setState({ - Modalstype: true, - Modalstopval: '截止时间已到,无法打回试卷', - modalsBottomval: '请在修改截止时间后再操作', - ModalCancel: this.cancelCommit, - ModalSave: this.cancelCommit, - Loadtype: true - }) - } else { - this.setState({ - Modalstype: true, - Modalstopval: '学生将得到一次重新答题的机会,现有的答题情况将被清空', - modalsBottomval: '是否确认回退TA的试卷答题', - ModalCancel: this.cancelCommit, - ModalSave: this.sureRepeatExercise, - Loadtype: false - }) - } - } - sureRepeatExercise = () => { - let eId = this.props.match.params.Id; - let user_id = this.state.Id; - let url = `/exercises/${eId}/redo_exercise.json` - axios.post((url), { - user_ids: [user_id] - }).then((result) => { - if (result) { - this.props.showNotification(`${result.data.message}`); - //打回重做后跳转到答题列表页 - this.sureCommit(); - } - }).catch((error) => { - console.log(error); - }) - } - - // 返回 - returnBtn = () => { - let coursesId = this.props.match.params.coursesId; - let eId = this.props.match.params.Id; - this.props.history.push(`/classrooms/${coursesId}/exercises/${eId}/student_exercise_list?tab=0`) - } - - deadline = (time) => { - if (time === null) { - this.setState({ - Datetime: 0 - }) - } else { - this.setState({ - Datetime: Date.now() + time * 1000 - }) - // return Date.now() + time * 1000 ; - } - - } - - ProgrammingDetails = (item) => { - if (item.hack_identifier) { - let url = `/problems/${item.hack_identifier}/start.json`; - var newOpenWindow = window.open('about:blank'); // 在ajax外部先打开空白新窗口 - - axios.get(url).then((result) => { - if (result.data.status === 0) { - newOpenWindow.location = `/myproblems/${result.data.identifier}?type=exercises`; - } - }).catch((error) => { - console.log(error); - }) - } - - } - //issue#29409 - goShixunDetail = (item,key)=>{ - if(item.redo){ - Modal.info({ - title:'提示', - content:"您之前已经挑战过该实训,考试过程中需要重新挑战", - onOk:()=>{ - const url = `/myshixuns/${item.myshixun_identifier}/reset_my_game.json` - return axios.get(url).then(response=>{ - if(response.status===200){ - window.open("/shixuns/" + item.shixun_identifier + "/challenges"); - let new_exercise_questions = this.state.exercise_questions; - new_exercise_questions[key]={...item,redo:false}; - this.setState({exercise_questions:new_exercise_questions}); - }else{ - console.log(response) - } - }).catch(e=>console.log(e)); - }, - okText:'确定', - maskClosable:false, - keyboard:false - }) - }else{ - window.open("/shixuns/" + item.shixun_identifier + "/challenges") - } - } - render() { - let coursesId = this.props.match.params.coursesId; - let eId = this.props.match.params.Id; - - let { - data, - questionPanelFixed, - courseName, - exercise, - exercise_types, - exercise_start_at, - exercise_scores, - exercise_questions, - - user_exercise_status,//试卷是否可以编辑 - - exercise_answer_user, - - question_status, - score, - setScoreReason, - setTip, - time, - hour, - minute, - second, - - Modalstype, - Modalstopval, - modalsBottomval, - ModalCancel, - ModalSave, - Loadtype, - exerciseTotalScore, - isSpin, - ajustSore, - is_md, - url - } = this.state - let isAdmin = this.props.isAdmin(); - let isStudent = this.props.isStudent(); - const { current_user } = this.props - // console.log(data&&data.exercise.user_name) - document.title = courseName && courseName; - - return ( -
    - - - {url ? - this.handleClose()}> - : - "" - } - -
    -

    - {courseName} - > - {data && data.left_banner_name} - > - {data && data.left_banner_name}详情> - {exercise_answer_user && exercise_answer_user.user_name}{data && data.exercise.user_name} -

    -

    - {exercise && exercise.exercise_name} - - - - - { - (isAdmin || (isStudent && exercise && user_exercise_status == 1)) ? - 返回 - : - time && time != 0 ? -

    - -
    - : "" - } - { - isAdmin && 打回重做 - } -

    - { - exercise && exercise.exercise_description && -

    {exercise.exercise_description}

    - } -

    - { - exercise_types && exercise_types.q_singles > 0 && - 单选题 {exercise_types.q_singles} 题,共 {exercise_types && exercise_types.q_singles_scores} 分 - } - { - exercise_types && exercise_types.q_doubles > 0 && - 多选题 {exercise_types.q_doubles} 题,共 {exercise_types && exercise_types.q_doubles_scores} 分 - } - { - exercise_types && exercise_types.q_judges > 0 && - 判断题 {exercise_types.q_judges} 题,共 {exercise_types && exercise_types.q_judges_scores} 分 - } - { - exercise_types && exercise_types.q_nulls > 0 && - 填空题 {exercise_types.q_nulls} 题,共 {exercise_types && exercise_types.q_nulls_scores} 分 - } - { - exercise_types && exercise_types.q_mains > 0 && - 简答题 {exercise_types.q_mains} 题,共 {exercise_types && exercise_types.q_mains_scores} 分 - } - { - exercise_types && exercise_types.q_shixuns > 0 && - 实训题 {exercise_types.q_shixuns} 题,共 {exercise_types && exercise_types.q_shixuns_scores} 分 - } - { - exercise_types && exercise_types.q_pros > 0 && - 编程题 {exercise_types.q_pros} 题,共 {exercise_types && exercise_types.q_pros_scores} 分 - } - {exercise_types && exercise_types.q_scores} - 合计 {exercise_types && exercise_types.q_counts} 题: -

    -
    - -
    - - { - exercise_start_at && 开始答题时间:{exercise_start_at && moment(exercise_start_at).format(format)} - } - { - (isAdmin || (isStudent && exercise && exercise.exercise_status == 3)) && exerciseTotalScore && - 总分: {exerciseTotalScore} - } - - { - // 老师身份 || 学生身份且试卷已经截止 - (isAdmin || (isStudent && exercise && exercise.exercise_status == 3)) && -
    - { - exercise_scores && exercise_scores.objective_scores && exercise_scores.objective_scores.length > 0 && -
    -

    - 客观题 - 正确 - 错误 - 部分得分 -

    - -
    - } - { - exercise_scores && exercise_scores.subjective_scores.length > 0 && -
    -

    - 主观题 - 已评 - 未评 -

    - -
    - } -
    - } - - { - //学生身份 且试卷还未截止 - isStudent && exercise && exercise.exercise_status == 2 ? -
    -

    - 已答 - 未答 -

    - -
    : "" - } -
    - {/* 试卷题目 */} -
    - { - exercise_questions && exercise_questions.map((item, key) => { - let list = ajustSore && ajustSore.filter(obj => obj.id === item.question_id); - let titename = (item.question_type == 5 ? item.shixun_name : item.question_title); - return ( -
    -

    - {item.q_position}、{type[item.question_type]}({item.question_score}分) - - { - // 填空(一直都有调分),和简答题调分:老师身份 已经评分的才能出现调分按钮 - isAdmin && item.question_type == 6 ? - this.showSetScore(key, item.setScore, item.q_position, item.question_type, item.question_id)}>调分 : "" - } - { - // 填空(一直都有调分),和简答题调分:老师身份 已经评分的才能出现调分按钮 - isAdmin && ((parseInt(item.answer_status) != 0 && item.question_type == 4) || item.question_type == 3 || item.question_type == 1) ? - this.showSetScore(key, item.setScore, item.q_position, item.question_type, item.question_id)}>调分 : "" - } - { - // 简答题,未评分的显示未批 - isAdmin && parseInt(item.answer_status) == 0 && item.question_type == 4 ? - 未批 : "" - } - { - // 客观题:老师||学生(试卷已截止且答案公开)显示正确答案 - item.question_type < 3 && item.standard_answer_show ? - - 正确答案:{item.standard_answer_show} - : "" - } - { - //(老师身份且除实训题外) || (学生身份且试卷已经截止)就显示用户当前题目所得分数 - (isAdmin || (isStudent && exercise.exercise_status == 3)) && item.question_type != 5 && item.user_score ? - - {item.user_score} - : "" - } - { - //实训题 ,答题 - item.question_type == 5 && - this.goShixunDetail(item,key)} className="font-16 color-blue fl">进入答题 - } - { - //编程题 ,答题 - isStudent && user_exercise_status == 0 && item.question_type == 6 && - this.ProgrammingDetails(item)} className="font-16 color-blue fl">进入答题 - } - -

    -
  • - -
  • - { - // 选择题和判断题共用 - (item.question_type == 0 || item.question_type == 2) && - this.changeOption(index, ids)} - changeQuestionStatus={(No, flag) => this.changeQuestionStatus(No, flag)} - index={key} - handleShowUploadImage={(u) => this.handleShowUploadImage(u)} - > - } - { - // 多选题 - item.question_type == 1 && - this.changeOption(index, ids)} - changeQuestionStatus={(No, flag) => this.changeQuestionStatus(No, flag)} - index={key} - handleShowUploadImage={(u) => this.handleShowUploadImage(u)} - > - } - { - // 填空题 - item.question_type == 3 && - this.changeQuestionStatus(No, flag)} - index={key} - handleShowUploadImage={(u) => this.handleShowUploadImage(u)} - > - } - { - // 简答题 - item.question_type == 4 && - this.changeQuestionStatus(No, flag)} - changeA_flag={(index, status) => this.changeA_flag(index, status)} - index={key} - handleShowUploadImage={(u) => this.handleShowUploadImage(u)} - > - } - { - // 实训题 - item.question_type == 5 && - this.handleShowUploadImage(u)} - > - } - { - //编程题 - item.question_type == 6 && - this.handleShowUploadImage(u)} - > - - } - - { - //调分理由部分 - item.question_comments && item.question_comments.comment && (item.question_type == 3 || item.question_type == 4 || item.question_type == 1) && -
    - -
    -
  • - {item.question_comments.user_name} - {moment(item.question_comments.updated_at).format(format)} -
  • -
  • {item.question_comments.comment}
  • -
    -
    - } - { - // 调分输入部分 - isAdmin && ((item.setScore && item.question_type == 3) || (item.setScore && item.question_type == 1) || ((item.setScore || parseInt(item.answer_status) == 0) && item.question_type == 4) || (item.setScore && item.question_type == 6)) ? -
    -
    - *调分: -
  • -

    - 0 && list[0].inputSore} - step={0.1} - precision={1} - className={list && list.length > 0 && list[0].setTip != "" ? "edu-txt-center fl mt3 noticeTip inputNumber30" : "edu-txt-center fl mt3 inputNumber30"} - onChange={(value) => this.inputScore(value, item.question_id)} - id={`${"input_" + item.q_position + "_" + item.question_type}`} - > - - { - parseInt(item.answer_status) == 0 && item.question_type == 4 ? 未评分 : '' - } - this.setAction(key, item.question_id, item.question_score, item.user_score)}>确认 -

    - { - list && list.length > 0 && list[0].setTip != "" ?

    {list[0].setTip}

    : "" - } -
  • -
    - {item.question_type == 6 ? "" : } -
    : "" - } -
    - ) - }) - } -
    -
    - { - isStudent && user_exercise_status == 0 ? -

    - 交卷 - 保存 - { - exercise && time != null ? - 保存或者离开页面后,系统将持续计时,到达时长系统将自动交卷 - : "" - } -

    : "" - } -
    -
    -
    - ) - } -} -export default ExerciseReviewAndAnswer diff --git a/src/modules/courses/exercise/Exercisesetting.js b/src/modules/courses/exercise/Exercisesetting.js deleted file mode 100644 index 0bd596c3..00000000 --- a/src/modules/courses/exercise/Exercisesetting.js +++ /dev/null @@ -1,918 +0,0 @@ -import React,{ Component } from "react"; -import {Form,Checkbox,DatePicker,Button,Input,Select,Tooltip} from "antd"; - -import { handleDateString } from 'educoder'; -import PollDetailTabForthRules from '../poll/PollDetailTabForthRules'; - -import '../css/members.css'; -import '../css/busyWork.css'; -import '../poll/pollStyle.css'; - -import moment from 'moment'; -import locale from 'antd/lib/date-picker/locale/zh_CN'; -import axios from 'axios'; -import Modals from '../../modals/Modals'; - -const Search=Input.Search; -const Option=Select.Option; - -function range(start, end) { - const result = []; - for (let i = start; i < end; i++) { - result.push(i); - } - return result; -} - -function disabledDateTime() { - return { - // disabledHours: () => range(0, 24).splice(4, 20), - disabledMinutes: () => range(1, 30).concat(range(31, 60)), - // disabledSeconds: () => [0, 60], - }; -} - -function disabledDate(current) { - return current && current < moment().endOf('day').subtract(1, 'days'); -} - -const dataformat="YYYY-MM-DD HH:mm"; - -class Exercisesetting extends Component{ - constructor(props){ - super(props); - this.state={ - flagPageEdit:undefined, - flagPublic:undefined, - flagRealName:undefined, - unified_list:undefined, - course_group:undefined, - end_time:undefined, - publish_time:undefined, - unit_p_tip:"", - unit_e_tip:"", - rules:undefined, - p_flag:true, - e_flag:true, - polls:undefined, - //公用提示弹框相关 - modalsType:false, - modalsTopval:"", - loadtype:false, - modalSave:undefined, - firstSetting:true, - score_open:false, - answer_open:false, - unified_setting:true, - show_statistic:false, - question_random:true, - choice_random:true, - time:0, - publish_timetype:false, - end_timetype:false, - exercise_group_id:[], - page:1, - limit:10, - searchtext:"", - order: "end_at", - assistant_auth:false - } - // console.log("Exercisesetting"); - // console.log("69"); - // console.log(props); - } - _getRequestParams() { - const { order, exercise_group_id,searchtext, page ,limit} = this.state - return { - page, - search:searchtext, - order, - limit: limit, - group_id:exercise_group_id, - } - } - //加载 - componentDidMount=()=>{ - this.setState({ - assistant_auth:this.props.assistant_auth, - }) - - - - this.getSettingInfo(); - - // window.addEventListener('click', this.handleClick); - try { - this.props.triggerRef(this); - }catch (e) { - - } - - if(this.props.Commonheadofthetestpaper!=undefined){ - this.editSetting() - } - - if(this.props.isAdmin() === false){ - this.cancelEdit() - } - - try { - //是否为助教 - if(this.props.isAssistant()===true){ - //如果是助教是否有权限 - if(this.props.assistant_auth===true){ - this.setState({ - flagPageEdit:true - }) - }else{ - this.setState({ - flagPageEdit:false - }) - } - } - }catch (e) { - - } - } - componentDidUpdate = (prevProps) => { - if(prevProps.Commonheadofthetestpaper!= this.props.Commonheadofthetestpaper){ - this.editSetting() - } - if(prevProps.assistant_auth!= this.props.assistant_auth){ - this.setState({ - assistant_auth:this.props.assistant_auth, - }) - } - } - - _getRequestParams() { - const { order, exercise_group_id,searchtext, page ,limit} = this.state - return { - page, - search:searchtext, - order, - limit: limit, - group_id:exercise_group_id, - } - } - - // handleClick=(e)=>{ - // console.log(e); - // } - - // 已有设置数据的查询 - getSettingInfo=(type)=>{ - if(type!=1){ - this.props.Commonheadofthetestpapers() - } - - let Id=this.props.match.params.Id; - let url=`/exercises/${Id}/exercise_setting.json`; - axios.get(url).then((result)=>{ - - - if(result.status==200){ - - this.props.form.setFieldsValue({ - time:result.data.exercise.time===-1?"":result.data.exercise.time, - }); - - this.setState({ - polls:result.data.exercise, - flagPublic:result.data.exercise.is_public, - flagRealName:result.data.exercise.un_anonymous, - unified_list:result.data.published_course_groups, - course_group:result.data.course_groups, - publish_time:result.data.exercise.publish_time, - end_time:result.data.exercise.end_time, - firstSetting:result.data.published_course_groups.length==0 && result.data.exercise.publish_time == null && result.data.exercise.end_time==null, - score_open:result.data.exercise.score_open, - answer_open:result.data.exercise.answer_open, - unified_setting:result.data.exercise.unified_setting, - show_statistic:result.data.exercise.show_statistic, - question_random:result.data.exercise.question_random, - choice_random:result.data.exercise.choice_random, - time:result.data.exercise.time, - - ...result.data.exercise - }) - - if(result.data.exercise.unified_setting == true && moment(result.data.exercise.publish_time) <= moment()){ - - // if(this.props.isSuperAdmin()===true){ - // this.setState({ - // publish_timetype:false - // }) - // }else{ - //发布后谁都不能改 - this.setState({ - publish_timetype:true - }) - // } - - } - if(result.data.exercise.unified_setting == true && moment(result.data.exercise.end_time) <= moment()){ - this.setState({ - end_timetype:true - }) - } - - let group=result.data.published_course_groups; - if(group.length==0){ - let list= [{ - course_group_id:[], - course_group_name:[], - publish_time:undefined, - end_time:undefined, - publish_flag:"", - end_flag:"", - class_flag:"", - course_search:"", - poll_status:0, - open:false - }] - this.setState({ - rules:list - }) - }else{ - let array=[]; - for(var i=0;i{ - console.log(error); - }) - } - -//提交form表单 - handleSubmit = (e) => { - e.preventDefault(); - // if(this.props&&this.props.Commonheadofthetestpaper.exercise_status){ - // console.log("190"); - // console.log(this.props.Commonheadofthetestpaper.exercise_status); - // } - - this.props.form.validateFieldsAndScroll((err, values) => { - if(!err){ - // 第一次进行问卷设置或者勾选了统一设置 - let{unified_setting}=this.state - if(unified_setting==true){ - console.log("统一设置"); - this.UnifiedSetting( ); - }else{ - console.log("非统一设置"); - this.NotUnifiedSetting( ); - } - } - }) - } - //跳转道描点的地方 - scrollToAnchor = (anchorName) => { - if (anchorName) { - // 找到锚点 - let anchorElement = document.getElementById(anchorName); - // 如果对应id的锚点存在,就跳转到锚点 - if(anchorElement) { anchorElement.scrollIntoView(); } - } - } - - UnifiedSetting=()=>{ - let { unit_e_tip , unit_p_tip , publish_time , end_time ,course_group }=this.state - // 如果两个时间都没有填写或者只选择了截止时间则先保存设置然后弹出立即发布弹框 - if ( publish_time === undefined ||publish_time === null ){ - - this.setState({ - unit_p_tip:"不能为空" - }) - this.scrollToAnchor("publishtimeid"); - - return - // if(moment(end_time,dataformat)<=moment()){ - // this.setState({ - // unit_e_tip:"截止时间不能小于当前时间" - // }) - // }else{ - // this.setState({ - // unit_e_tip:"" - // }) - - // let list=[]; - // let group=course_group; - // if(group.length>0){ - // for(var i=0;i 0 ? 1 : 2, - // visible:true, - // Topval:"本操作只对“未发布”的对象生效", - // Botvalleft:"暂不发布", - // Botval:"则通过后续手动设置,定时发布", - // starttime:"发布时间:"+this.props.getNowFormatDates(1), - // endtime:"截止时间:" + moment(end_time == "" || end_time ==undefined ? this.props.getNowFormatDates(2):end_time).format(dataformat), - // Cancelname:"暂不发布", - // Savesname:"立即发布", - // Cancel:this.homeworkhide, - // Saves:this.homeworkstartend, - // publishCourse:list, - // publish_time:this.props.getNowFormatDates(1) - // }) - // } - }else{ - - if(this.state.publish_timetype === false){ - if(moment(publish_time,dataformat) < moment() ){ - this.setState({ - unit_p_tip:"发布时间不能小于当前时间" - }) - return; - }else{ - this.setState({ - unit_p_tip:"" - }) - } - } - - if(this.state.end_timetype === false||this.props.isAdmin()==true){ - if(moment(end_time,dataformat) <= moment(publish_time,dataformat)){ - this.setState({ - unit_e_tip:"截止时间不能小于发布时间" - }) - return; - }else if(moment(end_time,dataformat)<=moment()){ - this.setState({ - unit_e_tip:"截止时间不能小于当前时间" - }) - return; - }else{ - this.setState({ - unit_e_tip:"" - }) - } - - } - - - - - this.commitSetting((result)=>{ - console.log(result) - if(result.status===200){ - this.props.showNotification(`${result.data.message}`); - this.getSettingInfo(1); - this.cancelEdit(); - try { - this.props.assistantauthoritys(this.state.assistant_auth); - - }catch (e) { - - } - } - }) - } - } - // 非统一设置提交 - NotUnifiedSetting=()=>{ - const result = this.refs.pollDetailTabForthRules.exerciseSettingCheck(this.state.rules); - this.setState({ - rules: result.rules - }) - if(result.validate==false){ - return; - } - this.commitSetting((result)=>{ - console.log(result) - if(result.status==200){ - this.props.showNotification(`${result.data.message}`); - this.cancelEdit(); - this.getSettingInfo(1); - try { - this.props.assistantauthoritys(this.state.assistant_auth); - - }catch (e) { - - } - } - }); - - - } - commitSetting=(callback)=>{ - let exercise_id=this.props.match.params.Id; - let url=`/exercises/${exercise_id}/commit_setting.json`; - let params=[]; - if(this.state.unified_setting){ - params={ - unified_setting:this.state.unified_setting, - publish_time:this.state.publish_time, - end_time:this.state.end_time, - show_statistic:this.state.show_statistic, - choice_random:this.state.choice_random, - score_open:this.state.score_open, - answer_open:this.state.answer_open, - question_random:this.state.question_random, - time:this.state.time, - assistant_auth:this.state.assistant_auth, - } - }else{ - let list=this.state.rules; - let lists=[] - list.map((item,key)=>{ - let newlist={ - course_group_id:item.course_group_id, - publish_time:item.publish_time, - end_time:item.end_time - } - lists.push(newlist) - }) - params={ - unified_setting:this.state.unified_setting, - show_statistic:this.state.show_statistic, - question_random:this.state.question_random, - choice_random:this.state.choice_random, - score_open:this.state.score_open, - answer_open:this.state.answer_open, - publish_time_groups:lists, - time:this.state.time, - assistant_auth:this.state.assistant_auth, - } - } - axios.post((url),params).then((result)=>{ - callback(result); - }).catch((error)=>{ - console.log(error); - }) - } - - - rulesCheckInfo=(rules)=>{ - this.setState({ - rules - }) - } - - - cancelBox=()=>{ - this.setState({ - modalsType:false, - modalsTopval:"", - loadtype:false, - }) - } - - // 是否统一设置 - changeUnit=(e)=>{ - this.setState({ - unified_setting:e.target.checked - }) - } - - //是否公开统计 - ChangeFlagPublic=(e)=>{ - this.setState({ - score_open:e.target.checked - }) - } - - //是否实名问卷 - ChangeFlagName=(e)=>{ - this.setState({ - answer_open:e.target.checked - }) - } - - //题目顺序随机打乱 - questionrandom=(e)=>{ - this.setState({ - question_random:e.target.checked - }) - } - - //选项顺序随机打乱 - choicerandom=(e)=>{ - this.setState({ - choice_random:e.target.checked - }) - } - //答题时间 - funlatepenalty=(e)=>{ - let value= parseInt(e.target.value); - - if(isNaN(value)){ - value=0 - } - - this.setState({ - time:value - }) - } - - showstatistic=(e)=>{ - this.setState({ - show_statistic:e.target.checked - }) - } - - assistantauthority=(e)=>{ - this.setState({ - assistant_auth:e.target.checked - }) - } - - onChangeTimepublish=(date, dateString)=>{ - if(date===null){ - this.setState({ - publish_time: null, - end_time:null - }) - }else{ - if(moment(handleDateString(dateString),"YYYY-MM-DD HH:mm") <= moment()){ - this.setState({ - unit_p_tip:"发布时间不能早于当前时间", - p_flag:true - }) - }else{ - this.setState({ - unit_p_tip:"", - p_flag:false - }) - } - this.setState({ - publish_time: handleDateString(dateString), - end_time:moment(moment(handleDateString(dateString)).add(1, 'months')).format("YYYY-MM-DD HH:mm") - }) - } - - } - onChangeTimeEnd=(date, dateString)=>{ - if(date===null){ - this.setState({ - end_time:null - }) - }else{ - if(dateString<=moment().format('YYYY-MM-DD HH:mm')){ - this.setState({ - unit_e_tip:"截止时间不能早于当前时间", - e_flag:true - }) - }else if(moment(date,"YYYY-MM-DD HH:mm") <= moment(this.state.publish_time,"YYYY-MM-DD HH:mm")){ - this.setState({ - unit_e_tip:"截止时间不能早于发布时间", - e_flag:true - }) - }else{ - this.setState({ - unit_e_tip:"", - e_flag:false - }) - } - this.setState({ - end_time: handleDateString(dateString) - }) - } - - } - - //编辑 - editSetting = () => { - if(this.props.Commonheadofthetestpaper.course_is_end==true){ - this.setState({ - modalsType:true, - modalsTopval:"课堂已结束不能再修改!", - loadtype:true, - modalSave:this.cancelBox - }) - }else{ - if(this.props.isAdmin()===true){ - try { - //是否为助教 - if(this.props.isAssistant()===true){ - //如果是助教是否有权限 - if(this.props.assistant_auth===true){ - this.setState({ - flagPageEdit:true - }) - }else{ - this.setState({ - flagPageEdit:false - }) - } - }else{ - //是老师 - this.setState({ - flagPageEdit:true - }) - } - }catch (e) { - this.setState({ - flagPageEdit:true - }) - } - } - - } - } - //取消编辑 - cancelEdit=()=>{ - this.getSettingInfo(1); - this.setState({ - flagPageEdit:false - }) - } - - - - - render(){ - let{flagPageEdit,end_time,publish_time,course_group,rules, - unit_p_tip, - unit_e_tip, - modalsType, - modalsTopval, - loadtype, - modalSave, - score_open, - answer_open, - unified_setting, - show_statistic, - question_random, - choice_random, - time, - polls, - publish_timetype, - end_timetype - }=this.state - 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 }, - }, - }; - - // console.log(flagPageEdit===true?polls&&polls.exercise_status===1?3:2:1) - // console.log("asdasdasda"); - // console.log(this.props); - // console.log(this.props.Commonheadofthetestpaper); - - - return( -
    - -
    -
    -
    -

    - 发布设置 - { - !flagPageEdit&&this.props.isAdmin()===true ? - ( - this.props.isAssistant()===true? - ( - this.props.assistant_auth===true? - - 编辑设置 - - : - "" - ) - : - - 编辑设置 - - ) - :"" - } - -

    -
    - {course_group&&course_group.length>1?

    - - {getFieldDecorator('unified_setting') - ( - 统一设置 - )} - - (选中则所有分班使用相同的发布设置,仅课堂管理员可修改;否则各个分班允许单独设置) -

    :""} - { - unified_setting===true ? -
    -
    - 发布时间: -
    - - - -

    - { - unit_p_tip !="" ? {unit_p_tip}:"" - } -

    -
    - (学生收到试卷的时间) -
    -
    - 截止时间: -
    - - - - -

    - { - unit_e_tip && unit_e_tip != "" ? { unit_e_tip }:"" - } -

    -
    - (学生可以答题的时间截点) -
    -
    - : - this.rulesCheckInfo(info)} - Commonheadofthetestpaper={this.props.Commonheadofthetestpaper} - > - } -
    -
    -
    -

    答题设置

    -
    -

    -

    - 答题时长: - - {getFieldDecorator('time') - ( - - )} - - 分钟 - (空值,代表不限时长;非空值,代表限制时长,从学生首次答题开始持续计时) -
    -

    - -

    -

    -
    答题显示:
    -

    - - {getFieldDecorator('question_random') - ( - 题目顺序随机打乱 - )} - - (选中,则学生答题时,题目顺序按照题型随机显示) -

    -

    - - {getFieldDecorator('choice_random') - ( - 选项顺序随机打乱 - )} - - (选中,则学生答题时,选项顺序随机显示) -

    -
    -

    - -
    -
    - - - -
    -

    属性设置

    -
    -

    - - - {getFieldDecorator('score_open') - ( - 公开成绩 - )} - - (选中,则在试卷截止时间之后,已提交答题的学生可以查看其它学生的成绩,否则只能查看自己的成绩) -

    -

    - - {getFieldDecorator('answer_open') - ( - 公开答案 - )} - - (选中,则在试卷截止时间之后,已提交答题的学生可以查看试卷题目的答案,否则不能查看) -

    -

    - - {getFieldDecorator('show_statistic') - ( - 公开统计 - )} - - (选中,则在试卷截止时间之后,已提交答题的学生可以查看答题统计,否则不能查看) -

    -

    - - {getFieldDecorator('assistantauthority') - ( - 助教权限 - )} - - (选中,则允许助教查看答案) -

    -
    -
    - -
    - { - flagPageEdit&&this.props.isAdmin()===true ? -
    - - 取消 -
    - - - :"" - } - - -
    - ) - } -} -const WrappedExercisesetting = Form.create({ name: 'exercisesetting' })(Exercisesetting); -export default WrappedExercisesetting; - - diff --git a/src/modules/courses/exercise/Exercisestatisticalresult.js b/src/modules/courses/exercise/Exercisestatisticalresult.js deleted file mode 100644 index de922edf..00000000 --- a/src/modules/courses/exercise/Exercisestatisticalresult.js +++ /dev/null @@ -1,367 +0,0 @@ -import React, {Component} from "react"; -import {MarkdownToHtml,mdJSONParse} from 'educoder'; -import {Checkbox,Pagination} from "antd"; -import axios from 'axios'; -import Exercisetablesmubu from './Exercisetablesmubu'; -import Exercisestatisticalresulttabel from './Exercisestatisticalresulttabel'; - -import '../css/members.css'; -import '../css/busyWork.css'; -import '../poll/pollStyle.css'; - -const CheckboxGroup = Checkbox.Group; -const $ = window.$ -function createMarkup(value) { return {__html:value} }; -class Exercisestatisticalresult extends Component { - - constructor(props) { - super(props); - this.state = { - data:undefined, - sort:"asc", - exercise_group_id:[], - page:1, - limit:10, - searchtext:"", - order: "end_at", - - - } - } - - componentDidMount() { - let{sort,exercise_group_id,page,limit}=this.state; - this.updatefun(sort,exercise_group_id,page,limit); - try { - this.props.triggerRef(this); - }catch (e) { - - } - } - _getRequestParams() { - const { order, exercise_group_id,searchtext, page ,limit} = this.state - return { - page, - search:searchtext, - order, - limit: limit, - group_id:exercise_group_id, - } - } - updatefun=(sort,exercise_group_id,page,limit)=>{ - let ExerciseId=this.props.match.params.Id; - let url = `/exercises/`+ExerciseId+`/exercise_result.json`; - axios.get(url,{ - params:{ - sort:sort, - exercise_group_id:exercise_group_id, - page:page, - limit:limit - } - }).then((result) => { - this.setState({ - data:result.data - }) - }).catch((error) => { - console.log(error) - }) - } - - - onSortTypeChange=()=>{ - let{exercise_group_id,page,limit,sort}=this.state; - let newdesc="asc"; - if(sort==="desc"){ - newdesc="asc" - }else{ - newdesc="desc" - } - this.setState({ - sort:newdesc - }) - - this.updatefun(newdesc,exercise_group_id,page,limit) - } - - funtaskstatustwo=(checkedValues,list)=>{ - - let{sort,page,limit}=this.state; - // if(checkedValues.length===list.length){ - // this.setState({ - // exercise_group_id:[] - // }) - // }else{ - // - // } - this.setState({ - exercise_group_id:checkedValues - }) - this.updatefun(sort,checkedValues,page,limit) - } - - alldatalist = () => { - let {sort, page, limit} = this.state; - this.setState({ - exercise_group_id: [] - }) - this.updatefun(sort, [], page, limit) - } - PaginationCourse=(pageNumber)=>{ - let{sort,exercise_group_id,limit}=this.state; - - this.setState({ - page:pageNumber - }) - - $('html').animate({ - scrollTop: 10 - }, 1000); - this.updatefun(sort,exercise_group_id,pageNumber,limit) - - } - - render() { - let{data,sort,page,limit} =this.state; - let choicetype=["满分作答","部分得分作答","零分作答","未批"] - return ( -
    - - -
    - - {data&&data.course_groups.length===0?"":
    -
    -
      -
    • - 分班情况: - - this.alldatalist()}>全部 - - this.funtaskstatustwo(e,data&&data.course_groups)} value={this.state.exercise_group_id} style={{width:'87%',paddingTop: '4px'}}> - { data&&data.course_groups.map((item, key) => { - return ( - - {item.exercise_group_name} - ({item.exercise_group_students}) - - - ) - })} - -
    • -
    -
    -
    } - -
    -
    - -
    -
    - - -
    -
  • 统计详情
  • -
  • this.onSortTypeChange()}> - {/*{sort==="percent"?"正确率":sort==="type"?"题型":sort==="position"?"题序":""}*/} - {/**/} - {/*
      */} - {/*{sort==='percent'?"":
    • this.onSortTypeChange('percent')}>正确率
    • }*/} - {/*{sort==='type'?"":
    • this.onSortTypeChange('type')}>题型
    • }*/} - {/*{sort==='position'?"":
    • this.onSortTypeChange('position')}>题序
    • }*/} - {/*
    */} - 正确率 - - - - -
  • -
    - - - - {/* 从子组件将样式提出来,不然会循环多次 */} - - {data&&data.commit_results.map((item,key)=>{ - return( -
    -
    -
    - {item.ques_position + "."}{item.ques_type === 0 ? "单选" : item.ques_type === 1 ? "多选" : item.ques_type === 2 ? "判断" : item.ques_type === 3 ? "填空" : item.ques_type === 4 ? "主观" : item.ques_type === 5 ? "实训" :item.ques_type === 6 ? "编程" : ""}题 -
    - {/*Q{item.ques_position}:*/} - {/*
    */} - - {/**/} -
    -
    -
    正确率 {item.right_percent}%
    -
    - {item.ques_type===5? - - item.ques_details.map((ite,k)=>{ - return( -
    -
    -
    - {ite.challenge_position}:{ite.challenge_name} -
    -
    正确率 {ite.challenge_percent}%
    -
    - -
    - ) - }): - } -
    - ) - })} - -
    - { - data && data.questions_count > 10 && -
    - -
    - } - -
    - - - ) - } -} - -export default Exercisestatisticalresult; - - - diff --git a/src/modules/courses/exercise/Exercisestatisticalresulttabel.js b/src/modules/courses/exercise/Exercisestatisticalresulttabel.js deleted file mode 100644 index c52c7c2a..00000000 --- a/src/modules/courses/exercise/Exercisestatisticalresulttabel.js +++ /dev/null @@ -1,190 +0,0 @@ -import React, {Component} from "react"; -import {Table} from "antd"; -class OfficialAcademicTranscript extends Component { - - constructor(props) { - super(props); - this.state = { - loadingstate:true, - datas:undefined - } - } - - componentDidMount() { - - } - - render() { - - let {data}=this.props; - let datas=[]; - // data&&data.exercise_counts.forEach((item,key)=>{ }) - - datas.push({ - commit_percent:data&&data.exercise_counts.commit_percent, - min_score:data&&data.exercise_counts.min_score, - max_score:data&&data.exercise_counts.max_score, - average_score:data&&data.exercise_counts.average_score, - fail_counts:data&&data.exercise_counts.fail_counts, - pass_counts:data&&data.exercise_counts.pass_counts, - good_counts:data&&data.exercise_counts.good_counts, - best_counts:data&&data.exercise_counts.best_counts, - }) - - - - let columns=[{ - title: '提交率', - dataIndex: 'commit_percent', - key: 'commit_percent', - render: (text, record) => ( - - {record.commit_percent===0?0:(record.commit_percent*100).toFixed(2)}% - - ), - }, { - title: '最低分', - dataIndex: 'min_score', - key: 'min_score', - render: (text, record) => ( - - {record.min_score} - - ), - }, { - title: '最高分', - dataIndex: 'max_score', - key: 'max_score', - render: (text, record) => ( - - {record.max_score} - - ), - }, { - title: '平均分', - key: 'average_score', - dataIndex: 'average_score', - - render: (text, record) => ( - - {record.average_score} - - ), - }, { - title: '不及格(得分 低于60%)', - key: 'fail_counts', - dataIndex: 'fail_counts', - render: (text, record) => ( - - {record.fail_counts} - - ), - }, { - title: '及格(得分 60%~70%)', - key: 'pass_counts', - dataIndex: 'pass_counts', - - render: (text, record) => ( - - {record.pass_counts} - - ), - }, { - title: '良好(得分 70%~90%)', - key: 'good_counts', - dataIndex: 'good_counts', - - render: (text, record) => ( - - {record.good_counts} - - ), - }, { - title: '优秀(得分 90%~100%)', - key: 'best_counts', - dataIndex: 'best_counts', - - render: (text, record) => ( - - {record.best_counts} - - ), - }]; - // { - // title: '调分', - // key: 'adjustmentminute', - // dataIndex: 'adjustmentminute', - // - // render: (text, record) => ( - // - // 6小时 50分钟 6秒 - // - // ), - // }, - - - - return ( -
    - {/*{data===undefined?"":""}*/} - - {datas===undefined?"":} - - - ) - } -} - -export default OfficialAcademicTranscript; \ No newline at end of file diff --git a/src/modules/courses/exercise/Exercisetablesmubu.js b/src/modules/courses/exercise/Exercisetablesmubu.js deleted file mode 100644 index ff334cac..00000000 --- a/src/modules/courses/exercise/Exercisetablesmubu.js +++ /dev/null @@ -1,142 +0,0 @@ -import React, {Component} from "react"; -import {MarkdownToHtml} from 'educoder'; -import {Table,Progress} from "antd"; - - -const tagArray = [ - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', - 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', - 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' -] - -class Exercisetablesmubus extends Component { - - constructor(props) { - super(props); - this.state = { - loadingstate:true, - } - } - - componentDidMount() { - - } - - - render() { - - let {datass,type,effictive_counts,choicetype, tableNum}=this.props; - let list=[]; - - datass&&datass.forEach((item,key)=>{ - list.push({ - commit_percent:{ - num:item.choice_position, - value:type===4||type===5?choicetype[item.choice_text-1]:item.choice_text, - type:item.choice_right_boolean, - _type: type - }, - min_score:{value:item.choice_users_count,type:item.choice_right_boolean}, - max_score:item.choice_percent, - }) - }) - list.push({ - commit_percent: {num:null,value:"有效填写量"}, - min_score:{value:effictive_counts}, - }) - - let columns=[] - if(list.length!=0){ - columns=[{ - title: '选项', - dataIndex: 'commit_percent', - key: 'commit_percent', - render: (text, record, index) => { - const _content = - {text.value>0&&text.value!="有效填写量"&&text.value!="wrong"||!text.value&&text.value!="有效填写量"&&text.value!="wrong"? - text.value===1?"满分":text.value===2?"部分得分":text.value===3?"零分":text.value:text.value!="有效填写量"&&text.value!="wrong"&& - } - {text.value==="wrong" && "填写了错误答案" } - {text.value==="有效填写量" && "有效填写量" } - - return ( - - (text._type === 0 || text._type === 1) ?
    - {{tagArray[index]}.} - {_content} -
    : {_content} - ) - - }, - }, { - title: '小计', - dataIndex: 'min_score', - key: 'min_score', - align: 'center', - width:'200px', - render: (text, record) => ( - - {text.value} - - ), - }, { - title: '百分比', - dataIndex: 'max_score', - key: 'max_score', - align: 'center', - width:'300px', - render: (text, record) => ( - - {record.max_score===undefined?"": -
    {(record.max_score*100).toFixed()}%
    } -
    - ), - }]; - - } - - - - - - return ( -
    - - - {list===undefined?"":
    } - - - ) - } -} - -export default Exercisetablesmubus; diff --git a/src/modules/courses/exercise/Studentshavecompletedthelist.js b/src/modules/courses/exercise/Studentshavecompletedthelist.js deleted file mode 100644 index 095560f1..00000000 --- a/src/modules/courses/exercise/Studentshavecompletedthelist.js +++ /dev/null @@ -1,3396 +0,0 @@ -import React, {Component} from "react"; -import CoursesListType from '../coursesPublic/CoursesListType'; -import {WordsBtn} from 'educoder'; - -import { - Select, - Input, - Checkbox, - Table, - Radio, - Pagination, - Tooltip, -} from "antd"; -import axios from 'axios'; -import '../css/members.css' -import "../common/formCommon.css" -import '../css/Courses.css' -import '../css/busyWork.css' -import '../poll/pollStyle.css' -import moment from 'moment'; -import 'moment/locale/zh-cn'; -import './yslexercisetable.css'; -import {getImageUrl, toPath, sortDirections} from 'educoder'; -import NoneData from '../../../modules/courses/coursesPublic/NoneData'; -import ModulationModal_exercise from "../coursesPublic/ModulationModal_exercise"; - -const Search = Input.Search; -const RadioGroup = Radio.Group; -const CheckboxGroup = Checkbox.Group; -const {Option} = Select; -//学生老师页面 -let columnsystwo = []; -let myssubjective = 0; //是否显示主观题 -let mysubjective_score = 0;//主观题得分 -let myobjective_score = 0;//客观题得分 - -class Studentshavecompletedthelist extends Component { - constructor(props) { - super(props); - this.state = { - data: [], - datas: [], - page: 1, - limit: 20, - testpapergradingboll: false, - styletable: { - "display": "block" - }, - course_groupyslstwodatas: [{id: 0, tu: "未评"}, {id: 1, tu: "已评"}], - course_groupyslsthree: undefined, - teacherlist: undefined, - searchtext: "", - Teacherliststudentlist: undefined, - mylistansum: 0, - review: null, - course_groupysls: undefined, - nocomment: false, - course_groupyslstwo: undefined, - commented: false, - commit_status: undefined, - submitted: false, - unsubmitted: false, - exercise_users: undefined, - loadingstate: true, - order: "end_at", - current_answer_user: undefined, - course_groups: undefined, - course_groupsdatas: false, - noclassroom: undefined, - current_status: props.current_status, - course_groupyslstwodata: [{id: 0, tu: "未开始"}, {id: 1, tu: "考试中"},{id: 2, tu: "已交卷"}], - columns: [ - { - title: '序号', - dataIndex: 'number', - key: 'number', - align: 'center', - className: "edu-txt-center font-14", - width: '100px', - render: (text, record) => ( - - {record.number === "--" ? - {record.number} - : - {record.number} - - } - - ) - }, - { - title: '姓名', - dataIndex: 'name', - key: 'name', - align: 'center', - className: "edu-txt-center font-14 maxnamewidth110", - width: '100px', - render: (text, record) => ( - - {record.name === "--" ? - {record.name} - : - {record.name} - - } - - ) - }, - { - title: '学号', - dataIndex: 'stduynumber', - key: 'stduynumber', - align: 'center', - className: "edu-txt-center font-14 maxnamewidth175", - width: '175px', - sorter: true, - sortDirections: sortDirections, - render: (text, record) => ( - - {record.stduynumber === null ? - -- : - record.stduynumber === - "" ? - -- : - {record.stduynumber} - } - - - ), - }, - { - title: '分班', - key: 'classroom', - dataIndex: 'classroom', - align: 'center', - className: "edu-txt-center font-14 maxnamewidth255", - width: '255px', - render: (text, record) => ( - - {record.classroom === null ? - -- : - record.classroom === - "" ? - -- : - {record.classroom} - } - - - ) - }, - { - title: '提交状态', - dataIndex: 'submitstate', - key: 'submitstate', - align: 'center', - className: "edu-txt-center font-14", - width: '98px', - render: (text, record) => ( - - {record.submitstate} - - ) - - }, - { - title: '提交时间', - dataIndex: 'updatetime', - key: 'updatetime', - align: 'center', - className: "edu-txt-center font-14", - width: '175px', - sorter: true, - defaultSortOrder: 'descend', - sortDirections: sortDirections, - render: (text, record) => ( - - {record.updatetime === "--" ? - {record.updatetime} - : - {record.updatetime} - } - - ), - }, - { - title: '客观题得分', - dataIndex: 'completion', - key: 'completion', - align: 'center', - className: "edu-txt-center font-14", - width: '98px', - render: (text, record) => ( - { - record.completion === "--" ? - - {record.completion} - - : - 90 ? { - color: '#DD1717', - textAlign: "center", - width: '98px', - } : parseInt(record.completion) <= 90 &&parseInt(record.completion)>60? { - color: '#FF6800', - textAlign: "center", - width: '98px', - } : parseInt(record.completion) <= 60 ? { - color: '#747A7F', - textAlign: "center", - width: '98px', - } : - { - color: '#747A7F', - textAlign: "center", - width: '98px', - }}>{record.completion} - } - - - ) - }, - { - title: '主观题得分', - dataIndex: 'levelscore', - key: 'levelscore', - align: 'center', - className: "edu-txt-center font-14", - width: '99px', - render: (text, record) => ( - - {record.levelscore === "--" ? - - {record.levelscore} - - : - 90 ? { - color: '#DD1717', - textAlign: "center", - width: '99px', - } : parseInt(record.levelscore) <= 90 &&parseInt(record.levelscore) >60? { - color: '#FF6800', - textAlign: "center", - width: '99px', - } : parseInt(record.levelscore) <= 60 ? { - color: '#747A7F', - textAlign: "center", - width: '99px', - } : {color: '#747A7F', textAlign: "center", width: '99px'}}>{record.levelscore} - { - //主观题老师没有评分是 - parseInt(record.levelscore) === 0 && myssubjective === 1 &&record.review_status===false? - - (待批阅) - - :"" - } - - } - - ) - }, - { - title: 最终成绩 - 鼠标停留具体分值上可查
    - 看得分明细
    - }>
    , - dataIndex: 'efficiencyscore', - key: 'efficiencyscore', - align: 'center', - className: "edu-txt-center font-14", - sorter: true, - sortDirections: sortDirections, - width: '199px', - render: (text, record) => ( - - {record.efficiencyscore === "--" ? - -
    未评分
    - }> - - {record.efficiencyscore} - -
    - : - record.commit_method === 5 ? - -
    最终调整成绩:{record.efficiencyscore}分
    - }> - 90 ? { - color: '#DD1717', - textAlign: "center" - } : parseInt(record.efficiencyscore) <= 90 && parseInt(record.efficiencyscore) > 60 ? { - color: '#FF6800', - textAlign: "center" - } : parseInt(record.efficiencyscore) <= 60 ? { - color: '#747A7F', - textAlign: "center", - } : { - color: '#747A7F', - textAlign: "center" - }}>{record.efficiencyscore} -
    - : - - -
    {record.objective_score === undefined ? "" : record.objective_score === "--" ? - 客观题得分:0分 : - 客观题得分:{record.objective_score}分} -
    - -
    {record.subjective_score === undefined ? "" : record.subjective_score === "--" ? - 主观题得分:0分 : - 主观题得分:{record.subjective_score}分} -
    - { - (parseInt(record.efficiencyscore) === 0||record.efficiencyscore === "--") && myssubjective === 0 && mysubjective_score>0 &&record.review_status===false? -
    - 待批阅 -
    - : -
    {record.efficiencyscore === "--" ? 最终成绩:0分 : - 最终成绩:{record.efficiencyscore}分} -
    - } - - - }> - 90 ? { - color: '#DD1717', - textAlign: "center" - } : parseInt(record.efficiencyscore) <= 90 && parseInt(record.efficiencyscore) > 60 ? { - color: '#FF6800', - textAlign: "center" - } : parseInt(record.efficiencyscore) <= 60 ? { - color: '#747A7F', - textAlign: "center", - } : { - color: '#747A7F', - textAlign: "center" - }}>{record.efficiencyscore} - {//只有一个主观题的时候 - parseInt(record.efficiencyscore) === 0 && myssubjective === 0 && mysubjective_score>0 &&record.review_status===false? - - (待批阅) - : - "" - } -
    - } -
    - ) - }, - { - title: '操作', - dataIndex: 'finalscore', - key: 'finalscore', - align: 'center', - className: "edu-txt-center font-14", - width: '98px', - render: (text, record) => ( - - -- - - ) - }, - ], - columnstwo: [ - { - title: '序号', - dataIndex: 'number', - key: 'number', - align: 'center', - className: "edu-txt-center tabletd font-14", - width: '100px', - render: (text, record) => ( - - { - - } - - ) - }, - { - title: '姓名', - dataIndex: 'name', - key: 'name', - align: 'center', - className: "edu-txt-center tabletd font-14 maxnamewidth110", - width: '100px', - render: (text, record) => ( - - { - record.name === "--" ? - {record.name} - : - {record.name} - - } - - ) - }, - { - title: '学号', - dataIndex: 'stduynumber', - key: 'stduynumber', - align: 'center', - className: "edu-txt-center tabletd font-14 maxnamewidth175", - width: '175px', - render: (text, record) => ( - - {record.stduynumber === null ? - -- - : - record.stduynumber === "" ? - -- - : - {record.stduynumber} - } - - - ), - }, - { - title: '分班', - key: 'classroom', - dataIndex: 'classroom', - align: 'center', - className: "edu-txt-center tabletd font-14 maxnamewidth255", - width: '255px', - render: (text, record) => ( - - {record.classroom === null ? - -- : record.classroom === "" ? - -- : - {record.classroom} - } - - - ) - }, - { - title: '提交状态', - dataIndex: 'submitstate', - key: 'submitstate', - align: 'center', - className: "edu-txt-center tabletd font-14", - width: '98px', - render: (text, record) => ( - - {record.submitstate} - - ) - - }, - { - title: '提交时间', - dataIndex: 'updatetime', - key: 'updatetime', - align: 'center', - className: "edu-txt-center tabletd font-14", - width: '175px', - render: (text, record) => ( - - {record.updatetime === "--" ? - -- - : - {record.updatetime} - } - - ), - }, - { - title: '客观题得分', - dataIndex: 'completion', - key: 'completion', - align: 'center', - className: "edu-txt-center tabletd font-14", - width: '98px', - render: (text, record) => ( - - {record.completion === "--" ? - - -- - - - : - 90 ? { - color: '#DD1717', - textAlign: "center", - width: '98px', - } : parseInt(record.completion) <= 90 && parseInt(record.completion)>60? { - color: '#FF6800', - textAlign: "center", - width: '98px', - } : parseInt(record.completion) <= 60 ? { - color: '#747A7F', - textAlign: "center", - width: '98px', - } : { - color: '#747A7F', - textAlign: "center", - width: '98px', - }}>{record.completion} - } - - ) - }, - { - title: '主观题得分', - dataIndex: 'levelscore', - key: 'levelscore', - align: 'center', - className: "edu-txt-center tabletd font-14", - width: '99px', - render: (text, record) => ( - - {record.levelscore === "--" ? - - -- - - : - 90 ? { - color: '#DD1717', - textAlign: "center", - width: '99px' - } : parseInt(record.levelscore) <= 90 && parseInt(record.levelscore) >60? { - color: '#FF6800', - textAlign: "center", - width: '99px' - } : parseInt(record.levelscore) <= 60 ? { - color: '#747A7F', - textAlign: "center", - width: '99px' - } : {color: '#747A7F', textAlign: "center", width: '99px'}}>{record.levelscore} - { - //主观题老师没有评分是 - parseInt(record.levelscore) === 0 && myssubjective === 1 &&record.review_status===false? - - (待批阅) - :"" - } - - } - - ) - }, - { - title: 最终成绩 - 鼠标停留具体分值上可查
    - 看得分明细
    - }>
    , - dataIndex: 'efficiencyscore', - key: 'efficiencyscore', - align: 'center', - className: "edu-txt-center tabletd font-14 columnstwoachievement", - width: "199px", - render: (text, record) => ( - - { - record.efficiencyscore === "--" ? - -
    未评分
    - }> - -- -
    - : - record.commit_method === 5 ? - -
    最终调整成绩:{record.efficiencyscore}分
    - }> - 90 ? { - color: '#DD1717', - textAlign: "center", - width: "199px" - } : parseInt(record.efficiencyscore) <= 90 && parseInt(record.efficiencyscore) > 60 ? { - color: '#FF6800', - textAlign: "center", - width: "199px" - } : parseInt(record.efficiencyscore) <= 60 ? { - color: '#747A7F', - textAlign: "center", - width: "199px" - } : { - color: '#747A7F', - textAlign: "center", - width: "199px" - }}>{record.efficiencyscore} -
    - : - - -
    {record.objective_score === undefined ? "" : record.objective_score === "--" ? - 客观题得分:0分 : - 客观题得分:{record.objective_score}分} -
    - -
    {record.subjective_score === undefined ? "" : record.subjective_score === "--" ? - 主观题得分:0分 : - 主观题得分:{record.subjective_score}分} -
    - { - (parseInt(record.efficiencyscore) === 0||record.efficiencyscore === "--") && myssubjective === 0&& mysubjective_score>0 &&record.review_status===false? -
    - 待批阅 -
    - : -
    {record.efficiencyscore === "--" ? 最终成绩:0分 : - 最终成绩:{record.efficiencyscore}分} -
    - } - - - }> - 90 ? { - color: '#DD1717', - textAlign: "center", - width: "199px" - } : parseInt(record.efficiencyscore) <= 90 && parseInt(record.efficiencyscore) > 60 ? { - color: '#FF6800', - textAlign: "center", - width: "199px" - } : parseInt(record.efficiencyscore) <= 60 ? { - color: '#747A7F', - textAlign: "center", - width: "199px" - } : { - color: '#747A7F', - textAlign: "center", - width: "199px" - }}>{record.efficiencyscore} - {//只有一个主观题的时候 - parseInt(record.efficiencyscore) === 0 && myssubjective === 0&& mysubjective_score>0 &&record.review_status===false? - - (待批阅) - : - "" - } -
    - } - -
    - ) - }, - { - title: '操作', - dataIndex: 'finalscore', - key: 'finalscore', - align: 'center', - className: "edu-txt-center tabletd font-14", - width: "98px", - render: (text, record) => ( - - { - record.submitstate === "未开始" || record.commit_method === 5 ? - -aa- - : record.submitstate === "已交卷" ? - record.score_open === null || record.score_open === undefined ? "" : - record.score_open === true ? - 查看 - : "" - : - -- - } - - ) - }, - ], - columnss: [ - { - title: '序号', - dataIndex: 'number', - key: 'number', - align: 'center', - className: "edu-txt-center font-14", - render: (text, record) => ( - - { - record.number === "--" ? - -- - : - {record.number} - } - - - ) - }, - { - title: '姓名', - dataIndex: 'name', - key: 'name', - align: 'center', - className: "edu-txt-center font-14", - render: (text, record) => ( - - { - record.name === "--" ? - -- - : - {record.name} - } - - ) - }, - { - title: '学号', - dataIndex: 'stduynumber', - key: 'stduynumber', - align: 'center', - className: "edu-txt-center font-14", - render: (text, record) => ( - - {record.stduynumber === null ? - -- - : record.stduynumber === "" ? - -- - : - {record.stduynumber} - } - - - ), - }, - { - title: '分班', - key: 'classroom', - dataIndex: 'classroom', - align: 'center', - className: "edu-txt-center font-14 maxnamewidth260", - width: "260px", - render: (text, record) => ( - - {record.classroom === null ? - -- : record.classroom === "" ? - -- : - {record.classroom} - } - - - ) - }, - { - title: '提交状态', - dataIndex: 'submitstate', - key: 'submitstate', - align: 'center', - className: "edu-txt-center font-14", - render: (text, record) => ( - - {record.submitstate} - - ) - - }, - { - title: '提交时间', - dataIndex: 'updatetime', - key: 'updatetime', - align: 'center', - className: "edu-txt-center font-14", - render: (text, record) => ( - - { - record.updatetime === "--" ? - -- - - : - {record.updatetime} - - } - - ), - }, - { - title: '客观题得分', - dataIndex: 'completion', - key: 'completion', - align: 'center', - className: "edu-txt-center font-14", - render: (text, record) => ( - - { - record.completion === "--" ? - -- - : - 90 ? { - color: '#DD1717', - textAlign: "center", - } : parseInt(record.completion) <= 90&& parseInt(record.completion) >60 ? { - color: '#FF6800', - textAlign: "center", - } : parseInt(record.completion) <= 60 ? { - color: '#747A7F', - textAlign: "center", - } : { - color: '#747A7F', - textAlign: "center", - }}>{record.completion} - } - - - ) - }, - { - title: '主观题得分', - dataIndex: 'levelscore', - key: 'levelscore', - align: 'center', - className: "edu-txt-center font-14", - render: (text, record) => ( - - { - record.levelscore === "--" ? - -- : - 90 ? { - color: '#DD1717', - textAlign: "center", - } : parseInt(record.levelscore) <= 90 &&parseInt(record.levelscore)>60? { - color: '#FF6800', - textAlign: "center", - } : parseInt(record.levelscore) <= 60 ? { - color: '#747A7F', - textAlign: "center", - } : {color: '#747A7F', textAlign: "center"}}>{record.levelscore} - { - //主观题老师没有评分是 - parseInt(record.levelscore) === 0 && myssubjective === 1 &&record.review_status===false? - - (待批阅) - : - "" - } - - } - - - ) - }, - { - title: 最终成绩 - 鼠标停留具体分值上可查
    - 看得分明细
    - }>
    , - dataIndex: 'efficiencyscore', - key: 'efficiencyscore', - align: 'center', - className: "edu-txt-center font-14", - render: (text, record) => ( - - { - record.efficiencyscore === "--" ? - -
    未评分
    - }> - -- -
    - : - record.commit_method === 5 ? - -
    最终调整成绩:{record.efficiencyscore}分
    - }> - 90 ? { - color: '#DD1717', - textAlign: "center", - } : parseInt(record.efficiencyscore) <= 90 && parseInt(record.efficiencyscore) > 60 ? { - color: '#FF6800', - textAlign: "center", - } : parseInt(record.efficiencyscore) <= 60 ? { - color: '#747A7F', - textAlign: "center", - } : { - color: '#747A7F', - textAlign: "center", - }}>{record.efficiencyscore} -
    - : - - -
    {record.objective_score === undefined ? "" : record.objective_score === "--" ? - 客观题得分:0分 : - 客观题得分:{record.objective_score}分} -
    - -
    {record.subjective_score === undefined ? "" : record.subjective_score === "--" ? - 主观题得分:0分 : - 主观题得分:{record.subjective_score}分} -
    - { - (parseInt(record.efficiencyscore) === 0||record.efficiencyscore === "--") && myssubjective === 0 && mysubjective_score>0 &&record.review_status===false? -
    - 待批阅 -
    - : -
    {record.efficiencyscore === "--" ? 最终成绩:0分 : - 最终成绩:{record.efficiencyscore}分} -
    - } - - - }> - 90 ? { - color: '#DD1717', - textAlign: "center", - } : parseInt(record.efficiencyscore) <= 90 && parseInt(record.efficiencyscore) > 60 ? { - color: '#FF6800', - textAlign: "center", - } : parseInt(record.efficiencyscore) <= 60 ? { - color: '#747A7F', - textAlign: "center", - } : { - color: '#747A7F', - textAlign: "center", - }}>{record.efficiencyscore} - {//只有一个主观题的时候 - parseInt(record.efficiencyscore) === 0 && myssubjective === 0&& mysubjective_score>0 &&record.review_status===false? - - (待批阅) - : - "" - } -
    - } -
    - ) - }, - { - title: '操作', - dataIndex: 'operating', - key: 'operating', - align: 'center', - className: "edu-txt-center font-14", - render: (text, record) => ( - - {record.operating === "--" ? - {record.operating} - : record.submitstate === "未开始" ? - -- - : - {record.operating} - } - - - ) - }, - ], - vaiew: false, - unlimited: 0, - unlimiteds: 0, - unlimitedtwo: 0, - checkedValues: [], - checkedValuesineinfo: [], - Evaluationarray: [{id: 1, value: "未评"}, {id: 2, value: "已评"}], - columnsys: [ - { - title: '序号', - dataIndex: 'number', - key: 'number', - align: 'center', - className: "edu-txt-center font-14", - render: (text, record) => ( - - {record.number === "--" ? - -- - : - {record.number} - } - - ) - }, - { - title: '姓名', - dataIndex: 'name', - key: 'name', - align: 'center', - className: "edu-txt-center font-14", - render: (text, record) => ( - - {record.name === "--" ? - {record.name} - : - {record.name} - } - - ) - }, - { - title: '学号', - dataIndex: 'stduynumber', - key: 'stduynumber', - align: 'center', - className: "edu-txt-center font-14", - sorter: true, - sortDirections: sortDirections, - render: (text, record) => ( - - {record.stduynumber === "--" ? - {record.stduynumber} - : - {record.stduynumber} - } - - ), - }, - { - title: '分班', - key: 'classroom', - dataIndex: 'classroom', - align: 'center', - className: "edu-txt-center font-14 maxnamewidth260", - width: '260px', - render: (text, record) => ( - - {record.classroom === "--" ? - {record.classroom} - : - {record.classroom} - } - - ) - }, - { - title: '提交状态', - dataIndex: 'submitstate', - key: 'submitstate', - align: 'center', - className: "edu-txt-center font-14", - render: (text, record) => ( - - {record.submitstate} - - - ) - - }, - { - title: '提交时间', - dataIndex: 'updatetime', - key: 'updatetime', - align: 'center', - className: "edu-txt-center font-14", - sorter: true, - defaultSortOrder: 'descend', - sortDirections: sortDirections, - render: (text, record) => ( - - {record.updatetime === "--" ? - -- - : - {record.updatetime} - } - - ), - }, - { - title: '客观题得分', - dataIndex: 'completion', - key: 'completion', - align: 'center', - className: "edu-txt-center font-14", - render: (text, record) => ( - - { - record.completion === "--" ? - -- - : - 90 ? { - color: '#DD1717', - textAlign: "center", - } : parseInt(record.completion) <= 90 && parseInt(record.completion) > 60 ? { - color: '#FF6800', - textAlign: "center", - } : parseInt(record.completion) <= 60 ? { - color: '#747A7F', - textAlign: "center", - } : { - color: '#747A7F', - textAlign: "center", - }}>{record.completion} - } - - ) - }, - { - title: '主观题得分', - dataIndex: 'levelscore', - key: 'levelscore', - align: 'center', - className: "edu-txt-center font-14", - render: (text, record) => ( - - { - record.levelscore === "--" ? - -- : - 90 ? { - color: '#DD1717', - textAlign: "center", - } : parseInt(record.levelscore) <= 90 && parseInt(record.levelscore) > 60 ? { - color: '#FF6800', - textAlign: "center", - } : parseInt(record.levelscore) <= 60 ? { - color: '#747A7F', - textAlign: "center", - } : {color: '#747A7F', textAlign: "center"}}>{record.levelscore} - { - //主观题老师没有评分是 - parseInt(record.levelscore) === 0 && myssubjective === 1&&record.review_status===false? - - (待批阅) - : - "" - } - - - } - - - ) - }, - { - title: 最终成绩 - 鼠标停留具体分值上可查
    - 看得分明细
    - }>
    , - dataIndex: 'efficiencyscore', - key: 'efficiencyscore', - align: 'center', - className: "edu-txt-center font-14", - sorter: true, - sortDirections: sortDirections, - render: (text, record) => ( - - {record.efficiencyscore === "--" ? - -
    未评分
    - }> - -- -
    - : - record.commit_method === 5 ? - -
    最终调整成绩:{record.efficiencyscore}分
    - }> - 90 ? { - color: '#DD1717', - textAlign: "center", - } : parseInt(record.efficiencyscore) <= 90 && parseInt(record.efficiencyscore) > 60 ? { - color: '#FF6800', - textAlign: "center", - } : parseInt(record.efficiencyscore) <= 60 ? { - color: '#747A7F', - textAlign: "center", - } : { - color: '#747A7F', - textAlign: "center", - }}>{record.efficiencyscore} -
    - : - - -
    {record.objective_score === undefined ? "" : record.objective_score === "--" ? - 客观题得分:0分 : - 客观题得分:{record.objective_score}分} -
    - -
    {record.subjective_score === undefined ? "" : record.subjective_score === "--" ? - 主观题得分:0分 : - 主观题得分:{record.subjective_score}分} -
    - { - (parseInt(record.efficiencyscore) === 0||record.efficiencyscore === "--") && myssubjective === 0&& mysubjective_score>0 && record.review_status===false? -
    - 待批阅 -
    - : -
    - {record.efficiencyscore === "--" ? - 最终成绩:0分 - : - 最终成绩:{record.efficiencyscore}分 - } -
    - } - - - - }> - 90 ? { - color: '#DD1717', - textAlign: "center", - } : parseInt(record.efficiencyscore) <= 90 && parseInt(record.efficiencyscore) > 60 ? { - color: '#FF6800', - textAlign: "center", - } : parseInt(record.efficiencyscore) <= 60 ? { - color: '#747A7F', - textAlign: "center", - } : { - color: '#747A7F', - textAlign: "center", - }}>{parseInt(record.efficiencyscore) === 0 ? 0 : record.efficiencyscore} - {//只有一个主观题的时候 - (parseInt(record.efficiencyscore) === 0||record.efficiencyscore === "--") && myssubjective === 0&& mysubjective_score>0 && record.review_status===false? - - (待批阅) - : - "" - } - -
    - } -
    - ) - }, - { - title: '操作', - dataIndex: 'finalscore', - key: 'finalscore', - align: 'center', - className: "edu-txt-center font-14", - render: (text, record) => ( - - { - record.submitstate === "未开始" || record.commit_method === 5 ? - (//是否助教 - this.props.isAssistant() && this.props.isAssistant() === true ? - (//助教是否有权限 - this.props.assistant_auth && this.props.assistant_auth === true ? - this.Adjustment(record.user_id)}>{record.has_comment === true ? "已评阅" : "评阅"} - : - (//是否截止 - this.props.Commonheadofthetestpaper && this.props.Commonheadofthetestpaper.exercise_status === 3 ? - this.Adjustment(record.user_id)}>{record.has_comment === true ? "已评阅" : "评阅"} - : - -- - ) - ) - : - this.Adjustment(record.user_id)}>{record.has_comment === true ? "已评阅" : "评阅"} - ) - : record.submitstate === "已交卷" ? - (//是否助教 - this.props.isAssistant() && this.props.isAssistant() === true ? - (//助教是否有权限 - this.props.assistant_auth && this.props.assistant_auth === true ? - {record.finalscore} - : - (//是否截止 - this.props.Commonheadofthetestpaper && this.props.Commonheadofthetestpaper.exercise_status === 3 ? - {record.finalscore} - : - -- - ) - ) - : - {record.finalscore} - ) - : - -- - } - - ) - }, - ], - // 也会被columnsys当作参数接收 - exercise_status: 0, - order_type: "desc", - exeuserid: 0, - subjective: 0, - objective_score: 0, - subjective_score: 0, - } - {/* this.Adjustment(record.user_id)}>评阅*/ - } - {/*--*/ - } - // //console.log("Studentshavecompletedthelist"); - // //console.log(props.current_status); - // columnsys 老师列表 - // columnss 学生只能看自己的 未截止页面 - // columnstwo 截止显示自己的 - // columns 截止后显示其他学生 - } - - paginationonChange = (pageNumber) => { - if (this.state.loadingstate === false) { - this.setState({ - page: pageNumber, - loadingstate: true, - }) - - } else { - this.setState({ - page: pageNumber, - }) - } - - this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, this.state.course_groupyslsthree, this.state.checkedValuesineinfo, this.state.searchtext, pageNumber, 20, this.state.order_type); - - } - paginationonChanges = (pageNumber) => { - // console.log('Page: ',pageNumber); - if (this.state.loadingstate === false) { - this.setState({ - page: pageNumber, - loadingstate: true, - }) - - } else { - this.setState({ - page: pageNumber, - }) - } - - this.Searchdata(this.state.order, null, null, null, null, pageNumber, this.state.limit, this.state.order_type); - - - } - - componentDidMount() { - //被columnsys当作参数接收 - // console.log("componentDidMount"); - // console.log(columnsystwo); - try { - columnsystwo = this.state.columnsys; - } catch (e) { - - } - // console.log(columnsystwo); - this.Teacherliststudentlist(); - - try { - this.props.triggerRef(this); - } catch (e) { - - } - - } - - componentWillReceiveProps = (nextProps) => { - - } - - - //试卷列表 - Teacherliststudentlist = () => { - // //console.log("Teacherliststudentlist"); // 764 - var thiss = this; - var exercise_id = this.props.match.params.Id; - // //console.log(731); // 764 935 - var url = `/exercises/${exercise_id}/exercise_lists.json`; - axios.get((url), { - params: { - order: "end_at", - commit_status: null, - review: null, - exercise_group_id: null, - search: "", - page: null, - limit: null, - } - }).then((response) => { - if (response === undefined) { - return - } - try { - myssubjective = response.data.exercise_types.subjective?response.data.exercise_types.subjective:0;//记录是否有主观题 1是有 - mysubjective_score = response.data.exercise_types.subjective_score?response.data.exercise_types.subjective_score:0; - myobjective_score = response.data.exercise_types.objective_score?response.data.exercise_types.objective_score:0; - } catch (e) { - - } - - //学生 - if (response.data.exercise_types.user_permission === 1) { - this.setState({ - Teacherliststudentlist: response.data, - review: response.data.review, - commit_status: response.data.commit_status, - exercise_users: response.data.exercise_users, - current_answer_user: response.data.current_answer_user, - course_groups: response.data.course_groups, - mylistansum: response.data.exercise_types.answer_users + response.data.exercise_types.unanswer_users - }) - if (response.data.current_answer_user === undefined || response.data.current_answer_user === null) { - // 学生未截止 - // //console.log("试卷学生未截止"); - this.Generatenewdatas(response.data.exercise_users); - if (response.data.exercise_types.subjective === 0) { - - if (this.state.noclassroom === undefined || this.state.noclassroom === "" || this.state.noclassroom === null) { - var arr = []; - for (var i = 0; i < this.state.columnss.length; i++) { - var item = this.state.columnss[i]; - if (item.title === "分班") { - } else if (item.title === "客观题得分") { - } else if (item.title === "主观题得分") { - } else if (this.props.isNotMember() === true && item.title === "学号") { - - } else { - arr.push(item); - } - } - this.setState({ - columnss: arr, - }) - - } else { - var arr = []; - for (var i = 0; i < this.state.columnss.length; i++) { - var item = this.state.columnss[i]; - if (item.title === "客观题得分") { - - } else if (item.title === "主观题得分") { - } else if (this.props.isNotMember() === true && item.title === "学号") { - - } else { - arr.push(item); - } - } - this.setState({ - columnss: arr - }) - } - - } - } else { - //学生已截止 - // //console.log("试卷学生已截止"); - if (response.data.exercise_types.subjective === 0) { - if (this.state.loadingstate === false) { - var arr = []; - for (var i = 0; i < this.state.columnstwo.length; i++) { - var item = this.state.columnstwo[i]; - if (item.title === "客观题得分") { - } else if (item.title === "主观题得分") { - } else if (this.props.isNotMember() === true && item.title === "学号") { - - } else { - arr.push(item); - } - } - - var arr2 = []; - for (var i = 0; i < this.state.columns.length; i++) { - var item = this.state.columns[i]; - if (item.title === "客观题得分") { - } else if (item.title === "主观题得分") { - } else if (this.props.isNotMember() === true && item.title === "学号") { - - } else { - arr2.push(item); - } - } - thiss.setState({ - columns: arr2, - columnstwo: arr, - loadingstate: true, - }) - } else { - - var arr = []; - for (var i = 0; i < this.state.columnstwo.length; i++) { - var item = this.state.columnstwo[i]; - if (item.title === "客观题得分") { - } else if (item.title === "主观题得分") { - } else if (this.props.isNotMember() === true && item.title === "学号") { - - } else { - arr.push(item); - } - } - var arr2 = []; - for (var i = 0; i < this.state.columns.length; i++) { - var item = this.state.columns[i]; - if (item.title === "客观题得分") { - } else if (item.title === "主观题得分") { - } else if (this.props.isNotMember() === true && item.title === "学号") { - - } else { - arr2.push(item); - } - } - thiss.setState({ - columns: arr2, - columnstwo: arr, - }) - } - - - } - thiss.Generatenewdata(response.data.exercise_users, response.data.current_answer_user, response.data.exercise_types); - } - } - //老师 - else if (response.data.exercise_types.user_permission === 0) { - // //console.log(response.data.exercise_users) - // //console.log(response) - // //console.log("试卷老师加载中"); - if (thiss.state.loadingstate === false) { - thiss.setState({ - loadingstate: true, - }) - } - //console.log(response); - //console.log(1393); - thiss.Generatenewdatasy(response.data.exercise_users, response); - } - }).catch((error) => { - // //console.log(error); - // //console.log("其实数据加载失败了"); - // //console.log("1111"); - }); - - - } - - Generatenewdata(exercise_users, current_answer_user, exercise_types) { - let {page, limit} = this.state; - let datalist = []; - let datalisttwo = []; - var teacherlist = undefined; - // //console.log("开始数据了"); - if (exercise_users !== undefined) { - // //console.log("开始打印数据了"); - for (var i = 0; i < exercise_users.length; i++) { - if (exercise_users[i].commit_status === 1) { - datalist.push({ - myid: exercise_users[i].login, - user_group_id: exercise_users[i].user_group_id, - number: (parseInt(page) - 1) * parseInt(limit) + (i + 1), - name: exercise_users[i].user_name, - stduynumber: exercise_users[i].student_id === undefined ? "--" : exercise_users[i].student_id === null ? "--" : exercise_users[i].student_id === "" ? "--" : exercise_users[i].student_id, - classroom: exercise_users[i].user_group_name, - submitstate: exercise_users[i].commit_status === 1 ? "考试中" : exercise_users[i].commit_status === 0?"未开始":"已交卷", - updatetime: moment(exercise_users[i].end_at).format('YYYY-MM-DD HH:mm') === "Invalid date" ? "--" : moment(exercise_users[i].end_at).format('YYYY-MM-DD HH:mm'), - completion: exercise_users[i].objective_score === undefined ? "--" : exercise_users[i].objective_score === null ? "--" : exercise_users[i].objective_score === "" ? "--" : exercise_users[i].objective_score, - levelscore: exercise_users[i].subjective_score === undefined ? "--" : exercise_users[i].subjective_score === null ? "--" : exercise_users[i].subjective_score === "" ? "--" : exercise_users[i].subjective_score, - efficiencyscore: exercise_users[i].score === null ? "--" : exercise_users[i].score === "" ? "--" : exercise_users[i].score, - objective_score: exercise_users[i].objective_score === null ? "--" : exercise_users[i].objective_score === "" ? "--" : exercise_users[i].objective_score, - subjective_score: exercise_users[i].subjective_score === null ? "--" : exercise_users[i].subjective_score === "" ? "--" : exercise_users[i].subjective_score, - operating: exercise_users[i].has_comment === true ? "已评阅" : "评阅", - commit_method: exercise_users[i].commit_method, - has_comment: exercise_users[i].has_comment, - review_status: exercise_users[i].review_status, - }) - } else { - datalist.push({ - myid: exercise_users[i].login, - user_group_id: exercise_users[i].user_group_id, - number: (parseInt(page) - 1) * parseInt(limit) + (i + 1), - name: exercise_users[i].user_name, - stduynumber: exercise_users[i].student_id === undefined ? "--" : exercise_users[i].student_id === null ? "--" : exercise_users[i].student_id === "" ? "--" : exercise_users[i].student_id, - classroom: exercise_users[i].user_group_name, - submitstate: exercise_users[i].commit_status === 1 ? "考试中" : exercise_users[i].commit_status === 0?"未开始":"已交卷", - updatetime: moment(exercise_users[i].end_at).format('YYYY-MM-DD HH:mm') === "Invalid date" ? "--" : moment(exercise_users[i].end_at).format('YYYY-MM-DD HH:mm'), - completion: exercise_users[i].objective_score === undefined ? "--" : exercise_users[i].objective_score === null ? "--" : exercise_users[i].objective_score === "" ? "--" : exercise_users[i].objective_score, - levelscore: exercise_users[i].subjective_score === undefined ? "--" : exercise_users[i].subjective_score === null ? "--" : exercise_users[i].subjective_score === "" ? "--" : exercise_users[i].subjective_score, - efficiencyscore: exercise_users[i].score === null ? "--" : exercise_users[i].score === "" ? "--" : exercise_users[i].score, - objective_score: exercise_users[i].objective_score === null ? "--" : exercise_users[i].objective_score === "" ? "--" : exercise_users[i].objective_score, - subjective_score: exercise_users[i].subjective_score === null ? "--" : exercise_users[i].subjective_score === "" ? "--" : exercise_users[i].subjective_score, - operating: exercise_users[i].has_comment === true ? "已评阅" : "--", - commit_method: exercise_users[i].commit_method, - has_comment: exercise_users[i].has_comment, - review_status: exercise_users[i].review_status, - - }) - - } - - } - teacherlist = { //分页 - total: exercise_users.length, //数据总数量 - pageSize: 20, //一页显示几条 - current: this.state.page, - } - } - if (current_answer_user !== undefined) { - datalisttwo.push({ - myid: current_answer_user.login, - student_id: current_answer_user.student_id, - user_group_id: current_answer_user.user_group_id, - number: 1, - name: current_answer_user.user_name, - classroom: current_answer_user.user_group_name, - stduynumber: current_answer_user.student_id === undefined ? "--" : current_answer_user.student_id === null ? "--" : current_answer_user.student_id === "" ? "--" : current_answer_user.student_id, - submitstate: exercise_users[i].commit_status === 1 ? "考试中" : exercise_users[i].commit_status === 0?"未开始":"已交卷", - updatetime: moment(current_answer_user.end_at).format('YYYY-MM-DD HH:mm') === "Invalid date" ? "--" : moment(current_answer_user.end_at).format('YYYY-MM-DD HH:mm'), - efficiencyscore: current_answer_user.score === undefined ? "--" : current_answer_user.score === null ? "--" : current_answer_user.score === "" ? "--" : current_answer_user.score, - objective_score: exercise_users[i].objective_score === null ? "--" : exercise_users[i].objective_score === "" ? "--" : exercise_users[i].objective_score, - subjective_score: exercise_users[i].subjective_score === null ? "--" : exercise_users[i].subjective_score === "" ? "--" : exercise_users[i].subjective_score, - review_status: current_answer_user.review_status, - completion: current_answer_user.objective_score === undefined ? "--" : current_answer_user.objective_score === null ? "--" : current_answer_user.objective_score === "" ? "--" : current_answer_user.objective_score, - levelscore: current_answer_user.subjective_score === undefined ? "--" : current_answer_user.subjective_score === null ? "--" : current_answer_user.subjective_score === "" ? "--" : current_answer_user.subjective_score, - score_open: exercise_types.score_open, - commit_method: current_answer_user.commit_method, - - }) - - - } - - - this.setState({ - data: datalisttwo, - datas: datalist, - teacherlist: teacherlist, - loadingstate: false, - }) - - } - - Generatenewdatas(exercise_users) { - let {page, limit} = this.state; - let datalist = []; - var teacherlist = undefined; - var noclassroom = undefined; - // //console.log("开始数据了"); - if (exercise_users !== undefined) { - // //console.log("开始打印数据了"); - for (var i = 0; i < exercise_users.length; i++) { - datalist.push({ - myid: exercise_users[i].login, - user_group_id: exercise_users[i].user_group_id, - number: (parseInt(page) - 1) * parseInt(limit) + (i + 1), - name: exercise_users[i].user_name, - stduynumber: exercise_users[i].student_id, - classroom: exercise_users[i].user_group_name, - submitstate: exercise_users[i].commit_status === 1 ? "考试中" : exercise_users[i].commit_status === 0?"未开始":"已交卷", - updatetime: moment(exercise_users[i].end_at).format('YYYY-MM-DD HH:mm') === "Invalid date" ? "--" : moment(exercise_users[i].end_at).format('YYYY-MM-DD HH:mm'), - completion: exercise_users[i].objective_score === undefined ? "--" : exercise_users[i].objective_score === null ? "--" : exercise_users[i].objective_score === "" ? "--" : exercise_users[i].objective_score, - levelscore: exercise_users[i].subjective_score === undefined ? "--" : exercise_users[i].subjective_score === null ? "--" : exercise_users[i].subjective_score === "" ? "--" : exercise_users[i].subjective_score, - efficiencyscore: exercise_users[i].score === null ? "--" : exercise_users[i].score === "" ? "--" : exercise_users[i].score, - objective_score: exercise_users[i].objective_score === null ? "--" : exercise_users[i].objective_score === "" ? "--" : exercise_users[i].objective_score, - subjective_score: exercise_users[i].subjective_score === null ? "--" : exercise_users[i].subjective_score === "" ? "--" : exercise_users[i].subjective_score, - operating: exercise_users[i].has_comment === true ? "已评阅" : "查看", - commit_method: exercise_users[i].commit_method, - has_comment: exercise_users[i].has_comment, - review_status: exercise_users[i].review_status, - - }) - noclassroom = exercise_users[i].user_group_name; - } - teacherlist = { //分页 - total: exercise_users.length, //数据总数量 - pageSize: 20, //一页显示几条 - current: this.state.page, - } - } - - this.setState({ - datas: datalist, - teacherlist: teacherlist, - noclassroom: noclassroom, - loadingstate: false, - }) - } - - TablePagination = (e) => { - // //console.log(e.current); - var teacherlist = { //分页 - total: this.state.exercise_users.length, //数据总数量 - pageSize: 20, //一页显示几条 - current: e.current, - } - this.setState({ - page: e.current, - teacherlist: teacherlist - }) - - } - TablePaginations = (e) => { - // //console.log(e.current); - var teacherlists = { //分页 - total: this.state.exercise_users, //数据总数量 - pageSize: 10, //一页显示几条 - current: e.current, - } - this.setState({ - page: e.current, - teacherlist: teacherlists - }) - - } - - - Searchdata = (order, commit_status, review, exercise_group_id, search, page, limit, order_type) => { - var exercise_id = this.props.match.params.Id; - // //console.log(731); // 764 935 - var url = `/exercises/${exercise_id}/exercise_lists.json`; - var params = { - order: order, - commit_status: null, - review: null, - exercise_group_id: null, - search: "", - page: page, - limit: limit, - order_type: order_type, - } - axios.get(url, { - params: params - }).then((response) => { - // //console.log(JSON.stringify(response)); - if (response === undefined) { - return - } - this.setState({ - Teacherliststudentlist: response.data, - review: response.data.review, - commit_status: response.data.commit_status, - exercise_users: response.data.exercise_users, - current_answer_user: response.data.current_answer_user, - mylistansum: response.data.exercise_types.answer_users + response.data.exercise_types.unanswer_users, - }) - try { - myssubjective = response.data.exercise_types.subjective?response.data.exercise_types.subjective:0;//记录是否有主观题 1是有 - mysubjective_score = response.data.exercise_types.subjective_score?response.data.exercise_types.subjective_score:0; - myobjective_score = response.data.exercise_types.objective_score?response.data.exercise_types.objective_score:0; - } catch (e) { - - } - if (response.data.exercise_types.subjective === 0) { - - var arr = []; - for (var i = 0; i < this.state.columnstwo.length; i++) { - var item = this.state.columnstwo[i]; - if (item.title === "客观题得分") { - } else if (item.title === "主观题得分") { - } else if (this.props.isNotMember() === true && item.title === "学号") { - - } else { - arr.push(item); - } - } - - var arr2 = []; - for (var i = 0; i < this.state.columns.length; i++) { - var item = this.state.columns[i]; - if (item.title === "客观题得分") { - } else if (item.title === "主观题得分") { - } else if (this.props.isNotMember() === true && item.title === "学号") { - - } else { - arr2.push(item); - } - } - this.setState({ - columns: arr2, - columnstwo: arr, - loadingstate: false, - }) - } - this.Generatenewdata(response.data.exercise_users, response.data.current_answer_user, response.data.exercise_types); - }).catch((error) => { - //console.log(error) - this.setState({ - loadingstate: false, - }) - }); - } - - //////老师页面调用的 - - Generatenewdatasy(exercise_users, response) { - let {page, limit} = this.state; - var thiss = this; - let datalist = []; - var indexi = 0; - var teacherlist = undefined; - // //console.log("开始数据了"); - if (exercise_users !== undefined) { - // //console.log("开始打印数据了"); - for (var i = 0; i < exercise_users.length; i++) { - if (exercise_users[i].commit_status === 1) { - datalist.push({ - myid: exercise_users[i].login, - user_group_id: exercise_users[i].user_group_id, - number: (parseInt(page) - 1) * parseInt(limit) + (i + 1), - name: exercise_users[i].user_name, - stduynumber: exercise_users[i].student_id === undefined ? "--" : exercise_users[i].student_id === null ? "--" : exercise_users[i].student_id === "" ? "--" : exercise_users[i].student_id, - classroom: exercise_users[i].user_group_name, - submitstate: exercise_users[i].commit_status === 1 ? "考试中" : exercise_users[i].commit_status === 0?"未开始":"已交卷", - updatetime: moment(exercise_users[i].end_at).format('YYYY-MM-DD HH:mm') === "Invalid date" ? "--" : moment(exercise_users[i].end_at).format('YYYY-MM-DD HH:mm'), - completion: exercise_users[i].objective_score === undefined ? "--" : exercise_users[i].objective_score === null ? "--" : exercise_users[i].objective_score === "" ? "--" : exercise_users[i].objective_score, - levelscore: exercise_users[i].subjective_score === undefined ? "--" : exercise_users[i].subjective_score === null ? "--" : exercise_users[i].subjective_score === "" ? "--" : exercise_users[i].subjective_score, - efficiencyscore: exercise_users[i].score === undefined ? "--" : exercise_users[i].score === null ? "--" : exercise_users[i].score === "" ? "--" : exercise_users[i].score, - objective_score: exercise_users[i].objective_score === null ? "--" : exercise_users[i].objective_score === "" ? "--" : exercise_users[i].objective_score, - subjective_score: exercise_users[i].subjective_score === null ? "--" : exercise_users[i].subjective_score === "" ? "--" : exercise_users[i].subjective_score, - finalscore: exercise_users[i].commit_status === 1 ? "--":exercise_users[i].has_comment === true ? "已评阅" : "评阅", - user_id: exercise_users[i].user_id, - commit_method: exercise_users[i].commit_method, - has_comment: exercise_users[i].has_comment, - review_status: exercise_users[i].review_status, - - }) - } else { - datalist.push({ - myid: exercise_users[i].login, - user_group_id: exercise_users[i].user_group_id, - number: (parseInt(page) - 1) * parseInt(limit) + (i + 1), - name: exercise_users[i].user_name, - stduynumber: exercise_users[i].student_id === undefined ? "--" : exercise_users[i].student_id === null ? "--" : exercise_users[i].student_id === "" ? "--" : exercise_users[i].student_id, - classroom: exercise_users[i].user_group_name, - submitstate: exercise_users[i].commit_status === 1 ? "考试中" : exercise_users[i].commit_status === 0?"未开始":"已交卷", - updatetime: moment(exercise_users[i].end_at).format('YYYY-MM-DD HH:mm') === "Invalid date" ? "--" : moment(exercise_users[i].end_at).format('YYYY-MM-DD HH:mm'), - completion: exercise_users[i].objective_score === undefined ? "--" : exercise_users[i].objective_score === null ? "--" : exercise_users[i].objective_score === "" ? "--" : exercise_users[i].objective_score, - levelscore: exercise_users[i].subjective_score === undefined ? "--" : exercise_users[i].subjective_score === null ? "--" : exercise_users[i].subjective_score === "" ? "--" : exercise_users[i].subjective_score, - efficiencyscore: exercise_users[i].score === undefined ? "--" : exercise_users[i].score === null ? "--" : exercise_users[i].score === "" ? "--" : exercise_users[i].score, - objective_score: exercise_users[i].objective_score === null ? "--" : exercise_users[i].objective_score === "" ? "--" : exercise_users[i].objective_score, - subjective_score: exercise_users[i].subjective_score === null ? "--" : exercise_users[i].subjective_score === "" ? "--" : exercise_users[i].subjective_score, - finalscore: exercise_users[i].commit_status === 1 ? "--" :exercise_users[i].has_comment === true ? "已评阅" : "评阅", - user_id: exercise_users[i].user_id, - commit_method: exercise_users[i].commit_method, - has_comment: exercise_users[i].has_comment, - review_status: exercise_users[i].review_status, - }) - indexi++; - } - - } - // teacherlist = { //分页 - // total: exercise_users.length, //数据总数量 - // pageSize: 20, //一页显示几条 - // current: this.state.page, - // } - } - - if (response.data.exercise_types.subjective === 0) { - //===0 不包括主观题 - if (indexi === exercise_users.length) { - //都没评论 不显示评论 - if (response.data.exercise_types.groups_count > 0) { - // //console.log("77771111111"); - //分班大于0显示分班 - //7ge - // this.state.columnsys.map((item,key)=>{ - // - // }) - var arr = []; - for (var i = 0; i < this.state.columnsys.length; i++) { - var item = this.state.columnsys[i]; - if (item.title === "客观题得分") { - } else if (item.title === "主观题得分") { - } else if (this.props.isNotMember() === true && item.title === "学号") { - - } else { - arr.push(item); - } - } - - this.setState({ - data: datalist, - teacherlist: teacherlist, - Teacherliststudentlist: response.data, - review: response.data.review, - commit_status: response.data.commit_status, - exercise_users: response.data.exercise_users, - course_groups: response.data.course_groups, - mylistansum: response.data.exercise_types.answer_users + response.data.exercise_types.unanswer_users, - loadingstate: false, - subjective: response.data.exercise_types.subjective, - objective_score: response.data.exercise_types.objective_score, - subjective_score: response.data.exercise_types.subjective_score, - columnsys: arr, - }) - } else { - //分班小于0不显示分班 - //6ge - - var arr = []; - for (var i = 0; i < this.state.columnsys.length; i++) { - var item = this.state.columnsys[i]; - if (item.title === "分班") { - } else if (item.title === "客观题得分") { - } else if (item.title === "主观题得分") { - } else if (this.props.isNotMember() === true && item.title === "学号") { - } else { - arr.push(item); - } - } - - thiss.setState({ - data: datalist, - teacherlist: teacherlist, - Teacherliststudentlist: response.data, - review: response.data.review, - loadingstate: false, - commit_status: response.data.commit_status, - exercise_users: response.data.exercise_users, - course_groups: response.data.course_groups, - mylistansum: response.data.exercise_types.answer_users + response.data.exercise_types.unanswer_users, - subjective: response.data.exercise_types.subjective, - objective_score: response.data.exercise_types.objective_score, - subjective_score: response.data.exercise_types.subjective_score, - columnsys: arr, - }) - } - - } else { - //已经评论 - // response.data.course_groups.length - if (response.data.exercise_types.groups_count > 0) { - //显示分班 - //8ge - - var arr = []; - for (var i = 0; i < this.state.columnsys.length; i++) { - var item = this.state.columnsys[i]; - if (item.title === "客观题得分") { - } else if (item.title === "主观题得分") { - } else if (this.props.isNotMember() === true && item.title === "学号") { - - } else { - arr.push(item); - } - } - // //console.log(thiss.state.columnsys); - // //console.log(arr); - - this.setState({ - data: datalist, - teacherlist: teacherlist, - Teacherliststudentlist: response.data, - review: response.data.review, - commit_status: response.data.commit_status, - exercise_users: response.data.exercise_users, - course_groups: response.data.course_groups, - mylistansum: response.data.exercise_types.answer_users + response.data.exercise_types.unanswer_users, - loadingstate: false, - subjective: response.data.exercise_types.subjective, - objective_score: response.data.exercise_types.objective_score, - subjective_score: response.data.exercise_types.subjective_score, - columnsys: arr, - }) - } else { - //不显示分班 - //7ge - var arr = []; - for (var i = 0; i < this.state.columnsys.length; i++) { - var item = this.state.columnsys[i]; - if (item.title === "分班") { - } else if (item.title === "客观题得分") { - } else if (item.title === "主观题得分") { - } else if (this.props.isNotMember() === true && item.title === "学号") { - - } else { - arr.push(item); - } - } - - - this.setState({ - data: datalist, - teacherlist: teacherlist, - Teacherliststudentlist: response.data, - review: response.data.review, - commit_status: response.data.commit_status, - exercise_users: response.data.exercise_users, - course_groups: response.data.course_groups, - mylistansum: response.data.exercise_types.answer_users + response.data.exercise_types.unanswer_users, - loadingstate: false, - subjective: response.data.exercise_types.subjective, - objective_score: response.data.exercise_types.objective_score, - subjective_score: response.data.exercise_types.subjective_score, - columnsys: arr, - }) - } - - } - - } else { - //包括主观题 - if (indexi === exercise_users.length) { - //console.log("2548包含主观题不包含分班"); - - if (response.data.exercise_types.groups_count > 0) { - var arr = []; - for (var i = 0; i < this.state.columnsys.length; i++) { - var item = this.state.columnsys[i]; - if (this.props.isNotMember() === true && item.title === "学号") { - - } else { - arr.push(item); - } - } - this.setState({ - data: datalist, - teacherlist: teacherlist, - Teacherliststudentlist: response.data, - review: response.data.review, - commit_status: response.data.commit_status, - exercise_users: response.data.exercise_users, - course_groups: response.data.course_groups, - mylistansum: response.data.exercise_types.answer_users + response.data.exercise_types.unanswer_users, - columnsys: arr, - subjective: response.data.exercise_types.subjective, - objective_score: response.data.exercise_types.objective_score, - subjective_score: response.data.exercise_types.subjective_score, - }) - } else { - var arr = []; - for (var i = 0; i < this.state.columnsys.length; i++) { - var item = this.state.columnsys[i]; - if (item.title === "分班") { - - } else if (this.props.isNotMember() === true && item.title === "学号") { - - } else { - arr.push(item); - } - } - this.setState({ - data: datalist, - teacherlist: teacherlist, - Teacherliststudentlist: response.data, - review: response.data.review, - commit_status: response.data.commit_status, - exercise_users: response.data.exercise_users, - course_groups: response.data.course_groups, - mylistansum: response.data.exercise_types.answer_users + response.data.exercise_types.unanswer_users, - columnsys: arr, - subjective: response.data.exercise_types.subjective, - objective_score: response.data.exercise_types.objective_score, - subjective_score: response.data.exercise_types.subjective_score, - }) - } - } else { - // //console.log("2699包含主观题包含分班"); - if (response.data.exercise_types.groups_count > 0) { - this.setState({ - data: datalist, - teacherlist: teacherlist, - Teacherliststudentlist: response.data, - review: response.data.review, - commit_status: response.data.commit_status, - exercise_users: response.data.exercise_users, - course_groups: response.data.course_groups, - mylistansum: response.data.exercise_types.answer_users + response.data.exercise_types.unanswer_users, - loadingstate: false, - columnsys: columnsystwo, - subjective: response.data.exercise_types.subjective, - objective_score: response.data.exercise_types.objective_score, - subjective_score: response.data.exercise_types.subjective_score, - }) - } else { - var arr = []; - for (var i = 0; i < this.state.columnsys.length; i++) { - var item = this.state.columnsys[i]; - if (item.title === "分班") { - - } else if (this.props.isNotMember() === true && item.title === "学号") { - - } else { - arr.push(item); - } - } - this.setState({ - data: datalist, - teacherlist: teacherlist, - Teacherliststudentlist: response.data, - review: response.data.review, - commit_status: response.data.commit_status, - exercise_users: response.data.exercise_users, - course_groups: response.data.course_groups, - mylistansum: response.data.exercise_types.answer_users + response.data.exercise_types.unanswer_users, - loadingstate: false, - columnsys: arr, - subjective: response.data.exercise_types.subjective, - objective_score: response.data.exercise_types.objective_score, - subjective_score: response.data.exercise_types.subjective_score - - }) - } - - } - } - this.setState({ - loadingstate: false - }) - } - - - TablePaginationsy = (e) => { - // //console.log(e.current); - var teacherlist = { //分页 - total: this.state.exercise_users.length, //数据总数量 - pageSize: 20, //一页显示几条 - current: e.current, - } - this.setState({ - page: e.current, - teacherlist: teacherlist - }) - - } - Searchdatasys = (order, commit_status, review, exercise_group_id, search, page, limit, order_type) => { - var exercise_id = this.props.match.params.Id; - var url = `/exercises/${exercise_id}/exercise_lists.json`; - axios.get((url), { - params: { - order: order, - commit_status: commit_status, - review: review, - exercise_group_id: exercise_group_id, - search: search, - page: page, - limit: limit, - order_type: order_type - } - }).then((response) => { - // //console.log("528"); - // //console.log(JSON.stringify(response)); - if (response === undefined) { - return - } - - - this.setState({ - loadingstate: false, - }) - try { - myssubjective = response.data.exercise_types.subjective?response.data.exercise_types.subjective:0;//记录是否有主观题 1是有 - mysubjective_score = response.data.exercise_types.subjective_score?response.data.exercise_types.subjective_score:0; - myobjective_score = response.data.exercise_types.objective_score?response.data.exercise_types.objective_score:0; - } catch (e) { - - } - // //console.log(response); - // //console.log(1997); - this.Generatenewdatasy(response.data.exercise_users, response); - }).catch((error) => { - // //console.log(error) - this.setState({ - loadingstate: false, - }) - }); - } - - notlimited = () => { - if (this.state.loadingstate === false) { - this.setState({ - unlimited: 0, - course_groupyslsthree: undefined, - loadingstate: true, - page: 1 - }) - } else { - this.setState({ - unlimited: 0, - course_groupyslsthree: undefined, - page: 1, - }) - } - this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, null, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit, this.state.order_type); - } - // notlimiteds = () => { - // this.setState({ - // unlimiteds: 0, - // commit_status: null, - // submitted: false, - // unsubmitted: false - // }) - // this.Searchdatasys(this.state.order, null, this.state.review, this.state.checkedValuesineinfo, this.state.searchtext, null, null); - // } - notlimiteds = () => { - if (this.state.loadingstate === false) { - this.setState({ - unlimiteds: 0, - course_groupyslstwo: undefined, - loadingstate: true, - page: 1, - }) - } else { - this.setState({ - unlimiteds: 0, - course_groupyslstwo: undefined, - page: 1, - }) - } - - this.Searchdatasys(this.state.order, undefined, this.state.course_groupyslsthree, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit, this.state.order_type); - } - checkeboxstwo = (checkedValues, data) => { - // //console.log(checkedValues) - if (JSON.stringify(checkedValues) === "[]") { - // //console.log(checkedValues); - if (this.state.loadingstate === false) { - this.setState({ - loadingstate: true, - course_groupyslstwo: undefined, - unlimiteds: 0, - page: 1 - }) - } else { - this.setState({ - course_groupyslstwo: undefined, - unlimiteds: 0, - page: 1, - }) - } - - this.Searchdatasys(this.state.order, checkedValues, this.state.course_groupyslsthree, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit, this.state.order_type); - } - // else if (checkedValues.length === data.length) { - // if (this.state.loadingstate === false) { - // this.setState({ - // loadingstate: true, - // course_groupyslstwo: undefined, - // unlimiteds: 0, - // page:1 - // }) - // } - // - // else { - // this.setState({ - // course_groupyslstwo: undefined, - // unlimiteds: 0, - // page:1, - // }) - // } - // - // this.Searchdatasys(this.state.order, checkedValues, this.state.review, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit, this.state.order_type); - // } - else { - // //console.log(checkedValues); - this.Searchdatasys(this.state.order, checkedValues, this.state.course_groupyslsthree, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit, this.state.order_type); - if (this.state.loadingstate === false) { - this.setState({ - loadingstate: true, - course_groupyslstwo: checkedValues, - unlimiteds: 1, - page: 1, - }) - } else { - this.setState({ - course_groupyslstwo: checkedValues, - unlimiteds: 1, - page: 1, - }) - } - - } - - } - - notlimitedst = () => { - // //console.log(); - // var datas=this.state.course_groups; - // for(var ik=0;ik { - // if(JSON.stringify(v)==="[]"){ - // this.setState({ - // review:undefined - // }) - // return - // } - - if (JSON.stringify(checkedValues) === "[]") { - // //console.log(checkedValues); - if (this.state.loadingstate === false) { - this.setState({ - unlimited: 0, - course_groupyslsthree: undefined, - loadingstate: true, - page: 1 - }) - } else { - this.setState({ - unlimited: 0, - course_groupyslsthree: undefined, - page: 1 - }) - } - - this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, checkedValues, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit, this.state.order_type); - } - // else if (checkedValues.length === data.length) { - // if (this.state.loadingstate === false) { - // this.setState({ - // unlimited: 0, - // course_groupyslsthree: undefined, - // loadingstate: true, - // page:1 - // }) - // } else { - // this.setState({ - // unlimited: 0, - // course_groupyslsthree: undefined, - // page:1 - // }) - // } - // - // this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, checkedValues, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit, this.state.order_type); - // } - else { - // //console.log(checkedValues); - if (this.state.loadingstate === false) { - this.setState({ - unlimited: 1, - loadingstate: true, - course_groupyslsthree: checkedValues, - page: 1 - }) - } else { - this.setState({ - unlimited: 1, - course_groupyslsthree: checkedValues, - page: 1 - }) - } - - this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, checkedValues, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit, this.state.order_type); - - } - } - funtaskstatustwos = () => { - - if (this.state.loadingstate === false) { - this.setState({ - unlimitedtwo: 0, - checkedValuesineinfo: undefined, - course_groupysls: undefined, - loadingstate: true, - page: 1, - }) - } else { - this.setState({ - unlimitedtwo: 0, - checkedValuesineinfo: undefined, - course_groupysls: undefined, - page: 1, - }) - } - - this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, this.state.review, undefined, this.state.searchtext, 1, this.state.limit, this.state.order_type) - } - - funtaskstatustwo = (checkedValues, data) => { - // //console.log(checkedValues); - if (JSON.stringify(checkedValues) === "[]") { - // //console.log(checkedValues); - if (this.state.loadingstate === false) { - this.setState({ - course_groupysls: undefined, - unlimitedtwo: 0, - loadingstate: true, - page: 1, - }) - } else { - this.setState({ - course_groupysls: undefined, - unlimitedtwo: 0, - page: 1, - }) - } - - this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, this.state.course_groupyslsthree, checkedValues, this.state.searchtext, 1, this.state.limit, this.state.order_type) - } - // else if (checkedValues.length === data.length) { - // if (this.state.loadingstate === false) { - // this.setState({ - // course_groupysls: undefined, - // unlimitedtwo: 0, - // loadingstate: true, - // page:1, - // }) - // } else { - // this.setState({ - // course_groupysls: undefined, - // unlimitedtwo: 0, - // page:1, - // }) - // } - // - // this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, this.state.review, checkedValues, this.state.searchtext, 1, this.state.limit, this.state.order_type) - // } - else { - // //console.log(checkedValues); - if (this.state.loadingstate === false) { - this.setState({ - checkedValuesineinfo: checkedValues, - course_groupysls: checkedValues, - unlimitedtwo: 1, - loadingstate: true, - page: 1 - }) - } else { - this.setState({ - checkedValuesineinfo: checkedValues, - course_groupysls: checkedValues, - unlimitedtwo: 1, - page: 1 - }) - - } - - this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, this.state.course_groupyslsthree, checkedValues, this.state.searchtext, 1, this.state.limit, this.state.order_type) - this.props.setcourse_groupysls(checkedValues) - } - - } - // 输入关键字后按回车,自动提交 - onSearchKeywordKeyUp = (e) => { - if (e.keyCode === 13) { - // this.onSearch(); - // //console.log("使用了回车键"); - // if(this.state.searchtext === ""){ - // message.error("请输入姓名或学号搜索"); - // return - // } - if (this.state.loadingstate === false) { - this.setState({ - loadingstate: true, - page: 1 - }) - } - - this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, this.state.course_groupyslsthree, this.state.checkedValuesineinfo, this.state.searchtext, 1, this.state.limit, this.state.order_type); - } - }; - //搜索学生按钮输入 老师 - searchValues = (value) => { - //点击直接搜索 - // if(value === ""){ - // message.error("请输入姓名或学号搜索"); - // return - // } - if (this.state.loadingstate === false) { - this.setState({ - loadingstate: true, - page: 1, - }) - } - - this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, this.state.course_groupyslsthree, this.state.checkedValuesineinfo, value, 1, this.state.limit, this.state.order_type); - // this.Startsorting(this.state.order,this.state.checkedValuesine,this.state.checkedValuesineinfo,value); - // //console.log(value) - - - }; - - _getRequestParams() { - const {order, checkedValuesineinfo, course_groupyslstwo, searchtext, page, limit, course_groupyslsthree} = this.state - return { - page, - review: course_groupyslsthree, - commit_status: course_groupyslstwo, - search: searchtext, - exercise_group_id: checkedValuesineinfo, - limit: limit, - order, - } - } - - //搜索学生 文字输入 - inputSearchValues = (e) => { - // //console.log(e.target.value) - if (e.target.value === "") { - this.setState({ - searchtext: undefined, - }) - } else { - this.setState({ - searchtext: e.target.value, - }) - } - - }; - - - //老师试卷table 列表塞选数据 - table1handleChange = (pagination, filters, sorter) => { - //"ascend" 升序 - //"descend" 降序 - if (JSON.stringify(sorter) === "{}") { - //没有选择 - } else { - try { - //时间排序 - if (sorter.columnKey === "updatetime") { - if (sorter.order === "ascend") { - //升序 - this.setState({ - order: "end_at", - loadingstate: true, - order_type: "asc" - }) - this.Searchdatasys("end_at", this.state.course_groupyslstwo, this.state.course_groupyslsthree, this.state.checkedValuesineinfo, this.state.searchtext, this.state.page, this.state.limit, "asc"); - } else if (sorter.order === "descend") { - //降序 - this.setState({ - order: "end_at", - loadingstate: true, - order_type: "desc" - }) - this.Searchdatasys("end_at", this.state.course_groupyslstwo, this.state.course_groupyslsthree, this.state.checkedValuesineinfo, this.state.searchtext, this.state.page, this.state.limit, "desc"); - } - } - } catch (e) { - - } - - try { - //学生学号排序 - if (sorter.columnKey === "stduynumber") { - if (sorter.order === "ascend") { - //升序 - this.setState({ - order: "student_id", - loadingstate: true, - order_type: "asc" - }) - this.Searchdatasys("student_id", this.state.course_groupyslstwo, this.state.course_groupyslsthree, this.state.checkedValuesineinfo, this.state.searchtext, this.state.page, this.state.limit, "asc"); - - } else if (sorter.order === "descend") { - //降序 - this.setState({ - order: "student_id", - loadingstate: true, - order_type: "desc" - }) - this.Searchdatasys("student_id", this.state.course_groupyslstwo, this.state.course_groupyslsthree, this.state.checkedValuesineinfo, this.state.searchtext, this.state.page, this.state.limit, "desc"); - - } - } - } catch (e) { - - } - - try { - //成绩排序排序 - if (sorter.columnKey === "efficiencyscore") { - if (sorter.order === "ascend") { - //升序 - this.setState({ - order: "score", - loadingstate: true, - order_type: "asc" - }) - this.Searchdatasys("score", this.state.course_groupyslstwo, this.state.course_groupyslsthree, this.state.checkedValuesineinfo, this.state.searchtext, this.state.page, this.state.limit, "asc"); - - } else if (sorter.order === "descend") { - //降序 - this.setState({ - order: "score", - loadingstate: true, - order_type: "desc" - }) - this.Searchdatasys("score", this.state.course_groupyslstwo, this.state.course_groupyslsthree, this.state.checkedValuesineinfo, this.state.searchtext, this.state.page, this.state.limit, "desc"); - - } - } - } catch (e) { - - } - - } - } - - //学生问卷table 列表塞选数据 - table1handleChangestuden = (pagination, filters, sorter) => { - if (JSON.stringify(sorter) === "{}") { - //没有选择 - } else { - try { - //时间排序 - if (sorter.columnKey === "updatetime") { - if (sorter.order === "ascend") { - //升序 - this.setState({ - order: "end_at", - loadingstate: true, - order_type: "asc" - }) - this.Searchdata("end_at", null, null, null, null, this.state.page, this.state.limit, "asc"); - } else if (sorter.order === "descend") { - //降序 - this.setState({ - order: "end_at", - loadingstate: true, - order_type: "desc" - }) - this.Searchdata("end_at", null, null, null, null, this.state.page, this.state.limit, "desc"); - } - } - } catch (e) { - - } - - try { - //学生学号排序 - if (sorter.columnKey === "stduynumber") { - if (sorter.order === "ascend") { - //升序 - this.setState({ - order: "student_id", - loadingstate: true, - order_type: "asc" - }) - this.Searchdata("student_id", null, null, null, null, this.state.page, this.state.limit, "asc"); - } else if (sorter.order === "descend") { - //降序 - this.setState({ - order: "student_id", - loadingstate: true, - order_type: "desc" - }) - this.Searchdata("student_id", null, null, null, null, this.state.page, this.state.limit, "desc"); - } - } - } catch (e) { - - } - - try { - //成绩排序排序 - if (sorter.columnKey === "efficiencyscore") { - if (sorter.order === "ascend") { - //升序 - this.setState({ - order: "score", - loadingstate: true, - order_type: "asc" - }) - this.Searchdata("score", null, null, null, null, this.state.page, this.state.limit, "asc"); - - } else if (sorter.order === "descend") { - //降序 - this.setState({ - order: "score", - loadingstate: true, - order_type: "desc" - }) - this.Searchdata("score", null, null, null, null, this.state.page, this.state.limit, "desc"); - } - } - } catch (e) { - - } - } - } - setExerciseReviewAndAnswer = () => { - - } - // 调分 - Adjustment = (e) => { - // console.log("Adjustment"); - // console.log(e); - if (this.state.objective_score === 0 && this.state.subjective_score === 0) { - this.props.showNotification('试卷题型分被限制为0分,不能调分,请点击编辑试卷修改题型分数'); - - return - } - - - this.setState({ - testpapergradingboll: true, - exeuserid: e, - }) - - } - //调分窗 - Adjustments = () => { - //弹出弹框 - this.setState({ - testpapergradingboll: false - }) - - } - - //试卷调分 - Testpapergrading = (v, n) => { - var exercise_id = this.props.match.params.Id; - let url = `/exercises/${exercise_id}/adjust_score.json`; - axios.post(url, { - user_id: this.state.exeuserid, - subjective_score: v, - objective_score: n, - }) - .then((response) => { - if (response.data.status == '0') { - this.setState({testpapergradingboll: false}); - this.props.showNotification('调分成功'); - this.Teacherliststudentlist(); - } - }) - .catch((error) => { - console.log(error); - this.setState({testpapergradingboll: false}) - }); - - - } - - - render() { - const isAdmin = this.props.isAdmin(); - - let {data, datas, page, columns, course_groupyslsthree, columnstwo, styletable, exercise_status, course_groupyslstwodatas, limit, course_groupysls, course_groupyslstwodata, course_groupyslstwo, teacherlists, Teacherliststudentlist, order, columnss, course_groupsdatas, course_groups, Evaluationarray, unlimited, unlimiteds, unlimitedtwo, teacherlist, searchtext, loadingstate, review, nocomment, commented, unsubmitted, submitted, columnsys, exercise_users, mylistansum, testpapergradingboll} = this.state; - // //console.log("Studentshavecompletedthelist"); - // //console.log(this.props.current_status); - // //console.log("获取到的数据"); - // //console.log(datas); - // //console.log(data); - // //console.log("this.props.Commonheadofthetestpaper.exercise_status"); - // //console.log(this.props.Commonheadofthetestpaper&&this.props.Commonheadofthetestpaper.exercise_status); - // //console.log(exercise_status); - // console.log("Studentshavecompletedthelis123123t"); - // console.log(columnss); - return ( - isAdmin === true ? - ( -
    - {/*老师*/} - { - this.props.Commonheadofthetestpaper && this.props.Commonheadofthetestpaper.exercise_status === 0 || this.props.Commonheadofthetestpaper && this.props.Commonheadofthetestpaper.exercise_status === 1 ? -
    - -
    - : -
    - {/*{testpapergradingboll === true ? this.Adjustments()}*/} - {/* Saves={(value, num) => this.Testpapergrading(value, num)}*/} - {/*/> : ""}*/} - { - testpapergradingboll === true ? this.Adjustments()} - Saves={(value, num) => this.Testpapergrading(value, num)} - /> : "" - } -
    -
      - - {/*你的评阅:*/} - { - Teacherliststudentlist === undefined || parseInt(Teacherliststudentlist.exercise_types.subjective_score) <= 0 ? -
    • - 作品状态: - this.notlimiteds()}>全部 - this.checkeboxstwo(e, course_groupyslstwodata && course_groupyslstwodata)}> - { - course_groupyslstwodata.map((item, key) => { - return ( - {item.tu}({Teacherliststudentlist === undefined ? "0" : key === 0 ? Teacherliststudentlist.exercise_types.unanswer_users : key===1? Teacherliststudentlist.exercise_types.answering_users: Teacherliststudentlist.exercise_types.answer_users}) - ) - }) - } - -
      - this.onSearchKeywordKeyUp(e)} - onInput={this.inputSearchValues} - onSearch={this.searchValues} - > -
      -
    • - : -
      -
    • - 你的评阅: - this.notlimited()}>全部 - - this.checkeboxs(e, course_groupyslstwodata && course_groupyslstwodata)}> - { - course_groupyslstwodatas.map((item, key) => { - return ( - {item.tu}({Teacherliststudentlist === undefined ? "0" : key === 0 ? Teacherliststudentlist.exercise_types.unreview_counts : Teacherliststudentlist.exercise_types.review_counts}) - ) - }) - } - -
      - this.onSearchKeywordKeyUp(e)} - onInput={this.inputSearchValues} - onSearch={this.searchValues} - > -
      -
    • - {/*作品状态*/} -
    • - 作品状态: - this.notlimiteds()}>全部 - this.checkeboxstwo(e, course_groupyslstwodata && course_groupyslstwodata)}> - { - course_groupyslstwodata.map((item, key) => { - return ( - {item.tu}({Teacherliststudentlist === undefined ? "0" : key === 0 ? Teacherliststudentlist.exercise_types.unanswer_users : key===1? Teacherliststudentlist.exercise_types.answering_users: Teacherliststudentlist.exercise_types.answer_users}) - - ) - }) - } - -
    • -
      - - } - {/*分班情况*/} - {course_groups === undefined ? "" : course_groups === null ? "" : course_groups.length < 2 ? "" : JSON.stringify(course_groups) === "[]" ? "" : -
    • -
    - - - - - - - } - - - - -
    -
    - {Teacherliststudentlist === undefined ? "0" : Teacherliststudentlist.exercise_types.total_users}个检索结果({Teacherliststudentlist === undefined ? "0" : Teacherliststudentlist.exercise_types.exercise_all_users}学生) - - -
    -
    - - {JSON.stringify(data) !== "[]" ? -
    - -
    - {data === undefined ? "" :
    分班情况: this.funtaskstatustwos()}>全部 - - this.funtaskstatustwo(e, course_groups && course_groups)} - style={{paddingTop: '4px', display: "inline"}}> - { - course_groups.map((item, key) => { - return ( - {item.exercise_group_name}({item.exercise_group_students}) - ) - }) - } - - - -
    } - - - - : -
    -
    -
    - -

    暂时还没有相关数据哦!

    -
    -
    - -
    - } - - - - { - Teacherliststudentlist && Teacherliststudentlist.exercise_types.total_users && Teacherliststudentlist.exercise_types.total_users > limit ? -
    - -
    - : "" - } - - } - - - - ) - : - ( - // 学生只能看自己的 - Teacherliststudentlist === undefined || Teacherliststudentlist.current_answer_user === undefined || Teacherliststudentlist.current_answer_user === null ? -
    -
    - { - this.props.Commonheadofthetestpaper && this.props.Commonheadofthetestpaper.exercise_status === 0 || this.props.Commonheadofthetestpaper && this.props.Commonheadofthetestpaper.exercise_status === 1 ? -
    - -
    - : -
    - -
    - -
    - - {Teacherliststudentlist === undefined ? "0" : Teacherliststudentlist.exercise_types.answer_users}已交 - {Teacherliststudentlist === undefined ? "0" : Teacherliststudentlist.exercise_types.unanswer_users}未交 - {Teacherliststudentlist && Teacherliststudentlist.exercise_types.exercise_end_time === "--" ? "" : - 剩余提交时间:} - {Teacherliststudentlist && Teacherliststudentlist.exercise_types.exercise_end_time === "--" ? "" : - - {Teacherliststudentlist === undefined ? "0" : Teacherliststudentlist.exercise_types.exercise_end_time} - } - - -
    - -
    - - - {JSON.stringify(datas) === "[]" ? -
    -
    -
    - -

    暂时还没有相关数据哦!

    -
    -
    - -
    - : -
    - -
    - {datas === undefined ? "" :
    } - - - } - - - - } - - - - : - // 学生能看别人的 -
    -
    - { - this.props.Commonheadofthetestpaper && this.props.Commonheadofthetestpaper.exercise_status === 0 || this.props.Commonheadofthetestpaper && this.props.Commonheadofthetestpaper.exercise_status === 1 ? -
    - -
    - : -
    -
    - -
    - {data === undefined ? "" :
    } - - {JSON.stringify(datas) === "[]" ? - -
    -
    -
    - -

    暂时还没有相关数据哦!

    -
    -
    - -
    - : -
    - < div id="graduation_work_list" style={{ - padding: '0px 30px 10px 30px', - "margin-top": "20px", - "margin-bottom": "10px" - }}> - -
    - {Teacherliststudentlist === undefined ? "0" : Teacherliststudentlist.exercise_types.answer_users}已交 {Teacherliststudentlist === undefined ? "0" : Teacherliststudentlist.exercise_types.unanswer_users}未交 - {Teacherliststudentlist && Teacherliststudentlist.exercise_types.exercise_end_time === "--" ? "" : - 剩余提交时间:} - {Teacherliststudentlist && Teacherliststudentlist.exercise_types.exercise_end_time === "--" ? "" : - {Teacherliststudentlist === undefined ? "0" : Teacherliststudentlist.exercise_types.exercise_end_time}} - - - -
    - -
    -
    - -
    - {datas === undefined ? "" :
    } - - - - - - } - - - { - mylistansum && mylistansum > limit ? -
    - -
    - : "" - } - - } - - - - - ) - - ) - - - } - -} - -// subjective 主要是用于判断答题列表页是否存在 主观题 一栏的 -// 客观题没有判断。当主观题存在时,就会有客观题出现,否则只有总成绩 -// 当subjective 等于1时,就出现3列,客观题,主观题,最终成绩。当subjective等于0时,你就只出现最终成绩一列就行了 -export default Studentshavecompletedthelist; diff --git a/src/modules/courses/exercise/Testpapersettinghomepage.js b/src/modules/courses/exercise/Testpapersettinghomepage.js deleted file mode 100644 index 936d9e42..00000000 --- a/src/modules/courses/exercise/Testpapersettinghomepage.js +++ /dev/null @@ -1,532 +0,0 @@ -import React,{ Component } from "react"; -import {Checkbox,Input,Table, Pagination,Menu,Spin} from "antd"; -import {Link,NavLink} from 'react-router-dom'; -import { WordsBtn ,getRandomNumber,queryString,getRandomcode} from 'educoder'; -import CoursesListType from '../coursesPublic/CoursesListType'; -import '../css/members.css'; -import '../css/busyWork.css'; -import axios from 'axios'; -import Modals from '../../modals/Modals'; -import DownloadMessageysl from "../../modals/DownloadMessageysl"; -import Studentshavecompletedthelist from './Studentshavecompletedthelist'; -import WrappedExercisesetting from './Exercisesetting'; -import ExerciseDisplay from './ExerciseDisplay' -import Exercisestatisticalresult from './Exercisestatisticalresult'; -import ImmediatelyPublish from "../poll/pollPublicBtn/ImmediatelyPublish"; -import ImmediatelyEnd from "../poll/pollPublicBtn/ImmediatelyEnd"; -import Ecerciseallbackagain from './Ecerciseallbackagain'; - - -const polls_status={1:"未发布",2:"考试中",3:"已截止",4:"已结束"} -const start_Value={0:"继续答题",1:"查看答题",2:"开始答题"} -const qs = require('qs'); -//试卷主要设置页面 -class Testpapersettinghomepage extends Component{ - constructor(props) { - super(props); - this.state={ - tab:["0"], - searchtext:"", - Commonheadofthetestpaper:undefined, - visible:false, - groupyslsval:"", - current_status:undefined, - DownloadType:false, - DownloadMessageval:undefined, - donwloading:false, - exercise_status:3, - assistant_auth:false, //设置助教 - } - } - //切换tab - changeTab=(e)=>{ - this.setState({ - tab:e.key - }) - - // this.props.history.push(`/classrooms/${this.props.match.params.coursesId}/exercises/${this.props.match.params.Id}/student_exercise_list?tab=`+e.key) - - } - componentDidMount(){ - const query =this.props.location.search; - const type = query.split('?tab='); - let sum = [] - sum.push(type[1]) - // console.log("componentDidMountcomponentDidMount"); - // console.log(sum); - this.setState({ - tab:sum, - }) - this.Commonheadofthetestpaper(); - - } - //试卷公用头部 - Commonheadofthetestpaper=()=>{ - // console.log("Commonheadofthetestpaper 试卷公用头部"); - var exercise_id = this.props.match.params.Id; - var url = `/exercises/${exercise_id}/common_header.json`; - axios.get(url).then((response) => { - // console.log(JSON.stringify(response)); - try { - if(response.status === 200){ - this.setState({ - Commonheadofthetestpaper:response.data, - current_status:response.data.user_permission.current_status, - exercise_status:response.data.exercise_status, - assistant_auth:response.data.assistant_auth, - }) - // console.log(JSON.stringify(response.data.show_statistic)); - - } - }catch (e) { - - } - }).catch((error) => { - console.log(error) - }); - - } - - assistantauthoritys=(bool)=>{ - this.setState({ - assistant_auth:bool, - }) - } - - Ecerciseacallagain=()=>{ - this.setState({ - visible:true - }) - } - callback=(val)=>{ - this.setState({ - visible:false - }) - if(val===1){ - window.location.reload() - } - } - - moveTos=(val)=>{ - if(val===0){ - - } - } - - setcourse_groupysls=(val)=>{ - let list=""; - val.map((item,key)=>{ - if(item!=undefined){ - list=list+"&exercise_group_id[]="+item - } - }) - this.setState({ - groupyslsval:list - }) - } - // experiment=(url)=>{ - // - // axios.get(url).then((response) => { - // console.log(response); - // if(response.data.status&&response.data.status===-1){ - // - // }else if(response.data.status&&response.data.status===-2){ - // if(response.data.messages === "100"){ - // // 已超出文件导出的上限数量(100 ),建议: - // this.setState({ - // DownloadType:true, - // DownloadMessageval:100 - // }) - // }else { - // //因附件资料超过500M - // this.setState({ - // DownloadType:true, - // DownloadMessageval:500 - // }) - // } - // }else { - // window.open("/api"+url, '_blank'); - // } - // }).catch((error) => { - // console.log(error) - // }); - // - // } - - setgameexercise=(url)=>{ - - let{Commonheadofthetestpaper}=this.state; - if(Commonheadofthetestpaper.time>0){ - this.setState({ - Modalstype:true, - ModalSave:()=>this.props.history.push(url), - Modalstopval:`答题时长限制${Commonheadofthetestpaper.time}分钟,从首次答题开始实行不间断计时`, - modalsBottomval:'请确认是否有充足的答题时间?', - }); - }else{ - this.setState({ - Modalstype:true, - ModalSave:()=>this.props.history.push(url), - Modalstopval:"是否确认开始答题?", - modalsBottomval:' ', - }) - } - - } - //打开pdf - confpdf = (url) =>{ - window.open(url); - } - /// 确认是否下载 - confirmysl(url,child){ - let params ={} - if(child!=undefined){ - params =child._getRequestParams()!==undefined?child._getRequestParams():{}; - } - - const urll=url+`?${queryString.stringify(params)}`; - - axios.get(urll+ '&export=true').then((response) => { - if(response===undefined){ - return - } - if(response.data.status&&response.data.status===-1){ - - }else if(response.data.status&&response.data.status===-2){ - if(response.data.message === "100"){ - // 已超出文件导出的上限数量(100 ),建议: - - this.setState({ - DownloadType:true, - DownloadMessageval:100 - }) - }else { - //因附件资料超过500M - this.setState({ - DownloadType:true, - DownloadMessageval:500 - }) - } - }else { - this.props.slowDownload(getRandomcode(urll)) - // this.setState({ donwloading: true }) - // downloadFile({ - // url: urll, - // successCallback: (url) => { - // this.setState({ donwloading: false }) - // console.log('successCallback') - // }, - // failCallback: (responseHtml, url) => { - // this.setState({ donwloading: false }) - // console.log('failCallback') - // } - // }) - // this.props.showNotification(`正在下载中`); - - // window.open("/api"+url+`?${queryString.stringify(params)}`+ '&export=true', '_blank'); - } - }).catch((error) => { - console.log(error) - }); - } - - Downloadcal=()=>{ - this.setState({ - DownloadType:false, - DownloadMessageval:undefined - }) - } - cancelmodel=()=>{ - this.setState({ - Modalstype:false, - ModalSave:' ', - Modalstopval:' ', - modalsBottomval:' ', - Loadtype:false - }) - } - // DownloadType=()=>{ - // this.setState({ - // DownloadType:false, - // DownloadMessageval:undefined - // }) - // } - // Downloadcal=()=>{ - // this.setState({ - // DownloadType:false, - // DownloadMessageval:undefined - // }) - // } - getsetdata =()=>{ - // console.log("Testpapersettinghomepage"); - // console.log("getsetdatassssss"); - let{tab}=this.state; - try { - if(tab[0]==="0"){ - this.child.Teacherliststudentlist(); - } - if(tab[0]==="1"){ - this.child.Teacherliststudentlist(); - } - if(tab[0]==="2"){ - this.child.Teacherliststudentlist(); - } - if(tab[0]==="3"){ - this.child.getSettingInfo(); - } - }catch (e) { - - } - - } - bindRef = ref => { this.child = ref }; - goback=()=>{ - // let {datalist}=this.state; - // let courseId=this.props.match.params.coursesId; - // let category_id=this.props.match.params.category_id; - // - // window.location.href="/classrooms/"+courseId+"/graduation_tasks/"+datalist.graduation_id; - // let courseId=this.props.match.params.coursesId; - // if(courseId===undefined){ - // this.props.history.push("/classrooms"); - // }else{ - // this.props.history.push(this.props.current_user.first_category_url); - // } - this.props.history.goBack() - } - render(){ - let {tab,visible,Commonheadofthetestpaper,exercise_status,assistant_auth}=this.state; - const isAdmin =this.props.isAdmin(); - const isAssistant=this.props.isAssistant(); - - const isStudent = this.props.isStudent(); - // TODO - - //console.log(Commonheadofthetestpaper.exercise_status); - document.title=this.props.coursedata&&this.props.coursedata.name; - return( -
    - {/**/} -
    - {/* 公用的提示弹框 */} - {this.state.Modalstype===true?:""} - {visible===true?:""} - -
    -

    - {this.props.coursedata.name} - > - 试卷 - > - 试卷详情 -

    -
    - - -
    -

    - {Commonheadofthetestpaper === undefined?"":Commonheadofthetestpaper.exercise_name} -

    - - 返回 -

    - -
    -
    -
    -
    -
    - {isAssistant===true? - ( - assistant_auth===true? - - 答题列表 - 统计结果 - 试卷预览 - 设置 - - : - - 答题列表 - {Commonheadofthetestpaper&&Commonheadofthetestpaper.show_statistic===true? - Commonheadofthetestpaper && Commonheadofthetestpaper.exercise_status===3? - 统计结果:"":""} - 设置 - - ) - : - this.props.isAdmin()===true? - - 答题列表 - 统计结果 - 试卷预览 - 设置 - - : - - 答题列表 - {Commonheadofthetestpaper&&Commonheadofthetestpaper.show_statistic===true? - Commonheadofthetestpaper && Commonheadofthetestpaper.exercise_status===3? - 统计结果:"":""} - 设置 - - } -
    - {/*导出这块应该是下拉 因为需要前端导出,目前就只导出学生成绩*/} - {/*{isAdmin === true? 导出成绩:""}*/} - - - - { - isAdmin === true &&Commonheadofthetestpaper && Commonheadofthetestpaper.user_permission.user_commit_counts>0&&Commonheadofthetestpaper.exercise_status===2? - 打回重做:"" - } - - {isAdmin === true? Commonheadofthetestpaper!==undefined&&Commonheadofthetestpaper.user_permission.exercise_publish_count>0? :"":""} - {isAdmin === true?Commonheadofthetestpaper!==undefined&&Commonheadofthetestpaper.user_permission.exercise_unpublish_count>0? - :"":""} - {/*const isAdminOrTeacher*/} - {/*assistant_auth===true*/} - {/**/} - {isAdmin === true? - ( - isAssistant===true? - ( - assistant_auth===true? - 编辑试卷 - : - "" - ) - - : - 编辑试卷 - ) - :""} - - {isAdmin === false && this.props.current_user !== undefined? - Commonheadofthetestpaper&&Commonheadofthetestpaper.user_permission.current_status===2? - this.setgameexercise(`/classrooms/${this.props.match.params.coursesId}/exercises/${this.props.match.params.Id}/users/${this.props.current_user.login}`)}>开始答题: - - {exercise_status===2?start_Value[Commonheadofthetestpaper&&Commonheadofthetestpaper.user_permission.current_status]:exercise_status===3?"":exercise_status===4?"":start_Value[Commonheadofthetestpaper&&Commonheadofthetestpaper.user_permission.current_status]} - - :""} - -
    -
    - - -
    - - { - // 教师列表 - parseInt(tab[0])==0 ? this.setcourse_groupysls(value)} current_status = {this.state.current_status} Commonheadofthetestpaper={this.state.Commonheadofthetestpaper} yslstustate={[`${polls_status[Commonheadofthetestpaper && Commonheadofthetestpaper.exercise_status]}`]}>:"" - } - - {/*统计结果*/} - { - - parseInt(tab[0])==1 ? :"" - } - - { - - parseInt(tab[0])==2 ? :"" - } - { - - parseInt(tab[0])==3 ? this.assistantauthoritys(bool)}>:"" - } -
    -
    - ) - } -} - -export default Testpapersettinghomepage; diff --git a/src/modules/courses/exercise/exercise-new-form/index.jsx b/src/modules/courses/exercise/exercise-new-form/index.jsx deleted file mode 100644 index 7c32a082..00000000 --- a/src/modules/courses/exercise/exercise-new-form/index.jsx +++ /dev/null @@ -1,64 +0,0 @@ -import React, { useState } from 'react' -import { Input, Form, Button } from 'antd' -import './index.scss' -const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 24 }, - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 24 }, - }, -} -const { TextArea } = Input -const TITLE_MAX_LENGTH = 60 - -export default ({ exercise_name = '', exercise_description, is_md, onSaveHandler, isEdit, onCancel }) => { - - const [data, setData] = useState({ - exercise_name, - exercise_description, - is_md - }) - - function onChange(prop, value) { - setData({ ...data, [prop]: value }) - } - - function onNameChange(e) { - onChange('exercise_name', e.target.value) - } - - function onDescChange(e) { - onChange('exercise_description', e.target.value) - } - - function onSave() { - onSaveHandler(data) - } - - return ( - -
    - - - - - -
    - } - - ) - }) - } - - { - pollDetail && pollDetail.questions && pollDetail.questions.length == 0 && - } - - : "" - } - - ) - } -} -export default PollDetailTabThirdInfo \ No newline at end of file diff --git a/src/modules/courses/poll/PollInfo.js b/src/modules/courses/poll/PollInfo.js deleted file mode 100644 index 01fb449b..00000000 --- a/src/modules/courses/poll/PollInfo.js +++ /dev/null @@ -1,519 +0,0 @@ -import React,{ Component } from "react"; -import {Checkbox,Radio, Input} from "antd"; - -import '../css/members.css' -import '../css/busyWork.css' -import './pollStyle.css' - -import moment from 'moment' -import { WordsBtn } from 'educoder' -import Modals from '../../modals/Modals' -import CoursesListType from '../coursesPublic/CoursesListType'; - -import axios from 'axios'; - -const map={1:"单选题",2:"多选题",3:"主观题"} -const statudmap={1:"未发布",2:"提交中",3:"已截止"} -class PollInfo extends Component{ - constructor(props){ - super(props); - this.state={ - courseName:undefined, - poll:undefined, - question_answered:undefined, - question_types:undefined, - questions:undefined, - inputArray:[], - modalsType:false, - modalsTopval:undefined, - modalsBottomval:undefined, - loadtype:true, - modalSave:undefined, - questionPanelFixed:false, - pollAnswerList:[] - } - } - componentDidUpdate (prevProps) { - // 需要等get_user_info执行完才能getInfo - if (!prevProps.current_user && this.props.current_user) { - this.getInfo() - } - } - - - componentDidMount(){ - if(this.props.current_user){ - this.getInfo(); - } - - //window.addEventListener('scroll', this.handleScroll); - } - - // 滚动定位 - handleScroll=()=>{ - if(parseInt(window.scrollY)>230){ - this.setState({ - questionPanelFixed:true - }) - }else{ - this.setState({ - questionPanelFixed:false - }) - } - } - - scrollToAnchor=(index)=>{ - let name="Anchor_"+index; - if (index) { - let anchorElement = document.getElementById(name); - if(anchorElement) { anchorElement.scrollIntoView(); } - } - } - - getInfo=()=>{ - this.setState({ - courseName:this.props.current_user.course_name - }) - let pollId=this.props.match.params.pollId; - let user_id=this.props.match.params.login; - let url=`/polls/${pollId}/start_answer.json?login=${user_id}` - axios.get(url).then((result)=>{ - if(result.status==200){ - this.setState({ - poll:result.data.poll, - question_answered:result.data.question_answered, - question_types:result.data.question_types, - questions:result.data.questions - }) - - let list=[]; - for(var i=0;i{ - console.log(error); - }) - } - - //选中选择题(单选题)选项保存 - ChangeOptionSingle=(item)=>{ - let arr=item.target.name - let txt=Object.assign({}, this.state.inputArray[parseInt(arr[1])]); - let ids=item.target.value; - let list=txt.answersList.filter(element => element.answer_id == ids); - - this.postAnswer(arr[0],ids,list[0].answer_text=="其他"?txt.text:"",arr[1]); - } - - //选中选择题(多选题)选项保存 - ChangeOptionMuntil=(a_id,q_id,key)=>{ - let ind=Object.assign({}, this.state.inputArray[parseInt(key)]); - let count=0; - a_id.forEach(element => { - let list=ind.answersList.filter(item=>item.answer_id==element); - if(list[0].answer_text=="其他"){ - count++; - } - }); - - this.postAnswer(q_id,a_id,count > 0 ? ind.text : "",key); - } - - postAnswer=(q_id,a_id,text,key)=>{ - let url=`/poll_questions/${q_id}/poll_votes.json`; - console.log(text); - axios.post(url,{ - poll_answer_id:a_id, - vote_text:text - }).then((result)=>{ - if(result){ - const answer=Object.assign({}, this.state.question_answered[parseInt(key)]); - answer.ques_status=result.data.poll_vote.question_status; - const question_answered=this.state.question_answered; - question_answered[parseInt(key)]=answer - - const inputs=Object.assign({}, this.state.inputArray[parseInt(key)]); - inputs.answers=a_id; - const inputArray=this.state.inputArray; - inputArray[parseInt(key)]=inputs; - - this.setState({ - question_answered, - inputArray - }) - } - }).catch((error)=>{ - console.log(error); - }) - } - - //输入其它--内容 - blurTxt=(e)=>{ - let index=parseInt(e.target.name) - - const list = Object.assign({}, this.state.inputArray[index]) - list.text=e.target.value; - const inputArray=this.state.inputArray; - inputArray[index]=list - - this.setState({ - inputArray - }) - } - - - //输入其它--内容后重新保存 - saveInputAndAnswer=(e,a_id,q_id,key,type)=>{ - const inputs=Object.assign({}, this.state.inputArray[parseInt(key)]); - let answers=inputs.answers; - let flag=true; - if(answers.length){ - flag=answers.indexOf(a_id) > -1?true:false; - answers= type == 1 ? answers[0] : answers; - }else{ - flag = answers==a_id?true:false; - } - if(answers && (answers.length>0 || answers !="")){ - this.postAnswer(q_id,answers,flag ? inputs.text : "",key); - } - } - - //提交主观题 - commitText=(key,q_id)=>{ - const text = Object.assign({}, this.state.inputArray[key]).text; - - let url='/poll_questions/'+q_id+'/poll_votes.json?'; - - const ans=Object.assign({}, this.state.question_answered[key]); - ans.ques_status=text ? 1 : 0 ; - const questionAnswered=this.state.question_answered; - questionAnswered[key]=ans - this.setState({ - question_answered:questionAnswered - }) - - if(text!=undefined){ - axios.post((url),{ - vote_text:text - }).then((result)=>{ - if(result.status==200){ - const answer=Object.assign({}, this.state.question_answered[key]); - answer.ques_status=result.data.poll_vote.question_status; - const question_answered=this.state.question_answered; - question_answered[key]=answer - this.setState({ - question_answered - }) - } - }).catch((error)=>{ - console.log(error); - }) - } - - } - - // 提交 - submitPoll=()=>{ - let {inputArray,question_answered}=this.state; - let must=0; - let may=0; - for(var j=0;j0){ - this.setState({ - modalsType:true, - modalsTopval:"有 "+must+" 题必答题未答,无法提交 ", - modalsBottomval:"请完成全部必答题后再提交", - loadtype:true, - modalSave:this.cancelSubmit - }) - return; - } - if(may >= 0){ - this.setState({ - modalsType:true, - modalsTopval: may>0 ? "有 "+may+" 题未答":"", - modalsBottomval:"提交后无法再修改答题,是否确认提交?", - loadtype:false, - modalSave:this.sureSubmit - }) - } - } - - - cancelSubmit=()=>{ - this.setState({ - modalsType:false, - modalsTopval:"", - modalsBottomval:"" - }) - } - - - sureSubmit=()=>{ - let pollId=this.props.match.params.pollId; - let url=`/polls/${pollId}/commit_poll.json` - axios.post(url).then((result)=>{ - if(result.status == 200){ - this.props.showNotification(result.data.message) - this.setState({ - modalsType:false, - modalsTopval:"", - modalsBottomval:"" - }) - window.location.href=`/classrooms/${this.props.match.params.coursesId}/polls/${pollId}/detail` - } - }).catch((error)=>{ - console.log(error); - }) - } - - render(){ - let coursesId=this.props.match.params.coursesId; - let{poll,question_answered,question_types,questions,courseName, - inputArray, - modalsType, - modalsTopval, - loadtype, - modalsBottomval, - modalSave, - questionPanelFixed - }=this.state; - const { current_user } = this.props - let isAdmin=this.props.isAdmin(); - let isStudent=this.props.isStudent(); - document.title=courseName&&courseName; - return( -
    - {/*

    */} - -
    -

    - {courseName} - > - 问卷 - > - 问卷详情> - {question_types&&question_types.user_name} -

    -

    - {poll && poll.polls_name} - - { - isAdmin || (poll && poll.user_poll_status == 1) ? 返回 :'' - } - -

    - { - poll && poll.polls_description && -

    {poll.polls_description}

    - } -
    -

    - { - question_types && question_types.q_counts > 0 && - 合计{question_types.q_counts}题: - } - { - question_types && question_types.q_singles > 0 && - 单选题{question_types.q_singles}题 - } - { - question_types && question_types.q_doubles > 0 && - 多选题{ question_types && question_types.q_doubles }题 - } - { - question_types && question_types.q_mains > 0 && - 主观题{question_types &&question_types.q_mains}题 - } -

    - -
    -

    - 已答 - 未答 - 截止时间 {poll && moment(poll.end_time).format("YYYY-MM-DD HH:mm")} -

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

    {item.question.question_title}

    - { - //单选 - item.question.question_type==1 && - - { - item.question.answers && item.question.answers.map((i,k)=>{ - return( -
  • - - {i.answer_text} - { - i.answer_text=="其他" ? - - { - inputArray && inputArray.map((j,k)=>{ - return( - - { - j.id == item.question.id ? - this.saveInputAndAnswer(e,i.answer_id,item.question.id,key,item.question.question_type)} - /> - : "" - } - - ) - }) - } - - : "" - } -
  • - ) - }) - } -
    - } - { - //多选 - item.question.question_type==2 && - this.ChangeOptionMuntil(value,item.question.id,key)} - disabled={isAdmin || (isStudent && poll && poll.user_poll_status == 1)?true:false} - defaultValue={item.question.poll_answer_ids} - className="answerList" - name={key}> - { - item.question.answers && item.question.answers.map((i,k)=>{ - return( -
  • - - {i.answer_text} - { - i.answer_text=="其他"? - - { - inputArray && inputArray.map((j,k)=>{ - return( - - { - j.id == item.question.id ? - this.saveInputAndAnswer(e,i.answer_id,item.question.id,key,item.question.question_type)} - /> - : "" - } - - ) - }) - } - - :"" - } -
  • - ) - }) - } -
    - } - { - //主观题 - item.question.question_type==3 && -
    - { - inputArray && inputArray.map((j,k)=>{ - return( - - { - j.id == item.question.id ? - - : "" - } - - ) - }) - } -
    - } - -
    - ) - }) - } -
    -
    - { - isStudent && poll && poll.user_poll_status == 0 ? -
    - 提交 -
    - :"" - } -
    -
    - ) - } -} -export default PollInfo; diff --git a/src/modules/courses/poll/PollListItem.js b/src/modules/courses/poll/PollListItem.js deleted file mode 100644 index a0977452..00000000 --- a/src/modules/courses/poll/PollListItem.js +++ /dev/null @@ -1,133 +0,0 @@ -import React,{ Component } from "react"; -import {Tooltip} from 'antd'; -import {Link} from 'react-router-dom'; -import moment from 'moment'; -import CoursesListType from '../coursesPublic/CoursesListType'; -import { WordsBtn,formatDuring } from 'educoder'; -import '../css/members.css'; -import '../css/busyWork.css'; - -const polls_status={1:"未发布",2:"提交中",3:"已截止",4:"已结束"} - - -const dataformat="YYYY-MM-DD HH:mm"; -class PollListItem extends Component{ - constructor(props){ - super(props); - } - toDetailPage=(url)=>{ - - if(this.props.checkIfLogin()===false){ - this.props.showLoginDialog() - return - } - // if(this.props.checkIfProfileCompleted()===false){ - // this.setState({ - // AccountProfiletype:true - // }) - // return - // } - // if(this.props.checkIfProfessionalCertification()===false){ - // this.props.showProfileCompleteDialog() - // return - // } - - this.props.history.push(url); - } - render(){ - let{item,checkBox,courseType,index}=this.props; - let {coursesId}=this.props.match.params; - - const IsAdmin =this.props.isAdmin(); - const isStudent = this.props.isStudent(); - const isNotMember = this.props.isNotMember(); - const isAdminOrStudent = this.props.isAdminOrStudent(); - - let t= item.end_time ? moment(item.end_time) - moment() : 0; - let canNotLink = !isAdminOrStudent && item.lock_status == 0 - return( - -
    window.$(`.pollitem${index} input`).click() }> - { - IsAdmin && - - {checkBox} - - } -
    -

    - { canNotLink ? - {item.polls_name} - : - this.toDetailPage(`/classrooms/${coursesId}/polls/${item.id}/detail`)} className="fl font-16 font-bd mt2 color-grey-3 task-hide pointer" style={{"maxWidth":"600px"}} title={item.polls_name}>{item.polls_name} - } - { - item.lock_status === 0 ? - - - - :"" - } - - { - isStudent && ((item.polls_status == 1 && (item.current_status ==0 ||item.current_status ==2)) || (item.polls_status==3 && item.current_status==2)) ? - 未提交:"" - } -

    -

    - { item.author && {item.author} } - { - item.polls_status !=1 && - - {item.poll_answer} 已答 - {item.poll_unanswer} 未答 - - } - { - item.polls_status ==1 && item.publish_time ==null && item.created_at && - 创建于{moment(item.created_at).fromNow()} - } - { - item.polls_status ==1 && item.publish_time !=null && - 将发布于{moment(item.publish_time).format(dataformat)} - } - { - item.polls_status ==2 && item.publish_time !=null && - - {"提交剩余时间:"+formatDuring(t)} - - } - - - { - isStudent ? - - - { - item.current_status == 0 && "继续答题" - } - { - item.current_status == 1 && "查看答题" - } - { - item.current_status == 2 && "开始答题" - } - :"" - } - { isStudent ?canNotLink ?"": this.toDetailPage(`/classrooms/${coursesId}/polls/${item.id}/detail`)} >查看详情:""} - - { - IsAdmin && -

      - { canNotLink ?"": this.toDetailPage(`/classrooms/${coursesId}/polls/${item.id}/detail`)} >查看详情} - 编辑 - 设置 -
    - } -

    -
    -
    - ) - } -} -export default PollListItem diff --git a/src/modules/courses/poll/PollNew.js b/src/modules/courses/poll/PollNew.js deleted file mode 100644 index b1ea7788..00000000 --- a/src/modules/courses/poll/PollNew.js +++ /dev/null @@ -1,3960 +0,0 @@ -import React, {Component} from "react"; -import {Form, Input, Tooltip, Checkbox, Radio, Select, message, Modal, Button} from 'antd' -import {WordsBtn, ActionBtn} from 'educoder' - -import {Link} from 'react-router-dom' - -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; -const $ = window.$; -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: 0, - 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, - bindingid:undefined, - Newdisplay:false, - first_category_url:"", - left_banner_id:"", - publishtimeid_int:0, - boolneweied:undefined, - } - // console.log("试卷新建和编辑"); - // console.log(JSON.stringify(props)); - - } - - changeTopicName = (e) => { - // console.log("调用了changeTopicName"); - let num = parseInt(e.target.value.length); - if(num>60){ - return; - } - 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.isStudent() === true){ - - this.props.history.push("/403") - - return - } - 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", - }) - } - } - - console.log("问卷返回"); - console.log(this.props); - try { - if(this.props.current_user!==undefined){ - this.setState({ - first_category_url :this.props.current_user.first_category_url, - }); - console.log("======================="); - console.log(this.props.current_user.first_category_url); - } - }catch (e) { - console.log("12312312312") - console.log(e); - } - - }; - componentDidUpdate = (prevProps) => { - // console.log("componentDidUpdate"); - // console.log(prevProps); - // console.log(this.props); - if(prevProps.current_user!=this.props.current_user){ - if(this.props.current_user!==undefined){ - // console.log(this.props.current_user.login); - // console.log(prevProps.current_user.login); - this.setState({ - first_category_url :this.props.current_user.first_category_url, - }) - } - } - } - - //获取权限 - // 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, - }); - - if(result.data){ - if(result.data.poll){ - if(result.data.poll.polls_name){ - let num = parseInt(result.data.poll.polls_name.length); - this.setState({ - addonAfter: num < 0 ? 0 : num - }) - } - } - - } - - this.setState({ - projects: result.data, - pollid: pollid, - polls_status: result.data.poll.polls_status, - polls_name: result.data.poll.polls_name, - polls_description: result.data.poll.polls_description, - poll_questions: result.data.poll_questions, - question_types: result.data.question_types, - mysingles: result.data.question_types.q_singles, - mydoubles: result.data.question_types.q_doubles, - mymainsint: result.data.question_types.q_mains, - polls_nametest: result.data.poll.polls_name, - polls_descriptiontest: result.data.poll.polls_description, - questionnair: true, - left_banner_id:result.data.left_banner_id - }) - if( result.data.poll.polls_name){ - if( result.data.poll.polls_name.length>0){ - this.setState({ - addonAfter: result.data.poll.polls_name.length, - }) - } - } - }).catch((error) => { - console.log(error) - }) - } - - } - - //重新获取数据 - 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, - }) - if( result.data.poll.polls_name){ - if( result.data.poll.polls_name.length>0){ - this.setState({ - addonAfter: result.data.poll.polls_name.length, - }) - } - } - }).catch((error) => { - console.log(error) - }) - } - //新建问卷 - 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(`/classrooms/${this.props.match.params.coursesId}/polls/${result.data.data.id}/detail?tab=2`) - } - }) - } - //添加单选题目 - addmysingles = () => { - if (this.state.q_countst > 0) { - this.scrollToAnchor("publishtimeid"+this.state.publishtimeid_int); - this.props.showNotification(`不能同时编辑两题`); - - return; - } - if (this.state.newoption === true) { - this.setState({ - newoption: false - }) - } - this.setState({ - Newdisplay:true, - boolneweied:true, - }) - 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,0); - this.scrollToAnchor("publishtimeids"); - } - - //添加多选题目 - addmydoubles = () => { - if (this.state.q_countst > 0) { - this.scrollToAnchor("publishtimeid"+this.state.publishtimeid_int); - this.props.showNotification(`不能同时编辑两题`); - - return; - } - // console.log("addmymainsint 70") - if (this.state.newoption === true) { - this.setState({ - newoption: false - }) - } - this.setState({ - Newdisplay:true, - boolneweied:true, - }) - 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,0); - this.scrollToAnchor("publishtimeids"); - } - - //添加主观题目 - addmymainsint = () => { - if (this.state.q_countst > 0) { - this.scrollToAnchor("publishtimeid"+this.state.publishtimeid_int); - this.props.showNotification(`不能同时编辑两题`); - return; - } - this.setState({ - Newdisplay:true, - boolneweied:true, - }) - 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,0); - this.scrollToAnchor("publishtimeids"); - } - - //编辑方法 - adddomedit = (object,indexysl) => { - // console.log("adddomedit 76"); - if (this.state.q_countst > 0) { - if(this.state.boolneweied !== undefined){ - if(this.state.boolneweied===true){ - this.scrollToAnchor("publishtimeids"); - }else{ - this.scrollToAnchor("publishtimeid"+this.state.publishtimeid_int); - } - }else{ - this.scrollToAnchor("publishtimeids"); - } - this.props.showNotification(`不能同时编辑两题`); - return; - } - var anserbool = false; - this.setState({ - q_countst: 1, - bindingid:object.question.id, - publishtimeid_int:indexysl, - boolneweied:false, - }) - // window.scrollTo(0, this.refs.targetElement.offsetTops) - 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 - }) - - } - //滚动 - scrollToAnchor=(index)=>{ - // let name="Anchor_"+index; - console.log("scrollToAnchor"); - console.log(index); - try { - if (index) { - let anchorElement = document.getElementById(index); - // if(anchorElement) { anchorElement.scrollIntoView(); } - $("html").animate({scrollTop: $(anchorElement).offset().top - 150}) - } - } catch (e) { - - } - - } - //新增添加题目 有new - addMytopic = (index, pollid, Insertposition, Whether, id,inty) => { - //Whether 是否插入 - // console.log("addMytopic 90") - // console.log(index) - // console.log(pollid) - // console.log(Insertposition) - // console.log(Whether) - // console.log("addMytopic"); - // console.log(id); - if (this.state.q_countst > 0) { - if(Whether===true){ - if(this.state.boolneweied !== undefined){ - if(this.state.boolneweied===true){ - this.scrollToAnchor("publishtimeids"); - }else{ - this.scrollToAnchor("publishtimeid"+this.state.publishtimeid_int); - } - }else{ - this.scrollToAnchor("publishtimeids"); - } - } - this.props.showNotification(`不能同时编辑两题`); - return; - } - if(Whether===true){ - this.setState({ - publishtimeid_int:inty, - }) - } - this.state.Insertposition = Insertposition; - var Whethername = null; - if (Whether === true) { - Whethername = id; - } - this.setState({ - Insertposition: Insertposition, - q_countst: 1, - boolneweied:false, - }) - // 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": Whether=== true? id :this.state.poll_questions[newarr.length - 1].question.id, - "is_necessary": 1, - "question_number": 1, - "question_title": "", - "question_type": 1, - "new": "new", - "newid":Whether=== true? id :this.state.poll_questions[newarr.length - 1].question.id + 1, - "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": Whether=== true? id :this.state.poll_questions[newarr.length - 1].question.id, - "is_necessary": 1, - "question_number": 2, - "question_title": "", - "question_type": 2, - "max_choices": 0, - "min_choices": 0, - "new": "new", - "newid":Whether=== true? id :this.state.poll_questions[newarr.length - 1].question.id + 1, - "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": Whether=== true? id :this.state.poll_questions[newarr.length - 1].question.id, - "is_necessary": 1, - "question_number": 3, - "question_title": "", - "question_type": 3, - "new": "new", - "newid":Whether=== true? id :this.state.poll_questions[newarr.length - 1].question.id + 1, - "answers": [] - }; - question = {"question": questiontwo}; - newarrr.push(question); - this.setState({ - adddom: newarrr, - problemtopic: Whethername, - problemtopicbool: Whether, - }) - - } - } else { - /////上面视图全部删除后 要加载的 - if (index === 1) { - // 插入单选题 - var ids; - try { - ids = this.state.poll_questions[newarr.length - 1].question.id; - } catch (e) { - ids= 1; - } - var questiontwo = { - // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, - "id": Whether=== true? id :ids, - "is_necessary": 1, - "question_number": 1, - "question_title": "", - "question_type": 1, - "new": "new", - "newid":Whether=== true? id :ids+ 1, - "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 ids; - try { - ids = this.state.poll_questions[newarr.length - 1].question.id; - } catch (e) { - ids = 1; - } - var questiontwo = { - "id": Whether=== true? id :ids, - "is_necessary": 1, - "question_number": 2, - "question_title": "", - "question_type": 2, - "max_choices": 0, - "min_choices": 0, - "new": "new", - "newid":Whether=== true? id :ids+1, - "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 ids; - try { - ids= this.state.poll_questions[newarr.length - 1].question.id; - } catch (e) { - ids = 1; - } - var questiontwo = { - "id":Whether=== true? id : ids, - "is_necessary": 1, - "question_number": 3, - "question_title": "", - "question_type": 3, - "new": "new", - "newid":Whether=== true? id :ids + 1, - "answers": [] - }; - question = {"question": questiontwo}; - newarrr.push(question); - this.setState({ - adddom: newarrr, - problemtopic: Whethername, - problemtopicbool: Whether, - }) - } - } - } - - //删除指定条目 - Deleteadddom = (indexo,bool) => { - // console.log("deleteadddom 259") - - var arr = this.state.adddom; - let newarr = [...arr]; - newarr.splice(indexo, 1); - if(bool === true) { - console.log("shangchu1"); - this.setState({ - adddom: newarr, - q_countst: 0, - problemtopic: null, - problemtopicbool: false, - bindingid:undefined, - Newdisplay:false, - newoption: false, - boolneweied:undefined - }) - - }else{ - console.log("shangchu2"); - - this.setState({ - adddom: newarr, - q_countst: 0, - problemtopic: null, - problemtopicbool: false, - Newdisplay:false, - newoption: false, - boolneweied:undefined - }) - } - - } - //保存并继续 - //保存并继续,即提交本题的新建并继续创建一个相同的题(该新题处于编辑模式,题目和选项不要清空) - Deleteadddomtwo = (indexo, object,bool) => { - var thiss = this; - - - 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 (object.question.question_type === 1) { - if (maxtie < 2) { - this.props.showNotification(`选项不能少于2个!`); - return - } - } else if (object.question.question_type === 2) { - if (maxtie < 3) { - this.props.showNotification(`选项不能少于3个!`); - 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,0); - // newarrpoll.push(question); - newarrpoll.splice(thiss.state.Insertposition, 0, question); - - } else if (object.question.question_type === 2) { - //插入多选题 - if(object.question.max_choices){ - if(object.question.max_choices>0){ - if (object.question.max_choices < object.question.min_choices) { - this.props.showNotification(`可选的最大限制不能小于最小限制`); - return; - } - } - } - - - if(object.question.max_choices){ - if(object.question.max_choices>0){ - if(object.question.min_choices){ - if(object.question.min_choices===0){ - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - } - }else { - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - - } - } - - } - - if(object.question.min_choices){ - if(object.question.min_choices>0){ - if(object.question.max_choices){ - if(object.question.max_choices===0){ - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - } - }else { - 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,object.question.answers.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++) { - 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,0); - // 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,0); - newarrpoll.splice(uuk, 1, question); - } else { - // console.log("他原来的删除掉了") - this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id,0); - newarrpoll.push(question); - } - newarr[indexo].question.new = "new" - // console.log(newarrpoll) - } else if (object.question.question_type === 2) { - //插入多选题 - if(object.question.max_choices){ - if(object.question.max_choices>0){ - if (object.question.max_choices < object.question.min_choices) { - this.props.showNotification(`可选的最大限制不能小于最小限制`); - return; - } - } - } - - - if(object.question.max_choices){ - if(object.question.max_choices>0){ - if(object.question.min_choices){ - if(object.question.min_choices===0){ - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - } - }else { - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - - } - } - - } - - if(object.question.min_choices){ - if(object.question.min_choices>0){ - if(object.question.max_choices){ - if(object.question.max_choices===0){ - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - } - }else { - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - - } - } - - } - - // 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,object.question.answers.length); - 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,object.question.answers.length); - 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,0); - newarrpoll.splice(uuk, 1, question); - } else { - // console.log("删除") - this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id,0); - 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; - - } - if(bool === true){ - console.log("tianjiadao1"); - this.setState({ - q_countst: 1, - bindingid:undefined, - Newdisplay:false, - newoption: false, - }) - }else { - console.log("tianjiadao2"); - this.setState({ - q_countst: 1, - Newdisplay:false, - newoption: false, - }) - } - this.setState({ - // poll_questions: newarrpoll, - adddom: newarr, - problemtopic: null, - problemtopicbool: false, - boolneweied:undefined - // mysingles: this.state.mysingles, - // mydoubles: this.state.mydoubles, - // mymainsint: this.state.mymainsint - }) - - } - - - //保存 后期可以考虑和保存并继续 合并 - //保存,即完成新建并退出本题编辑 - // indexo 第几个数组 - //object 单个数组数据 - Deleteadddomthree = (indexo, object,bool) => { - - // 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 (newarr[indexo].question.question_title.match(/^[ ]*$/)) { - 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 (object.question.question_type === 1) { - if (maxtie < 2) { - this.props.showNotification('选项不能少于2个!'); - return - } - } else if (object.question.question_type === 2) { - if (maxtie < 3) { - this.props.showNotification('选项不能少于3个!'); - 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,0); - newarrpoll.splice(thiss.state.Insertposition, 0, question); - } else if (object.question.question_type === 2) { - //插入多选题 - if(object.question.max_choices){ - if(object.question.max_choices>0){ - if (object.question.max_choices < object.question.min_choices) { - this.props.showNotification(`可选的最大限制不能小于最小限制`); - return; - } - } - } - - if(object.question.max_choices){ - if(object.question.max_choices>0){ - if(object.question.min_choices){ - if(object.question.min_choices===0){ - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - } - }else { - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - - } - } - - } - - if(object.question.min_choices){ - if(object.question.min_choices>0){ - if(object.question.max_choices){ - if(object.question.max_choices===0){ - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - } - }else { - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - - } - } - - } - - - // 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,object.question.answers.length); - //插入多选题 - // 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,0); - // 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,0); - newarrpoll.splice(uuk, 1, question); - } else { - // console.log("删除") - this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id,0); - newarrpoll.push(question); - } - // console.log(newarrpoll) - } else if (object.question.question_type === 2) { - //插入多选题 - if(object.question.max_choices){ - if(object.question.max_choices>0){ - if (object.question.max_choices < object.question.min_choices) { - this.props.showNotification(`可选的最大限制不能小于最小限制`); - return; - } - } - } - - if(object.question.max_choices){ - if(object.question.max_choices>0){ - if(object.question.min_choices){ - if(object.question.min_choices===0){ - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - } - }else { - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - - } - } - - } - - if(object.question.min_choices){ - if(object.question.min_choices>0){ - if(object.question.max_choices){ - if(object.question.max_choices===0){ - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - } - }else { - 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,object.question.answers.length); - 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,object.question.answers.length); - newarrpoll.push(question); - } - - } 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,0); - newarrpoll.splice(uuk, 1, question); - } else { - // console.log("删除") - this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id,0); - 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, - }) - } - if(bool === true) { - this.setState({ - bindingid:undefined, - }) - } - this.Deleteadddom(indexo); - // console.log(indexo) - this.setState({ - boolneweied:undefined - }) - } - - - ////新增到服务器中 - createquestionsandanswers = (object, number, option, other, max_choices, min_choices, insert_id,length) => { - - 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; - try { - if (max_choices === 0 && min_choices === 0) { - max_choicess = null; - min_choicess = null; - } else { - max_choicess = max_choices; - min_choicess = min_choices; - } - }catch (e) { - max_choicess = null; - min_choicess = null; - } - // console.log("createquestionsandanswers"); - // console.log(max_choicess); - // console.log(min_choicess); - // console.log(length); - var datay={}; - datay={ - question_title: object.question.question_title, - question_type: number, - is_necessary: object.question.is_necessary, - question_answers: option, - question_other_answer: null, - insert_id: insert_id - } - try { - if(number===2){ - datay={ - question_title: object.question.question_title, - question_type: number, - is_necessary: object.question.is_necessary, - max_choices: max_choicess===undefined||max_choicess===null||max_choicess===0||max_choicess==="0"?null:max_choicess, - min_choices: min_choicess===undefined||min_choicess===null||min_choicess===0||min_choicess==="0"?null:min_choicess, - question_answers: option, - question_other_answer: null, - insert_id: insert_id - } - } - }catch (e) { - - } - - axios.post(urlly, datay).then((result) => { - // try { - if (result !== undefined) { - if (result.data.status === 0) { - this.props.showNotification(`已完成`); - thiss.thisinitializationdatanew(); - console.log("已完成了了了1"); - this.setState({ - Newdisplay:false, - newoption: false, - - }) - // console.log("确认创建问题") - // console.log(result) - // try { - // if (result.data.status === 0) { - // console.log("确认创建问题") - // console.log(JSON.stringify(result.data)) - // } - // } catch (e) { - // - // } - } - }else{ - this.setState({ - Newdisplay:true, - newoption: false, - - }) - } - // } catch (e) { - // - // } - - }).catch((error) => { - console.log(error) - this.setState({ - Newdisplay:true, - newoption: false, - - }) - }) - - - } - ///编辑修改到服务器当中 - edittotheserver = (object, number, option, other, max_choices, min_choices,length) => { - // console.log("调用了edittotheserver") - var url = `/poll_questions/${object.question.id}.json` - var thiss = this; - var max_choicess = null; - var min_choicess = null; - try { - if (max_choices === 0 && min_choices === 0) { - max_choicess = null; - min_choicess = null; - } else { - max_choicess = max_choices; - min_choicess = min_choices; - } - }catch (e) { - max_choicess = null; - min_choicess = null; - } - - // console.log("createquestionsandanswers"); - // console.log(max_choicess); - // console.log(min_choicess); - // console.log(length); - var datay={}; - datay={ - // debug: true, - question_title: object.question.question_title, - question_type: number, - is_necessary: object.question.is_necessary, - question_answers: option, - question_other_answer: null, - }; - try { - if(number===2){ - datay={ - // debug: true, - question_title: object.question.question_title, - question_type: number, - is_necessary: object.question.is_necessary, - max_choices: max_choicess===undefined||max_choicess===null||max_choicess===0||max_choicess==="0"?null:max_choicess, - min_choices: min_choicess===undefined||min_choicess===null||min_choicess===0||min_choicess==="0"?null:min_choicess, - question_answers: option, - question_other_answer: null, - }; - } - }catch (e) { - - } - - axios.put(url,datay).then((result) => { - try { - if (result.data.status === 0) { - console.log("编辑题目成功1"); - this.props.showNotification(`编辑题目成功`); - thiss.thisinitializationdatanew(); - this.setState({ - Newdisplay:false, - newoption: false, - }) - } - } catch (e) { - // console.log("调用了edittotheserver") - this.setState({ - Newdisplay:true, - newoption: false, - }) - } - }).catch((error) => { - console.log(error) - this.setState({ - Newdisplay:true, - newoption: false, - }) - }) - } - - //删除到服务器当中 - 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) - // } - try { - if(result){ - if(result.data){ - if (result.data.status === 0) { - this.props.showNotification(`上移成功`); - thiss.thisinitializationdatanew(); - }else{ - this.props.showNotification(`上移失败`); - } - } - }else { - this.props.showNotification(`上移失败`); - } - } catch (e) { - this.props.showNotification(`上移失败`); - - } - }) - } else { - var url = `/poll_questions/${poll_question_id}/up_down.json`; - axios.post(url, { - opr: "down", - }).then((result) => { - // try { - // if (result.data.status === 0) { - // // message.success("下移题目成功", 1) - // this.props.showNotification(`下移成功`); - // thiss.thisinitializationdatanew(); - // } - // // console.log(JSON.stringify(result)) - // } catch (e) { - // // console.log("下移题目成功 错误") - // console.log(e) - // } - - - try { - if(result){ - if(result.data){ - if (result.data.status === 0) { - this.props.showNotification(`下移成功`); - thiss.thisinitializationdatanew(); - }else { - this.props.showNotification(`下移失败`); - } - }else { - this.props.showNotification(`上移失败`); - } - } - } catch (e) { - this.props.showNotification(`上移失败`); - 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"+" "+e); - console.log("handleInputChanges"+" "+i); - console.log("handleInputChanges"+" "+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) => { - // console.log("最小值"); - // console.log(value); - // console.log(index); - // console.log(max); - // console.log(length); - - - 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; - break; - } - } - this.setState({ - adddom: arr - }) - // } - - } - - //最大值 - HandleGradationGroupChangeee = (value, index,minchoices,length) => { - // console.log("2112"); - // console.log(value); - // console.log(minchoices); - // console.log("最大值"); - // console.log(value); - // console.log(index); - // console.log(minchoices); - // console.log(length); - let arr = this.state.adddom; - for (var i = 0; i < arr.length; i++) { - if (index === i) { - // if(parseInt(value)===0&&parseInt(minchoices)===0){ - // arr[i].question.min_choices= parseInt(0); - // arr[i].question.max_choices = parseInt(0); - // }else if(parseInt(minchoices)===0){ - // arr[i].question.min_choices= parseInt(2); - // arr[i].question.max_choices = parseInt(value); - // } - // else if(parseInt(value)===0&&parseInt(minchoices)>0){ - // arr[i].question.min_choices= parseInt(minchoices); - // arr[i].question.max_choices = parseInt(value); - // } - // else { - // arr[i].question.min_choices= minchoices===null?2:minchoices===undefined?2:minchoices===0?2:parseInt(minchoices); - arr[i].question.max_choices = parseInt(value); - // } - } - } - // console.log(2119); - // console.log(arr); - this.setState({ - adddom: arr - }) - // console.log(this.state.adddom); - } - - //提交题目//没有就创建新的题库,新建问newz题和保存题目不一样不能同时保存 这里只是新建 和编辑 标题和须知 - submitQuestionnaire = (mews) => { - // 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; - } - - // if(mews ==="new"){ - if(this.state.poll_questions&&this.state.poll_questions.length===0){ - this.props.showNotification("至少创建1个题目"); - return; - } - // } - - 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(`/classrooms/${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, - }); - // var currenturl = window.location.href; - // var newUrl = (currenturl.split("?"))[0]; - // var newr=(newUrl.slice("new"))[0]; - // console.log(newUrl); - // console.log("2301"); - // console.log(newr); - // window.history.pushState('','',newUrl+'?tab='+e); - - // window.location.href = `/courses/${coursesId}/polls/${result.data.data.id}/edit`; - - }) - } else { - if (this.state.polls_nametest === undefined || this.state.polls_nametest === "") { - this.props.showNotification("请输入标题"); - return - } - - 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", - }) - } - - }) - } - - } - gotohome=()=>{ - // const { current_user} = this.props - if(this.state.first_category_url){ - window.location.href=this.state.first_category_url; - }else{ - this.props.history.goBack(); - } - - // - // let courseId=this.props.match.params.coursesId; - // if(courseId===undefined){ - // this.props.history.push("/classrooms"); - // }else{ - // this.props.history.push(this.props.current_user.first_category_url); - // } - } - //试图 - render() { - let { - addonAfter, - user_permission, - polls_status, - Modalstype, - mysave, - readOnlys, - newoption, - cancellation, - left_banner_id - } = 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', - }; - const hejiine=this.state.mysingles + this.state.mydoubles + this.state.mymainsint; - - // console.log(this.state.projects===undefined?"":this.state.projects.poll_questions) - var displaymysave = (mysave === true) ? "" : "display:none;"; - document.title=this.props.coursedata&&this.props.coursedata.name; - return ( -
    - {/*提示*/} - {Modalstype && Modalstype === true ? : ""} - -
    -

    - this.gotohome()}>{this.props.coursedata.name} - > - { - 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.props.match.params.news === "new" ? - - : - - } -
    - - {/**/} - { - this.state.mysave === false ? -
    - -
    - -
    - :"" - } - { - this.state.mysave === true ? -
    -
    - - -
    -
    *问卷标题 -
    - { - this.props.match.params.news === undefined ? "" : this.props.match.params.news === "new" ? - ( - this.state.mysave === false ? - - : "") - :"" - } - -
    - {/*suffix={String(addonAfter)}*/} - - - -
    -
    - - -
    问卷须知
    - - - { - this.state.Newedit === true || this.state.mysave === true ? -
    - - {cancellation === false ? - - : ""} - -
    - : "" - } - -
    - -
    :"" - } - - - -

    - - - { - hejiine=== 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 ? "" : hejiine} -
    - - } - -

    -
    - - {/*自动生成修改好的获取到的*/} - {/**************************************************************************/} - {this.state.poll_questions === undefined ? "" : this.state.poll_questions.map((item, index) => { - // console.log('打印this.state.poll_questions'); - // console.log(this.state.poll_questions); - // console.log(this.state.adddom); - 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.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 === "null" && item.question.max_choices === "null" ? "" : item.question.min_choices === item.question.max_choices && item.question.max_choices === item.question.min_choices ? "可选"+(item.question.max_choices)+"项" : "可选" +(item.question.min_choices===undefined||item.question.min_choices===null||item.question.min_choices===""||item.question.min_choices==="null"?2:item.question.min_choices) + "-" + (item.question.max_choices===undefined||item.question.max_choices===null||item.question.max_choices===""||item.question.max_choices==="null"?item.question.answers.length: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,index)}> - this.adddomedit(item,index)}> - : this.adddomedit(item,index)}> - } - -

    -

    {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} - -
    - ) - })} -
    - {/*单选题*/} - - -
    - : item.question.question_type === 2 ? -
    - - {item.question.answers === undefined ? "" : item.question.answers.map((items, i) => { - return ( -
    - - {items.answer_text} -
    - ) - })} -
    - {/*多选题*/} -
    - - : item.question.question_type === 3 ? - // 主观题 - (
    -
    ) : (
    )} -
    - - return ( -
    - {/*这里是编辑和新增的地方*/} - { - this.state.bindingid && this.state.bindingid===item.question.id? - (this.state.Newdisplay === false? -
    -
    - {this.state.adddom === undefined ? "" :this.state.adddom===undefined?"": this.state.adddom.length===0?"":item.question.id === this.state.adddom[0].question.id&&this.state.adddom.map((itemo, indexo) => { - 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 === "其他" ? ( -

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

    ) : (

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

    )} -
    - ) - })} - -
    - {itemo.question.question_type === 1 ? ( -
    -
    - {this.state.polls_status === undefined || this.state.polls_status === 1 ? - this.Ewoption(itemo.question.id, itemo)}>新增选项 - - : ""} - {this.state.polls_status === undefined || this.state.polls_status === 1 ? - - (this.state.newoption === false ? - this.Addanotheroption(itemo.question.id)}>新增其他选项 - : "") - : ""} - - this.Deleteadddom(indexo,true)}>取消 - this.Deleteadddomthree(indexo, itemo,true)}>保存 - { - polls_status && polls_status < 2 ? - this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 - :""} - -
    -
    - - - ) - - - : itemo.question.question_type === 2 ? ( - //////////////////////////////////////////// 可选 -
    -
    -
    - 可选 -
    - {/*可选最小1*/} - - - ~ - {/*可选最大2*/} - - - (学生答题时,系统对其选择的选项个数进行限制,--表示不限制) -
    - -
    -
    -
    - ) - - : (
    ) - - } -
    -
    - {itemo.question.question_type === 2 ? - ( - this.state.polls_status === undefined || this.state.polls_status === 1 ? -
    - -
    this.Ewoption(itemo.question.id, itemo)}>新增选项 - - { - this.state.newoption === false ? this.Addanotheroption(itemo.question.id)}>新增其他选项 : "" - } - -
    - - - - this.Deleteadddom(indexo,true)}>取消 - this.Deleteadddomthree(indexo, itemo,true)}>保存 - { - polls_status && polls_status < 2 ? - this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 - :""} - -
    - - - : -
    - - this.Deleteadddom(indexo,true)}>取消 - this.Deleteadddomthree(indexo, itemo,true)}>保存 - { - polls_status && polls_status < 2 ? - this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 - :""} - -
    - ) - - : itemo.question.question_type === 3 ? -
    - - this.Deleteadddom(indexo,true)}>取消 - this.Deleteadddomthree(indexo, itemo,true)}>保存 - { - polls_status && polls_status < 2 ? - this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 - :""} - -
    - : - ""} - - -
    -
    - - - return ( -
    - {resultDomtwo} -
    - ) - })} -
    -
    :"") - : -
    - {resultDom} - {this.state.Newdisplay === false? - -
    - {this.state.adddom === undefined ? "" :this.state.adddom===undefined?"": this.state.adddom.length===0?"":item.question.id === this.state.adddom[0].question.id&&this.state.adddom.map((itemo, indexo) => { - 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 === "其他" ? ( -

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

    ) : (

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

    )} -
    - ) - })} - -
    - {itemo.question.question_type === 1 ? ( -
    -
    - {this.state.polls_status === undefined || this.state.polls_status === 1 ? - this.Ewoption(itemo.question.id, itemo)}>新增选项 - - : ""} - {this.state.polls_status === undefined || this.state.polls_status === 1 ? - - (this.state.newoption === false ? - this.Addanotheroption(itemo.question.id)}>新增其他选项 - : "") - : ""} - - this.Deleteadddom(indexo,true)}>取消 - this.Deleteadddomthree(indexo, itemo,true)}>保存 - { - polls_status && polls_status < 2 ? - this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 - :""} - -
    -
    - - - ) - - - : itemo.question.question_type === 2 ? ( - //////////////////////////////////////////// 可选 -
    -
    -
    - 可选 -
    - {/*可选最小*/} - - - ~ - {/*可选最大*/} - - - (学生答题时,系统对其选择的选项个数进行限制,--表示不限制) -
    - -
    -
    -
    - ) - - : (
    ) - - } -
    -
    - {itemo.question.question_type === 2 ? - ( - this.state.polls_status === undefined || this.state.polls_status === 1 ? -
    - -
    this.Ewoption(itemo.question.id, itemo)}>新增选项 - - { - this.state.newoption === false ? this.Addanotheroption(itemo.question.id)}>新增其他选项 : "" - } - -
    - - - - this.Deleteadddom(indexo,true)}>取消 - this.Deleteadddomthree(indexo, itemo,true)}>保存 - { - polls_status && polls_status < 2 ? - this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 - :""} - -
    - - - : -
    - - this.Deleteadddom(indexo,true)}>取消 - this.Deleteadddomthree(indexo, itemo,true)}>保存 - { - polls_status && polls_status < 2 ? - this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 - :""} - -
    - ) - - : itemo.question.question_type === 3 ? -
    - - this.Deleteadddom(indexo,true)}>取消 - this.Deleteadddomthree(indexo, itemo,true)}>保存 - { - polls_status && polls_status < 2 ? - this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 - :""} - -
    - : - ""} - - -
    -
    - - - return ( -
    - {resultDomtwo} -
    - ) - })} -
    :""} -
    - } -
    - - ) - })} - - - - {/*新建单选多选2*/} -
    - { - this.state.Newdisplay === true? -
    - {this.state.adddom === undefined ? "publishtimeids123123" : this.state.adddom.map((itemo, indexo) => { - // console.log('打印this.state.adddom') - // console.log(this.state.adddom); - 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)}>保存 - { - polls_status && polls_status < 2 ? - 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)}>保存 - { - polls_status&&polls_status<2? - this.Deleteadddomtwo(indexo, itemo)}>保存并继续 - :"" - } - -
    - - - : -
    - - this.Deleteadddom(indexo)}>取消 - this.Deleteadddomthree(indexo, itemo)}>保存 - { - polls_status&&polls_status<2? - this.Deleteadddomtwo(indexo, itemo)}>保存并继续 - :"" - } - -
    - ) - - : itemo.question.question_type === 3 ? -
    - - this.Deleteadddom(indexo)}>取消 - this.Deleteadddomthree(indexo, itemo)}>保存 - { - polls_status&&polls_status<2? - 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); diff --git a/src/modules/courses/poll/PollNewQuestbank.js b/src/modules/courses/poll/PollNewQuestbank.js deleted file mode 100644 index e9f1b700..00000000 --- a/src/modules/courses/poll/PollNewQuestbank.js +++ /dev/null @@ -1,4312 +0,0 @@ -import React, {Component} from "react"; -import {Form, Input, Tooltip, Checkbox, Radio, Select, message, Modal, Button} from 'antd' -import {WordsBtn, ActionBtn,WordNumberTextarea} from 'educoder' - -import {Link} from 'react-router-dom' - -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"; -import PollListItem from "./PollListItem"; -import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; - -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; -const $ = window.$; -class PollNewQuestbank extends Component { - // 题库的问卷新建和编辑 - // - // * addonAfter 字数限制 - // * q_counts 题目总数 - // * mysingles 单选题数量 - // * mydoubles 多选题数量 - // * mymainsint 主观题数量 - // * adddom 添加编辑的数据 页面点击新增题目 - // * editentry 编辑条目 新增的题目点击到条目中 - //* questionnair 问卷是否存在 默认不存在 - // * - - constructor(props) { - super(props); - this.contentMdRef = React.createRef(); - this.state = { - visible: false, - poll_questions: [], - user_permission: "", - addonAfter: 0, - addonAftertwo: 0, - 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, - bindingid: undefined, - Newdisplay: false, - first_category_url: "", - left_banner_id: "", - publishtimeid_int:0, - boolneweied:undefined, - } - // console.log("试卷新建和编辑"); - // console.log(JSON.stringify(props)); - - } - - changeTopicName = (e) => { - // console.log("调用了changeTopicName"); - let num = parseInt(e.target.value.length); - if (num > 60) { - return; - } - 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.isStudent() === true) { - - this.props.history.push("/403") - - return - } - // 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", - }) - // } - // } - - console.log("问卷返回"); - console.log(this.props); - try { - if (this.props.current_user !== undefined) { - this.setState({ - first_category_url: this.props.current_user.first_category_url, - }); - console.log("======================="); - console.log(this.props.current_user.first_category_url); - } - } catch (e) { - console.log("12312312312") - console.log(e); - } - - }; - componentDidUpdate = (prevProps) => { - // console.log("componentDidUpdate"); - // console.log(prevProps); - // console.log(this.props); - if (prevProps.current_user != this.props.current_user) { - if (this.props.current_user !== undefined) { - // console.log(this.props.current_user.login); - // console.log(prevProps.current_user.login); - this.setState({ - first_category_url: this.props.current_user.first_category_url, - }) - } - } - } - - //获取权限 - // 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.workid; - 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 = `/exercise_banks/${pollid}.json`; - axios.get(url).then((result) => { - if (result) { - console.log("247"); - console.log(result); - - - } - - - if (result.data) { - if (result.data.poll) { - if (result.data.poll.polls_name) { - let num = parseInt(result.data.poll.polls_name.length); - this.setState({ - addonAfter: num < 0 ? 0 : num - }) - } - } - - } - - this.setState({ - projects: result.data, - pollid: pollid, - polls_status: result.data.poll.is_public === false ? 1 : 2, - polls_name: result.data.poll.name, - polls_description: result.data.poll.description, - poll_questions: result.data.questions, - question_types: result.data.question_types, - mysingles: result.data.question_types.q_singles, - mydoubles: result.data.question_types.q_doubles, - mymainsint: result.data.question_types.q_mains, - q_counts: result.data.question_types.q_counts, - polls_nametest: result.data.poll.name, - polls_descriptiontest: result.data.poll.description, - questionnair: true, - left_banner_id: result.data.left_banner_id - }) - - if (result.data.poll.name) { - if (result.data.poll.name.length > 0) { - this.setState({ - addonAfter: result.data.poll.name.length, - }) - } - } - try { - const crumbData={ - title:'编辑', - is_public:result && result.data && result.data.is_public, - crumbArray:[ - {to:`/banks/poll/${pollid}/${this.props.match.params.type}`,content:'详情'}, - {content:'编辑'} - ] - } - this.props.initPublic(crumbData,result.data); - }catch (e) { - - } - }).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.workid; - } - } - - if (pollidsy === null || pollidsy === undefined) { - return - } - - const url = `/exercise_banks/${pollidsy}.json`; - axios.get(url).then((result) => { - if (result !== undefined) { - this.setState({ - projects: result.data, - pollid: pollidsy, - polls_status: result.data.poll.is_public === false ? 1 : 2, - polls_name: result.data.poll.name, - polls_description: result.data.poll.description, - poll_questions: result.data.questions, - question_types: result.data.question_types, - mysingles: result.data.question_types.q_singles, - mydoubles: result.data.question_types.q_doubles, - mymainsint: result.data.question_types.q_mains, - q_counts: result.data.question_types.q_counts, - polls_nametest: result.data.poll.name, - polls_descriptiontest: result.data.poll.description, - questionnair: true, - left_banner_id: result.data.left_banner_id - }); - - - if (result.data.poll.name) { - if (result.data.poll.name.length > 0) { - this.setState({ - addonAfter: result.data.poll.name.length, - }) - } - } - } - - // console.log("有问卷~~~") - - - // } - }).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(`/classrooms/${this.props.match.params.coursesId}/polls/${result.data.data.id}/detail?tab=2`) - } - }) - } - //添加单选题目 - addmysingles = () => { - - if (this.state.q_countst > 0) { - this.scrollToAnchor("publishtimeid"+this.state.publishtimeid_int); - this.props.showNotification(`不能同时编辑两题`); - - return; - } - if (this.state.newoption === true) { - this.setState({ - newoption: false - }) - } - this.setState({ - Newdisplay: true, - boolneweied:true, - }) - 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,0); - this.scrollToAnchor("publishtimeids"); - } - - //添加多选题目 - addmydoubles = () => { - if (this.state.q_countst > 0) { - this.scrollToAnchor("publishtimeid"+this.state.publishtimeid_int); - this.props.showNotification(`不能同时编辑两题`); - - return; - } - if (this.state.newoption === true) { - this.setState({ - newoption: false - }) - } - this.setState({ - Newdisplay: true, - boolneweied:true, - }) - 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,0); - this.scrollToAnchor("publishtimeids"); - - // } - } - - //添加主观题目 - addmymainsint = () => { - if (this.state.q_countst > 0) { - this.scrollToAnchor("publishtimeid"+this.state.publishtimeid_int); - this.props.showNotification(`不能同时编辑两题`); - return; - } - this.setState({ - Newdisplay: true, - boolneweied:true, - }) - 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,0); - this.scrollToAnchor("publishtimeids"); - } - - //编辑方法 - adddomedit = (object,indexysl) => { - if (this.state.q_countst > 0) { - if(this.state.boolneweied !== undefined){ - if(this.state.boolneweied===true){ - this.scrollToAnchor("publishtimeids"); - }else{ - this.scrollToAnchor("publishtimeid"+this.state.publishtimeid_int); - } - }else{ - this.scrollToAnchor("publishtimeids"); - } - this.props.showNotification(`不能同时编辑两题`); - return; - } - - var anserbool = false; - this.setState({ - q_countst: 1, - bindingid: object.question.id, - publishtimeid_int:indexysl, - boolneweied:false, - }) - // window.scrollTo(0, this.refs.targetElement.offsetTops) - 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); - } - // try { - // if(anserbool===false){ - // let answersysltwo = { - // "answer_id": parseInt(object.question.answers[object.question.answers.length-1].answer_id)+1, - // "answer_position": parseInt(object.question.answers[object.question.answers.length-1].answer_position)+1, - // "answer_text": "其他" - // } - // answers.push(answersysltwo); - // } - // }catch (e) { - // - // } - - 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,inty) => { - //Whether 是否插入 - // console.log("addMytopic 90") - // console.log(index) - // console.log(pollid) - // console.log(Insertposition) - // console.log(Whether) - // console.log("addMytopic"); - // console.log(id); - - if (this.state.q_countst > 0) { - if(Whether===true){ - if(this.state.boolneweied !== undefined){ - if(this.state.boolneweied===true){ - this.scrollToAnchor("publishtimeids"); - }else{ - this.scrollToAnchor("publishtimeid"+this.state.publishtimeid_int); - } - }else{ - this.scrollToAnchor("publishtimeids"); - } - } - this.props.showNotification(`不能同时编辑两题`); - return; - } - - if(Whether===true){ - this.setState({ - publishtimeid_int:inty, - }) - } - this.state.Insertposition = Insertposition; - var Whethername = null; - if (Whether === true) { - Whethername = id; - } - this.setState({ - Insertposition: Insertposition, - q_countst: 1, - boolneweied:false, - }) - // 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": Whether === true ? id : this.state.poll_questions[newarr.length - 1].question.id, - "is_necessary": 1, - "question_number": 1, - "question_title": "", - "question_type": 1, - "new": "new", - "newid": Whether === true ? id : this.state.poll_questions[newarr.length - 1].question.id + 1, - "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": Whether === true ? id : this.state.poll_questions[newarr.length - 1].question.id, - "is_necessary": 1, - "question_number": 2, - "question_title": "", - "question_type": 2, - "max_choices": 0, - "min_choices": 0, - "new": "new", - "newid": Whether === true ? id : this.state.poll_questions[newarr.length - 1].question.id + 1, - "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": Whether === true ? id : this.state.poll_questions[newarr.length - 1].question.id, - "is_necessary": 1, - "question_number": 3, - "question_title": "", - "question_type": 3, - "new": "new", - "newid": Whether === true ? id : this.state.poll_questions[newarr.length - 1].question.id + 1, - "answers": [] - }; - question = {"question": questiontwo}; - newarrr.push(question); - this.setState({ - adddom: newarrr, - problemtopic: Whethername, - problemtopicbool: Whether, - }) - - } - } else { - /////上面视图全部删除后 要加载的 - if (index === 1) { - // 插入单选题 - var ids; - try { - ids = this.state.poll_questions[newarr.length - 1].question.id; - } catch (e) { - ids = 1; - } - var questiontwo = { - // "id": this.state.poll_questions[arr.length - 1].question.id + 1 + arrr.length, - "id": Whether === true ? id : ids, - "is_necessary": 1, - "question_number": 1, - "question_title": "", - "question_type": 1, - "new": "new", - "newid": Whether === true ? id : ids + 1, - "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 ids; - try { - ids = this.state.poll_questions[newarr.length - 1].question.id; - } catch (e) { - ids = 1; - } - var questiontwo = { - "id": Whether === true ? id : ids, - "is_necessary": 1, - "question_number": 2, - "question_title": "", - "question_type": 2, - "max_choices": 0, - "min_choices": 0, - "new": "new", - "newid": Whether === true ? id : ids + 1, - "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 ids; - try { - ids = this.state.poll_questions[newarr.length - 1].question.id; - } catch (e) { - ids = 1; - } - var questiontwo = { - "id": Whether === true ? id : ids, - "is_necessary": 1, - "question_number": 3, - "question_title": "", - "question_type": 3, - "new": "new", - "newid": Whether === true ? id : ids + 1, - "answers": [] - }; - question = {"question": questiontwo}; - newarrr.push(question); - this.setState({ - adddom: newarrr, - problemtopic: Whethername, - problemtopicbool: Whether, - }) - } - } - } - - //删除指定条目 - Deleteadddom = (indexo, bool) => { - // console.log("deleteadddom 259") - - var arr = this.state.adddom; - let newarr = [...arr]; - newarr.splice(indexo, 1); - if (bool === true) { - this.setState({ - adddom: newarr, - q_countst: 0, - problemtopic: null, - problemtopicbool: false, - bindingid: undefined, - Newdisplay: false, - newoption: false, - boolneweied:undefined - }) - - } else { - this.setState({ - adddom: newarr, - q_countst: 0, - problemtopic: null, - problemtopicbool: false, - Newdisplay: false, - newoption: false, - boolneweied:undefined - }) - } - } - //保存并继续 - //保存并继续,即提交本题的新建并继续创建一个相同的题(该新题处于编辑模式,题目和选项不要清空) - Deleteadddomtwo = (indexo, object, bool) => { - var thiss = this; - - if (object.question.question_type === 3) { - this.HandleInputTopics(this.contentMdRef.current.getValue().trim(), indexo); - - } - 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 (object.question.question_type !== 3) { - 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 (object.question.question_type === 1) { - if (maxtie < 2) { - this.props.showNotification(`选项不能少于2个!`); - return - } - } else if (object.question.question_type === 2) { - if (maxtie < 3) { - this.props.showNotification(`选项不能少于3个!`); - 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,0); - // 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; - } - - if(object.question.max_choices){ - if(object.question.max_choices>0){ - if(object.question.min_choices){ - if(object.question.min_choices===0){ - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - } - }else { - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - - } - } - - } - - if(object.question.min_choices){ - if(object.question.min_choices>0){ - if(object.question.max_choices){ - if(object.question.max_choices===0){ - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - } - }else { - 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,object.question.answers.length); - //插入多选题 - // 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) { - // this.HandleInputTopics(this.contentMdRef.current.getValue().trim(),indexo); - //插入主观题 - 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": this.contentMdRef.current.getValue().trim(), - "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,0); - // 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,0); - newarrpoll.splice(uuk, 1, question); - } else { - // console.log("他原来的删除掉了") - this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id,0); - 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; - } - - if(object.question.max_choices){ - if(object.question.max_choices>0){ - if(object.question.min_choices){ - if(object.question.min_choices===0){ - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - } - }else { - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - - } - } - - } - - if(object.question.min_choices){ - if(object.question.min_choices>0){ - if(object.question.max_choices){ - if(object.question.max_choices===0){ - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - } - }else { - 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,object.question.answers.length); - 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,object.question.answers.length); - newarrpoll.push(question); - } - // console.log(newarrpoll) - newarr[indexo].question.new = "new" - } else if (object.question.question_type === 3) { - // this.HandleInputTopics(this.contentMdRef.current.getValue().trim(),indexo); - - //插入主观题 - 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": this.contentMdRef.current.getValue().trim(), - "question_type": 3, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - - if (uuk !== -1) { - // console.log("修改") - this.edittotheserver(object, 3, null, null, 0, 0,0); - newarrpoll.splice(uuk, 1, question); - } else { - // console.log("删除") - this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id,0); - 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; - - } - if (bool === true) { - this.setState({ - q_countst: 1, - bindingid: undefined, - Newdisplay: false, - - }) - } else { - this.setState({ - q_countst: 1, - Newdisplay: false, - }) - } - this.setState({ - // poll_questions: newarrpoll, - adddom: newarr, - problemtopic: null, - problemtopicbool: false, - boolneweied:undefined - // mysingles: this.state.mysingles, - // mydoubles: this.state.mydoubles, - // mymainsint: this.state.mymainsint - }) - - } - - - //保存 后期可以考虑和保存并继续 合并 - //保存,即完成新建并退出本题编辑 - // indexo 第几个数组 - //object 单个数组数据 - Deleteadddomthree = (indexo, object, bool) => { - - this.setState({ - Newdisplay: false, - }); - if (object.question.question_type === 3) { - this.HandleInputTopics(this.contentMdRef.current.getValue().trim(), indexo); - - } - // 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 (object.question.question_type !== 3) { - 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 (object.question.question_type === 1) { - if (maxtie < 2) { - this.props.showNotification('选项不能少于2个!'); - return - } - } else if (object.question.question_type === 2) { - if (maxtie < 3) { - this.props.showNotification('选项不能少于3个!'); - 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,0); - 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; - } - - - if(object.question.max_choices){ - if(object.question.max_choices>0){ - if(object.question.min_choices){ - if(object.question.min_choices===0){ - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - } - }else { - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - - } - } - - } - - if(object.question.min_choices){ - if(object.question.min_choices>0){ - if(object.question.max_choices){ - if(object.question.max_choices===0){ - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - } - }else { - 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,object.question.answers.length); - //插入多选题 - // if (object.question.max_choices > arrc.length) { - - newarrpoll.splice(thiss.state.Insertposition, 0, question); - } else if (object.question.question_type === 3) { - // this.HandleInputTopics(this.contentMdRef.current.getValue().trim(),indexo); - - //插入主观题 - 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": this.contentMdRef.current.getValue().trim(), - "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,0); - // 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,0); - newarrpoll.splice(uuk, 1, question); - } else { - // console.log("删除") - this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id,0); - 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; - } - - - if(object.question.max_choices){ - if(object.question.max_choices>0){ - if(object.question.min_choices){ - if(object.question.min_choices===0){ - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - } - }else { - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - - } - } - - } - - if(object.question.min_choices){ - if(object.question.min_choices>0){ - if(object.question.max_choices){ - if(object.question.max_choices===0){ - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); - return; - } - }else { - 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,object.question.answers.length); - 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,object.question.answers.length); - newarrpoll.push(question); - } - // console.log(newarrpoll) - - } else if (object.question.question_type === 3) { - // this.HandleInputTopics(this.contentMdRef.current.getValue().trim(),indexo); - - //插入主观题 - 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": this.contentMdRef.current.getValue().trim(), - "question_type": 3, - "new": "", - "answers": answers - }; - question = {"question": questiontwo}; - if (uuk !== -1) { - // console.log("修改") - this.edittotheserver(object, 3, null, null, 0, 0,0); - newarrpoll.splice(uuk, 1, question); - } else { - // console.log("删除") - this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id,0); - 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 (bool === true) { - this.setState({ - bindingid: undefined, - }) - } - //这里更新数据 - if (this.state.q_countst == 1) { - this.setState({ - q_countst: 0, - }) - } - this.Deleteadddom(indexo); - this.setState({ - boolneweied:undefined - }) - } - - - ////新增到服务器中 - createquestionsandanswers = (object, number, option, other, max_choices, min_choices, insert_id,length) => { - var thiss = this; - var poll_id = this.state.pollid; - var urlly = `/poll_bank_questions.json`; - var max_choicess = null; - var min_choicess = null; - try { - if (max_choices === 0 && min_choices === 0) { - max_choicess = null; - min_choicess = null; - } else { - max_choicess = max_choices; - min_choicess = min_choices; - } - }catch (e) { - max_choicess = null; - min_choicess = null; - } - var datay={}; - datay={ - exercise_bank_id: poll_id, - question_title: object.question.question_title, - question_type: number, - is_necessary: object.question.is_necessary, - question_answers: option, - question_other_answer: null, - insert_id: insert_id - } - try { - if(number===2){ - datay={ - exercise_bank_id: poll_id, - question_title: object.question.question_title, - question_type: number, - is_necessary: object.question.is_necessary, - max_choices: max_choicess===undefined||max_choicess===null||max_choicess===0||max_choicess==="0"?null:max_choicess, - min_choices: min_choicess===undefined||min_choicess===null||min_choicess===0||min_choicess==="0"?null:min_choicess, - question_answers: option, - question_other_answer: null, - insert_id: insert_id - } - } - }catch (e) { - - } - - axios.post(urlly,datay).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,length) => { - // console.log("调用了edittotheserver") - var url = `/poll_bank_questions/${object.question.id}.json` - var thiss = this; - var max_choicess = null; - var min_choicess = null; - try { - if (max_choices === 0 && min_choices === 0) { - max_choicess = null; - min_choicess = null; - } else { - max_choicess = max_choices; - min_choicess = min_choices; - } - }catch (e) { - max_choicess = null; - min_choicess = null; - } - var datay={}; - datay={ - // debug: true, - question_title: object.question.question_title, - question_type: number, - is_necessary: object.question.is_necessary, - question_answers: option, - question_other_answer: null, - }; - try { - if(number===2){ - datay={ - // debug: true, - question_title: object.question.question_title, - question_type: number, - is_necessary: object.question.is_necessary, - max_choices: max_choicess===undefined||max_choicess===null||max_choicess===0||max_choicess==="0"?null:max_choicess, - min_choices: min_choicess===undefined||min_choicess===null||min_choicess===0||min_choicess==="0"?null:min_choicess, - question_answers: option, - question_other_answer: null, - }; - } - }catch (e) { - - } - - axios.put(url,datay).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 = `/exercise_bank_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,index) => { - // console.log("调用了Upanddownmovementofr") - // console.log(poll_question_id) - var thiss = this; - if (bool === true) { - var url = `/exercise_bank_questions/${poll_question_id}/up_down.json`; - axios.put(url, { - opr: "up", - }).then((result) => { - - try { - if(result){ - if(result.data){ - if (result.data.status === 0) { - this.props.showNotification(`上移成功`); - // let arr = this.state.poll_questions; - // let newarr = [...arr]; - // let temp = newarr[index - 1]; - // newarr[index - 1] = newarr[index]; - // newarr[index] = temp; - // this.setState({ - // poll_questions: newarr, - // }); - thiss.thisinitializationdatanew(); - }else{ - this.props.showNotification(`上移失败`); - } - } - }else { - this.props.showNotification(`上移失败`); - } - } catch (e) { - this.props.showNotification(`上移失败`); - console.log(e) - } - - }) - } else { - var url = `/exercise_bank_questions/${poll_question_id}/up_down.json`; - axios.put(url, { - opr: "down", - }).then((result) => { - - try { - if(result){ - if(result.data){ - if (result.data.status === 0) { - // message.success("下移题目成功", 1) - this.props.showNotification(`下移成功`); - // let arr = this.state.poll_questions; - // let newarr = [...arr]; - // let temp = newarr[index + 1]; - // newarr[index + 1] = newarr[index]; - // newarr[index] = temp; - // this.setState({ - // poll_questions: newarr, - // }); - thiss.thisinitializationdatanew(); - }else { - this.props.showNotification(`下移失败`); - } - }else { - this.props.showNotification(`上移失败`); - } - } - } catch (e) { - this.props.showNotification(`上移失败`); - 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") - - // console.log(newarr) - if (index != 0) { - this.Upanddownmovementof(true, object.question.id,index); - - } - } - - //点击向下排序按钮事件 - 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,index); - - } 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" + " " + e); - console.log("handleInputChanges" + " " + i); - console.log("handleInputChanges" + " " + 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 - }) - } - - HandleInputTopics = (value, i) => { - console.log("handleInputTopic 633") - console.log(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) => { - // console.log("最小值"); - // console.log(value); - // console.log(index); - // console.log(max); - // console.log(length); - - - 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; - break; - } - } - this.setState({ - adddom: arr - }) - // } - - } - - //最大值 - HandleGradationGroupChangeee = (value, index,minchoices,length) => { - // console.log("2112"); - // console.log(value); - // console.log(minchoices); - // console.log("最大值"); - // console.log(value); - // console.log(index); - // console.log(minchoices); - // console.log(length); - let arr = this.state.adddom; - for (var i = 0; i < arr.length; i++) { - if (index === i) { - // if(parseInt(value)===0&&parseInt(minchoices)===0){ - // arr[i].question.min_choices= parseInt(0); - // arr[i].question.max_choices = parseInt(0); - // }else if(parseInt(minchoices)===0){ - // arr[i].question.min_choices= parseInt(2); - // arr[i].question.max_choices = parseInt(value); - // } - // else if(parseInt(value)===0&&parseInt(minchoices)>0){ - // arr[i].question.min_choices= parseInt(minchoices); - // arr[i].question.max_choices = parseInt(value); - // } - // else { - // arr[i].question.min_choices= minchoices===null?2:minchoices===undefined?2:minchoices===0?2:parseInt(minchoices); - arr[i].question.max_choices = parseInt(value); - // } - } - } - // console.log(2119); - // console.log(arr); - this.setState({ - adddom: arr - }) - // console.log(this.state.adddom); - } - - //提交题目//没有就创建新的题库,新建问newz题和保存题目不一样不能同时保存 这里只是新建 和编辑 标题和须知 - submitQuestionnaire = () => { - if (this.state.polls_nametest === undefined || this.state.polls_nametest === "") { - this.props.showNotification("请输入标题"); - return - } - if(this.state.poll_questions&&this.state.poll_questions.length===0){ - this.props.showNotification("至少创建1个题目"); - return; - } - - this.props.history.push(`/banks/poll/${this.props.match.params.workid}/${this.props.match.params.type}`); - // this.props.initPublic(undefined); - // 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.workid; - // } else { - // pollid = this.state.pollid; - // } - // - // // if(mews ==="new"){ - // if (this.state.poll_questions && this.state.poll_questions.length === 0) { - // this.props.showNotification("至少创建1个题目"); - // return; - // } - // // } - // - // 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("保存成功"); - // - // } - // } 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, - // }); - // // var currenturl = window.location.href; - // // var newUrl = (currenturl.split("?"))[0]; - // // var newr=(newUrl.slice("new"))[0]; - // // console.log(newUrl); - // // console.log("2301"); - // // console.log(newr); - // // window.history.pushState('','',newUrl+'?tab='+e); - // // window.location.href = `/courses/${coursesId}/polls/${result.data.data.id}/edit`; - // - // }) - // } else { - if (this.state.polls_nametest === undefined || this.state.polls_nametest === "") { - this.props.showNotification("请输入标题"); - return - } - - var pollid; - if (this.state.pollid === undefined) { - pollid = this.props.match.params.workid; - } else { - pollid = this.state.pollid; - } - - - var url = `/exercise_banks/${pollid}.json`; - axios.put(url, { - exercise_name: this.state.polls_nametest, - exercise_description: this.state.polls_descriptiontest - }).then((result) => { - if (result !== undefined) { - this.props.showNotification(`问卷更新成功!`); - this.setState({ - mysave: false, - readOnlys: "readOnly", - }) - } - - }) - // } - - } - gotohome = () => { - // const { current_user} = this.props - if (this.state.first_category_url) { - window.location.href = this.state.first_category_url; - } else { - this.props.history.goBack(); - } - - // - // let courseId=this.props.match.params.coursesId; - // if(courseId===undefined){ - // this.props.history.push("/classrooms"); - // }else{ - // this.props.history.push(this.props.current_user.first_category_url); - // } - } - //试图 - toWorkDetail = () => { - // console.log(this.props); - // console.log("toWorkDetail"); - this.props.history.push(`/banks/poll/${this.props.match.params.workid}/${this.props.match.params.type}`); - // this.props.initPublic(undefined); - }; - //跳转道描点的地方 - // scrollToAnchor = (anchorName) => { - // if (anchorName) { - // // 找到锚点 - // let anchorElement = document.getElementById(anchorName); - // // 如果对应id的锚点存在,就跳转到锚点 - // if(anchorElement) { anchorElement.scrollIntoView(false); } - // } - // } - - scrollToAnchor=(index)=>{ - // let name="Anchor_"+index; - console.log("scrollToAnchor"); - console.log(index); - if (index) { - let anchorElement = document.getElementById(index); - // if(anchorElement) { anchorElement.scrollIntoView(); } - $("html").animate({ scrollTop: $(anchorElement).offset().top - 150}) - } - } - render() { - let { - addonAfter, - user_permission, - polls_status, - Modalstype, - mysave, - readOnlys, - newoption, - cancellation, - left_banner_id, - addonAftertwo - } = this.state - //获取老师权限 - // console.log("[`${maps[polls_status && polls_status]}`]]"); - // console.log(polls_status); - // console.log([[`${maps[polls_status && polls_status]}`]] + ""); - - // 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.gotohome()}>{this.props.coursedata.name}*/} - {/* >*/} - {/*{*/} - {/* 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.props.match.params.news === "new" ?*/} - {/* 返回*/} - {/* :*/} - {/**/} - {/*}*/} - {/*
    */} - - {/*
    */} - { - this.state.mysave === false ? -
    - -
    - -
    - : "" - } - { - this.state.mysave === true ? -
    -
    - - -
    -
    *问卷标题 -
    - { - // this.props.match.params.news === undefined ? "" : this.props.match.params.news === "new" ? - // ( - this.state.mysave === false ? - - : "" - // ) - // :"" - } - -
    - {/*suffix={String(addonAfter)}*/} - - - -
    -
    - - -
    问卷须知
    - - - {/**/} - { - 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.q_counts === undefined ? "" : this.state.q_counts} -
    - - } - -

    - - -
    - - {/*自动生成修改好的获取到的*/} - {/**************************************************************************/} - {this.state.poll_questions === undefined ? "" : this.state.poll_questions.map((item, index) => { - console.log('打印this.state.poll_questions'); - console.log(this.state.poll_questions); - console.log(this.state.adddom); - 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.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 === "null" && item.question.max_choices === "null" ? "" : item.question.min_choices === item.question.max_choices && item.question.max_choices === item.question.min_choices ? "可选"+(item.question.max_choices)+"项" : "可选" +(item.question.min_choices===undefined||item.question.min_choices===null||item.question.min_choices===""||item.question.min_choices==="null"?2:item.question.min_choices) + "-" + (item.question.max_choices===undefined||item.question.max_choices===null||item.question.max_choices===""||item.question.max_choices==="null"?item.question.answers.length: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,index)}> - this.adddomedit(item,index)}> - : this.adddomedit(item,index)}> - } - -

    -

    {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} - -
    - ) - })} -
    - {/*单选题*/} - - -
    - : item.question.question_type === 2 ? -
    - - {item.question.answers === undefined ? "" : item.question.answers.map((items, i) => { - return ( -
    - - {items.answer_text} -
    - ) - })} -
    - {/*多选题*/} -
    - - : item.question.question_type === 3 ? - // 主观题 - (
    - -
    ) : (
    )} -
    - - return ( -
    - {/*这里是编辑和新增的地方*/} - { - this.state.bindingid && this.state.bindingid === item.question.id ? - (this.state.Newdisplay === false ? -
    -
    - {this.state.adddom === undefined ? "" : this.state.adddom === undefined ? "" : this.state.adddom.length === 0 ? "" : item.question.id === this.state.adddom[0].question.id && this.state.adddom.map((itemo, indexo) => { - let arrid = itemo.question.id; - let resultDomtwo; - resultDomtwo = -
    - {/*{itemo&&itemo.question&&itemo.question.question_number}、*/} - {itemo.question.question_type === 1 ? "单选题" : itemo.question.question_type === 2 ? "多选题" : "主观题"} - this.OnCheckAllChange(e, indexo)} - className="lineh-40" - style={{"marginLeft": "20px"}}>必答 - - - { - itemo.question.question_type === 3 ? - - : - - - } - {itemo.question.answers === undefined ? "" : itemo.question.answers.map((itemt, indext) => { - return ( -
    - {itemt.answer_text === undefined ? ( -
    ) : itemt.answer_text === "其他" ? ( -

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

    ) : (

    - 选项 - - - {this.state.polls_status === undefined || this.state.polls_status === 1 ? - // (itemo.question.question_type === 2 && itemo.question.answers.length === 3 ? - // (indext ===1? - // this.Ewoption(itemo.question.id, itemo)}> - // : - // "" - // ) - // "" - // : - itemo.question.answers.length > 2 &&indext>=1? - - { - indext > 1 ? - this.Deleteentrys(arrid, indext, false)}> - :"" - } - { - itemo.question.answers[itemo.question.answers.length - 1].answer_text === "其他" && itemo.question.answers.length - 2 === indext ? - - this.Ewoption(itemo.question.id, itemo)}> - : itemo.question.answers.length - 1 === indext ? - this.Ewoption(itemo.question.id, itemo)}> - : - } - - :itemo.question.answers.length === 2? - (indext ===1? - this.Ewoption(itemo.question.id, itemo)}> - :"") - // : "") - : "":""} -

    )} -
    - ) - })} - -
    - {itemo.question.question_type === 1 ? ( -
    - {/* this.Ewoption(itemo.question.id, itemo)}>新增选项*/} -
    - {this.state.polls_status === undefined || this.state.polls_status === 1 ? - "" - : ""} - {this.state.polls_status === undefined || this.state.polls_status === 1 ? - - (this.state.newoption === false ? - this.Addanotheroption(itemo.question.id)}>添加[其它]选项 - : "") - : ""} - - this.Deleteadddom(indexo, true)}>取消 - this.Deleteadddomtwo(indexo, itemo, true)}>保存并继续 - this.Deleteadddomthree(indexo, itemo, true)}>保存并退出 - -
    -
    - - - ) - - - : itemo.question.question_type === 2 ? ( - //////////////////////////////////////////// 可选 -
    -
    - {this.state.polls_status === undefined || this.state.polls_status === 1 ? - - (this.state.newoption === false ? - this.Addanotheroption(itemo.question.id)}>添加[其它]选项 - : "") - : ""} -
    - 可选 -
    - {/*可选最小1*/} - - - ~ - {/*可选最大1*/} - - - (学生答题时,系统对其选择的选项个数进行限制,--表示不限制) - - this.Deleteadddom(indexo, true)}>取消 - this.Deleteadddomtwo(indexo, itemo, true)}>保存并继续 - this.Deleteadddomthree(indexo, itemo, true)}>保存并退出 - -
    - -
    -
    -
    - ) - - : (
    ) - - } -
    -
    - {itemo.question.question_type === 2 ? - // ( - // this.state.polls_status === undefined || this.state.polls_status === 1 ? - //
    - // - // {/*
    this.Ewoption(itemo.question.id, itemo)}>新增选项*/} - // - // {/* {*/} - // {/* this.state.newoption === false ? this.Addanotheroption(itemo.question.id)}>新增其他选项 : ""*/} - // {/* }*/} - // - // {/*
    */} - // - // - // - // this.Deleteadddom(indexo,true)}>取消 - // this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 - // this.Deleteadddomthree(indexo, itemo,true)}>保存并退出 - // - //
    - // - // - // : - //
    - // - // this.Deleteadddom(indexo,true)}>取消 - // this.Deleteadddomtwo(indexo, itemo,true)}>保存并继续 - // this.Deleteadddomthree(indexo, itemo,true)}> 保存并退出 - // - //
    - // ) - "" - : itemo.question.question_type === 3 ? -
    - - this.Deleteadddom(indexo, true)}>取消 - this.Deleteadddomtwo(indexo, itemo, true)}>保存并继续 - this.Deleteadddomthree(indexo, itemo, true)}>保存并退出 - -
    - : - ""} - - -
    -
    - - - return ( -
    - {resultDomtwo} -
    - ) - })} -
    -
    : "") - : - // 编辑 -
    - {resultDom} - {this.state.Newdisplay === false ? - -
    - {this.state.adddom === undefined ? "" : this.state.adddom === undefined ? "" : this.state.adddom.length === 0 ? "" : item.question.id === this.state.adddom[0].question.id && this.state.adddom.map((itemo, indexo) => { - let arrid = itemo.question.id; - let resultDomtwo; - resultDomtwo = -
    - {/*{itemo&&itemo.question&&itemo.question.question_number}、*/} - - {itemo.question.question_type === 1 ? "单选题" : itemo.question.question_type === 2 ? "多选题" : "主观题"} - this.OnCheckAllChange(e, indexo)} - className="lineh-40" - style={{"marginLeft": "20px"}}>必答 - - { - itemo.question.question_type === 3 ? - - : - - - } - {itemo.question.answers === undefined ? "" : itemo.question.answers.map((itemt, indext) => { - // console.log("chishiyong1"); - // console.log(itemo.question.answers[itemo.question.answers.length - 1]); - // var bools=true; - // if(){ - // - // } - return ( -
    - {itemt.answer_text === undefined ? ( -
    ) : itemt.answer_text === "其他" ? ( -

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

    ) : (

    - 选项 - - - {this.state.polls_status === undefined || this.state.polls_status === 1 ? - // ( itemo.question.question_type === 2 && itemo.question.answers.length === 3 ? - // (indext ===1? - // this.Ewoption(itemo.question.id, itemo)}> - // :"") - itemo.question.answers.length > 2 && indext>=1 ? - - { - indext > 1 ? - this.Deleteentrys(arrid, indext, false)}> - :"" - } - { - itemo.question.answers[itemo.question.answers.length - 1].answer_text === "其他" && itemo.question.answers.length - 2 === indext ? - this.Ewoption(itemo.question.id, itemo)}> - : itemo.question.answers.length - 1 === indext ? - this.Ewoption(itemo.question.id, itemo)}> - : - - } - - :itemo.question.answers.length === 2 && indext ===1 ? - (indext ===1? - this.Ewoption(itemo.question.id, itemo)}> - :"") - // : "") - : "":""} -

    )} -
    - ) - })} - -
    - {itemo.question.question_type === 1 ? ( -
    - {/* this.Ewoption(itemo.question.id, itemo)}>新增选项*/} -
    - {this.state.polls_status === undefined || this.state.polls_status === 1 ? - "" - : ""} - {this.state.polls_status === undefined || this.state.polls_status === 1 ? - - (this.state.newoption === false ? - this.Addanotheroption(itemo.question.id)}>添加[其它]选项 - : "") - : ""} - - this.Deleteadddom(indexo, true)}>取消 - this.Deleteadddomtwo(indexo, itemo, true)}>保存并继续 - this.Deleteadddomthree(indexo, itemo, true)}>保存并退出 - -
    -
    - - - ) - - - : itemo.question.question_type === 2 ? ( - //////////////////////////////////////////// 可选 -
    -
    - {this.state.polls_status === undefined || this.state.polls_status === 1 ? - - (this.state.newoption === false ? - this.Addanotheroption(itemo.question.id)}>添加[其它]选项 - : "") - : ""} -
    - 可选 -
    - {/*可选最小2*/} - - - ~ - {/*可选最大2*/} - - - (学生答题时,系统对其选择的选项个数进行限制,--表示不限制) - - this.Deleteadddom(indexo, true)}>取消 - this.Deleteadddomtwo(indexo, itemo, true)} - >保存并继续 - this.Deleteadddomthree(indexo, itemo, true)}>保存并退出 - -
    - -
    -
    -
    - ) - - : (
    ) - - } -
    -
    - {itemo.question.question_type === 2 ? - // ( - // this.state.polls_status === undefined || this.state.polls_status === 1 ? - //
    - // - //
    this.Ewoption(itemo.question.id, itemo)}>新增选项 - // - // { - // this.state.newoption === false ? this.Addanotheroption(itemo.question.id)}>新增其他选项 : "" - // } - // - //
    - // - // - // - // this.Deleteadddom(indexo,true)}>取消 - // this.Deleteadddomtwo(indexo, itemo,true)} - // >保存并继续 - // this.Deleteadddomthree(indexo, itemo,true)}>保存并退出 - // - //
    - // - // - // : - //
    - // - // this.Deleteadddom(indexo,true)}>取消 - // this.Deleteadddomtwo(indexo, itemo,true)} - // >保存并继续 - // this.Deleteadddomthree(indexo, itemo,true)}> 保存并退出 - // - //
    - // ) - "" - - : itemo.question.question_type === 3 ? -
    - - this.Deleteadddom(indexo, true)}>取消 - this.Deleteadddomtwo(indexo, itemo, true)} - >保存并继续 - this.Deleteadddomthree(indexo, itemo, true)}> 保存并退出 - -
    - : - ""} - - -
    -
    - - - return ( -
    - {resultDomtwo} -
    - ) - })} -
    : ""} -
    - } -
    - - ) - })} - - - {/*新建单选多选2*/} -
    - { - this.state.Newdisplay === true ? -
    - {this.state.adddom === undefined ? "": this.state.adddom.map((itemo, indexo) => { - // console.log('打印this.state.adddom') - // console.log(this.state.adddom); - let arrid = itemo.question.id; - let resultDomtwo; - resultDomtwo = -
    - {/*{itemo&&itemo.question&&itemo.question.question_number}、*/} - {itemo.question.question_type === 1 ? "单选题" : itemo.question.question_type === 2 ? "多选题" : "主观题"} - this.OnCheckAllChange(e, indexo)} - className="lineh-40" - style={{"marginLeft": "20px"}}>必答 - - { - itemo.question.question_type === 3 ? - - : - - } - - - {itemo.question.answers === undefined ? "" : itemo.question.answers.map((itemt, indext) => { - console.log("ceshiyong2"); - console.log(itemo.question.answers.length - 1); - 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 ? - // (itemo.question.question_type === 2&& itemo.question.answers.length === 3 ? - // (itemo.question.answers[itemo.question.answers.length-1].answer_text === "其他" &&indext ===1? - // this.Ewoption(itemo.question.id, itemo)}> - // :itemo.question.answers[itemo.question.answers.length-1].answer_text === "选项" &&indext ===1? - // this.Ewoption(itemo.question.id, itemo)}> - // :"") - // : - itemo.question.answers.length > 2 && indext>=1 ? - - { - indext>1? - this.Deleteentrys(arrid, indext, false)}> - :"" - } - - { - - itemo.question.answers[itemo.question.answers.length - 1].answer_text === "其他" && itemo.question.answers.length - 2 === indext ? - this.Ewoption(itemo.question.id, itemo)}> - : - itemo.question.answers.length - 1 === indext ? - this.Ewoption(itemo.question.id, itemo)}> - : - - - } - - : itemo.question.answers.length === 2? - (indext ===1? - this.Ewoption(itemo.question.id, itemo)}> - :"") - : "":""} -

    )} -
    - ) - })} - -
    - {itemo.question.question_type === 1 ? ( -
    - {/* this.Ewoption(itemo.question.id, itemo)}>新增选项*/} -
    - {this.state.polls_status === undefined || this.state.polls_status === 1 ? - "" - : ""} - {this.state.polls_status === undefined ||this.state.polls_status === 1 ? - - (this.state.newoption === false ? - this.Addanotheroption(itemo.question.id)}>添加[其它]选项 - : "") - : ""} - - this.Deleteadddom(indexo)}>取消 - this.Deleteadddomtwo(indexo, itemo)} - > 保存并继续 - this.Deleteadddomthree(indexo, itemo)}>保存并退出 - -
    -
    - - - ) - - - : itemo.question.question_type === 2 ? ( - //////////////////////////////////////////// 可选 -
    -
    - {this.state.polls_status === undefined || this.state.polls_status === 1 ? - - (this.state.newoption === false ? - this.Addanotheroption(itemo.question.id)}>添加[其它]选项 - : "") - : ""} -
    - 可选 -
    - {/*可选最小3*/} - - - ~ - {/*可选最大3*/} - - - (学生答题时,系统对其选择的选项个数进行限制,--表示不限制) - - this.Deleteadddom(indexo)}>取消 - this.Deleteadddomtwo(indexo, itemo)} - >保存并继续 - this.Deleteadddomthree(indexo, itemo)}> 保存并退出 - -
    - -
    -
    -
    - ) - - : (
    ) - - } -
    -
    - {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.Deleteadddomtwo(indexo, itemo)} - // >保存并继续 - // this.Deleteadddomthree(indexo, itemo)}> 保存并退出 - // - //
    - // - // - // : - //
    - // - // this.Deleteadddom(indexo)}>取消 - // this.Deleteadddomtwo(indexo, itemo)} - // > 保存并继续 - // this.Deleteadddomthree(indexo, itemo)}>保存并退出 - // - //
    - // ) - "" - : itemo.question.question_type === 3 ? -
    - - this.Deleteadddom(indexo)}>取消 - this.Deleteadddomtwo(indexo, itemo)} - >保存并继续 - this.Deleteadddomthree(indexo, itemo)}>保存并退出 - -
    - : - ""} - - -
    -
    - - - return ( -
    - {resultDomtwo} -
    - ) - })} -
    - : - "" - } - {polls_status === undefined || polls_status === 1 ? -
    -
    - this.addmysingles()}>单选题 - this.addmydoubles()}>多选题 - this.addmymainsint()}>主观题 -
    -
    - :
    } -
    -
    - - {/**/} -
    -
    -
    - ) - } - -} - -// RouteHOC() -export default PollNewQuestbank -{/*
    */ -} -{/* {*/ -} -{/* 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 ?*/ -} -{/* */ -} -{/*
  • */ -} -{/* this.props.history.goBack()}>取消*/ -} -{/* this.submitQuestionnaire(this.props.match.params.news)}>提交*/ -} -{/*
  • */ -} - - -{/* */ -} - -{/* : "")*/ -} -{/* :*/ -} -{/* */ -} -{/*}*/ -} diff --git a/src/modules/courses/poll/pollPublicBtn/CancelPublish.js b/src/modules/courses/poll/pollPublicBtn/CancelPublish.js deleted file mode 100644 index 11451e9e..00000000 --- a/src/modules/courses/poll/pollPublicBtn/CancelPublish.js +++ /dev/null @@ -1,205 +0,0 @@ -import React,{ Component } from "react"; - - -import Modals from '../../../modals/Modals' -import { WordsBtn } from 'educoder' -import HomeworkModal from "../../coursesPublic/HomeworkModal"; - -import axios from 'axios' -import moment from 'moment'; - - - -class CancelPublish extends Component{ - constructor(props){ - super(props) - this.state={ - modalname:undefined, - modaltype:undefined, - visible:false, - Topval:undefined, - Topvalright:undefined, - Botvalleft:undefined, - Botval:undefined, - starttime:undefined, - endtime:undefined, - Cancelname:undefined, - Savesname:undefined, - Cancel:undefined, - Saves:undefined, - course_groups:undefined, - - modalsType:false, - modalsTopval:"", - loadtype:false, - chooseId:undefined - } - } - //撤销发布 - homeworkstart=()=>{ - let {checkBoxValues}=this.props - if(checkBoxValues.length==0){ - this.props.showNotification("请先在列表中选择数据"); - // this.setState({ - // modalsType:true, - // modalsTopval:"请先在列表中选择数据", - // loadtype:true - // }) - }else{ - let pollId=this.props.match.params.pollId; - let url=`/polls/${pollId}/cancel_publish_modal.json`; - - axios.get(url,{ - params:{ - check_ids:checkBoxValues - } - }).then((response) => { - if(response.status===200){ - let list=[]; - if(response.data.course_info){ - for(var i=0;i 0 ? 1 : 2, - visible:true, - Topval:"将删除学生已提交的全部作品及其评阅记录", - // Botvalleft:"", - Botval:"删除的作品记录无法恢复", - // starttime:"发布时间:"+getNowFormatDate(1), - // endtime:"截止时间:"+getNowFormatDate(2), - Cancelname:"暂不撤销", - Savesname:"立即撤销", - Cancel:this.homeworkhide, - Saves:this.homeworkstartend, - }) - } - }).catch((error) => { - console.log(error) - }); - - } - } - - //取消提示弹框 - modalCancel=()=>{ - this.setState({ - modalsType:false, - modalsTopval:"", - loadtype:false - }) - } - //暂不发布 - homeworkhide=()=>{ - this.setState({ - modalname:undefined, - modaltype:undefined, - visible:false, - Topval:undefined, - Topvalright:undefined, - Botvalleft:undefined, - Botval:undefined, - starttime:undefined, - endtime:undefined, - Cancelname:undefined, - Savesname:undefined, - Cancel:undefined, - Saves:undefined, - StudentList_value:undefined, - addname:undefined, - addnametype:false, - addnametab:undefined - }) - } - // 确定撤销发布 - homeworkstartend=()=>{ - let {checkBoxValues}=this.props - let {chooseId}=this.state; - let pollId=this.props.match.params.pollId; - let url=`/polls/${pollId}/cancel_publish.json` - axios.post(url,{ - check_ids:checkBoxValues, - group_ids:chooseId - }).then((result)=>{ - if(result.status==200){ - this.props.showNotification(result.data.message); - this.homeworkhide(); - - // 调用父级公共头部的接口刷新 - this.props.action() - } - }).catch((error)=>{ - console.log(error); - }) - } - - getcourse_groupslist=(id)=>{ - this.setState({ - chooseId:id - }) - } - - render(){ - let{ - modalname, - modaltype, - visible, - Topval, - Topvalright, - Botvalleft, - Botval, - starttime, - endtime, - Cancelname, - Savesname, - Cancel, - Saves, - course_groups, - - modalsType, - modalsTopval, - loadtype, - }=this.state - return( - - this.getcourse_groupslist(id)} - /> - {/* 公用的提示弹框 */} - - - 撤销发布 - - ) - } -} -export default CancelPublish \ No newline at end of file diff --git a/src/modules/courses/poll/pollPublicBtn/ImmediatelyEnd.js b/src/modules/courses/poll/pollPublicBtn/ImmediatelyEnd.js deleted file mode 100644 index 00cb1783..00000000 --- a/src/modules/courses/poll/pollPublicBtn/ImmediatelyEnd.js +++ /dev/null @@ -1,269 +0,0 @@ -import React,{ Component } from "react"; - - -import Modals from '../../../modals/Modals' -import { WordsBtn } from 'educoder' -import HomeworkModal from "../../coursesPublic/HomeworkModal"; - -import axios from 'axios' -import moment from 'moment'; - - -class ImmediatelyEnd extends Component{ - constructor(props){ - super(props) - this.state={ - modalname:undefined, - modaltype:undefined, - visible:false, - Topval:undefined, - Topvalright:undefined, - Botvalleft:undefined, - Botval:undefined, - starttime:undefined, - endtime:undefined, - Cancelname:undefined, - Savesname:undefined, - Cancel:undefined, - Saves:undefined, - course_groups:undefined, - - modalsType:false, - modalsTopval:"", - loadtype:false, - chooseId:undefined - } - } - //立即截止 - homeworkstart=()=>{ - let {checkBoxValues}=this.props - if(checkBoxValues.length==0){ - this.props.showNotification("请先在列表中选择数据"); - // this.setState({ - // modalsType:true, - // modalsTopval:"请先在列表中选择数据", - // loadtype:true - // }) - }else{ - let coursesId=this.props.match.params.coursesId; - if(this.props.Exercisetype==="exercise"){ - let url=`/courses/${coursesId}/exercises/end_modal.json`; - axios.get(url,{ - params:{ - check_ids:checkBoxValues - } - }).then((response) => { - if(response.status===200){ - let list=[]; - if(response.data.course_info){ - for(var i=0;i 0 ? 1 : 2, - visible:true, - Topval:this.props.Exercisetype==="exercise"?"学生将不能再提交试卷":"学生将不能再提交问卷", - // Botvalleft:"暂不截止", - Botval:this.props.single ?this.props.Exercisetype==="exercise"?`本操作只对"提交中"的试卷有效`:`本操作只对"提交中"的问卷有效`:"", - // starttime:"发布时间:"+getNowFormatDate(1), - // endtime:"截止时间:"+getNowFormatDate(2), - Cancelname:"暂不截止", - Savesname:"立即截止", - Cancel:this.homeworkhide, - Saves:this.homeworkstartend, - }) - } - }).catch((error) => { - console.log(error) - }); - - - - }else{ - let url=`/courses/${coursesId}/polls/end_poll_modal.json`; - - axios.get(url,{ - params:{ - check_ids:checkBoxValues - } - }).then((response) => { - if(response.status===200){ - let list=[]; - if(response.data.course_info){ - for(var i=0;i 0 ? 1 : 2, - visible:true, - Topval:this.props.Exercisetype==="exercise"?"学生将不能再提交试卷":"学生将不能再提交问卷", - // Botvalleft:"暂不截止", - Botval:this.props.single ?this.props.Exercisetype==="exercise"?`本操作只对"提交中"的试卷有效`:`本操作只对"提交中"的问卷有效`:"", - // starttime:"发布时间:"+getNowFormatDate(1), - // endtime:"截止时间:"+getNowFormatDate(2), - Cancelname:"暂不截止", - Savesname:"立即截止", - Cancel:this.homeworkhide, - Saves:this.homeworkstartend, - }) - } - }).catch((error) => { - console.log(error) - }); - } - - - } - } - - //取消提示弹框 - modalCancel=()=>{ - this.setState({ - modalsType:false, - modalsTopval:"", - loadtype:false - }) - } - //暂不发布 - homeworkhide=()=>{ - this.setState({ - modalname:undefined, - modaltype:undefined, - visible:false, - Topval:undefined, - Topvalright:undefined, - Botvalleft:undefined, - Botval:undefined, - starttime:undefined, - endtime:undefined, - Cancelname:undefined, - Savesname:undefined, - Cancel:undefined, - Saves:undefined, - StudentList_value:undefined, - addname:undefined, - addnametype:false, - addnametab:undefined - }) - } - // 确定立即截止 - homeworkstartend=()=>{ - - let {checkBoxValues}=this.props - let {chooseId}=this.state; - let coursesId=this.props.match.params.coursesId; - if(this.props.Exercisetype==="exercise"){ - let url=`/courses/${coursesId}/exercises/end_exercise.json` - axios.post(url,{ - check_ids:checkBoxValues, - group_ids:chooseId - }).then((result)=>{ - if(result){ - this.props.showNotification(result.data.message); - this.homeworkhide(); - // 调用父级公共头部的接口刷新 - this.props.action() - } - }).catch((error)=>{ - console.log(error); - }) - }else{ - let url=`/courses/${coursesId}/polls/end_poll.json` - axios.post(url,{ - check_ids:checkBoxValues, - group_ids:chooseId - }).then((result)=>{ - if(result){ - this.props.showNotification(result.data.message); - this.homeworkhide(); - // 调用父级公共头部的接口刷新 - this.props.action() - } - }).catch((error)=>{ - console.log(error); - }) - } - - - - } - - getcourse_groupslist=(id)=>{ - this.setState({ - chooseId:id - }) - } - - render(){ - let{ - modalname, - modaltype, - visible, - Topval, - Topvalright, - Botvalleft, - Botval, - starttime, - endtime, - Cancelname, - Savesname, - Cancel, - Saves, - course_groups, - - modalsType, - modalsTopval, - loadtype, - }=this.state - return( - - this.getcourse_groupslist(id)} - /> - {/* 公用的提示弹框 */} - - - 立即截止 - - ) - } -} -export default ImmediatelyEnd \ No newline at end of file diff --git a/src/modules/courses/poll/pollPublicBtn/ImmediatelyPublish.js b/src/modules/courses/poll/pollPublicBtn/ImmediatelyPublish.js deleted file mode 100644 index bbc61702..00000000 --- a/src/modules/courses/poll/pollPublicBtn/ImmediatelyPublish.js +++ /dev/null @@ -1,413 +0,0 @@ -import React,{ Component } from "react"; - - -import Modals from '../../../modals/Modals' -import { WordsBtn } from 'educoder' -import HomeworkModal from "../../coursesPublic/HomeworkModal"; -import OneSelfOrderModal from "../../coursesPublic/OneSelfOrderModal"; -import axios from 'axios' -import moment from 'moment'; - - - - - -class Immediatelypublish extends Component{ - constructor(props){ - super(props) - this.state={ - modalname:undefined, - modaltype:undefined, - visible:false, - Topval:undefined, - Topvalright:undefined, - Botvalleft:undefined, - Botval:undefined, - starttime:undefined, - starttimes:undefined, - endtime:undefined, - Cancelname:undefined, - Savesname:undefined, - Cancel:undefined, - Saves:undefined, - course_groups:undefined, - - modalsType:false, - modalsTopval:"", - loadtype:false, - chooseId:undefined, - immediatelyopen:false - } - } - //立即发布 - homeworkstart=()=>{ - let {checkBoxValues,pushtype}=this.props - - - if(pushtype===true){ - if(checkBoxValues.length==0){ - this.props.showNotification("请先在列表中选择数据"); - // this.setState({ - // modalsType:true, - // modalsTopval:"请先在列表中选择数据", - // loadtype:true - // }) - }else{ - let coursesId=this.props.match.params.coursesId; - if(this.props.Exercisetype==="exercise"){ - let url=`/exercises/${this.props.match.params.Id}/publish_groups.json`; - axios.get(url).then((response) => { - if (response.data) { - let starttimesend=response.data.end_time === undefined || response.data.end_time === null || response.data.end_time === "" ? undefined : response.data.end_time; - - this.setState({ - modalname:"立即发布", - modaltype:response.data.course_groups===null||response.data.course_groups.length===0?2:1, - Topval:this.props.Exercisetype==="exercise"?"学生将立即收到试卷":"学生将立即收到问卷", - // Botvalleft:"暂不发布", - Botval:this.props.single ? "":this.props.Exercisetype==="exercise"?`本操作只对"未发布"的试卷有效`:`本操作只对"未发布"的问卷有效`, - starttime:moment(moment(new Date())).format("YYYY-MM-DD HH:mm"), - starttimes:this.props.getNowFormatDates(1), - endtime:"截止时间:"+this.props.getNowFormatDates(2), - Cancelname:"暂不发布", - Savesname:"立即发布", - Cancel:this.homeworkhide, - Saves:this.homeworkstartend, - course_groups:response.data.course_groups, - starttimesend:starttimesend, - immediatelyopen:response.data.course_groups===null||response.data.course_groups.length===0?false:true, - OneSelftype:true, - }) - - } - }).catch((error) => { - console.log(error) - }); - }else{ - let url=`/polls/${this.props.match.params.pollId}/publish_groups.json`; - axios.get(url).then((response) => { - if (response.data) { - let starttimesend=response.data.end_time === undefined || response.data.end_time === null || response.data.end_time === "" ? undefined : response.data.end_time; - - this.setState({ - modalname:"立即发布", - modaltype:response.data.course_groups===null||response.data.course_groups.length===0?2:1, - Topval:this.props.Exercisetype==="exercise"?"学生将立即收到试卷":"学生将立即收到问卷", - // Botvalleft:"暂不发布", - Botval:this.props.single ? "":this.props.Exercisetype==="exercise"?`本操作只对"未发布"的试卷有效`:`本操作只对"未发布"的问卷有效`, - starttime:"发布时间:"+moment(moment(new Date())).format("YYYY-MM-DD HH:mm"), - starttimes:this.props.getNowFormatDates(1), - endtime:"截止时间:"+this.props.getNowFormatDates(2), - Cancelname:"暂不发布", - Savesname:"立即发布", - Cancel:this.homeworkhide, - Saves:this.homeworkstartend, - course_groups:response.data.course_groups, - starttimesend:starttimesend, - immediatelyopen:response.data.course_groups===null||response.data.course_groups.length===0?false:true, - OneSelftype:true, - }) - } - }).catch((error) => { - console.log(error) - }); - - } - - } - }else{ - if(checkBoxValues.length==0){ - this.props.showNotification("请先在列表中选择数据"); - // this.setState({ - // modalsType:true, - // modalsTopval:"请先在列表中选择数据", - // loadtype:true - // }) - }else{ - let coursesId=this.props.match.params.coursesId; - if(this.props.Exercisetype==="exercise"){ - let url=`/courses/${coursesId}/exercises/publish_modal.json`; - axios.get(url,{ - params:{ - check_ids:checkBoxValues - } - }).then((response) => { - if(response.status===200){ - let list=[]; - if(response.data.course_info){ - for(var i=0;i 0 ? 1 : 2, - visible:true, - Topval:this.props.Exercisetype==="exercise"?"学生将立即收到试卷":"学生将立即收到问卷", - // Botvalleft:"暂不发布", - Botval:this.props.single ? "":this.props.Exercisetype==="exercise"?`本操作只对"未发布"的试卷有效`:`本操作只对"未发布"的问卷有效`, - starttime:"发布时间:"+moment(moment(new Date())).format("YYYY-MM-DD HH:mm"), - starttimes:this.props.getNowFormatDates(1), - endtime:"截止时间:"+this.props.getNowFormatDates(2), - Cancelname:"暂不发布", - Savesname:"立即发布", - Cancel:this.homeworkhide, - Saves:this.homeworkstartend, - }) - - } - }).catch((error) => { - console.log(error) - }); - }else{ - let url=`/courses/${coursesId}/polls/publish_modal.json`; - axios.get(url,{ - params:{ - check_ids:checkBoxValues - } - }).then((response) => { - if(response){ - let list=[]; - if(response.data.course_info){ - for(var i=0;i 0 ? 1 : 2, - visible:true, - Topval:this.props.Exercisetype==="exercise"?"学生将立即收到试卷":"学生将立即收到问卷", - // Botvalleft:"暂不发布", - Botval:this.props.single ? "":this.props.Exercisetype==="exercise"?`本操作只对"未发布"的试卷有效`:`本操作只对"未发布"的问卷有效`, - starttime:"发布时间:"+moment(moment(new Date())).format("YYYY-MM-DD HH:mm"), - starttimes:this.props.getNowFormatDates(1), - endtime:"截止时间:"+this.props.getNowFormatDates(2), - Cancelname:"暂不发布", - Savesname:"立即发布", - Cancel:this.homeworkhide, - Saves:this.homeworkstartend, - }) - } - }).catch((error) => { - console.log(error) - }); - - } - - } - } - - - } - - //取消提示弹框 - modalCancel=()=>{ - this.setState({ - modalsType:false, - modalsTopval:"", - loadtype:false - }) - } - //暂不发布 - homeworkhide=()=>{ - this.setState({ - modalname:undefined, - modaltype:undefined, - visible:false, - OneSelftype:false, - Topval:undefined, - Topvalright:undefined, - Botvalleft:undefined, - Botval:undefined, - starttime:undefined, - starttimes:undefined, - endtime:undefined, - Cancelname:undefined, - Savesname:undefined, - Cancel:undefined, - Saves:undefined, - StudentList_value:undefined, - addname:undefined, - addnametype:false, - addnametab:undefined - }) - } - // 确定立即发布 - homeworkstartend=(ids,endtime)=>{ - - let {checkBoxValues,pushtype}=this.props - let {chooseId}=this.state; - let coursesId=this.props.match.params.coursesId; - - let data={}; - - if(pushtype===true){ - - if(ids.length===0){ - data = { - check_ids:checkBoxValues, - end_time: endtime, - } - }else{ - data={ - check_ids: checkBoxValues, - group_ids: ids, - group_end_times:endtime, - detail:true - } - - } - }else{ - - data={ - check_ids:checkBoxValues, - group_ids:chooseId, - end_time:endtime - } - } - - - if(this.props.Exercisetype==="exercise"){ - - let url=`/courses/${coursesId}/exercises/publish.json` - axios.post(url,data).then((result)=>{ - if(result){ - this.props.showNotification(result.data.message); - this.homeworkhide(); - - // 调用父级公共头部的接口刷新 - try { - this.props.action(); - }catch (e) { - - } - // 调用父级刷新数据的接口刷新 - try { - this.props.getsetdata() - }catch (e) { - - } - - } - }).catch((error)=>{ - console.log(error); - }) - - }else{ - let url=`/courses/${coursesId}/polls/publish.json` - axios.post(url,data).then((result)=>{ - if(result){ - this.props.showNotification(result.data.message); - this.homeworkhide(); - - // 调用父级公共头部的接口刷新 - this.props.action() - } - }).catch((error)=>{ - console.log(error); - }) - } - - } - - getcourse_groupslist=(id)=>{ - this.setState({ - chooseId:id - }) - } - - render(){ - let{ - modalname, - modaltype, - visible, - Topval, - Topvalright, - Botvalleft, - Botval, - starttime, - starttimes, - endtime, - Cancelname, - Savesname, - Cancel, - Saves, - course_groups, - - modalsType, - modalsTopval, - loadtype, - }=this.state - return( - - this.getcourse_groupslist(id)} - /> - - {/*立即发布*/} - {this.state.OneSelftype===true? this.getcourse_groupslist(id)} - starttimes={this.state.starttimes} - starttimesend={this.state.starttimesend} - typs={this.state.typs} - immediatelyopen={this.state.immediatelyopen} - />:""} - - {/* 公用的提示弹框 */} - - - this.homeworkstart()}>立即发布 - - ) - } -} -export default Immediatelypublish \ No newline at end of file diff --git a/src/modules/courses/poll/pollStyle.css b/src/modules/courses/poll/pollStyle.css deleted file mode 100644 index 5a5e9f76..00000000 --- a/src/modules/courses/poll/pollStyle.css +++ /dev/null @@ -1,382 +0,0 @@ -/* 单选或多选 */ -.ant-form{ - color:#05101A; -} -.ant-radio-disabled + span,.ant-checkbox-disabled + span{ - color: #666!important; - cursor: default -} -.ant-radio-wrapper { - color: #666!important; -} -.ant-checkbox-wrapper + .ant-checkbox-wrapper{ - margin-left: 0px!important; -} -/* 下拉 */ -.ant-select-selection,.ant-select-selection-selected-value{ - min-height: 40px; - min-line-height: 40px; -} -.ml61{ - margin-left: 61px; -} -.w64{ - width: 64px; -} -.w55{ - width: 55px!important; -} -.max1010{ - width: 1010px !important; - max-width: 1010px !important; -} -.yw18{ - min-width: 18px; -} -/* 选答 */ -.chooseAnswer{ - display: inline-block; - width: 68px; - text-align: center; - height: 24px; - line-height: 24px; - background: #EDEDED; - color: #666; - margin-left: 10px; - border-radius: 12px; -} - -.problemShow{ - padding:30px; - border-bottom: 1px solid #eee; -} -.problemShow:last-child{ - border-bottom: none; -} -.invite-tipysls{position: absolute;top: -8px;right: 140px;color: #fff; box-sizing: border-box;width: 170px;text-align: center;border-radius: 2px;background-color: rgba(5,16,26,0.6)} -.yslinvitetip{display: block;border-width: 8px;position: absolute;top: 10px;right: -16px;border-style: dashed solid dashed dashed;border-color: transparent transparent transparent rgba(5,16,26,0.6);font-size: 0;line-height: 0;} -.right-black-trangle{border-width: 8px;position: absolute;top: 10px;left: -16px;border-style: dashed solid dashed dashed;border-color: transparent transparent transparent rgba(5,16,26,0.6);font-size: 0;line-height: 0;} -.right-black-trangles{border-width: 8px;position: absolute;top: 10px;left: -16px;border-style: dashed solid dashed dashed;border-color: transparent rgba(5,16,26,0.6) transparent transparent;font-size: 0;line-height: 0;} -.top-black-trangle{border-width: 8px;position: absolute;top: -16px;right: 4px;border-style: dashed solid dashed dashed;border-color: transparent transparent rgba(5,16,26,0.6) transparent;font-size: 0;line-height: 0;} -.invite-tipysl{color: #999999; box-sizing: border-box;text-align: center;border-radius: 2px;font-size: 14px} -.edu-position-hideysl li a:hover{ background:#F1F1F1; color:#05101A;} -.to-back-left { - width: 0; - height: 0; - margin-top: 27px; - border-right: 15px solid #FAFAFA; - border-top: 10px solid transparent; - border-bottom: 10px solid transparent; -} -/* 问卷详情 */ -/* 答题列表 */ -.unlimit{ - height: 24px; - line-height: 24px; - padding:0px 10px; - border-radius: 12px; - cursor: pointer; - border:1px solid #cdcdcd; - color:#666; -} -.unlimit.active{ - background-color: #4CACFF; - border:1px solid #4CACFF; - color: #fff; -} -.edu-table thead th,.edu-table tbody tr:last-child td{ - border-bottom: none!important; -} -.edu-table tbody tr:hover td{ - background-color: #fff!important; -} -/* 统计结果 */ -.countList p.countHeader{ - background-color: #f8f8f8; - color: #666; - height: 38px; - font-size: 16px; - justify-content: center; - align-items: center; - display: -webkit-flex; -} -.countList p.countHeader ul{ - width: 100%; - padding:0px 30px -} -.countList p.countHeader span,.countList div.countBody span{ - float: left; -} -.countList div.countBody{ - margin:0px 30px; - border-bottom:1px solid #EBEBEB; - padding:12px 0px; -} -.countList div.countBody:last-child{ - border-bottom: none; -} -.countList p.countHeader span:nth-child(1),.countList div.countBody span:nth-child(1){ - width: 50%; - text-align: left; -} -.countList p.countHeader span:nth-child(2),.countList div.countBody span:nth-child(2){ - width:15%; - text-align: center; -} -.countList p.countHeader span:nth-child(3),.countList div.countBody span:nth-child(3){ - width:35%; - text-align: left; -} -.percentForm{ - width: 330px; - height: 11px; - background: #F5F5F5; - border-radius: 6px; - position: relative; - margin-top: 7px; -} -.percentValue{ - position: absolute; - top:0px; - left: 0px; - height: 11px; - background: #29BD8B; - border-radius: 6px; -} -.answerTxt{ - max-height: 500px; - background-color: #F2F9FF; - width: 100%; - margin-top: 10px; - padding:10px; - box-sizing: border-box; - color: #4c4c4c; -} -.otherTxt{ - border:none!important; - border-bottom: 1px solid #eee!important; - background: transparent!important; - flex:1; - height: 20px!important; - line-height: 20px!important; -} -.otherTxt.ant-input:hover,.otherTxt.ant-input:focus{ - border:none!important; - border-bottom: 1px solid #eee!important; - background: #F8F8F8!important; -} - -/* 必答 */ -.mustAnswer{ - padding:0px 10px; - border-radius: 15px; - height: 22px; - line-height: 22px; - background: #eaeaea; - color: #999; - font-size: 14px; -} -/* 问卷内容 */ -.previewList{ - border-bottom: 1px solid #ebebeb; -} -.previewList:last-child{ - border-bottom:none; -} -.textLine{ - flex: 1; - height:22px; - border-bottom: 1px solid #ebebeb; -} -.answerList{ - box-sizing: border-box; - width: 100%; - margin-bottom: 20px; -} -.answerList li{ - padding:10px 30px; - box-sizing: border-box; - line-height:20px; - width: 100%; -} -.answerList li:hover{ - background: #F0F8FF; -} -textarea:read-only{ - background: #f3f3f3; -} -.ant-calendar-picker-input{ - height: 40px; -} - -/* 问卷答题 */ -.questionsNo{ - position: relative; - padding: 30px; - border-bottom: 1px solid #ebebeb; -} -.questionsfixed{ - position: fixed; - padding: 30px; - z-index: 12; - top: 60px; - width: 1200px; - background: #fff; -} -.answered,.unanswer,.answerTure,.answerFalse,.answerHalf{ - position: relative; -} -.answered::after{ - position: absolute; - right:35px; - top:4px; - width: 12px; - height: 12px; - border-radius: 50%; - background: #CBCBCB; - content: ""; -} -.unanswer::after{ - position: absolute; - right:35px; - top:4px; - width: 12px; - height: 12px; - border-radius: 50%; - background: #fff; - content: ""; - border:1px solid rgba(203,203,203,1); -} -.answerTure::after{ - position: absolute; - right:35px; - top:4px; - width: 20px; - height: 10px; - border-radius: 5px; - background: #29BD8B; - content: ""; -} -.answerFalse::after{ - position: absolute; - right:35px; - top:4px; - width: 20px; - height: 10px; - border-radius: 5px; - background: #FF3756; - content: ""; -} -.color-red{color: #FF3756!important} -.answerHalf::after{ - position: absolute; - left:-25px; - top:4px; - width: 20px; - height: 10px; - border-radius: 5px; - background: #FF6800; - content: ""; -} -.leaderNav,.leaderMainNav{ - margin-top: 20px; -} -.leaderNav a,.leaderMainNav a{ - display: block; - float: left; - margin-right: 10px; - border-radius: 50%; - border:1px solid #CBCBCB; - height: 40px; - line-height: 40px; - width: 40px; - text-align: center; - color: #999999; - cursor: pointer; - margin-bottom: 5px; -} -.leaderMainNav a{ - background: #FF3756; - color: #fff; - border:1px solid #FF3756; -} -.leaderNav a.acted{ - background:rgba(203,203,203,1); - color: #fff; -} -.leaderMainNav a.acted{ - background-color: #29BD8B; - color: #fff; - border:1px solid #29BD8B; -} -.leaderMainNav a.half{ - background-color: #FF6800; - color: #fff; - border:1px solid #FF6800; -} - -/* 问卷设置 */ -.pollForm .ant-form-item-control{ - line-height: 20px; -} -.pollForm.ant-form-item{ - margin-bottom: 0px -} -.setInfo .ant-select-selection__rendered{ - line-height: 40px; -} - -/* 下拉搜索框 */ -.ant-select-dropdown-menu .ant-select-dropdown-menu-item{ - padding:5px 15px; -} -.ant-select-dropdown.ant-select-dropdown--multiple .ant-select-dropdown-menu-item .ant-select-selected-icon{ - right: 15px; -} - -.noticeTip{ - border:1px solid #FF0000; - border-radius: 5px; -} -.pollResultList .ant-table-thead > tr > th,.pollResultList .ant-table-tbody > tr > td{ - padding:15px 6px; -} -/* 试卷 */ -.setScoreInput{ - width: 60px!important;height: 30px!important;box-sizing: border-box; - text-align: center!important; - background: #F8F8F8; - color:#666; -} -.setScoreInput:focus{ - background: #fff; - color:#FF6800 -} -.standardAnswer p{ - line-height: 20px!important; -} -/* 倒计时 */ -.remainingTime li{ - float: left; - width: 40px; - line-height: 40px; - background-color: #111C24; - color: #fff; - border-radius: 4px; - text-align: center -} -.remainingTime span{ - float: left; - width: 20px; - line-height: 40px; - text-align: center; -} -.myyslwidth { - min-width:1200px -} - -.zexercisetitle { - font-size: 16px; - color: rgba(51, 51, 51, 1); - min-width: 95px; -}