Errors trying to get LTI working

Re: Errors trying to get LTI working

by Jacques Barzic -
Number of replies: 12

hi,

I believe the default come from the LTI Authentification.

On the error page, there is also a "Continue" button.

When I clic on this button, the authentification page of the LTI provider site is display.

This means that the LTI function can't create an account for the LTI consumer user on LTI provider site.

In my case, the two Moodle (provider and consumer) are on two different virtual servers.

Also, I've make a test with two Moodle on the same servers, it's OK!

Perhaps, is there a specific setting to do on the servers (apache, php,...)?

Best regards,

Jacques.

 

In reply to Jacques Barzic

Re: Errors trying to get LTI working

by Przemek Kaszubski -
Picture of Particularly helpful Moodlers Picture of Testers

Have you ever resolved this issue? It seems like I'm stuck at precisely the same step. Trying to connect Moodle 3.2.9 to Moodle 3.5.1. Getting the same "Call to a member function out() on string" notification with the Continue button leading me on to the target site embedded in a frame, without being logged onto it..

In reply to Przemek Kaszubski

Re: Errors trying to get LTI working

by Przemek Kaszubski -
Picture of Particularly helpful Moodlers Picture of Testers

Replying to myself, as I continued testing:

1. I was able to connect the two Moodle installations in the opposite direction: with Moodle 3.2.9 as provider and Moodle 3.5.1 as consumer. 

2. My Moodle 3.5.1 is using the Fordson theme, which seems responsible  for the problem with LTI provision - cf. https://github.com/dbnschools/moodle-theme_fordson/issues/26 .

I have tested deeper, changed to another theme - Boost Campus - and faced the same problem !

After switching to plain Boost I was able to connect from Moodle 3.2.9 to the Moodle 3.5.1 via LTI authentication without issues.

I hope this problem can be addressed and my little report helps others.

Is there a tracker for this issue? Where's the best place to report it? It seems like an LTI tool issue and theming issue at the same time.

Perhaps I would yet need to test yet if a consumer Moodle 3.5.1 can connect / authenticate. Will proceed to that.

Regards,

Przemek

Average of ratings: Useful (1)
In reply to Przemek Kaszubski

Re: Errors trying to get LTI working

by Przemek Kaszubski -
Picture of Particularly helpful Moodlers Picture of Testers

PS. After testing connections from another Moodle 3.5.1 site I can confirm that the problem persists. Ergo, there is something wrong with favicon overrides in the themes mentioned, which prevents sites with these themes to serve as LTI tool providers.

 

Average of ratings: Useful (1)
In reply to Przemek Kaszubski

Re: Errors trying to get LTI working

by Jacques Barzic -

Hi,

I confirm, for me the issue come from the theme of the LTI provider.
When I use on  LTI provider a standard Moodle them (like clean) it's OK.
I continue my testing.

Best regards,

Jacques,

In reply to Przemek Kaszubski

Re: Errors trying to get LTI working

by Jacques Barzic -

Hello,

my last tests confirm the issue come from favicon.
On our project, we have put a custom faivicon as the theme alows.
When I take off this custom favicon (the default setting off the theme) on the LTI provider, LTI woks well.

Finaly, I put our custom favicon directly in the theme folder instead of the default favicon, it's OK.
With this solution, be careful when you make a theme update.

Tanks Przemek for this tip.

Best regards.

Jacques.

Average of ratings: Useful (2)
In reply to Jacques Barzic

Re: Errors trying to get LTI working

by Przemek Kaszubski -
Picture of Particularly helpful Moodlers Picture of Testers

Thank you, Jacques, for your tests and update. Would you mind telling us which theme you are using? Mine were based on Fordson and Boost_Campus. I just wonder if all this is a theme thing or an LTI Tool module issue. With the new Moodle version around, I might test again one day..

Kind regards.

Przemek

In reply to Przemek Kaszubski

Re: Errors trying to get LTI working

