From 7b28dc0cbc1a879b06ef07a48a82b258928dccf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Mon, 9 Sep 2019 21:59:32 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/coursesPublic/AppraiseModal.js | 2 +- .../shixunHomework/ShixunWorkReport.js | 71 +++++---- .../shixunHomework/ShowAppraiseList.js | 141 +++++++++--------- 3 files changed, 103 insertions(+), 111 deletions(-) diff --git a/public/react/src/modules/courses/coursesPublic/AppraiseModal.js b/public/react/src/modules/courses/coursesPublic/AppraiseModal.js index a78e5be62..f1ee18bb7 100644 --- a/public/react/src/modules/courses/coursesPublic/AppraiseModal.js +++ b/public/react/src/modules/courses/coursesPublic/AppraiseModal.js @@ -74,7 +74,7 @@ class AppraiseModal extends Component{ if(response.data.status===0){ debugger this.props.showNotification(response.data.message) - this.props.showCancel(comment,hidden_comment,response.data.comment_id) + this.props.showCancel(comment,hidden_comment,challenge_id,response.data.comment_id) }else{ this.props.showNotification(response.data.message) } diff --git a/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js b/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js index e1b6590b5..a8efd3060 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js @@ -157,7 +157,7 @@ class ShixunWorkReport extends Component { showAppraiseModal=(type,id,show,hidden)=>{ let{data}=this.state; - + debugger if(type==="child"){ data.stage_list.forEach((item,key)=>{ if(item.challenge_id===id){ @@ -188,17 +188,17 @@ class ShixunWorkReport extends Component { showAppraiseModaltype:false, }) } - showAppraiseModals=(show,hidden,id)=>{ + showAppraiseModals=(show,hidden,id,comment_id)=>{ let{data,showAppraisetype}=this.state; - + debugger if(showAppraisetype==="child"){ data.stage_list.forEach((item,key)=>{ if(item.challenge_id===id){ item.challenge_comment=show; item.challenge_comment_hidden=hidden; - item.challenge_id=id; + item.comment_id=comment_id } }) this.setState({ @@ -206,7 +206,7 @@ class ShixunWorkReport extends Component { data:data }) }else{ - data.comment_id=id + data.comment_id=comment_id; this.setState({ showAppraiseModaltype:false, work_comment:show, @@ -216,11 +216,11 @@ class ShixunWorkReport extends Component { } } - isdeleteModal=(comment_id,visible_comment)=>{ + isdeleteModal=(comment_id,visible_comment,type)=>{ this.setState({ modalsType: true, modalsTopval:"是否确认删除?", - modalSave: ()=>this.isdeleteModals(comment_id,visible_comment), + modalSave: ()=>this.isdeleteModals(comment_id,visible_comment,type), modalCancel:()=>this.hideisdeleteModals(), }) } @@ -235,20 +235,25 @@ class ShixunWorkReport extends Component { } - hideisdeleteModal=(comment_id,visible_comment)=>{ + hideisdeleteModal=(comment_id,visible_comment,type)=>{ - let{data,work_comment,work_comment_hidden,showAppraisetype}=this.state; - if(showAppraisetype==="child"){ - data.stage_list.forEach((item,key)=>{ - if(item.comment_id===comment_id){ - if(visible_comment===true){ - item.challenge_comment=null; - }else{ - item.challenge_comment_hidden=null; + let{data,work_comment,work_comment_hidden}=this.state; + + if(type==="child"){ + data.stage_list.map((item,key)=>{ + console.log(item) + if(item.comment_id!=null){ + if(item.comment_id===comment_id){ + if(visible_comment===true){ + item.challenge_comment=null; + }else{ + item.challenge_comment_hidden=null; + } } } }) + this.setState({ modalsType:false, modalsTopval:"是否确认删除?", @@ -256,40 +261,36 @@ class ShixunWorkReport extends Component { modalCancel:"", data:data }) + }else{ - if(visible_comment===true){ - this.setState({ - modalsType:false, - modalsTopval:"是否确认删除?", - modalSave: "", - modalCancel:"", - work_comment:visible_comment===true?null:work_comment, - }) - }else{ + this.setState({ modalsType:false, modalsTopval:"是否确认删除?", modalSave: "", modalCancel:"", - work_comment_hidden:visible_comment===false?null:work_comment_hidden + work_comment:null, + work_comment_hidden:null }) - } + } } - isdeleteModals=(comment_id,visible_comment)=>{ + isdeleteModals=(comment_id,visible_comment,type)=>{ + let newcomment_id=comment_id; + let newvisible_comment=visible_comment; + let newtype=type; + let url =`/student_works/${this.props.match.params.homeworkid}/destroy_work_comment.json` axios.delete(url, { data: { comment_id:comment_id, - visible_comment:visible_comment }}).then((response) => { // const { status } = response.data; if(response.data.status===0){ this.props.showNotification(response.data.message) - - this.hideisdeleteModal(comment_id,visible_comment) + this.hideisdeleteModal(newcomment_id,newvisible_comment,newtype) }else{ this.props.showNotification(response.data.message) } @@ -308,9 +309,7 @@ class ShixunWorkReport extends Component { // let showAppraiseModals=this.props&&this.props.isAdminOrTeacher()===true?work_comment===null||work_comment===undefined?false:true:work_comment===null||work_comment===undefined?false:true; let showAppraiseModals=work_comment===null||work_comment===undefined?false:true; - console.log(data) - console.log(work_comment_hidden) - console.log(work_comment) + return ( data===undefined?"": @@ -329,7 +328,7 @@ class ShixunWorkReport extends Component { {...this.state} visible={showAppraiseModaltype} Cancel={()=>this.hideAppraiseModal()} - showCancel={(show,hidden,id)=>this.showAppraiseModals(show,hidden,id)} + showCancel={(show,hidden,id,comment_id)=>this.showAppraiseModals(show,hidden,id,comment_id)} work_comment={this.state.work_comment} work_type={work_comment===null||work_comment===undefined?this.state.work_type:work_comment_hidden===true?1:0} />:""} @@ -551,7 +550,7 @@ class ShixunWorkReport extends Component { this.isdeleteModal(comment_id,visible_comment)} + isdeleteModal={(comment_id,visible_comment,type)=>this.isdeleteModal(comment_id,visible_comment,type)} showAppraiseModal={(type,id,show,hidden)=>this.showAppraiseModal(type,id,show,hidden)} /> diff --git a/public/react/src/modules/courses/shixunHomework/ShowAppraiseList.js b/public/react/src/modules/courses/shixunHomework/ShowAppraiseList.js index 66ac56a63..f53ad2cd9 100644 --- a/public/react/src/modules/courses/shixunHomework/ShowAppraiseList.js +++ b/public/react/src/modules/courses/shixunHomework/ShowAppraiseList.js @@ -11,16 +11,12 @@ class ShowAppraiseList extends Component{ } } - componentDidMount() { - - - } - render(){ - let {data,work_comment,work_comment_hidden}=this.props; - console.log(data) + let {data, work_comment,work_comment_hidden}=this.props; + let work_commenttype=work_comment===undefined||work_comment===null||work_comment===""; + let work_comment_hiddentype=work_comment===undefined||work_comment===null||work_comment===""; return(
- {data===undefined?"":work_comment===undefined||work_comment===null||work_comment===""?"": + {data===undefined?"":work_commenttype===true&&work_comment_hiddentype===true?"":
@@ -49,7 +53,7 @@ class ShowAppraiseList extends Component{ 总体评阅评阅内容 {this.props&&this.props.isAdminOrTeacher()===true?this.props.isdeleteModal(data.comment_id,true)} + onClick={()=>this.props.isdeleteModal(data.comment_id,true,"main")} >删除:""} {this.props&&this.props.isAdminOrTeacher()===true? -
+ {this.props&&this.props.isAdminOrTeacher()===true? +
+
+ 学生不可见(仅对课堂老师可见) +
+
+ {work_comment_hidden===true?"":
+
+
} +
+
+ 学生可见(学生可查看老师的评阅内容) +
-
+ {work_comment===true?"":
-
+
}
-
- -
-
} - - - - {data===undefined?"":work_comment_hidden===undefined||work_comment_hidden===null||work_comment_hidden===""?"":this.props&&this.props.isAdminOrTeacher()===true? -
- +
}
-
:""} + } + + {data===undefined?"":data.stage_list.map((item,key)=>{ let challenge_comment_hidden=item.challenge_comment_hidden===undefined||item.challenge_comment_hidden===null||item.challenge_comment_hidden===""; let challenge_comment=item.challenge_comment===undefined||item.challenge_comment===null||item.challenge_comment===""; + return( -
- {challenge_comment===false?
+
+ {challenge_comment===false&&challenge_comment_hidden==false?
- 第{key+1}关评阅内容 + 第{key+1}关{item.name} {this.props&&this.props.isAdminOrTeacher()===true?this.props.isdeleteModal(item.comment_id,true)} + onClick={()=>this.props.isdeleteModal(item.comment_id,true,"child")} >删除:""} {this.props&&this.props.isAdminOrTeacher()===true?this.props.showAppraiseModal("child",item.challenge_id,item.challenge_comment,item.challenge_comment_hidden)} >编辑:""}
-
-
-
-
-
-
-
- -
-
:""} - - {challenge_comment_hidden===false&&this.props&&this.props.isAdminOrTeacher()===true?
-
-
- 第{key+1}关评阅内容(仅对课堂老师可见) - - {this.props&&this.props.isAdminOrTeacher()===true?this.props.isdeleteModal(item.comment_id,false)} - >删除:""} + {this.props&&this.props.isAdminOrTeacher()===true? +
+
+ 学生不可见(仅对课堂老师可见) +
+
+ {challenge_comment_hidden===true?"":
+
+
} +
+
+ 学生可见(学生可查看老师的评阅内容) +
+
+ {challenge_comment===true?"":
+
+
} +
- {this.props&&this.props.isAdminOrTeacher()===true?this.props.showAppraiseModal("child",item.challenge_id,item.challenge_comment,item.challenge_comment_hidden)} - >编辑:""} -
-
-
-
-
+
:
+
+
+
+
-
-
+
}
:""} From 06c750162b7c4bf0e376e0a3161598568a0bb485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Mon, 9 Sep 2019 22:02:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/courses/shixunHomework/ShixunWorkReport.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js b/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js index a8efd3060..ab801fe40 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js @@ -245,11 +245,8 @@ class ShixunWorkReport extends Component { console.log(item) if(item.comment_id!=null){ if(item.comment_id===comment_id){ - if(visible_comment===true){ - item.challenge_comment=null; - }else{ - item.challenge_comment_hidden=null; - } + item.challenge_comment=null; + item.challenge_comment_hidden=null; } } })