Get Test Instances Details List
This API can be used to get list of test attempts (test instances) for a specific test or survey. The returned data contains full details of the test instance, including the attempted questions and what answer was selected. The API is a restrictive one and can be called by an admin of the site only. Any other user trying to invoke this API would result in an error being returned by the API.
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
reportService.do
Parameter 2 - UserName
Username of any site administrator
Parameter 3 - Request Parameters
Name | Value |
dispatch | getTestInstancesDetails |
testId | guid of test or survey |
optional parameters | |
userId | return data for a specific user corresponding to specified userId |
openId | return data for a specific user corresponding to specified openId |
courseId | for a specific course id |
courseSessionId | for a specific course session id |
eventId | for a specific event (scheduled exam) |
groupId | Group Id of the group for which to fetch the learners data |
userSearchStr | matching username, first/last name, email |
fromDate | test attempt modified date from |
toDate | test attempt modified date to |
Paging parameters | |
currPage | page number to fetch, must be specified for 2nd page onwards. Value of currPage starts with 0. So for page 2 specify currPage = 1 |
numItems | total records in the list, must be specified for 2nd page onwards. You can get the count of records from response of first page. then pass it as-is in subsequent pages. |
pageSize | Number of items in a page |
All date parameters are numbers, represented as epoch time in milliseconds - number of milliseconds that have elapsed since January 1, 1970 (midnight UTC/GMT),
Date filtering note - by default, date filters are converted to BOD and EOD (e.g. from date is converted to beginning of the day and to date is converted to end of day while applying the filtering criteria (similar to report screens in application). If you like to perform exact filtering on the passed date time, then set API_REPORT_USE_EXACT_TIME=true in Site Admin->Site Details->Customization.
Response
1. Response on successfully getting results
HTTP Response Code = HttpServletResponse.SC_OK
Response XML
<response code="0">
<msgs>
<msg>
<code>0</code>
<value>
<![CDATA[ Success ]]>
</value>
</msg>
</msgs>
<data>
<testInstances numItems="9" currPage="0" pageSize="10">
<testinstance id="23ccd842-2d5f-11e9-86ce-0b5eb5752a72"
testId="e4d2f9ec-7caa-11e8-81ab-4891014e86b7" adaptive="false"
randomize="false" instructorOrAdmin="true" checksum="857305255"
evaluated="true" elapsedDuration="322173" canDelete="false">
<student id="e8508aa0-2ef1-11e8-ab3a-0327bc39e9e4"
userName="site1" pictureId="b179511c-5262-11e8-ad0f-dc50fd021256"><![CDATA[ Ajay123 Upadhyaya11 ]]>
</student>
<status>FINISHED</status>
<startDate>1549822225000</startDate>
<completedDate>1549822547000</completedDate>
<timeRemaining>59999617827</timeRemaining>
<pauseCount>0</pauseCount>
<noOfAttempted>5</noOfAttempted>
<showResult>true</showResult>
<totalQuestions>5</totalQuestions>
<courseId>19dd509e-ae72-11e8-813e-2239b7ec7a9c</courseId>
<courseName>
<![CDATA[ aup1 ]]>
</courseName>
<contextStr>
<![CDATA[ CR:19dd509e-ae72-11e8-813e-2239b7ec7a9c ]]>
</contextStr>
<resultStatus>AVAILABLE</resultStatus>
<totalScore>3</totalScore>
<noOfCorrect>3</noOfCorrect>
<noOfIncorrect>2</noOfIncorrect>
<noOfUnknown>0</noOfUnknown>
<pass>true</pass>
<testQuestions>...</testQuestions> see below
</testinstance>
<testinstance id="73f8acd0-2d0d-11e9-86ce-0b5eb5752a72"
testId="e4d2f9ec-7caa-11e8-81ab-4891014e86b7" adaptive="false"
randomize="false" instructorOrAdmin="true" checksum="-125276746"
evaluated="true" elapsedDuration="33477918" canDelete="false">...
</testinstance>
<testinstance id="6d9163ce-2d0c-11e9-86ce-0b5eb5752a72"
testId="e4d2f9ec-7caa-11e8-81ab-4891014e86b7" adaptive="false"
randomize="false" instructorOrAdmin="true" checksum="1403305421"
evaluated="true" elapsedDuration="11906" canDelete="false">...
</testinstance>
<testinstance id="593f2d5c-2d0c-11e9-86ce-0b5eb5752a72"
testId="e4d2f9ec-7caa-11e8-81ab-4891014e86b7" adaptive="false"
randomize="false" instructorOrAdmin="true" checksum="-1992288599"
evaluated="true" elapsedDuration="16654" canDelete="false">...
</testinstance>
<testinstance id="e73d2272-2cfc-11e9-86ce-0b5eb5752a72"
testId="e4d2f9ec-7caa-11e8-81ab-4891014e86b7" adaptive="false"
randomize="false" instructorOrAdmin="true" checksum="406103335"
evaluated="true" elapsedDuration="6602727" canDelete="false">...
</testinstance>
<testinstance id="f92a08f2-2cf1-11e9-86ce-0b5eb5752a72"
testId="e4d2f9ec-7caa-11e8-81ab-4891014e86b7" adaptive="false"
randomize="false" instructorOrAdmin="true" checksum="-1379700523"
evaluated="true" elapsedDuration="4685941" canDelete="false">...
</testinstance>
<testinstance id="1b100934-ae7c-11e8-813e-2239b7ec7a9c"
testId="e4d2f9ec-7caa-11e8-81ab-4891014e86b7" adaptive="false"
randomize="false" instructorOrAdmin="true" checksum="-209097562"
evaluated="true" elapsedDuration="4951" canDelete="false">...</testinstance>
<testinstance id="d09859ae-7f25-11e8-81ab-4891014e86b7"
testId="e4d2f9ec-7caa-11e8-81ab-4891014e86b7" adaptive="false"
randomize="false" instructorOrAdmin="true" checksum="-1587799075"
evaluated="true" elapsedDuration="19301" canDelete="false">...
</testinstance>
<testinstance id="06441f98-7cab-11e8-81ab-4891014e86b7"
testId="e4d2f9ec-7caa-11e8-81ab-4891014e86b7" adaptive="false"
randomize="false" instructorOrAdmin="true" checksum="-2011245894"
evaluated="true" elapsedDuration="21226" canDelete="false">...
</testinstance>
</testInstances>
</data>
</response>
Details inside testQuestions
<testQuestions>
<testQuestion id="db2298ce-2cf1-11e9-86ce-0b5eb5752a72"
openResp="false" attempted="true" responseTime="2012" correct="false"
partiallyCorrect="false" score="0" interactionCtr="1" effectiveSeq="1"
sequence="3">
<comment><![CDATA[]]>
</comment>
<choice id="db2cd87a-2cf1-11e9-86ce-0b5eb5752a72" />
<choice id="db2cf0da-2cf1-11e9-86ce-0b5eb5752a72" />
<choice id="db2caddc-2cf1-11e9-86ce-0b5eb5752a72" />
<choice id="db2d04ee-2cf1-11e9-86ce-0b5eb5752a72" />
<attemptedAnswerString><br>choice text2<br>choice
text3<br>choice text1<br>choice text4<br>
</attemptedAnswerString>
<correctAnswerString><![CDATA[<br>choice text1<br>choice text2<br>choice text3<br>choice text4<br>]]></correctAnswerString>
</testQuestion>
<testQuestion id="e85eb7fc-2cf1-11e9-86ce-0b5eb5752a72"
openResp="false" attempted="true" responseTime="1002" correct="false"
partiallyCorrect="false" score="0" interactionCtr="1" effectiveSeq="3"
sequence="4">
<comment><![CDATA[]]>
</comment>
<choice id="e85f6f94-2cf1-11e9-86ce-0b5eb5752a72" />
<choice id="e85f52fc-2cf1-11e9-86ce-0b5eb5752a72" />
<choice id="e85f886c-2cf1-11e9-86ce-0b5eb5752a72" />
<choice id="e85f9cd0-2cf1-11e9-86ce-0b5eb5752a72" />
<attemptedAnswerString><br>choice text2<br>choice
text1<br>choice text3<br>choice text4<br>
</attemptedAnswerString>
<correctAnswerString><![CDATA[<br>choice text1<br>choice text2<br>choice text3<br>choice text4<br>]]></correctAnswerString>
</testQuestion>
<testQuestion id="f7a2e5e6-7caa-11e8-81ab-4891014e86b7"
openResp="false" attempted="true" responseTime="20042" correct="true"
partiallyCorrect="false" score="1" interactionCtr="1" effectiveSeq="4"
sequence="0">
<comment><![CDATA[]]>
</comment>
<choice id="f7a3f620-7caa-11e8-81ab-4891014e86b7" />
<attemptedAnswerString>A</attemptedAnswerString>
<correctAnswerString><![CDATA[A]]></correctAnswerString>
</testQuestion>
<testQuestion id="f7a60866-7caa-11e8-81ab-4891014e86b7"
openResp="false" attempted="true" responseTime="9026" correct="true"
partiallyCorrect="false" score="1" interactionCtr="1" effectiveSeq="2"
sequence="1">
<comment><![CDATA[]]>
</comment>
<choice id="f7a6e0b0-7caa-11e8-81ab-4891014e86b7" />
<choice id="f7a701c6-7caa-11e8-81ab-4891014e86b7" />
<choice id="f7a71c6a-7caa-11e8-81ab-4891014e86b7" />
<choice id="f7a73aa6-7caa-11e8-81ab-4891014e86b7" />
<attemptedAnswerString><br>choice text1<br>choice
text2<br>choice text3<br>choice text4<br>
</attemptedAnswerString>
<correctAnswerString><![CDATA[<br>choice text1<br>choice text2<br>choice text3<br>choice text4<br>]]></correctAnswerString>
</testQuestion>
<testQuestion id="f7a919c0-7caa-11e8-81ab-4891014e86b7"
openResp="false" attempted="true" responseTime="1001" correct="true"
partiallyCorrect="false" score="1" interactionCtr="1" effectiveSeq="0"
sequence="2">
<comment><![CDATA[]]>
</comment>
<choice id="f7a9c5a0-7caa-11e8-81ab-4891014e86b7" />
<attemptedAnswerString>A</attemptedAnswerString>
<correctAnswerString><![CDATA[A]]></correctAnswerString>
</testQuestion>
</testQuestions>
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 generic code */
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("dispatch", "getTestInstancesDetails");
parameters.put("testId", "e4d2f9ec-7caa-11e8-81ab-4891014e86b7");
String retStr = connection.invokeApi("reportService.do", "chenry", parameters);
System.out.println(retStr);