by Gemma Lesterhuis -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Przemek,

I have tested it with a 3.5.1 with Essential theme - and I accountered the same issue. 
The issue is resolved itself the minute I removed the favicon from the theme settings. 

I have tested it with the new version 3.5.2 with Essential theme and again accounted the same message. 
I solved the issue by removing the Favicon. 

Gemma

Average of ratings: Useful (1)
In reply to Gemma Lesterhuis

Re: Errors trying to get LTI working

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Ok, from a developers point of view there is an error in the documentation of the favicon method in the core_renderer class.

Note: All code referenced from Moodle version 3.5.2+ (Build: 20180914).

So, given the stack trace in the OP, line 102 is:

$icon = helper::get_icon($tool)->out();

this calls the static method 'get_icon' in the class helper to get a 'moodle_url' object and then call the 'out' method on it.  The 'get_icon' method in /enrol/lti/classes/helper.php is:

    /**
     * Returns the icon of the tool.
     *
     * @param \stdClass $tool The lti tool
     * @return \moodle_url A url to the icon of the tool
     * @since Moodle 3.2
     */
    public static function get_icon($tool) {
        global $OUTPUT;
        return $OUTPUT->favicon();
    }

Thus this is the 'favicon' method in the 'core_renderer' class which is in /lib/outputrenderers.php:

    /**
     * Returns the URL for the favicon.
     *
     * @since Moodle 2.5.1 2.6
     * @return string The favicon URL
     */
    public function favicon() {
        return $this->image_url('favicon', 'theme');
    }

this states that the return is a 'string', however the 'image_url' method of the same class is:

    /**
     * Return the moodle_url for an image.
     *
     * The exact image location and extension is determined
     * automatically by searching for gif|png|jpg|jpeg, please
     * note there can not be diferent images with the different
     * extension. The imagename is for historical reasons
     * a relative path name, it may be changed later for core
     * images. It is recommended to not use subdirectories
     * in plugin and theme pix directories.
     *
     * There are three types of images:
     * 1/ theme images  - stored in theme/mytheme/pix/,
     *                    use component 'theme'
     * 2/ core images   - stored in /pix/,
     *                    overridden via theme/mytheme/pix_core/
     * 3/ plugin images - stored in mod/mymodule/pix,
     *                    overridden via theme/mytheme/pix_plugins/mod/mymodule/,
     *                    example: image_url('comment', 'mod_glossary')
     *
     * @param string $imagename the pathname of the image
     * @param string $component full plugin name (aka component) or 'theme'
     * @return moodle_url
     */
    public function image_url($imagename, $component = 'moodle') {
        return $this->page->theme->image_url($imagename, $component);
    }

which states it is a 'moodle_url' class, the 'image_url' method that is called on the 'theme_config' class in /lib/outputlib.php is:

    /**
     * Return the direct URL for an image from the pix folder.
     *
     * Use this function sparingly and never for icons. For icons use pix_icon or the pix helper in a mustache template.
     *
     * @param string $imagename the name of the icon.
     * @param string $component specification of one plugin like in get_string()
     * @return moodle_url
     */
    public function image_url($imagename, $component) {
        global $CFG;
        $params = array('theme'=>$this->name);
        $svg = $this->use_svg_icons();
        if (empty($component) or $component === 'moodle' or $component === 'core') {
            $params['component'] = 'core';
        } else {
            $params['component'] = $component;
        }
        $rev = theme_get_revision();
        if ($rev != -1) {
            $params['rev'] = $rev;
        }
        $params['image'] = $imagename;
        $url = new moodle_url("/theme/image.php");
        if (!empty($CFG->slasharguments) and $rev > 0) {
            $path = '/'.$params['theme'].'/'.$params['component'].'/'.$params['rev'].'/'.$params['image'];
            if (!$svg) {
                // We add a simple /_s to the start of the path.
                // The underscore is used to ensure that it isn't a valid theme name.
                $path = '/_s'.$path;
            }
            $url->set_slashargument($path, 'noparam', true);
        } else {
            if (!$svg) {
                // We add an SVG param so that we know not to serve SVG images.
                // We do this because all modern browsers support SVG and this param will one day be removed.
                $params['svg'] = '0';
            }
            $url->params($params);
        }
        return $url;
    }

