diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 28a1b5b6e..3a7096b2a 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -60,7 +60,8 @@ class AccountsController < ApplicationController ua = UserAgent.find_by_ip(ip) ua.update_column(:agent_type, UserAgent::USER_REGISTER) if ua successful_authentication(@user) - session[:user_id] = @user.id + # session[:user_id] = @user.id + session[:"#{default_yun_session}"] = @user.id normal_status("注册成功") end rescue Exception => e @@ -94,7 +95,7 @@ class AccountsController < ApplicationController successful_authentication(@user) login_control.clear # 重置每日密码错误次数 - session[:user_id] = @user.id + # session[:user_id] = @user.id end # 忘记密码 @@ -158,7 +159,7 @@ class AccountsController < ApplicationController def logout UserAction.create(action_id: User.current.id, action_type: "Logout", user_id: User.current.id, :ip => request.remote_ip) - session[:user_id] = nil + session[:"#{default_yun_session}"] = nil logout_user render :json => {status: 1, message: "退出成功!"} end diff --git a/app/controllers/admins/shixun_feedback_messages_controller.rb b/app/controllers/admins/shixun_feedback_messages_controller.rb new file mode 100644 index 000000000..31fcc468c --- /dev/null +++ b/app/controllers/admins/shixun_feedback_messages_controller.rb @@ -0,0 +1,14 @@ +class Admins::ShixunFeedbackMessagesController < Admins::BaseController + + def index + default_sort('created_at', 'desc') + @params_page = params[:page] || 1 + if params[:keyword] + discusses = Discuss.find_by_sql("select * from discusses join shixuns on discusses.dis_id = shixuns.id where discusses.dis_type='Shixun' AND + shixuns.name like '%#{params[:keyword]}%'") + else + discusses = Discuss.where(:dis_type => 'Shixun').includes(:user, :dis) + end + @discusses = paginate discusses + end +end \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c6aca5ae5..4c61fb1df 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -299,9 +299,11 @@ class ApplicationController < ActionController::Base # and starts a session if needed def find_current_user uid_logger("user setup start: session[:user_id] is #{session[:user_id]}") - if session[:user_id] + uid_logger("0000000000000user setup start: session[:user_id] is #{session[:"#{default_yun_session}"]}") + current_domain_session = session[:"#{default_yun_session}"] + if current_domain_session # existing session - (User.active.find(session[:user_id]) rescue nil) + (User.active.find(current_domain_session) rescue nil) elsif autologin_user = try_to_autologin autologin_user elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth? @@ -313,10 +315,10 @@ class ApplicationController < ActionController::Base def try_to_autologin if cookies[autologin_cookie_name] # auto-login feature starts a new session - user = User.try_to_autologin(cookies[autologin_cookie_name]) - if user - start_user_session(user) - end + user = nil + Rails.logger.info("111111111111111111#{default_yun_session}, session is #{session[:"#{default_yun_session}"]} ") + user = User.try_to_autologin(cookies[autologin_cookie_name]) if session[:"#{default_yun_session}"] + start_user_session(user) if user user end end diff --git a/app/controllers/concerns/laboratory_helper.rb b/app/controllers/concerns/laboratory_helper.rb index 37a3675f0..ecb478388 100644 --- a/app/controllers/concerns/laboratory_helper.rb +++ b/app/controllers/concerns/laboratory_helper.rb @@ -27,5 +27,6 @@ module LaboratoryHelper def default_yun_session @_default_yun_session = "#{request.subdomain.split('.').first}_user_id" + # @_default_yun_session = "#{current_laboratory.try(:identifier).split('.').first}_user_id" end end \ No newline at end of file diff --git a/app/controllers/concerns/login_helper.rb b/app/controllers/concerns/login_helper.rb index 8497799e3..cf0c8e1e3 100644 --- a/app/controllers/concerns/login_helper.rb +++ b/app/controllers/concerns/login_helper.rb @@ -47,7 +47,7 @@ module LoginHelper User.current.delete_session_token(session[:tk]) self.logged_user = nil end - session[:user_id] = nil + session[:"#{default_yun_session}"] = nil end # Sets the logged in user @@ -73,8 +73,8 @@ module LoginHelper # # session[:"#{request.subdomain}_user_id"] = user.id # # end - session[:user_id] = user.id - # session[:"#{default_yun_session}"] = user.id + # session[:user_id] = user.id + session[:"#{default_yun_session}"] = user.id session[:ctime] = Time.now.utc.to_i session[:atime] = Time.now.utc.to_i end diff --git a/app/controllers/hack_user_lastest_codes_controller.rb b/app/controllers/hack_user_lastest_codes_controller.rb index a4b41a162..2d749ce75 100644 --- a/app/controllers/hack_user_lastest_codes_controller.rb +++ b/app/controllers/hack_user_lastest_codes_controller.rb @@ -35,7 +35,7 @@ class HackUserLastestCodesController < ApplicationController # 提交结果显示 def result if @my_hack.submit_status == 1 - render json: {status:0, message: "正在评测中"} + render json: {status: 1, message: "正在评测中"} else @mode = params[:mode] @result = diff --git a/app/controllers/oauth/base_controller.rb b/app/controllers/oauth/base_controller.rb index e4068fbda..327f21845 100644 --- a/app/controllers/oauth/base_controller.rb +++ b/app/controllers/oauth/base_controller.rb @@ -12,7 +12,8 @@ class Oauth::BaseController < ActionController::Base private def session_user_id - session[:user_id] + # session[:user_id] + session[:"#{default_yun_session}"] end def current_user diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 5a3fda7a4..068a0dafd 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -198,14 +198,14 @@ class PollsController < ApplicationController def common_header ActiveRecord::Base.transaction do begin + @poll_status = @poll.get_poll_status(current_user) if @user_course_identity > Course::ASSISTANT_PROFESSOR @is_teacher_or = 0 - @user_poll_answer = @poll.check_user_votes_status(current_user) + @user_poll_answer = @poll.check_user_votes_status(current_user, @poll_status) else @is_teacher_or = 1 @user_poll_answer = 3 #教师页面 end - @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 #是否存在未发布的 diff --git a/app/controllers/weapps/registers_controller.rb b/app/controllers/weapps/registers_controller.rb index 391850090..de48ebd54 100644 --- a/app/controllers/weapps/registers_controller.rb +++ b/app/controllers/weapps/registers_controller.rb @@ -48,7 +48,8 @@ class Weapps::RegistersController < Weapps::BaseController ) end successful_authentication(@user) - session[:user_id] = @user.id + # session[:user_id] = @user.id + session[:"#{default_yun_session}"] = @user.id # render_ok(user_id: @user.id) end diff --git a/app/helpers/polls_helper.rb b/app/helpers/polls_helper.rb index 866d28254..7ae4470e2 100644 --- a/app/helpers/polls_helper.rb +++ b/app/helpers/polls_helper.rb @@ -77,7 +77,7 @@ module PollsHelper ex_pb_time = poll.get_poll_times(user.id,false) poll_publish_time = ex_pb_time[:publish_time] poll_end_time = ex_pb_time[:end_time] - current_status = poll.check_user_votes_status(user) + current_status = poll.check_user_votes_status(user, poll_status) lock_icon = 0 #不显示锁图标 else poll_users_list = poll.get_poll_exercise_users diff --git a/app/models/poll.rb b/app/models/poll.rb index 9cb860f61..ea6656ca2 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -146,12 +146,22 @@ class Poll < ApplicationRecord end #判断当前用户的答题状态 - def check_user_votes_status(user) + def check_user_votes_status(user, poll_status) poll_answer_user = poll_users.where(user_id: user.id).select(:start_at,:end_at,:commit_status) user_status = 2 if poll_answer_user.exists? && (poll_answer_user.first&.start_at.present? || poll_answer_user.first&.end_at.present?) #学生有过答题的,或者立即截止,但学生未做试卷的 user_status = poll_answer_user.first.commit_status end + # 问卷已截止时学生的答题状态需要考虑问卷的状态 + if poll_status > 2 + # 问卷如果还是继续答题状态则自动提交 + if user_status == 0 + poll_end_time = get_poll_times(user.id,false)[:end_time] + poll_answer_user.first.update_attributes!(:commit_status => 1, :end_at => poll_end_time) + user_status = 1 + end + user_status = user_status == 1 ? 1 : 4 + end user_status end diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb index f78b52ac7..7b1f5db7a 100644 --- a/app/views/admins/shared/_sidebar.html.erb +++ b/app/views/admins/shared/_sidebar.html.erb @@ -65,6 +65,12 @@ <% end %> +
序号 | +实训名称 | +评论内容 | +评论者 | +评论时间 | +
---|---|---|---|---|
<%= (@params_page.to_i - 1) * 20 + index + 1 %> | + <% identifier = Game.find_by(challenge_id: discuss.challenge_id, user_id: discuss.user_id)&.identifier %> +<%= link_to discuss.dis.name, "/tasks/#{identifier}", target: '_blank'%> | +<%= content_safe discuss.content %> | +<%= discuss.user.show_real_name %> | +<%= format_time discuss.created_at %> | +