Module: Course::Discussion::PostsConcern

Extended by:
ActiveSupport::Concern
Included in:
Assessment::Submission::Answer::Programming::AnnotationsController, Assessment::SubmissionQuestion::CommentsController, PostsController, Forum::PostsController, Video::TopicsController
Defined in:
app/controllers/concerns/course/discussion/posts_concern.rb

Instance Method Summary collapse

Instance Method Details

#create_topic_subscriptionBoolean (protected)

Create topic subscriptions for related users

Raises:

  • (NotImplementedError)

36
37
38
# File 'app/controllers/concerns/course/discussion/posts_concern.rb', line 36

def create_topic_subscription
  raise NotImplementedError, 'To be implemented by the concrete topic posts controller.'
end

#discussion_topicCourse::Discussion::Topic (protected)

The discussion topic record that posts belong to. When your model uses 'acts_as :topic', you can write: 'your_instance.topic' in this method.

Raises:

  • (NotImplementedError)

44
45
46
# File 'app/controllers/concerns/course/discussion/posts_concern.rb', line 44

def discussion_topic
  raise NotImplementedError, 'To be implemented by the concrete topic posts controller.'
end

#skip_update_topic_statusObject (protected)

Option for controller to skip the topic_status.


29
30
31
# File 'app/controllers/concerns/course/discussion/posts_concern.rb', line 29

def skip_update_topic_status
  false
end

#update_topic_pending_statusBoolean (protected)

Update pending status of the topic: If the student replies to the topic, set to true. If the staff replies the post, set to false.


18
19
20
21
22
23
24
25
26
# File 'app/controllers/concerns/course/discussion/posts_concern.rb', line 18

def update_topic_pending_status
  return true if !current_course_user || skip_update_topic_status

  if current_course_user.teaching_staff?
    @post.topic.unmark_as_pending
  else
    @post.topic.mark_as_pending
  end
end