签到调整

video_transcode
cxt 5 years ago
parent 304ae69f4e
commit 6b22c52549

@ -330,7 +330,7 @@ class ApplicationController < ActionController::Base
end
if !User.current.logged? && Rails.env.development?
User.current = User.find 3117
User.current = User.find 1
end

@ -90,12 +90,13 @@ class Weapps::AttendancesController < ApplicationController
@_is_current_attendance = @attendance.current_attendance?
if @attendance.course_attendance_groups.first&.course_group_id.to_i == 0
@groups = @course.course_groups
@group_ids = @course.course_groups.pluck(:id) + [0]
else
@groups = @course.course_groups.where(id: @attendance.course_attendance_groups.pluck(:course_group_id))
@group_ids = @attendance.course_attendance_groups.pluck(:course_group_id)
end
@groups = @groups.includes(:course_members) if @_is_current_attendance
@groups = @course.course_groups.where(id: @group_ids)
@course_members = @course.students if @_is_current_attendance
@all_attendances = @attendance.course_member_attendances
end

@ -5,9 +5,9 @@ module Weapps::AttendancesHelper
st_attendance.present? ? st_attendance.attendance_status : "ABSENCE"
end
def group_attendance_count attendances, group
course_member_ids = group.course_members.pluck(:id)
attendances.select{|attendance| course_member_ids.include?(attendance.course_member_id) && attendance.attendance_status == "NORMAL"}.size
def group_attendance_count attendances, member_ids
# course_member_ids = group.course_members.pluck(:id)
attendances.select{|attendance| member_ids.include?(attendance.course_member_id) && attendance.attendance_status == "NORMAL"}.size
end
def history_member_count member_attendances, status, attendance_id

@ -9,6 +9,8 @@ class CourseGroup < ApplicationRecord
has_many :homework_group_settings, :dependent => :destroy
scope :by_group_ids, lambda { |ids| where(id: ids)}
has_many :course_attendance_groups, dependent: :destroy
validates :name, length: { maximum: 60, too_long: "不能超过60个字符" }
validates_uniqueness_of :name, scope: :course_id, message: "不能创建相同名称的分班"

@ -9,7 +9,22 @@ json.attendance_date @attendance.attendance_date.strftime("%Y/%m/%d")
json.start_time @attendance.start_time.strftime("%H:%M")
json.end_time @attendance.end_time.strftime("%H:%M")
json.course_groups @groups do |group|
json.(group, :id, :name, :course_members_count)
json.attendance_count group_attendance_count(@all_attendances, group) if @_is_current_attendance
# json.course_groups @group_ids do |group|
# json.(group, :id, :name, :course_members_count)
# json.attendance_count group_attendance_count(@all_attendances, group) if @_is_current_attendance
# end
json.course_groups @group_ids do |group_id|
if group_id != 0
group = @groups.select{|group| group.id == group_id}.first
json.(group, :id, :name, :course_members_count)
else
json.id 0
json.name "未分班"
json.course_members_count @course.none_group_count
end
if @_is_current_attendance
member_ids = @course_members.select{|member| member.course_group_id == group_id}.map(&:id)
json.attendance_count group_attendance_count(@all_attendances, member_ids)
end
end
Loading…
Cancel
Save