diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 55f8722a2..ac5bd027f 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -1,5 +1,5 @@ class SubjectsController < ApplicationController - before_action :require_login, :check_auth, except: [:index, :show] + before_action :require_login, :check_auth, except: [:index, :show, :right_banner] # before_action :check_auth, except: [:index] before_action :check_account, except: [:index, :show] before_action :find_subject, except: [:index, :create, :new, :append_to_stage] @@ -85,17 +85,6 @@ class SubjectsController < ApplicationController # 合作团队 @shixuns = @subject.shixuns.published.pluck(:id) @courses = @subject.courses if @subject.excellent - - @members = @subject.subject_members.includes(:user) - shixuns = @subject.shixuns.published.pluck(:id) - challenge_ids = Challenge.where(shixun_id: shixuns).pluck(:id) - # 实训路径中的所有实训标签 - @tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq - # 用户获取的实训标签 - # @user_tags = @subject.shixuns.map(&:user_tags_name).flatten.uniq - @user_tags = user_shixun_tags challenge_ids, @user.id - @my_subject_progress = @subject.my_subject_progress - # 访问数变更 @subject.increment!(:visits) end diff --git a/app/views/subjects/show.json.jbuilder b/app/views/subjects/show.json.jbuilder index ec76b5a2d..53e76a96f 100644 --- a/app/views/subjects/show.json.jbuilder +++ b/app/views/subjects/show.json.jbuilder @@ -23,26 +23,4 @@ if @subject.excellent json.course_identity @user.course_identity(course) json.course_status subject_course_status course end -end - - -json.members @members do |member| - json.partial! 'subject_member', locals: { user: member.user } - json.role member.role -end - -# 技能标签 -json.tags @tags do |tag| - unless tag.blank? - json.tag_name tag - json.status @user_tags.include?(tag) - end -end - -# 我的进展 -json.progress do - json.my_score @subject.my_subject_score - json.all_score @subject.all_score - json.learned @subject.my_subject_progress - json.time @subject.my_consume_time end \ No newline at end of file diff --git a/lib/tasks/public_course.rake b/lib/tasks/public_course.rake index 13ef7b2e7..0f10b84ad 100644 --- a/lib/tasks/public_course.rake +++ b/lib/tasks/public_course.rake @@ -48,27 +48,17 @@ namespace :public_course do end end - # - task :message => :environment do - discusses = Discuss.find_by_sql("select content, user_id, created_on, updated_on from discusses where dis_id in (select shixun_id from stage_shixuns where - stage_id in (select id from stages where subject_id=#{subject_id})) and created_at > #{start_time} and - created_at<#{end_time}") - discusses.find_each do |discuss| - puts discuss.user_id - puts discuss.content - # 回复帖子 - # 讨论区发布帖子 - # Message.create!(board: @message.board, root_id: @message.root_id || @message.id, - # author: current_user, parent: @message, - # message_detail_attributes: { - # content: params[:content] - # }) + task :test_user => :environment do + users = User.where(is_test: true) + users.find_each do |user| + puts user.id + CourseMember.create!(course_id: course_id, user_id: user.id, role: 4) end end # 更新某个课程的某类时间 - # 执行示例 bundle exec rake public_course:student args=2903,1 + # 执行示例 bundle exec rake public_course:time args=-1,2932,1,1 task :time => :environment do # course_id = ENV['args'].split(",")[0] # 对应课堂的id # type = ENV['args'].split(",")[1] @@ -78,6 +68,11 @@ namespace :public_course do case type.to_i when 1 # 讨论区 + created_on = random_time start_time, end_time + messages = Message.where(board_id: course.boards) + message_details = MessageDetail.where(message_id: messages) + messages.update_columns(created_on: created_on, updated_on: created_on) + message_details.update_columns(created_at: created_on, updated_at: created_on) when 2 # 作业