@akai-mirai/report-ui 1.0.0
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.
- package/README.md +249 -0
- package/dist/ems-report-ui.cjs.js +250 -0
- package/dist/ems-report-ui.es.js +25990 -0
- package/dist/index.d.ts +1 -0
- package/package.json +76 -0
package/README.md
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# @ems/report-ui
|
|
2
|
+
|
|
3
|
+
Beautiful React-based report generation library for quiz and session results. Built with Material-UI and TypeScript.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 📊 **Quiz Results Reports** - Comprehensive analytics for all students
|
|
8
|
+
- 📝 **Session Results Reports** - Detailed individual student reports
|
|
9
|
+
- 🎨 **Beautiful UI** - Modern design matching your platform's style
|
|
10
|
+
- 🌍 **Internationalization** - Support for Kazakh, Russian, and English
|
|
11
|
+
- 📄 **PDF Export** - Generate PDF reports using Puppeteer
|
|
12
|
+
- 📈 **Analytics** - Question analysis, subject statistics, and more
|
|
13
|
+
- 🎯 **TypeScript** - Full type safety
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Using yarn
|
|
19
|
+
yarn add @ems/report-ui
|
|
20
|
+
|
|
21
|
+
# Using npm
|
|
22
|
+
npm install @ems/report-ui
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Peer Dependencies
|
|
26
|
+
|
|
27
|
+
This library requires React and React DOM to be installed in your project:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
yarn add react react-dom
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { renderReportToHTML } from '@ems/report-ui'
|
|
37
|
+
import type { QuizData, SessionData } from '@ems/report-ui'
|
|
38
|
+
|
|
39
|
+
// Generate HTML for quiz results report
|
|
40
|
+
const html = renderReportToHTML({
|
|
41
|
+
type: 'QUIZ_RESULTS',
|
|
42
|
+
quiz: quizData,
|
|
43
|
+
allSessions: sessionsData,
|
|
44
|
+
options: {
|
|
45
|
+
language: 'ru', // 'kk' | 'ru' | 'en'
|
|
46
|
+
includeProctoring: true,
|
|
47
|
+
includeAiAnalysis: true
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
// Use with Puppeteer to generate PDF
|
|
52
|
+
// (see backend integration example)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
### Quiz Results Report
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { QuizResultsReportSSR } from '@ems/report-ui'
|
|
61
|
+
import { ReportWrapper } from '@ems/report-ui'
|
|
62
|
+
|
|
63
|
+
function App() {
|
|
64
|
+
return (
|
|
65
|
+
<ReportWrapper>
|
|
66
|
+
<QuizResultsReportSSR
|
|
67
|
+
quiz={quizData}
|
|
68
|
+
allSessions={sessionsData}
|
|
69
|
+
options={{ language: 'ru' }}
|
|
70
|
+
/>
|
|
71
|
+
</ReportWrapper>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Session Results Report
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { SessionResultsReport } from '@ems/report-ui'
|
|
80
|
+
import { ReportWrapper } from '@ems/report-ui'
|
|
81
|
+
|
|
82
|
+
function App() {
|
|
83
|
+
return (
|
|
84
|
+
<ReportWrapper>
|
|
85
|
+
<SessionResultsReport
|
|
86
|
+
session={sessionData}
|
|
87
|
+
options={{
|
|
88
|
+
language: 'ru',
|
|
89
|
+
includeDetailedAnswers: true,
|
|
90
|
+
includeProctoring: true,
|
|
91
|
+
includeAiAnalysis: true
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
</ReportWrapper>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## API Reference
|
|
100
|
+
|
|
101
|
+
### Components
|
|
102
|
+
|
|
103
|
+
#### `QuizResultsReportSSR`
|
|
104
|
+
Comprehensive quiz results report for teachers.
|
|
105
|
+
|
|
106
|
+
**Props:**
|
|
107
|
+
- `quiz: QuizData` - Quiz data
|
|
108
|
+
- `allSessions: SessionData[]` - All student sessions
|
|
109
|
+
- `options?: ReportGenerationOptions` - Report options
|
|
110
|
+
|
|
111
|
+
#### `SessionResultsReport`
|
|
112
|
+
Detailed individual session results report.
|
|
113
|
+
|
|
114
|
+
**Props:**
|
|
115
|
+
- `session: SessionData` - Session data with answers
|
|
116
|
+
- `options?: ReportGenerationOptions` - Report options
|
|
117
|
+
|
|
118
|
+
#### `ReportWrapper`
|
|
119
|
+
Theme provider wrapper for reports.
|
|
120
|
+
|
|
121
|
+
**Props:**
|
|
122
|
+
- `children: React.ReactNode` - Report components
|
|
123
|
+
|
|
124
|
+
### Utilities
|
|
125
|
+
|
|
126
|
+
#### `renderReportToHTML(options)`
|
|
127
|
+
Renders a report to HTML string for PDF generation.
|
|
128
|
+
|
|
129
|
+
**Parameters:**
|
|
130
|
+
- `options.type: 'QUIZ_RESULTS' | 'SESSION_RESULTS'` - Report type
|
|
131
|
+
- `options.quiz?: QuizData` - Quiz data (for QUIZ_RESULTS)
|
|
132
|
+
- `options.allSessions?: SessionData[]` - All sessions (for QUIZ_RESULTS)
|
|
133
|
+
- `options.session?: SessionData` - Session data (for SESSION_RESULTS)
|
|
134
|
+
- `options.options?: ReportGenerationOptions` - Report generation options
|
|
135
|
+
|
|
136
|
+
**Returns:** `string` - HTML string
|
|
137
|
+
|
|
138
|
+
### Types
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
interface QuizData {
|
|
142
|
+
id: string
|
|
143
|
+
title: string
|
|
144
|
+
description?: string
|
|
145
|
+
startTime?: Date | string
|
|
146
|
+
endTime?: Date | string
|
|
147
|
+
duration?: number
|
|
148
|
+
status?: string
|
|
149
|
+
locale?: string
|
|
150
|
+
quizSubjects?: Array<{ subject?: { title: Record<string, string> } }>
|
|
151
|
+
author?: { firstName?: string; lastName?: string; email?: string }
|
|
152
|
+
_count?: { questions: number }
|
|
153
|
+
questions?: Array<{ question: QuestionData }>
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
interface SessionData {
|
|
157
|
+
id: string
|
|
158
|
+
status: string
|
|
159
|
+
score?: number
|
|
160
|
+
correctAnswers?: number
|
|
161
|
+
totalQuestions?: number
|
|
162
|
+
timeSpent?: number
|
|
163
|
+
finishedAt?: Date | string
|
|
164
|
+
startedAt?: Date | string
|
|
165
|
+
user: { firstName?: string; lastName?: string; userName?: string; email?: string }
|
|
166
|
+
quiz?: { title?: string; quizSubjects?: Array<{ subject?: { title: Record<string, string> } }> }
|
|
167
|
+
answers?: AnswerData[]
|
|
168
|
+
proctoringMetrics?: { riskScore?: number }
|
|
169
|
+
proctoringAlerts?: Array<{ severity?: string; type?: string; message?: string; timestamp?: Date | string }>
|
|
170
|
+
aiAnalysis?: { summary?: string; recommendations?: string }
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
interface ReportGenerationOptions {
|
|
174
|
+
includeAiAnalysis?: boolean
|
|
175
|
+
includeProctoring?: boolean
|
|
176
|
+
includeDetailedAnswers?: boolean
|
|
177
|
+
language?: 'kk' | 'ru' | 'en'
|
|
178
|
+
format?: 'PDF' | 'IMAGE'
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Development
|
|
183
|
+
|
|
184
|
+
### Setup
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
# Install dependencies
|
|
188
|
+
yarn install
|
|
189
|
+
|
|
190
|
+
# Start dev server (for preview)
|
|
191
|
+
yarn dev
|
|
192
|
+
|
|
193
|
+
# Build library
|
|
194
|
+
yarn build:lib
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Project Structure
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
src/
|
|
201
|
+
├── components/ # React components
|
|
202
|
+
│ ├── QuizResultsReportSSR.tsx
|
|
203
|
+
│ ├── SessionResultsReport.tsx
|
|
204
|
+
│ ├── SubjectStatistics.tsx
|
|
205
|
+
│ └── QuestionAnalysis.tsx
|
|
206
|
+
├── utils/ # Utilities
|
|
207
|
+
│ ├── render.tsx # HTML rendering
|
|
208
|
+
│ └── format.ts # Formatting helpers
|
|
209
|
+
├── types/ # TypeScript types
|
|
210
|
+
├── theme/ # Material-UI theme
|
|
211
|
+
├── i18n/ # Internationalization
|
|
212
|
+
└── index.ts # Main entry point
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Backend Integration
|
|
216
|
+
|
|
217
|
+
See `INTEGRATION_GUIDE.md` for detailed backend integration instructions.
|
|
218
|
+
|
|
219
|
+
Example with NestJS:
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
import { renderReportToHTML } from '@ems/report-ui'
|
|
223
|
+
import puppeteer from 'puppeteer'
|
|
224
|
+
|
|
225
|
+
async function generatePDF(quizData: QuizData, sessions: SessionData[]) {
|
|
226
|
+
const html = renderReportToHTML({
|
|
227
|
+
type: 'QUIZ_RESULTS',
|
|
228
|
+
quiz: quizData,
|
|
229
|
+
allSessions: sessions,
|
|
230
|
+
options: { language: 'ru' }
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
const browser = await puppeteer.launch()
|
|
234
|
+
const page = await browser.newPage()
|
|
235
|
+
await page.setContent(html)
|
|
236
|
+
const pdf = await page.pdf({ format: 'A4' })
|
|
237
|
+
await browser.close()
|
|
238
|
+
|
|
239
|
+
return pdf
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## License
|
|
244
|
+
|
|
245
|
+
MIT
|
|
246
|
+
|
|
247
|
+
## Support
|
|
248
|
+
|
|
249
|
+
For issues and questions, please contact the EMS team.
|