Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Add "test connection" functionality in GUI and cli #13

Open
upats opened this issue Jun 10, 2015 · 4 comments
Open

Add "test connection" functionality in GUI and cli #13

upats opened this issue Jun 10, 2015 · 4 comments

Comments

@upats
Copy link

upats commented Jun 10, 2015

A user on the Moodle forums sent me a message with a request:

"I work for the University of Montreal, we are using Mahara 1.10.2, Moodle 2.7 with the new versions of plugins for assign submission and feedback from Mahara.

We would like to have an automated test that can detect if my Moodle-Mahara integration is working fine. In other words, any kind of integration test that can check the SSO, exporting files from Moodle to Mahara, and any others shared functionalities. I would like to run it daily and be alerted if there is something that doesn't work.

Do you know if anybody in the community use some kind of test for that? Behat tests? Unit tests?

Thanks in advance!"

I mentioned that once you get the initial setup working, there should be no problems going into the future unless, possibly, you have Mahara and Moodle installed on separate servers in which case there are more potential points of failure (firewall, SSH keys, etc).

Either way, I thought it might be nice to have a feature that tests your connection between Moodle and Mahara to make sure page submitting will work. This could be accessed via a menu in Moodle that just says "connection successful!" and also a cli script that could be set to run on a cron (if someone wanted notifications on failures).

Obviously not a priority but it could be a nice long-term goal.

Now that I think about it, maybe this would be more appropriate for general XMLRPC connections in Moodle to other software, since that's ultimately what would be the cause of failure.

@agwells
Copy link

agwells commented Nov 8, 2015

I'm not aware of any tests written for this yet. It probably would make sense to have a "test connection" button in the admin section. And if you did that, you could also use the same code to make a CLI script, which could be useful for things like nagios.

However, Moodle HQ probably isn't going to be accepting any enhancements to MNet into Moodle core any time soon, because MNet is still in the (lengthy) process of being replaced. We could put a test page into Mahara or into this plugin, though. Or a Moodle plugin that just adds an Mnet test button.

@upats
Copy link
Author

upats commented Nov 10, 2015

Aaron,

Do you have any recommendations on how we could go about testing? I can have my student worker take a stab at developing a test page with a button in the admin panel. I'm just not sure how the test would function.

Would we just attempt an XMLRPC connection from Moodle -> Mahara and verify there is a response with no errors?

@upats
Copy link
Author

upats commented Nov 10, 2015

Sorry, an Mnet connection.

@agwells
Copy link

agwells commented Nov 10, 2015

Hi Tony,

I think the most sensible thing would be if Moodle sends an XMLRPC request to Mahara (and/or vice-versa). MNet uses XMLRPC as the communication medium, and all XMLRPC really is, is a way to make a function calls across the network (plus some authentications and stuff).

If you look in Mahara at the file htdocs/api/xmlrpc/dispatcher.php, you can see a list of all the functions that Mahara exposes via XMLRPC. They're in the Dispatcher->services['sso_out'] array, which maps them from an XMLRPC method name, to an actualy PHP function. This array is a bit confusing, because the XMLRPC method names look like filenames, but they're actually arbitrary strings.

For instance, when the assignment submission plugin in Moodle is requesting a list of all of a user's views from Mahara, it sends a request to Mahara for the method 'mod/assignment/type/mahara/rpclib.php/get_views_for_user', which causes Mahara to locally run the function "get_views_for_user()" in api/xmlrpc/lib.php, and return the values from that.

Unfortunately there isn't a basic "get_status" XMLRPC method or anything like that, in either Moodle or Mahara. But perhaps you could call "auth/mnet/auth.php/user_authorise" with an invalid username, and then check whether you get back a "no such user" response, or a "could not connect" response.

To summarize some of the useful code locations:

  1. The list of Mnet methods exposed by Mahara is in api/xmlrpc/dispatcher.php
  2. The Mnet methods exposed by Moodle are located in a "mnet/db/mnet.php" file within each of the plugins that use Mnet: auth/mnet/db/mnet.php, and portfolio/mahara/db/mnet.php.
  3. In Moodle, for a sample of how to send an MNet request, you can look at the "mnet_send_request()" function in the Mahara assign submission plugin's locallib.php file.
  4. In Mahara, for a sample of how to send an MNet request, you can look in the "request_user_authorise()" function in htdocs/auth/xmlrpc/lib.php

Cheers,
Aaron

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

No branches or pull requests

2 participants