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

dev_forum
jingquan huang 6 years ago
commit 6b457de9c5

@ -184,14 +184,13 @@ class ApplicationController < ActionController::Base
end
# 系统全局认证
#
def check_auth
if !current_user.profile_completed?
info_url = '/account/profile'
tip_exception(402, info_url)
elsif current_user.certification != 1
if current_user.certification != 1
day_cer = UserDayCertification.find_by(user_id: current_user.id)
tip_exception(407, "系统未授权") unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400
elsif !current_user.profile_completed?
info_url = '/account/profile'
tip_exception(402, info_url)
end
end

@ -15,7 +15,17 @@ class Competitions::CompetitionModulesController < Competitions::BaseController
md = current_module.competition_module_md_content || current_module.build_competition_module_md_content
md.name = params[:md_name]
md.content = params[:md_content]
md.save!
ActiveRecord::Base.transaction do
md.save!
attachment_ids = Array.wrap(params[:attachment_ids]).map(&:to_i)
old_attachment_ids = md.attachments.pluck(:id)
destroy_ids = old_attachment_ids - attachment_ids
md.attachments.where(id: destroy_ids).delete_all
Attachment.where(id: attachment_ids - old_attachment_ids).update_all(container: md)
end
render_ok
end

@ -54,13 +54,13 @@ class Competitions::CompetitionTeamsController < Competitions::BaseController
end
@count = teams.count
@teams = paginate(teams.includes(:user, users: :user_extension))
@teams = paginate(teams.includes(:user, users: { user_extension: :school }))
end
def user_competition_teams
teams = current_competition.competition_teams
teams = teams.joins(:team_members).where(team_members: { user_id: current_user.id })
@teams = teams.includes(:user, users: :user_extension).to_a
@teams = teams.includes(:user, users: { user_extension: :school }).to_a
@count = @teams.size
end

@ -667,6 +667,7 @@ class ExercisesController < ApplicationController
#立即发布的弹窗内容
def publish_modal
ActiveRecord::Base.transaction do
begin
exercise_ids = params[:check_ids]
@ -685,6 +686,9 @@ class ExercisesController < ApplicationController
#首页批量或单独 立即发布,应是跳出弹窗,设置开始时间和截止时间。
def publish
tip_exception("缺少截止时间参数") if params[:end_time].blank?
tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now)
tip_exception("截止时间不能晚于课堂结束时间") if @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day)
ActiveRecord::Base.transaction do
begin
check_ids = Exercise.where(id: params[:check_ids])

@ -205,15 +205,15 @@ class PollsController < ApplicationController
@is_teacher_or = 1
@user_poll_answer = 3 #教师页面
end
poll_status = @poll.get_poll_status(current_user)
@poll_status = @poll.get_poll_status(current_user)
poll_id_array = [@poll.id]
@poll_publish_count = get_user_permission_course(poll_id_array,2).count #是否存在已发布的
@poll_unpublish_count = get_user_permission_course(poll_id_array,1).count #是否存在未发布的
if (@poll_publish_count == 0) && (@poll_unpublish_count == 0) #即表示没有分班
if poll_status == 1
if @poll_status == 1
@poll_unpublish_count = 1 #试卷未发布,且课堂没有分班的时候
elsif poll_status == 2
elsif @poll_status == 2
@poll_publish_count = 1 #试卷未发布,且课堂没有分班的时候
end
end
@ -244,6 +244,9 @@ class PollsController < ApplicationController
end
#首页批量或单独 立即发布,应是跳出弹窗,设置开始时间和截止时间。
def publish
tip_exception("缺少截止时间参数") if params[:end_time].blank?
tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now)
tip_exception("截止时间不能晚于课堂结束时间") if @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day)
ActiveRecord::Base.transaction do
begin
check_ids = Poll.where(id: params[:check_ids])

