The **Questionnaire Player** is a web component built with Angular (version 16.2.1).
npm install questionnaire-webcomponentThe Questionnaire Player is a web component built with Angular (version 16.2.1).
- Angular 16
- Node.js 16.19.0
1. Run npm install after cloning the repo locally to install the necessary dependencies.
2. Run npm run build-web-comp to build the player with the latest changes and reflect the updates in the web component.
3. Navigate to projects/questionnaire-app and run ng serve for a dev server. Open http://localhost:4200/ in your browser. The application will automatically reload when source files are changed.
- If changes are made to the library, running npm run build-web-comp will automatically reflect those changes in the demo app (applicable only to this Angular app, not the React demo app).
4. The web component can be installed by running:
``bash`
npm i questionnaire-webcomponent
5. In angular.json, include the published web component script under the "scripts" section (navigate to projects -> questionnaire-app -> architect -> build).
6. Path to the web component script:
`bash`
"scripts":[... , "node_modules/questionnaire-webcomponent/questionnaire-player-webcomponent.js"]
To include the npm-published styles of the web component, add the following path to the "styles" section in angular.json:
"styles":[... , "node_modules/questionnaire-webcomponent/styles.scss"]
For usage in a React app, visit the React demo repository - https://github.com/5Amogh/react-usingwebcomponent-app
1. API-based Data Fetching
- The component accepts a solution ID and configuration options via an apiConfig object.
- It fetches questionnaire data dynamically through API calls based on the provided solution ID.
2. Configurable Theming
- Theming is flexible and configurable at the application level using CSS variables, allowing for seamless integration into various applications with customized designs.
3. Pagination
- A built-in pagination system makes it easy to navigate through multi-page questionnaires.
4. Question Map (Navigation)
- A question map provides a visual overview of progress:
- Filled questions are marked in green.
- Mandatory unfilled questions are highlighted in red.
- Non-mandatory unfilled questions are shown in light green.
- Clicking on a question in the map allows users to directly navigate to that question.
`html`ngOnChanges
If you are using the webcomponent inside an angular application, use the attribute angular in questionnaire-player-main tag to help the webcomponent detect the input changes inside
In your Angular component, you can configure the apiConfig object as follows:
`typescript`
apiConfig = {
baseURL: '
fileSizeLimit:
userAuthToken: '
solutionId: '
solutionType: 'survey' | 'observation'
}
):
`css
:root {
--primary-color: 1B4CA1;
--btn-outline: 1B4CA1;
--error-color: rgb(150, 4, 4);
--question-tip: gray;
--general-btn-text-color: white;
--general-btn-hover-bg: white;
--secondary-btn-bg: white;
--secondary-btn-hover-bg: whitesmoke;
--card-bg: white;
--disabled-btn-bg: gainsboro;
--disabled-btn-text: gray;
}
``npm run build-web-comp