danmarsden / moodle-plagiarism_urkund

Ouriginal plagiarism plugin for Moodle (previously called Urkund)
https://ouriginal.com/
12 stars 19 forks source link

use JSON instead of xml when communicating with URKUND #128

Closed danmarsden closed 4 years ago

danmarsden commented 4 years ago

When the Urkund api was first created xml was the only option, but now it supports JSON we'd like to convert to using json for validating the response in urkund_get_score and plagiarism_urkund_update_allowed_filetypes

To do this we need to add a new accept header to the curl calls eg here: https://github.com/danmarsden/moodle-plagiarism_urkund/blob/master/lib.php#L1420

should now be this: $headers = array('Accept: application/json', 'Accept-Language: '.$plagiarismsettings['urkund_lang']);

and then instead of using simplexml we can use json functions.

Also - on an error state, we store the response in the errorresponse field, here: https://github.com/danmarsden/moodle-plagiarism_urkund/blob/master/lib.php#L1456

and then parse that when showing error data in the get_links() table https://github.com/danmarsden/moodle-plagiarism_urkund/blob/master/lib.php#L251