diff --git a/app/controllers/weapps/attendances_controller.rb b/app/controllers/weapps/attendances_controller.rb index da22aa300..9740da15f 100644 --- a/app/controllers/weapps/attendances_controller.rb +++ b/app/controllers/weapps/attendances_controller.rb @@ -114,6 +114,8 @@ class Weapps::AttendancesController < ApplicationController @course_members = @course.students if @_is_current_attendance @all_attendances = @attendance.course_member_attendances + + @user = @attendance.user end def update diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 27444b3c9..99925505f 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -81,6 +81,8 @@ module CoursesHelper "/classrooms/#{course.id}/statistics" when "video" "/classrooms/#{course.id}/course_videos" + when "attendance" + "/classrooms/#{course.id}/signin" end end @@ -131,31 +133,33 @@ module CoursesHelper # 课堂模块的任务数 def course_task_count(course, module_type) case module_type - when "shixun_homework" - get_homework_commons_count(course, 4, 0) - when "common_homework" - get_homework_commons_count(course, 1, 0) - when "group_homework" - get_homework_commons_count(course, 3, 0) - when "graduation" - 0 - when "exercise" - course.exercises_count - when "poll" - course.polls_count - when "attachment" - get_attachment_count(course, 0) - when "board" - course_board = course.course_board - course_board.present? ? course_board.messages.size : 0 - when "course_group" - course.course_groups_count - when "announcement" - course.informs.count - when "online_learning" - course.shixuns.count - when "video" - course.videos_count + course.live_links.count + when "shixun_homework" + get_homework_commons_count(course, 4, 0) + when "common_homework" + get_homework_commons_count(course, 1, 0) + when "group_homework" + get_homework_commons_count(course, 3, 0) + when "graduation" + 0 + when "exercise" + course.exercises_count + when "poll" + course.polls_count + when "attachment" + get_attachment_count(course, 0) + when "board" + course_board = course.course_board + course_board.present? ? course_board.messages.size : 0 + when "course_group" + course.course_groups_count + when "announcement" + course.informs.count + when "online_learning" + course.shixuns.count + when "video" + course.videos_count + course.live_links.count + when "attendance" + course.course_attendances.count end end diff --git a/app/models/course.rb b/app/models/course.rb index abe17b3cd..bd36e65eb 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -226,7 +226,7 @@ class Course < ApplicationRecord end 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 def get_course_module_by_type(type) @@ -429,6 +429,7 @@ class Course < ApplicationRecord when 'video' then '视频直播' when 'board' then '讨论' when 'course_group' then '分班' + when 'attendance' then '签到' when 'statistics' then '统计' else '' end @@ -449,7 +450,8 @@ class Course < ApplicationRecord when 'video' then 11 when 'board' then 12 when 'course_group' then 13 - when 'statistics' then 14 + when 'attendance' then 14 + when 'statistics' then 15 else 100 end end diff --git a/app/views/weapps/attendances/show.json.jbuilder b/app/views/weapps/attendances/show.json.jbuilder index b3f13ca60..b16971741 100644 --- a/app/views/weapps/attendances/show.json.jbuilder +++ b/app/views/weapps/attendances/show.json.jbuilder @@ -9,6 +9,10 @@ json.name @attendance.name 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.author do + json.user_name @user.real_name + json.user_login @user.login +end # json.course_groups @group_ids do |group| # json.(group, :id, :name, :course_members_count) diff --git a/db/migrate/20200312075912_add_attendance_to_course_module.rb b/db/migrate/20200312075912_add_attendance_to_course_module.rb new file mode 100644 index 000000000..02bb48fe1 --- /dev/null +++ b/db/migrate/20200312075912_add_attendance_to_course_module.rb @@ -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 diff --git a/public/images/qiandao/daoke.png b/public/images/qiandao/daoke.png new file mode 100644 index 000000000..7bdcac50e Binary files /dev/null and b/public/images/qiandao/daoke.png differ diff --git a/public/images/qiandao/kuangke.png b/public/images/qiandao/kuangke.png new file mode 100644 index 000000000..13c9972ee Binary files /dev/null and b/public/images/qiandao/kuangke.png differ diff --git a/public/images/qiandao/lishi.png b/public/images/qiandao/lishi.png new file mode 100644 index 000000000..98c72702a Binary files /dev/null and b/public/images/qiandao/lishi.png differ diff --git a/public/images/qiandao/qingjia.png b/public/images/qiandao/qingjia.png new file mode 100644 index 000000000..2d885f432 Binary files /dev/null and b/public/images/qiandao/qingjia.png differ