LTI: add XAPI duration to enrollment activity time
Change-Id: I2e381a0a65b81d8f1ad31562b67caf74d5962f84 Reviewed-on: https://gerrit.instructure.com/37116 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Brad Humphrey <brad@instructure.com> QA-Review: Clare Strong <clare@instructure.com> Product-Review: Braden Anderson <braden@instructure.com>
This commit is contained in:
parent
4864b0e7b5
commit
233617f4f1
|
@ -53,6 +53,25 @@ class LtiApiController < ApplicationController
|
|||
render :text => e.to_s, :status => 401
|
||||
end
|
||||
|
||||
def xapi
|
||||
verify_oauth
|
||||
|
||||
if request.content_type != "application/json"
|
||||
return render :text => '', :status => 415
|
||||
end
|
||||
|
||||
source_id = params[:actor]['account']['name']
|
||||
course, assignment, user = BasicLTI::BasicOutcomes.decode_source_id(@tool, source_id)
|
||||
|
||||
duration = params[:result]['duration']
|
||||
seconds = duration.match(/PT(\d+)S/)[1].to_i
|
||||
|
||||
# TODO: This should create an asset user access and page view as well.
|
||||
course.enrollments.where(:user_id => user).update_all(['total_activity_time = total_activity_time + ?', seconds])
|
||||
|
||||
return render :text => '', :status => 200
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def verify_oauth
|
||||
|
|
|
@ -1571,6 +1571,7 @@ CanvasRails::Application.routes.draw do
|
|||
ApiRouteSet.draw(self, "/api/lti/v1") do
|
||||
post "tools/:tool_id/grade_passback", :controller => :lti_api, :action => :grade_passback, :path_name => "lti_grade_passback_api"
|
||||
post "tools/:tool_id/ext_grade_passback", :controller => :lti_api, :action => :legacy_grade_passback, :path_name => "blti_legacy_grade_passback_api"
|
||||
post "tools/:tool_id/xapi", :controller => :lti_api, :action => :xapi, :path_name => "lti_xapi"
|
||||
end
|
||||
|
||||
ApiRouteSet.draw(self, "/api/lti") do
|
||||
|
|
|
@ -23,7 +23,8 @@ module Lti
|
|||
module MessageHelper
|
||||
def common_variable_substitutions
|
||||
{
|
||||
'$Canvas.api.domain' => -> {HostUrl.context_host(@domain_root_account, request.host)}
|
||||
'$Canvas.api.domain' => -> {HostUrl.context_host(@domain_root_account, request.host)},
|
||||
'$Canvas.xapi.url' => -> {lti_xapi_url(@tool)}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue