Merge branches 'dev_aliyun' and 'dev_chen' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_chen

PCqiandao
杨树明 5 years ago
commit cf0ba6cf80

@ -114,6 +114,8 @@ class Weapps::AttendancesController < ApplicationController
@course_members = @course.students if @_is_current_attendance @course_members = @course.students if @_is_current_attendance
@all_attendances = @attendance.course_member_attendances @all_attendances = @attendance.course_member_attendances
@user = @attendance.user
end end
def update def update

@ -81,6 +81,8 @@ module CoursesHelper
"/classrooms/#{course.id}/statistics" "/classrooms/#{course.id}/statistics"
when "video" when "video"
"/classrooms/#{course.id}/course_videos" "/classrooms/#{course.id}/course_videos"
when "attendance"
"/classrooms/#{course.id}/signin"
end end
end end
@ -131,31 +133,33 @@ module CoursesHelper
# 课堂模块的任务数 # 课堂模块的任务数
def course_task_count(course, module_type) def course_task_count(course, module_type)
case module_type case module_type
when "shixun_homework" when "shixun_homework"
get_homework_commons_count(course, 4, 0) get_homework_commons_count(course, 4, 0)
when "common_homework" when "common_homework"
get_homework_commons_count(course, 1, 0) get_homework_commons_count(course, 1, 0)
when "group_homework" when "group_homework"
get_homework_commons_count(course, 3, 0) get_homework_commons_count(course, 3, 0)
when "graduation" when "graduation"
0 0
when "exercise" when "exercise"
course.exercises_count course.exercises_count
when "poll" when "poll"
course.polls_count course.polls_count
when "attachment" when "attachment"
get_attachment_count(course, 0) get_attachment_count(course, 0)
when "board" when "board"
course_board = course.course_board course_board = course.course_board
course_board.present? ? course_board.messages.size : 0 course_board.present? ? course_board.messages.size : 0
when "course_group" when "course_group"
course.course_groups_count course.course_groups_count
when "announcement" when "announcement"
course.informs.count course.informs.count
when "online_learning" when "online_learning"
course.shixuns.count course.shixuns.count
when "video" when "video"
course.videos_count + course.live_links.count course.videos_count + course.live_links.count
when "attendance"
course.course_attendances.count
end end
end end

@ -226,7 +226,7 @@ class Course < ApplicationRecord
end end
def all_course_module_types def all_course_module_types
%w[activity announcement online_learning shixun_homework common_homework group_homework exercise attachment course_group graduation poll board statistics video] %w[activity announcement online_learning shixun_homework common_homework group_homework exercise attachment course_group graduation poll board statistics video attendance]
end end
def get_course_module_by_type(type) def get_course_module_by_type(type)
@ -429,6 +429,7 @@ class Course < ApplicationRecord
when 'video' then '视频直播' when 'video' then '视频直播'
when 'board' then '讨论' when 'board' then '讨论'
when 'course_group' then '分班' when 'course_group' then '分班'
when 'attendance' then '签到'
when 'statistics' then '统计' when 'statistics' then '统计'
else '' else ''
end end
@ -449,7 +450,8 @@ class Course < ApplicationRecord
when 'video' then 11 when 'video' then 11
when 'board' then 12 when 'board' then 12
when 'course_group' then 13 when 'course_group' then 13
when 'statistics' then 14 when 'attendance' then 14
when 'statistics' then 15
else 100 else 100
end end
end end

@ -9,6 +9,10 @@ json.name @attendance.name
json.attendance_date @attendance.attendance_date.strftime("%Y-%m-%d") json.attendance_date @attendance.attendance_date.strftime("%Y-%m-%d")
json.start_time @attendance.start_time.strftime("%H:%M") json.start_time @attendance.start_time.strftime("%H:%M")
json.end_time @attendance.end_time.strftime("%H:%M") json.end_time @attendance.end_time.strftime("%H:%M")
json.author do
json.user_name @user.real_name
json.user_login @user.login
end
# json.course_groups @group_ids do |group| # json.course_groups @group_ids do |group|
# json.(group, :id, :name, :course_members_count) # json.(group, :id, :name, :course_members_count)

@ -0,0 +1,16 @@
class AddAttendanceToCourseModule < ActiveRecord::Migration[5.2]
def change
Course.all.each do |course|
unless course.course_modules.exists?(module_type: "attendance")
atta_position = course.course_modules.find_by(module_type: 'course_group')&.position.to_i
attendance_position = atta_position != 0 ? (atta_position + 1) : 14
course.course_modules.where("position >= #{attendance_position}").update_all("position = position + 1")
if course.is_end
course.course_modules << CourseModule.new(module_type: "attendance", hidden: 1, module_name: "签到", position: attendance_position)
else
course.course_modules << CourseModule.new(module_type: "attendance", hidden: 0, module_name: "签到", position: attendance_position)
end
end
end
end
end
Loading…
Cancel
Save