diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 825040528..9b28d9a10 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -81,6 +81,7 @@ class SubjectsController < ApplicationController def show @user = current_user @is_creator = current_user.creator_of_subject?(@subject) + @is_manager = @user.manager_of_subject?(@subject) # 合作团队 @members = @subject.subject_members.includes(:user) @shixuns = @subject.shixuns.published.pluck(:id) @@ -281,7 +282,7 @@ class SubjectsController < ApplicationController # 删除实训 # DELETE: /api/subejcts/:id/delete_member def delete_member - tip_exception(403, "没权限操作") if !current_user.admin? + tip_exception(403, "没权限操作") unless current_user.manager_of_subject?(@subject) tip_exception('用户id不能为空') if params[:user_id].blank? user = @subject.subject_members.where(:user_id => params[:user_id], :role => 2).first tip_exception("管理员用户不允许删除,或用户不存在") if user.blank? diff --git a/app/models/user.rb b/app/models/user.rb index 7f724d081..9c3d1af39 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -263,9 +263,9 @@ class User < ApplicationRecord course&.course_members.exists?(user_id: id) end - # 实训路径管理员:创建者或admin + # 实训路径管理员 def creator_of_subject?(subject) - subject.user_id == id || admin? + subject.user_id == id end # 实训路径:合作者、admin diff --git a/app/views/subjects/show.json.jbuilder b/app/views/subjects/show.json.jbuilder index d93ee62f9..af524f5b3 100644 --- a/app/views/subjects/show.json.jbuilder +++ b/app/views/subjects/show.json.jbuilder @@ -5,12 +5,12 @@ json.challenges_count @subject.subject_challenge_count json.subject_score @subject.all_score json.member_count @subject.member_count -json.allow_delete @is_creator && (@subject.status != 2 || @user.admin?) +json.allow_delete (@subject.status != 2 && @is_creator) || @user.admin? json.publish_status publish_status(@subject, @is_creator, @user, @shixuns) -json.allow_statistics @user.manager_of_subject?(@subject) +json.allow_statistics @is_manager json.allow_send @user.logged? -json.allow_visit @user.manager_of_subject?(@subject) || @user.admin? || @subject.status > 1 -json.allow_add_member @user.manager_of_subject?(@subject) +json.allow_visit @subject.status > 1 || @is_manager +json.allow_add_member @is_manager json.members @members do |member| json.partial! 'subject_member', locals: { user: member.user } diff --git a/app/views/subjects/up_member_position.json.jbuilder b/app/views/subjects/up_member_position.json.jbuilder index 410b5641b..64038f419 100644 --- a/app/views/subjects/up_member_position.json.jbuilder +++ b/app/views/subjects/up_member_position.json.jbuilder @@ -1,3 +1,4 @@ json.members @subject.subject_members do |member| json.partial! 'subject_member', locals: { user: member.user } + json.role member.role end \ No newline at end of file diff --git a/public/react/src/Loading.js b/public/react/src/Loading.js index cf17d1d1b..e05a36a54 100644 --- a/public/react/src/Loading.js +++ b/public/react/src/Loading.js @@ -5,6 +5,13 @@ import { BrowserRouter as Router, Route, Link } from "react-router-dom"; import { Spin } from 'antd'; class Loading extends Component { + componentDidUpdate(prevProps, prevState) { + if (!prevProps.error && this.props.error) { + console.log(this.props.error) + window.location.reload() + } + } + render() { // Loading return ( diff --git a/public/react/src/modules/courses/ListPageIndex.js b/public/react/src/modules/courses/ListPageIndex.js index 9c1923452..20718c903 100644 --- a/public/react/src/modules/courses/ListPageIndex.js +++ b/public/react/src/modules/courses/ListPageIndex.js @@ -119,17 +119,17 @@ class ListPageIndex extends Component{ {/*头部banner*/} - {mysearch!==undefined? - ( - mysearch===true? - this.setwindowlocal(b)} - > - - :"" - ) - :"" - } + {/*{mysearch!==undefined?*/} + {/*(*/} + {/* mysearch===true?*/} + {/* this.setwindowlocal(b)}*/} + {/* >*/} + {/* */} + {/* :""*/} + {/* )*/} + {/* :""*/} + {/*}*/}
diff --git a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js index a438e78a8..dfdc6291a 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js @@ -246,9 +246,32 @@ class CoursesBanner extends Component { }) var url = `/courses/${id}/duplicate_course.json` axios.post(url).then((response) => { + if(response!==undefined){ + window.location.href = "/courses/" + response.data.new_course_id+"/students"; + }else { + this.modalCancel(); + } // window.location.href = "/courses/" + response.data.new_course_id; - window.location.href = "/courses/" + response.data.new_course_id+"/students"; - }) + + }).catch(function (error) { + this.modalCancel(); + console.log(252); + console.log(error); + }); + + // axios.interceptors.response.use((response) => { + // if (response != undefined) + // if (response && response.data.status === -1) { + // this.setState({ + // antIcon: false, + // }) + // + // } + // return response; + // }, (error) => { + // //TODO 这里如果样式变了会出现css不加载的情况 + // + // }); } if(this.state.metype===6){ diff --git a/public/react/src/modules/courses/shixunHomework/ShixunStudentWork.js b/public/react/src/modules/courses/shixunHomework/ShixunStudentWork.js index 511c40d61..0c2e528c5 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunStudentWork.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunStudentWork.js @@ -72,7 +72,8 @@ class ShixunStudentWork extends Component { showmodel:false, jobsettingsdata:undefined, DownloadType:false, - DownloadMessageval:undefined + DownloadMessageval:undefined, + lunxun:true, } } @@ -121,6 +122,7 @@ class ShixunStudentWork extends Component { getupdata=(pages)=>{ let {order,b_order,page,limit,group_infolist,search}=this.state; + var homeworkid = this.props.match.params.homeworkid; let url = "/homework_commons/" + homeworkid + "/code_review_results.json"; @@ -151,10 +153,10 @@ class ShixunStudentWork extends Component { } this.setState({ data: response.data, - datalist:datas - }) + datalist:datas, + lunxun:false, + }); } - } } @@ -174,7 +176,13 @@ class ShixunStudentWork extends Component { description: response.data.message }); } - + setInterval(() => { + console.log("开始轮询了"); + if(this.state.lunxun===true){ + console.log("开始轮询了getupdata"); + this.getupdatasysk(); + } + }, 5000); }).catch((error) => { @@ -186,6 +194,53 @@ class ShixunStudentWork extends Component { this.setState({ shixuntypes:type[3] }) + }; + getupdatasysk=(pages)=>{ + let {order,b_order,page,limit,group_infolist,search}=this.state; + + var homeworkid = this.props.match.params.homeworkid; + let url = "/homework_commons/" + homeworkid + "/code_review_results.json"; + + axios.get(url,{params:{ + order:order, + sort:b_order, + page:pages===undefined?page:pages, + limit:limit, + group_ids:group_infolist, + search:search + }, + paramsSerializer: function(params) { + return qs.stringify(params, {arrayFormat: 'brackets'}) + }}).then((response) => { + if (response.data.status === undefined || response.data.status === 0) { + if(response.data!=undefined){ + if(response.data.status!=-2){ + let datas=[]; + let list=response.data.users_reviews; + for(var i=0; i { + console.log(error) + }); + + } getcode_review_results=(order,b_order,page,limit,group_infolist,search)=>{ diff --git a/public/react/src/modules/courses/shixunHomework/shixunreport/Shixunechart.js b/public/react/src/modules/courses/shixunHomework/shixunreport/Shixunechart.js index c12ec13d5..d19835f3b 100644 --- a/public/react/src/modules/courses/shixunHomework/shixunreport/Shixunechart.js +++ b/public/react/src/modules/courses/shixunHomework/shixunreport/Shixunechart.js @@ -24,7 +24,8 @@ function startechart(data){ // trigger: 'axis', showDelay : 0, formatter : function (params) { - if(params.name == data.username){ + + if(params.name === data.username){ return "姓名:"+data.username + "
"+'学号: '+data.user_id + "
"+'效率:'+ data.echart_data.myself_eff[1]; }else if (params.value.length > 1) { /* return '学生ID: ' + params.value[2] + '
' @@ -34,6 +35,7 @@ function startechart(data){ return params.name + ":" + params.value +" "; } }, + axisPointer:{ show: true, type : 'cross', @@ -106,7 +108,7 @@ function startechart(data){ markPoint : { data : [ { - name: data.username, + name: data===undefined?"":data.username, xAxis:data.echart_data===undefined?"":data.echart_data.myself_eff[0], yAxis:data.echart_data===undefined?"":data.echart_data.myself_eff[1], value:data.echart_data===undefined?"":data.echart_data.myself_eff[1], @@ -130,13 +132,13 @@ function startechart(data){ ] } }, - { - name:'二班', - type:'scatter', - data: data.echart_data===undefined?"":data.echart_data.myself_eff, - itemStyle:{ - color:'#c23531' - }} + // { + // name:'二班', + // type:'scatter', + // data: data.echart_data===undefined?"":data.echart_data.myself_eff, + // itemStyle:{ + // color:'#c23531' + // }} ]}; effChart.setOption(option); @@ -189,7 +191,7 @@ function startechart(data){ borderWidth: 1, formatter: function (obj) { var value = obj.value; - if(obj.name ==data.username){ + if(obj.name ===data.username){ return "姓名:"+data.username + "
"+'学号: '+data.user_id + "
"+'得分:'+ data.echart_data===undefined?"":data.echart_data.myself_object[1]; } @@ -242,7 +244,7 @@ function startechart(data){ markPoint : { data : [ { - name: data.username, + name: data===undefined?"":data.username, xAxis: data.echart_data===undefined?"":data.echart_data.myself_object[0], yAxis:data.echart_data===undefined?"":data.echart_data.myself_object[1], value:data.echart_data===undefined?"":data.echart_data.myself_object[1] @@ -255,15 +257,15 @@ function startechart(data){ } } }, - { - name: '能力1', - type: 'scatter', - data: data.echart_data===undefined?"":data.echart_data.myself_object, - itemStyle:itemStyle1, - symbolSize: function (val){ - return Math.round(val[2]); - } - } + // { + // name: '能力1', + // type: 'scatter', + // data: data.echart_data===undefined?"":data.echart_data.myself_object, + // itemStyle:itemStyle1, + // symbolSize: function (val){ + // return Math.round(val[2]); + // } + // } ] }; // 使用刚指定的配置项和数据显示图表。 @@ -368,7 +370,7 @@ class Shixunechart extends Component {
  • {data&&data.username}
  • -
  • {data&&data.user_id}
  • +
  • {data!==undefined?"无":data.student_id===undefined?"无":data.student_id===null?"无":data.student_id}
  • {data&&data.echart_data===undefined?"":data&&data.echart_data.myself_eff[1]}
  • {data&&data.echart_data===undefined?"":data&&data.echart_data.myself_eff[0]}
  • @@ -394,7 +396,7 @@ class Shixunechart extends Component {
  • {data&&data.username}
  • -
  • {data&&data.user_id}
  • +
  • {data!==undefined?"无":data.student_id===undefined?"无":data.student_id===null?"无":data.student_id}
  • {data&&data.echart_data===undefined?"":data&&data.echart_data.myself_object[1]}
  • diff --git a/public/react/src/modules/paths/PathDetail/DetailTop.js b/public/react/src/modules/paths/PathDetail/DetailTop.js index 5bfb3c765..701a2a3da 100644 --- a/public/react/src/modules/paths/PathDetail/DetailTop.js +++ b/public/react/src/modules/paths/PathDetail/DetailTop.js @@ -209,7 +209,7 @@ class DetailTop extends Component{ >删除路径:""} { - detailInfoList.publish_status===0&&detailInfoList.allow_statistics===true? + detailInfoList.publish_status===0&&detailInfoList.allow_add_member===true? 申请发布:"" diff --git a/public/react/src/modules/paths/PathDetail/PathDetailIndex.js b/public/react/src/modules/paths/PathDetail/PathDetailIndex.js index 3c17a98f1..fd45f13e6 100644 --- a/public/react/src/modules/paths/PathDetail/PathDetailIndex.js +++ b/public/react/src/modules/paths/PathDetail/PathDetailIndex.js @@ -252,6 +252,10 @@ class PathDetailIndex extends Component{ let param={user_id:user_id}; axios.delete(url,{data:param}).then((response) => { if(response.data.status===1){ + if (this.props.current_user.user_id == user_id) { + this.props.history.push('/paths') + return; + } this.props.showNotification(response.data.message) this.setState({ Modalstype:false,