Quiz: Implementing xAPI in Intelligent Textbooks¶
Test your understanding of the JavaScript/TypeScript client library, retry logic, error handling, and instrumentation patterns with these review questions.
1. Which three properties define a Level 3 intelligent textbook in this book's framing?¶
- PDF format, hyperlinks, and bookmarks
- Web rendering, genuine interactivity, and structured behavioral instrumentation
- Animations, audio narration, and quiz banks
- Adaptive sequencing, video lectures, and proctoring
Show Answer
The correct answer is B. A Level 3 intelligent textbook renders as web content (HTML/CSS/JavaScript), contains genuinely interactive elements that respond to learner input (MicroSims, quizzes, adaptive branching), and captures behavioral signals from those interactions through structured instrumentation. xAPI is the standard instrumentation layer for Level 3. Levels 1 and 2 are static and non-instrumented respectively. The other options describe surface features but miss the instrumentation requirement.
Concept Tested: Level 3 Intelligent Textbook
2. According to the chapter, an xAPI client library has four responsibilities. Which of the following is NOT one of them?¶
- Statement construction
- Authentication
- Rendering interactive UI components
- Batching and delivery
Show Answer
The correct answer is C. The chapter lists four client library responsibilities: statement construction, authentication, batching and delivery, and error handling. UI rendering is the responsibility of the components that call into the library — MicroSims, quizzes, adaptive branching widgets — not the client library itself. The library's design rule is "every emit site says what happened, the library handles how to send it."
Concept Tested: xAPI Client Library Design
3. A 5xx error is returned from the LRS for a batch POST. What is the correct client behavior?¶
- Drop the batch and surface a permanent error
- Retry with exponential backoff and jitter
- Re-authenticate and re-issue immediately
- Ignore and proceed to the next batch
Show Answer
The correct answer is B. 5xx errors indicate the LRS had a transient problem (overload, bad gateway, deploy in progress). The same payload may succeed seconds from now, so the right behavior is retry with exponential backoff plus random jitter. The jitter prevents thundering-herd retries after a global outage. 4xx errors should not be retried (option A is what you do for 4xx). Re-authentication isn't typically needed for 5xx (option C). Ignoring loses data (option D).
Concept Tested: Retry-With-Backoff Pattern / 5xx Error Patterns
4. Why should a passed/failed statement that ties to a learner's official grade be emitted server-side rather than client-side?¶
- Server-side emission has lower latency
- The browser would not be able to construct a valid Statement object
- Statement authenticity — the browser cannot forge a server-side credential
- xAPI 1.0.3 forbids client-side emission
Show Answer
The correct answer is C. Statement authenticity is the deciding factor. Anyone with developer tools can construct and send statements from the browser as if they were the learner; client-side emission is fine for analytics but should not be the source of truth for grades or certifications. Server-side emission uses a backend credential the browser doesn't have, so the browser cannot forge it. Server-side emission has higher (not lower) latency. Client-side emission is permitted by the spec.
Concept Tested: Server-Side xAPI Emission / Statement Authenticity
5. Which HTTP status code should NOT trigger a retry in a robust client library?¶
- 503 Service Unavailable
- 502 Bad Gateway
- 504 Gateway Timeout
- 401 Unauthorized
Show Answer
The correct answer is D. 4xx errors (including 401 Unauthorized) indicate a client problem — bad credentials, malformed payload, duplicate UUID, failed precondition. Retrying with the same payload will fail the same way. Retrying 4xx in a tight loop is the most common way to accidentally DDOS your own LRS. The 5xx codes (503, 502, 504) all indicate transient server problems and should be retried with backoff.
Concept Tested: 4xx Error Patterns
6. The chapter's retry-with-backoff implementation includes random jitter (Math.random() * 1000). What problem does the jitter solve?¶
- It prevents many clients from retrying in lockstep after a global outage (thundering herd)
- It compensates for clock skew between client and server
- It satisfies an xAPI specification requirement
- It improves SHA-2 hash entropy for attachment verification
Show Answer
The correct answer is A. The random jitter prevents the thundering-herd problem — without jitter, all clients that backed off the same amount will retry simultaneously when the LRS recovers, immediately re-overloading it. With jitter, retries spread across a window. The xAPI spec doesn't mandate jitter. Clock skew is unrelated. Hash entropy is unrelated to retry timing.
Concept Tested: Retry-With-Backoff Pattern
7. A textbook supports both modern browsers and IE11. What is the chapter's recommended polyfill strategy?¶
- Always ship the full polyfill bundle to every browser for safety
- Detect older browsers at runtime and dynamically import polyfills only when needed
- Refuse to serve the textbook to older browsers
- Manually rewrite Fetch calls as XMLHttpRequest
Show Answer
The correct answer is B. The chapter recommends conditional dynamic imports: if (!("fetch" in window)) { await import("whatwg-fetch"); }. These imports cost nothing in modern browsers (the condition is false) and rescue older ones. Always shipping polyfills bloats the bundle for every learner. Refusing service is a poor accessibility outcome. Manual XHR rewrites bypass the value of having a clean Fetch-based library.
Concept Tested: Polyfill Strategy / Browser Compatibility
8. A quiz instrumentation pattern emits four statements per attempt. Which sequence is correct, and what ties them together?¶
- attempted, scored, passed/failed, completed — tied by a shared registration UUID
- completed, attempted, scored, passed/failed — tied by the activity IRI
- interacted, scored, completed, terminated — tied by the platform name
- attempted, completed, passed/failed, scored — tied by the timestamp range
Show Answer
The correct answer is A. The canonical quiz sequence is attempted (start), scored (a score is recorded), then passed or failed (success outcome), then completed. All four share a single registration UUID minted at quiz start, which is the analytics-friendly correlation key. The other sequences either reorder these incorrectly or use the wrong tie-key (the activity IRI, platform name, or timestamps are not designed for per-attempt correlation).
Concept Tested: Quiz Instrumentation
9. The xAPI client library exposes two public methods: send and flush. What is flush for?¶
- Forcing buffered statements to be sent immediately, typically at page-unload
- Removing all statements from the LRS that match a query
- Flushing browser cache to prevent stale credentials
- Triggering a full re-authentication handshake
Show Answer
The correct answer is A. flush forces any buffered statements to be sent immediately, used at page-unload time so in-flight events aren't lost when the learner closes the tab. send queues a statement for delivery. The library buffers and batches by default for efficiency. The other options misdescribe flush — it does not affect the LRS's stored data, browser cache, or authentication state.
Concept Tested: JavaScript xAPI Client Library
10. A team is investigating production health by querying LRS server logs. A sudden spike in 401 status codes most likely indicates what?¶
- A recent code change broke statement construction
- The LRS itself is unhealthy
- A client credential expired or was revoked
- The xAPI version header is missing
Show Answer
The correct answer is C. 401 Unauthorized means the credential was rejected — typically because a token expired, was revoked, or never made it to the request. A spike in 400 (bad request) would suggest a code change broke statement construction. A spike in 5xx would indicate LRS health issues. Missing version headers usually produce 400, not 401. The chapter's log-analysis playbook explicitly maps each status-code pattern to its likely cause.
Concept Tested: LRS Server Log Analysis