@schoolio/player 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +90 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # @schoolio/player
2
2
 
3
- A React component for loading and playing quizzes from Quiz Engine.
3
+ React components for loading quizzes and displaying attempt results from Quiz Engine.
4
+
5
+ ## Components
6
+
7
+ - **QuizPlayer** - Interactive quiz-taking component
8
+ - **AttemptViewer** - Displays quiz attempt results with detailed breakdown
4
9
 
5
10
  ## Installation
6
11
 
@@ -138,6 +143,90 @@ await client.updateAttempt(attempt.id, {
138
143
  });
139
144
  ```
140
145
 
146
+ ---
147
+
148
+ ## AttemptViewer
149
+
150
+ The `AttemptViewer` component displays quiz attempt results with a summary and detailed question-by-question breakdown.
151
+
152
+ ### Usage
153
+
154
+ ```tsx
155
+ import { AttemptViewer } from '@schoolio/player';
156
+
157
+ function MyResultsPage() {
158
+ return (
159
+ <AttemptViewer
160
+ attemptId={123}
161
+ apiBaseUrl="https://your-quiz-engine-url.com"
162
+ />
163
+ );
164
+ }
165
+ ```
166
+
167
+ ### Props
168
+
169
+ | Prop | Type | Required | Description |
170
+ |------|------|----------|-------------|
171
+ | `attemptId` | `number` | Yes | The ID of the quiz attempt to display |
172
+ | `apiBaseUrl` | `string` | Yes | Base URL of your Quiz Engine API |
173
+ | `title` | `string` | No | Optional title (reserved for future use) |
174
+
175
+ ### API Endpoint Required
176
+
177
+ The component expects this endpoint:
178
+
179
+ ```
180
+ GET {apiBaseUrl}/api/quiz-attempts/{attemptId}/results
181
+ ```
182
+
183
+ **Response format:**
184
+
185
+ ```json
186
+ {
187
+ "attempt": {
188
+ "id": 123,
189
+ "quizId": 1,
190
+ "score": 80,
191
+ "totalQuestions": 10,
192
+ "correctAnswers": 8,
193
+ "timeTaken": 300,
194
+ "completedAt": "2025-01-02T10:00:00Z",
195
+ "answers": { "1": "selected_answer", "2": "another_answer" }
196
+ },
197
+ "questions": [
198
+ {
199
+ "id": 1,
200
+ "questionText": "What is 2+2?",
201
+ "questionType": "multiple_choice",
202
+ "options": ["3", "4", "5"],
203
+ "correctAnswer": "4",
204
+ "explanation": "Basic addition"
205
+ }
206
+ ]
207
+ }
208
+ ```
209
+
210
+ ### Styling
211
+
212
+ The component uses 100% width to fill its parent container. Wrap it in a sized container to control dimensions:
213
+
214
+ ```tsx
215
+ <div style={{ maxWidth: '800px', margin: '0 auto' }}>
216
+ <AttemptViewer attemptId={123} apiBaseUrl="https://api.example.com" />
217
+ </div>
218
+ ```
219
+
220
+ ### Features
221
+
222
+ - **Summary cards** showing score, questions count, and time taken
223
+ - **Detailed breakdown** of each question with correct/incorrect indicators
224
+ - **Explanations** displayed for each question when available
225
+ - **Purple theme** (#6721b0) matching the QuizPlayer design
226
+ - **Responsive layout** that adapts to container width
227
+
228
+ ---
229
+
141
230
  ## License
142
231
 
143
232
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schoolio/player",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Quiz Player component for loading and playing quizzes, and attempts from Quiz Engine",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",