dev_SaaS
杨树明 6 years ago
commit 71b3b1ce4a

@ -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,

@ -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,

@ -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

@ -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
@ -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)
@ -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, :compelete_status => 0, :commit_time => nil)
# myshixun.destroy
myshixun.delete
# 主从复制出现脏读的情况

@ -49,7 +49,7 @@
<!--</span>-->
</span>
<span class="column-2 fr edu-txt-center">
<% if @major_manager && !@major_school.template_major %>
<% if @major_manager && !@major_school.template_major || User.current.admin? %>
<a href="javascript:void(0);" onclick="delete_confirm_box_3('<%= ec_major_school_ec_year_path(year, :ec_major_school_id => @major_school) %>','您确定要删除吗?')" class="mr15 color-grey-c">删除</a>
<% 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: '您确定要删除吗' } %>

@ -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
Loading…
Cancel
Save