diff --git a/app/controllers/weapps/courses_controller.rb b/app/controllers/weapps/courses_controller.rb index 1d510a863..f1edc191c 100644 --- a/app/controllers/weapps/courses_controller.rb +++ b/app/controllers/weapps/courses_controller.rb @@ -1,6 +1,6 @@ class Weapps::CoursesController < Weapps::BaseController # before_action :require_wechat_login! - before_action :teacher_allowed, except: [:create, :show] + before_action :teacher_allowed, except: [:create, :show, :shixun_homework_category] def create return render_error("只有老师身份才能创建课堂") unless current_user.is_teacher? @@ -26,6 +26,10 @@ class Weapps::CoursesController < Weapps::BaseController @current_user = current_user end + def shixun_homework_category + @categories = current_course.shixun_course_modules.first&.course_second_categories + end + private def course_params diff --git a/app/views/weapps/courses/shixun_homework_category.json.jbuilder b/app/views/weapps/courses/shixun_homework_category.json.jbuilder new file mode 100644 index 000000000..b38748597 --- /dev/null +++ b/app/views/weapps/courses/shixun_homework_category.json.jbuilder @@ -0,0 +1,3 @@ +json.categories @categories.each do |category| + json.(category, :id, :name) +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d663e7cfb..245e984c6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -880,7 +880,11 @@ Rails.application.routes.draw do post :cancel_sticky, on: :collection end - resources :courses, only: [:create, :update, :edit, :show] + resources :courses, only: [:create, :update, :edit, :show] do + member do + get :shixun_homework_category + end + end end resources :users_for_partners, only: [:index]