From 6b734110fb815c8ed308296623544a703cea5f58 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 9 Jan 2020 15:55:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=BC=96=E8=BE=91=E7=AD=94=E6=A1=88?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E8=AF=95=E9=A2=98=E7=9A=84=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/item_analysis.rb | 2 +- app/models/item_choice.rb | 2 +- app/models/tag_discipline_container.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 From c32bce5c3573cbeb6f42c6f8c3d875f86ae6bdd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Thu, 9 Jan 2020 16:21:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=A2=98=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/question/Question.js | 32 ----------------- .../modules/question/component/Contentpart.js | 34 ++++++++++++++----- .../src/modules/testpaper/Testpaperlibrary.js | 27 --------------- .../testpaper/component/Contentpart.js | 30 ++++++++++++---- 4 files changed, 50 insertions(+), 73 deletions(-) diff --git a/public/react/src/modules/question/Question.js b/public/react/src/modules/question/Question.js index 92e97161d..3b2c3a9bd 100644 --- a/public/react/src/modules/question/Question.js +++ b/public/react/src/modules/question/Question.js @@ -72,7 +72,6 @@ class Question extends Component { } chakanjiexibool=(index)=>{ - debugger if(this.state.chakanjiexiboolindex===index){ this.setState({ chakanjiexiboolindex:"无", @@ -163,37 +162,8 @@ class Question extends Component { //初始化 componentDidMount() { - 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.state; - var defaultActiveKeys=defaultActiveKey; - if(isysladmins===true||(is_teacher===true&&professional_certification===true)){ - defaultActiveKeys="0" - }else{ - defaultActiveKeys="1" - } - - - - - 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: defaultActiveKeys, - page:1, - per_page:10, - }; - this.getdata(data); - this.setState({ - defaultActiveKey:defaultActiveKeys - }) - 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({ @@ -203,9 +173,7 @@ class Question extends Component { } } }); - this.getbasket_listdata(); - //获取题库筛选资料 let urls = `/disciplines.json`; axios.get(urls, {params: { diff --git a/public/react/src/modules/question/component/Contentpart.js b/public/react/src/modules/question/component/Contentpart.js index 44871ec76..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){ @@ -119,7 +134,10 @@ class Contentpart extends Component { ); - const buttonWidth = 70; + + console.log("Contentpart.js"); + console.log(this.props.defaultActiveKey); + return (
@@ -148,12 +166,12 @@ class Contentpart extends Component { { isysladmins===true||(is_teacher===true&&professional_certification===true)? - this.props.callback(e)}> - - - - - + this.props.callback(e)}> + + + + + : this.props.callback(e)}> diff --git a/public/react/src/modules/testpaper/Testpaperlibrary.js b/public/react/src/modules/testpaper/Testpaperlibrary.js index 0e8c362df..77192b1b2 100644 --- a/public/react/src/modules/testpaper/Testpaperlibrary.js +++ b/public/react/src/modules/testpaper/Testpaperlibrary.js @@ -51,20 +51,6 @@ class Testpaperlibrary extends Component { //初始化 componentDidMount() { - 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.state; - var defaultActiveKeys=defaultActiveKey; - if(isysladmins===true||(is_teacher===true&&professional_certification===true)){ - defaultActiveKeys="0" - }else{ - defaultActiveKeys="1" - } - - this.setState({ - defaultActiveKey:defaultActiveKeys - }) let url = `/users/get_navigation_info.json`; axios.get(url, {}).then((response) => { // ////console.log("开始请求/get_navigation_info.json"); @@ -78,7 +64,6 @@ class Testpaperlibrary extends Component { } } }); - //获取题库筛选资料 let urls = `/disciplines.json`; axios.get(urls, {params: { @@ -90,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: defaultActiveKeys, - difficulty: this.state.difficulty, - keywords: this.state.keywords, - page: 1, - per_page:10, - } - this.getdata(data); - } paginationonChange=(pages)=>{ diff --git a/public/react/src/modules/testpaper/component/Contentpart.js b/public/react/src/modules/testpaper/component/Contentpart.js index d5b568d52..97db4844b 100644 --- a/public/react/src/modules/testpaper/component/Contentpart.js +++ b/public/react/src/modules/testpaper/component/Contentpart.js @@ -38,6 +38,22 @@ 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; @@ -62,6 +78,8 @@ class Contentpart extends Component {

); + + return (
@@ -90,12 +108,12 @@ class Contentpart extends Component { { isysladmins===true||(is_teacher===true&&professional_certification===true)? - this.props.callback(e)}> - - - - - + this.props.callback(e)}> + + + + + : this.props.callback(e)}>