Class: Course::Video::Submission::SessionsController

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


5
6
7
# File 'app/controllers/course/video/submission/sessions_controller.rb', line 5

def create
  head :bad_request unless @session.save
end

#updateObject


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/course/video/submission/sessions_controller.rb', line 9

def update
  # We received a message from client, so time is updated regardless of how event records turn out
  if params[:is_old_session]
    @session.update_attributes!(last_video_time: update_params[:last_video_time])
  else
    @session.update_attributes!(session_end: Time.zone.now,
                                last_video_time: update_params[:last_video_time])
  end
  @session.merge_in_events!(update_params[:events])

  head :no_content
rescue ArgumentError => _
  head :bad_request
rescue ActiveRecord::RecordInvalid => _
  head :bad_request
end