commons-assessment 12.0.30 → 12.0.32

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 CHANGED
@@ -1,203 +1,211 @@
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+ usage.
8
-
9
- ## Dependencies
10
-
11
- The library uses Bootstrap styles and requires the following modules to be imported in your application:
12
- - `BrowserAnimationsModule`
13
- - `HttpClientModule`
14
- - `CommonsAssessmentModule`
15
- - `AssessmentMakerModule` (If creating assessments)
16
- - `AssessmentTakerModule` (If rendering assessments)
17
-
18
- ## Installation & Configuration
19
-
20
- ### 1. Import Modules
21
-
22
- Import the appropriate modules in your `app.module.ts`. You must configure `CommonsAssessmentModule` with `forRoot()` to provide the backend base URL.
23
-
24
- ```typescript
25
- import { CommonsAssessmentModule, AssessmentMakerModule, AssessmentTakerModule } from 'commons-assessment';
26
-
27
- @NgModule({
28
- imports: [
29
- CommonsAssessmentModule.forRoot({
30
- baseURL: 'https://dev.platformcommons.org', // Use your backend API base URL
31
- }),
32
- AssessmentMakerModule,
33
- AssessmentTakerModule
34
- ]
35
- })
36
- ```
37
-
38
- ### 2. Configure `angular.json`
39
-
40
- Add the necessary assets and global styles in your `angular.json` file inside the `architect.build.options` block.
41
-
42
- **Assets:**
43
- Add the library assets and angular-editor icons to the `assets` array.
44
- ```json
45
- "assets": [
46
- {
47
- "glob": "**/*",
48
- "input": "node_modules/commons-assessment/src/lib/assets",
49
- "output": "assets/commons-assessment"
50
- },
51
- {
52
- "glob": "**/*",
53
- "input": "node_modules/@kolkov/angular-editor/assets/icons",
54
- "output": "assets/ae-icons/"
55
- }
56
- ]
57
- ```
58
-
59
- **Styles:**
60
- Include the library's global styles and third-party dependencies in the `styles` array.
61
- ```json
62
- "styles": [
63
- "src/styles.scss",
64
- "node_modules/commons-assessment/src/lib/assets/theme/styles.global.scss",
65
- "node_modules/@kolkov/angular-editor/themes/default.scss"
66
- ]
67
- ```
68
-
69
- ### 3. Theming Setup (`styles.scss`)
70
-
71
- 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`:
72
-
73
- ```scss
74
- // Import the library's theme mixin
75
- @use "/node_modules/commons-assessment/src/lib/assets/theme/theme.global" as theme;
76
- // Import Bootstrap and Material core styles
77
- @import "~bootstrap/dist/css/bootstrap.min.css";
78
- @import "@angular/material/prebuilt-themes/indigo-pink.css";
79
-
80
- // Include customized variables into the theme
81
- :root {
82
- @include theme.assessment-theme(
83
- (
84
- font-family: "Poppins",
85
- // You can override library palette by uncommenting and modifying below:
86
- // primary-one: #2e7d32,
87
- // primary-four: #1b5e20,
88
- // palette-EDF3FD: #e8f5e9,
89
- // grey-one: #fff,
90
- )
91
- );
92
- }
93
- ```
94
-
95
- ## Component Usage
96
-
97
- ### Assessment Maker
98
-
99
- To render the assessment maker interface, use the `<lib-assessment-maker>` component in your template.
100
-
101
- **`component.ts`**:
102
- ```typescript
103
-
104
- export class Component {
105
- // Define default structure or data payload for the assessment
106
- createAssessmentDTO: Assessment = {
107
- assessmentCode: 'TEST_ASSESSMENT_CODE',
108
- domain: 'domain.test',
109
- assessmentName: [{
110
- id: 0,
111
- text: 'test assessment',
112
- language: {
113
- code: 'ENG',
114
- }
115
- }],
116
- tenant: 123
117
- };
118
- }
119
- ```
120
-
121
- **`component.html`**:
122
- ```html
123
- <lib-assessment-maker
124
- [defaultAssessmentDTO]="createAssessmentDTO"
125
- [assessmentId]="2298"
126
- [showFooter]="true">
127
- </lib-assessment-maker>
128
- ```
129
-
130
- #### Maker Inputs and Outputs
131
-
132
- | Property | Type (`@Input` / `@Output`) | Data Type | Description |
133
- | --- | --- | --- | --- |
134
- | `[labelConfig]` | `@Input` | `{ [key: string]: string }` | (Optional) Configuration strings to overwrite internal labels. |
135
- | `[imageConfig]` | `@Input` | `{ [key: string]: string }` | (Optional) Configuration paths/URLs to overwrite internal icons or images. |
136
- | `[questionTypes]` | `@Input` | `QuestionType[]` | (Optional) Restrict or customize the array of available question types. |
137
- | `[showFooter]` | `@Input` | `boolean` | (Optional) Toggles visibility of the assessment component footer actions. |
138
- | `[customRules]` | `@Input` | `any` | (Optional) Pass your custom question builder rules overrides. |
139
- | `[assessmentId]` | `@Input` | `number` | Provide the ID of an existing assessment to edit or attach questions to. Default is 0. |
140
- | `[assessmentInstanceId]` | `@Input` | `number` | Current assessment instance identifier, if the assessment is already published. Default is 0. |
141
- | `[defaultAssessmentDTO]` | `@Input` | `Assessment` | The default contextual configuration object for creating new assessments. |
142
- | `[predefinedAssessmentInstance]` | `@Input` | `AssessmentInstance` | The default contextual configuration object for creating new assessment instances. |
143
- | `[minimumRequiredSections]` | `@Input` | `number` | Minimum number of sections needed before assessment can be published. Default is 0. |
144
- | `[assessmentContext]` | `@Input` | `AssessmentContext` | (Optional) Pre-loaded assessment context data to bypass the initial data load API call. |
145
- | `(assessmentIdChange)` | `@Output` | `EventEmitter<number>` | Emits the new `assessmentId` when an assessment is successfully created. |
146
- | `(assessmentInstanceIdChange)` | `@Output` | `EventEmitter<number>` | Emits the new instance ID integer when an assessment is published. |
147
- | `(snackbarMessage)` | `@Output` | `EventEmitter<{ message: string, type: 'success' \| 'error' \| 'info' }>` | Emits message status updates representing errors and workflow successes from the service. |
148
-
149
- ### Assessment Taker
150
-
151
- To render the assessment taker interface, use the `<lib-assessment-taker>` component in your template.
152
-
153
- **`component.html`**:
154
- ```html
155
- <lib-assessment-taker
156
- [labelConfig]="{}"
157
- [imageConfig]="{}"
158
- [assessmentId]="2298"
159
- [assessmentInstanceId]="1135"
160
- [assesseeData]="assesseeData"
161
- [assessorData]="assessorData"
162
- [showFooter]="true"
163
- [disabled]="false"
164
- [previewMode]="false"
165
- [verticalView]="false"
166
- [enableMarks]="false"
167
- [assessmentContext]="assessmentContext"
168
- (submitAssessment)="onSubmit($event)"
169
- (snackbarMessage)="onSnackbarMessage($event)">
170
- </lib-assessment-taker>
171
- ```
172
-
173
- #### Taker Inputs and Outputs
174
-
175
- | Property | Type (`@Input` / `@Output`) | Data Type | Description |
176
- | --- | --- | --- | --- |
177
- | `[labelConfig]` | `@Input` | `{ [key: string]: string }` | (Optional) Configuration strings to overwrite internal labels. |
178
- | `[imageConfig]` | `@Input` | `{ [key: string]: string }` | (Optional) Configuration paths/URLs to overwrite internal icons or images. |
179
- | `[assessmentId]` | `@Input` | `number` | **Required.** Provide the ID of an existing assessment to take. |
180
- | `[assessmentInstanceId]` | `@Input` | `number` | **Required.** The published instance ID of the assessment. |
181
- | `[assesseeData]` | `@Input` | `AssesseeDTO` | **Required.** Data concerning the person taking the assessment. |
182
- | `[assessorData]` | `@Input` | `AssessorDTO` | **Required.** Data concerning the entity or person grading/creating the assessment. |
183
- | `[showFooter]` | `@Input` | `boolean` | (Optional) Toggles visibility of the assessment component footer actions. |
184
- | `[disabled]` | `@Input` | `boolean` | (Optional) Disables the form to prevent interaction. |
185
- | `[previewMode]` | `@Input` | `boolean` | (Optional) Disables interaction and enables preview functionality. |
186
- | `[verticalView]` | `@Input` | `boolean` | (Optional) Displays the assessment sections vertically instead of tabs. |
187
- | `[enableMarks]` | `@Input` | `boolean` | (Optional) Enables ability to view or provide marks. |
188
- | `[assessmentContext]` | `@Input` | `AssessmentContextDTO` | (Optional) Pre-loaded assessment context data to bypass the initial data load API call. |
189
- | `[assesseeResponse]` | `@Input` | `AssessmentInstanceAssesseDTO` | (Optional) Pre-loaded assessee response data to bypass the initial data load API call. |
190
- | `[hideSectionTabs]` | `@Input` | `boolean` | (Optional) Hides the section tabs. |
191
- | `[markAsCompleted]` | `@Input` | `boolean` | (Optional) Marks the assessment as completed when the last section is submitted. Default is true. |
192
- | `[sectionWiseScore]` | `@Input` | `{ [sectionId: number]: SectionScore }` | (Optional) Shows section wise score. Default is null. |
193
- | `[showOverallRemarks]` | `@Input` | `boolean` | (Optional) Shows overall remarks field. Default is false. |
194
- | `[showCorrectAnswers]` | `@Input` | `boolean` | (Optional) Shows correct and incorrect answers for objective and multiselect type questions. Default is false. |
195
- | `[enableSkillsToQuestionMapping]` | `@Input` | `boolean` | (Optional) Enables ability to map skills to questions. Default is false. |
196
- | `(stepChanged)` | `@Output` | `EventEmitter<{ currentStepIndex: number, totalSteps: number, isLastStep: boolean }>` | Emits initially and on every step change. Provides the current step index, total steps, and indicating boolean. |
197
- | `(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. |
198
- | `(snackbarMessage)` | `@Output` | `EventEmitter<{ message: string, type: 'success' \| 'error' \| 'info' }>` | Emits message status updates representing errors and workflow successes from the service. |
199
-
200
- ## Development Commands
201
-
202
- - Run `npm run build` or `ng build commons-assessment` to build the library project. The build artifacts will be stored in the `dist/` directory.
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+ usage.
8
+
9
+ ## Dependencies
10
+
11
+ The library uses Bootstrap styles and requires the following modules to be imported in your application:
12
+ - `BrowserAnimationsModule`
13
+ - `HttpClientModule`
14
+ - `CommonsAssessmentModule`
15
+ - `AssessmentMakerModule` (If creating assessments)
16
+ - `AssessmentTakerModule` (If rendering assessments)
17
+
18
+ ## Installation & Configuration
19
+
20
+ ### 1. Import Modules
21
+
22
+ Import the appropriate modules in your `app.module.ts`. You must configure `CommonsAssessmentModule` with `forRoot()` to provide the backend base URL.
23
+
24
+ ```typescript
25
+ import { CommonsAssessmentModule, AssessmentMakerModule, AssessmentTakerModule } from 'commons-assessment';
26
+
27
+ @NgModule({
28
+ imports: [
29
+ CommonsAssessmentModule.forRoot({
30
+ baseURL: 'https://dev.platformcommons.org', // Use your backend API base URL
31
+ }),
32
+ AssessmentMakerModule,
33
+ AssessmentTakerModule
34
+ ]
35
+ })
36
+ ```
37
+
38
+ ### 2. Configure `angular.json`
39
+
40
+ Add the necessary assets and global styles in your `angular.json` file inside the `architect.build.options` block.
41
+
42
+ **Assets:**
43
+ Add the library assets and angular-editor icons to the `assets` array.
44
+ ```json
45
+ "assets": [
46
+ {
47
+ "glob": "**/*",
48
+ "input": "node_modules/commons-assessment/src/lib/assets",
49
+ "output": "assets/commons-assessment"
50
+ },
51
+ {
52
+ "glob": "**/*",
53
+ "input": "node_modules/@kolkov/angular-editor/assets/icons",
54
+ "output": "assets/ae-icons/"
55
+ }
56
+ ]
57
+ ```
58
+
59
+ **Styles:**
60
+ Include the library's global styles and third-party dependencies in the `styles` array.
61
+ ```json
62
+ "styles": [
63
+ "src/styles.scss",
64
+ "node_modules/@kolkov/angular-editor/themes/default.scss"
65
+ ]
66
+ ```
67
+
68
+ ### 3. Theming Setup (`styles.scss`)
69
+
70
+ 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
+
72
+ ```scss
73
+ // Import the library's theme mixin
74
+ @use "/node_modules/commons-assessment/src/lib/assets/theme/theme.global" as theme;
75
+ @import "commons-assessment/src/lib/assets/theme/styles.global";
76
+ // Import Bootstrap and Material core styles
77
+ @import "~bootstrap/dist/css/bootstrap.min.css";
78
+ @import "@angular/material/prebuilt-themes/indigo-pink.css";
79
+
80
+ // Include customized variables into the theme
81
+ :root {
82
+ @include theme.assessment-theme(
83
+ (
84
+ font-family: "Poppins",
85
+ // You can override library palette by uncommenting and modifying below:
86
+ // primary-one: #2e7d32,
87
+ // primary-four: #1b5e20,
88
+ // palette-EDF3FD: #e8f5e9,
89
+ // grey-one: #fff,
90
+ )
91
+ );
92
+ }
93
+ ```
94
+
95
+ ## Component Usage
96
+
97
+ ### Assessment Maker
98
+
99
+ To render the assessment maker interface, use the `<lib-assessment-maker>` component in your template.
100
+
101
+ **`component.ts`**:
102
+ ```typescript
103
+
104
+ export class Component {
105
+ // Define default structure or data payload for the assessment
106
+ createAssessmentDTO: Assessment = {
107
+ assessmentCode: 'TEST_ASSESSMENT_CODE',
108
+ domain: 'domain.test',
109
+ assessmentName: [{
110
+ id: 0,
111
+ text: 'test assessment',
112
+ language: {
113
+ code: 'ENG',
114
+ }
115
+ }],
116
+ tenant: 123
117
+ };
118
+ }
119
+ ```
120
+
121
+ **`component.html`**:
122
+ ```html
123
+ <lib-assessment-maker
124
+ [defaultAssessmentDTO]="createAssessmentDTO"
125
+ [assessmentId]="2298"
126
+ [showFooter]="true">
127
+ </lib-assessment-maker>
128
+ ```
129
+
130
+ #### Maker Inputs and Outputs
131
+
132
+ | Property | Type (`@Input` / `@Output`) | Data Type | Description |
133
+ | --- | --- | --- | --- |
134
+ | `[labelConfig]` | `@Input` | `{ [key: string]: string }` | (Optional) Configuration strings to overwrite internal labels. |
135
+ | `[imageConfig]` | `@Input` | `{ [key: string]: string }` | (Optional) Configuration paths/URLs to overwrite internal icons or images. |
136
+ | `[questionTypes]` | `@Input` | `QuestionType[]` | (Optional) Restrict or customize the array of available question types. |
137
+ | `[showFooter]` | `@Input` | `boolean` | (Optional) Toggles visibility of the assessment component footer actions. |
138
+ | `[customRules]` | `@Input` | `any` | (Optional) Pass your custom question builder rules overrides. |
139
+ | `[assessmentId]` | `@Input` | `number` | Provide the ID of an existing assessment to edit or attach questions to. Default is 0. |
140
+ | `[assessmentInstanceId]` | `@Input` | `number` | Current assessment instance identifier, if the assessment is already published. Default is 0. |
141
+ | `[defaultAssessmentDTO]` | `@Input` | `Assessment` | The default contextual configuration object for creating new assessments. |
142
+ | `[predefinedAssessmentInstance]` | `@Input` | `AssessmentInstance` | The default contextual configuration object for creating new assessment instances. |
143
+ | `[minimumRequiredSections]` | `@Input` | `number` | Minimum number of sections needed before assessment can be published. Default is 0. |
144
+ | `[assessmentContext]` | `@Input` | `AssessmentContext` | (Optional) Pre-loaded assessment context data to bypass the initial data load API call. |
145
+ | `(assessmentIdChange)` | `@Output` | `EventEmitter<number>` | Emits the new `assessmentId` when an assessment is successfully created. |
146
+ | `(assessmentInstanceIdChange)` | `@Output` | `EventEmitter<number>` | Emits the new instance ID integer when an assessment is published. |
147
+ | `(snackbarMessage)` | `@Output` | `EventEmitter<{ message: string, type: 'success' \| 'error' \| 'info' }>` | Emits message status updates representing errors and workflow successes from the service. |
148
+
149
+ ### Assessment Taker
150
+
151
+ To render the assessment taker interface, use the `<lib-assessment-taker>` component in your template.
152
+
153
+ **`component.html`**:
154
+ ```html
155
+ <lib-assessment-taker
156
+ [labelConfig]="{}"
157
+ [imageConfig]="{}"
158
+ [assessmentId]="2298"
159
+ [assessmentInstanceId]="1135"
160
+ [assesseeData]="assesseeData"
161
+ [assessorData]="assessorData"
162
+ [showFooter]="true"
163
+ [disabled]="false"
164
+ [previewMode]="false"
165
+ [verticalView]="false"
166
+ [enableMarks]="false"
167
+ [assessmentContext]="assessmentContext"
168
+ (submitAssessment)="onSubmit($event)"
169
+ (snackbarMessage)="onSnackbarMessage($event)">
170
+ </lib-assessment-taker>
171
+ ```
172
+
173
+ #### Taker Inputs and Outputs
174
+
175
+ | Property | Type (`@Input` / `@Output`) | Data Type | Description |
176
+ | --- | --- | --- | --- |
177
+ | `[labelConfig]` | `@Input` | `{ [key: string]: string }` | (Optional) Configuration strings to overwrite internal labels. |
178
+ | `[imageConfig]` | `@Input` | `{ [key: string]: string }` | (Optional) Configuration paths/URLs to overwrite internal icons or images. |
179
+ | `[assessmentId]` | `@Input` | `number` | **Required.** Provide the ID of an existing assessment to take. |
180
+ | `[assessmentInstanceId]` | `@Input` | `number` | **Required.** The published instance ID of the assessment. |
181
+ | `[assesseeData]` | `@Input` | `AssesseeDTO` | **Required.** Data concerning the person taking the assessment. |
182
+ | `[assessorData]` | `@Input` | `AssessorDTO` | **Required.** Data concerning the entity or person grading/creating the assessment. |
183
+ | `[showFooter]` | `@Input` | `boolean` | (Optional) Toggles visibility of the assessment component footer actions. |
184
+ | `[disabled]` | `@Input` | `boolean` | (Optional) Disables the form to prevent interaction. |
185
+ | `[previewMode]` | `@Input` | `boolean` | (Optional) Disables interaction and enables preview functionality. |
186
+ | `[verticalView]` | `@Input` | `boolean` | (Optional) Displays the assessment sections vertically instead of tabs. |
187
+ | `[enableMarks]` | `@Input` | `boolean` | (Optional) Enables ability to view or provide marks. |
188
+ | `[assessmentContext]` | `@Input` | `AssessmentContextDTO` | (Optional) Pre-loaded assessment context data to bypass the initial data load API call. |
189
+ | `[assesseeResponse]` | `@Input` | `AssessmentInstanceAssesseDTO` | (Optional) Pre-loaded assessee response data to bypass the initial data load API call. |
190
+ | `[hideSectionTabs]` | `@Input` | `boolean` | (Optional) Hides the section tabs. |
191
+ | `[markAsCompleted]` | `@Input` | `boolean` | (Optional) Marks the assessment as completed when the last section is submitted. Default is true. |
192
+ | `[sectionWiseScore]` | `@Input` | `{ [sectionId: number]: SectionScore }` | (Optional) Shows section wise score. Default is null. |
193
+ | `[showOverallRemarks]` | `@Input` | `boolean` | (Optional) Shows overall remarks field. Default is false. |
194
+ | `[showCorrectAnswers]` | `@Input` | `boolean` | (Optional) Shows correct and incorrect answers for objective and multiselect type questions. Default is false. |
195
+ | `[enableSkillsToQuestionMapping]` | `@Input` | `boolean` | (Optional) Enables ability to map skills to questions. Default is false. |
196
+ | `(stepChanged)` | `@Output` | `EventEmitter<{ currentStepIndex: number, totalSteps: number, isLastStep: boolean }>` | Emits initially and on every step change. Provides the current step index, total steps, and indicating boolean. |
197
+ | `(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. |
198
+ | `(snackbarMessage)` | `@Output` | `EventEmitter<{ message: string, type: 'success' \| 'error' \| 'info' }>` | Emits message status updates representing errors and workflow successes from the service. |
199
+
200
+ ## Detailed Documentation
201
+
202
+ For a more comprehensive guide on features, detailed input/output variables, interfaces, custom events, and styling variables, please refer to the following documentation files:
203
+
204
+ - **Assessment Maker Component**: [assessment-maker.md](../../documentation/assessment-maker.md)
205
+ - **Assessment Taker Component**: [assessment-taker.md](../../documentation/assessment-taker.md)
206
+ - **Theming & Styles Guide**: [theme.md](../../documentation/theme.md)
207
+
208
+ ## Development Commands
209
+
210
+ - Run `npm run build` or `ng build commons-assessment` to build the library project. The build artifacts will be stored in the `dist/` directory.
203
211
  - Run `ng test commons-assessment` to execute the unit tests via [Karma](https://karma-runner.github.io).