diff --git a/app/forms/item_banks/save_item_form.rb b/app/forms/item_banks/save_item_form.rb index d6d3a3e28..f4ad5291c 100644 --- a/app/forms/item_banks/save_item_form.rb +++ b/app/forms/item_banks/save_item_form.rb @@ -8,7 +8,7 @@ class ItemBanks::SaveItemForm validates :item_type, presence: true, inclusion: {in: %W(SINGLE MULTIPLE JUDGMENT COMPLETION SUBJECTIVE PRACTICAL PROGRAM)} validates :difficulty, presence: true, inclusion: {in: 1..3}, numericality: { only_integer: true } validates :name, presence: true, length: { maximum: 1000 } - validates :analysis, length: { maximum: 1000 } + validates :analysis, length: { maximum: 5000 } def validate! super @@ -27,7 +27,7 @@ class ItemBanks::SaveItemForm attr_accessor :choice_text, :is_answer - validates :choice_text, presence: true, length: { maximum: 300 } + validates :choice_text, presence: true, length: { maximum: 500 } validates :is_answer, presence: true, inclusion: {in: 0..1}, numericality: { only_integer: true } end end \ No newline at end of file diff --git a/app/models/item_analysis.rb b/app/models/item_analysis.rb index 8f6e71302..dc1453982 100644 --- a/app/models/item_analysis.rb +++ b/app/models/item_analysis.rb @@ -1,3 +1,3 @@ class ItemAnalysis < ApplicationRecord - belongs_to :item_bank + belongs_to :item_bank, touch: true end diff --git a/app/models/item_choice.rb b/app/models/item_choice.rb index ccc35698e..2b2b08c9d 100644 --- a/app/models/item_choice.rb +++ b/app/models/item_choice.rb @@ -1,3 +1,3 @@ class ItemChoice < ApplicationRecord - belongs_to :item_bank + belongs_to :item_bank, touch: true end diff --git a/app/models/tag_discipline_container.rb b/app/models/tag_discipline_container.rb index 585182bbf..44b28af1a 100644 --- a/app/models/tag_discipline_container.rb +++ b/app/models/tag_discipline_container.rb @@ -1,5 +1,5 @@ class TagDisciplineContainer < ApplicationRecord belongs_to :tag_discipline - belongs_to :container, polymorphic: true, optional: true + belongs_to :container, polymorphic: true, optional: true, touch: true end diff --git a/config/routes.rb b/config/routes.rb index a63776d44..7d85d66db 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -98,7 +98,7 @@ Rails.application.routes.draw do resources :examination_intelligent_settings do collection do - get :optinal_items + post :optinal_items end member do diff --git a/public/react/src/App.js b/public/react/src/App.js index ee986824a..dabe4a50d 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -334,7 +334,11 @@ const Paperreview= Loadable({ loading: Loading }) - +//智能组卷 +const Integeneration= Loadable({ + loader: () => import('./modules/testpaper/Intecomponents'), + loading: Loading +}) // 学院统计 const College = Loadable({ @@ -754,6 +758,7 @@ class App extends Component { } } /> + () @@ -764,7 +769,14 @@ class App extends Component { render={ (props) => () } /> - + () + }/> + () + }/> () @@ -774,6 +786,7 @@ class App extends Component { render={ (props) => () }/> + () @@ -795,9 +808,10 @@ class App extends Component { render={ (props) => () }/> - () + (props) => () }/> { // ////console.log("开始请求/get_navigation_info.json"); @@ -190,6 +189,24 @@ class NewMyShixunModel extends Component { } }); } + + componentDidUpdate(prevProps) { + if(prevProps.current_user !== this.props.current_user) { + debugger + const isysladmins=this.props&&this.props.current_user&&this.props.current_user.admin?this.props.current_user.admin:false; + const is_teacher=this.props&&this.props.current_user&&this.props.current_user.is_teacher?this.props.current_user.is_teacher:false; + const professional_certification=this.props&&this.props.current_user&&this.props.current_user.professional_certification?this.props.current_user.professional_certification:false; + let {defaultActiveKey} = this.props; + var defaultActiveKeys=defaultActiveKey; + if(isysladmins===true||(is_teacher===true&&professional_certification===true)){ + defaultActiveKeys="0" + }else{ + defaultActiveKeys="1" + } + this.callback(defaultActiveKeys); + } + } + //公共和我的 callback = (key) => { this.setState({ diff --git a/public/react/src/modules/question/Paperreview.js b/public/react/src/modules/question/Paperreview.js index b65127c8d..c0660d544 100644 --- a/public/react/src/modules/question/Paperreview.js +++ b/public/react/src/modules/question/Paperreview.js @@ -51,6 +51,7 @@ class Paperreview extends Component { name:null, duration:null, newmyshixunmodelbool:false, + artificialtype:"artificial", } // single_questions:null, 单选题 @@ -64,10 +65,27 @@ class Paperreview extends Component { //初始化 componentDidMount() { + console.log("Paperreview.js"); + console.log(this.props.match.params.type); + this.setState({ + artificialtype:this.props.match.params.type + }) + if(this.props.match.params.type==="artificial"){ + //人工组卷 + + var data = {} + this.getdata(data); + }else{ + //智能组卷 + // + var data = { + exam_setting_id:this.props.match.params.id + } + this.getdata(data); + } + - var data = {} - this.getdata(data); let urls = `/disciplines.json`; axios.get(urls, { params: { @@ -193,43 +211,51 @@ class Paperreview extends Component { } preservation = () => { //保存试卷 - if(this.state.Cohetepaperbool===true){ - if (this.contentMdRef.Getdatas().length === 0) { - this.scrollToAnchor("Itembankstopid"); - return; - } - var myrbkc=[]; - var Getdatasdatas=this.contentMdRef.Getdatas()[2].rbzsd; - for(let myda of Getdatasdatas) { - myrbkc.push(myda.id); - } - const url = `/examination_banks.json`; - var data={ - difficulty:this.contentMdRef.Getdatas()[0].rbnd, - name:this.contentMdRef.Getdatas()[4].classroom, - duration:this.contentMdRef.Getdatas()[5].kssc, - discipline_id: this.contentMdRef.Getdatas()[3].rbkc[0], - sub_discipline_id: this.contentMdRef.Getdatas()[3].rbkc[1], - tag_discipline_id: myrbkc, + if(this.state.artificialtype==="artificial"){ + if(this.state.Cohetepaperbool===true){ + if (this.contentMdRef.Getdatas().length === 0) { + this.scrollToAnchor("Itembankstopid"); + return; + } + var myrbkc=[]; + var Getdatasdatas=this.contentMdRef.Getdatas()[2].rbzsd; + for(let myda of Getdatasdatas) { + myrbkc.push(myda.id); + } + const url = `/examination_banks.json`; + var data={ + difficulty:this.contentMdRef.Getdatas()[0].rbnd, + name:this.contentMdRef.Getdatas()[4].classroom, + duration:this.contentMdRef.Getdatas()[5].kssc, + discipline_id: this.contentMdRef.Getdatas()[3].rbkc[0], + sub_discipline_id: this.contentMdRef.Getdatas()[3].rbkc[1], + tag_discipline_id: myrbkc, + } + axios.post(url, data) + .then((result) => { + if (result.data.status === 0) { + // this.props.showNotification(`组卷成功`); + this.props.history.replace('/paperlibrary'); + } + }).catch((error) => { + console.log(error); + }) + + }else{ + this.setCohetepaperbool(true); + } - axios.post(url, data) - .then((result) => { - if (result.data.status === 0) { - // this.props.showNotification(`组卷成功`); - this.props.history.replace('/paperlibrary'); - } - }).catch((error) => { - console.log(error); - }) }else{ - this.setCohetepaperbool(true); + //智能组卷 + } + } @@ -265,7 +291,7 @@ class Paperreview extends Component { this.getdata(data); } render() { - let {page, limit, count, Headertop, visible, placement, modalsType, item_type,Cohetepaperbool,newmyshixunmodelbool} = this.state; + let {page, limit, count, Headertop, visible, placement, modalsType, item_type,artificialtype,Cohetepaperbool,newmyshixunmodelbool} = this.state; const params = this.props && this.props.match && this.props.match.params; // //console.log(params); return ( @@ -285,7 +311,7 @@ class Paperreview extends Component { { newmyshixunmodelbool===true?
- this.setnewmyshixunmodelbool(e)}> + this.setnewmyshixunmodelbool(e)}>
: "" @@ -305,11 +331,18 @@ class Paperreview extends Component {
{ Cohetepaperbool===false? - - 试题库 - 人工组卷 - 试卷预览 - + artificialtype==="artificial"? + + 试题库 + 人工组卷 + 试卷预览 + + : + + 试卷库 + 智能组卷 + 试卷预览 + : 试题库 diff --git a/public/react/src/modules/question/Question.js b/public/react/src/modules/question/Question.js index 3264c52fa..47343e091 100644 --- a/public/react/src/modules/question/Question.js +++ b/public/react/src/modules/question/Question.js @@ -26,7 +26,7 @@ class Question extends Component { super(props); this.state = { count: 50, - defaultActiveKey:"0", + defaultActiveKey:"1", Headertop: "", Footerdown: "", visible: false, @@ -72,7 +72,6 @@ class Question extends Component { } chakanjiexibool=(index)=>{ - debugger if(this.state.chakanjiexiboolindex===index){ this.setState({ chakanjiexiboolindex:"无", @@ -163,21 +162,8 @@ class Question extends Component { //初始化 componentDidMount() { - let {defaultActiveKey} = this.state; - var data = { - discipline_id:this.state.discipline_id, - sub_discipline_id:this.state.sub_discipline_id, - tag_discipline_id:this.state.tag_discipline_id, - public: defaultActiveKey, - page:1, - per_page:10, - }; - this.getdata(data); - let url = `/users/get_navigation_info.json`; axios.get(url, {}).then((response) => { - // ////console.log("开始请求/get_navigation_info.json"); - // ////console.log(response); if (response != undefined) { if (response.status === 200) { this.setState({ @@ -187,9 +173,7 @@ class Question extends Component { } } }); - this.getbasket_listdata(); - //获取题库筛选资料 let urls = `/disciplines.json`; axios.get(urls, {params: { @@ -775,7 +759,7 @@ class Question extends Component { //跳转 gotopaperreview=()=>{ - this.props.history.replace("/paperreview"); + this.props.history.replace("/paperreview/artificial"); } @@ -816,7 +800,9 @@ class Question extends Component { + program_questions_count + single_questions_count + subjective_questions_count; - + const isysladmins=this.props&&this.props.current_user&&this.props.current_user.admin?this.props.current_user.admin:false; + const is_teacher=this.props&&this.props.current_user&&this.props.current_user.is_teacher?this.props.current_user.is_teacher:false; + const professional_certification=this.props&&this.props.current_user&&this.props.current_user.professional_certification?this.props.current_user.professional_certification:false; return ( @@ -878,15 +864,33 @@ class Question extends Component { ` } - this.showDrawer()} - Headertop={Headertop} + { + isysladmins===true? + this.showDrawer()} + Headertop={Headertop} + + /> + : + is_teacher===true&&professional_certification===true? + this.showDrawer()} + Headertop={Headertop} + + /> + : + + "" + } - /> {/*顶部*/} diff --git a/public/react/src/modules/question/component/Contentpart.js b/public/react/src/modules/question/component/Contentpart.js index da85ce0f7..5a50104a8 100644 --- a/public/react/src/modules/question/component/Contentpart.js +++ b/public/react/src/modules/question/component/Contentpart.js @@ -36,7 +36,22 @@ class Contentpart extends Component { chakanjiexibool=(index)=>{ this.props.chakanjiexibool(index); } - + componentDidUpdate(prevProps) { + if(prevProps.current_user !== this.props.current_user) { + debugger + const isysladmins=this.props&&this.props.current_user&&this.props.current_user.admin?this.props.current_user.admin:false; + const is_teacher=this.props&&this.props.current_user&&this.props.current_user.is_teacher?this.props.current_user.is_teacher:false; + const professional_certification=this.props&&this.props.current_user&&this.props.current_user.professional_certification?this.props.current_user.professional_certification:false; + let {defaultActiveKey} = this.props; + var defaultActiveKeys=defaultActiveKey; + if(isysladmins===true||(is_teacher===true&&professional_certification===true)){ + defaultActiveKeys="0" + }else{ + defaultActiveKeys="1" + } + this.props.callback(defaultActiveKeys); + } + } xinzenw=(e)=>{ var urls="?"; if(this.props.discipline_id){ @@ -82,6 +97,11 @@ class Contentpart extends Component { render() { let {page}=this.state; let {defaultActiveKey,item_type,booljupyterurls}=this.props; + const isysladmins=this.props&&this.props.current_user&&this.props.current_user.admin?this.props.current_user.admin:false; + const is_teacher=this.props&&this.props.current_user&&this.props.current_user.is_teacher?this.props.current_user.is_teacher:false; + const professional_certification=this.props&&this.props.current_user&&this.props.current_user.professional_certification?this.props.current_user.professional_certification:false; + + const content = (
); - const buttonWidth = 70; - //console.log("Contentpart"); - //console.log(this.props); + + console.log("Contentpart.js"); + console.log(this.props.defaultActiveKey); + return (
@@ -141,12 +162,23 @@ class Contentpart extends Component { ` } - this.props.callback(e)}> - - - - - + + + { + isysladmins===true||(is_teacher===true&&professional_certification===true)? + this.props.callback(e)}> + + + + + + : + this.props.callback(e)}> + + + + } +
{ defaultActiveKey===0||defaultActiveKey==="0"? - this.xinzenw(e)}> -
-

新增

-
-
+ isysladmins===true||(is_teacher===true&&professional_certification===true)? + this.xinzenw(e)}> +
+

新增

+
+
+ :"" :"" } @@ -208,7 +242,7 @@ class Contentpart extends Component { { defaultActiveKey===0||defaultActiveKey==="0"? { + handleFormLayoutChange = (e) => { //难度塞选 ////console.log("难度塞选"); ////console.log(value); this.props.form.setFieldsValue({ - rbnd: value + "", + rbnd: e.target.value + "", }); this.setState({ - rbnd: value + "", + rbnd: e.target.value + "", }) } @@ -403,8 +403,8 @@ class Itembankstop extends Component { const _result =[]; this.state.knowledgepoints.filter(item => { if (this.state.Knowpoints.findIndex(t => t.id === item.id) === -1) { - console.log("guonue"); - console.log(item); + // console.log("guonue"); + // console.log(item); _result.push(item); } }); @@ -628,9 +628,9 @@ class Itembankstop extends Component { let {page, options,NewknTypedel,knowledgepoints,knowledgepoints2,Knowpoints} = this.state; const {getFieldDecorator} = this.props.form; - console.log("this.state.rbkc"); - console.log(this.state.rbkc); - console.log(options); + // console.log("this.state.rbkc"); + // console.log(this.state.rbkc); + // console.log(options); return ( @@ -718,30 +718,30 @@ class Itembankstop extends Component {
)} - -
- - {this.state.Knowpoints === undefined ? "" : this.state.Knowpoints.map((object, index) => { - return ( -
0? +
-

{object.name}

- - this.deletesobject(object, index)} src={getImageUrl("images/educoder/bzucha.png")}/> - + {this.state.Knowpoints === undefined ? "" : this.state.Knowpoints.map((object, index) => { + return ( +
+

{object.name}

+ + this.deletesobject(object, index)} src={getImageUrl("images/educoder/bzucha.png")}/> + +
+ ) + })}
- ) - })} - - - + : + "" + } -
this.props.showmodels(items.id)}> 公开

- : + : + "" + :items.apply===false?

this.props.showmodels(items.id)}> 公开

+ : + "" : "" } diff --git a/public/react/src/modules/question/comthetestpaper/Comthetestpaperst.js b/public/react/src/modules/question/comthetestpaper/Comthetestpaperst.js index 50d2bb85f..64990f3dc 100644 --- a/public/react/src/modules/question/comthetestpaper/Comthetestpaperst.js +++ b/public/react/src/modules/question/comthetestpaper/Comthetestpaperst.js @@ -331,15 +331,15 @@ class Comthetestpaperst extends Component { }); } - handleFormLayoutChange = (value) => { + handleFormLayoutChange = (e) => { //难度塞选 ////console.log("难度塞选"); ////console.log(value); this.props.form.setFieldsValue({ - rbnd: value + "", + rbnd: e.target.value + "", }); this.setState({ - rbnd: value + "", + rbnd: e.target.value + "", }) } @@ -494,6 +494,10 @@ class Comthetestpaperst extends Component { } NewknTypedeldel=(bool)=>{ + if(this.state.rbkc===undefined || this.state.rbkc===null || this.state.rbkc===""){ + this.props.showNotification(`请选择课程方向`); + return; + } this.setState({ NewknTypedel:bool }) @@ -524,11 +528,7 @@ class Comthetestpaperst extends Component { return } - if(this.state.rbkc===undefined || this.state.rbkc===null || this.state.rbkc===""){ - this.props.showNotification(`请选择课程方向`); - this.setboolred(true); - return; - } + var data={ name:value, sub_discipline_id:this.state.rbkc[1] @@ -699,29 +699,29 @@ class Comthetestpaperst extends Component { )}
-
- - {this.state.Knowpoints === undefined ? "" : this.state.Knowpoints.map((object, index) => { - return ( -
0? +
-

{object.name}

- - this.deletesobject(object, index)} src={getImageUrl("/images/educoder/bzucha.png")}/> - + {this.state.Knowpoints === undefined ? "" : this.state.Knowpoints.map((object, index) => { + return ( +
+

{object.name}

+ + this.deletesobject(object, index)} src={getImageUrl("images/educoder/bzucha.png")}/> + +
+ ) + })}
- ) - })} - - - - -
+ : + "" + } +
+ { + NewknTypedel? + this.setboolred(bool)} + NewknTypedeldel={(bool)=>this.NewknTypedeldel(bool)} + NewknTypedeltyoedel={(value)=>this.NewknTypedeltyoedel(value)} + > + :"" + } + +
+
+
+ + {getFieldDecorator("rbkc" + , + {initialValue: this.state.rbkc, + rules: [{required: true, message: '请选择课程'}], + } + )( + + )} + +
+
+
+ + {getFieldDecorator("rbzsd" + )( +
+ + + + + + + this.NewknTypedeldel(true)}/> + + + +
+ )} +
+
+ { + this.state.Knowpoints===undefined||this.state.Knowpoints===null?"": + this.state.Knowpoints.length>0? +
+ {this.state.Knowpoints === undefined ? "" : this.state.Knowpoints.map((object, index) => { + return ( +
+

{object.name}

+ + this.deletesobject(object, index)} src={getImageUrl("images/educoder/bzucha.png")}/> + +
+ ) + })} +
+ : + "" + } + + +
+ + {getFieldDecorator('rbly' + , + {initialValue: this.state.rbly, + } + )( + + 公共 + 我的 + , + )} + +
+ +

条件设置

+
+ + + +
+ + {getFieldDecorator('rbnd' + , + {initialValue: this.state.rbnd, + rules: [{required: true, message: '请选择难度'}], + } + )( + + 简单 + 适中 + 困难 + , + )} + +
+ + +
+

题型及数量

+
+ this.props.getdatas()} ref={dom => { + this.$dxt = dom; + }}> + this.props.getdatas()} ref={dom => { + this.$ddxt = dom; + }}> + this.props.getdatas()} ref={dom => { + this.$pdt = dom; + }}> + this.props.getdatas()} ref={dom => { + this.$bct = dom; + }}> + + + +
+
+ ) + + } + + +} + +const Intelligentcomponentss = Form.create({name: 'Intelligentcomponents'})(Intelligentcomponents); +export default Intelligentcomponentss; diff --git a/public/react/src/modules/question/comthetestpaper/lntlligentpone.js b/public/react/src/modules/question/comthetestpaper/lntlligentpone.js new file mode 100644 index 000000000..d9c6527c1 --- /dev/null +++ b/public/react/src/modules/question/comthetestpaper/lntlligentpone.js @@ -0,0 +1,169 @@ +import React, {Component} from "react"; +import {Link, NavLink} from 'react-router-dom'; +import {WordsBtn, ActionBtn, getImageUrl, markdownToHTML} from 'educoder'; +import axios from 'axios'; +import { + notification, + Spin, + Table, + Pagination, + Drawer, + Input, + Button, + Breadcrumb, + Icon, + InputNumber, + Tooltip +} from "antd"; +import '../questioncss/questioncom.css'; + +//判断题 +class lntlligentpone extends Component { + constructor(props) { + super(props); + + this.state = { + count: 0, + countbool: false, + } + + } + + //初始化 + componentDidMount() { + + + } + + increase = () => { + + const datasbool=this.props.getdatas(); + // if(datasbool===undefined || datasbool===null){ + // if(this.props.mycount===0){ + // this.props.showNotification(`题数为0无法增加题目`); + // return + // } + // + // } + + const count = this.state.count + 1; + if(count<=this.props.mycount){ + this.setState({count: count, countbool: false}); + } + + + }; + + decline = () => { + const datasbool=this.props.getdatas(); + // if(datasbool===undefined || datasbool===null){ + // if(this.props.mycount===0){ + // this.props.showNotification(`题数为0无法减少题目`); + // return + // } + // } + + let count = this.state.count - 1; + if (count < 0) { + count = 0; + } + this.setState({count: count, countbool: false}); + }; + inputsnumber = (value) => { + const datasbool=this.props.getdatas(); + // if(datasbool===undefined || datasbool===null){ + // if(this.props.mycount===0){ + // this.setState({count: 0, countbool: false}); + // this.props.showNotification(`题数为0无法输入`); + // return + // } + // } + + if(this.props.mycount===0){ + this.setState({count: 0, countbool: false}); + }else { + this.setState({count: value, countbool: false}); + } + + + } + + //返回数据 + mygetinputnumber=()=>{ + return this.state.count; + } + isNumber=(val)=>{ + var regPos = /^\d+(\.\d+)?$/; //非负浮点数 + var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数 + if(regPos.test(val) && regNeg.test(val)){ + return true; + }else{ + return false; + } + } + + render() { + let {questions, totalscore, total, items} = this.state; + return ( +
+

{this.props.dxtx}

+ { + this.props.mycount===0? +
+ + + +
+ + + + + +
+ + + + +

共{this.props.mycount}道

+
+ : + +
+ +
+ +
+ +

共{this.props.mycount}道

+
+ + } + +
+ ) + + } + + +} + +export default lntlligentpone + + diff --git a/public/react/src/modules/question/questioncss/questioncom.css b/public/react/src/modules/question/questioncss/questioncom.css index 84a663217..ae405001a 100644 --- a/public/react/src/modules/question/questioncss/questioncom.css +++ b/public/react/src/modules/question/questioncss/questioncom.css @@ -524,7 +524,14 @@ margin-top: 19px; } .mytags{ - min-width:106px; + min-width:106px !important; + height:32px; + border-radius:2px; + border:1px solid #DDDDDD; + margin-right: 20px; +} +.mytagss{ + min-width:106px !important; height:32px; border-radius:2px; border:1px solid #DDDDDD; @@ -970,3 +977,48 @@ .mt15{ margin-top: 15px; } +.conditionsetting{ + width:64px; + height:21px; + font-size:16px; + color:#333333; + line-height:21px; +} +.hengxians{ + width:1021px; + height:1px; + background: #EEEEEE; +} +.mt13{ + margin-top: 13px; +} +.inpustredss .ant-input-number{ + border: 1px solid #f30707; + border-radius: 5px; +} + +.inpustredssdiv button { + border-radius: 50%; + width: 38px; + height: 38px; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + +.inpustredssdiv .ant-input-number-input{ + text-align: center; +} +.lh32{ + line-height: 32px; +} +.ml23{ + margin-left: 23px; +} +.ml12{ + margin-left: 12px; +} +.mr12{ + margin-right: 12px; +} diff --git a/public/react/src/modules/testpaper/Intecomponents.js b/public/react/src/modules/testpaper/Intecomponents.js new file mode 100644 index 000000000..ad8171ae0 --- /dev/null +++ b/public/react/src/modules/testpaper/Intecomponents.js @@ -0,0 +1,347 @@ +import React, {Component} from "react"; +import {Link, NavLink} from 'react-router-dom'; +import {WordsBtn, ActionBtn, SnackbarHOC, getImageUrl} from 'educoder'; +import axios from 'axios'; +import { + notification, + Spin, + Table, + Pagination, + Drawer, + Input, + Button, + Breadcrumb +} from "antd"; +import {TPMIndexHOC} from "../tpm/TPMIndexHOC"; +import './testioncss/testioncss.css'; +import '../tpm/newshixuns/css/Newshixuns.css'; +import Bottomsubmit from "../../modules/modals/Bottomsubmit"; +import Intelligentcomponents from "../question/comthetestpaper/Intelligentcomponents"; + +//试卷编辑 +class Intecomponents extends Component { + constructor(props) { + super(props); + this.Judquestio = React.createRef(); + this.state = { + paperlibrartdata: [], + disciplinesdata: [], + knowledgepoints: [], + disciplmy: [], + item_banksedit: [], + newmyshixunmodelbool:false, + single_question_count:0, + multiple_question_count:0, + judgement_question_count:0, + program_question_count:0, + } + + + } + + getJudquestio = (Ref) => { + console.log("子组件对象"); + console.log(Ref); + this.Judquestio = Ref; + } + + //初始化 + componentDidMount() { + let urls = `/disciplines.json`; + axios.get(urls, { + params: { + source: "question" + } + }).then((response) => { + if (response) { + this.setState({ + disciplinesdata: response.data.disciplines, + }) + if (response.data) { + if (response.data.disciplines) { + + const didata = response.data.disciplines; + + for (var i = 0; i < didata.length; i++) { + const childern = []; + //方向 + const fxdidata = didata[i].sub_disciplines; + + + for (var j = 0; j < fxdidata.length; j++) { + //课程 + const zsddata = fxdidata[j].tag_disciplines; + childern.push( + { + value: fxdidata[j].id, + label: fxdidata[j].name, + } + ) + for (var k = 0; k < zsddata.length; k++) { + //知识点 + this.state.knowledgepoints.push(zsddata[k]); + + + } + } + + const datakec = { + value: didata[i].id, + label: didata[i].name, + children: childern, + } + this.state.disciplmy.push(datakec); + } + + this.setState({ + knowledgepoints: this.state.knowledgepoints, + disciplmy: this.state.disciplmy, + }) + + + } + + } + + } + }); + + + + + } + getdatas=()=>{ + if (this.Judquestio.Getdatas().length === 0) { + this.scrollToAnchor("Itembankstopid"); + return false; + } + console.log(this.Judquestio.Getdatas()); + var myrbkc=[]; + var Getdatasdatas=this.Judquestio.Getdatas()[1].rbzsd; + for(let myda of Getdatasdatas) { + myrbkc.push(myda.id); + } + const url="/examination_intelligent_settings/optinal_items.json"; + var data={ + sub_discipline_id:this.Judquestio.Getdatas()[2].rbkc[1], + tag_discipline_id:myrbkc, + source:this.Judquestio.Getdatas()[7].rbly, + difficulty:this.Judquestio.Getdatas()[0].rbnd, + } + + axios.get(url, {params: { + data + }}).then((response) => { + if (response) { + console.log("智能组卷"); + console.log(response); + if(response.data){ + this.setState({ + single_question_count:response.data.single_question_count, + multiple_question_count:response.data.multiple_question_count, + judgement_question_count:response.data.judgement_question_count, + program_question_count:response.data.program_question_count, + }) + + } + + } + }); + + } + + getdatass=(nandu)=>{ + debugger + if (this.Judquestio.Getdatas().length === 0) { + this.scrollToAnchor("Itembankstopid"); + return false; + } + console.log(this.Judquestio.Getdatas()); + var myrbkc=[]; + var Getdatasdatas=this.Judquestio.Getdatas()[1].rbzsd; + for(let myda of Getdatasdatas) { + myrbkc.push(myda.id); + } + const url="/examination_intelligent_settings/optinal_items.json"; + var data={ + sub_discipline_id:this.Judquestio.Getdatas()[2].rbkc[1], + tag_discipline_id:myrbkc, + source:this.Judquestio.Getdatas()[7].rbly, + difficulty:nandu, + } + + axios.get(url, {params: { + data + }}).then((response) => { + if (response) { + console.log("智能组卷"); + console.log(response); + if(response.data){ + this.setState({ + single_question_count:response.data.single_question_count, + multiple_question_count:response.data.multiple_question_count, + judgement_question_count:response.data.judgement_question_count, + program_question_count:response.data.program_question_count, + }) + + } + + } + }); + + } + + + componentDidUpdate(prevProps) { + + } + + + + //跳转道描点的地方 + scrollToAnchor = (anchorName) => { + try { + if (anchorName) { + // 找到锚点 + let anchorElement = document.getElementById(anchorName); + // 如果对应id的锚点存在,就跳转到锚点 + if (anchorElement) { + anchorElement.scrollIntoView(); + } + } + } catch (e) { + + } + + } + preservation = () => { + if (this.Judquestio.Getdatas().length === 0) { + this.scrollToAnchor("Itembankstopid"); + return; + } + var myrbkc=[]; + var Getdatasdatas=this.Judquestio.Getdatas()[1].rbzsd; + for(let myda of Getdatasdatas) { + myrbkc.push(myda.id); + } + // console.log(myrbkc); + // console.log("preservation"); + // console.log(this.Judquestio.Getdatas()); + + + var question_settings =[ + { + "item_type": "SINGLE", + "count": this.Judquestio.Getdatas()[3].rbdxt + }, + { + "item_type": "MULTIPLE", + "count": this.Judquestio.Getdatas()[4].rbdxtx + }, + { + "item_type": "JUDGMENT", + "count": this.Judquestio.Getdatas()[5].rbpdt + }, + { + "item_type": "PROGRAM", + "count": this.Judquestio.Getdatas()[6].rbbct + } + ] + + + const url="/examination_intelligent_settings.json" + var data = { + discipline_id: this.Judquestio.Getdatas()[2].rbkc[0], + sub_discipline_id:this.Judquestio.Getdatas()[2].rbkc[1], + tag_discipline_id:myrbkc, + source:this.Judquestio.Getdatas()[7].rbly, + difficulty:this.Judquestio.Getdatas()[0].rbnd, + question_settings:question_settings, + } + axios.post(url, data) + .then((result) => { + if (result.data.status == 0) { + console.log("组卷成功"); + this.props.history.push(`/IntegenerationSee/Intelligence/${result.data.exam_setting_id}`); + } + }).catch((error) => { + console.log(error); + }) + + } + + + setitem_type = (item_type) => { + + + } + + setCohetepaperbool = (bool) => { + + } + getcontentMdRef = (Ref) => { + this.contentMdRef = Ref; + } + + setnewmyshixunmodelbool=()=>{ + + } + + render() { + let {paperlibrartdata,newmyshixunmodelbool,single_question_count,multiple_question_count,judgement_question_count,program_question_count} = this.state; + const params = this.props && this.props.match && this.props.match.params; + return ( +
+
+ +
+
+ + 试题库 + 智能组卷 + +
+ this.getdatas()} + getdatass={(nd)=>this.getdatass(nd)} + getJudquestio={(ref) => this.getJudquestio(ref)} + > + + + + +
+ + +
+ { + newmyshixunmodelbool === true ? "" : + this.setCohetepaperbool(bool)} + onSubmits={() => this.preservation()} url={'/paperlibrary'}> + } +
+ ) + + } + + +} + +export default SnackbarHOC()(TPMIndexHOC(Intecomponents)); + + diff --git a/public/react/src/modules/testpaper/Paperlibraryeditid.js b/public/react/src/modules/testpaper/Paperlibraryeditid.js index efcb45496..449de0219 100644 --- a/public/react/src/modules/testpaper/Paperlibraryeditid.js +++ b/public/react/src/modules/testpaper/Paperlibraryeditid.js @@ -227,7 +227,7 @@ class Paperlibraryeditid extends Component { { newmyshixunmodelbool===true?
- this.setnewmyshixunmodelbool(e)}> + this.setnewmyshixunmodelbool(e)}>
: "" diff --git a/public/react/src/modules/testpaper/Testpaperlibrary.js b/public/react/src/modules/testpaper/Testpaperlibrary.js index fdd290ed8..fb77352ef 100644 --- a/public/react/src/modules/testpaper/Testpaperlibrary.js +++ b/public/react/src/modules/testpaper/Testpaperlibrary.js @@ -36,7 +36,7 @@ class Testpaperlibrary extends Component { booljupyterurls:false, Contentdata:[], items_count:0, - defaultActiveKey:"0", + defaultActiveKey:"1", modalsTypes:false, modalsType:false, timuid:0, @@ -64,7 +64,6 @@ class Testpaperlibrary extends Component { } } }); - //获取题库筛选资料 let urls = `/disciplines.json`; axios.get(urls, {params: { @@ -76,18 +75,6 @@ class Testpaperlibrary extends Component { }) } }); - var data={ - discipline_id:this.state.discipline_id, - sub_discipline_id:this.state.sub_discipline_id, - tag_discipline_id:this.state.tag_discipline_id, - public: this.state.defaultActiveKey, - difficulty: this.state.difficulty, - keywords: this.state.keywords, - page: 1, - per_page:10, - } - this.getdata(data); - } paginationonChange=(pages)=>{ @@ -417,6 +404,12 @@ class Testpaperlibrary extends Component { render() { let{Headertop,items_count,page,per_page,modalsTypes,modalsType}=this.state; + + const isysladmins=this.props&&this.props.current_user&&this.props.current_user.admin?this.props.current_user.admin:false; + const is_teacher=this.props&&this.props.current_user&&this.props.current_user.is_teacher?this.props.current_user.is_teacher:false; + const professional_certification=this.props&&this.props.current_user&&this.props.current_user.professional_certification?this.props.current_user.professional_certification:false; + + return (
{ diff --git a/public/react/src/modules/testpaper/component/Contentpart.js b/public/react/src/modules/testpaper/component/Contentpart.js index 1a7c90740..9df40b455 100644 --- a/public/react/src/modules/testpaper/component/Contentpart.js +++ b/public/react/src/modules/testpaper/component/Contentpart.js @@ -38,9 +38,31 @@ class Contentpart extends Component { } + componentDidUpdate(prevProps) { + if(prevProps.current_user !== this.props.current_user) { + const isysladmins=this.props&&this.props.current_user&&this.props.current_user.admin?this.props.current_user.admin:false; + const is_teacher=this.props&&this.props.current_user&&this.props.current_user.is_teacher?this.props.current_user.is_teacher:false; + const professional_certification=this.props&&this.props.current_user&&this.props.current_user.professional_certification?this.props.current_user.professional_certification:false; + let {defaultActiveKey} = this.props; + var defaultActiveKeys=defaultActiveKey; + if(isysladmins===true||(is_teacher===true&&professional_certification===true)){ + defaultActiveKeys="0" + }else{ + defaultActiveKeys="1" + } + this.props.callback(defaultActiveKeys); + } + } + render() { let {page}=this.state; let {defaultActiveKey}=this.props; + + + const isysladmins=this.props&&this.props.current_user&&this.props.current_user.admin?this.props.current_user.admin:false; + const is_teacher=this.props&&this.props.current_user&&this.props.current_user.is_teacher?this.props.current_user.is_teacher:false; + const professional_certification=this.props&&this.props.current_user&&this.props.current_user.professional_certification?this.props.current_user.professional_certification:false; + const contents = (

); + + return (
@@ -82,12 +106,20 @@ class Contentpart extends Component { } - this.props.callback(e)}> - - - - - + { + isysladmins===true||(is_teacher===true&&professional_certification===true)? + this.props.callback(e)}> + + + + + + : + this.props.callback(e)}> + + + + }
-
+
- - diff --git a/public/react/src/modules/testpaper/testioncss/testioncss.css b/public/react/src/modules/testpaper/testioncss/testioncss.css index c22c93f8a..2025779ab 100644 --- a/public/react/src/modules/testpaper/testioncss/testioncss.css +++ b/public/react/src/modules/testpaper/testioncss/testioncss.css @@ -895,3 +895,35 @@ .tites{ color: #888888 !important; } +.conditionsetting{ + width:64px; + height:21px; + font-size:16px; + color:#333333; + line-height:21px; +} + +.conditionsettings{ + width:80px; + height:21px; + font-size:16px; + font-family:MicrosoftYaHei; + color:rgba(51,51,51,1); + line-height:21px; +} +.hengxians{ + width:1021px; + height:1px; + background: #EEEEEE; +} +.mt13{ + margin-top: 13px; +} +.dxuantitie{ + width:57px; + height:19px; + font-size:14px; + font-family:MicrosoftYaHei; + color:rgba(51,51,51,1); + line-height:19px; +}