commons-assessment 12.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 +191 -0
- package/bundles/commons-assessment.umd.js +3968 -0
- package/bundles/commons-assessment.umd.js.map +1 -0
- package/commons-assessment.d.ts +5 -0
- package/esm2015/commons-assessment.js +5 -0
- package/esm2015/lib/commons-assessment.module.js +28 -0
- package/esm2015/lib/configuration.js +4 -0
- package/esm2015/lib/modules/assessment-maker/assessment-maker.component.js +409 -0
- package/esm2015/lib/modules/assessment-maker/assessment-maker.module.js +52 -0
- package/esm2015/lib/modules/assessment-maker/components/add-edit-section-introduction/add-edit-section-introduction.component.js +55 -0
- package/esm2015/lib/modules/assessment-maker/components/assessment-builder/assessment-builder.component.js +551 -0
- package/esm2015/lib/modules/assessment-maker/components/question-details/question-details.component.js +75 -0
- package/esm2015/lib/modules/assessment-maker/services/assessment-builder.service.js +150 -0
- package/esm2015/lib/modules/assessment-maker/services/assessment-maker.service.js +55 -0
- package/esm2015/lib/modules/assessment-taker/assessment-taker.component.js +618 -0
- package/esm2015/lib/modules/assessment-taker/assessment-taker.module.js +70 -0
- package/esm2015/lib/modules/assessment-taker/components/question-type-editor/question-type-editor.component.js +70 -0
- package/esm2015/lib/modules/assessment-taker/components/question-type-file-upload/question-type-file-upload.component.js +153 -0
- package/esm2015/lib/modules/assessment-taker/components/question-type-long/question-type-long.component.js +74 -0
- package/esm2015/lib/modules/assessment-taker/components/question-type-multiselect/question-type-multiselect.component.js +105 -0
- package/esm2015/lib/modules/assessment-taker/components/question-type-number/question-type-number.component.js +47 -0
- package/esm2015/lib/modules/assessment-taker/components/question-type-objective/question-type-objective.component.js +91 -0
- package/esm2015/lib/modules/assessment-taker/components/question-type-preference/question-type-preference.component.js +105 -0
- package/esm2015/lib/modules/assessment-taker/components/question-type-short/question-type-short.component.js +98 -0
- package/esm2015/lib/modules/assessment-taker/components/section-instructions/section-instructions.component.js +61 -0
- package/esm2015/lib/modules/assessment-taker/services/assessment-taker.service.js +58 -0
- package/esm2015/lib/modules/assessment-taker/services/response-builder.service.js +202 -0
- package/esm2015/lib/shared/components/text-editor/text-editor.component.js +119 -0
- package/esm2015/lib/shared/controllers.js +21 -0
- package/esm2015/lib/shared/interfaces/assessment.interface.js +2 -0
- package/esm2015/lib/shared/interfaces/question-paper.interface.js +2 -0
- package/esm2015/lib/shared/interfaces/question.interface.js +2 -0
- package/esm2015/lib/shared/material-modules.js +74 -0
- package/esm2015/lib/shared/pipes/order-by.pipe.js +25 -0
- package/esm2015/lib/shared/shared.module.js +48 -0
- package/esm2015/lib/shared/utils.js +16 -0
- package/esm2015/public-api.js +13 -0
- package/fesm2015/commons-assessment.js +3278 -0
- package/fesm2015/commons-assessment.js.map +1 -0
- package/lib/commons-assessment.module.d.ts +10 -0
- package/lib/configuration.d.ts +5 -0
- package/lib/modules/assessment-maker/assessment-maker.component.d.ts +64 -0
- package/lib/modules/assessment-maker/assessment-maker.module.d.ts +14 -0
- package/lib/modules/assessment-maker/components/add-edit-section-introduction/add-edit-section-introduction.component.d.ts +24 -0
- package/lib/modules/assessment-maker/components/assessment-builder/assessment-builder.component.d.ts +70 -0
- package/lib/modules/assessment-maker/components/question-details/question-details.component.d.ts +36 -0
- package/lib/modules/assessment-maker/services/assessment-builder.service.d.ts +43 -0
- package/lib/modules/assessment-maker/services/assessment-maker.service.d.ts +22 -0
- package/lib/modules/assessment-taker/assessment-taker.component.d.ts +81 -0
- package/lib/modules/assessment-taker/assessment-taker.module.d.ts +20 -0
- package/lib/modules/assessment-taker/components/question-type-editor/question-type-editor.component.d.ts +22 -0
- package/lib/modules/assessment-taker/components/question-type-file-upload/question-type-file-upload.component.d.ts +38 -0
- package/lib/modules/assessment-taker/components/question-type-long/question-type-long.component.d.ts +23 -0
- package/lib/modules/assessment-taker/components/question-type-multiselect/question-type-multiselect.component.d.ts +25 -0
- package/lib/modules/assessment-taker/components/question-type-number/question-type-number.component.d.ts +13 -0
- package/lib/modules/assessment-taker/components/question-type-objective/question-type-objective.component.d.ts +23 -0
- package/lib/modules/assessment-taker/components/question-type-preference/question-type-preference.component.d.ts +25 -0
- package/lib/modules/assessment-taker/components/question-type-short/question-type-short.component.d.ts +25 -0
- package/lib/modules/assessment-taker/components/section-instructions/section-instructions.component.d.ts +24 -0
- package/lib/modules/assessment-taker/services/assessment-taker.service.d.ts +20 -0
- package/lib/modules/assessment-taker/services/response-builder.service.d.ts +16 -0
- package/lib/shared/components/text-editor/text-editor.component.d.ts +24 -0
- package/lib/shared/controllers.d.ts +19 -0
- package/lib/shared/interfaces/assessment.interface.d.ts +133 -0
- package/lib/shared/interfaces/question-paper.interface.d.ts +73 -0
- package/lib/shared/interfaces/question.interface.d.ts +82 -0
- package/lib/shared/material-modules.d.ts +18 -0
- package/lib/shared/pipes/order-by.pipe.d.ts +7 -0
- package/lib/shared/shared.module.d.ts +12 -0
- package/lib/shared/utils.d.ts +2 -0
- package/package.json +22 -0
- package/public-api.d.ts +9 -0
- package/src/lib/assets/images/action-dots.svg +5 -0
- package/src/lib/assets/images/add-section.svg +4 -0
- package/src/lib/assets/images/arrow-down-black.svg +3 -0
- package/src/lib/assets/images/arrow-ramp-left.svg +3 -0
- package/src/lib/assets/images/close.svg +3 -0
- package/src/lib/assets/images/copy.svg +3 -0
- package/src/lib/assets/images/delete.svg +1 -0
- package/src/lib/assets/images/drag-drop.svg +8 -0
- package/src/lib/assets/images/file.svg +5 -0
- package/src/lib/assets/images/go-back.svg +3 -0
- package/src/lib/assets/images/info.svg +3 -0
- package/src/lib/assets/images/jpeg.svg +5 -0
- package/src/lib/assets/images/jpg.svg +5 -0
- package/src/lib/assets/images/keyboard.svg +3 -0
- package/src/lib/assets/images/no-questions.svg +14 -0
- package/src/lib/assets/images/pdf.svg +5 -0
- package/src/lib/assets/images/pencil.svg +3 -0
- package/src/lib/assets/images/plus-primary.svg +3 -0
- package/src/lib/assets/images/png.svg +5 -0
- package/src/lib/assets/images/svg.svg +5 -0
- package/src/lib/assets/json/imageConfig.json +22 -0
- package/src/lib/assets/json/labelConfig.json +96 -0
- package/src/lib/assets/json/question-builder-rules.json +97 -0
- package/src/lib/assets/json/questionTypes.json +50 -0
- package/src/lib/assets/theme/_theme.global.scss +63 -0
- package/src/lib/assets/theme/_theme.scss +568 -0
- package/src/lib/assets/theme/styles.global.scss +191 -0
- package/src/lib/assets/theme/styles.scss +63 -0
package/README.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# Commons Assessment Library
|
|
2
|
+
|
|
3
|
+
This library provides a comprehensive set of tools and components to create and manage assessments (Maker module), as well as to facilitate users in taking assessments (Taker module) within an Angular application.
|
|
4
|
+
|
|
5
|
+
## Version Compatibility
|
|
6
|
+
|
|
7
|
+
- **Version 12**: For Angular 12 to 15 usage.
|
|
8
|
+
- **Version 16**: For Angular 16+ usage.
|
|
9
|
+
|
|
10
|
+
## Dependencies
|
|
11
|
+
|
|
12
|
+
The library uses Bootstrap styles and requires the following modules to be imported in your application:
|
|
13
|
+
- `BrowserAnimationsModule`
|
|
14
|
+
- `HttpClientModule`
|
|
15
|
+
- `CommonsAssessmentModule`
|
|
16
|
+
- `AssessmentMakerModule` (If creating assessments)
|
|
17
|
+
- `AssessmentTakerModule` (If rendering assessments)
|
|
18
|
+
|
|
19
|
+
## Installation & Configuration
|
|
20
|
+
|
|
21
|
+
### 1. Import Modules
|
|
22
|
+
|
|
23
|
+
Import the appropriate modules in your `app.module.ts`. You must configure `CommonsAssessmentModule` with `forRoot()` to provide the backend base URL.
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { CommonsAssessmentModule, AssessmentMakerModule, AssessmentTakerModule } from 'commons-assessment';
|
|
27
|
+
|
|
28
|
+
@NgModule({
|
|
29
|
+
imports: [
|
|
30
|
+
CommonsAssessmentModule.forRoot({
|
|
31
|
+
baseURL: 'https://dev.platformcommons.org', // Use your backend API base URL
|
|
32
|
+
}),
|
|
33
|
+
AssessmentMakerModule,
|
|
34
|
+
AssessmentTakerModule
|
|
35
|
+
]
|
|
36
|
+
})
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 2. Configure `angular.json`
|
|
40
|
+
|
|
41
|
+
Add the necessary assets and global styles in your `angular.json` file inside the `architect.build.options` block.
|
|
42
|
+
|
|
43
|
+
**Assets:**
|
|
44
|
+
Add the library assets and angular-editor icons to the `assets` array.
|
|
45
|
+
```json
|
|
46
|
+
"assets": [
|
|
47
|
+
{
|
|
48
|
+
"glob": "**/*",
|
|
49
|
+
"input": "node_modules/commons-assessment/src/lib/assets",
|
|
50
|
+
"output": "assets/commons-assessment"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"glob": "**/*",
|
|
54
|
+
"input": "node_modules/@kolkov/angular-editor/assets/icons",
|
|
55
|
+
"output": "assets/ae-icons/"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Styles:**
|
|
61
|
+
Include the library's global styles and third-party dependencies in the `styles` array.
|
|
62
|
+
```json
|
|
63
|
+
"styles": [
|
|
64
|
+
"src/styles.scss",
|
|
65
|
+
"node_modules/commons-assessment/src/lib/assets/theme/styles.global.scss",
|
|
66
|
+
"node_modules/@kolkov/angular-editor/themes/default.scss"
|
|
67
|
+
]
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 3. Theming Setup (`styles.scss`)
|
|
71
|
+
|
|
72
|
+
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`:
|
|
73
|
+
|
|
74
|
+
```scss
|
|
75
|
+
// Import the library's theme mixin
|
|
76
|
+
@use "/node_modules/commons-assessment/src/lib/assets/theme/theme.global" as theme;
|
|
77
|
+
// Import Bootstrap and Material core styles
|
|
78
|
+
@import "~bootstrap/dist/css/bootstrap.min.css";
|
|
79
|
+
@import "@angular/material/prebuilt-themes/indigo-pink.css";
|
|
80
|
+
|
|
81
|
+
// Include customized variables into the theme
|
|
82
|
+
:root {
|
|
83
|
+
@include theme.assessment-theme(
|
|
84
|
+
(
|
|
85
|
+
font-family: "Poppins",
|
|
86
|
+
// You can override library palette by uncommenting and modifying below:
|
|
87
|
+
// primary-one: #2e7d32,
|
|
88
|
+
// primary-four: #1b5e20,
|
|
89
|
+
// palette-EDF3FD: #e8f5e9,
|
|
90
|
+
// grey-one: #fff,
|
|
91
|
+
)
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Component Usage
|
|
97
|
+
|
|
98
|
+
### Assessment Maker
|
|
99
|
+
|
|
100
|
+
To render the assessment maker interface, use the `<lib-assessment-maker>` component in your template.
|
|
101
|
+
|
|
102
|
+
**`component.ts`**:
|
|
103
|
+
```typescript
|
|
104
|
+
|
|
105
|
+
export class Component {
|
|
106
|
+
// Define default structure or data payload for the assessment
|
|
107
|
+
createAssessmentDTO: Assessment = {
|
|
108
|
+
assessmentCode: 'TEST_ASSESSMENT_CODE',
|
|
109
|
+
domain: 'domain.test',
|
|
110
|
+
assessmentName: [{
|
|
111
|
+
id: 0,
|
|
112
|
+
text: 'test assessment',
|
|
113
|
+
language: {
|
|
114
|
+
code: 'ENG',
|
|
115
|
+
}
|
|
116
|
+
}],
|
|
117
|
+
tenant: 123
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**`component.html`**:
|
|
123
|
+
```html
|
|
124
|
+
<lib-assessment-maker
|
|
125
|
+
[defaultAssessmentDTO]="createAssessmentDTO"
|
|
126
|
+
[assessmentId]="2298"
|
|
127
|
+
[showFooter]="true">
|
|
128
|
+
</lib-assessment-maker>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
#### Maker Inputs and Outputs
|
|
132
|
+
|
|
133
|
+
| Property | Type (`@Input` / `@Output`) | Data Type | Description |
|
|
134
|
+
| --- | --- | --- | --- |
|
|
135
|
+
| `[labelConfig]` | `@Input` | `{ [key: string]: string }` | (Optional) Configuration strings to overwrite internal labels. |
|
|
136
|
+
| `[imageConfig]` | `@Input` | `{ [key: string]: string }` | (Optional) Configuration paths/URLs to overwrite internal icons or images. |
|
|
137
|
+
| `[questionTypes]` | `@Input` | `QuestionType[]` | (Optional) Restrict or customize the array of available question types. |
|
|
138
|
+
| `[showFooter]` | `@Input` | `boolean` | (Optional) Toggles visibility of the assessment component footer actions. |
|
|
139
|
+
| `[customRules]` | `@Input` | `any` | (Optional) Pass your custom question builder rules overrides. |
|
|
140
|
+
| `[assessmentId]` | `@Input` | `number` | Provide the ID of an existing assessment to edit or attach questions to. Default is 0. |
|
|
141
|
+
| `[assessmentInstanceId]` | `@Input` | `number` | Current assessment instance identifier, if the assessment is already published. Default is 0. |
|
|
142
|
+
| `[defaultAssessmentDTO]` | `@Input` | `Assessment` | The default contextual configuration object for creating new assessments. |
|
|
143
|
+
| `(assessmentIdChange)` | `@Output` | `EventEmitter<number>` | Emits the new `assessmentId` when an assessment is successfully created. |
|
|
144
|
+
| `(assessmentInstanceIdChange)` | `@Output` | `EventEmitter<number>` | Emits the new instance ID integer when an assessment is published. |
|
|
145
|
+
| `(snackbarMessage)` | `@Output` | `EventEmitter<{ message: string, type: 'success' \| 'error' \| 'info' }>` | Emits message status updates representing errors and workflow successes from the service. |
|
|
146
|
+
|
|
147
|
+
### Assessment Taker
|
|
148
|
+
|
|
149
|
+
To render the assessment taker interface, use the `<lib-assessment-taker>` component in your template.
|
|
150
|
+
|
|
151
|
+
**`component.html`**:
|
|
152
|
+
```html
|
|
153
|
+
<lib-assessment-taker
|
|
154
|
+
[labelConfig]="{}"
|
|
155
|
+
[imageConfig]="{}"
|
|
156
|
+
[assessmentId]="2298"
|
|
157
|
+
[assessmentInstanceId]="1135"
|
|
158
|
+
[assesseeData]="assesseeData"
|
|
159
|
+
[assessorData]="assessorData"
|
|
160
|
+
[showFooter]="true"
|
|
161
|
+
[disabled]="false"
|
|
162
|
+
[previewMode]="false"
|
|
163
|
+
[verticalView]="false"
|
|
164
|
+
[enableMarks]="false"
|
|
165
|
+
(submitAssessment)="onSubmit($event)"
|
|
166
|
+
(snackbarMessage)="onSnackbarMessage($event)">
|
|
167
|
+
</lib-assessment-taker>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
#### Taker Inputs and Outputs
|
|
171
|
+
|
|
172
|
+
| Property | Type (`@Input` / `@Output`) | Data Type | Description |
|
|
173
|
+
| --- | --- | --- | --- |
|
|
174
|
+
| `[labelConfig]` | `@Input` | `{ [key: string]: string }` | (Optional) Configuration strings to overwrite internal labels. |
|
|
175
|
+
| `[imageConfig]` | `@Input` | `{ [key: string]: string }` | (Optional) Configuration paths/URLs to overwrite internal icons or images. |
|
|
176
|
+
| `[assessmentId]` | `@Input` | `number` | **Required.** Provide the ID of an existing assessment to take. |
|
|
177
|
+
| `[assessmentInstanceId]` | `@Input` | `number` | **Required.** The published instance ID of the assessment. |
|
|
178
|
+
| `[assesseeData]` | `@Input` | `AssesseeDTO` | **Required.** Data concerning the person taking the assessment. |
|
|
179
|
+
| `[assessorData]` | `@Input` | `AssessorDTO` | **Required.** Data concerning the entity or person grading/creating the assessment. |
|
|
180
|
+
| `[showFooter]` | `@Input` | `boolean` | (Optional) Toggles visibility of the assessment component footer actions. |
|
|
181
|
+
| `[disabled]` | `@Input` | `boolean` | (Optional) Disables the form to prevent interaction. |
|
|
182
|
+
| `[previewMode]` | `@Input` | `boolean` | (Optional) Disables interaction and enables preview functionality. |
|
|
183
|
+
| `[verticalView]` | `@Input` | `boolean` | (Optional) Displays the assessment sections vertically instead of tabs. |
|
|
184
|
+
| `[enableMarks]` | `@Input` | `boolean` | (Optional) Enables ability to view or provide marks. |
|
|
185
|
+
| `(submitAssessment)` | `@Output` | `EventEmitter<{ assesseeId: number, completed: boolean }>` | Emits when the assessment is submitted, containing the `assesseeId` and a `completed` flag indicating if the taker finished the entire assessment. |
|
|
186
|
+
| `(snackbarMessage)` | `@Output` | `EventEmitter<{ message: string, type: 'success' \| 'error' \| 'info' }>` | Emits message status updates representing errors and workflow successes from the service. |
|
|
187
|
+
|
|
188
|
+
## Development Commands
|
|
189
|
+
|
|
190
|
+
- Run `npm run build` or `ng build commons-assessment` to build the library project. The build artifacts will be stored in the `dist/` directory.
|
|
191
|
+
- Run `ng test commons-assessment` to execute the unit tests via [Karma](https://karma-runner.github.io).
|