API - Create ExamTestInstance

This API is used to create exam test instance.

API Details

Signature of API call

connection.invokeApi(String uri, String realUserName, Map<String, String> requestParameters);

See details about invoking API in general

 

Parameter 1 - URI

enrollmentService.do

 

Parameter 2 - UserName

Username of the site admin

 

Parameter 3 - Request Parameters

Name Value  
dispatch

createExamTestInstance

 
xml true  
subscriptionId Event Subscription Id  

testId

Test Id whose Instance needs to be added in exam event for this user. (Note: Test must be already present in Event's  EventItem)  

startDate

Test Taken start date. Start date of the learner, represented as epoch time in milliseconds - number of milliseconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds

(Dummy End date is default added as  start date + 60 seconds

 

passed

TestInstance status for this user. This is boolean value to be passed as 'true' / 'false'

 

 
score Float number - total points, optional  

scorePercentage

Float number  - score in percentage terms (this can be only between 0-100). If both score and scorePercentage is passed, then percentage will take precedence.  

 

Response

1. Response on successfully adding user to group

HTTP Response Code = HttpServletResponse.SC_OK

Response XML

<response code="0">
    <msgs>
         <msg>
             <code>0</code>
             <value><![CDATA[Success]]></value>
         </msg>
    </msgs>

</response>

2. Response for unauthorized access

HTTP Response Code = HttpServletResponse.SC_UNAUTHORIZED

Response XML

<response code="-1">
    <msgs>
         <msg>
             <code>0005</code>
             <value><![CDATA[You are not allowed to perform this action.]]></value>
         </msg>
    </msgs>
</response>

 

 

Code Snippet

/* Check API Call for detail */

 

Map<String, String> parameters = new HashMap<String, String>();

populateMapForCreateExam(parameters);

String result = connection.invokeApi("enrollmentService.do", "adminusername", parameters);
System.out.println(result);

 

private void populateMapForCreateExam(Map<String, String> parameters) {
    parameters.put("dispatch", "createExamTestInstance");
    parameters.put("xml", String.valueOf(true));
    parameters.put("subscriptionId", "xxxx-xxxx-xxxx-xxxx");
    parameters.put("testId", "xxxx-xxxx-xxxx-xxxx");
    parameters.put("startDate", "1495163497116"); //Set exam instance  dates of learners

      parameters.put("passed", String.valueOf(true));
}


Rating: