diff --git a/lib/tasks/public_course_sync.rake b/lib/tasks/public_course_sync.rake new file mode 100644 index 000000000..928cd9113 --- /dev/null +++ b/lib/tasks/public_course_sync.rake @@ -0,0 +1,149 @@ +#coding=utf-8 +# 执行示例 bundle exec rake public_course:student args=149,2903 +# args 第一个参数是subject_id,第二个参数是课程course_id +# 第一期时间:2018-12-16 至2019-03-31 +# 第二期时间:2019-04-07 至2019-07-28 +# +# 这次学习很有收获,感谢老师提供这么好的资源和细心的服务🎉🎉🎉 +# + +desc "同步精品课数据" +namespace :public_classes do + if ENV['args'] + subject_id = ENV['args'].split(",")[0] # 对应课程的id + course_id = ENV['args'].split(",")[1] # 对应课堂的id + start_time = ENV['args'].split(",")[2] # 表示课程模块 + end_time = ENV['args'].split(",")[3] # 表示课程模块 + limit = ENV['args'].split(",")[4] # 限制导入的数量 + type = ENV['args'].split(",")[5] # 表示课程模块 + end + + + task :student => :environment do + 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 created_at between #{start_time} and #{end_time} and shixun_id in (select shixun_id from stage_shixuns + where stage_id in (select id from stages where subject_id=#{subject_id})) limit #{limit}").map(&:user_id) + puts user_ids + if user_ids.present? + user_ids.each do |user_id| + puts user_id + begin + CourseMember.create!(course_id: course_id, user_id: user_id, role: 4) + rescue Exception => e + Rails.logger(e.message) + end + end + end + end + + task :test_user => :environment do + users = User.where(is_test: true) + users.limit(limit).find_each do |user| + puts user.id + CourseMember.create!(course_id: course_id, user_id: user.id, role: 4) + end + end + + + # 更新某个课程的某类时间 + # 执行示例 RAILS_ENV=production bundle exec rake public_course:time args=-1,2932,1,1 + task :time => :environment do + # course_id = ENV['args'].split(",")[0] # 对应课堂的id + # type = ENV['args'].split(",")[1] + + course = Course.find(course_id) + + case type.to_i + when 1 + # 讨论区 + messages = Message.where(board_id: course.boards) + messages.each do |message| + created_on = random_time start_time, end_time + puts created_on + message.update_columns(created_on: created_on, updated_on: created_on) + MessageDetail.where(message_id: message.id).each do |detail| + rand_created_on = random_time start_time, end_time + detail.update_columns(created_at: rand_created_on, updated_at: rand_created_on) + end + end + when 2 + # 作业 + course.homework_commons.each do |homework| + created_at = random_time(start_time, end_time) + publish_time = random_larger_time created_at, start_time, end_time + end_time = random_larger_time publish_time, start_time, end_time + updated_at = end_time + + homework.update_columns(publish_time: publish_time, end_time: end_time, created_at: created_at, updated_at: updated_at) + homework.homework_detail_manual.update_columns(comment_status: 6, created_at: created_at, updated_at: updated_at) + + homework.student_works.where("work_status !=0 and update_time > '#{end_time}'").update_all(update_time: end_time) + end + when 3 + # 试卷 + course.exercises.each do |exercise| + created_at = random_time start_time, end_time + publish_time = random_larger_time created_at, start_time, end_time + end_time = random_larger_time publish_time, start_time, end_time + updated_at = end_time + + exercise.update_columns(publish_time: publish_time, end_time: end_time, created_at: created_at, updated_at: updated_at, exercise_status: 3) + end + when 4 + # 资源 + course.attachments.each do |atta| + created_on = random_time start_time, end_time + + atta.update_columns(is_publish: 1, created_on: created_on, publish_time: created_on) + end + end + + end + + task :create_homework_work => :environment do + course = Course.find(course_id) + course.practice_homeworks.each do |homework| + if homework.student_works.count == 0 + str = "" + CourseMember.students(course).each do |student| + str += "," if str != "" + str += "(#{homework.id},#{student.user_id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" + end + if str != "" + sql = "insert into student_works (homework_common_id, user_id, created_at, updated_at) values" + str + ActiveRecord::Base.connection.execute sql + end + end + end + end + + def min_swith(time) + puts time + return time < 9 ? "0#{time}" : time + end + + def random_time(start_time, end_time) + hour = (6..23).to_a.sample(1).first + min = rand(60) + sec = rand(60) + + start_time = Date.parse(start_time) + end_time = Date.parse(end_time) + date = (start_time..end_time).to_a.sample(1).first + + time = "#{date} #{min_swith(hour)}:#{min_swith(min)}:#{min_swith(sec)}" + + puts time + time + end + + def random_larger_time(time, start_time, end_time) + large_time = random_time(start_time, end_time) + while large_time <= time + large_time = random_time(start_time, end_time) + end + large_time + end +end \ No newline at end of file diff --git a/public/javascripts/wx/jweixin-1.3.0.js b/public/javascripts/wx/jweixin-1.3.0.js new file mode 100644 index 000000000..d06d2c362 --- /dev/null +++ b/public/javascripts/wx/jweixin-1.3.0.js @@ -0,0 +1 @@ +!function(e,n){"function"==typeof define&&(define.amd||define.cmd)?define(function(){return n(e)}):n(e,!0)}(this,function(e,n){function i(n,i,t){e.WeixinJSBridge?WeixinJSBridge.invoke(n,o(i),function(e){c(n,e,t)}):u(n,t)}function t(n,i,t){e.WeixinJSBridge?WeixinJSBridge.on(n,function(e){t&&t.trigger&&t.trigger(e),c(n,e,i)}):t?u(n,t):u(n,i)}function o(e){return e=e||{},e.appId=C.appId,e.verifyAppId=C.appId,e.verifySignType="sha1",e.verifyTimestamp=C.timestamp+"",e.verifyNonceStr=C.nonceStr,e.verifySignature=C.signature,e}function r(e){return{timeStamp:e.timestamp+"",nonceStr:e.nonceStr,package:e.package,paySign:e.paySign,signType:e.signType||"SHA1"}}function a(e){return e.postalCode=e.addressPostalCode,delete e.addressPostalCode,e.provinceName=e.proviceFirstStageName,delete e.proviceFirstStageName,e.cityName=e.addressCitySecondStageName,delete e.addressCitySecondStageName,e.countryName=e.addressCountiesThirdStageName,delete e.addressCountiesThirdStageName,e.detailInfo=e.addressDetailInfo,delete e.addressDetailInfo,e}function c(e,n,i){"openEnterpriseChat"==e&&(n.errCode=n.err_code),delete n.err_code,delete n.err_desc,delete n.err_detail;var t=n.errMsg;t||(t=n.err_msg,delete n.err_msg,t=s(e,t),n.errMsg=t),(i=i||{})._complete&&(i._complete(n),delete i._complete),t=n.errMsg||"",C.debug&&!i.isInnerInvoke&&alert(JSON.stringify(n));var o=t.indexOf(":");switch(t.substring(o+1)){case"ok":i.success&&i.success(n);break;case"cancel":i.cancel&&i.cancel(n);break;default:i.fail&&i.fail(n)}i.complete&&i.complete(n)}function s(e,n){var i=e,t=v[i];t&&(i=t);var o="ok";if(n){var r=n.indexOf(":");"confirm"==(o=n.substring(r+1))&&(o="ok"),"failed"==o&&(o="fail"),-1!=o.indexOf("failed_")&&(o=o.substring(7)),-1!=o.indexOf("fail_")&&(o=o.substring(5)),"access denied"!=(o=(o=o.replace(/_/g," ")).toLowerCase())&&"no permission to execute"!=o||(o="permission denied"),"config"==i&&"function not exist"==o&&(o="ok"),""==o&&(o="fail")}return n=i+":"+o}function d(e){if(e){for(var n=0,i=e.length;n0){var n=e.split("?")[0],i=e.split("?")[1];return n+=".html",void 0!==i?n+"?"+i:n}}if(!e.jWeixin){var h={config:"preVerifyJSAPI",onMenuShareTimeline:"menu:share:timeline",onMenuShareAppMessage:"menu:share:appmessage",onMenuShareQQ:"menu:share:qq",onMenuShareWeibo:"menu:share:weiboApp",onMenuShareQZone:"menu:share:QZone",previewImage:"imagePreview",getLocation:"geoLocation",openProductSpecificView:"openProductViewWithPid",addCard:"batchAddCard",openCard:"batchViewCard",chooseWXPay:"getBrandWCPayRequest",openEnterpriseRedPacket:"getRecevieBizHongBaoRequest",startSearchBeacons:"startMonitoringBeacons",stopSearchBeacons:"stopMonitoringBeacons",onSearchBeacons:"onBeaconsInRange",consumeAndShareCard:"consumedShareCard",openAddress:"editAddress"},v=function(){var e={};for(var n in h)e[h[n]]=n;return e}(),S=e.document,I=S.title,y=navigator.userAgent.toLowerCase(),_=navigator.platform.toLowerCase(),w=!(!_.match("mac")&&!_.match("win")),T=-1!=y.indexOf("wxdebugger"),k=-1!=y.indexOf("micromessenger"),M=-1!=y.indexOf("android"),P=-1!=y.indexOf("iphone")||-1!=y.indexOf("ipad"),x=function(){var e=y.match(/micromessenger\/(\d+\.\d+\.\d+)/)||y.match(/micromessenger\/(\d+\.\d+)/);return e?e[1]:""}(),V={initStartTime:p(),initEndTime:0,preVerifyStartTime:0,preVerifyEndTime:0},A={version:1,appId:"",initTime:0,preVerifyTime:0,networkType:"",isPreVerifyOk:1,systemType:P?1:M?2:-1,clientVersion:x,url:encodeURIComponent(location.href)},C={},L={_completes:[]},B={state:0,data:{}};f(function(){V.initEndTime=p()});var O=!1,N=[],b={config:function(e){C=e,u("config",e);var n=!1!==C.check;f(function(){if(n)i(h.config,{verifyJsApiList:d(C.jsApiList)},function(){L._complete=function(e){V.preVerifyEndTime=p(),B.state=1,B.data=e},L.success=function(e){A.isPreVerifyOk=0},L.fail=function(e){L._fail?L._fail(e):B.state=-1};var e=L._completes;return e.push(function(){l()}),L.complete=function(n){for(var i=0,t=e.length;i0){var n=N.shift();wx.getLocalImgData(n)}},e))):N.push(e)},getNetworkType:function(e){var n=function(e){var n=e.errMsg;e.errMsg="getNetworkType:ok";var i=e.subtype;if(delete e.subtype,i)e.networkType=i;else{var t=n.indexOf(":"),o=n.substring(t+1);switch(o){case"wifi":case"edge":case"wwan":e.networkType=o;break;default:e.errMsg="getNetworkType:fail"}}return e};i("getNetworkType",{},(e._complete=function(e){e=n(e)},e))},openLocation:function(e){i("openLocation",{latitude:e.latitude,longitude:e.longitude,name:e.name||"",address:e.address||"",scale:e.scale||28,infoUrl:e.infoUrl||""},e)},getLocation:function(e){e=e||{},i(h.getLocation,{type:e.type||"wgs84"},(e._complete=function(e){delete e.type},e))},hideOptionMenu:function(e){i("hideOptionMenu",{},e)},showOptionMenu:function(e){i("showOptionMenu",{},e)},closeWindow:function(e){i("closeWindow",{},e=e||{})},hideMenuItems:function(e){i("hideMenuItems",{menuList:e.menuList},e)},showMenuItems:function(e){i("showMenuItems",{menuList:e.menuList},e)},hideAllNonBaseMenuItem:function(e){i("hideAllNonBaseMenuItem",{},e)},showAllNonBaseMenuItem:function(e){i("showAllNonBaseMenuItem",{},e)},scanQRCode:function(e){i("scanQRCode",{needResult:(e=e||{}).needResult||0,scanType:e.scanType||["qrCode","barCode"]},(e._complete=function(e){if(P){var n=e.resultStr;if(n){var i=JSON.parse(n);e.resultStr=i&&i.scan_code&&i.scan_code.scan_result}}},e))},openAddress:function(e){i(h.openAddress,{},(e._complete=function(e){e=a(e)},e))},openProductSpecificView:function(e){i(h.openProductSpecificView,{pid:e.productId,view_type:e.viewType||0,ext_info:e.extInfo},e)},addCard:function(e){for(var n=e.cardList,t=[],o=0,r=n.length;oEduCoder diff --git a/public/react/src/App.js b/public/react/src/App.js index 49c2eab99..fbb9ac7b0 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -281,7 +281,58 @@ class App extends Component { mydisplay:true, }) }; + initWXShare = () => { + if (window.wx) { + const wx = window.wx + const url = '/wechats/js_sdk_signature.json' + axios.post(url, { + url: 'http://pre-newweb.educoder.net', + }).then((response) => { + const data = response.data; + wx.config({ + debug: false, + appId: data.appid, + timestamp: data.timestamp, + nonceStr: data.nonceStr, + signature: data.signature, + jsApiList: [ + 'onMenuShareTimeline',// + 'onMenuShareAppMessage', + 'onMenuShareQQ', + 'onMenuShareWeibo', + 'onMenuShareQZone' + + ] + }); + wx.ready(function () { + var shareData = { + title: '这是是分享标题', + desc: '这是是摘要', + link: 'http://pre-newweb.educoder.net', + imgUrl: 'http://pre-newweb.educoder.net/images/educoder/index/subject/subject15.jpg' + }; + + wx.onMenuShareAppMessage(shareData);//分享给好友 + wx.onMenuShareTimeline(shareData);//分享到朋友圈 + wx.onMenuShareQQ(shareData);//分享给手机QQ + wx.onMenuShareWeibo(shareData);//分享腾讯微博 + wx.onMenuShareQZone(shareData);//分享到QQ空间 + + + + }); + wx.error(function (res) { + //alert(res.errMsg);//错误提示 + + }); + }).catch((error) => { + console.log(error) + }) + } + } componentDidMount() { + + // force an update if the URL changes history.listen(() => { this.forceUpdate() @@ -291,7 +342,7 @@ class App extends Component { }); initAxiosInterceptors(this.props) - + this.initWXShare() // // axios.interceptors.response.use((response) => { // // console.log("response"+response); diff --git a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js index 1a7c19824..24235d723 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js @@ -749,9 +749,9 @@ class Coursesleftnav extends Component{ {/*毕业设计*/} {/*{item.type==="graduation"?
this.Navmodalnames(1,"attachment",item.id)}>添加目录
:""}*/} {/*讨论区*/} - {item.type==="board"?
this.Navmodalnames(e,6,"board",item.main_id)}>添加目录
:""} + {item.type==="board"?this.props.current_user&&this.props.current_user.course_is_end===true?"":
this.Navmodalnames(e,6,"board",item.main_id)}>添加目录
:""} {/*分班*/} - {item.type==="course_group"?
this.Navmodalnames(e,2,"course_group",item.id)}>添加分班
:""} + {item.type==="course_group"?this.props.current_user&&this.props.current_user.course_is_end===true?"":
this.Navmodalnames(e,2,"course_group",item.id)}>添加分班
:""} {/*分班*/} {/*{item.type==="course_group"? :""}*/}
this.Navmodalnames(e,3,"editname",item.id,item.name)}>重命名
@@ -798,7 +798,6 @@ class Coursesleftnav extends Component{ // console.log("778"); // console.log("CoursesLeftNav"); - // console.log(this.props); // console.log(course_modules); return( diff --git a/public/react/src/modules/courses/graduation/topics/index.js b/public/react/src/modules/courses/graduation/topics/index.js index b5be57564..ef4257e2e 100644 --- a/public/react/src/modules/courses/graduation/topics/index.js +++ b/public/react/src/modules/courses/graduation/topics/index.js @@ -58,7 +58,7 @@ class Boards extends Component{ let {pageSize}=this.state; const cid = this.props.match.params.coursesId - let url = `/courses/${cid}/graduation_topics.json?limit=`+pageSize + let url = `/courses/${cid}/graduation_topics.json?limit=${pageSize}` if(searchValue!=""){ url+="&search="+searchValue } @@ -68,7 +68,17 @@ class Boards extends Component{ if(status!="" && status != "all"){ url+="&status="+status; } - axios.get(url).then((response) => { + url=encodeURI(url);//IE11传参为乱码(search) + axios.get(url + // ,{ + // params:{ + // search:encodeURI(searchValue), + // page:page, + // status:status, + // limit:pageSize + // } + // } + ).then((response) => { if (response.status == 200 && response.status) { this.setState({ data:response.data, diff --git a/public/react/src/modules/courses/poll/Poll.js b/public/react/src/modules/courses/poll/Poll.js index b395b2bd2..288ac6f2c 100644 --- a/public/react/src/modules/courses/poll/Poll.js +++ b/public/react/src/modules/courses/poll/Poll.js @@ -116,6 +116,7 @@ class Poll extends Component{ if(search!=""&&search!=undefined){ url+="&search="+search } + url=encodeURI(url);//IE11传参为乱码(search) axios.get(url).then((result)=>{ if(result){ this.setState({ diff --git a/public/react/src/modules/courses/shixunHomework/Listofworksstudentone.js b/public/react/src/modules/courses/shixunHomework/Listofworksstudentone.js index a803ecdd2..bba76386a 100644 --- a/public/react/src/modules/courses/shixunHomework/Listofworksstudentone.js +++ b/public/react/src/modules/courses/shixunHomework/Listofworksstudentone.js @@ -2641,7 +2641,7 @@ class Listofworksstudentone extends Component {
  • 计算成绩时间:{teacherdata&&teacherdata.calculation_time==null?"--": moment(teacherdata&&teacherdata.calculation_time).format('YYYY-MM-DD HH:mm')} - {course_is_end===true? + {course_is_end===true?"": {teacherdata&&teacherdata.publish_immediately===false&&computeTimetype===true? (this.props.isNotMember()===false?
    计算成绩 @@ -2651,7 +2651,7 @@ class Listofworksstudentone extends Component { 计算成绩
    :"") } -
    :""} +
    }
    计算成绩时间:{teacherdata&&teacherdata.calculation_time==null?"--": moment(teacherdata&&teacherdata.calculation_time).format('YYYY-MM-DD HH:mm')} { course_is_end===true?"":teacherdata&&teacherdata.task_operation&&teacherdata.task_operation[0]==="开启挑战"?"": - {computeTimetype===true? - (this.props.isNotMember()===false?
    - 计算成绩 -
    :""): - teacherdata&&teacherdata.homework_status!==undefined&&teacherdata.homework_status[0]=== "未发布"? "": - (this.props.isNotMember()===false?
    - 计算成绩 -
    :"") - } -
    } + {computeTimetype===true? + (this.props.isNotMember()===false?
    + 计算成绩 +
    :""): + teacherdata&&teacherdata.homework_status!==undefined&&teacherdata.homework_status[0]=== "未发布"? "": + (this.props.isNotMember()===false?
    + 计算成绩 +
    :"") + } + }
    {/*因为计算按钮占了和这个位置,和设计沟通学生视角取消这个按钮*/} diff --git a/public/react/src/modules/page/component/monaco/TPIMonaco.js b/public/react/src/modules/page/component/monaco/TPIMonaco.js index c16889db2..83d55915e 100644 --- a/public/react/src/modules/page/component/monaco/TPIMonaco.js +++ b/public/react/src/modules/page/component/monaco/TPIMonaco.js @@ -188,6 +188,19 @@ function getLanguageByMirrorName(mirror_name) { } let notCallCodeMirrorOnChangeFlag = false; + +/** + props : + mirror_name 决定语言 + isEditablePath + repositoryCode + + codemirrorDidMount + + shixun.forbid_copy + + showSettingDrawer, settingDrawerOpen +*/ class TPIMonaco extends Component { constructor(props) { @@ -201,7 +214,7 @@ class TPIMonaco extends Component { } componentDidUpdate(prevProps, prevState, snapshot) { - const { game, mirror_name } = this.props + const { mirror_name } = this.props const editor_monaco = this.editor_monaco; if (editor_monaco && !_.isEqual(prevProps.mirror_name, mirror_name)) { // TODO 后期考虑加入,根据文件类型的不同,使用不同的lang @@ -294,7 +307,7 @@ class TPIMonaco extends Component { }) this.props.codemirrorDidMount && this.props.codemirrorDidMount() - if(this.props.shixun.forbid_copy == true) { + if(this.props.shixun && this.props.shixun.forbid_copy == true) { // 禁用粘贴 // https://github.com/Microsoft/monaco-editor/issues/100 window.editor_monaco.onDidPaste( (a, b, c) => { window.__pastePosition = a })