Class: AtomicLti::Services::Results

Inherits:
Base
  • Object
show all
Defined in:
app/lib/atomic_lti/services/results.rb

Overview

Instance Method Summary collapse

Methods inherited from Base

#get_next_url, #headers, #initialize, #logged_service_call, #service_delete, #service_get, #service_post, #service_put

Constructor Details

This class inherits a constructor from AtomicLti::Services::Base

Instance Method Details

#list(line_item_id, query: {}, page_url: nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/lib/atomic_lti/services/results.rb', line 10

def list(line_item_id, query: {}, page_url: nil)
  url = if page_url.present?
          page_url
        else
          uri = Addressable::URI.parse(line_item_id)
          uri.path = "#{uri.path}/results"
          uri.query_values = (uri.query_values || {}).merge(query)
          uri.to_str
        end

  accept = { "Accept" => "application/vnd.ims.lis.v2.resultcontainer+json" }
  response, = service_get(url, headers: headers(accept))
  response
end

#list_all(line_item_id, query: {}) ⇒ Object



25
26
27
28
29
30
# File 'app/lib/atomic_lti/services/results.rb', line 25

def list_all(line_item_id, query: {})
  AtomicLti::PagingHelper.paginate_request do |next_link|
    result_page = list(line_item_id, query: query, page_url: next_link)
    [JSON.parse(result_page.body), get_next_url(result_page)]
  end
end

#scopesObject



6
7
8
# File 'app/lib/atomic_lti/services/results.rb', line 6

def scopes
  [AtomicLti::Definitions::AGS_SCOPE_RESULT]
end

#show(result_id) ⇒ Object



32
33
34
35
# File 'app/lib/atomic_lti/services/results.rb', line 32

def show(result_id)
  response, = service_get(result_id, headers: headers)
  response
end