Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_course
daiao 6 years ago
commit ccbe7cb1ad

@ -1016,10 +1016,15 @@ class ExercisesController < ApplicationController
@exercise_user_current.update_attribute("start_at",Time.now)
end
end
if @exercise.time > 0
ex_time = @exercise.time
if ex_time > 0
time_mill = ex_time * 60 #转为秒
exercise_end_time = @exercise.end_time.present? ? @exercise.end_time.to_i : 0
exercise_user_start = @exercise_user_current.present? ? @exercise_user_current.start_at.to_i : 0
exercise_user_left_time = Time.now.to_i - exercise_user_start
time_mill = @exercise.time * 60 #转为毫秒
if (exercise_user_start + time_mill) > exercise_end_time
time_mill = exercise_end_time - exercise_user_start #如果开始答题时间加试卷的限时长大于试卷的截止时间,则以试卷的截止时间到开始答题时间为试卷的限时
end
exercise_user_left_time = Time.now.to_i - exercise_user_start #用户已回答的时间
@user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间
end

@ -530,7 +530,7 @@ class HomeworkCommonsController < ApplicationController
if setting && setting.score != score
score_change = true
setting.update_attributes(score: score)
else
elsif setting.blank?
score_change = true
HomeworkChallengeSetting.create!(homework_common_id: @homework.id, challenge_id: challenge[:challenge_id],
shixun_id: @homework.homework_commons_shixun.try(:shixun_id), score: score)

@ -56,8 +56,8 @@ module ExercisesHelper
}
@ex_sub_array.push(sub_score)
end
@ex_obj_array.sort_by {|k| k[:q_position]}
@ex_sub_array.sort_by {|k| k[:q_position]}
@ex_obj_array = @ex_obj_array.sort_by {|k| k[:q_position]}
@ex_sub_array = @ex_sub_array.sort_by {|k| k[:q_position]}
end
#试卷的统计结果页面计算各题的

@ -165,7 +165,7 @@ class HomeworksService
homework = work.homework_common
#logger.info("#############member_course_group_id: #{member.try(:course_group_id)}")
setting_time = homework.homework_group_setting work.user_id
if setting_time.end_time.present? && (setting_time.end_time > Time.now || (homework.allow_late && !homework.course.is_end))
if setting_time.end_time.present? && (setting_time.end_time > Time.now || (homework.allow_late && homework.late_time && homework.late_time > Time.now))
#logger.info("#############setting_time: #{setting_time.end_time}")
user_total_score = 0

@ -0,0 +1,10 @@
class AddUniqIndexToHomeworkChallengeSettings < ActiveRecord::Migration[5.2]
def change
remove_index :homework_challenge_settings, [:homework_common_id, :challenge_id] if index_exists?(:homework_challenge_settings, [:homework_common_id, :challenge_id])
sql = %Q(delete from homework_challenge_settings where (homework_common_id, challenge_id) in
(select * from (select homework_common_id, challenge_id from homework_challenge_settings group by homework_common_id, challenge_id having count(*) > 1) a)
and id not in (select * from (select max(id) from homework_challenge_settings group by homework_common_id, challenge_id having count(*) > 1 order by id) b))
ActiveRecord::Base.connection.execute sql
add_index :homework_challenge_settings, [:homework_common_id, :challenge_id], unique: true, name: "index_on_homework_common_id_challenge_id"
end
end
Loading…
Cancel
Save