@ -127,8 +127,10 @@ class Exercise < ApplicationRecord
#判断是否为分班,如果分班,试卷的截止时间为当前分班时间,否则为试卷的截止时间
def get_exercise_status(user)
return Exercise::UNPUBLISHED if user.nil?
if user.student_of_course?(course) #当为学生的时候,需根据分班来判断试卷状态
if course.is_end
status = 4
else
if user.present? && user.student_of_course?(course) #当为学生的时候,需根据分班来判断试卷状态
ex_time = get_exercise_times(user_id,false)
pb_time = ex_time[:publish_time]
ed_time = ex_time[:end_time]
@ -139,8 +141,9 @@ class Exercise < ApplicationRecord
else
status = Exercise::UNPUBLISHED
end
else
status = exercise_status #当为老师的时候,则为试卷的总状态
else
status = exercise_status #当为老师的时候,则为试卷的总状态
end
end
status
end

@ -100,19 +100,23 @@ class Poll < ApplicationRecord
end
def get_poll_status(user)
if user.student_of_course?(course)
ex_time = get_poll_times(user_id,false)
pb_time = ex_time[:publish_time]
ed_time = ex_time[:end_time]
if pb_time.present? && ed_time.present? && pb_time <= Time.now && ed_time > Time.now
status = 2
elsif ed_time.present? && ed_time <= Time.now
status = 3
if course.is_end
status = 4
else
if user.present? && user.student_of_course?(course)
ex_time = get_poll_times(user_id,false)
pb_time = ex_time[:publish_time]
ed_time = ex_time[:end_time]
if pb_time.present? && ed_time.present? && pb_time <= Time.now && ed_time > Time.now
status = 2
elsif ed_time.present? && ed_time <= Time.now
status = 3
else
status = 1
end
else
status = 1
status = polls_status
end
else
status = polls_status
end
status
end

@ -10,7 +10,7 @@ module Searchable::Dependents::ChallengeTag
def check_searchable_dependents
if new_record? || name_previously_changed?
challenge.shixun.reindex(:searchable_challenge_data)
challenge.shixun.reindex
end
end
end

@ -9,7 +9,7 @@ module Searchable::Dependents::Stage
def check_searchable_dependents
if name_previously_changed? || description_previously_changed?
subject.reindex(:searchable_stages_data)
subject.reindex
end
end
end

@ -10,13 +10,13 @@ module Searchable::Dependents::User
def check_searchable_dependents
if firstname_previously_changed? || lastname_previously_changed? || user_extension.school_id_previously_changed?
# reindex shixun
created_shixuns.each{ |shixun| shixun.reindex(:searchable_user_data) }
created_shixuns.each(&:reindex)
# reindex course
manage_courses.each(&:reindex)
# reindex subject
created_subjects.each { |subject| subject.reindex(:searchable_user_data) }
created_subjects.each(&:reindex)
end
end
end

@ -5,4 +5,7 @@ if md.present?
json.md_name md.name
json.md_content md.content
json.created_at md.created_at.strftime('%Y-%m-%d %H:%M:%S')
json.attachments do
json.array! md.attachments, partial: 'attachments/attachment_simple', as: :attachment
end
end

@ -1,5 +1,6 @@
competition = current_competition
json.personal competition.personal?
json.enroll_ended competition.enroll_ended?
json.enrolled competition.enrolled?(current_user)

@ -17,6 +17,9 @@ json.competition_teams do
json.partial! 'users/user_simple', user: member.user
json.user_id member.user_id
json.role member.en_role
json.identity member.user.identity
json.school_name member.user.school_name
json.student_id member.user.student_id
end
end
end

@ -1,5 +1,6 @@
json.course_is_end @course.is_end # true表示已结束false表示未结束
json.extract! @poll, :id,:polls_name,:polls_description,:polls_status,:show_result
json.extract! @poll, :id,:polls_name,:polls_description,:show_result
json.polls_status @poll_status
json.user_permission do
json.is_teacher_or @is_teacher_or

Loading…
Cancel
Save