dev_course
SylorHuang 6 years ago
parent 590464369f
commit 84c714310c

@ -48,6 +48,7 @@ class ExercisesController < ApplicationController
@exercises = @exercises_all #老师能看到全部的试卷,不管是已发布的/未发布的/已截止的/统一设置的/私有设置的(看到内容不同)
elsif @user_course_identity == Course::STUDENT # 2为课堂成员能看到统一设置的和自己班级的
@is_teacher_or = 2
# get_exercise_left_time(@exercise,current_user)
member_group_id = @current_student.first.try(:course_group_id).to_i # 成员的分班id默认为0
if member_group_id == 0 #表示是课堂的未分班成员,只能查看统一设置的试卷(已发布的/已截止的)
@exercises = member_show_exercises.present? ? member_show_exercises.unified_setting : []
@ -204,10 +205,12 @@ class ExercisesController < ApplicationController
@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)
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)
@ -222,6 +225,8 @@ class ExercisesController < ApplicationController
@exercise_publish_count = 1 #试卷未发布,且课堂没有分班的时候
end
end
rescue Exception => e
uid_logger_error(e.message)
tip_exception("没有权限")
@ -1016,17 +1021,20 @@ class ExercisesController < ApplicationController
@exercise_user_current.update_attribute("start_at",Time.now)
end
end
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
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
get_exercise_left_time(@exercise,@exercise_user_current)
# 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
# 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
@t_user_exercise_status = @exercise.get_exercise_status(current_user.id)
@ -1788,4 +1796,6 @@ class ExercisesController < ApplicationController
end
end
end

@ -419,13 +419,13 @@ module ExercisesHelper
if game.present?
exercise_cha_score = 0.0
answer_status = 0
cha_path = challenge_path exercise_cha.challenge.path
if game.status == 2 && game.final_score >= 0
exercise_cha_score = exercise_cha.question_score #每一关卡的得分
answer_status = 1
end
ex_shixun_answer_content = answers_content.where(exercise_shixun_challenge_id: exercise_cha.id)
if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里
cha_path = challenge_path exercise_cha.challenge.path
game_challenge = game.game_codes.search_challenge_path(cha_path).first
if game_challenge.present?
game_code = game_challenge
@ -681,6 +681,21 @@ module ExercisesHelper
result
end
def get_exercise_left_time(exercise,exercise_user)
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.present? ? exercise_user.start_at.to_i : 0
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
@user_left_time
end
#实训题学生代码的行数
def content_line(content)
content.split(/\r?\n/).length

@ -1,5 +1,7 @@
json.course_is_end @course.is_end # true表示已结束false表示未结束
json.extract! @exercise, :id,:exercise_name,:exercise_description,:show_statistic,:time
json.extract! @exercise, :id,:exercise_name,:exercise_description,:show_statistic
json.time @user_left_time
json.exercise_status @ex_status
json.user_permission do

@ -21,7 +21,11 @@ if @exercises_count > 0
json.exercises do
json.array! @exercises do |exercise|
ex_index = exercise_index_show(exercise,@course,@is_teacher_or,@current_user_)
json.extract! exercise, :id, :exercise_name,:is_public,:created_at,:time
json.extract! exercise, :id, :exercise_name,:is_public,:created_at
if @is_teacher_or == 2
json.time get_exercise_left_time(exercise,@current_user_)
end
json.exercise_status ex_index[:ex_status]
json.lock_status ex_index[:lock_icon]
json.publish_time ex_index[:publish_time] # 试卷的发布时间

Loading…
Cancel
Save