Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

dev_cs
杨树明 5 years ago
commit 760ccb3436

@ -40,8 +40,8 @@ class CollegesController < ApplicationController
def teachers
@teachers = User.find_by_sql("SELECT users.id, users.login, users.lastname, users.firstname, users.nickname, IFNULL((SELECT count(shixuns.id) FROM shixuns where shixuns.user_id =users.id group by shixuns.user_id), 0) AS publish_shixun_count,
(SELECT count(c.id) FROM courses c, course_members m WHERE c.id != 1309 and m.course_id = c.id AND m.role in (1,2,3) and c.school_id = #{current_school.id} AND m.user_id=users.id AND c.is_delete = 0) as course_count
FROM `users`, user_extensions ue where users.id=ue.user_id and ue.identity=0 and ue.school_id=#{current_school.id} ORDER BY publish_shixun_count desc, course_count desc, id desc LIMIT 10")
(SELECT count(c.id) FROM courses c, course_members m WHERE c.id != 1309 and m.course_id = c.id AND m.user_id=users.id AND m.role in (1,2,3) and c.school_id = #{current_school.id} AND c.is_delete = 0) as course_count
FROM `users`, user_extensions ue where ue.school_id=#{current_school.id} and users.id=ue.user_id and ue.identity=0 ORDER BY publish_shixun_count desc, course_count desc, id desc LIMIT 10")
# ).order("publish_shixun_count desc, experience desc").limit(10)
@teachers =
@teachers.map do |teacher|

@ -14,7 +14,7 @@ class Ecs::StudentsController < Ecs::BaseController
end
def import
success_count = Ecs::ImportStudentService.call(current_year, params[:attachment_id])
success_count = Ecs::ImportStudentService.call(current_year, params)
render_ok(success_count: success_count)
rescue Ecs::ImportStudentService::Error => ex
render_error(ex.message)

@ -168,7 +168,7 @@ class GraduationTasksController < ApplicationController
end
end
else
@work_list = @work
@work_list = !@task.published? ? [] : @work
@view_work = false
@work_count = @work_list.count
@all_work_count = @work_list.count

@ -48,7 +48,7 @@ class GraduationWork < ApplicationRecord
def delete_atta atta
last_score = graduation_work_scores.where.not(score: nil).last
atta.author_id == user_id && (!last_score.present? || last_score.try(:created_at) < atta.created_on)
(atta.author_id == User.current.id) && (last_score.blank? || last_score.try(:created_at) < atta.created_on)
end
# 分班名

@ -106,7 +106,7 @@ class StudentWork < ApplicationRecord
def delete_atta atta
last_score = student_works_scores.where.not(score: nil).last
atta.author_id == user_id && (!last_score.present? || last_score.try(:created_at) < atta.created_on)
(atta.author_id == User.current.id) && (last_score.blank? || last_score.try(:created_at) < atta.created_on)
end
# 作品总体评价

@ -1,21 +1,20 @@
class Ecs::ImportStudentService < ApplicationService
Error = Class.new(StandardError)
attr_reader :ec_year, :attachment
attr_reader :ec_year, :params
def initialize(ec_year, attachment_id)
@ec_year = ec_year
@attachment = Attachment.find_by(id: attachment_id)
def initialize(ec_year, params)
@ec_year = ec_year
@params = params
end
def call
raise Error, '文件不存在' if attachment.blank?
raise Error, '文件不存在' if params[:file].blank? || !params[:file].is_a?(ActionDispatch::Http::UploadedFile)
path = attachment.diskfile
excel = Ecs::ImportStudentExcel.new(path)
excel = Ecs::ImportStudentExcel.new(params[:file].path)
success_count = 0
EcYearStudent.bulk_insert(:student_id, :name, :created_at, :updated_at) do |worker|
EcYearStudent.bulk_insert(:ec_year_id, :student_id, :name, :created_at, :updated_at) do |worker|
excel.read_each do |student_id, name|
success_count += 1
@ -25,7 +24,7 @@ class Ecs::ImportStudentService < ApplicationService
next
end
worker.add(student_id: student_id, name: name)
worker.add(ec_year_id: ec_year.id, student_id: student_id, name: name)
end
end

@ -9,6 +9,8 @@ class Ecs::SaveGraduationCourseSupportsService < ApplicationService
end
def call
set_course_supports_position!
Ecs::SaveGraduationCourseSupportForm.new(params).validate!
accepts_attributes = build_accepts_nested_attributes(
@ -20,4 +22,10 @@ class Ecs::SaveGraduationCourseSupportsService < ApplicationService
graduation_subitem.save!
graduation_subitem
end
def set_course_supports_position!
params[:course_supports].each_with_index do |item, index|
item[:position] = index + 1
end
end
end

@ -27,8 +27,8 @@ class StatisticSchoolDailyReportTask
# 新增实训评测数量
shixun_evaluate_count = EvaluateRecord.joins('LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = evaluate_records.shixun_id')
.joins('LEFT JOIN homework_commons hc ON hcs.homework_common_id = hc.id AND hc.homework_type = 4')
.joins('LEFT JOIN members ON members.user_id = evaluate_records.user_id')
.joins('LEFT JOIN courses ON members.course_id = courses.id AND hc.course_id = courses.id')
.joins('LEFT JOIN course_members ON course_members.user_id = evaluate_records.user_id')
.joins('LEFT JOIN courses ON course_members.course_id = courses.id AND hc.course_id = courses.id')
.where(courses: { school_id: school.id })
.where(created_at: yesterday).reorder(nil).count

@ -2,10 +2,10 @@ class StatisticSchoolReportTask
def call
School.find_each do |school|
evaluate_count = Game.joins(:challenge)
.joins('LEFT JOIN members ON members.user_id = games.user_id')
.joins('LEFT JOIN course_members ON course_members.user_id = games.user_id')
.joins('LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = challenges.shixun_id')
.joins('LEFT JOIN homework_commons hc ON hcs.homework_common_id = hc.id AND hc.homework_type = 4')
.joins('LEFT JOIN courses ON hc.course_id = courses.id AND members.course_id = courses.id')
.joins('LEFT JOIN courses ON hc.course_id = courses.id AND course_members.course_id = courses.id')
.where(courses: { school_id: school.id })
.sum(:evaluate_count)

@ -53,12 +53,12 @@
<td><span class="apply-status-<%= apply.status %>"><%= apply.status_text %></span></td>
<% else %>
<td class="action-container">
<%= agree_link '同意', agree_admins_professional_authentication_path(apply, element: ".professional-authentication-#{apply.id}"), 'data-confirm': '确认审核通过?' %>
<%= agree_link '同意', agree_admins_professional_authentication_path(apply, element: ".professional-authentication-#{apply.id}"), 'data-confirm': '确认审核通过?', 'data-disable-with': "提交中..." %>
<%= javascript_void_link('拒绝', class: 'action refuse-action',
data: {
toggle: 'modal', target: '.admin-common-refuse-modal', id: apply.id,
url: refuse_admins_professional_authentication_path(apply, element: ".professional-authentication-#{apply.id}")
}) %>
}, 'data-disable-with': "拒绝中...") %>
</td>
<% end %>
</tr>

@ -11,7 +11,7 @@ json.update_user_name @is_evaluation ? "匿名" : @work.update_user.try(:real_na
json.update_atta @homework.late_duration && @is_author
json.attachments @attachments do |atta|
json.partial! "attachments/attachment_simple", locals: {attachment: atta, delete: @work.delete_atta(atta)}
json.partial! "attachments/attachment_simple", locals: {attachment: atta, delete: false}
end
unless @is_evaluation

@ -0,0 +1,6 @@
class MigrateUserExtensionIndex < ActiveRecord::Migration[5.2]
def change
remove_index :user_extensions, :school_id
add_index :user_extensions, [:school_id, :user_id]
end
end

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save