How to take an assessment
Syntax
- https://assessmentcenter.net/ac_api/2014-01/Participants/{AssessmentOID}
Remarks
- This API will return the current question determined by the IRT algorithm.
- Post the 'ItemResponseOID' and 'Value' attributes from the Map node to the API as ItemResponseOID and Response parameters.
- When the DateFinished attribute of the top node is not '', then the assessment is over.
Sample code for https://assessmentcenter.net/ac_api/2014-01/Participants
<script langauge="javascript" src="jquery-1.7.1.min.js"></script> <script language="javascript" src="crypto.js"></script> <script type='text/javascript' version='1.3'> var Server = https://assessmentcenter.net/ac_api; var ItemResponseOID = "0ADCCAA5-1A10-4FED-B2A6-E4FFF4FE3725"; // Sample item response -- replace with your ItemResponseOID var Response = "1"; // Sample response -- replace with your Response var UID = 0; function renderScreen() { var postedData =""; if (ItemResponseOID != "") { postedData ="ItemResponseOID=" + ItemResponseOID + "&Response=" + Response ; } $.ajax({ url: Server + "Participants/" + Orders[currentOrder] + ".json", cache: false, type: "POST", data: postedData, dataType: "json", beforeSend: function (xhr) { var bytes = Crypto.charenc.Binary.stringToBytes(document.getElementById("txtRegistration").value + ":" + document.getElementById("txtToken").value); var base64 = Crypto.util.bytesToBase64(bytes); xhr.setRequestHeader("Authorization", "Basic " + base64); }, success: function (data) { if (data.DateFinished != '') { currentOrder = currentOrder + 1; if (currentOrder < Orders.length) { renderScreen(); return; } document.getElementById("Content").innerHTML = "You have finished the assessment.<br /> Thank you"; return } var screen = ""; var HasBitWiseValues = false; var HasMultipleItems = false; if (data.Items.length > 1) { HasMultipleItems = true; } if (!HasMultipleItems) { for (var i = 0; i < data.Items.length; i++) { for (var j = 0; j < data.Items[i].Elements.length; j++) { if (typeof (data.Items[i].Elements[j].Map) == 'undefined') { screen = screen + "<div style=\'height: 30px\' >" + data.Items[i].Elements[j].Description + "</div>" } else { for (var k = 0; k < data.Items[i].Elements[j].Map.length; k++) { switch (data.Items[i].Elements[j].Map[k].Description) { case "INFORMATIONAL": screen = screen + "<div style=\'height: 50px\' ><input type=\'button\' class='btn-submit' id=\'" + data.Items[i].Elements[j].Map[k].Value + "\' name=\'" + data.Items[i].Elements[j].Map[k].ItemResponseOID + "\' value=\'" + "Save" + "\' onclick=getResponse('" + data.Items[i].Elements[j].Map[k].Value + "') />" + "</div>"; break; case "TEXT": screen = screen + "<div style=\'height: 50px\' ><input type=\'text\' id=\'" + data.Items[i].Elements[j].Map[k].Value + "\' name=\'" + data.Items[i].Elements[j].Map[k].ItemResponseOID + "\' value=\'" + data.Items[i].Elements[j].Map[k].Description + "\' />" + "</div>"; screen = screen + "<div style=\'height: 50px\' ><input type=\'button\' class='btn-submit' id=\'" + "btnSave" + "\' name=\'" + "btnSave" + "\' value=\'" + "Save" + "\' onclick=getResponse('" + data.Items[i].Elements[j].Map[k].Value + "') />" + "</div>"; break; default: ItemResponseOID = data.Items[i].Elements[j].Map[k].ItemResponseOID; Response = data.Items[i].Elements[j].Map[k].Value; if (data.Items[i].Elements[j].Map[k].DataType == "bitwise") { HasBitWiseValues = true; screen = screen + "<div style=\'height: 20px\' ><input type=\'checkbox\' id=\'" + data.Items[i].Elements[j].Map[k].ItemResponseOID + "\' name=\'" + data.Items[i].FormItemOID + "\' value=\'" + data.Items[i].Elements[j].Map[k].Value + "\' onclick=addResponse(this) />" + data.Items[i].Elements[j].Map[k].Description + "</div>"; } else { screen = screen + "<div style=\'height: 50px\' ><input type=\'button\' class='btn-submit' id=\'" + data.Items[i].Elements[j].Map[k].Value + "\' name=\'" + data.Items[i].Elements[j].Map[k].ItemResponseOID + "\' value=\'" + data.Items[i].Elements[j].Map[k].Description + "\' onclick=getResponse('" + data.Items[i].Elements[j].Map[k].Value + "') />" + "</div>"; } } } screen = screen + "<div style=\'height: 50px\' ><input type=\'button\' class='btn-submit' id=\'" + '00000000-0000-0000-0000-000000000000' + "\' name=\'" + '00000000-0000-0000-0000-000000000000' + "\' value=\'" + 'SKIP' + "\' onclick=getResponse('" + '00000000-0000-0000-0000-000000000000' + "') />" + "</div>"; } } if (HasBitWiseValues) { screen = screen + "<div style=\'height: 50px\' ><input type=\'text\' id=\'" + data.Items[i].FormItemOID + "\' name=\'" + data.Items[i].FormItemOID + "\' value=\'0\' />" + "</div>"; } } } else { /* Stem (e.g., "Thinking about how your illness...") */ screen += "<div style=\'height: 50px; text-align: bottom\'>" + data.Items[0].Elements[0].Description + "</div>"; /* Question */ screen += "<div style=\'height: 40px; font-style: italic\'>" + data.Items[0].Elements[1].Description + "</div>"; screen += "<table>"; /* "How true was this before/since your illness?" */ screen += "<tr>"; screen += "<td width=\'50%\'><div style=\'height: 20px\'>" + data.Items[1].Elements[1].Description + "</div></td>"; screen += "<td width=\'10px\'></td>"; screen += "<td><div style=\'height: 20px\'>" + data.Items[2].Elements[1].Description + "</div></td>"; screen += "</tr>"; /* Answers */ theQuestion = data.Items[0].FormItemOID; for (var i = 0; i < 5; i++) { screen += "<tr>"; screen += "<td><div style=\'height: 50px\'><input type=\'button\' class=\'btn-submit\' id=\'" + data.Items[1].Elements[2].Map[i].FormItemOID + "\' name=\'" + data.Items[1].Elements[2].Map[i].Value + "\' value=\'" + data.Items[1].Elements[2].Map[i].Description + "\' onclick=getResponseMultiple(this) />" + "</div>"; screen += "<td width=\'10px\'></td>"; screen += "<td><div style=\'height: 50px\'><input type=\'button\' class=\'btn-submit\' id=\'" + data.Items[2].Elements[2].Map[i].FormItemOID + "\' name=\'" + data.Items[2].Elements[2].Map[i].Value + "\' value=\'" + data.Items[2].Elements[2].Map[i].Description + "\' onclick=getResponseMultiple(this) />" + "</div>"; screen += "</tr>" } screen += "<tr><td colspan=\'3\' style=\'height: 70px; text-align: center; vertical-align: bottom\'><div><input type=\'button\' class='btn-submit' id=\'btnSave\' name=\'btnSave\' value=\'Save\' onclick=getResponseSave()></div></td></tr>"; screen += "</table>"; } document.getElementById("Content").innerHTML = screen; }, error: function (jqXHR, textStatus, errorThrown) { alert('renderScreen: ' + jqXHR.responseText + ':' + textStatus + ':' + errorThrown); } }) }
Based on twillio example to call RESTful services. (http://www.twilio.com/docs/api/rest)
using System; using System.Collections; using System.Configuration; using System.IO; using System.Net; using System.Web; using System.Text; using System.Text.RegularExpressions; public class TestHarness { static void Main(string[] args) { string REGISTRATIONID ="31839849-ECE0-4F5E-BEAE-3D655ED65E31"; // Sample registration -- replace with your RegistrationOID string TOKEN ="F3738486-5A7D-41EF-8044-DCBAF800E2D4"; // Sample token -- replace with your TokenOID string AssessmentOID ="4F321A3F-FFFE-46DA-994E-C7415FC75C66"; // Sample AssessmentOID -- replace with your OID from Assessment endpoint response string API_URL = "https://assessmentcenter.net/ac_api/2014-01/Participants/" + AssessmentOID + ".xml"; string authstring = Convert.ToBase64String(Encoding.ASCII.GetBytes(String.Format("{0}:{1}", REGISTRATIONID, TOKEN))); ServicePointManager.Expect100Continue = false; Byte[] postbytes = Encoding.ASCII.GetBytes( "ItemResponseOID=0ADCCAA5-1A10-4FED-B2A6-E4FFF4FE3725&Response=1"); // ItemResponseOID represents the primary key to response option user has selected. WebClient client = new WebClient(); client.Headers.Add("Authorization", String.Format("Basic {0}", authstring)); client.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); byte[] resp = client.UploadData(API_URL, "post", postbytes); Console.WriteLine(Encoding.ASCII.GetString(resp)); } }
// Requesting API to administer an Assessment
Request:https://assessmentcenter.net/ac_api/2014-01/Participants/{AssessmentID}.json
Response:
Request:https://assessmentcenter.net/ac_api/2014-01/Participants/{AssessmentID}.json
Response:
{ "DateFinished": "", "Items": [ { "FormItemOID": "FEE9A6CC-7492-466B-A2E0-443726B26F9D", "ID": "4196R1", "Order": "17", "Elements": [ { "ElementOID": "8AB8BA58-3BB0-40B6-B656-C24F1169069B", "Description": "In the past 7 days", "ElementOrder": "1" }, { "ElementOID": "635B60F1-FDB0-48FA-A349-CE3967263630", "Description": "I was too tired to enjoy the things I like to do.", "ElementOrder": "2" }, { "ElementOID": "C08BDEB7-358E-4CB6-BD43-54A234D2D75A", "Description": "ContainerForC08BDEB7-358E-4CB6-BD43-54A234D2D75A", "ElementOrder": "3", "Map": [ { "ElementOID": "00483AA5-3F7A-47A7-85ED-B8158CAD3441", "Description": "Never", "FormItemOID": "FEE9A6CC-7492-466B-A2E0-443726B26F9D", "ItemResponseOID": "0ADCCAA5-1A10-4FED-B2A6-E4FFF4FE3725", "Value": "1", "Position": "1" }, { "ElementOID": "463E034D-37AD-4B0B-836D-E8739DD54B48", "Description": "Almost Never", "FormItemOID": "FEE9A6CC-7492-466B-A2E0-443726B26F9D", "ItemResponseOID": "EA09803E-00AA-4B53-885F-01869502983A", "Value": "2", "Position": "2" }, { "ElementOID": "025469C3-CDE6-480C-99B9-33DF319C369A", "Description": "Sometimes", "FormItemOID": "FEE9A6CC-7492-466B-A2E0-443726B26F9D", "ItemResponseOID": "7885C54E-CF21-4D37-9317-E2634198D491", "Value": "3", "Position": "3" }, { "ElementOID": "2B092F99-1551-4871-8D42-6AD280AFEB33", "Description": "Often", "FormItemOID": "FEE9A6CC-7492-466B-A2E0-443726B26F9D", "ItemResponseOID": "4CAA6EAC-446A-4B89-8EA8-073462FAF0C6", "Value": "4", "Position": "4" }, { "ElementOID": "DA3C4987-6335-448E-A95F-855BD4ED0276", "Description": "Almost Always", "FormItemOID": "FEE9A6CC-7492-466B-A2E0-443726B26F9D", "ItemResponseOID": "870C172B-ABA9-4896-BCDC-C89E79E22056", "Value": "5", "Position": "5" } ] } ] } ] }
// Requesting API to administer an Assessment
Request:https://assessmentcenter.net/ac_api/2014-01/Participants/{AssessmentID}.xml
Response:
Request:https://assessmentcenter.net/ac_api/2014-01/Participants/{AssessmentID}.xml
Response:
<Form DateFinished="" Name="PROMIS pediatric item bank for fatigue."> <Item FormItemOID="FEE9A6CC-7492-466B-A2E0-443726B26F9D" ID="4196R1" Order="17"> <Element ElementOID="8AB8BA58-3BB0-40B6-B656-C24F1169069B" Description="In the past 7 days" ElementOrder="1" /> <Element ElementOID="635B60F1-FDB0-48FA-A349-CE3967263630" Description="I was too tired to enjoy the things I like to do." ElementOrder="2" /> <Element ElementOID="C08BDEB7-358E-4CB6-BD43-54A234D2D75A" Description="ContainerForC08BDEB7-358E-4CB6-BD43-54A234D2D75A" ElementOrder="3"> <Map ElementOID="00483AA5-3F7A-47A7-85ED-B8158CAD3441" Description="Never" FormItemOID="FEE9A6CC-7492-466B-A2E0-443726B26F9D" ItemResponseOID="0ADCCAA5-1A10-4FED-B2A6-E4FFF4FE3725" Value="1" Position="1" /> <Map ElementOID="463E034D-37AD-4B0B-836D-E8739DD54B48" Description="Almost Never" FormItemOID="FEE9A6CC-7492-466B-A2E0-443726B26F9D" ItemResponseOID="EA09803E-00AA-4B53-885F-01869502983A" Value="2" Position="2" /> <Map ElementOID="025469C3-CDE6-480C-99B9-33DF319C369A" Description="Sometimes" FormItemOID="FEE9A6CC-7492-466B-A2E0-443726B26F9D" ItemResponseOID="7885C54E-CF21-4D37-9317-E2634198D491" Value="3" Position="3" /> <Map ElementOID="2B092F99-1551-4871-8D42-6AD280AFEB33" Description="Often" FormItemOID="FEE9A6CC-7492-466B-A2E0-443726B26F9D" ItemResponseOID="4CAA6EAC-446A-4B89-8EA8-073462FAF0C6" Value="4" Position="4" /> <Map ElementOID="DA3C4987-6335-448E-A95F-855BD4ED0276" Description="Almost Always" FormItemOID="FEE9A6CC-7492-466B-A2E0-443726B26F9D" ItemResponseOID="870C172B-ABA9-4896-BCDC-C89E79E22056" Value="5" Position="5" /> </Element> </Item> </Form>