Forums | Mahara Community
Support
/
Error adding Moodle assignment
16 December 2022, 2:51
Posted this yesterday and realise that it was unreadable for some reason.
Moodle 3.11.11, Mahara 22.10.
Adding an Assignment with a Mahara submission type. "New" web service plugin. When saving, this happens...
16 December 2022, 4:27
It seems to be going wrong in classes/mahara_oauth.php in the 'request' function.
I trapped the error and dumped the curl object
So it seems to be the dreaded curl error 3 'malformed', but I still can't see why...
object(curl)#126 (19) {
["cache"]=>
bool(false)
["proxy"]=>
bool(false)
["version"]=>
string(7) "0.4 dev"
["response"]=>
array(0) {
}
["rawresponse"]=>
array(0) {
}
["header"]=>
array(3) {
[0]=>
string(7) "Expect:"
[1]=>
string(312) "Authorization: OAuth alt="json", oauth_consumer_key="", oauth_nonce="b46aaaad22580af8f46d9614cad8dc57", oauth_signature="%2FdekCBgh%2BDb4BKDevlz%2Fp%2F4C%2B5U%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1671117857", oauth_token="", oauth_version="1.0", wsfunction="mahara_user_get_extended_context""
[2]=>
string(67) "User-Agent: MoodleBot/3.11 (+https://blah.ac.uk/moodle311)"
}
["info"]=>
array(37) {
["url"]=>
string(27) "/webservice/rest/server.php"
["content_type"]=>
NULL
["http_code"]=>
int(0)
["header_size"]=>
int(0)
["request_size"]=>
int(0)
["filetime"]=>
int(-1)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(0)
["namelookup_time"]=>
float(0)
["connect_time"]=>
float(0)
["pretransfer_time"]=>
float(0)
["size_upload"]=>
float(0)
["size_download"]=>
float(0)
["speed_download"]=>
float(0)
["speed_upload"]=>
float(0)
["download_content_length"]=>
float(-1)
["upload_content_length"]=>
float(-1)
["starttransfer_time"]=>
float(0)
["redirect_time"]=>
float(0)
["redirect_url"]=>
string(0) ""
["primary_ip"]=>
string(0) ""
["certinfo"]=>
array(0) {
}
["primary_port"]=>
int(0)
["local_ip"]=>
string(0) ""
["local_port"]=>
int(0)
["http_version"]=>
int(0)
["protocol"]=>
int(0)
["ssl_verifyresult"]=>
int(0)
["scheme"]=>
string(0) ""
["appconnect_time_us"]=>
int(0)
["connect_time_us"]=>
int(0)
["namelookup_time_us"]=>
int(0)
["pretransfer_time_us"]=>
int(0)
["redirect_time_us"]=>
int(0)
["starttransfer_time_us"]=>
int(0)
["total_time_us"]=>
int(0)
}
["error"]=>
string(15) " malformed"
["errno"]=>
int(3)
["emulateredirects"]=>
bool(true)
["options":"curl":private]=>
array(15) {
["CURLOPT_USERAGENT"]=>
string(55) "MoodleBot/3.11 (+https://blah.ac.uk/moodle311)"
["CURLOPT_HEADER"]=>
int(0)
["CURLOPT_NOBODY"]=>
int(0)
["CURLOPT_FOLLOWLOCATION"]=>
int(1)
["CURLOPT_MAXREDIRS"]=>
int(10)
["CURLOPT_ENCODING"]=>
string(0) ""
["CURLOPT_RETURNTRANSFER"]=>
int(1)
["CURLOPT_SSL_VERIFYPEER"]=>
int(0)
["CURLOPT_SSL_VERIFYHOST"]=>
int(2)
["CURLOPT_CONNECTTIMEOUT"]=>
int(30)
["CURLOPT_URL"]=>
string(27) "/webservice/rest/server.php"
["CURLOPT_POST"]=>
int(1)
["CURLOPT_POSTFIELDS"]=>
array(2) {
["wsfunction"]=>
string(32) "mahara_user_get_extended_context"
["alt"]=>
string(4) "json"
}
["CURLOPT_PROTOCOLS"]=>
int(3)
["CURLOPT_REDIR_PROTOCOLS"]=>
int(3)
}
["proxy_host":"curl":private]=>
string(0) ""
["proxy_auth":"curl":private]=>
string(0) ""
["proxy_type":"curl":private]=>
string(0) ""
["debug":"curl":private]=>
bool(false)
["cookie":"curl":private]=>
bool(false)
["responsefinished":"curl":private]=>
bool(false)
["securityhelper":"curl":private]=>
object(core\files\curl_security_helper)#127 (1) {
["transportschemes":protected]=>
array(2) {
["http"]=>
int(80)
["https"]=>
int(443)
}
}
["ignoresecurity":"curl":private]=>
bool(false)
}
16 December 2022, 4:48
So this is really strange....
In the funtion webservice_call() in locallib.php (in the Moodle code), there is a line
$endpoint = $this->get_config('url') .
It looks wrong to me. It doesn't return anything. What I think it should be is...
$endpoint = get_config('assignsubmission_maharaws', 'url') .
...which I have tested and works.
But that's not a new line - so how did it ever work?
$this->get_config() appears to access the mdl_assign_plugin_config table which on my sites only have some 'enabled' settings. Anyway, I assume that the plugin is trying to do something clever to get either the globally set URL or the one in the individual assignment setting - but it's not working. I'm getting pretty lost at this point so I think it's worth asking in case you have seen this before.
16 December 2022, 5:37
Essentially, it's trying the OAuth request *before* it's running save_settings() in locallib.php.
The upshot being that the settings aren't there and the webservice call fails.
Why save_settings() isn't getting called, I have no idea.
16 December 2022, 23:54
Got it - https://github.com/catalyst/moodle-assignsubmission_maharaws/issues/50
If you don't have the 'assignsubmission/maharaws:configure' capability then it fails horribly as described above :(