From 582e8921db2a83848e16921a03fbcb4f9f86938f Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Mon, 11 Mar 2019 14:17:12 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E9=80=9A=E5=85=B3=E5=8D=B4=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E8=8E=B7=E5=BE=97=E9=87=91=E5=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 2 +- ...190311032811_add_passed_score_for_users.rb | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20190311032811_add_passed_score_for_users.rb diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 0ed0cbe1..2b1e9b80 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -697,7 +697,7 @@ class GamesService if had_passed && !game.had_passed? game.update_attributes(:status => 2, :end_time => Time.now) # TPM实训已发布并且没有查看答案 - if shixun.is_published? && !game.answer_open + if shixun.is_published? && game.answer_open == 0 # 查看答案的时候处理final_scor和扣分记录 experience = score reward_grade(myshixun.owner, game.id, 'Game', score) diff --git a/db/migrate/20190311032811_add_passed_score_for_users.rb b/db/migrate/20190311032811_add_passed_score_for_users.rb new file mode 100644 index 00000000..c65550eb --- /dev/null +++ b/db/migrate/20190311032811_add_passed_score_for_users.rb @@ -0,0 +1,40 @@ +class AddPassedScoreForUsers < ActiveRecord::Migration + def up + games = Game.where("final_score = 0 and status = 2 and answer_open = 0 and created_at > '2019-03-09 00:00:00'").includes(:challenge) + puts "game_count: #{games.count}" + games.find_each do |game| + puts "#{game.id}" + challenge = game.challenge + # 选择题和实践题的分数 + score = challenge.choose_score + user = game.user + game.update_column(:final_score, score) + # 奖励金币和提供记录 + grade = Grade.where(:user_id => user.id, :container_id => game.id, :container_type => "Game").first + if grade.nil? + Grade.create!(:user_id => user.id, + :container_id => game.id, + :container_type => "Game", + :score => score, + :created_at => game.end_time || Time.now, + :updated_at => game.end_time || Time.now) + user.update_column(:grade, (score + user.grade.to_i)) + end + # 经验奖励 + experience = Experience.where(:user_id => user.id, :container_id => game.id, :container_type => "Game").first + if experience.nil? + Experience.create!(:user_id => user.id, + :container_id => game.id, + :container_type => "Game", + :score => score, + :created_at => game.end_time || Time.now, + :updated_at => game.end_time || Time.now) + user.update_column(:experience, (score + user.experience.to_i)) + end + end + + end + + def down + end +end From cb4ecb8a0fed6a5611158ab58de5707035e7c296 Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Mon, 11 Mar 2019 17:52:23 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=B0=83=E8=AF=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 581eaa31..1797f3ed 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -219,10 +219,10 @@ class GamesController < ApplicationController @had_passed_testsests_public_count = had_test.blank? ? 0 : had_test.select{|had_test| had_test.result == true && had_test.is_public == true}.count @mirror_name = @myshixun.mirror_name @final_score = ((@shixun.status <= 1) ? 0 : @game.final_score.to_i) - if @myshixun.shixun.status <= 1 || (@game.final_score != 0 && @game.answer_open?) + if @myshixun.shixun.status <= 1 || (@game.final_score != 0 && @game.answer_open > 0) @gold = 0 else - if @game.answer_open? && @game.final_score ==0 + if @game.answer_open > 0 && @game.final_score ==0 @gold = -@game_challenge.score.to_i else @gold = @game.final_score.to_i From 1d53060af9fac34eca718239260b93ac5ca8aa76 Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Tue, 12 Mar 2019 09:47:38 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E5=B7=A5=E7=A8=8B=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ec_courses_controller.rb | 2 +- app/views/ec_major_schools/_year_list.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/ec_courses_controller.rb b/app/controllers/ec_courses_controller.rb index ebd9ca1a..0ad029f4 100644 --- a/app/controllers/ec_courses_controller.rb +++ b/app/controllers/ec_courses_controller.rb @@ -630,7 +630,7 @@ class EcCoursesController < ApplicationController # 遍历学生成绩统计数据 student_scores.each do |sc| sub_ecss = EcCourseStudentScore.where(:ec_course_id => @ec_course.id, :ec_year_student_id => sc.ec_year_student_id).first - sub_score = base_score == 0 ? 0 : ((sc.try(:score).to_f/base_score) * percentage).round(3) + sub_score = base_score == 0 || sc.try(:score).nil? ? 0 : ((sc.try(:score).to_f/base_score) * percentage).round(3) if sub_ecss ess_target = sub_ecss.ec_student_score_targets.where(:ec_course_target_id => target.id, diff --git a/app/views/ec_major_schools/_year_list.html.erb b/app/views/ec_major_schools/_year_list.html.erb index 98a04678..5fd7bab1 100644 --- a/app/views/ec_major_schools/_year_list.html.erb +++ b/app/views/ec_major_schools/_year_list.html.erb @@ -49,7 +49,7 @@ - <% if @major_manager && !@major_school.template_major %> + <% if @major_manager && !@major_school.template_major || User.current.admin? %> 删除 <% end %> <%#= link_to '删除', ec_major_school_ec_year_path(year, :ec_major_school_id => @major_school), method: :delete, :class => "mr15 color-grey-c", data: { confirm: '您确定要删除吗' } %> From 4aadc998b9d5ff8985a6b0fc438923402e35fe18 Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Tue, 12 Mar 2019 11:06:57 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=85=81=E8=AE=B8=E8=B7=B3=E5=85=B3?= =?UTF-8?q?=E7=9A=84=E5=AE=9E=E8=AE=AD=E5=8F=82=E6=95=B0=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 2b1e9b80..57d0e829 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -43,7 +43,7 @@ class GamesService # 高性能取上一关、下一关 prev_game = Game.prev_identifier(shixun.id, game.myshixun_id, game_challenge.position) - next_game = if current_user.is_certification_teacher || shixun_manager(shixun, current_user) || game.status == 2 + next_game = if current_user.is_certification_teacher || shixun_manager(shixun, current_user) || game.status || shixun.task_pass Game.next_game(shixun.id, game.myshixun_id, game_challenge.position).try(:identifier) end From 3bd2a00768d9529c095d199df171fd28660592b0 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 12 Mar 2019 16:03:10 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E9=87=8D=E7=BD=AEmyshixun=E6=97=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7=E5=85=B3=E8=81=94=E7=9A=84?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 57d0e829..956e5809 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -930,7 +930,8 @@ class GamesService end #end myshixun_job = Base64.urlsafe_encode64("myshixun_#{myshixun.id}") - StudentWork.where(:myshixun_id => myshixun.id).update_all(:myshixun_id => nil, :work_status => 0) + StudentWork.where(:myshixun_id => myshixun.id).update_all(:myshixun_id => 0, :work_status => 0, :work_score => nil, :final_score => nil, + :cost_time => 0, :update_time => nil) # myshixun.destroy myshixun.delete # 主从复制出现脏读的情况 From 4fa4e2d19905bb26c477d7fcc3f616b1c6db9fcb Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Tue, 12 Mar 2019 16:04:06 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=9C=A8=E6=8E=A5=E5=8F=A3=E9=87=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8C=87=E7=A4=BA=E7=82=B9=E5=86=85=E5=AE=B9?= =?UTF-8?q?=20=EF=BC=88=E5=90=8E=E7=AB=AF=E5=A2=9E=E5=8A=A0=E5=8F=82?= =?UTF-8?q?=E6=95=B0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ec_course_supports_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/ec_course_supports_controller.rb b/app/controllers/ec_course_supports_controller.rb index d81782a8..337c183a 100644 --- a/app/controllers/ec_course_supports_controller.rb +++ b/app/controllers/ec_course_supports_controller.rb @@ -60,7 +60,12 @@ class EcCourseSupportsController < ApplicationController course_data << { name: name, top_relation: cs.top_relation, weigths: cs.weigths} end gs.ec_course_supports.count > max_support_count && max_support_count = gs.ec_course_supports.count - course_support_data << {sequence_num: sequence_num, ec_graduation_subitem_id: gs.id, course_data: course_data, num_total: gs.ec_course_supports.count, weights_total: weigths_sum} + course_support_data << {sequence_num: sequence_num, + sequence_title: gs.content, + ec_graduation_subitem_id: gs.id, + course_data: course_data, + num_total: gs.ec_course_supports.count, + weights_total: weigths_sum} end end render :json => {ec_year_id: @year.id, From afa8d8f1f3716b0273fef4034d664ad0ec6d5f5b Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 12 Mar 2019 16:05:10 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 956e5809..039d90c8 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -931,7 +931,7 @@ class GamesService #end myshixun_job = Base64.urlsafe_encode64("myshixun_#{myshixun.id}") StudentWork.where(:myshixun_id => myshixun.id).update_all(:myshixun_id => 0, :work_status => 0, :work_score => nil, :final_score => nil, - :cost_time => 0, :update_time => nil) + :cost_time => 0, :update_time => nil, :compelete_status => 0, :commit_time => nil) # myshixun.destroy myshixun.delete # 主从复制出现脏读的情况