diff --git a/app/controllers/colleges_controller.rb b/app/controllers/colleges_controller.rb index 960030c9..fff508a8 100644 --- a/app/controllers/colleges_controller.rb +++ b/app/controllers/colleges_controller.rb @@ -31,9 +31,9 @@ class CollegesController < ApplicationController end def verification_school_identifier - school = School.where(:identifier => params[:identifier]).first - status = school.present? ? 1 : 0 - render :json => {status: status} + schools = School.where(identifier: params[:identifier]) + schools = schools.where('id != ?', params[:school_id]) if params[:school_id].present? + render :json => { status: schools.exists? ? 1 : 0 } end def online_school diff --git a/app/controllers/managements/schools_controller.rb b/app/controllers/managements/schools_controller.rb index f27e00ae..a5c789ff 100644 --- a/app/controllers/managements/schools_controller.rb +++ b/app/controllers/managements/schools_controller.rb @@ -4,8 +4,8 @@ class Managements::SchoolsController < Managements::BaseController def statistics @sub_type = 1 - params[:sort_by] = :teacher_count if params[:sort_by].blank? - params[:sort_direction] = :desc if params[:sort_direction].blank? + params[:sort_by] = params[:sort_by].presence || :teacher_count + params[:sort_direction] = params[:sort_direction].presence || :desc service = Management::SchoolReportService.new(params) @obj_count, @schools = service.call @@ -20,8 +20,8 @@ class Managements::SchoolsController < Managements::BaseController def data_grow @sub_type = 2 params[:data_type] ||= 'grow' - params[:sort_by] = :teacher_increase_count if params[:sort_by].blank? - params[:sort_direction] = :desc if params[:sort_direction].blank? + params[:sort_by] = params[:sort_by].presence || :teacher_increase_count + params[:sort_direction] = params[:sort_direction].presence || :desc service = Management::SchoolDataGrowService.new(params) @grow_summary = service.grow_summary @@ -31,7 +31,7 @@ class Managements::SchoolsController < Managements::BaseController end def data_contrast - params[:contrast_column] = :teacher_increase_count if params[:contrast_column].blank? + params[:contrast_column] = params[:contrast_column].presence || :teacher_increase_count params[:sort_direction] ||= :desc params[:sort_by] = :percentage diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 2d7ba1e2..03ffd83d 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -875,7 +875,7 @@ class ManagementsController < ApplicationController keyword = params[:keyword] limit = 20 - if search + if search.present? if "u_name" == keyword @evaluate_recods = EvaluateRecord.joins("join users u on evaluate_records.user_id = u.id").where("concat(u.lastname, u.firstname) like '%#{search}%'") # @evaluate_recods = EvaluateRecord.where(user_id: User.where("concat(lastname, firstname) like '%#{search}%'").pluck(:id)) @@ -884,7 +884,12 @@ class ManagementsController < ApplicationController # @evaluate_recods = EvaluateRecord.where(user_id: UserExtensions.where(school_id: School.where("name like '%#{search}%'").pluck(:id)).pluck(:user_id)) end else - @evaluate_recods = EvaluateRecord.where("0=0") + @evaluate_recods = EvaluateRecord.where(nil) + end + + if params[:beginTime].present? + endTime = params[:endTime].present? ? params[:endTime] : Time.now + @evaluate_recods = @evaluate_recods.where("created_at >= ? and created_at <= ?", params[:beginTime], endTime) end @evaluate_recods_count = @evaluate_recods.count @@ -1513,7 +1518,7 @@ end if search.blank? @schools = School.where("0=0") else - @schools = School.where("name like '%#{search}%'") + @schools = School.where("name like ?", "%#{search}%") end if params[:index] == '8' @schools = @schools.reorder("created_at #{@sx_order}") diff --git a/app/models/course.rb b/app/models/course.rb index 843d846d..c6c6d3df 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -500,6 +500,15 @@ class Course < ActiveRecord::Base end end + # 课堂实训作业的评测次数 + def evaluate_count + course_user_ids = self.members.map(&:user_id) + shixun_ids = self.homework_commons.joins(:homework_commons_shixuns).where(homework_type: 4).pluck(:shixun_id) + return 0 if shixun_ids.blank? + Game.joins(:challenge).where(challenges: {shixun_id: shixun_ids}, games: {user_id: course_user_ids}).sum(:evaluate_count) + end + + #课程动态公共表记录 def act_as_course_activity self.course_acts << CourseActivity.new(:user_id => self.tea_id,:course_id => self.id) diff --git a/app/views/attachments/_form_attachments.html.erb b/app/views/attachments/_form_attachments.html.erb index e1d6b3b5..58ae4aa0 100644 --- a/app/views/attachments/_form_attachments.html.erb +++ b/app/views/attachments/_form_attachments.html.erb @@ -49,8 +49,9 @@ <%= javascript_include_tag 'attachments' %>