Hello,
I am extending moodle's core submission plugin to execute curl rest request upon submitting assignment. However it behaves oddly and seemingly does empty request.
I decided to test the code shown below in isolated enviroment that is separate from moodle. Everything worked without issues so i'm left baffled without any clue on whats going on.
CODE (submissionplugin.php) :
public function submit_for_grading($submission) {
$url = 'localhost:8080/snacks';
$asdata = array('asid'=> 2, 'userid' => 3, 'sbm_fpth' => 5);
$builtquery = http_build_query($asdata);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $builtquery);
$result = curl_exec($ch);
echo $result;
curl_close($ch);
}
I am sure i have missed something or i'm executing this logic in wrong place.
Thanks in advance!