dev_course
SylorHuang 6 years ago
parent 84c714310c
commit 01be5588be

@ -201,16 +201,16 @@ class ExercisesController < ApplicationController
def common_header
ActiveRecord::Base.transaction do
begin
@user_left_time = nil
if @user_course_identity > Course::ASSISTANT_PROFESSOR
@is_teacher_or = 0
@user_exercise_answer = @exercise.check_user_answer_status(current_user)
@user_commit_counts = 0
get_exercise_left_time(@exercise,current_user)
@user_left_time = get_exercise_left_time(@exercise,current_user)
else
@is_teacher_or = 1
@user_exercise_answer = 3 #教师页面
@user_commit_counts = @exercise.exercise_users.where(commit_status:1).count #已提交的用户数
@user_left_time = nil
end
@ex_status = @exercise.get_exercise_status(current_user.id)
@ -1022,8 +1022,6 @@ class ExercisesController < ApplicationController
end
end
get_exercise_left_time(@exercise,@exercise_user_current)
# ex_time = @exercise.time
# if ex_time > 0
# time_mill = ex_time * 60 #转为秒
@ -1038,10 +1036,12 @@ class ExercisesController < ApplicationController
@t_user_exercise_status = @exercise.get_exercise_status(current_user.id)
@user_left_time = nil
if @user_course_identity < Course::STUDENT || (@t_user_exercise_status == 3) ||
(@exercise_user_current.present? && @exercise_user_current.commit_status == 1)
@user_exercise_status = 1 #当前用户为老师/试卷已截止/试卷已提交不可编辑
else
@user_left_time = get_exercise_left_time(@exercise,current_user)
@user_exercise_status = 0 #可编辑
end

@ -681,9 +681,11 @@ module ExercisesHelper
result
end
def get_exercise_left_time(exercise,exercise_user)
def get_exercise_left_time(exercise,user)
ex_time = exercise.time
user_left_time = nil
if ex_time > 0
exercise_user = exercise.exercise_users.find_by(user_id:user.id)
time_mill = ex_time * 60 #转为秒
exercise_end_time = exercise.end_time.present? ? exercise.end_time.to_i : 0
exercise_user_start = exercise_user.present? ? exercise_user.start_at.to_i : 0
@ -691,9 +693,9 @@ module ExercisesHelper
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) #当前用户对试卷的回答剩余时间
user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间
end
@user_left_time
user_left_time
end
#实训题学生代码的行数

Loading…
Cancel
Save