diff --git a/app/controllers/admins/subject_settings_controller.rb b/app/controllers/admins/subject_settings_controller.rb index 903c5a458..29e4dfd30 100644 --- a/app/controllers/admins/subject_settings_controller.rb +++ b/app/controllers/admins/subject_settings_controller.rb @@ -8,16 +8,15 @@ class Admins::SubjectSettingsController < Admins::BaseController end def update - if params[:sub_disciplines] - sub_ids = params[:sub_disciplines].reject(&:blank?).map(&:to_i) - old_sub_ids = current_subject.sub_discipline_containers.pluck(:sub_discipline_id) - new_ids = sub_ids - old_sub_ids - delete_ids = old_sub_ids - sub_ids - sub_params = new_ids.map{|sub| {sub_discipline_id: sub}} - ActiveRecord::Base.transaction do - current_subject.sub_discipline_containers.where(sub_discipline_id: delete_ids).destroy_all - current_subject.sub_discipline_containers.create!(sub_params) - end + sub_discipline_ids = params[:sub_disciplines] || [] + sub_ids = sub_discipline_ids.reject(&:blank?).map(&:to_i) + old_sub_ids = current_subject.sub_discipline_containers.pluck(:sub_discipline_id) + new_ids = sub_ids - old_sub_ids + delete_ids = old_sub_ids - sub_ids + sub_params = new_ids.map{|sub| {sub_discipline_id: sub}} + ActiveRecord::Base.transaction do + current_subject.sub_discipline_containers.where(sub_discipline_id: delete_ids).destroy_all + current_subject.sub_discipline_containers.create!(sub_params) end end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 1864195f7..c946cd5c1 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1157,8 +1157,8 @@ class CoursesController < ApplicationController CourseAddStudentCreateWorksJob.perform_later(course.id, [current_user.id]) StudentJoinCourseNotifyJob.perform_later(current_user.id, course.id) + student_role = 1 end - student_role = 1 end # 创建教师身份 @@ -1195,9 +1195,9 @@ class CoursesController < ApplicationController teacher_role = 1 end - if teacher_role && student_role + if (teacher_role && student_role) || message.to_s == "您已是课堂成员" render json: { status: 0, message: message, course_id: course.id} - elsif student_role + elsif student_role.to_i == 1 render json: { status: 0, message: "加入成功", course_id: course.id} else normal_status(message) diff --git a/app/views/weapps/subjects/index.json.jbuilder b/app/views/weapps/subjects/index.json.jbuilder index cfdce4530..8f61f150c 100644 --- a/app/views/weapps/subjects/index.json.jbuilder +++ b/app/views/weapps/subjects/index.json.jbuilder @@ -1,6 +1,7 @@ json.subjects @subjects do |subject| json.(subject, :id, :excellent, :name, :stages_count, :shixuns_count) - json.myshixuns_count subject.member_count + json.myshixuns_count subject.excellent ? subject.member_count : subject.myshixuns_count + json.challenges_count subject.subject_challenge_count json.image_url url_to_avatar(subject) json.allow_visit subject.status > 1 || User.current.manager_of_subject?(subject) || User.current.admin? end diff --git a/app/views/weapps/subjects/show.json.jbuilder b/app/views/weapps/subjects/show.json.jbuilder index 757257e82..29a30a89a 100644 --- a/app/views/weapps/subjects/show.json.jbuilder +++ b/app/views/weapps/subjects/show.json.jbuilder @@ -2,6 +2,7 @@ json.subject do json.name @subject.name json.description @subject.description json.shixuns_count @subject.shixuns_count + json.challenges_count @subject.subject_challenge_count json.member_count @subject.member_count json.subject_score @subject.all_score json.learning_notes @subject.learning_notes diff --git a/public/react/public/index.html b/public/react/public/index.html index de176398c..7da2b8d03 100755 --- a/public/react/public/index.html +++ b/public/react/public/index.html @@ -17,7 +17,7 @@ - + @@ -202,5 +202,11 @@ --> + +