commons-assessment 12.0.32 → 12.1.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 +43 -16
- package/bundles/commons-assessment.umd.js +135 -168
- package/bundles/commons-assessment.umd.js.map +1 -1
- package/esm2015/lib/commons-assessment.module.js +6 -4
- package/esm2015/lib/modules/assessment-maker/components/add-edit-section-introduction/add-edit-section-introduction.component.js +1 -1
- package/esm2015/lib/modules/assessment-maker/components/assessment-builder/assessment-builder.component.js +1 -1
- package/esm2015/lib/modules/assessment-maker/services/assessment-maker.service.js +24 -27
- package/esm2015/lib/modules/assessment-taker/components/question-type-editor/question-type-editor.component.js +1 -1
- package/esm2015/lib/modules/assessment-taker/components/question-type-file-upload/question-type-file-upload.component.js +1 -1
- package/esm2015/lib/modules/assessment-taker/services/assessment-taker.service.js +24 -27
- package/esm2015/lib/shared/components/text-editor/text-editor.component.js +68 -92
- package/esm2015/lib/shared/shared.module.js +4 -8
- package/fesm2015/commons-assessment.js +122 -155
- package/fesm2015/commons-assessment.js.map +1 -1
- package/lib/commons-assessment.module.d.ts +1 -2
- package/lib/modules/assessment-maker/services/assessment-maker.service.d.ts +3 -3
- package/lib/modules/assessment-taker/services/assessment-taker.service.d.ts +3 -3
- package/lib/shared/components/text-editor/text-editor.component.d.ts +13 -15
- package/lib/shared/shared.module.d.ts +1 -2
- package/package.json +2 -2
- package/src/lib/assets/theme/styles.global.scss +36 -28
- package/esm2015/lib/configuration.js +0 -4
- package/lib/configuration.d.ts +0 -5
package/README.md
CHANGED
|
@@ -8,7 +8,17 @@ This library provides a comprehensive set of tools and components to create and
|
|
|
8
8
|
|
|
9
9
|
## Dependencies
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
### Required Peer Dependencies
|
|
12
|
+
|
|
13
|
+
Ensure the following packages are installed in your consumer application (as defined in `package.json`):
|
|
14
|
+
- **Angular Core & Common**: `>=12.0.0`
|
|
15
|
+
- **Angular Material & CDK** (for UI components and drag-and-drop): `>=12.0.0`
|
|
16
|
+
- **Bootstrap** (for baseline grid and component styling): `>=5.0.0`
|
|
17
|
+
- **Quill** (for rich text subjective questions): `>=2.0.0`
|
|
18
|
+
|
|
19
|
+
### Required Angular Imports
|
|
20
|
+
|
|
21
|
+
Import the following modules in your application:
|
|
12
22
|
- `BrowserAnimationsModule`
|
|
13
23
|
- `HttpClientModule`
|
|
14
24
|
- `CommonsAssessmentModule`
|
|
@@ -19,53 +29,70 @@ The library uses Bootstrap styles and requires the following modules to be impor
|
|
|
19
29
|
|
|
20
30
|
### 1. Import Modules
|
|
21
31
|
|
|
22
|
-
Import the
|
|
32
|
+
Import the `CommonsAssessmentModule.forRoot()` in your root `app.module.ts` once to register the singleton service providers. Other modules can then import the specific feature modules as needed:
|
|
23
33
|
|
|
24
34
|
```typescript
|
|
25
35
|
import { CommonsAssessmentModule, AssessmentMakerModule, AssessmentTakerModule } from 'commons-assessment';
|
|
26
36
|
|
|
27
37
|
@NgModule({
|
|
28
38
|
imports: [
|
|
29
|
-
CommonsAssessmentModule.forRoot(
|
|
30
|
-
baseURL: 'https://dev.platformcommons.org', // Use your backend API base URL
|
|
31
|
-
}),
|
|
39
|
+
CommonsAssessmentModule.forRoot(), // Import once in root app.module
|
|
32
40
|
AssessmentMakerModule,
|
|
33
41
|
AssessmentTakerModule
|
|
34
42
|
]
|
|
35
43
|
})
|
|
36
44
|
```
|
|
37
45
|
|
|
38
|
-
### 2. Configure
|
|
46
|
+
### 2. Configure HTTP Interceptor (Decoupled base URL)
|
|
47
|
+
|
|
48
|
+
Since the library uses relative paths, you must configure an HTTP Interceptor in your application to detect library API requests (which carry the `X-Library-Source: commons-assessment` header), prepend your backend API base URL, and strip the header before forwarding the request.
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { Injectable } from '@angular/core';
|
|
52
|
+
import { HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
|
|
53
|
+
|
|
54
|
+
@Injectable()
|
|
55
|
+
export class ApiInterceptor implements HttpInterceptor {
|
|
56
|
+
intercept(req: HttpRequest<any>, next: HttpHandler) {
|
|
57
|
+
let headers = req.headers;
|
|
58
|
+
let url = req.url;
|
|
59
|
+
|
|
60
|
+
if (headers.has('X-Library-Source')) {
|
|
61
|
+
headers = headers.delete('X-Library-Source');
|
|
62
|
+
url = 'https://your-api-domain.org' + url; // Prepend your backend base URL
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
req = req.clone({ url, headers });
|
|
66
|
+
return next.handle(req);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 3. Configure `angular.json`
|
|
39
72
|
|
|
40
73
|
Add the necessary assets and global styles in your `angular.json` file inside the `architect.build.options` block.
|
|
41
74
|
|
|
42
75
|
**Assets:**
|
|
43
|
-
Add the library assets
|
|
76
|
+
Add the library assets to the `assets` array.
|
|
44
77
|
```json
|
|
45
78
|
"assets": [
|
|
46
79
|
{
|
|
47
80
|
"glob": "**/*",
|
|
48
81
|
"input": "node_modules/commons-assessment/src/lib/assets",
|
|
49
82
|
"output": "assets/commons-assessment"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"glob": "**/*",
|
|
53
|
-
"input": "node_modules/@kolkov/angular-editor/assets/icons",
|
|
54
|
-
"output": "assets/ae-icons/"
|
|
55
83
|
}
|
|
56
84
|
]
|
|
57
85
|
```
|
|
58
86
|
|
|
59
87
|
**Styles:**
|
|
60
|
-
Include the library's global styles
|
|
88
|
+
Include the library's global styles in the `styles` array.
|
|
61
89
|
```json
|
|
62
90
|
"styles": [
|
|
63
|
-
"src/styles.scss"
|
|
64
|
-
"node_modules/@kolkov/angular-editor/themes/default.scss"
|
|
91
|
+
"src/styles.scss"
|
|
65
92
|
]
|
|
66
93
|
```
|
|
67
94
|
|
|
68
|
-
###
|
|
95
|
+
### 4. Theming Setup (`styles.scss`)
|
|
69
96
|
|
|
70
97
|
The library provides a mixin to easily customize the theme, including fonts and color variables. Set this up in your application's global `styles.scss`:
|
|
71
98
|
|