From 97dab335f3f6c83d159c434e4ae5a948de2dc483 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 16 Jan 2020 14:39:05 +0800 Subject: [PATCH 01/15] =?UTF-8?q?=E9=95=9C=E5=83=8F=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/edu_datas/game.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/edu_datas/game.json.jbuilder b/app/views/edu_datas/game.json.jbuilder index 3f4a0335e..963583d2f 100644 --- a/app/views/edu_datas/game.json.jbuilder +++ b/app/views/edu_datas/game.json.jbuilder @@ -3,4 +3,5 @@ json.game @game json.shixun @shixun json.shixun_env @env +json.shixun_image @shixun.main_mirror_name json.shixun_tags @shixun_tags \ No newline at end of file From 00a5bb8834853ad62e185f67d4c9f8a85d47aef5 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 17 Jan 2020 13:56:57 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/git_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/git_service.rb b/app/services/git_service.rb index 2bfc7423c..3f7a42c97 100644 --- a/app/services/git_service.rb +++ b/app/services/git_service.rb @@ -68,8 +68,8 @@ class GitService content = JSON.parse(body) if content["code"] != 0 - raise("版本库异常") logger.error("repository error: #{content['msg']}") + raise("版本库异常") end #raise content["msg"] if content["code"] != 0 From fa1affb3f71c6ac1530300f85649ee71b8a07639 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 17 Jan 2020 14:17:38 +0800 Subject: [PATCH 03/15] 1 --- app/helpers/student_works_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/student_works_helper.rb b/app/helpers/student_works_helper.rb index 40759c9e0..9a91dfbf2 100644 --- a/app/helpers/student_works_helper.rb +++ b/app/helpers/student_works_helper.rb @@ -82,7 +82,7 @@ module StudentWorksHelper # 最大效率值 # max_efficiency = objects.map{|o| o[:efficiency]}.max results = - objects.each_with_index.map do |object, index| + objects.map_with_index do |object, index| y_score = (object[:evaluate_count] == 0 ? 0 : (object[:user_total_score] / object[:evaluate_count].to_f)) eff_score = format("%.2f", y_score).to_f # 效率值 From 8e85bbdc4d7744c1bb3c2f2bdb201482b3805fa4 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 17 Jan 2020 14:43:59 +0800 Subject: [PATCH 04/15] 1 --- app/helpers/student_works_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/student_works_helper.rb b/app/helpers/student_works_helper.rb index 9a91dfbf2..40759c9e0 100644 --- a/app/helpers/student_works_helper.rb +++ b/app/helpers/student_works_helper.rb @@ -82,7 +82,7 @@ module StudentWorksHelper # 最大效率值 # max_efficiency = objects.map{|o| o[:efficiency]}.max results = - objects.map_with_index do |object, index| + objects.each_with_index.map do |object, index| y_score = (object[:evaluate_count] == 0 ? 0 : (object[:user_total_score] / object[:evaluate_count].to_f)) eff_score = format("%.2f", y_score).to_f # 效率值 From 8457cfc406ac2c6dbf51e5cade04c20a70524118 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 17 Jan 2020 16:58:01 +0800 Subject: [PATCH 05/15] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/zip_pack.rake | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/tasks/zip_pack.rake b/lib/tasks/zip_pack.rake index e3215090b..9cfb36a8e 100644 --- a/lib/tasks/zip_pack.rake +++ b/lib/tasks/zip_pack.rake @@ -38,9 +38,8 @@ namespace :zip_pack do def zip_homework_pdf homeworks, folder, parallel_size Dir.mkdir(folder) unless File.directory?(folder) - homeworks = homeworks.includes(:score_student_works) - Parallel.each(homeworks, in_processes: 2) do |homework| + homeworks.includes(:score_student_works).each do |homework| out_file_name = "#{Time.now.strftime("%Y%m%d%H%M%S").to_s}-#{homework.course_id}-#{homework.name}.zip" out_file_name.gsub!(" ", "-") out_file_name.gsub!("/", "_") @@ -51,21 +50,26 @@ namespace :zip_pack do if student_works.size > 0 pdfs = [] + file_paths = [] + student_works.find_in_batches(batch_size: 500) do |sw| + Parallel.each(sw, in_threads: parallel_size) do |student_work| + export = ExportShixunReportService.new(homework, student_work) + pdf = export.to_pdf + pdfs << pdf + file_paths << {filename: export.filename, path: pdf.path} + puts "out: #{export.filename}_#{pdf.path}" + end + end + Zip::File.open(zipfile_name, Zip::File::CREATE) do |zip| - student_works.find_in_batches(batch_size: 500) do |sw| - Parallel.each(sw, in_processes: parallel_size) do |student_work| - export = ExportShixunReportService.new(homework, student_work) - pdf = export.to_pdf - pdfs << pdf - begin - zip.add(export.filename, pdf.path) - puts "out: #{export.filename}_#{pdf.path}" - rescue => ex - Rails.logger.error(ex.message) + file_paths.each do |pdf| + begin + zip.add(pdf[:filename], pdf[:path]) + rescue => ex + Rails.logger.error(ex.message) - zip.get_output_stream('FILE_NOTICE.txt'){|os| os.write("文件重复:#{export.filename}") } - next - end + zip.get_output_stream('FILE_NOTICE.txt'){|os| os.write("文件重复:#{export.filename}") } + next end end end From b6f42ad542acc98a2c13b438dd4bb6570a4463db Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 17 Jan 2020 17:31:10 +0800 Subject: [PATCH 06/15] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/statistic_subject_info.rake | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/tasks/statistic_subject_info.rake b/lib/tasks/statistic_subject_info.rake index 259824174..aecaa1866 100644 --- a/lib/tasks/statistic_subject_info.rake +++ b/lib/tasks/statistic_subject_info.rake @@ -10,7 +10,7 @@ namespace :subjects do column_value = "subject_id, study_count, course_study_count, initiative_study, passed_count, course_used_count, " + "school_used_count, created_at, updated_at" subjects.find_in_batches(batch_size: 50) do |s| - Parallel.each(s, in_processes: 4) do |subject| + Parallel.each_with_index(s, in_processes: 4) do |subject, index| puts("---------------------data_statistic: #{subject.id}") Rails.logger.info("---------------------data_statistic: #{subject.id}") data = Subjects::DataStatisticService.new(subject) @@ -23,7 +23,7 @@ namespace :subjects do "#{data.passed_count}, #{data.course_used_count}, #{data.school_used_count}, " + "'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')") buffer_size += 1 - if buffer_size == 1000 + if buffer_size == 1000 || (index +1) == data.size sql = "REPLACE INTO subject_records(#{column_value}) VALUES #{str}" puts sql ActiveRecord::Base.connection.execute sql @@ -55,14 +55,14 @@ namespace :subjects do puts("---------------------course_info_statistic: #{subject.id}") Rails.logger.info("---------------------course_info_statistic: #{subject.id}") data = Subjects::CourseUsedInfoService.call(subject) - Parallel.map(data) do |key| + Parallel.map_with_index(data) do |key, index| next if key[:school_id].nil? str += ", " unless str.empty? str += ("(#{subject.id}, #{key[:school_id]}, '#{key[:school_name]}', #{key[:course_count]}, " + "#{key[:student_count]}, #{key[:choice_shixun_num]}, #{key[:choice_shixun_frequency]}, " + "'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')") buffer_size += 1 - if buffer_size == 1000 + if buffer_size == 1000 || (index + 1) == data.size sql = "REPLACE INTO subject_course_records(#{column_value}) VALUES #{str}" puts sql ActiveRecord::Base.connection.execute sql @@ -90,11 +90,11 @@ namespace :subjects do column_value = "subject_id, shixun_id, stage, shixun_name, challenge_count, course_count, " + "school_count, used_count, passed_count, evaluate_count, passed_ave_time, created_at, updated_at" subjects.find_in_batches(batch_size: 50) do |s| - Parallel.each(s, in_processes: 4) do |subject| + Parallel.each_with_index(s, in_processes: 4) do |subject| puts("---------------------shixun_info_statistic: #{subject.id}") Rails.logger.info("---------------------shixun_info_statistic: #{subject.id}") data = Subjects::ShixunUsedInfoService.call(subject) - data.each do |key| + data.each_with_index do |key, index| next if key[:shixun_id].nil? str += ", " unless str.empty? str += ("(#{subject.id}, #{key[:shixun_id]}, '#{key[:stage]}', '#{key[:name]}', #{key[:challenge_count]}, " + @@ -102,7 +102,7 @@ namespace :subjects do "#{key[:evaluate_count]}, #{key[:passed_ave_time]}, " + "'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')") buffer_size += 1 - if buffer_size == 1000 + if buffer_size == 1000 || (index+1) == data.size sql = "REPLACE INTO subject_shixun_infos(#{column_value}) VALUES #{str}" puts sql ActiveRecord::Base.connection.execute sql @@ -131,7 +131,7 @@ namespace :subjects do "code_line_count, evaluate_count, cost_time, created_at, updated_at" subjects.find_in_batches(batch_size: 50) do |s| - Parallel.each(s, in_processes: 4) do |subject| + Parallel.each_with_index(s, in_processes: 4) do |subject, index| puts("---------------------user_info_statistic: #{subject.id}") data = Subjects::UserUsedInfoService.call(subject) data.each do |key| @@ -141,7 +141,7 @@ namespace :subjects do "#{key[:passed_games_count]}, #{key[:code_line_count]}, #{key[:evaluate_count]}, #{key[:cost_time]}, " + "'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')") buffer_size += 1 - if buffer_size == 1000 + if buffer_size == 1000 || (index+1 == data.size) sql = "REPLACE INTO subject_user_infos(#{column_value}) VALUES #{str}" ActiveRecord::Base.connection.execute sql str = "" From ce1ac4d8389488f33d5bee4b31e783d147cda0df Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 17 Jan 2020 17:37:30 +0800 Subject: [PATCH 07/15] 1 --- lib/tasks/statistic_subject_info.rake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tasks/statistic_subject_info.rake b/lib/tasks/statistic_subject_info.rake index aecaa1866..c510c60fb 100644 --- a/lib/tasks/statistic_subject_info.rake +++ b/lib/tasks/statistic_subject_info.rake @@ -9,8 +9,8 @@ namespace :subjects do buffer_size = 0 column_value = "subject_id, study_count, course_study_count, initiative_study, passed_count, course_used_count, " + "school_used_count, created_at, updated_at" - subjects.find_in_batches(batch_size: 50) do |s| - Parallel.each_with_index(s, in_processes: 4) do |subject, index| + subjects.find_in_batches(batch_size: 50) do |s, index| + Parallel.each_with_index(s, in_processes: 4) do |subject| puts("---------------------data_statistic: #{subject.id}") Rails.logger.info("---------------------data_statistic: #{subject.id}") data = Subjects::DataStatisticService.new(subject) @@ -23,7 +23,7 @@ namespace :subjects do "#{data.passed_count}, #{data.course_used_count}, #{data.school_used_count}, " + "'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')") buffer_size += 1 - if buffer_size == 1000 || (index +1) == data.size + if buffer_size == 1000 || subjects.count == (index+1) sql = "REPLACE INTO subject_records(#{column_value}) VALUES #{str}" puts sql ActiveRecord::Base.connection.execute sql From 06eb69097aefd1354b0a5074a59db9e216ce26ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Fri, 17 Jan 2020 17:58:03 +0800 Subject: [PATCH 08/15] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/AppConfig.js | 42 +++++++++++++++++++- public/react/src/modules/wxcode/index.js | 46 +++++++++++----------- public/react/src/services/wxcodeService.js | 38 +++++++++--------- 3 files changed, 83 insertions(+), 43 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index cf813573c..72053896b 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -5,6 +5,7 @@ import md5 from 'md5'; import { requestProxy } from "./indexEduplus2RequestProxy"; import { broadcastChannelOnmessage ,SetAppModel, isDev, queryString } from 'educoder'; import { notification } from 'antd'; +import cookie from 'react-cookies'; import './index.css'; const $ = window.$; const opens ="79e33abd4b6588941ab7622aed1e67e8"; @@ -24,6 +25,18 @@ function locationurl(list){ } +function setCookier(){ + const _params = window.location.search; + if (_params) { + let _search = _params.split('?')[1]; + _search.split('&').forEach(item => { + console.log(item); + const _arr = item.split('='); + cookie.save('_educoder_session',_arr[0]); + cookie.save('autologin_trustie',_arr[1]); + }); + } +} // TODO 开发期多个身份切换 let debugType ="" @@ -96,7 +109,7 @@ export function initAxiosInterceptors(props) { requestMap[keyName] = false; } - + //响应前的设置 axios.interceptors.request.use( config => { // config.headers['Content-Type']= 'no-cache' @@ -111,6 +124,33 @@ export function initAxiosInterceptors(props) { // proxy = 'http://localhost:3000' // } // --------------------------------------------- + // console.log("开始请求了"); + // console.log(config.url); + // console.log(window.location.pathname); + try { + const str =window.location.pathname; + if(str.indexOf("/wxcode") !== -1){ + // console.log("开始重写cookis"); + const _params = window.location.search; + // console.log("1111"); + if (_params) { + // console.log("22222"); + let _search = _params.split('?')[1]; + _search.split('&').forEach(item => { + const _arr = item.split('='); + if(_arr[0]==='_educoder_session'){ + cookie.save('_educoder_session',_arr[1],{ path: '/' }); + }else{ + cookie.save('autologin_trustie',_arr[1],{ path: '/' }); + } + }); + } + } + }catch (e) { + + } + + // if (config.url.indexOf(proxy) != -1 || config.url.indexOf(':') != -1) { return config } diff --git a/public/react/src/modules/wxcode/index.js b/public/react/src/modules/wxcode/index.js index 2fb871288..67bea0524 100644 --- a/public/react/src/modules/wxcode/index.js +++ b/public/react/src/modules/wxcode/index.js @@ -1,7 +1,7 @@ /* * @Description: 微信端代码编辑器 * @Author: tangjiang - * @Github: + * @Github: * @Date: 2020-01-15 09:56:34 * @LastEditors : tangjiang * @LastEditTime : 2020-01-17 15:34:40 @@ -35,28 +35,28 @@ const App = (props) => { evaluateWxCode, showWXCodeTextCase, changeWXCodeEvaluateLoading - } = props; + } = props; const {identifier} = props.match.params; // 获取路径参数 const setCookier = () => { - const _params = window.location.search; - if (_params) { - let _search = _params.split('?')[1]; - _search.split('&').forEach(item => { - // console.log(item); - const _arr = item.split('='); - cookie.remove(_arr[0], { - path: '/', - domain: '.educoder.net' - }); - cookie.save(_arr[0], _arr[1], { - path: '/', - domain: '.educoder.net' - }); - }); - } + // const _params = window.location.search; + // if (_params) { + // let _search = _params.split('?')[1]; + // _search.split('&').forEach(item => { + // // console.log(item); + // const _arr = item.split('='); + // cookie.remove(_arr[0], { + // path: '/', + // domain: '.educoder.net' + // }); + // cookie.save(_arr[0], _arr[1], { + // path: '/', + // domain: '.educoder.net' + // }); + // }); + // } } setCookier(); const [isActive, setIsActive] = useState(-1); @@ -111,7 +111,7 @@ const App = (props) => { updateWXCodeForInterval(identifier, path); }, 10000); } - } + } // 关闭单个测试集 const handleCloseItem = (i, flag) => { @@ -130,7 +130,7 @@ const App = (props) => { changeWXCodeEvaluateLoading(true); evaluateWxCode(identifier, path); } - + const tcclasses = isShow ? `wx-code-test-case active` : 'wx-code-test-case'; const loading = showLoading ? 'code-evaluate-loading active' : 'code-evaluate-loading'; const _val = sets_error_count === 0; @@ -200,19 +200,19 @@ const App = (props) => { { is_public - ? (result + ? (result ? : ) : ( 隐藏测试集,暂不支持解锁和查看 - {/* {result + {/* {result ? : } */} ) } - +