dev_course
SylorHuang 5 years ago
parent 0a7715cbc5
commit ddd24d9aca

@ -44,25 +44,24 @@ class ExercisesController < ApplicationController
# exercises的不同用户群体的显示
if @user_course_identity < Course::STUDENT # @is_teacher_or 1为老师/管理员/助教
@is_teacher_or = 1
# @teacher_groups_ids = @course.teacher_course_groups.get_user_groups(current_user.id).pluck(:course_group_id).reject(&:blank?)
@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 : []
@exercises = member_show_exercises.exists? ? member_show_exercises.unified_setting : []
else #已分班级的成员,可以查看统一设置和单独设置(试卷是发布在该班级)试卷
# 已发布 当前用户班级分组的 试卷id
exercise_settings_ids = @course.exercise_group_settings.exercise_group_published
.where(course_group_id: member_group_id).pluck(:exercise_id).uniq
@exercises = member_show_exercises.present? ?
@exercises = member_show_exercises.exists? ?
member_show_exercises.unified_setting.or(member_show_exercises.where(id: exercise_settings_ids))
: []
end
else #用户未登陆或不是该课堂成员,仅显示统一设置的(已发布的/已截止的),如有公开,则不显示锁,不公开,则显示锁
@is_teacher_or = 0
@exercises = member_show_exercises.present? ? member_show_exercises.unified_setting : []
@exercises = member_show_exercises.exists? ? member_show_exercises.unified_setting : []
end
if @exercises.size > 0
if params[:type].present?
@ -74,12 +73,12 @@ class ExercisesController < ApplicationController
exercise_settings_ids = exercise_groups_sets.pluck(:exercise_id)
exercise_ended_ids = exercise_groups_sets.exercise_group_ended.pluck(:exercise_id).uniq
if choose_type == 2
@exercises = @exercises_all.present? ?
@exercises = @exercises_all.exists? ?
@exercises_all.exercise_by_status(2).unified_setting
.or(@exercises_all.where(id: (exercise_settings_ids - exercise_ended_ids).uniq))
: []
elsif choose_type == 3
@exercises = @exercises_all.present? ?
@exercises = @exercises_all.exists? ?
@exercises_all.exercise_by_status(3).unified_setting
.or(@exercises_all.where(id: exercise_ended_ids))
: []

@ -208,8 +208,9 @@ class HomeworkCommonsController < ApplicationController
student_work_to_xlsx(@work_excel,@homework)
exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
response.set_header("Content-Disposition","attachment; filename=#{exercise_export_name.strip.first(30)}};filename*=utf-8''#{exercise_export_name.strip.first(30)}}")
file_name = Base64.urlsafe_encode64(exercise_export_name.strip.first(30))
# response.setHeader['Content-Disposition'] = "attachment; filename=\"#{exercise_export_name.strip.first(30)}\""
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals:
render xlsx: "#{file_name}",template: "homework_commons/works_list.xlsx.axlsx",locals:
{table_columns: @work_head_cells,task_users: @work_cells_column}
}
end

@ -251,16 +251,14 @@ module ExercisesHelper
#获取试卷的已答/未答人数
def get_exercise_answers(ex_users)
@commit_ex_users = ex_users.commit_exercise_by_status(1) #当前老师的全部学生中已提交的
@exercise_answers = @commit_ex_users.present? ? @commit_ex_users.size : 0 #表示已经提交了的用户
course_all_members_count = ex_users.present? ? ex_users.size : 0
@exercise_answers = ex_users.commit_exercise_by_status(1).size #表示已经提交了的用户
course_all_members_count = ex_users.exists? ? ex_users.size : 0
@exercise_unanswers = (course_all_members_count - @exercise_answers)
end
def exercise_index_show(exercise,course,is_teacher_or,user)
# exercise_all_users = exercise.exercise_users
# lock_icon 0不出现锁1和2均出现锁。但是1仅表示私有可点击2表示私有且不点击
# lock_icon 0出现锁1不出现锁
ex_show_text = []
if course.is_end #课堂停止后,试卷显示为已结束
@ -290,7 +288,7 @@ module ExercisesHelper
exercise_publish_time = ex_pb_time[:publish_time]
exercise_end_time = ex_pb_time[:end_time]
current_status = 3
lock_icon = 1
lock_icon = 0
if exercise_status == 1
ex_show_text.push("未发布")
elsif exercise_status == 3
@ -304,7 +302,7 @@ module ExercisesHelper
exercise_publish_time = ex_pb_time[:publish_time]
exercise_end_time = ex_pb_time[:end_time]
current_status = exercise.check_user_answer_status(user)
lock_icon = 1
lock_icon = 0
if current_status == 4
ex_show_text.push("未提交")
end
@ -316,18 +314,18 @@ module ExercisesHelper
unreview_count = nil
if exercise.is_public
current_status = exercise.check_user_answer_status(user)
lock_icon = 0 #不出现锁
lock_icon = 1 #不出现锁
if current_status == 4
ex_show_text.push("未提交")
end
else
current_status = 4
lock_icon = 2
lock_icon = 0
end
end
if (course.is_public == 1) && exercise.is_public
lock_icon = 0
lock_icon = 1
end
if exercise_status > 1
@ -336,7 +334,7 @@ module ExercisesHelper
show_unreview_count = nil
end
if exercise_status == 2 && exercise_end_time.present?
if exercise_status == 2 && exercise_end_time.exists?
ex_left_time = how_much_time(exercise_end_time)
else #已截止后不显示时间
ex_left_time = nil
@ -725,8 +723,8 @@ module ExercisesHelper
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&.start_at.present? ? exercise_user.start_at.to_i : 0
exercise_end_time = exercise.end_time.exists? ? exercise.end_time.to_i : 0
exercise_user_start = exercise_user&.start_at.exists? ? exercise_user.start_at.to_i : 0
#用户未开始答题时即exercise_user_start为0
if exercise_user_start == 0
if (exercise_end_time - time_now_i) > time_mill

@ -130,11 +130,11 @@ class Exercise < ApplicationRecord
else
ex_group_setting = exercise_group_settings
user_group = course.students.course_find_by_ids("user_id",user_id)
if user_group.present?
if user_group.exists?
user_group_id = user_group.first.course_group_id
user_ex_group_setting = ex_group_setting.find_in_exercise_group("course_group_id",user_group_id)
pb_time = user_ex_group_setting.present? ? user_ex_group_setting.first.publish_time : nil
en_time = user_ex_group_setting.present? ? user_ex_group_setting.first.end_time : nil
pb_time = user_ex_group_setting.exists? ? user_ex_group_setting.first.publish_time : nil
en_time = user_ex_group_setting.exists? ? user_ex_group_setting.first.end_time : nil
else
pb_time = nil
en_time = nil
@ -152,10 +152,10 @@ class Exercise < ApplicationRecord
ex_answer_user = exercise_users.find_by(user_id: user.id)
user_ex_status = get_exercise_status(user.id)
user_status = 2
if ex_answer_user.present? && (ex_answer_user.start_at.present? || ex_answer_user.end_at.present?) #学生有过答题的,或者立即截止,但学生未做试卷的
if ex_answer_user.exists? && (ex_answer_user.start_at.exists? || ex_answer_user.end_at.exists?) #学生有过答题的,或者立即截止,但学生未做试卷的
user_status = ex_answer_user.commit_status
end
if ex_answer_user.present? && ex_answer_user.start_at.blank? && user_ex_status == 3
if ex_answer_user.exists? && ex_answer_user.start_at.blank? && user_ex_status == 3
user_status = 4
end

Loading…
Cancel
Save