There is one main profile type in EthosCE, used to store learner information, such as first name, last name, location, and any custom fields. Instructions on creating a user with the default profile are found at Creating a user via web service. Customers using the Faculty Management Add-on feature have access to two additional profile types, Faculty Bio and Disclosure. The PHP script below details the calls required to populate the more complex fields found in these types. It will check a user exists in the system, and create a new account if not found. It then creates a main profile, faculty bio with biography text, and disclosure with two financial relationships.
...
language | php |
---|
...
(type: bio) and Financial Relationships (type: disclosure).
The main Profile
The two date formats accepted are ISO 8601 (2018-07-28T12:00:00Z) and Epoch (1532779200). The format required may differ depending on which field you are updating.
Code Block | ||
---|---|---|
| ||
{
"user": "123", // The internal user id (uid) to associate the profile
"label": "Profile",
"type": "profile", // An internal machine name
"field_first_name": "John",
"field_middle_name": "Middle",
"field_last_name": "Smith",
"field_profile_location":
{
"street": "1520 Locust Street",
"additional": "Suite 1000",
"city": "Philadelphia",
"province": "PA",
"postal_code": "19102",
"country": "us"
},
"field_date_of_birth": "-2077668614" // Feb 29 1904.
"field_date": "-2077668614" // Feb 29 1904.
}
|
A creation call will return the profile id (pid) used for additional updates, or adding more complex field collection fields such as Creating "Boards" values via web services.
Faculty profiles
Faculty Bio
Faculty bios contain both text fields like Credentials and WYSIWYG text areas, such as Biography.
Code Block |
---|
{ "user": "123", "label": "Bio", "type": "bio", "field_fm_biography": { "value": "This is the learner <b>bio</b>",', 'format' => ' "format": "filtered_html', // Text format is required. Filtered HTML is availabe to all learners ), 'field_credentials' => '" }, "field_credentials": "PhD, MD', ); // Create the bio curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($bio)); $json = curl_exec($curl); $response = json_decode($json); // User disclosure data $disclosure = array( 'user' => $userInfo->id, 'label' => 'Disclosure', 'type' => 'disclosure', 'field_fm_disclose' => 1, ); // Create the disclosure curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($disclosure)); $json = curl_exec($curl); $disclosure_new = json_decode($json); // Add financial relationships field collections to the disclosure $financial_info = array( // Field 1 array( 'field_fm_attribution' => 'Other', 'field_fm_commercial_interest' => 'Pharma Clinic', 'field_fm_dates' => array( 'value' => "2014-08-20T00:00:00Z",// Dates must be sent in this ISO format, Y-m-d\TH:i:sZ, to be properly read from the database 'value2' => "2014-08-28T00:00:00Z", ), 'field_fm_relationship_type' => 'Other', 'field_fm_relationship_type_other' => 'I bought supplies which were reimbursed.', 'field_name' => 'field_fm_financial_relationships', 'host_entity' => array( 'id' => $disclosure_new->id, 'resource' => "profile2", ), ), // Field 2 array( 'field_fm_attribution' => 'Self', 'field_fm_commercial_interest' => 'Pharma Clinic', 'field_fm_dates' => array( 'value' => "2015-08-20T00:00:00Z", // Dates must be sent in this ISO format, Y-m-d\TH:i:sZ, to be properly read from the database 'value2' => "2015-08-28T00:00:00Z", ), 'field_fm_relationship_type' => 'Employment', 'field_fm_relationship_type_other' => 'Paid sponsorship', 'field_name' => 'field_fm_financial_relationships', 'host_entity' => array( 'id' => $disclosure_new->id, 'resource' => "profile2", ), ), ); curl_setopt($curl, CURLOPT_URL, "http://your-domain.com/field_collection_item.json"); foreach ($financial_info as $item) { curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($item)); $json = curl_exec($curl); $response = json_decode($json); print "\nCreated financial relationship " . $json; } " } |
Financial Relationships disclosure
Financial relationships profile is intended to collect individual disclosures for each faculty member. The main data sets are collected via Creating "Boards" values via web services.
Code Block |
---|
{
"user": 123,
"label": "Financial Relationships",
"type": "disclosure",
"field_fm_disclose": 1 // Set to 0 if the account has no disclosures to add
} |