Can external software insert data into the gradebook?

Can external software insert data into the gradebook?

by Tony Gardner-Medwin -
Number of replies: 3
Picture of Particularly helpful Moodlers Picture of Plugin developers

Excuse if this is something in the documentation, but I haven't found it. I want external software (written in PHP) to be able to send grades to Moodle to go into a specified column in the gradebook for a specified student.

I can do this nicely in WebCT 4.1. The code of course has to be in a secure place, and contains a secret 'key' to allow info sent to the VLE to be inserted. But it is a really useful facility where grades are generated by external software. Everything happens wthout staff intervention: the student calls the external software from within the VLE, and the grade is returned on completion, checking on the way that the same student is still logged in to the VLE. Is this possible with Moodle? I hope so!

 

In reply to Tony Gardner-Medwin

Re: Can external software insert data into the gradebook?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I think it is possible, but not currently documented or easy. I just found the mysterious line

if (defined('USER_KEY_LOGIN')) {

in grade/import/xml/import.php, which I think is something to do with letting remote systems trigger an import without having to authenticate with Moodle.

It would probably be easier to write a new, very small gradebook plugin that gives you a web service interface to import grades. Look at the code in grade/import/lib.php to see what you have to do on the Moodle side to poke a grade into the gradebook, then wrap that in a web service.


In reply to Tim Hunt

Re: Can external software insert data into the gradebook?

by Tony Gardner-Medwin -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Thanks Tim. 'USER_KEY_LOGIN' only seems to be set by the function require_user_key_login($script, $instance=null) in lib/moodlelib.php, which in turn is only called in an import context by grade/import/xml/fetch.php. This seems to be a regular import plugin, as I understand it, initiated by a teacher fetching grades for insertion from a file somewhere. Do you think there are examples of external sotware triggering such inserts instead of a teacher? I'm afraid I'm lost on how to approach coding such a thing unless I can start from an example - of your concept of "wrap that in a web service". TGM

In reply to Tim Hunt

Re: Can external software insert data into the gradebook?

by Tony Gardner-Medwin -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Repeat of the first part of the (11 March) post above, because it seems not to be rendering properly. (I've no idea why not!)

Thanks Tim. USER_KEY_LOGIN only seems to be set by the function require_user_key_login () in lib/moodlelib.php, which in turn is only called in an import context by grade/import/xml/fetch.php.

TGM