From 164d3d4413b1e0b0f12511aba65e0085262b74ea Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 10 Oct 2019 15:20:38 +0800 Subject: [PATCH 01/18] =?UTF-8?q?=E5=88=86=E7=8F=AD=E7=9A=84=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 68 +++++++++++++++++++-- app/libs/util.rb | 4 +- app/models/user.rb | 15 +++++ app/views/courses/students.json.jbuilder | 7 ++- app/views/courses/teachers.json.jbuilder | 3 + app/views/users/accounts/show.json.jbuilder | 4 +- config/routes.rb | 1 + 7 files changed, 92 insertions(+), 10 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 4bfc236a1..d639662c2 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -27,7 +27,8 @@ class CoursesController < ApplicationController :attahcment_category_list,:export_member_scores_excel, :duplicate_course, :switch_to_teacher, :switch_to_assistant, :switch_to_student, :exit_course, :informs, :update_informs, :online_learning, :update_task_position, :tasks_list, - :join_excellent_course, :export_couser_info, :export_member_act_score, :new_informs, :delete_informs] + :join_excellent_course, :export_couser_info, :export_member_act_score, :new_informs, + :delete_informs, :change_member_role] before_action :user_course_identity, except: [:join_excellent_course, :index, :create, :new, :apply_to_join_course, :search_course_list, :get_historical_course_students, :mine, :search_slim, :board_list] before_action :teacher_allowed, only: [:update, :destroy, :settings, :search_teacher_candidate, @@ -39,7 +40,7 @@ class CoursesController < ApplicationController :set_course_group, :create_group_by_importing_file, :update_task_position, :tasks_list] before_action :teacher_or_admin_allowed, only: [:graduation_group_list, :create_graduation_group, :join_graduation_group, - :change_course_teacher, :course_group_list, + :change_course_teacher, :course_group_list, :change_member_role, :teacher_application_review, :apply_teachers, :delete_course_teacher] before_action :validate_course_name, only: [:create, :update] before_action :find_board, only: :board_list @@ -340,8 +341,8 @@ class CoursesController < ApplicationController @has_graduation_design = @course.course_modules.graduation_module_not_hidden.any? - sort = params[:sort] || "desc" - @order = params[:order].to_i + sort = params[:sort] || "asc" + @order = params[:order] ? params[:order].to_i : 1 if @order.present? case @order when 1 @@ -547,6 +548,61 @@ class CoursesController < ApplicationController end end + # 修改角色 + def change_member_role + tip_exception("请至少选择一个角色") if params[:roles].blank? + tip_exception("不能具有老师、助教两种角色") if params[:roles].include?("PROFESSOR") && params[:roles].include?("ASSISTANT_PROFESSOR") + tip_exception("管理员不能切换为助教或老师") if @user_course_identity == Course::CREATOR && + (params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR")) + + course_members = @course.course_members.where(user_id: params[:user_id]) + tip_exception("非课堂成员不能修改角色") if course_members.blank? + + ActiveRecord::Base.transaction do + # 第一次修改为教师或助教身份时直接创建数据 + if params[:roles].include?("CREATOR") + teacher_member = course_members.where(role: %i[CREATOR]).take + elsif (params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR")) && !course_members.exists?(role: %i[PROFESSOR ASSISTANT_PROFESSOR]) + teacher_member = CourseMember.create!(course_id: @course.id, user_id: params[:user_id], role: params[:roles].include?("PROFESSOR") ? 2 : 3) + elsif course_members.exists?(role: %i[PROFESSOR ASSISTANT_PROFESSOR]) + teacher_member = course_members.where(role: %i[PROFESSOR ASSISTANT_PROFESSOR]).take + if params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR") + # 如果之前有老师身份且老师身份要调整时,只需要修改role字段 + if !params[:roles].include?(teacher_member.role) && params[:roles].include?("PROFESSOR") + teacher_member.PROFESSOR! + elsif !params[:roles].include?(teacher_member.role) && params[:roles].include?("ASSISTANT_PROFESSOR") + teacher_member.ASSISTANT_PROFESSOR! + end + teacher_member.save! + else + # 不含教师的参数时删除记录 + teacher_member.destroy! + # CourseDeleteStudentNotifyJob.perform_later(@course.id, [teacher_member.user_id], current_user.id) + end + end + + # 学生身份的处理 + student_member = course_members.where(role: %i[STUDENT]).take + if params[:roles].include?("STUDENT") && student_member.blank? + correspond_teacher_exist = CourseMember.exists?(user_id: params[:user_id], is_active: 1, course_id: @course.id, role: %i[CREATOR PROFESSOR ASSISTANT_PROFESSOR]) + new_student = CourseMember.new(user_id: params[:user_id], course_id: @course.id, role: 4) + new_student.is_active = 0 if correspond_teacher_exist + new_student.save! + + CourseAddStudentCreateWorksJob.perform_later(@course.id, [params[:user_id]]) + # StudentJoinCourseNotifyJob.perform_later(current_user.id, course.id) + elsif !params[:roles].include?("STUDENT") && student_member.present? + # 删除学生身份时激活老师身份 + teacher_member.update_attributes!(is_active: 1) if student_member.is_active && teacher_member.present? + student_member.destroy! + CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, [params[:user_id]]) + # CourseDeleteStudentNotifyJob.perform_later(@course.id, [params[:user_id]], current_user.id) + end + + normal_status(0, "修改成功") + end + end + # 教师和助教角色转换的接口 def change_course_teacher begin @@ -715,8 +771,8 @@ class CoursesController < ApplicationController # 学生列表(包括各个子分班的学生列表)及搜索 def students search = params[:search].present? ? params[:search].strip : nil - order = params[:order].present? ? params[:order].to_i : 0 - sort = params[:sort].present? ? params[:sort] : "desc" + order = params[:order].present? ? params[:order].to_i : 1 + sort = params[:sort].present? ? params[:sort] : "asc" course_group_id = params[:course_group_id].present? ? params[:course_group_id].to_i : nil @students = CourseMember.students(@course) diff --git a/app/libs/util.rb b/app/libs/util.rb index ae2e4b80b..72e728ab9 100644 --- a/app/libs/util.rb +++ b/app/libs/util.rb @@ -48,8 +48,8 @@ module Util return if str.blank? case type - when :phone then "#{str[0..2]}***#{str[-4..-1]}" - when :email then "#{str[0..2]}***#{str[str.rindex('@')..-1]}" + when :phone then "#{str[0..2]}***#{str[-3..-1]}" + when :email then "#{str[0]}***#{str[(str.rindex('@')-1)..-1]}" else "#{str[0..2]}***#{str[-3..-1]}" end end diff --git a/app/models/user.rb b/app/models/user.rb index 5fdb1a713..7bfe9c36f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -242,6 +242,11 @@ class User < ApplicationRecord user_extension&.department&.name || '' end + # 课堂的所有身份 + def course_role course + course.course_members.where(user_id: id).pluck(:role) + end + # 课堂的老师(创建者、老师、助教) def teacher_of_course?(course) course.course_members.exists?(user_id: id, role: [1,2,3], is_active: 1) || admin? || business? @@ -583,6 +588,16 @@ class User < ApplicationRecord mail.present? end + # 手机号:123***123 + def hidden_phone + Util.conceal(phone, :phone).to_s + end + + # 邮箱:w***l@qq.com + def hidden_mail + Util.conceal(mail, :email).to_s + end + # 学院的url标识 def college_identifier Department.find_by_id(department_members.pluck(:department_id).first)&.identifier diff --git a/app/views/courses/students.json.jbuilder b/app/views/courses/students.json.jbuilder index a7585672f..016efa711 100644 --- a/app/views/courses/students.json.jbuilder +++ b/app/views/courses/students.json.jbuilder @@ -1,12 +1,17 @@ json.students do json.array! @students do |student| json.user_id student.user_id - json.login student.user.try(:login) + # json.login student.user.try(:login) json.name student.user.try(:real_name) json.name_link user_path(student.user) json.student_id student.user.try(:student_id) json.course_group_name student.course_group.try(:name) json.course_member_id student.id + if @user_course_identity < Course::ASSISTANT_PROFESSOR + json.member_roles student.user.course_role(@course) + end + json.user_phone student.user.hidden_phone + json.user_mail student.user.hidden_mail end end json.students_count @students_count diff --git a/app/views/courses/teachers.json.jbuilder b/app/views/courses/teachers.json.jbuilder index 040ffb2aa..19a92790d 100644 --- a/app/views/courses/teachers.json.jbuilder +++ b/app/views/courses/teachers.json.jbuilder @@ -16,6 +16,9 @@ json.teacher_list do end json.graduation_group teacher.graduation_group.try(:name) json.graduation_group_id teacher.graduation_group.try(:id) + if @user_course_identity < Course::ASSISTANT_PROFESSOR + json.member_roles teacher.user.course_role(@course) + end end end json.teacher_list_size @teacher_list_size diff --git a/app/views/users/accounts/show.json.jbuilder b/app/views/users/accounts/show.json.jbuilder index 6b28bda55..ec81cc6bf 100644 --- a/app/views/users/accounts/show.json.jbuilder +++ b/app/views/users/accounts/show.json.jbuilder @@ -1,5 +1,7 @@ -json.extract! observed_user, :id, :nickname, :phone, :mail, :show_realname +json.extract! observed_user, :id, :nickname, :show_realname +json.phone observed_user.hidden_phone +json.mail observed_user.hidden_mail json.avatar_url url_to_avatar(observed_user) user = ActiveDecorator::Decorator.instance.decorate(observed_user) json.name user.name diff --git a/config/routes.rb b/config/routes.rb index 2c02c6a79..503210a91 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -331,6 +331,7 @@ Rails.application.routes.draw do post 'join_graduation_group' post 'set_course_group' post 'change_course_admin' + post 'change_member_role' post 'change_course_teacher' post 'delete_course_teacher' post 'teacher_application_review' From 22993dfb7c22d68935404bb88049feed5a38144d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 10 Oct 2019 17:01:02 +0800 Subject: [PATCH 02/18] =?UTF-8?q?=E5=88=86=E7=8F=AD=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 26 ++++++++++++++++--- app/helpers/courses_helper.rb | 14 +++++++++- app/views/courses/course_groups.json.jbuilder | 11 ++++++++ app/views/courses/students.json.jbuilder | 2 +- config/routes.rb | 2 ++ 5 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 app/views/courses/course_groups.json.jbuilder diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index d639662c2..a3b20c598 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -12,10 +12,10 @@ class CoursesController < ApplicationController end before_action :require_login, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups, - :left_banner, :top_banner, :informs, :online_learning] + :left_banner, :top_banner, :informs, :online_learning, :course_groups] before_action :check_account, only: [:new, :create, :apply_to_join_course, :join_excellent_course] before_action :check_auth, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups, - :left_banner, :top_banner, :apply_to_join_course, :exit_course] + :left_banner, :top_banner, :apply_to_join_course, :exit_course, :course_groups] before_action :set_course, only: [:show, :update, :destroy, :settings, :set_invite_code_halt, :set_public_or_private, :search_teacher_candidate, :teachers, :apply_teachers, :top_banner, :left_banner, :add_teacher_popup, :add_teacher, @@ -28,7 +28,7 @@ class CoursesController < ApplicationController :switch_to_teacher, :switch_to_assistant, :switch_to_student, :exit_course, :informs, :update_informs, :online_learning, :update_task_position, :tasks_list, :join_excellent_course, :export_couser_info, :export_member_act_score, :new_informs, - :delete_informs, :change_member_role] + :delete_informs, :change_member_role, :course_groups, :join_course_group] before_action :user_course_identity, except: [:join_excellent_course, :index, :create, :new, :apply_to_join_course, :search_course_list, :get_historical_course_students, :mine, :search_slim, :board_list] before_action :teacher_allowed, only: [:update, :destroy, :settings, :search_teacher_candidate, @@ -822,6 +822,26 @@ class CoursesController < ApplicationController end end + # 分班列表 + def course_groups + @course_groups = @course.course_groups + @course_groups = @course_groups.where("name like ?", "%#{params[:search]}%") unless params[:search].blank? + @all_group_count = @course_groups.size + @teachers = @course.teachers.includes(:user, :teacher_course_groups) if @user_course_identity < Course::NORMAL + @current_group_id = @course.students.where(user_id: current_user.id).take&.course_group_id if @user_course_identity == Course::STUDENT + end + + # 学生自动加入分班 + def join_course_group + tip_exception("学生才能加入分班") if @user_course_identity != Course::STUDENT + course_group = CourseGroup.find_by!(id: params[:course_group_id], course_id: @course.id) + member = CourseMember.find_by!(user_id: current_user.id, course_id: @course.id, role: 4) + if course_group && member + member.update_attributes!(course_group_id: course_group.id) + normal_status(0, "加入成功") + end + end + # 将学生批量移动到某个分班 def transfer_to_course_group ActiveRecord::Base.transaction do diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index d670614d5..fb7bd1a88 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -1,6 +1,18 @@ module CoursesHelper - # 是否有切换为学生的入口 + def member_manager group, teachers + str = "" + members = teachers.select{|teacher| teacher.teacher_course_groups.pluck(:course_group_id).include?(group.id) || teacher.teacher_course_groups.size == 0} + str = members.uniq.size == teachers.size ? "全部教师" : members.map{|member| member.user.real_name}.join("、") + str + # teachers.each do |member| + # if member.teacher_course_groups.exists?(course_group_id: group.id) || member.teacher_course_groups.size == 0 + # str << member.user.real_name + # end + # end + end + + # 是否有切换为学生的入口 def switch_student_role is_teacher, course, user is_teacher && course.course_members.where(user_id: user.id, role: %i(STUDENT)).exists? end diff --git a/app/views/courses/course_groups.json.jbuilder b/app/views/courses/course_groups.json.jbuilder new file mode 100644 index 000000000..48a5922a6 --- /dev/null +++ b/app/views/courses/course_groups.json.jbuilder @@ -0,0 +1,11 @@ +json.course_groups @course_groups.each do |group| + json.(group, :id, :course_members_count, :name) + json.invite_code group.invite_code if @user_course_identity < Course::STUDENT + json.member_manager member_manager(group, @teachers) if @user_course_identity < Course::NORMAL +end + +if @user_course_identity == Course::STUDENT + json.current_group_id @current_group_id +end +json.none_group_member_count @course.none_group_count +json.group_count @all_group_count \ No newline at end of file diff --git a/app/views/courses/students.json.jbuilder b/app/views/courses/students.json.jbuilder index 016efa711..0b5d7fe71 100644 --- a/app/views/courses/students.json.jbuilder +++ b/app/views/courses/students.json.jbuilder @@ -7,7 +7,7 @@ json.students do json.student_id student.user.try(:student_id) json.course_group_name student.course_group.try(:name) json.course_member_id student.id - if @user_course_identity < Course::ASSISTANT_PROFESSOR + if @user_course_identity < Course::ASSISTANT_PROFESSOR && !params[:course_group_id].present? json.member_roles student.user.course_role(@course) end json.user_phone student.user.hidden_phone diff --git a/config/routes.rb b/config/routes.rb index 503210a91..a3c2078f3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -370,6 +370,8 @@ Rails.application.routes.draw do post 'join_excellent_course' get 'tasks_list' post 'update_task_position' + get 'course_groups' + post 'join_course_group' end collection do From 8191926264022d362aa757d4c5522a3b21873d75 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 11 Oct 2019 14:11:03 +0800 Subject: [PATCH 03/18] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E3=80=81=E9=97=AE?= =?UTF-8?q?=E5=8D=B7=E7=9A=84=E7=AB=8B=E5=8D=B3=E5=8F=91=E5=B8=83=E5=BC=B9?= =?UTF-8?q?=E6=A1=86=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../homework_commons_controller.rb | 53 +++++++++++++++---- app/controllers/polls_controller.rb | 48 ++++++++++++----- .../publish_groups.json.jbuilder | 4 +- app/views/polls/publish_groups.json.jbuilder | 6 +++ config/routes.rb | 1 + 5 files changed, 88 insertions(+), 24 deletions(-) create mode 100644 app/views/polls/publish_groups.json.jbuilder diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 0ed5730a4..70f0345b1 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -1036,6 +1036,7 @@ class HomeworkCommonsController < ApplicationController # 可立即发布的分班:当前用户管理的分班去除已发布的分班 group_ids = @course.charge_group_ids(@current_user) - @homework.homework_group_settings.group_published.pluck(:course_group_id) @course_groups = @course.course_groups.where(id: group_ids) + @group_settings = @homework.homework_group_settings.where(id: group_ids) else tip_exception("没有可发布的分班") end @@ -1043,16 +1044,28 @@ class HomeworkCommonsController < ApplicationController def publish_homework tip_exception("请至少选择一个分班") if params[:group_ids].blank? && @course.course_groups.size != 0 - tip_exception("缺少截止时间参数") if params[:end_time].blank? - tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now) - tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if - @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day) + if params[:detail].blank? + tip_exception("缺少截止时间参数") if params[:end_time].blank? + tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now) + tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if + @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day) + else + group_end_times = params[:group_end_times].reject(&:blank?).map{|time| time.to_time} + group_ids = params[:group_ids].reject(&:blank?) + tip_exception("缺少截止时间参数") if group_end_times.blank? + tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length + group_end_times.each do |time| + tip_exception("分班截止时间不能早于当前时间") if time <= Time.now + tip_exception("分班截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if + @course.end_date.present? && time > @course.end_date.end_of_day + end + end homeworks = @course.homework_commons.where(id: params[:homework_ids]) homeworks = homeworks.includes(:homework_group_settings, :homework_detail_manual) charge_group_ids = @course.charge_group_ids(current_user) - publish_groups = charge_group_ids & params[:group_ids] if params[:group_ids] + publish_groups = charge_group_ids & group_ids if group_ids # ActiveRecord::Base.transaction do begin @@ -1062,18 +1075,26 @@ class HomeworkCommonsController < ApplicationController if !params[:group_ids].blank? # 全选即统一设置,unified_setting为true - if @course.course_groups.where(id: publish_groups).size == @course.course_groups.size + if @course.course_groups.where(id: publish_groups).size == @course.course_groups.size && + ((params[:detail] && group_end_times.min == group_end_times.max) || params[:detail].blank?) homework.homework_group_settings.destroy_all homework.unified_setting = true - homework.end_time = params[:end_time] + homework.end_time = params[:detail] ? group_end_times.max : params[:end_time] else homework.unified_setting = false # 创建作业分班设置:homework_group_setting create_homework_group_settings(homework) # 选中的分班设置的发布时间改为当前时间,截止时间改为传的截止时间参数 - homework.homework_group_settings.where(course_group_id: publish_groups).update_all(publish_time: Time.now, - end_time: params[:end_time]) + if params[:detail] + group_ids.each_with_index do |group_id, index| + homework.homework_group_settings.find_by(course_group_id: group_id)&.update_attributes!(publish_time: Time.now, + end_time: group_end_times[index]) + end + else + homework.homework_group_settings.where(course_group_id: publish_groups).update_all(publish_time: Time.now, + end_time: params[:end_time]) + end # 发消息 tiding_group_ids = publish_groups end @@ -1086,7 +1107,7 @@ class HomeworkCommonsController < ApplicationController # 截止时间的处理 if homework.end_time.nil? - homework.end_time = params[:end_time] + homework.end_time = params[:detail] ? group_end_times.max : params[:end_time] elsif homework.max_group_end_time homework.end_time = homework.max_group_end_time end @@ -1101,12 +1122,22 @@ class HomeworkCommonsController < ApplicationController create_homework_group_settings(homework) none_publish_settings = homework.homework_group_settings.where(course_group_id: publish_groups).none_published - none_publish_settings.update_all(publish_time: Time.now, end_time: params[:end_time]) + if params[:detail] + group_ids.each_with_index do |group_id, index| + none_publish_settings.find_by(course_group_id: group_id)&.update_attributes!(publish_time: Time.now, + end_time: group_end_times[index]) + end + else + none_publish_settings.update_all(publish_time: Time.now, end_time: params[:end_time]) + end + if homework.max_group_end_time homework.end_time = homework.max_group_end_time end HomeworkCommonPushNotifyJob.perform_later(homework.id, none_publish_settings.pluck(:course_group_id)) end + + if homework.end_time > Time.now && homework.homework_detail_manual.try(:comment_status) > 1 homework.homework_detail_manual.update_attribute("comment_status", 1) end diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index dcbded6fe..a8e081cb2 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -2,10 +2,10 @@ class PollsController < ApplicationController # before_action :check_poll_status 问卷的发消息和定时任务没有做 before_action :require_login, :check_auth,except: [:index] before_action :find_course, except: [:show,:poll_setting,:commit_setting,:edit,:update,:start_answer,:commit_poll, - :commit_result,:poll_lists,:cancel_publish,:cancel_publish_modal,:common_header] + :commit_result,:poll_lists,:cancel_publish,:cancel_publish_modal,:common_header,:publish_groups] before_action :get_poll_and_course, only: [:show,:poll_setting,:commit_setting,:edit,:update,:start_answer, :commit_poll,:commit_result,:poll_lists,:cancel_publish, - :cancel_publish_modal,:common_header] + :cancel_publish_modal,:common_header, :publish_groups] before_action :user_course_identity before_action :is_course_teacher, except: [:index,:start_answer,:poll_setting,:commit_poll,:commit_result,:poll_lists,:common_header] #判断是否为课堂老师 before_action :check_user_status @@ -242,12 +242,35 @@ class PollsController < ApplicationController end end end + + # 详情页的立即发布弹框 + def publish_groups + @current_user = current_user + # 可立即发布的分班:当前用户管理的分班去除已发布的分班 + group_ids = @course.charge_group_ids(@current_user) - @poll.poll_group_settings.poll_group_published.pluck(:course_group_id) + @course_groups = @course.course_groups.where(id: group_ids) + @group_settings = @poll.poll_group_settings.where(id: group_ids) + end + #首页批量或单独 立即发布,应是跳出弹窗,设置开始时间和截止时间。 def publish - tip_exception("缺少截止时间参数") if params[:end_time].blank? - tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now) - tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if - @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day) + if params[:detail].blank? + tip_exception("缺少截止时间参数") if params[:end_time].blank? + tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now) + tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if + @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day) + else + group_end_times = params[:group_end_times].reject(&:blank?).map{|time| time.to_time} + group_ids = params[:group_ids].reject(&:blank?) + tip_exception("缺少截止时间参数") if group_end_times.blank? + tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length + group_end_times.each do |time| + tip_exception("分班截止时间不能早于当前时间") if time <= Time.now + tip_exception("分班截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if + @course.end_date.present? && time > @course.end_date.end_of_day + end + end + ActiveRecord::Base.transaction do begin check_ids = Poll.where(id: params[:check_ids]) @@ -259,26 +282,27 @@ class PollsController < ApplicationController pl_status = poll.poll_group_settings.find_in_poll_group("course_group_id",params[:group_ids]).poll_group_not_published.present? ? 1 : 0 #立即发布针对分组设置的全部未发布的班级才生效 end if pl_status == 1 #如果问卷存在已发布的,或者是已截止的,那么则直接跳过 - g_course = params[:group_ids] #表示是否传入分班参数,如果传入分班的参数,那么poll的统一设置需修改 + g_course = group_ids #表示是否传入分班参数,如果传入分班的参数,那么poll的统一设置需修改 if g_course - user_course_groups = @course.charge_group_ids(current_user) - if g_course.map(&:to_i).sort == user_course_groups.sort # 如果是设置为全部班级,则问卷不用分组,且问卷设定为统一设置,否则则分组设置 + user_course_groups = @course.course_groups.pluck(:id) + if g_course.map(&:to_i).sort == user_course_groups.sort && + ((params[:detail] && group_end_times.min == group_end_times.max) || params[:detail].blank?) # 如果是设置为全部班级,则问卷不用分组,且问卷设定为统一设置,否则则分组设置 poll.poll_group_settings.destroy_all poll_unified = true e_time = ex_end_time else poll_unified = false - g_course.each do |i| + g_course.each_with_index do |i, index| poll_group_setting = poll.poll_group_settings.find_in_poll_group("course_group_id",i).first #根据课堂分班的id,寻找问卷所在的班级 if poll_group_setting #如果该问卷分组存在,则更新,否则新建 - poll_group_setting.update_attributes(publish_time:Time.now,end_time:ex_end_time) + poll_group_setting.update_attributes(publish_time:Time.now, end_time: params[:detail] ? group_end_times[index] : ex_end_time) else p_course_group = { :poll_id => poll.id, :course_group_id => i, :course_id => poll.course.id, :publish_time => Time.now, - :end_time => ex_end_time, + :end_time => params[:detail] ? group_end_times[index] : ex_end_time, } new_poll_group = poll.poll_group_settings.new p_course_group new_poll_group.save diff --git a/app/views/homework_commons/publish_groups.json.jbuilder b/app/views/homework_commons/publish_groups.json.jbuilder index 67722bb04..f3a99dbca 100644 --- a/app/views/homework_commons/publish_groups.json.jbuilder +++ b/app/views/homework_commons/publish_groups.json.jbuilder @@ -1,4 +1,6 @@ json.course_groups @course_groups do |group| json.id group.id json.name group.name -end \ No newline at end of file + json.end_time @group_settings.select{|group_setting| group_setting.course_group_id == group.id}.first&.end_time +end +json.end_time @homework.end_time \ No newline at end of file diff --git a/app/views/polls/publish_groups.json.jbuilder b/app/views/polls/publish_groups.json.jbuilder new file mode 100644 index 000000000..f63a2ea90 --- /dev/null +++ b/app/views/polls/publish_groups.json.jbuilder @@ -0,0 +1,6 @@ +json.course_groups @course_groups do |group| + json.id group.id + json.name group.name + json.end_time @group_settings.select{|group_setting| group_setting.course_group_id == group.id}.first&.end_time +end +json.end_time @poll.end_time \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 847afaa83..1fd31c50c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -584,6 +584,7 @@ Rails.application.routes.draw do post :cancel_publish #撤销发布 get :cancel_publish_modal #撤销发布的弹窗 get :common_header + get :publish_groups end resources :poll_questions,only:[:new,:create] end From 6b0f8d1a9e2f6e4b1dacd89725273c4eda0e277e Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 11 Oct 2019 14:31:53 +0800 Subject: [PATCH 04/18] stu --- public/react/src/modules/courses/members/studentsList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/members/studentsList.js b/public/react/src/modules/courses/members/studentsList.js index 2d26cff91..e3859345a 100644 --- a/public/react/src/modules/courses/members/studentsList.js +++ b/public/react/src/modules/courses/members/studentsList.js @@ -814,7 +814,7 @@ class studentsList extends Component{
- {!this.state.isSpin && + {students && students.length &&
}
From c180267b807bef2e02a5853c1f17c1edd223a463 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 11 Oct 2019 14:32:04 +0800 Subject: [PATCH 05/18] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E7=AB=8B?= =?UTF-8?q?=E5=8D=B3=E5=8F=91=E5=B8=83=E5=BC=B9=E6=A1=86=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 46 ++++++++++++++----- app/controllers/polls_controller.rb | 7 +-- .../exercises/publish_groups.json.jbuilder | 6 +++ config/routes.rb | 1 + 4 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 app/views/exercises/publish_groups.json.jbuilder diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 30fef596d..a51f65c6b 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -683,12 +683,34 @@ class ExercisesController < ApplicationController end end + # 详情页的立即发布弹框 + def publish_groups + @current_user = current_user + # 可立即发布的分班:当前用户管理的分班去除已发布的分班 + group_ids = @course.charge_group_ids(@current_user) - @exercise.exercise_group_settings.exercise_group_published.pluck(:course_group_id) + @course_groups = @course.course_groups.where(id: group_ids) + @group_settings = @exercise.exercise_group_settings.where(id: group_ids) + end + #首页批量或单独 立即发布,应是跳出弹窗,设置开始时间和截止时间。 def publish - tip_exception("缺少截止时间参数") if params[:end_time].blank? - tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now) - tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if - @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day) + if params[:detail].blank? + tip_exception("缺少截止时间参数") if params[:end_time].blank? + tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now) + tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if + @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day) + else + group_end_times = params[:group_end_times].reject(&:blank?).map{|time| time.to_time} + group_ids = params[:group_ids].reject(&:blank?) + tip_exception("缺少截止时间参数") if group_end_times.blank? + tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length + group_end_times.each do |time| + tip_exception("分班截止时间不能早于当前时间") if time <= Time.now + tip_exception("分班截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if + @course.end_date.present? && time > @course.end_date.end_of_day + end + end + ActiveRecord::Base.transaction do begin check_ids = Exercise.where(id: params[:check_ids]) @@ -702,28 +724,30 @@ class ExercisesController < ApplicationController .exercise_group_not_published.present? ? 1 : 0 end if ex_status == 1 #如果试卷存在已发布的,或者是已截止的,那么则直接跳过 - g_course = params[:group_ids] #表示是否传入分班参数,如果传入分班的参数,那么试卷的统一设置需修改 + g_course = group_ids #表示是否传入分班参数,如果传入分班的参数,那么试卷的统一设置需修改 tiding_group_ids = g_course if g_course - user_course_groups = @course.charge_group_ids(current_user) - if g_course.map(&:to_i).sort == user_course_groups.sort # 如果是设置为全部班级,则试卷不用分组,且试卷设定为统一设置,否则则分组设置 + user_course_groups = @course.course_groups.pluck(:id) + if g_course.map(&:to_i).sort == user_course_groups.sort && + ((params[:detail] && group_end_times.min == group_end_times.max) || params[:detail].blank?) # 如果是设置为全部班级,则试卷不用分组,且试卷设定为统一设置,否则则分组设置 exercise.exercise_group_settings.destroy_all ex_unified = true - e_time = ex_end_time + e_time = params[:detail] ? group_end_times.max : ex_end_time tiding_group_ids = [] else ex_unified = false - g_course.each do |i| + g_course.each_with_index do |i, index| exercise_group_setting = exercise.exercise_group_settings.find_in_exercise_group("course_group_id",i).first #根据课堂分班的id,寻找试卷所在的班级 + group_end_time = params[:detail] ? group_end_times[index] : ex_end_time if exercise_group_setting #如果该试卷分组存在,则更新,否则新建 - exercise_group_setting.update_attributes(publish_time:Time.now,end_time:ex_end_time) + exercise_group_setting.update_attributes(publish_time: Time.now, end_time: group_end_time) else p_course_group = { :exercise_id => exercise.id, :course_group_id => i, :course_id => exercise.course.id, :publish_time => Time.now, - :end_time => ex_end_time, + :end_time => group_end_time, } new_exercise_group = exercise.exercise_group_settings.new p_course_group new_exercise_group.save diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index a8e081cb2..6b9fd004c 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -289,20 +289,21 @@ class PollsController < ApplicationController ((params[:detail] && group_end_times.min == group_end_times.max) || params[:detail].blank?) # 如果是设置为全部班级,则问卷不用分组,且问卷设定为统一设置,否则则分组设置 poll.poll_group_settings.destroy_all poll_unified = true - e_time = ex_end_time + e_time = params[:detail] ? group_end_times.max : ex_end_time else poll_unified = false g_course.each_with_index do |i, index| poll_group_setting = poll.poll_group_settings.find_in_poll_group("course_group_id",i).first #根据课堂分班的id,寻找问卷所在的班级 + group_end_time = params[:detail] ? group_end_times[index] : ex_end_time if poll_group_setting #如果该问卷分组存在,则更新,否则新建 - poll_group_setting.update_attributes(publish_time:Time.now, end_time: params[:detail] ? group_end_times[index] : ex_end_time) + poll_group_setting.update_attributes(publish_time: Time.now, end_time: group_end_time) else p_course_group = { :poll_id => poll.id, :course_group_id => i, :course_id => poll.course.id, :publish_time => Time.now, - :end_time => params[:detail] ? group_end_times[index] : ex_end_time, + :end_time => group_end_time, } new_poll_group = poll.poll_group_settings.new p_course_group new_poll_group.save diff --git a/app/views/exercises/publish_groups.json.jbuilder b/app/views/exercises/publish_groups.json.jbuilder new file mode 100644 index 000000000..72cefdd1a --- /dev/null +++ b/app/views/exercises/publish_groups.json.jbuilder @@ -0,0 +1,6 @@ +json.course_groups @course_groups do |group| + json.id group.id + json.name group.name + json.end_time @group_settings.select{|group_setting| group_setting.course_group_id == group.id}.first&.end_time +end +json.end_time @exercise.end_time \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 1fd31c50c..b94d1ca9a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -616,6 +616,7 @@ Rails.application.routes.draw do get :exercise_result post :cancel_exercise get :begin_commit #提交前的弹窗 + get :publish_groups end resources :exercise_questions,only:[:new,:create,:index] end From 2435342ae91136272a5927cec143609c6fd6a0fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 11 Oct 2019 14:34:25 +0800 Subject: [PATCH 06/18] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/shixunHomework/ShixunhomeWorkItem.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js b/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js index 8b63a3471..be138996f 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js @@ -354,8 +354,8 @@ class ShixunhomeWorkItem extends Component{ {/* {discussMessage.author.name} */} { discussMessage.author && {discussMessage.author} } - {discussMessage.commit_count===undefined?"":{discussMessage.commit_count} 已开始做题} - {discussMessage.uncommit_count===undefined?"":{discussMessage.uncommit_count} 未开始做题} + {discussMessage.commit_count===undefined?"":已开始做题:{discussMessage.commit_count}} + {discussMessage.uncommit_count===undefined?"":未开始做题:{discussMessage.uncommit_count}} {/*{discussMessage.replies_count} 3 未评*/} { @@ -381,7 +381,7 @@ class ShixunhomeWorkItem extends Component{ { discussMessage && discussMessage.upper_category_name && 22 }> - { {discussMessage.upper_category_name}} + { {discussMessage.upper_category_name}} } From 938b974d772cb299084a48d7ced8f7446d1d9d22 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 11 Oct 2019 14:34:57 +0800 Subject: [PATCH 07/18] check commit_method --- app/controllers/exercises_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index e76148f20..f74eefabf 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1078,6 +1078,7 @@ class ExercisesController < ApplicationController ActiveRecord::Base.transaction do begin can_commit_exercise = false + Rails.logger.info("######____________params[:commit_method]_________################{params[:commit_method]}") if (@user_course_identity > Course::ASSISTANT_PROFESSOR) && params[:commit_method].present? #为学生时 if params[:commit_method].to_i == 2 #自动提交时 user_left_time = get_exercise_left_time(@exercise,current_user) From 369bbac497959b52fcc83168ccf56e6d3d82529d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 11 Oct 2019 14:40:32 +0800 Subject: [PATCH 08/18] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 2 +- app/controllers/homework_commons_controller.rb | 2 +- app/controllers/polls_controller.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index ac18754cd..3835baf55 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -689,7 +689,7 @@ class ExercisesController < ApplicationController # 可立即发布的分班:当前用户管理的分班去除已发布的分班 group_ids = @course.charge_group_ids(@current_user) - @exercise.exercise_group_settings.exercise_group_published.pluck(:course_group_id) @course_groups = @course.course_groups.where(id: group_ids) - @group_settings = @exercise.exercise_group_settings.where(id: group_ids) + @group_settings = @exercise.exercise_group_settings.where(course_group_id: group_ids) end #首页批量或单独 立即发布,应是跳出弹窗,设置开始时间和截止时间。 diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 70f0345b1..9941e1d42 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -1036,7 +1036,7 @@ class HomeworkCommonsController < ApplicationController # 可立即发布的分班:当前用户管理的分班去除已发布的分班 group_ids = @course.charge_group_ids(@current_user) - @homework.homework_group_settings.group_published.pluck(:course_group_id) @course_groups = @course.course_groups.where(id: group_ids) - @group_settings = @homework.homework_group_settings.where(id: group_ids) + @group_settings = @homework.homework_group_settings.where(course_group_id: group_ids) else tip_exception("没有可发布的分班") end diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 6b9fd004c..2259907e4 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -249,7 +249,7 @@ class PollsController < ApplicationController # 可立即发布的分班:当前用户管理的分班去除已发布的分班 group_ids = @course.charge_group_ids(@current_user) - @poll.poll_group_settings.poll_group_published.pluck(:course_group_id) @course_groups = @course.course_groups.where(id: group_ids) - @group_settings = @poll.poll_group_settings.where(id: group_ids) + @group_settings = @poll.poll_group_settings.where(course_group_id: group_ids) end #首页批量或单独 立即发布,应是跳出弹窗,设置开始时间和截止时间。 From ef56ceb092633add234a03a4d2b4288a42531207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 11 Oct 2019 14:40:44 +0800 Subject: [PATCH 09/18] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/shixunHomework/ShixunhomeWorkItem.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js b/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js index be138996f..7aa1d44de 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js @@ -354,8 +354,8 @@ class ShixunhomeWorkItem extends Component{ {/* {discussMessage.author.name} */} { discussMessage.author && {discussMessage.author} } - {discussMessage.commit_count===undefined?"":已开始做题:{discussMessage.commit_count}} - {discussMessage.uncommit_count===undefined?"":未开始做题:{discussMessage.uncommit_count}} + {discussMessage.commit_count===undefined?"":已开始做题 {discussMessage.commit_count}} + {discussMessage.uncommit_count===undefined?"":未开始做题 {discussMessage.uncommit_count}} {/*{discussMessage.replies_count} 3 未评*/} { @@ -381,7 +381,7 @@ class ShixunhomeWorkItem extends Component{ { discussMessage && discussMessage.upper_category_name && 22 }> - { {discussMessage.upper_category_name}} + { {discussMessage.upper_category_name}} } From 83b58843192d406ec5a2882c6de84a2a6e1ba2c2 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 11 Oct 2019 14:43:30 +0800 Subject: [PATCH 10/18] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=AD=94=E9=A2=98?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercises/common_header.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/exercises/common_header.json.jbuilder b/app/views/exercises/common_header.json.jbuilder index 5d33aca66..d43d7c3f8 100644 --- a/app/views/exercises/common_header.json.jbuilder +++ b/app/views/exercises/common_header.json.jbuilder @@ -1,6 +1,6 @@ json.course_is_end @course.is_end # true表示已结束,false表示未结束 json.extract! @exercise, :id,:exercise_name,:exercise_description,:show_statistic -json.time @user_left_time +json.time (@user_left_time.to_i / 60) json.exercise_status @ex_status From 36c774689307e1f7de5ffbb95bc308a40f9ac632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 11 Oct 2019 15:04:41 +0800 Subject: [PATCH 11/18] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/AppConfig.js | 4 +-- .../exercise/ExerciseReviewAndAnswer.js | 32 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index e1d5da561..c00c5fb62 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -84,9 +84,9 @@ export function initAxiosInterceptors(props) { } config.url = `${proxy}${url}`; if (config.url.indexOf('?') == -1) { - config.url = `${config.url}?debug=${debugType}`; + config.url = `${config.url}?debug=${'student'}`; } else { - config.url = `${config.url}&debug=${debugType}`; + config.url = `${config.url}&debug=${'student'}`; } } else { // 加api前缀 diff --git a/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js b/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js index 59072a862..a9143176c 100644 --- a/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js +++ b/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js @@ -127,25 +127,25 @@ class ExerciseReviewAndAnswer extends Component{ } //自动交卷 autoCommitExercise=()=>{ - let eId=this.props.match.params.Id; - let url=`/exercises/${eId}/commit_exercise.json`; - axios.post(url,{ + let eId=this.props.match.params.Id; + let url=`/exercises/${eId}/commit_exercise.json`; + axios.post(url,{ commit_method:2 }).then((result)=>{ - if(result){ - this.setState({ - Modalstype:true, - Modalstopval:'答题结束了,系统已自动提交试卷', - modalsBottomval:"不能再修改答题", - ModalCancel:undefined, - ModalSave:this.sureCommit, - Loadtype:true - }) + if(result){ + this.setState({ + Modalstype:true, + Modalstopval:'答题结束了,系统已自动提交试卷', + modalsBottomval:"不能再修改答题", + ModalCancel:undefined, + ModalSave:this.sureCommit, + Loadtype:true + }) this.props.showNotification(`${result.data.message}`); - } - }).catch((error)=>{ - console.log(error); - }) + } + }).catch((error)=>{ + console.log(error); + }) } sureCommit=()=>{ From e1bea29dcbf25bfc2ec643fe454ba50596c25de0 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 11 Oct 2019 15:15:07 +0800 Subject: [PATCH 12/18] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AF=95=E5=8D=B7?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=8F=90=E4=BA=A4=E7=9A=84=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index bc0da8ffc..ed09b8784 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1102,10 +1102,10 @@ class ExercisesController < ApplicationController ActiveRecord::Base.transaction do begin can_commit_exercise = false - Rails.logger.info("######____________params[:commit_method]_________################{params[:commit_method]}") - if (@user_course_identity > Course::ASSISTANT_PROFESSOR) && params[:commit_method].present? #为学生时 + if @user_course_identity > Course::ASSISTANT_PROFESSOR #为学生时 if params[:commit_method].to_i == 2 #自动提交时 user_left_time = get_exercise_left_time(@exercise,current_user) + Rails.logger.info("######__________auto_commit_user_left_time_________################{user_left_time}") if user_left_time.to_i <= 0 can_commit_exercise = true end @@ -1130,10 +1130,10 @@ class ExercisesController < ApplicationController CommitExercsieNotifyJobJob.perform_later(@exercise.id, current_user.id) normal_status(0,"试卷提交成功!") else - normal_status(-1,"提交失败,请重试!") + normal_status(-1,"提交失败,未到截止时间!") end else - normal_status(-1,"提交失败,请重试!") + normal_status(-1,"提交失败,当前用户不为课堂学生!") end rescue Exception => e uid_logger_error(e.message) From b8cc352c525604904c6749710c4f4b11aa80ce70 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 11 Oct 2019 15:20:25 +0800 Subject: [PATCH 13/18] =?UTF-8?q?=E6=89=93=E5=9B=9E=E9=87=8D=E5=81=9A?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E6=94=B9commit=5Fmethod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index ed09b8784..f9d9531f1 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -978,7 +978,8 @@ class ExercisesController < ApplicationController :status => nil, :commit_status => 0, :objective_score => 0.0, - :subjective_score => -1.0 + :subjective_score => -1.0, + :commit_method => 0 } redo_exercise_users = @exercise_users.exercise_commit_users(user_ids) redo_exercise_users.update_all(redo_option) From a64d6ef50214f8e29a3130edeba1dd84e7a504cd Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 11 Oct 2019 15:23:25 +0800 Subject: [PATCH 14/18] =?UTF-8?q?=E9=A2=98=E5=BA=93=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/question_banks_controller.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/question_banks_controller.rb b/app/controllers/question_banks_controller.rb index 60b9a807c..7781b5792 100644 --- a/app/controllers/question_banks_controller.rb +++ b/app/controllers/question_banks_controller.rb @@ -90,23 +90,25 @@ class QuestionBanksController < ApplicationController def send_to_course banks = @object_type.classify.constantize.where(id: params[:object_id]) course = current_user.manage_courses.find_by!(id: params[:course_id]) + task_ids = [] banks.each do |bank| case @object_type when 'HomeworkBank' # 作业 - quote_homework_bank bank, course + task = quote_homework_bank bank, course when 'ExerciseBank' if bank.container_type == 'Exercise' # 试卷 - quote_exercise_bank bank, course + task = quote_exercise_bank bank, course else # 问卷 - quote_poll_bank bank, course + task = quote_poll_bank bank, course end when 'GtaskBank' - quote_gtask_bank bank, course + task = quote_gtask_bank bank, course when 'GtopicBank' - quote_gtopic_bank bank, course + task = quote_gtopic_bank bank, course end + task_ids << task.id if task end - normal_status("发送成功") + render :json => {task_ids: task_ids, status: 0, message: "发送成功"} end def destroy From cce35c89ff26dbaad9a0e055d3bc7d70987bec84 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 11 Oct 2019 15:31:39 +0800 Subject: [PATCH 15/18] tiaoz --- app/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index a3b20c598..bab8a4189 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -552,7 +552,7 @@ class CoursesController < ApplicationController def change_member_role tip_exception("请至少选择一个角色") if params[:roles].blank? tip_exception("不能具有老师、助教两种角色") if params[:roles].include?("PROFESSOR") && params[:roles].include?("ASSISTANT_PROFESSOR") - tip_exception("管理员不能切换为助教或老师") if @user_course_identity == Course::CREATOR && + tip_exception("管理员不能切换为助教或老师") if current_user.id == @course.tea_id && (params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR")) course_members = @course.course_members.where(user_id: params[:user_id]) From 450e9675348a085b852311cf25cce9b7b3bf4532 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 11 Oct 2019 15:32:09 +0800 Subject: [PATCH 16/18] tiaoz --- app/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index bab8a4189..0c643d15c 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -552,7 +552,7 @@ class CoursesController < ApplicationController def change_member_role tip_exception("请至少选择一个角色") if params[:roles].blank? tip_exception("不能具有老师、助教两种角色") if params[:roles].include?("PROFESSOR") && params[:roles].include?("ASSISTANT_PROFESSOR") - tip_exception("管理员不能切换为助教或老师") if current_user.id == @course.tea_id && + tip_exception("管理员不能切换为助教或老师") if params[:user_id].to_i == @course.tea_id && (params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR")) course_members = @course.course_members.where(user_id: params[:user_id]) From 2651dd7f2258c7f67590db9daec91ca68622dc58 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 11 Oct 2019 15:33:48 +0800 Subject: [PATCH 17/18] trigger('updatabanner') --- public/react/src/modules/courses/members/ChangeRolePop.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/react/src/modules/courses/members/ChangeRolePop.js b/public/react/src/modules/courses/members/ChangeRolePop.js index 44dfc28fc..896360a40 100644 --- a/public/react/src/modules/courses/members/ChangeRolePop.js +++ b/public/react/src/modules/courses/members/ChangeRolePop.js @@ -41,7 +41,9 @@ function ChangeRolePop({ member_roles = [], record, courseId, onChangeRoleSucces user_id: record.user_id }) if (response.data.status == 0) { + showNotification('保存成功') onChangeRoleSuccess() + trigger('updatabanner') } console.log(response) } From 8b65317d974fe1985218e752a5c86376d7a00ac8 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 11 Oct 2019 15:35:04 +0800 Subject: [PATCH 18/18] debug --- public/react/src/AppConfig.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index c00c5fb62..e1d5da561 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -84,9 +84,9 @@ export function initAxiosInterceptors(props) { } config.url = `${proxy}${url}`; if (config.url.indexOf('?') == -1) { - config.url = `${config.url}?debug=${'student'}`; + config.url = `${config.url}?debug=${debugType}`; } else { - config.url = `${config.url}&debug=${'student'}`; + config.url = `${config.url}&debug=${debugType}`; } } else { // 加api前缀