From 110fbbc87b7437061f2d86821049b93c540ce712 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 14 May 2019 10:11:58 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/zipdown_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 2f01c494..03a5b218 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -20,8 +20,10 @@ class ZipdownController < ApplicationController begin if params[:base64file] file = decode64(params[:base64file]) + Rails.logger.info("##################detect_content_type: #{detect_content_type(file)}") send_file "#{OUTPUT_FOLDER}/#{file}", :filename => filename_for_content_disposition(file), :type => detect_content_type(file) else + Rails.logger.info("##################detect_content_type: #{detect_content_type(params[:file])}") send_file "#{OUTPUT_FOLDER}/#{params[:file]}", :filename => filename_for_content_disposition(params[:filename]), :type => detect_content_type(params[:file]) end rescue => e From 9e68757d50e7731605e2f58fb375a6c520853a08 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 14 May 2019 10:25:41 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/zipdown_controller.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 03a5b218..2f01c494 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -20,10 +20,8 @@ class ZipdownController < ApplicationController begin if params[:base64file] file = decode64(params[:base64file]) - Rails.logger.info("##################detect_content_type: #{detect_content_type(file)}") send_file "#{OUTPUT_FOLDER}/#{file}", :filename => filename_for_content_disposition(file), :type => detect_content_type(file) else - Rails.logger.info("##################detect_content_type: #{detect_content_type(params[:file])}") send_file "#{OUTPUT_FOLDER}/#{params[:file]}", :filename => filename_for_content_disposition(params[:filename]), :type => detect_content_type(params[:file]) end rescue => e From 4a95592b67611e885d9a6bcd570a3f2a5b5cda2c Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Tue, 14 May 2019 14:14:26 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E8=A7=A3=E5=86=B3HiDPI/Retina=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=99=A8=E8=BF=9B=E5=85=A5tpi=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E7=BC=A9=E6=94=BE=E6=AF=94=E4=BE=8B=E5=8F=98?= =?UTF-8?q?=E5=8A=A8=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/educoder/edu_application.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/public/javascripts/educoder/edu_application.js b/public/javascripts/educoder/edu_application.js index 5d81c572..47705d21 100644 --- a/public/javascripts/educoder/edu_application.js +++ b/public/javascripts/educoder/edu_application.js @@ -1113,13 +1113,16 @@ function _initZoomCheck() { if (!IsPC()) { // 手机端不需要提示 return; } - var isNormalZoom = Math.round(window.devicePixelRatio * 100) === 100 + var ratio = Math.round(window.devicePixelRatio * 100); + // A value of 1 indicates a classic 96 DPI (76 DPI on some platforms) display, while a value of 2 is expected for HiDPI/Retina displays + var isNormalZoom = ratio === 100 || ratio === 200 if (!isNormalZoom) { suofang(); } $(window).resize(function() { - var isNormalZoom = Math.round(window.devicePixelRatio * 100) === 100 + var ratio = Math.round(window.devicePixelRatio * 100); + var isNormalZoom = ratio === 100 || ratio === 200 if (!isNormalZoom) { suofang(); } else { From b4bc64e401a4c8fff3a20875b95ec139e56aff1e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 14 May 2019 17:07:41 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=9B=BE=E7=89=87=E7=B1=BB=E5=AE=9E?= =?UTF-8?q?=E8=AE=AD=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/games_service.rb | 7 ++++--- app/views/users/picture_show.js.erb | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index f172edbd..4e6be5d3 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -92,12 +92,12 @@ class GamesService sql = if max_query_index > 0 "SELECT - b.actual_output, b.out_put, b.result, b.compile_success, a.is_public, a.input, a.output + b.code, b.actual_output, b.out_put, b.result, b.compile_success, a.is_public, a.input, a.output FROM (SELECT position, input, output, challenge_id, is_public FROM test_sets where challenge_id=#{game_challenge.id}) a LEFT JOIN (SELECT - result, test_set_position, g.challenge_id, o.actual_output, o.out_put, o.compile_success + result, test_set_position, g.challenge_id, o.actual_output, o.out_put, o.compile_success, o.code FROM outputs o left join games g on g.id=o.game_id WHERE @@ -153,9 +153,10 @@ class GamesService actual_output = test_set.attributes.count > 4 ? test_set.try(:actual_output) : nil result = test_set.attributes.count > 4 ? test_set.try(:result) : nil compile_success = test_set.attributes.count > 4 ? test_set.try(:compile_success) : nil + status = test_set.attributes.count > 4 ? test_set.try(:code) : nil #actual_output = Base64.encode64(actual_output) - actual_output = (compile_success.to_s == "0" ? "编译失败,请在测试结果中查看具体的错误信息" : actual_output) + actual_output = (compile_success.to_s == "0" && status.to_s == "-1" ? "编译失败,请在测试结果中查看具体的错误信息" : actual_output) public_result = {:is_public => (test_set.is_public ? 1 : 0), :result => result, :actual_output => actual_output, :compile_success => compile_success} diff --git a/app/views/users/picture_show.js.erb b/app/views/users/picture_show.js.erb index afde2b61..a41c1ed7 100644 --- a/app/views/users/picture_show.js.erb +++ b/app/views/users/picture_show.js.erb @@ -1,3 +1,4 @@ +console.log("<%= @user_picture.present? %>") <% if @user_picture.present? %> $("#picture_display").html('<%= j (render :partial => 'games/picture_display') %>'); $("#picture_display").show(); From 62e36d87e5cd71500cff9b14ab33965ba624424b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 14 May 2019 17:58:35 +0800 Subject: [PATCH 5/7] 1 --- app/services/games_service.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 4e6be5d3..3dccc7f9 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -838,7 +838,8 @@ class GamesService max_query_index = game.query_index - 1 # 区分评测过未评测过,未评测过按需求取数据 if max_query_index > 0 - qurey_test_sets = TestSet.find_by_sql("SELECT o.actual_output,o.result, o.compile_success, o.test_set_position, o.query_index,t.is_public,t.input, t.output, g.id as game_id, c.id as challenge_id FROM outputs o,games g ,challenges c,test_sets t where + qurey_test_sets = TestSet.find_by_sql("SELECT o.code, o.actual_output,o.result, o.compile_success, o.test_set_position, + o.query_index,t.is_public,t.input, t.output, g.id as game_id, c.id as challenge_id FROM outputs o,games g ,challenges c,test_sets t where g.id=#{game.id} and o.query_index=#{max_query_index} and g.id = o.game_id and c.id= g.challenge_id and t.challenge_id = c.id and t.position =o.test_set_position order by o.query_index ") else From 3685c386db39dd67afbddecef2f0f58a09dd5d9a Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Tue, 14 May 2019 20:09:30 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 2 +- app/models/challenge.rb | 8 ++++++++ app/views/challenges/_content_list.html.erb | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 344976ab..bf01ffb0 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -2,7 +2,7 @@ class ChallengesController < ApplicationController layout "base_shixun" # 如要添加或修改before_filter时,请将handle_openi_request这个before_filter放至第一位 - before_filter :handle_openi_request, if: -> { user_login_and_from_openi? }, only: [:index] + # before_filter :handle_openi_request, if: -> { user_login_and_from_openi? }, only: [:index] before_filter :check_authentication, :except => [:index] before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build, :update_evaluation, :add_choose_question, :new_choose_question, :choose_type_show, :edit_choose_question, :update_choose_question, :destroy_challenge_choose] diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 5180c8fa..6f4cccfd 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -24,6 +24,14 @@ class Challenge < ActiveRecord::Base scope :choose_type, lambda{where(st: 1)} scope :practice_type, lambda{where(st: 0)} + def shixun_done_new + self.games.map{|game| game.status == 2 }.size + end + + def shixun_running_new + self.games.map{|game| game.status != 2 }.size + end + def game_difficulty str = "简单" case self.difficulty diff --git a/app/views/challenges/_content_list.html.erb b/app/views/challenges/_content_list.html.erb index bc7743de..f9ac88b8 100644 --- a/app/views/challenges/_content_list.html.erb +++ b/app/views/challenges/_content_list.html.erb @@ -73,8 +73,8 @@
- <%= shixun_done(@shixun, challenge.position).to_i %> 人完成挑战 - <%= shixun_running(@shixun, challenge.position).to_i %> 人正在挑战 + <%= challenge.shixun_done_new.to_i %> 人完成挑战 + <%= challenge.shixun_running_new.to_i %> 人正在挑战 <% if challenge.st != 0 %> 经验值 <%= challenge.choose_score %> <% else %> From 037e7c08ecb7c75e5d07774b5585fba54afff5a1 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Tue, 14 May 2019 20:16:04 +0800 Subject: [PATCH 7/7] .. --- app/models/challenge.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 6f4cccfd..704fffb3 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -25,11 +25,11 @@ class Challenge < ActiveRecord::Base scope :practice_type, lambda{where(st: 0)} def shixun_done_new - self.games.map{|game| game.status == 2 }.size + self.games.select{|game| game.status == 2 }.size end def shixun_running_new - self.games.map{|game| game.status != 2 }.size + self.games.select{|game| game.status != 2 }.size end def game_difficulty