diff --git a/app/controllers/admins/shixun_settings_controller.rb b/app/controllers/admins/shixun_settings_controller.rb index 37ca45674..2f139279b 100644 --- a/app/controllers/admins/shixun_settings_controller.rb +++ b/app/controllers/admins/shixun_settings_controller.rb @@ -17,7 +17,8 @@ class Admins::ShixunSettingsController < Admins::BaseController homepage_show: params[:homepage_show].present? ? params[:homepage_show] : false, task_pass: params[:task_pass].present? ? params[:task_pass] : false, code_hidden: params[:code_hidden].present? ? params[:code_hidden] : false, - vip: params[:vip].present? ? params[:vip] : false + vip: params[:vip].present? ? params[:vip] : false, + is_wechat_support: params[:is_wechat_support].present? ? params[:is_wechat_support] : false } @shixuns_type_check = MirrorRepository.pluck(:type_name,:id) @@ -131,6 +132,7 @@ class Admins::ShixunSettingsController < Admins::BaseController end def setting_params - params.permit(:use_scope,:excute_time,:close,:status,:can_copy,:webssh,:hidden,:homepage_show,:task_pass,:code_hidden,:vip,:page_no,:id,tag_repertoires:[]) + params.permit(:use_scope,:excute_time,:close,:status,:can_copy,:webssh,:hidden,:homepage_show,:task_pass, + :code_hidden,:vip,:page_no,:id, :is_wechat_support, tag_repertoires:[]) end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e0639de3f..fdb41c114 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -23,7 +23,7 @@ class ApplicationController < ActionController::Base # 所有请求必须合法签名 def check_sign - if !Rails.env.development? && EduSetting.get("host_name") != "https://test-newweb.educoder.net" + if !Rails.env.development? Rails.logger.info("66666 #{params}") # suffix = request.url.split(".").last.split("?").first # suffix_arr = ["xls", "xlsx", "pdf", "zip"] # excel文件先注释 diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 5b555cf4c..44bfcf03f 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -402,7 +402,7 @@ class ExercisesController < ApplicationController if unified_setting || (course_group_ids.size == 0) tip_exception("发布时间不能为空") if params[:publish_time].blank? tip_exception("截止时间不能为空") if params[:end_time].blank? - tip_exception("截止时间不能早于发布时间") if params[:publish_time].to_time > params[:end_time].to_time + tip_exception("截止时间必须晚于发布时间") if params[:publish_time].to_time >= params[:end_time].to_time tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if @course.end_date.present? && params[:end_time].to_time > @course.end_date.end_of_day params_publish_time = params[:publish_time].to_time diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb index cac763344..6196aa5f5 100644 --- a/app/controllers/graduation_tasks_controller.rb +++ b/app/controllers/graduation_tasks_controller.rb @@ -384,11 +384,11 @@ class GraduationTasksController < ApplicationController if @task.status == 0 tip_exception("发布时间不能为空") if params[:publish_time].blank? tip_exception("截止时间不能为空") if params[:end_time].blank? - tip_exception("发布时间不能早于当前时间") if params[:publish_time] <= Time.now.strftime("%Y-%m-%d %H:%M:%S") - tip_exception("截止时间不能早于当前时间") if params[:end_time] <= Time.now.strftime("%Y-%m-%d %H:%M:%S") - tip_exception("截止时间不能早于发布时间") if params[:publish_time] > params[:end_time] + tip_exception("发布时间不能早于当前时间") if params[:publish_time].to_time <= Time.now + tip_exception("截止时间不能早于当前时间") if params[:end_time].to_time <= Time.now + tip_exception("截止时间必须晚于发布时间") if params[:publish_time].to_time >= params[:end_time].to_time tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if - @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day) + @course.end_date.present? && params[:end_time].to_time > @course.end_date.end_of_day @task.publish_time = params[:publish_time] @task.end_time = params[:end_time] diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 96a73b08b..db8c688ad 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -909,7 +909,7 @@ class HomeworkCommonsController < ApplicationController def publish_homework tip_exception("请至少选择一个分班") if params[:group_ids].blank? && @course.course_groups.size != 0 - group_ids = params[:group_ids]&.reject(&:blank?) + group_ids = params[:group_ids]&.reject(&:blank?).map(&:to_i) if params[:detail].blank? tip_exception("缺少截止时间参数") if params[:end_time].blank? tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now) @@ -1048,7 +1048,8 @@ class HomeworkCommonsController < ApplicationController homeworks = homeworks.published_no_end.includes(:homework_group_settings, :homework_detail_manual, :homework_challenge_settings) course_students = @course.students charge_group_ids = @course.charge_group_ids(current_user) - end_groups = charge_group_ids & params[:group_ids] if params[:group_ids] + group_ids = params[:group_ids]&.reject(&:blank?).map(&:to_i) + end_groups = charge_group_ids & group_ids if group_ids begin homeworks.each do |homework| diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index c9c9cc567..d320379be 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -724,7 +724,7 @@ class PollsController < ApplicationController if unified_setting || (course_group_ids.size == 0) tip_exception("发布时间不能为空") if params[:publish_time].blank? tip_exception("截止时间不能为空") if params[:end_time].blank? - tip_exception("截止时间不能早于发布时间") if params[:publish_time].to_time > params[:end_time].to_time + tip_exception("截止时间必须晚于发布时间") if params[:publish_time].to_time >= params[:end_time].to_time tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if @course.end_date.present? && params[:end_time].to_time > @course.end_date.end_of_day diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 47863a3a0..ce7fc575c 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -458,30 +458,19 @@ class SubjectsController < ApplicationController end def statistics_info - # data = Subjects::DataStatisticService.new(@subject) - # Rails.logger.info("study_count: #{data.study_count}") - # Rails.logger.info("course_study_count: #{ data.course_study_count}") - # Rails.logger.info("passed_count: #{data.passed_count}") - # Rails.logger.info("course_used_count: #{data.course_used_count}") - # Rails.logger.info("school_used_count: #{data.school_used_count}") - - # data_1 = Subjects::CourseUsedInfoService.call(@subject) - # Rails.logger.info("study_count: #{data_1}") - - # data_2 = Subjects::ShixunUsedInfoService.call(@subject) - # Rails.logger.info("study_count: #{data_2}") - - # data_3 = Subjects::UserUsedInfoService.call(@subject) - # Rails.logger.info("study_count: #{data_3}") - @data = if params[:type] == "shixun_info" @subject.subject_shixun_infos elsif params[:type] == "user_info" @subject.subject_user_infos else + select_sql = "id, count(subject_course_records.id) total, sum(course_count) course_count, sum(student_count) student_count, " + + "sum(choice_shixun_num) choice_shixun_num, sum(choice_shixun_frequency) choice_shixun_frequency" + @total = @subject.subject_course_records.select("#{select_sql}").first @subject.subject_course_records end + + @data_count = @data.count @data = paginate custom_sort(@data, params[:sort_by], params[:sort_direction]) end diff --git a/app/models/searchable/shixun.rb b/app/models/searchable/shixun.rb index e01920490..dfa565da9 100644 --- a/app/models/searchable/shixun.rb +++ b/app/models/searchable/shixun.rb @@ -18,7 +18,8 @@ module Searchable::Shixun status: status, myshixuns_count: myshixuns_count, created_at: created_at, - publish_time: publish_time + publish_time: publish_time, + is_wechat_support: is_wechat_support }.merge!(searchable_user_data) .merge!(searchable_challenge_data) end diff --git a/app/services/shixun_search_service.rb b/app/services/shixun_search_service.rb index 32488a7c3..071b9f478 100644 --- a/app/services/shixun_search_service.rb +++ b/app/services/shixun_search_service.rb @@ -23,9 +23,10 @@ class ShixunSearchService < ApplicationService if User.current.admin? || User.current.business? || !User.current.school_id @shixuns = @shixuns.where(hidden: 0) else - none_shixun_ids = ShixunSchool.where("school_id != #{User.current.school_id}").pluck(:shixun_id) + shixun_ids = ShixunSchool.where(school_id: User.current.school_id).pluck(:shixun_id) + shixun_ids = shixun_ids.reject(&:blank?).length == 0 ? -1 : shixun_ids.join(",") - @shixuns = @shixuns.where.not(id: none_shixun_ids).where(hidden: 0, status: 2, public: 2).or(@shixuns.where(id: User.current.shixuns)) + @shixuns = @shixuns.where("use_scope = 0 or id in (#{shixun_ids})").unhidden.published.or(@shixuns.where(id: User.current.shixuns)) end end @@ -49,11 +50,18 @@ class ShixunSearchService < ApplicationService private def search_options + + order = + if sort_str == "wechat_myshixuns_count" + {"is_wechat_support" => "desc", sort_str => order_str} + else + {sort_str => order_str} + end model_options = { includes: [ :shixun_info, :challenges, :subjects, user: { user_extension: :school } ] } model_options.merge!(where: { id: @shixuns.pluck(:id) }) - model_options.merge!(order: {sort_str => order_str}) + model_options.merge!(order: order) model_options.merge!(default_options) model_options end diff --git a/app/services/subjects/user_used_info_service.rb b/app/services/subjects/user_used_info_service.rb index 3b1b969f0..52d6be005 100644 --- a/app/services/subjects/user_used_info_service.rb +++ b/app/services/subjects/user_used_info_service.rb @@ -10,7 +10,7 @@ class Subjects::UserUsedInfoService < ApplicationService def call users_info = [] users = User.includes(myshixuns: :games).where(myshixuns: {shixun_id: shixun_ids}, games: {status: 2}) - users.each do |user| + users.find_each do |user| myshixuns = user.myshixuns.select{|m| shixun_ids.include?(m.shixun_id)} name = "#{user.lastname}#{user.firstname}" passed_myshixun_count = myshixuns.select{|m| m.status == 1}.size diff --git a/app/services/update_homework_publish_setting_service.rb b/app/services/update_homework_publish_setting_service.rb index 69a68b613..61902cd80 100644 --- a/app/services/update_homework_publish_setting_service.rb +++ b/app/services/update_homework_publish_setting_service.rb @@ -15,11 +15,11 @@ class UpdateHomeworkPublishSettingService < ApplicationService if params[:unified_setting] || course.course_groups_count == 0 tip_exception("发布时间不能为空") if params[:publish_time].blank? tip_exception("截止时间不能为空") if params[:end_time].blank? - tip_exception("发布时间不能早于当前时间") if params[:publish_time] <= Time.now.strftime("%Y-%m-%d %H:%M:%S") - tip_exception("截止时间不能早于当前时间") if params[:end_time] <= Time.now.strftime("%Y-%m-%d %H:%M:%S") - tip_exception("截止时间不能早于发布时间") if params[:publish_time] > params[:end_time] + tip_exception("发布时间不能早于当前时间") if params[:publish_time].to_time <= Time.now + tip_exception("截止时间不能早于当前时间") if params[:end_time].to_time <= Time.now + tip_exception("截止时间必须晚于发布时间") if params[:publish_time].to_time >= params[:end_time].to_time tip_exception("截止时间不能晚于课堂结束时间(#{course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if - course.end_date.present? && params[:end_time] > course.end_date.end_of_day + course.end_date.present? && params[:end_time].to_time > course.end_date.end_of_day homework.unified_setting = 1 homework.homework_group_settings.destroy_all diff --git a/app/views/admins/shixun_settings/shared/_list.html.erb b/app/views/admins/shixun_settings/shared/_list.html.erb index 549c7edf4..b02fc420c 100644 --- a/app/views/admins/shixun_settings/shared/_list.html.erb +++ b/app/views/admins/shixun_settings/shared/_list.html.erb @@ -15,7 +15,7 @@