Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Creating a course object fulfillment record

POST course_object_fulfillment.json

Code Block
languagephp
<?php
// Send the creation request
$object_info = array(
  {
	"coid": => 456, // The course object ID
  	"uid": => 200, // User ID
  	"grade_result": => 60, // The object grade, when applicable. Used for reporting. It does not affect complete status.
  	"date_started" =>: 1461613186,
  	"complete": => 0, // This marks the object as incomplete. A setting of 1 allows the user to navigate to the next object immediately
);
$curl = curl_init("http://your-domain.com/course_object_fulfillment");
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); //Your credentials goes here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($object_info));

$json = curl_exec($curl);
}


A successful update  will return the entity "id", which is the course object fulfillment id (cofid) used in any future update calls. For instance, the call above created an object with the cofid of 1000, as seen in the return array below.

Code Block
{
  "uri":"http://your-domain.com/course_object_fulfillment/1000",
  "id":"1000",
  "resource":"course_object_fulfillment",
  "uuid":"d955ee03-0161-4778-9872-7f229b57bad4"
}

Updating a course object fulfillment record

In the call above, the user did not pass the object immediately. They were marked as incomplete, and unable to proceed past the Manual object. In the next call, we will update the same record with a passing grade, recent date, and a completed status, to allow the user to continue past the object.

PUT course_object_fulfillment/1000.json

Code Block
languagephp
<?php{
// Send the update request, via PUT
// Only the attributes being updated need to be sent
$object_info = array(
  "grade_result" =>: 90, // The updated grade
  "date_started": => 1461610021, // The updated date
  "date_completed": => 1461610021, // The completion date
  "complete": => 1, // Mark the object as complete.
);
// Note the course object fulfillment id (cofid) in the URL, for updating
$curl = curl_init("http://your-domain.com/course_object_fulfillment/456.json"); 
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); //Your credentials goes here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($object_info));

$json = curl_exec($curl);
}


A successful update call will return an empty array as a the body, with an HTTP Status Code of 200 OK.

...

It is recommended to run this check before any creation requests, to prevent errors by attempting to create a record that already exists in the system.

...

languagephp

...

GET course_object_fulfillment.json?uid=200&coid=

...

1000