json.exercise do
  json.extract! @exercise, :id,:exercise_name, :exercise_status,:time,:publish_time,
                :end_time,:score_open,:answer_open,:question_random,:choice_random,
                :unified_setting,:show_statistic
  json.course_id @course.id
  json.published_count @exercise_publish_count
  json.unpublish_count @exercise_unpublish_count
  json.committed_count @exercise_users_count
  json.user_permission @user_permission
end

if @user_published_setting.size > 0   #老师存在已发布的分班
  total_array_groups = get_user_setting_course(@user_published_setting,@user_course_groups)
  json.published_course_groups do
    json.array! total_array_groups do |s|
      json.course_group_id s[:course_group_id]
      json.course_group_name s[:course_group_name]
      json.course_publish_time s[:course_publish_time]
      json.course_end_time s[:course_end_time]
    end
  end
else
  json.published_course_groups []
end

if @user_course_groups.count > 0
  json.course_groups do
    json.array! @user_course_groups do |group|
      course_choosed = 0
      if @being_setting_course_ids.include?(group[:group_id])
        course_choosed = 1
      end
      json.course_group_id group[:group_id]
      json.course_group_name group[:group_name]
      json.course_choosed course_choosed
    end
  end
else
  json.course_groups []
end
