Class: Course::Assessment::SessionLogService

Inherits:
Object
  • Object
show all
Defined in:
app/services/course/assessment/session_log_service.rb

Overview

Authenticate the assessment and update the session_id in submission.

Instance Method Summary collapse

Constructor Details

#initialize(assessment, session, submission) ⇒ SessionLogService


7
8
9
10
11
# File 'app/services/course/assessment/session_log_service.rb', line 7

def initialize(assessment, session, submission)
  @assessment = assessment
  @session = session
  @submission = submission
end

Instance Method Details

#log_submission_access(request) ⇒ Object

Log submission access attempts for password-protected assessments.


14
15
16
17
18
19
20
21
22
23
# File 'app/services/course/assessment/session_log_service.rb', line 14

def log_submission_access(request)
  request_headers = request.headers.env.select do |k, _|
    k.in?(ActionDispatch::Http::Headers::CGI_VARIABLES) || k =~ /^HTTP_/
  end

  request_headers['USER_SESSION_ID'] = current_authentication_token
  request_headers['SUBMISSION_SESSION_ID'] = @submission.session_id

  @submission.logs.create(request: request_headers)
end