diff --git a/lib/tasks/publick_course.rake b/lib/tasks/publick_course.rake new file mode 100644 index 000000000..532e32369 --- /dev/null +++ b/lib/tasks/publick_course.rake @@ -0,0 +1,25 @@ +#coding=utf-8 +# 执行示例 bundle exec rake public_course:student args=149,2903 +# args 第一个参数是subject_id,第二个参数是课程course_id + +desc "同步精品课数据" +namespace :public_course do + task :student => :environment do + + + subject_id = ENV['args'].split(",").first + course_id = ENV['args'].split(",").last + puts "subject_id is #{subject_id}" + puts "course_id is #{course_id}" + + user_ids = Myshixun.find_by_sql("select distinct(user_id) from myshixuns where shixun_id in (select shixun_id from stage_shixuns + where stage_id in (select id from stages where subject_id=#{subject_id}))").map(&:user_id) + puts user_ids + if user_ids.present? + user_ids.each do |user_id| + puts user_id + CourseMember.create!(course_id: course_id, user_id: user_id, role: 4) + end + end + end +end \ No newline at end of file diff --git a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js index dfdc6291a..ed4e58e11 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js @@ -248,9 +248,9 @@ class CoursesBanner extends Component { axios.post(url).then((response) => { if(response!==undefined){ window.location.href = "/courses/" + response.data.new_course_id+"/students"; - }else { - this.modalCancel(); + return } + this.modalCancel(); // window.location.href = "/courses/" + response.data.new_course_id; }).catch(function (error) { @@ -259,19 +259,16 @@ class CoursesBanner extends Component { 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不加载的情况 - // - // }); + axios.interceptors.response.use((response) => { + if (response != undefined) + if (response && response.data.status === -1) { + this.modalCancel(); + } + 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 1041bb284..bb5ff3577 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunStudentWork.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunStudentWork.js @@ -153,19 +153,11 @@ class ShixunStudentWork extends Component { } this.setState({ data: response.data, - datalist:datas + datalist:datas, + lunxun:false, + duplicatechecking:false, }); } - this.setState({ - lunxun:false, - }) - }else{ - setInterval(() => { - if(this.state.lunxun===true){ - this.getupdata(); - } - }, 1000); - } } @@ -185,7 +177,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) => { @@ -197,6 +195,55 @@ 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){ + console.log(); + 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 9842aa026..2deffd5c5 100644 --- a/public/react/src/modules/courses/shixunHomework/shixunreport/Shixunechart.js +++ b/public/react/src/modules/courses/shixunHomework/shixunreport/Shixunechart.js @@ -370,7 +370,7 @@ class Shixunechart extends Component {
  • {data&&data.username}
  • -
  • {data&&data.student_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]}
  • @@ -396,7 +396,7 @@ class Shixunechart extends Component {
  • {data&&data.username}
  • -
  • {data&&data.student_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]}