From 2020beba2aa567e24d50313072cea80a320040c5 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 4 Sep 2017 14:40:25 +0800 Subject: [PATCH 01/39] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=B8=AD=E7=9A=84edito?= =?UTF-8?q?r=EF=BC=8C=E7=BC=96=E8=BE=91=E7=8A=B6=E6=80=81=E5=92=8C?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=9A=84=E4=B8=8D=E4=B8=80=E6=A0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/messages/_common_reply_box.html.erb | 2 +- public/stylesheets/css/edu-public.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/messages/_common_reply_box.html.erb b/app/views/messages/_common_reply_box.html.erb index 947f6892b..f770a3de0 100644 --- a/app/views/messages/_common_reply_box.html.erb +++ b/app/views/messages/_common_reply_box.html.erb @@ -59,7 +59,7 @@ <% end %> - <% end %>‘ + <% end %>
<%= comment.content_detail.html_safe %>
diff --git a/public/stylesheets/css/edu-public.css b/public/stylesheets/css/edu-public.css index a1328af84..ab4db0458 100644 --- a/public/stylesheets/css/edu-public.css +++ b/public/stylesheets/css/edu-public.css @@ -95,7 +95,7 @@ a:hover.panel-list-title{color:#29bd8b;} a.panel-name-small{ display: inline-block; max-width:100px; color:#29bd8b; font-size:12px; } .panel-list-infobox{ width: 92%; margin-left:8%; margin-top:-70px;} .panel-lightgrey,.panel-lightgrey span{ font-size:12px; color:#888;} -.panel-inner-info{ width: 92%; margin-left:8%; color:#666;} +.panel-inner-info{ width: 92%; margin-left:8%;} .panel-bg-grey{ padding:5px 0;background:#f6f6f6; width: 100%; color:#666;} .panel-list-nodata{ width: 420px; margin:100px auto; text-align: center;} From 5678fbfccb44d0ce439a3d80fde41aeb77595d07 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 6 Sep 2017 16:08:56 +0800 Subject: [PATCH 02/39] =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E8=AF=BE=E5=A0=82?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=AD=9B=E9=80=89=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 15 +++++++-------- app/views/courses/_course_index_search.html.erb | 2 +- app/views/courses/index.html.erb | 15 ++++++++++----- app/views/courses/index.js.erb | 13 +------------ 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 97d193fbd..b5b3c58b4 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -44,30 +44,29 @@ class CoursesController < ApplicationController @user = User.current @search = params[:search].nil? ? '' : params[:search] @select = params[:select].nil? ? '' : params[:select] - @is_end = params[:is_end].nil? ? 0 : params[:is_end].to_i # 是否归档 @is_over = params[:is_over] # 是否是新建课程页面跳转的查看归档 - @syllabuses_num = Course.where("is_end = #{@is_end} and is_delete = 0").count + @syllabuses_num = Course.where("is_end = 0 and is_delete = 0").count #@syllabus_count = all_syllabuses.count # 我创建的课堂 create_syllabuses = Course.where(:tea_id => @user.id) # 我参与的课堂 join_syllabuses = @user.courses.where("is_delete = 0 and tea_id != #{@user.id}") - @join_syllabuses_count = join_syllabuses.where(:is_end => @is_end, :is_delete => 0).count - @create_syllabuses_count = create_syllabuses.where(:is_end => @is_end, :is_delete => 0).count + @join_syllabuses_count = join_syllabuses.where(:is_end => 0, :is_delete => 0).count + @create_syllabuses_count = create_syllabuses.where(:is_end => 0, :is_delete => 0).count # 页面筛选的课程 if @select == "create" - @syllabuses = create_syllabuses.where("is_end = #{@is_end} and is_delete = 0 and name like '%#{@search}%'") + @syllabuses = create_syllabuses.where("is_end = 0 and is_delete = 0 and name like '%#{@search}%'") elsif @select == "join" - @syllabuses = join_syllabuses.where("is_end = #{@is_end} and is_delete = 0 and tea_id != #{@user.id} and name like '%#{@search}%'") + @syllabuses = join_syllabuses.where("is_end = 0 and is_delete = 0 and tea_id != #{@user.id} and name like '%#{@search}%'") elsif @select == "end" # 归档的课堂 - end_syllabuses = Course.where("is_end = #{@is_end} and name like '%#{@search}%'") + end_syllabuses = Course.where("is_end = 1 and name like '%#{@search}%'") @syllabuses = end_syllabuses else # 全部课堂 - all_syllabuses = Course.where("is_end = #{@is_end} and is_delete = 0 and name like '%#{@search}%'") + all_syllabuses = Course.where("is_end = 0 and is_delete = 0 and name like '%#{@search}%'") @syllabuses = all_syllabuses end diff --git a/app/views/courses/_course_index_search.html.erb b/app/views/courses/_course_index_search.html.erb index 3c07cd79c..ddabac1ac 100644 --- a/app/views/courses/_course_index_search.html.erb +++ b/app/views/courses/_course_index_search.html.erb @@ -1,4 +1,4 @@ -
+
diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index 49dd1a06e..4036e3af8 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -13,10 +13,10 @@
- @is_end,:search => @search) %>" id="courses_index_syllabuses_1" class="course_filtrate fl course_filtrate_bg" data-tab="all" data-remote="true">全部课堂 - @is_end, :search => @search) %>" id="courses_index_syllabuses_2" class="course_filtrate fl" data-tab="create" data-remote="true">我管理的 - @is_end, :search => @search) %>" id="courses_index_syllabuses_3" class="course_filtrate fl" data-tab="join" data-remote="true">我参与的 - 1) %>" id="courses_index_syllabuses_4" class="course_filtrate fl" data-tab="end" data-remote="true">查看归档 + @search) %>" id="courses_index_syllabuses_1" class="edu-filter-cir-grey mr20 active fl" data-tab="all" data-remote="true">全部课堂 + @search) %>" id="courses_index_syllabuses_2" class="edu-filter-cir-grey mr20 fl" data-tab="create" data-remote="true">我管理的 + @search) %>" id="courses_index_syllabuses_3" class="edu-filter-cir-grey mr20 fl" data-tab="join" data-remote="true">我参与的 + " id="courses_index_syllabuses_4" class="edu-filter-cir-grey fl" data-tab="end" data-remote="true">查看归档 From 0b1f6f53783b63b35cd9b736ceda80d3b7539351 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 7 Sep 2017 14:22:12 +0800 Subject: [PATCH 11/39] =?UTF-8?q?=E5=AE=9E=E8=AE=ADTPI=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=AF=84=E6=B5=8B=E4=BF=AE=E6=94=B9=E4=B8=BA=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=8A=9B=E5=BC=82=E5=B8=B8=E5=92=8C=E4=BB=A3=E7=A0=81=E5=AE=9E?= =?UTF-8?q?=E9=99=85=E8=BE=93=E5=87=BA=E4=B8=8E=E6=B5=8B=E8=AF=95=E9=9B=86?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E4=B8=8D=E5=8C=B9=E9=85=8D2=E7=A7=8D?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 12 ++++++++---- app/controllers/myshixuns_controller.rb | 3 ++- app/models/output.rb | 1 + app/views/games/_code_actions.html.erb | 3 ++- app/views/games/_game_results.html.erb | 5 +++-- ...20170907025441_add_compile_success_to_outputs.rb | 5 +++++ ...70907061723_modify_compile_success_to_outputs.rb | 13 +++++++++++++ public/javascripts/edu/edu_tpi.js | 5 +++-- 8 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 db/migrate/20170907025441_add_compile_success_to_outputs.rb create mode 100644 db/migrate/20170907061723_modify_compile_success_to_outputs.rb diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 3031dccbc..49462ac03 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -94,7 +94,8 @@ class GamesController < ApplicationController @language = @game_challenge.shixun.language error_position = had_test.blank? ? nil : had_test.select{|had_test| had_test.result == false}.last logger.info("latest output id is #{error_position.id unless error_position.blank?}") - @latest_output = error_position.try(:out_put).gsub(/\n/, '
').gsub(/\t/, '        ').to_json unless error_position.try(:out_put).blank? + @latest_output = error_position.try(:out_put).gsub(/\n/, '
').gsub(/\t/, '        ').to_json unless error_position.try(:out_put).blank? + @compile_success = error_position.try(:compile_success) logger.info(@latest_output) respond_to do |format| @@ -218,7 +219,7 @@ class GamesController < ApplicationController def game_status game_challenge = @game.challenge had_done = @game.had_done - resubmit_identifier = @game.resubmit_identifier + resubmit_identifier = @game.resubmit_iden67tifier shixun = @myshixun.shixun score = 0 tag_count = 0 @@ -278,6 +279,7 @@ class GamesController < ApplicationController @final_score = ((@game.answer_open? || shixun.status <= 1) ? 0 : @game.final_score.to_i) error_position = had_test.blank? ? nil : had_test.select{|had_test| had_test.result == false}.last @latest_output = error_position.try(:out_put).gsub(/\n/, '
').gsub(/\t/, '        ') unless error_position.try(:out_put).blank? + @compile_success = error_position.try(:out_put) @language = game_challenge.shixun.language render :json => {test_sets: total_test_sets, test_sets_count: @test_sets_count, @@ -293,7 +295,9 @@ class GamesController < ApplicationController had_done: had_done, language: @language, score: score, - tag_count: tag_count} + tag_count: tag_count, + compile_success: @compile_success + } end # 选择题评测(选择题不需要重新评测) @@ -504,7 +508,7 @@ class GamesController < ApplicationController unless test_sets.blank? test_sets.each do |test_set| output = Output.where(:game_id => @game.id, :test_set_position => test_set.position).first - actual_output = (output.try(:actual_output).gsub(/\n/, '
').gsub(/\t/, '        ') unless output.try(:actual_output).blank?) + actual_output = (output.try(:actual_output).gsub(/\n/, '
').gsub(/\t/, '        ') unless output.try(:actual_output).blank?) result = output.try(:result) public_result = {:is_public => (test_set.is_public ? 1 : 0), :result => result, :input => test_set.input, :actual_output => actual_output, :output => test_set.output} diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 0e05db265..9d1c2effd 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -109,6 +109,7 @@ class MyshixunsController < ApplicationController resubmit = jsonTestDetails['resubmit'] outPut = tran_base64_decode64(jsonTestDetails['outPut']) jenkins_testsets = jsonTestDetails['msg'] + compile_success = jsonTestDetails['compileSuccess'] # message = Base64.decode64(params[:msg]) unless params[:msg].blank? logger.info(outPut) game = Game.find(game_id) @@ -117,7 +118,7 @@ class MyshixunsController < ApplicationController jenkins_testsets.each do |j_test_set| actual_output = tran_base64_decode64(j_test_set['output']) game_outputs = Output.create(:code => status, :game_id => game_id, :out_put => outPut, :test_set_position => j_test_set['caseId'], - :actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => game.query_index) + :actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => game.query_index, :compile_success => compile_success) # output = Output.where(:game_id => game.id, :test_set_position => j_test_set['caseId'].to_i).first # logger.info("#############{outPut}") diff --git a/app/models/output.rb b/app/models/output.rb index 6c833b091..4ce462eff 100644 --- a/app/models/output.rb +++ b/app/models/output.rb @@ -1,6 +1,7 @@ class Output < ActiveRecord::Base # attr_accessible :title, :body # actual_output 编程题:实际输出, 选择题: 用户提交的答案(如: 014 对应用户选择为A B E) + # compile_success 1 表示程序未报错,有正常输出, 0.表示程序抛异常了,报错! default_scope :order => 'query_index desc' belongs_to :game diff --git a/app/views/games/_code_actions.html.erb b/app/views/games/_code_actions.html.erb index c1bd54ac9..16d0a30c4 100644 --- a/app/views/games/_code_actions.html.erb +++ b/app/views/games/_code_actions.html.erb @@ -221,7 +221,8 @@ data.had_passed_testsests_public_count, data.final_score, data.latest_output, - data.language + data.language, + data.compile_success ); $("#blacktab_nav_1").trigger("click"); if(data.status == 2){ diff --git a/app/views/games/_game_results.html.erb b/app/views/games/_game_results.html.erb index 14b5af39f..2730c3e1b 100644 --- a/app/views/games/_game_results.html.erb +++ b/app/views/games/_game_results.html.erb @@ -21,7 +21,7 @@ \ No newline at end of file diff --git a/app/views/shixuns/index.html.erb b/app/views/shixuns/index.html.erb index 3adfad831..d162ee613 100644 --- a/app/views/shixuns/index.html.erb +++ b/app/views/shixuns/index.html.erb @@ -336,34 +336,26 @@ //搜索实训 function search_shixun(){ - console.log($("#shixun_index_search_form").serialize()); - if($(".searchCon").is(":visible")){ - $.ajax({ - url: '/shixuns/search', - type: 'post', - data: $("#shixun_index_search_form").serialize(), - remote: true, - success: function(data){ - } - }); - } else{ - $(".searchCon").show(); - } + $.ajax({ + url: '/shixuns/search', + type: 'post', + data: $("#shixun_index_search_form").serialize(), + remote: true, + success: function(data){ + } + }); } //关闭搜索框 function colse_searchbox(){ - $('.searchCon').hide(); - if($('.searchinput').val().trim() != ""){ - $('.searchinput').val(''); - $.ajax({ - url: '/shixuns/search', - type: 'post', - data: $("#shixun_index_search_form").serialize(), - remote: true, - success: function(data){ - } - }); - } + $('.searchinput').val(''); + $.ajax({ + url: '/shixuns/search', + type: 'post', + data: $("#shixun_index_search_form").serialize(), + remote: true, + success: function(data){ + } + }); } // 新建实训 diff --git a/public/stylesheets/css/taskstyle.css b/public/stylesheets/css/taskstyle.css index b53cc74ce..7307f7d1e 100644 --- a/public/stylesheets/css/taskstyle.css +++ b/public/stylesheets/css/taskstyle.css @@ -343,7 +343,7 @@ a.shixun-task-ban-btn{background-color: #c2c4c6;display: inline-block;font-weigh .scroll_lesson{overflow-x: hidden;overflow-y: scroll;} .searchFor{width:auto;} -.searchFor .searchCon{width:240px;border-bottom:1px solid #cccccc;float: left;height: 30px;display: none;} +.searchFor .searchCon{width:240px;border-bottom:1px solid #cccccc;float: left;height: 30px;} .searchFor .searchCon input{border: none;outline: none;height: 29px;width:91%;} .searchFor .searchImg{margin:5px 10px 0px 0px;cursor: pointer;} From 1d8ef146c65cc26385063c8c36266e5b9f6db848 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 7 Sep 2017 16:55:25 +0800 Subject: [PATCH 17/39] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E7=9A=84=E8=AE=BF=E9=97=AE=E6=95=B0=E6=B2=A1=E6=9C=89=E5=8F=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 805b52131..5a0d54ce6 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -97,6 +97,7 @@

+ <% update_visiti_count @user %> <% if current_user %>
@@ -105,7 +106,6 @@

- <% update_visiti_count @user %> <%= @user.visits.to_i %> 次访问

From 143a16e9432568422276057df112a023bf903a65 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 7 Sep 2017 17:54:51 +0800 Subject: [PATCH 18/39] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=BF=98=E5=9C=A8?= =?UTF-8?q?=E6=8C=91=E6=88=98=E7=AC=AC=E4=B8=80=E5=85=B3=EF=BC=8C=E5=AE=9E?= =?UTF-8?q?=E8=AE=AD=E4=BD=9C=E4=B8=9A=E5=85=B3=E8=81=94=E5=AE=9E=E6=88=98?= =?UTF-8?q?=E5=90=8E=E6=98=BE=E7=A4=BA=E6=95=B0=E6=8D=AE=E4=B8=8D=E5=AF=B9?= =?UTF-8?q?=EF=BC=8C=E4=B8=94=E6=9F=A5=E7=9C=8B=E6=93=8D=E4=BD=9C=E6=97=A0?= =?UTF-8?q?=E6=95=88=E6=9E=9C=EF=BC=88=E5=8F=8C=E9=87=8D=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 10 ++++++++++ app/models/myshixun.rb | 2 +- .../student_work/_evaluation_un_shixun_work.html.erb | 4 ++-- app/views/student_work/_shixun_work_show.html.erb | 6 +++--- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2c22efb8e..65a242cf3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -267,6 +267,16 @@ module ApplicationHelper end end + # 已通过的关卡数 返回int类型 + def had_passed_changllenge_num shixun, user + myshixun = Myshixun.where(:shixun_id => shixun.id, :user_id => user.id).first + if myshixun.nil? + 0 + else + myshixun.games.select{|game| game.status == 2}.count + end + end + # TPI状态 :已通关、未通关、未开启 def my_shixun_status shixun, user status = "" diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index cf0579655..4a9c66771 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -32,7 +32,7 @@ class Myshixun < ActiveRecord::Base time = 0 self.games.each do |game| if game.status == 2 - time += (game.end_time -game.open_time).to_i > 0 ? (game.end_time -game.open_time).to_i : 0 + time += (game.end_time.to_i - game.open_time.to_i) > 0 ? (game.end_time.to_i - game.open_time.to_i) : 0 end end time diff --git a/app/views/student_work/_evaluation_un_shixun_work.html.erb b/app/views/student_work/_evaluation_un_shixun_work.html.erb index 9423f400c..974d6698a 100644 --- a/app/views/student_work/_evaluation_un_shixun_work.html.erb +++ b/app/views/student_work/_evaluation_un_shixun_work.html.erb @@ -13,12 +13,12 @@ <%= student_work.work_status == 0 ? '--' : format_time(student_work.updated_at) %> - <%= student_work.work_status == 0 ? '--' : had_passed_changllenge_count(shixun, student_work.user).to_s+"/"+shixun.challenges.count.to_s %> + <%= student_work.work_status == 0 ? '--' : had_passed_changllenge_num(shixun, student_work.user).to_s+"/"+shixun.challenges.count.to_s %> <% if student_work.work_status != 0 %>

<% end %> diff --git a/app/views/student_work/_shixun_work_show.html.erb b/app/views/student_work/_shixun_work_show.html.erb index 961683f78..a5d8c4d3d 100644 --- a/app/views/student_work/_shixun_work_show.html.erb +++ b/app/views/student_work/_shixun_work_show.html.erb @@ -22,8 +22,8 @@
  • 通关时间: <%= @myshixun.try(:status) == 1 ? (format_time @myshixun.done_time) : '- -' %>
    • -
    • 通关情况:<%= had_passed_changllenge_count(@shixun, @work.user).to_s+" / "+@shixun.challenges.count.to_s %>
    • -
    • 总耗时:<%=had_passed_changllenge_count(@shixun, @work.user) > 0 ? game_spend_time(total_spend_time @myshixun) : '- -' %>
    • +
    • 通关情况:<%= had_passed_changllenge_num(@shixun, @work.user).to_s+" / "+@shixun.challenges.count.to_s %>
    • +
    • 总耗时:<%=had_passed_changllenge_num(@shixun, @work.user) > 0 ? game_spend_time(@myshixun.total_spend_time) : '- -' %>
    @@ -41,7 +41,7 @@ 第<%= index + 1 %>关 - <%= game.status == 2 ? game_spend_time((game.end_time - game.open_time).to_i) : '- -' %> + <%= game.status == 2 ? game_spend_time(game.end_time.to_i - game.open_time.to_i) : '- -' %> <%= game.status == 2 ? game.final_score : '- -' %> <% end %> From aff7febcc39a1d6c80d98dda30ca5ec4a03b35e4 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 7 Sep 2017 19:28:09 +0800 Subject: [PATCH 19/39] =?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/controllers/myshixuns_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 9d1c2effd..40f0e2f50 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -112,14 +112,15 @@ class MyshixunsController < ApplicationController compile_success = jsonTestDetails['compileSuccess'] # message = Base64.decode64(params[:msg]) unless params[:msg].blank? logger.info(outPut) + logger.info("##################"+ compile_success) game = Game.find(game_id) challenge = game.challenge unless jenkins_testsets.blank? jenkins_testsets.each do |j_test_set| actual_output = tran_base64_decode64(j_test_set['output']) game_outputs = Output.create(:code => status, :game_id => game_id, :out_put => outPut, :test_set_position => j_test_set['caseId'], - :actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => game.query_index, :compile_success => compile_success) - + :actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => game.query_index, :compile_success => compile_success.to_i) + logger.info("compile_success:"+ game_outputs.compile_success) # output = Output.where(:game_id => game.id, :test_set_position => j_test_set['caseId'].to_i).first # logger.info("#############{outPut}") # if output.nil? From 2b8f057d3d549b499b3a24883e2f4c06bd4771d0 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 7 Sep 2017 19:36:46 +0800 Subject: [PATCH 20/39] =?UTF-8?q?=E8=AF=84=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 40f0e2f50..448868c08 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -120,7 +120,7 @@ class MyshixunsController < ApplicationController actual_output = tran_base64_decode64(j_test_set['output']) game_outputs = Output.create(:code => status, :game_id => game_id, :out_put => outPut, :test_set_position => j_test_set['caseId'], :actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => game.query_index, :compile_success => compile_success.to_i) - logger.info("compile_success:"+ game_outputs.compile_success) + logger.info("compile_success:"+ compile_success) # output = Output.where(:game_id => game.id, :test_set_position => j_test_set['caseId'].to_i).first # logger.info("#############{outPut}") # if output.nil? From d924b60d7d2c1e97888f5f467764f9f2153db618 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 7 Sep 2017 20:02:33 +0800 Subject: [PATCH 21/39] =?UTF-8?q?=E5=88=B6=E8=A1=A8=E7=AC=A6=E6=9C=AA?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/edu/edu_tpi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index 78fc71fa9..04605abff 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -430,7 +430,7 @@ function code_evaluation(test_sets, "
  • " + "
    " + " 预期输出:" + - "

    " + ( test_sets[i].output == null ? "空" : test_sets[i].output.replace(/\r\n/g, "
    ").replace(/ /g, "") ) + "

    " + + "

    " + ( test_sets[i].output == null ? "空" : test_sets[i].output.replace(/\r\n/g, "
    ").replace(/\t/g, "        ").replace(/ /g, "") ) + "

    " + "
    " + "
  • " + "
  • " + From 918d6b3c957b24e2fad598f956e578b09bf8bcf9 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 7 Sep 2017 20:35:30 +0800 Subject: [PATCH 22/39] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 8 +++----- app/views/games/_game_results.html.erb | 3 +-- public/javascripts/edu/edu_tpi.js | 7 ++----- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 5fa85adce..eb23caca3 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -95,7 +95,6 @@ class GamesController < ApplicationController error_position = had_test.blank? ? nil : had_test.select{|had_test| had_test.result == false}.last logger.info("latest output id is #{error_position.id unless error_position.blank?}") @latest_output = error_position.try(:out_put).gsub(/\n/, '
    ').gsub(/\t/, '        ').to_json unless error_position.try(:out_put).blank? - @compile_success = error_position.try(:compile_success) logger.info(@latest_output) respond_to do |format| @@ -279,7 +278,7 @@ class GamesController < ApplicationController @final_score = ((@game.answer_open? || shixun.status <= 1) ? 0 : @game.final_score.to_i) error_position = had_test.blank? ? nil : had_test.select{|had_test| had_test.result == false}.last @latest_output = error_position.try(:out_put).gsub(/\n/, '
    ').gsub(/\t/, '        ') unless error_position.try(:out_put).blank? - @compile_success = error_position.try(:compile_success) + logger.info("@compile_success###################{@compile_success}") @language = game_challenge.shixun.language render :json => {test_sets: total_test_sets, test_sets_count: @test_sets_count, @@ -295,8 +294,7 @@ class GamesController < ApplicationController had_done: had_done, language: @language, score: score, - tag_count: tag_count, - compile_success: @compile_success + tag_count: tag_count } end @@ -511,7 +509,7 @@ class GamesController < ApplicationController actual_output = (output.try(:actual_output).gsub(/\n/, '
    ').gsub(/\t/, '        ') unless output.try(:actual_output).blank?) result = output.try(:result) public_result = {:is_public => (test_set.is_public ? 1 : 0), :result => result, :input => test_set.input, - :actual_output => actual_output, :output => test_set.output} + :actual_output => actual_output, :output => test_set.output, :compile_success => output.try(:compile_success)} logger.info("1111#################################{public_result.to_json}") test_result << public_result.to_json end diff --git a/app/views/games/_game_results.html.erb b/app/views/games/_game_results.html.erb index 2730c3e1b..f651c1fec 100644 --- a/app/views/games/_game_results.html.erb +++ b/app/views/games/_game_results.html.erb @@ -34,8 +34,7 @@ '<%= @had_passed_testsests_public_count %>', '<%= @final_score %>', [<%= @latest_output.html_safe unless @latest_output.blank? %>], - '<%= @language %>', - '<%= @compile_success %>' + '<%= @language %>' ); $("#blacktab_nav_1").trigger("click"); }); diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index 04605abff..297f72759 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -362,15 +362,12 @@ function code_evaluation(test_sets, had_passed_testsests_public_count, final_score, latest_output, - language, - compile_success + language ) { //动态加载评测区域 /** * Created by wang on 2017/8/9. */ - console.log(compile_success); - console.log(compile_success == "1"); var $EffectDisplay , $b, $TestResult, $d, $e, $f, $g, $h, $EvaluationInformation , $n; // 第一块 效果显示 $EffectDisplay = "
    "; @@ -436,7 +433,7 @@ function code_evaluation(test_sets, "
  • " + "
    " + "实际输出:" + - "

    " + (test_sets[i].actual_output == null ? "空" : (compile_success == "1" ? test_sets[i].actual_output.replace(/\r\n/g, "
    ").replace(/ /g, "") : test_sets[i].actual_output.replace(/\r\n/g, "
    "))) + "

    " + + "

    " + (test_sets[i].actual_output == null ? "空" : (test_sets[i].compile_success == "1" ? test_sets[i].actual_output.replace(/\r\n/g, "
    ").replace(/ /g, "") : test_sets[i].actual_output.replace(/\r\n/g, "
    "))) + "

    " + "
    " + "
  • " + "" + From bad7322c8632525fb40c94b564a73331a5a430db Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 8 Sep 2017 09:18:33 +0800 Subject: [PATCH 23/39] =?UTF-8?q?=E5=AE=9E=E9=99=85=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E6=98=AF=E5=BC=82=E5=B8=B8=E8=BE=93=E5=87=BA=E5=88=99=E4=B8=8D?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E7=A9=BA=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index eb23caca3..695743fcf 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -508,8 +508,9 @@ class GamesController < ApplicationController output = Output.where(:game_id => @game.id, :test_set_position => test_set.position).first actual_output = (output.try(:actual_output).gsub(/\n/, '
    ').gsub(/\t/, '        ') unless output.try(:actual_output).blank?) result = output.try(:result) + compile_success = (actual_output.blank? || !actual_output.match(/error/).blank?) ? 0 : 1 public_result = {:is_public => (test_set.is_public ? 1 : 0), :result => result, :input => test_set.input, - :actual_output => actual_output, :output => test_set.output, :compile_success => output.try(:compile_success)} + :actual_output => actual_output, :output => test_set.output, :compile_success => compile_success} logger.info("1111#################################{public_result.to_json}") test_result << public_result.to_json end From e3543d3b737a8bbe2baa27f9fdaf13f443af2ad6 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 8 Sep 2017 09:28:26 +0800 Subject: [PATCH 24/39] =?UTF-8?q?iframe=E6=8B=89=E5=8A=A8=E5=AE=9E?= =?UTF-8?q?=E8=B7=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/edu/edu_tpi.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index 297f72759..dd0459e6c 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -379,6 +379,7 @@ function code_evaluation(test_sets, "" + "" + + "
    " + "
    " + "
    "; From 27c20e03ecd7fcb1fcd3638c972602cfd98502a1 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 8 Sep 2017 09:38:43 +0800 Subject: [PATCH 25/39] =?UTF-8?q?=E5=AE=9E=E8=AE=ADtpm=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E8=AF=84=E6=B5=8B=E8=AE=BE=E7=BD=AE=EF=BC=8C=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E6=A1=86=E5=8F=AA=E6=9C=89=E4=B8=80=E8=A1=8C?= =?UTF-8?q?=E9=AB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/challenges/_edit_evaluating.html.erb | 9 +++++++++ app/views/challenges/_evaluating_form.html.erb | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/challenges/_edit_evaluating.html.erb b/app/views/challenges/_edit_evaluating.html.erb index bbc795b3a..0b3ca9147 100644 --- a/app/views/challenges/_edit_evaluating.html.erb +++ b/app/views/challenges/_edit_evaluating.html.erb @@ -62,5 +62,14 @@ $("#edit_task_pass").click(function(){ $("#evaluating_edit").show(); $("#evaluating_show").hide(); + // 设置textarea的宽度到140以后出现滚动条 + var test_set_inputs = document.getElementsByName("test_set[input][]"); + var test_set_outputs = document.getElementsByName("test_set[output][]"); + if (test_set_inputs.length == test_set_outputs.length) { + for (var i = 0; i < test_set_inputs.length; i++) { + autoTextarea(test_set_inputs[i], 0, 140); + autoTextarea(test_set_outputs[i], 0, 140); + } + } }) \ No newline at end of file diff --git a/app/views/challenges/_evaluating_form.html.erb b/app/views/challenges/_evaluating_form.html.erb index 80ad18a7c..197860477 100644 --- a/app/views/challenges/_evaluating_form.html.erb +++ b/app/views/challenges/_evaluating_form.html.erb @@ -157,15 +157,6 @@ }); }); - // 设置textarea的宽度到140以后出现滚动条 - var test_set_inputs = document.getElementsByName("test_set[input][]"); - var test_set_outputs = document.getElementsByName("test_set[output][]"); - if (test_set_inputs.length == test_set_outputs.length) { - for (var i = 0; i < test_set_inputs.length; i++) { - autoTextarea(test_set_inputs[i], 0, 140); - autoTextarea(test_set_outputs[i], 0, 140); - } - } // 判断测试集是否锁定, 0未锁定,1锁定 function test_set_whether_lock(){ var lock = document.getElementsByName("test_set[lock][]"); From ab95db24de21bbe3b815c38db6fd32c177114804 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 8 Sep 2017 09:41:09 +0800 Subject: [PATCH 26/39] =?UTF-8?q?=E6=88=91=E7=9A=84=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E4=B8=AD=E7=82=B9=E5=87=BB=E6=88=91=E5=B7=B2=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=B8=AD=E7=9A=84=E6=95=B0=E6=8D=AE=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E9=9C=80=E8=A6=81=E6=96=B0=E5=BC=80=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E5=BD=93=E5=89=8D=E9=A1=B5=E9=9D=A2=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_myshixuns_list.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/_myshixuns_list.html.erb b/app/views/users/_myshixuns_list.html.erb index ad0da9cc1..e6d5890b0 100644 --- a/app/views/users/_myshixuns_list.html.erb +++ b/app/views/users/_myshixuns_list.html.erb @@ -5,7 +5,7 @@ <% @shixuns.each do |shixun| %>
    - <%= shixun.name %> + <%= shixun.name %>

    <%= shixun.language %> From dcf26e0fb3e30aa0a03ee220933cb9f8699474fb Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 8 Sep 2017 09:51:12 +0800 Subject: [PATCH 27/39] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E6=88=AA=E6=AD=A2=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=92=8C=E7=BB=93=E6=9D=9F=E6=97=B6=E9=97=B4=E5=9C=A8=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E4=BA=86=E5=8F=91=E5=B8=83=E6=97=B6=E9=97=B4=E5=90=8E?= =?UTF-8?q?=E7=BB=99=E5=87=BA=E5=88=9D=E5=A7=8B=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/edu/base_edu.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/public/javascripts/edu/base_edu.js b/public/javascripts/edu/base_edu.js index 1ebf1970d..48ea8ac4b 100644 --- a/public/javascripts/edu/base_edu.js +++ b/public/javascripts/edu/base_edu.js @@ -180,7 +180,27 @@ $(function(){ allowBlank:true, lang:'ch', format:'Y-m-d H:i', - validateOnBlur:false + validateOnBlur:false, + onSelectDate:function() { + if($.trim($("input[name='homework_end_time']").val()) == ""){ + var date = new Date(Date.parse($("input[name='homework_publish_time']").val().replace(/-/g, "/"))); + $("input[name='homework_end_time']").val(formate_time(new Date(date.setDate(date.getDate()+14)))); + } + if($.trim($("input[name='homework_archive_time']").val()) == ""){ + var date = new Date(Date.parse($("input[name='homework_end_time']").val().replace(/-/g, "/"))); + $("input[name='homework_archive_time']").val(formate_time(new Date(date.setMonth(date.getMonth()+1)))); + } + }, + onSelectTime:function() { + if($.trim($("input[name='homework_end_time']").val()) == ""){ + var date = new Date(Date.parse($("input[name='homework_publish_time']").val().replace(/-/g, "/"))); + $("input[name='homework_end_time']").val(formate_time(new Date(date.setDate(date.getDate()+14)))); + } + if($.trim($("input[name='homework_archive_time']").val()) == ""){ + var date = new Date(Date.parse($("input[name='homework_end_time']").val().replace(/-/g, "/"))); + $("input[name='homework_archive_time']").val(formate_time(new Date(date.setMonth(date.getMonth()+1)))); + } + } }); $("input[name='homework_end_time']").datetimepicker({ From 30517525e911d5aa64430de5afdc9b4aedacad71 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 8 Sep 2017 11:10:30 +0800 Subject: [PATCH 28/39] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=A1=8C=E4=B8=BA=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 3fea82bff..b7a764999 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -109,7 +109,9 @@ class AccountController < ApplicationController if User.current.anonymous? redirect_to signin_path else + UserActions.create(:action_id => User.current.id, :action_type => "Logout", :user_id => User.current.id) logout_user + # 记录用户登出行为 redirect_to signin_path end # display the logout form @@ -816,6 +818,8 @@ class AccountController < ApplicationController call_hook(:controller_account_success_authentication_after, {:user => user }) code = /\d*/ + # 记录用户登录行为 + UserActions.create(:action_id => User.current.id, :action_type => "Login", :user_id => User.current.id) #根据home_url生产正则表达式 eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/") if (code=~params[:back_url] || params[:back_url].to_s.include?('lost_password')) && last_login_on != '' From 0bc86d9bd7eacc10593cd990b652132a85b9f227 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 8 Sep 2017 11:21:08 +0800 Subject: [PATCH 29/39] =?UTF-8?q?=E5=AE=9E=E8=AE=ADTPI=E7=9A=84=E8=AF=84?= =?UTF-8?q?=E6=B5=8B=E6=8C=89=E9=92=AE=E5=8C=BA=E5=9F=9F=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E2=80=9C=E4=B8=8A=E4=B8=80=E5=85=B3=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 16 ++++++++++++---- app/models/challenge.rb | 5 +++++ app/models/game.rb | 8 ++++++++ app/views/games/_code_actions.html.erb | 26 +++++++++++++++----------- app/views/games/_game_show.html.erb | 3 ++- config/routes.rb | 1 + public/javascripts/edu/edu_tpi.js | 9 +++++++++ 7 files changed, 52 insertions(+), 16 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 695743fcf..660596a56 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -3,7 +3,7 @@ class GamesController < ApplicationController layout "base_myshixun" skip_before_filter :verify_authenticity_token, :only => [:file_update] before_filter :find_myshixun, :only => [:index] - before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :outputs_show, :file_edit, :file_update, :get_waiting_time, + before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :prev_step,:outputs_show, :file_edit, :file_update, :get_waiting_time, :game_status, :change_status, :answer, :minus_score, :refresh_game_list, :reset_original_code, :reset_new_code, :evaluating_choice] before_filter :find_repository, :only => [:show, :entry, :file_edit, :file_update, :reset_original_code, :reset_new_code, :html_show] before_filter :allowd_manager @@ -163,7 +163,7 @@ class GamesController < ApplicationController raise("实训云平台繁忙(繁忙等级:94)") end render :json => {:result => "success", :onRun => res['onRun'], :waitNum => res['waitNum'], :waitingTime => res['waitingTime'], :resubmit => resubmit } - #render :json => {:result => "success", :onRun => 1, :waitNum => 12, :waitingTime => 546 } + #render :json => {:result => "success", :onRun => 0, :waitNum => 12, :waitingTime => 1234 } rescue Exception => e render :json => {:result => "failed"} end @@ -294,7 +294,8 @@ class GamesController < ApplicationController had_done: had_done, language: @language, score: score, - tag_count: tag_count + tag_count: tag_count, + position: game_challenge.position } end @@ -345,7 +346,7 @@ class GamesController < ApplicationController if @game.outputs.blank? Output.create(:game_id => @game.id, :actual_output => user_answer, :result => correct) end - render :json => {correct: correct, had_done: had_done, :grade => User.where(:id => User.current.id).first.grade, score: score, tag_count: tag_count} + render :json => {correct: correct, had_done: had_done, :grade => User.where(:id => User.current.id).first.grade, score: score, tag_count: tag_count, position: @game_challenge.position} end @@ -393,6 +394,13 @@ class GamesController < ApplicationController end end + def prev_step + prev_game = @game.prev_game + respond_to do |format| + format.js{ redirect_to myshixun_game_path(prev_game, :myshixun_id => @myshixun)} + end + end + # 获取答案,第一次查看需扣掉该关卡的积分 # 如果已看过,下次可以免费查看 # viewed 1: 直接查看 2:弹框提示将要扣除积分,确定后显示内容 3:弹框提示分数不够 diff --git a/app/models/challenge.rb b/app/models/challenge.rb index db15195a1..dcc50dd43 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -34,6 +34,11 @@ class Challenge < ActiveRecord::Base Challenge.where(:position => (self.position + 1), :shixun_id => self.shixun).first end + def prev_challenge + render_404 if self.position == 1 + Challenge.where(:position => (self.position - 1), :shixun_id => self.shixun).first + end + def last_challenge render_404 if self.position < 2 position = self.position - 1 diff --git a/app/models/game.rb b/app/models/game.rb index 03d1d58ae..9485f2a15 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -46,6 +46,14 @@ class Game < ActiveRecord::Base return game end + def prev_game + challenge = self.challenge + prev_challenge_id = challenge.prev_challenge + game = Game.where(:myshixun_id => self.myshixun_id, :challenge_id => prev_challenge_id).first + render_404 if game.nil? + return game + end + # 获取game最新的一条输出结果 def latest_output outputs = Output.where(:game_id => self.id).order("created_at desc") diff --git a/app/views/games/_code_actions.html.erb b/app/views/games/_code_actions.html.erb index 16d0a30c4..845f54feb 100644 --- a/app/views/games/_code_actions.html.erb +++ b/app/views/games/_code_actions.html.erb @@ -1,5 +1,5 @@ - + <% if @st == 0 %>

    "> 加载上次通过的代码 @@ -12,6 +12,12 @@ 评测 <% end %>
    +
    + <% if @game.challenge.position > 1 %> + <%= link_to "上一关 ", {:controller => 'games', :action => "prev_step", :id => @game, :myshixun_id => @myshixun}, + :class => "shixun-task-btn task-btn-blue mr15 mt8", :id => "prev_step", :remote => true %> + <% end %> +
    <% if @game.status == 1 %> 评测中.. @@ -72,15 +78,6 @@ $("#time-consuming").html("耗时:" + days + " 天 " + hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒 "); } - /* -----------------下一关增加loading效果--------------------- */ - $("#next_step").live("click", function(){ - if($("#next_step").attr("href") != "javascript:void(0);"){ - nNext = $("#code_estimate"); - html = "下一关"; - nNext.html(html); - } - }); - // 选择题提交评测 // answer 选择的答案 function choice_submmit(){ @@ -163,7 +160,11 @@ $("#code_estimate").html("下一关"); } else if($("#exit_shixun").length > 0){ $("#code_estimate").html("退出实训"); - }$(".blacktab_con").eq(1).trigger("click"); // 回到测试结果页面 + } + if($("#prev_step").length > 0){ + $("#prev_step_area").html("上一关"); + } + $(".blacktab_con").eq(1).trigger("click"); // 回到测试结果页面 // 保存版本库代码 var fileUpdateUrl = $("#current_repository_path").html(); $.ajax({ @@ -252,6 +253,9 @@ } var html = "评测"; $("#code_test").html(html); // 恢复评测 + if(data.position > 1){ + $("#prev_step_area").html("上一关") + } var codeEstimate = $("#code_estimate").children("a").html(); if(codeEstimate == undefined){ return; diff --git a/app/views/games/_game_show.html.erb b/app/views/games/_game_show.html.erb index 5248930d6..4e30983aa 100644 --- a/app/views/games/_game_show.html.erb +++ b/app/views/games/_game_show.html.erb @@ -113,11 +113,12 @@
    -
    +
    <%= render :partial => "games/code_actions" %>
    +
    diff --git a/config/routes.rb b/config/routes.rb index bc1a8e856..7a9413b83 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -140,6 +140,7 @@ RedmineApp::Application.routes.draw do match 'game_build', :via => [:get, :post] match 'get_waiting_time', :via => [:get, :post] match 'next_step', :via => [:get, :post] + match 'prev_step', :via => [:get, :post] match 'reset_original_code', :via => [:get, :post] match 'reset_new_code', :via => [:get, :post] get 'entry' diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index dd0459e6c..d4fdc2498 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -110,6 +110,14 @@ $(function(){ }); // end + // 上一关增加loading效果 + $("#prev_step").live("click", function(){ + nNext = $("#prev_step_area"); + html = "上一关"; + nNext.html(html); + }); + // end + }); // 查看参考答案 @@ -327,6 +335,7 @@ function setupAjaxIndicatorBase() { || settings.url.match(/game_status/) || settings.url.match(/refresh_game_list/) || settings.url.match(/next_step/) + || settings.url.match(/prev_step/) || settings.url.match(/open_webssh/) || settings.url.match(/repository/) )){ From e399879d685e722e27a731a518ebc219dc263367 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 8 Sep 2017 11:25:38 +0800 Subject: [PATCH 30/39] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=85=B3=E5=8D=A1?= =?UTF-8?q?=E7=9A=84=E8=AF=84=E6=B5=8B=E8=AE=BE=E7=BD=AE=EF=BC=8C=E9=9D=9E?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E6=B5=8B=E8=AF=95=E9=9B=86=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=94=81icon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/challenges/_edit_evaluating.html.erb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/views/challenges/_edit_evaluating.html.erb b/app/views/challenges/_edit_evaluating.html.erb index 0b3ca9147..f7190a85e 100644 --- a/app/views/challenges/_edit_evaluating.html.erb +++ b/app/views/challenges/_edit_evaluating.html.erb @@ -35,9 +35,7 @@
  • 测试集<%= index + 1 %> - <% if test.is_public? %> - - <% else %> + <% unless test.is_public? %> <% end %>

    From bfe20231e88ba342a43c88483a536d33f141f817 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 8 Sep 2017 13:04:47 +0800 Subject: [PATCH 31/39] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E8=AF=84=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 9 + app/helpers/application_helper.rb | 10 + app/models/homework_detail_manual.rb | 2 +- .../_edit_score_setting.html.erb | 43 ++- .../_show_score_setting.html.erb | 246 ++++++++++-------- app/views/homework_common/setting.html.erb | 39 +-- ...n_evaluation_to_homework_detail_manuals.rb | 5 + lib/tasks/homework_publishtime.rake | 27 +- 8 files changed, 236 insertions(+), 145 deletions(-) create mode 100644 db/migrate/20170908020109_add_answer_open_evaluation_to_homework_detail_manuals.rb diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 315a69d9d..2d5ef5b76 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -332,6 +332,15 @@ class HomeworkCommonController < ApplicationController end if @homework.homework_type == 4 + if @homework_detail_manual.answer_open_evaluation != params[:answer_open_evaluation].to_i + @homework_detail_manual.answer_open_evaluation = params[:answer_open_evaluation].to_i + if @homework.end_time < Time.now + @homework.student_works.each do |student_work| + set_shixun_final_score @homework,student_work + student_work.save + end + end + end @homework.score_open = params[:homework_score_open] ? 1 : 0 else @homework.work_public = params[:homework_work_public] ? 1 : 0 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 65a242cf3..ce01129ea 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -5208,6 +5208,16 @@ def set_final_score homework,student_work end end +# 实训作业的评分 +def set_shixun_final_score homework,student_work + unless student_work.work_status == 0 + shixun = homework.homework_commons_shixuns.shixun + final_score =(had_passed_changllenge_num(shixun, student_work.user).to_f / shixun.challenges.count) * 100 + student_work.final_score = format("%.2f",final_score.to_f) + score = student_work.final_score - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + end +end def quote_resource_bank resource, course atta = Attachment.new(:filename => resource.filename, :disk_filename => resource.disk_filename, :filesize => resource.filesize, :digest => resource.digest, :downloads => 0, :is_publish => 0, diff --git a/app/models/homework_detail_manual.rb b/app/models/homework_detail_manual.rb index de289b54f..ffdeda060 100644 --- a/app/models/homework_detail_manual.rb +++ b/app/models/homework_detail_manual.rb @@ -1,7 +1,7 @@ #手动评分作业表 #comment_status: 0:挂起, 1:提交,2:补交(去掉),3:匿评中,4:申诉中,5:评阅中,6:已结束 class HomeworkDetailManual < ActiveRecord::Base - attr_accessible :ta_proportion, :comment_status, :evaluation_start, :evaluation_end, :evaluation_num, :absence_penalty, :homework_common_id, :no_anon_penalty + attr_accessible :ta_proportion, :comment_status, :evaluation_start, :evaluation_end, :evaluation_num, :absence_penalty, :homework_common_id, :no_anon_penalty, :answer_open_evaluation belongs_to :homework_common end diff --git a/app/views/homework_common/_edit_score_setting.html.erb b/app/views/homework_common/_edit_score_setting.html.erb index aa24b4970..984998cf6 100644 --- a/app/views/homework_common/_edit_score_setting.html.erb +++ b/app/views/homework_common/_edit_score_setting.html.erb @@ -1,6 +1,46 @@

    评分设置

    +<% if @homework.homework_type == 4 %> +
    +
    +
      +
    • + +
    • +
    • + + > + + > + + +
    • +
    • + +
    • +
    • + + + +
    • +
    +
    +
    +<% else %>
      @@ -122,4 +162,5 @@
    -
    \ No newline at end of file +
  • +<% end %> \ No newline at end of file diff --git a/app/views/homework_common/_show_score_setting.html.erb b/app/views/homework_common/_show_score_setting.html.erb index 909fe0208..55344e4c6 100644 --- a/app/views/homework_common/_show_score_setting.html.erb +++ b/app/views/homework_common/_show_score_setting.html.erb @@ -1,124 +1,164 @@

    评分设置

    -
    -
    -
      -
    • - -
    • -
    • - - - > - - - (选中则取各助教最终评分的平均分) -
    • -
    • - - - > - - - (选中则只取最终次的助教评分) -
    • -
    • - -
    • -
    • - - - > - - - -
    • -
    • - - - - - -
    • -
    • - - - - - -
    • - <% if @homework.homework_type == 2 %> +<% if @homework.homework_type == 4 %> +
      +
      +
        +
      • + +
      • - - - - + > + + > + + +
      • +
      • + +
      • +
      • + + + +
      • +
      +
      +
      +<% else %> +
      +
      +
        +
      • + +
      • +
      • + + + > + + + (选中则取各助教最终评分的平均分) +
      • +
      • + + + > + + + (选中则只取最终次的助教评分) +
      • +
      • + +
      • +
      • + + + > + + +
      • - - + +
      • - <% else %> -
      • +
      • - - + +
      • - <% end %> -
      • - - - > - - - -
      • -
      • - - <% if @homework.homework_type == 2 %> - 教师评分 → 教辅评分 → 系统评分 → 学生匿评评分 +
      • + + + + + +
      • +
      • + + + + + +
      • <% else %> - 教师评分 → 教辅评分 → 学生匿评评分 +
      • + + + + + +
      • <% end %> - - -
      -
      -
      - +
    • + + + > + + + +
    • +
    • + + + <% if @homework.homework_type == 2 %> + 教师评分 → 教辅评分 → 系统评分 → 学生匿评评分 + <% else %> + 教师评分 → 教辅评分 → 学生匿评评分 + <% end %> + +
    • +
    +
    +
    +<% end %>