Class: Course::Video::Submission::SubmissionsController

Inherits:
Controller show all
Defined in:
app/controllers/course/video/submission/submissions_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

#createObject


17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/course/video/submission/submissions_controller.rb', line 17

def create
  if @submission.save
    redirect_to edit_course_video_submission_path(current_course, @video, @submission)
  elsif @submission.existing_submission.present?
    redirect_to edit_course_video_submission_path(current_course,
                                                  @video,
                                                  @submission.existing_submission)
  else
    redirect_to course_videos_path(current_course),
                danger: t('.failure', error: @submission.errors.full_messages.to_sentence)
  end
end

#editObject


30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/course/video/submission/submissions_controller.rb', line 30

def edit
  # @submission is normally authorized in the super controller, and has to be manually authorized
  # here for a custom access denied behaviour to be implemented
  authorize!(:edit, @submission)

  @topics = @video.topics.includes(posts: :children).order(:timestamp)
  @topics = @topics.reject { |topic| topic.posts.empty? }
  @posts = @topics.map(&:posts).inject(Course::Discussion::Post.none, :+)
  set_seek_and_scroll
  set_monitoring
rescue CanCan::AccessDenied
  redirect_to course_video_path(current_course, @video)
end

#indexObject


6
7
8
9
10
11
# File 'app/controllers/course/video/submission/submissions_controller.rb', line 6

def index
  authorize!(:manage, @video)
  @submissions = @submissions.includes(experience_points_record: :course_user)
  @my_students = current_course_user.try(:my_students) || []
  @course_students = current_course.course_users.students.order_alphabetically
end

#showObject


13
14
15
# File 'app/controllers/course/video/submission/submissions_controller.rb', line 13

def show
  @sessions = @submission.sessions.with_events_present
end