@patch-adams/plugin-feedback 1.0.7 → 1.0.8
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 +144 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# @patch-adams/plugin-feedback
|
|
2
|
+
|
|
3
|
+
A feedback widget plugin for Patch-Adams that injects a customizable feedback form into Rise courses.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Star rating (configurable 3-10 stars)
|
|
8
|
+
- Issue type dropdown with subtypes
|
|
9
|
+
- Comment field with character counter
|
|
10
|
+
- Auto-detects language from `<html lang>` or `<body lang>` attribute
|
|
11
|
+
- Live language switching (English/French)
|
|
12
|
+
- Submits to configurable endpoint
|
|
13
|
+
- Fully customizable appearance and behavior
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @patch-adams/plugin-feedback
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
Configure the feedback plugin in your patch configuration:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { patchCourse } from '@patch-adams/core';
|
|
27
|
+
import feedbackPlugin from '@patch-adams/plugin-feedback';
|
|
28
|
+
|
|
29
|
+
const result = await patchCourse(courseZip, {
|
|
30
|
+
plugins: {
|
|
31
|
+
feedback: {
|
|
32
|
+
enabled: true,
|
|
33
|
+
tabText: 'Feedback',
|
|
34
|
+
tabColor: '#da291c',
|
|
35
|
+
position: 'right',
|
|
36
|
+
endpoint: 'https://api.example.com/feedback',
|
|
37
|
+
showRating: true,
|
|
38
|
+
showIssueType: true,
|
|
39
|
+
showComment: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Language Detection
|
|
46
|
+
|
|
47
|
+
The widget automatically detects the language from the HTML document:
|
|
48
|
+
|
|
49
|
+
1. Checks `<html lang="xx">` attribute
|
|
50
|
+
2. Falls back to `<body lang="xx">` attribute
|
|
51
|
+
3. Falls back to `config.locale` value
|
|
52
|
+
4. Defaults to English
|
|
53
|
+
|
|
54
|
+
Language variants are normalized: `fr-CA` → `fr`, `en-US` → `en`
|
|
55
|
+
|
|
56
|
+
**Live switching**: If the `lang` attribute changes at runtime (e.g., via JavaScript or DevTools), the widget automatically re-renders with the new language.
|
|
57
|
+
|
|
58
|
+
## Configuration Options
|
|
59
|
+
|
|
60
|
+
| Option | Type | Default | Description |
|
|
61
|
+
|--------|------|---------|-------------|
|
|
62
|
+
| `enabled` | boolean | `true` | Enable/disable the plugin |
|
|
63
|
+
| `endpoint` | string | - | URL to POST feedback data |
|
|
64
|
+
| `method` | `'POST'` \| `'PUT'` | `'POST'` | HTTP method |
|
|
65
|
+
| `headers` | object | - | Additional headers for the request |
|
|
66
|
+
| `position` | `'left'` \| `'right'` | `'right'` | Tab position |
|
|
67
|
+
| `tabText` | string | `'Feedback'` | Text on the tab button |
|
|
68
|
+
| `tabColor` | string | `'#da291c'` | Tab background color |
|
|
69
|
+
| `tabTextColor` | string | `'#ffffff'` | Tab text color |
|
|
70
|
+
| `zIndex` | number | `9999` | Widget z-index |
|
|
71
|
+
| `showRating` | boolean | `true` | Show star rating |
|
|
72
|
+
| `ratingRequired` | boolean | `false` | Require rating to submit |
|
|
73
|
+
| `ratingStars` | number | `5` | Number of stars (3-10) |
|
|
74
|
+
| `showIssueType` | boolean | `true` | Show issue type dropdown |
|
|
75
|
+
| `issueTypeRequired` | boolean | `false` | Require issue type |
|
|
76
|
+
| `issueTypes` | array | default types | Custom issue types |
|
|
77
|
+
| `showComment` | boolean | `true` | Show comment field |
|
|
78
|
+
| `commentRequired` | boolean | `false` | Require comment |
|
|
79
|
+
| `commentMaxLength` | number | `500` | Max comment length |
|
|
80
|
+
| `locale` | `'en'` \| `'fr'` | `'en'` | Default locale (auto-detected at runtime) |
|
|
81
|
+
| `translations` | object | - | Custom translation overrides |
|
|
82
|
+
| `autoClose` | boolean | `true` | Auto-close after success |
|
|
83
|
+
| `autoCloseDelay` | number | `2000` | Delay before auto-close (ms) |
|
|
84
|
+
| `debug` | boolean | `false` | Enable debug logging |
|
|
85
|
+
| `includeMetadata` | object | all true | What metadata to include |
|
|
86
|
+
|
|
87
|
+
## Custom Issue Types
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
{
|
|
91
|
+
issueTypes: [
|
|
92
|
+
{
|
|
93
|
+
id: 'content',
|
|
94
|
+
label: 'Content Issue',
|
|
95
|
+
subtypes: [
|
|
96
|
+
{ id: 'typo', label: 'Typo / Grammar' },
|
|
97
|
+
{ id: 'incorrect', label: 'Incorrect Information' },
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: 'technical',
|
|
102
|
+
label: 'Technical Issue',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: 'other',
|
|
106
|
+
label: 'Other',
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Metadata
|
|
113
|
+
|
|
114
|
+
By default, feedback submissions include:
|
|
115
|
+
|
|
116
|
+
- `courseId` - From `data-pa-course-id` attribute on `<html>`
|
|
117
|
+
- `courseTitle` - From LRS bridge if available
|
|
118
|
+
- `lessonId` - Current URL hash or pathname
|
|
119
|
+
- `userAgent` - Browser user agent
|
|
120
|
+
- `timestamp` - ISO 8601 timestamp
|
|
121
|
+
- `url` - Current page URL
|
|
122
|
+
|
|
123
|
+
## Submitted Data Format
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"rating": 4,
|
|
128
|
+
"issueType": "content",
|
|
129
|
+
"issueSubtype": "typo",
|
|
130
|
+
"comment": "Found a typo on slide 3",
|
|
131
|
+
"metadata": {
|
|
132
|
+
"courseId": "course-123",
|
|
133
|
+
"courseTitle": "Safety Training",
|
|
134
|
+
"lessonId": "#/lessons/intro",
|
|
135
|
+
"userAgent": "Mozilla/5.0...",
|
|
136
|
+
"timestamp": "2024-01-15T10:30:00.000Z",
|
|
137
|
+
"url": "https://example.com/course/#/lessons/intro"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
MIT
|
package/package.json
CHANGED