Merge branch 'develop' into educoder

dev_ec
daiao 6 years ago
commit 97a5e132ee

@ -2,7 +2,7 @@
class ChallengesController < ApplicationController class ChallengesController < ApplicationController
layout "base_shixun" layout "base_shixun"
# 如要添加或修改before_filter时请将handle_openi_request这个before_filter放至第一位 # 如要添加或修改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 :check_authentication, :except => [:index]
before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build, :update_evaluation, :add_choose_question, :new_choose_question, 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] :choose_type_show, :edit_choose_question, :update_choose_question, :destroy_challenge_choose]

@ -24,6 +24,14 @@ class Challenge < ActiveRecord::Base
scope :choose_type, lambda{where(st: 1)} scope :choose_type, lambda{where(st: 1)}
scope :practice_type, lambda{where(st: 0)} scope :practice_type, lambda{where(st: 0)}
def shixun_done_new
self.games.select{|game| game.status == 2 }.size
end
def shixun_running_new
self.games.select{|game| game.status != 2 }.size
end
def game_difficulty def game_difficulty
str = "简单" str = "简单"
case self.difficulty case self.difficulty

@ -92,12 +92,12 @@ class GamesService
sql = sql =
if max_query_index > 0 if max_query_index > 0
"SELECT "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 FROM
(SELECT position, input, output, challenge_id, is_public FROM test_sets where challenge_id=#{game_challenge.id}) a (SELECT position, input, output, challenge_id, is_public FROM test_sets where challenge_id=#{game_challenge.id}) a
LEFT JOIN LEFT JOIN
(SELECT (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 FROM
outputs o left join games g on g.id=o.game_id outputs o left join games g on g.id=o.game_id
WHERE WHERE
@ -153,9 +153,10 @@ class GamesService
actual_output = test_set.attributes.count > 4 ? test_set.try(:actual_output) : nil actual_output = test_set.attributes.count > 4 ? test_set.try(:actual_output) : nil
result = test_set.attributes.count > 4 ? test_set.try(:result) : 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 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 = 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, public_result = {:is_public => (test_set.is_public ? 1 : 0), :result => result,
:actual_output => actual_output, :compile_success => compile_success} :actual_output => actual_output, :compile_success => compile_success}
@ -837,7 +838,8 @@ class GamesService
max_query_index = game.query_index - 1 max_query_index = game.query_index - 1
# 区分评测过未评测过,未评测过按需求取数据 # 区分评测过未评测过,未评测过按需求取数据
if max_query_index > 0 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 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 else

@ -73,8 +73,8 @@
</div> </div>
<div class="clearfix pl28"> <div class="clearfix pl28">
<span class="task-colspan"><%= shixun_done(@shixun, challenge.position).to_i %>&nbsp;人完成挑战</span> <span class="task-colspan"><%= challenge.shixun_done_new.to_i %>&nbsp;人完成挑战</span>
<span class="task-colspan"><%= shixun_running(@shixun, challenge.position).to_i %>&nbsp;人正在挑战</span> <span class="task-colspan"><%= challenge.shixun_running_new.to_i %>&nbsp;人正在挑战</span>
<% if challenge.st != 0 %> <% if challenge.st != 0 %>
<span class="task-colspan"><span class="colspan-grey">经验值&nbsp;<%= challenge.choose_score %></span></span> <span class="task-colspan"><span class="colspan-grey">经验值&nbsp;<%= challenge.choose_score %></span></span>
<% else %> <% else %>

@ -1,3 +1,4 @@
console.log("<%= @user_picture.present? %>")
<% if @user_picture.present? %> <% if @user_picture.present? %>
$("#picture_display").html('<%= j (render :partial => 'games/picture_display') %>'); $("#picture_display").html('<%= j (render :partial => 'games/picture_display') %>');
$("#picture_display").show(); $("#picture_display").show();

@ -1113,13 +1113,16 @@ function _initZoomCheck() {
if (!IsPC()) { // 手机端不需要提示 if (!IsPC()) { // 手机端不需要提示
return; 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) { if (!isNormalZoom) {
suofang(); suofang();
} }
$(window).resize(function() { $(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) { if (!isNormalZoom) {
suofang(); suofang();
} else { } else {

Loading…
Cancel
Save