Forums | Mahara Community

Mahara/Moodle integration /
Can't get Moodle Mahara LTI integration & assign submissions working


Dan Marsden's profile picture
Posts: 13

03 August 2023, 19:35

Yeah - it's definitely not an ideal situation you're in! - great to hear you've signed up for the enterprise subscription too! - The Mahara team will know more about the process, but my understanding is that the enterprise subscription does come with the ability to raise issues as part of your agreement, so that's a good way to go and hopefully they can help via that method (if you haven't already).

i didn't mean to suggest "you" were looking for free help, just that I have something in my teams backlog related to investigation of the LTI integration and testing the latest version of Mahara/Moodle and the plugin with PHP 8.1 but that internal task is currently listed as "volunteer/non-chargeable" time at the moment and not something I can charge an existing client for so that limits my ability to prioritize it within my team over other work that clients are directly paying us for right now. (I am not part of the Mahara core team). I do think we'll get to it, but I'm not sure if I could say it would be within the next 2 weeks at this stage.

03 August 2023, 21:21

OK, thanks Dan.

I don't know what's on the rest of the backlog, but I do think that the Mahara team should proritize to keep the functionality they had above creating new functionality.

We have been using the Moodle assignment submission for Mahara for 2 years now. It has stopped working for different reasons, mainly PHP 8. But it has been used a lot.

So keep what you have, then focus on the new. At least, that would be my concern. I will stress the importance for this to the Mahara team.

Robert Lyon's profile picture
Posts: 764

04 August 2023, 10:27

Hi Richard,

Looking at the file in Mahara htdocs/webservice/lib.php in the authenticate_by_token() function can you try debugging the $tokentype value and the state of the object at that point please.

so about line 1214 add 

log_debug($tokentype);
log_degug($this);

And let me know what information you see

Cheers
Robert

04 August 2023, 22:03

Thanks for helping me with this Robert.

Is see no difference when adding these lines. This remains the error I get in Moodle (when trying to save the Moodle assignment with the Mahara option checked)

n2saF5R.png

Mahara webservice logs says this:
az12tw6.png

What would your extra lines do? Log something and where?

 

04 August 2023, 22:09

I also see this error:

Warning: foreach() argument must be of type array|object, null given in /home/learndev/public_html/mod/assign/submission/maharaws/locallib.php on line 238

05 August 2023, 1:16

This is what I see in the Apache SSL logs on Mahara:

145.19.1.141 - - [04/Aug/2023:15:05:11 +0200] "POST /webservice/rest/server.php HTTP/1.1" 200 3072 "-" "MoodleBot/4.2 (+https://learn.hzdev.nl)"

05 August 2023, 2:18

OK, so forgive my methods here - I'm a bad programmer. But I decided to mail the webservice call made by Moodle to Mahara to myself.

In file: /mod/assign/submission/maharaws/locallib.php line 288, public function webservice_call($function, $params, $method = "POST")

 

I added this:

// Prepare the email content
    $emailSubject = 'WebService Call Information';
    $emailBody = "Authentication URL: " . $endpoint . PHP_EOL;
    $emailBody .= "Method: " . $method . PHP_EOL;
    $emailBody .= "Function: " . $function . PHP_EOL;
    $emailBody .= "Parameters: " . print_r($params, true) . PHP_EOL;

    // Send the email
    $to = 'my@email'; // Replace with your email address
    $headers = 'From: portfolio@mahara'; // Replace with a sender email address
    mail($to, $emailSubject, $emailBody, $headers);
 

Guess what I received:

Authentication URL: https://portfolio.hzdev.nl/webservice/rest/server.php

Method: POST

Function: mahara_user_get_extended_context

Parameters: Array

(

)

Good news: my Email-debugging worked. Bad news: no parameters are being passed. URL, Method, Function all seem to be OK. But where are the parameters?

Will keep searching....

05 August 2023, 3:43

OK, so what I see in mod/assign/submission/maharaws/locallib.php line 307 is this:

        // Have to flatten nested parameters into JSON as OAuth can't handle it.
        foreach ($params as $k => $v) {
            if (is_array($v)) {
                $params[$k] = json_encode($v);
            }
        }

However, never before this part is $params being filled with anything... so what should be in $params? And where in what file or on what line should $params get any value? Because in my Moodle, it's empty and stays empty.

 

Dan Marsden's profile picture
Posts: 13

14 August 2023, 15:29

I've just had a look at this myself today - on a Moodle 4.3 site (running PHP 8) and a Mahara 24.04dev site (running php 7.4) and it seems to work fine for me - I did run into a Moodle 4.3 issue which I've pushed a fix for into the github repo.

Next step will be to test this on Mahara site with PHP 8 to make sure that isn't the issue as that's the only difference I think you're saying compared with the versions I'm using?

I didn't look through the full history here, but I assume you are testing with publicly accessible Moodle and Mahara sites (not internal testing systems) and they both have valid SSL certs and not self-signed certs or no ssl certs installed?

14 August 2023, 17:39

Dan,

As far as I know, there's no Moodle 4.3 yet. Don't you mean 4.2?

Can you post screenshots of your settings, because please see my posts above. I find it very, very hard to believe this actually works as some needed parameters do not seem to be passed. At all.

I assume you are testing with publicly accessible Moodle and Mahara sites (not internal testing systems) and they both have valid SSL certs and not self-signed certs or no ssl certs installed?

Yes. This is not my problem.

I also tested this with Mahara running on PHP7.4 and it also doesn't work.