which also states it is a 'moodle_url' class (instantiated object of) being returned.

So from a purely Essential theme point of view, I / Julian / David has been misinformed when reading the core code and written:

    /**
     * Returns the url of the custom favicon.
     */
    public function favicon() {
        $favicon = \theme_essential\toolbox::get_setting('favicon', 'format_file_url');
        if (empty($favicon)) {
            return $this->page->theme->image_url('favicon', 'theme');
        } else {
            return $favicon;
        }
    }

in the overridden core_renderer method 'favicon'.  And thus I suspect many other developers have too.  I'll now work on a fix.

Therefore the 'favicon' method in the 'core_renderer' class is incorrectly documented and hence the error message 'Exception - Call to a member function out() on string' because a string does not have a method called 'out' but a 'moodle_url' object does.

Is there an MDL for this trivial bug?

Also if you're using any of my other themes and have the same issue, then let me know.

Gareth


Average of ratings: Useful (4)
In reply to Gareth J Barnard

Re: Errors trying to get LTI working

by C Behan -
Just noting that this issue is present in Moodle 3.6 also.
In reply to Gareth J Barnard

Re: Custom theme favicon on LTI provider site breaks LTI authentication [Solved]

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Thanks Gareth for the detailed information.

Just noting that the problem of a custom theme favicon on the LTI provider site breaking authentication - MDL-66272 - has been fixed in Moodle 3.6.6 and 3.7.2.

In reply to Helen Foster

Re: Custom theme favicon on LTI provider site breaks LTI authentication [Solved]

by Sarah Ashley -

Hi Helen! 

Thanks for sharing the news about the fix in 

Has anyone tested publishing an LTI activity or course from 3.7.2 and successfully launched the content elsewhere?

I have been at it all night with no success. Upgraded our dev Moodle site to 3.7.2 from the GIT file, since it is not yet on moodle.org. 

I tried the Fordson theme, the new Classic theme, and the Boost theme. None of them make a difference. I still get the same Exception - Call to a member function out() on string error that started this particular thread.

I was initially trying to add LTI content to a WordPress site, using a WordPress LTI Consumer plugin. No joy. So I tried adding it to another Moodle site running 3.6.2+. Same error occurs. Publishing LTIs from the 3.6.2 Moodle site to consume on the 3.7.2 site however works perfectly fine. 

I have tried all kinds of combinations of: 

  • Launch URL + secret (this is the combo that worked on Moodle and on WordPress after deleting the favicon!)
  • Cartridge URL + secret
  • Proxy URL alone
  • Proxy URL + secret
  • Cartridge URL alone

I am now at a loss what to do to get this content to work. Any thoughts, anyone? I had such high hopes when I read that this had been fixed in 3.7.2 and spent long hours on a test upgrade and test of publishing the LTI to no avail.

Help, please, anyone?

Million thanks!

PS: (4 hrs later...) I deleted the favicon in Fordson on the 3.7.2 site and now it works. But that seems to indicate that the problem was not taken care of in 3.7.2 as suggested in that tracker item, Helen. Or am I missing something? Thanks again.
Then again, maybe the problem is in the Fordson Theme after all?

In reply to Sarah Ashley

Re: Custom theme favicon on LTI provider site breaks LTI authentication [Solved]

by C Behan -
Hi Sarah,
The problem does need to be fixed in the theme. The fix in the tracker is to update the documentation, but the theme developers still need to update their themes. I have flagged it with the Moove theme developer - maybe you could draw the Fordson theme's developer's attention to it?
Catherine