Class: Course::Discussion::TopicsController

Inherits:
ComponentController show all
Defined in:
app/controllers/course/discussion/topics_controller.rb

Instance Method Summary collapse

Methods included from ApplicationSignInCallbacksConcern

#sign_in

Methods included from ApplicationPaginationConcern

#page_param

Methods included from ApplicationAnnouncementsConcern

#global_announcements, #unread_global_announcements

Methods included from ApplicationInstanceUserConcern

#current_instance_user

Methods included from ApplicationUserTimeZoneConcern

#set_time_zone

Methods included from ApplicationUserConcern

#handle_access_denied, #publicly_accessible?

Methods included from ApplicationComponentsConcern

#handle_component_not_found

Instance Method Details

#indexObject


8
9
10
11
12
13
# File 'app/controllers/course/discussion/topics_controller.rb', line 8

def index
  @topics = all_topics

  return unless current_course_user&.student?
  @topics = @topics.merge(Course::Discussion::Topic.from_user(current_course_user.user_id))
end

#mark_as_readObject


44
45
46
47
# File 'app/controllers/course/discussion/topics_controller.rb', line 44

def mark_as_read
  @topic.mark_as_read! for: current_user
  redirect_back fallback_location: course_topics_path(current_course)
end

#my_studentsObject


26
27
28
# File 'app/controllers/course/discussion/topics_controller.rb', line 26

def my_students
  @topics = my_students_topics
end

#my_students_pendingObject


30
31
32
# File 'app/controllers/course/discussion/topics_controller.rb', line 30

def my_students_pending
  @topics = my_students_topics.pending_staff_reply
end

#pendingObject

Loads topics pending staff reply for course_staff, and unread topics for students.


16
17
18
19
20
21
22
23
24
# File 'app/controllers/course/discussion/topics_controller.rb', line 16

def pending
  @topics = begin
    if current_course_user&.student?
      unread_topics_for_student
    else
      all_topics.pending_staff_reply
    end
  end
end

#toggle_pendingObject


34
35
36
37
38
39
40
41
42
# File 'app/controllers/course/discussion/topics_controller.rb', line 34

def toggle_pending
  success = if mark_as_pending?
              @topic.mark_as_pending
            else
              @topic.unmark_as_pending
            end

  head :bad_request unless success
end