Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LTI2 Registration with Canvas #2

Merged
merged 3 commits into from
May 8, 2018
Merged

Fix LTI2 Registration with Canvas #2

merged 3 commits into from
May 8, 2018

Conversation

dac514
Copy link
Collaborator

@dac514 dac514 commented May 8, 2018

When trying to do LTI2 Registration with Canvas I get back:

{"errors":[{"field":"product_code","message":null,"error_code":"blank"}],"error_report_id":155315614}

The reason is this code:

def create_product_family(tp, account, developer_key)
  vendor_code = tp.tool_profile.product_instance.product_info.product_family.vendor.code
  product_code = tp.tool_profile.product_instance.product_info.product_family.code

Source: https://github.com/instructure/canvas-lms/blob/0063478e81b0175f47ce0698345b3b8f42e6d52a/app/models/lti/tool_proxy_service.rb#L125

When I change ToolProvider/MediaType/ToolProfile.php from:

if (!empty($toolProvider->vendor->id)) { 
  $this->product_instance->product_info->product_family->vendor->code = $toolProvider->vendor->id;	
}

To:

if (!empty($toolProvider->vendor->id)) { 
  $this->product_instance->product_info->product_family->vendor->code = $toolProvider->vendor->id; 
  $this->product_instance->product_info->product_family->code = $toolProvider->vendor->id; }

Ir works.

Unsure if it should be the same vendor ID though. Here's the spec: https://www.imsglobal.org/specs/ltiv2p0/implementation-guide#toc-68

When trying to do LTI2 Registration with Canvas I get back:

{"errors":[{"field":"product_code","message":null,"error_code":"blank"}],"error_report_id":155315614}

The reason is this code:

```ruby
def create_product_family(tp, account, developer_key)
  vendor_code = tp.tool_profile.product_instance.product_info.product_family.vendor.code
  product_code = tp.tool_profile.product_instance.product_info.product_family.code
```

Source: https://github.com/instructure/canvas-lms/blob/0063478e81b0175f47ce0698345b3b8f42e6d52a/app/models/lti/tool_proxy_service.rb#L125

When I change ToolProvider/MediaType/ToolProfile.php from:

```php
if (!empty($toolProvider->vendor->id)) { 
  $this->product_instance->product_info->product_family->vendor->code = $toolProvider->vendor->id;	
}
```

To:

```php
if (!empty($toolProvider->vendor->id)) { 
  $this->product_instance->product_info->product_family->vendor->code = $toolProvider->vendor->id; 
  $this->product_instance->product_info->product_family->code = $toolProvider->vendor->id; }
```

Ir works.

Unsure if it should be the same vendor ID though. Here's the spec: https://www.imsglobal.org/specs/ltiv2p0/implementation-guide#toc-68
@Izumi-kun
Copy link
Owner

I think product_code will be an id of Product.

The product family is identified by a code that is unique within the namespace of some vendor

So this:

        if (!empty($toolProvider->vendor)) {
            $this->product_instance->product_info->product_family = new \stdClass;
            $this->product_instance->product_info->product_family->vendor = new \stdClass;
        }

became like this:

        if (!empty($toolProvider->vendor)) {
            $this->product_instance->product_info->product_family = new \stdClass;
            $this->product_instance->product_info->product_family->vendor = new \stdClass;
            if (!empty($toolProvider->product->id)) {
                $this->product_instance->product_info->product_family->code = $toolProvider->product->id;
            }
        }

What do you think?

@Izumi-kun Izumi-kun added the bug label May 8, 2018
@dac514
Copy link
Collaborator Author

dac514 commented May 8, 2018

Yes sounds good. So long as there's an ID (string, int) it seems to work for me.

@Izumi-kun
Copy link
Owner

Please add extra commit so i can merge this bugfix.

@dac514
Copy link
Collaborator Author

dac514 commented May 8, 2018

Done.

@Izumi-kun Izumi-kun merged commit 357f28e into Izumi-kun:fixed May 8, 2018
@Izumi-kun
Copy link
Owner

Merged. Thanks!

Related: 1EdTech#24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants