Viewing All Results
You can also load a summary table of all test attempts, containing start and end times, Trust Scores, and more. The table looks like this.
The .showResults() method
.showResults() methodUnlike a single report, this endpoint fetches all test attempts. The credentials object cannot use a single testAttemptId. Instead, it requires the current UNIX time in seconds (10 digits).
In JS, you can get this with Math.floor(Date.now() / 1000). This is the unixTimestamp variable in credentials. If unixTimestamp is more than 60 seconds older than the server's current time, the server returns a 403 Forbidden response.
Hash the UNIX time the same way you hash the Test Attempt ID, and send it as hashedUnixTimestamp in credentials. This approach ensures that:
- Only someone with the
CLIENT_SECRETcan produce a valid hash - The time constraint on
unixTimestampprevents a leaked hash from being reused indefinitely
const unixTimestamp = Math.floor(Date.now() / 1000)
const hashedUnixTimestamp = getHashedValue(unixTimestamp, CLIENT_SECRET)
const credentials = {
clientId: CLIENT_ID,
unixTimestamp: unixTimestamp,
hashedUnixTimestamp: hashedUnixTimestamp
}
const apInst = new AutoProctor(credentials)
const resultsOptions = {...}
apInst.showResults(resultsOptions)
The reportUrlPrefix
reportUrlPrefixEach row in the results table includes a link to that test attempt's report. The reportUrlPrefix option controls the URL prefix for these links. For example, if the results table is loaded on yourwebsite.com/ap/results and you want reports at yourwebsite.com/ap/results/abc123, set reportUrlPrefix to /ap/results.
With reportUrlPrefix = /ap/results, a test attempt with ID xyz456 links to /ap/results/xyz456. Set the option to null to hide report links. All links open in a new tab (target="_blank").
You must still handle rendering the report at the linked URL.
reportUrlPrefix only inserts the hyperlink into the table — it does not
render the report page.
Grouping tests with the lookupKey
If you have used a lookupKey while setting up the test attempt, you can restrict the results to only those with that lookupKey. See Lookup Key for details.
The resultsOptions object
resultsOptions objectThe resultsOptions object accepts the following keys:
| key | datatype | meaning | default |
|---|---|---|---|
reportUrlPrefix | str | The string that gets prefixed to the testAttemptId to load the report for that Attempt | /ap/reports |
resultsDOMId | str | The DOM element to load the results table onto | ap-results |
lookupKey | str | The lookup key by which to filter results | null |
includeUnfinished | bool | Should tests that have not been marked as finished be shown in the table | false |
columnsToHide | array | Array of keys for the columns that you want to hide. Possible keys are "index", "name", "email", "startedAt", "finishedAt", "trustScore", "reportUrl" | null |
If resultsDOMId isn't specified, a <div> is created with the default value and inserted at the end of the <body> element. If it is specified, but the element doesn't exist, a div is created and with that ID inserted at the end of the <body> element.
Getting the results as a JSON
To render the data using your own UI instead of the SDK's built-in table, call the .getResults() method:
const results = apInst.getResults(resultsOptions)
This method takes the same options as showResults(), except for reportUrlPrefix and resultsDOMId. It returns JSON with the following structure:
[
{
"trustScore": 0.79,
"testAttemptId": "1639076",
"startedAt": "2023-01-26T09:22:43.050316+00:00",
"finishedAt": "2023-01-26T09:23:09.273894+00:00",
"miscData": {
"userDetails": null
},
"userAgentString": null
},
{
"trustScore": 0.23,
"testAttemptId": "2576806",
"startedAt": "2021-12-12T12:38:43.302000+00:00",
"finishedAt": "2021-12-12T12:39:59.448418+00:00",
"miscData": {
"userDetails": {
"name": "Tom Sawyer", "email": "tomsawyer@example.com"
}
},
"userAgentString": "Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 desktop Safari/537.36",
"lookupKey": "abc"
},
{
"testAttemptId": "6137469",
"startedAt": "2021-12-12T12:41:10.301000+00:00",
"userAgentString": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
"trustScore": null,
"finishedAt": null
}
]