This service is a Web API service which allows question sets to be organised and presented and their answers collected by exposing HTTP REST end points.
Nuget packages that go with this solution include:
- A .Net Core client library for QnA API HTTP REST end points
- Common types to interact with the QnA Api
- Asp.Net Core Views using GOV UK Design System
- Install .NET Core 2.2 SDK
- Install Visual Studio 2019 with the following workloads:
- ASP.NET and web development
- Install SQL Server 2017 Developer Edition
- Install SQL Management Studio
- Install Azure Storage Emulator (Make sure you are on at least v5.3)
- Install Azure Storage Explorer
- Administrator Access
- Clone this repository
- Open Visual Studio as an administrator
- Database - Build the solution
SFA.DAS.QnA.sln. Either use Visual Studio'sPublish Databasetool to publish the database projectSFA.DAS.QnA.Databaseto the database name{{database name}}on{{local instance name}}.- To include the latest question sets when publishing a database to your local SQL Server, you need to ensure that the
ProjectPathvariable contains the full path in the format{{drive}}:\{{project-folders}}\das-qna-api\src\SFA.DAS.QnA.Database\eg.C:\Source\Repos\SFA\das-qna-api\src\SFA.DAS.QnA.Database\Note: The required trailing backslash on the path in the example above.
- To include the latest question sets when publishing a database to your local SQL Server, you need to ensure that the
- or create a database manually named
{{database name}}on{{local instance name}}and run each of the.sqlscripts in theSFA.DAS.QnA.Databaseproject. - json file - Get the
das-qna-apiconfiguration json file from das-employer-config which is a non-public repository. - Azure Table Storage Config - Add the following to your Azure Table Storage Config.
PartitionKey: LOCAL
RowKey: SFA.DAS.QnA.Api_1.0
Data:
{{The contents of the local config json file}}
- Update Configuration
SFA.DAS.QnA.API_1.0with data{ "SqlConnectionstring":"Server={{local instance name}};Initial Catalog={{database name}};Trusted_Connection=True;" }
JSON configuration was created to work with dotnet run.
- Navigate to
src/SFA.DAS.QnA.API/ - run
dotnet restore - run
dotnet run
or
-
Set
SFA.DAS.QnA.APIas the startup project -
Running the solution will launch the API in your browser.
-
NB - To run a local copy you may also need:
- To create a JSON structure required to author updates and create new question sets: Config Tool
- To view how the question sets will be presented when integrated into a client application using GOV UK Design System and Config Preview
This project contains all of the application logic to handle requests.
This project enables functionality to store and read configuration from Microsoft Azure Storage.
-
AzureActiveDirectoryConfiguration
- Azure Managed Identity authentication
-
FileStorageConfig
- Information relating to storage of files
-
QnAConfig
- Connection string for the QnA Database
This is the database project containing setup in order to the create the QnA Database.
-
projects
- A subfolder should be created per project.
-
projects/{subfolder}/project.json- Contains information on how to setup the Workflow information.
-
projects/{subfolder}/ApplicationDataSchema.json- Contains JSON schema to validate ApplicationData.
-
projects/{subfolder}/sections- Holds QnAData for each WorkflowSection.
A Workflow is made up of multiple sequences. Each sequence may have multiple sections.
The QnAData within each section defines the flow and logic. There are multiple pages consisting of questions and relevant answers. Depending on the answers provided, it will decide which pages are active.
Questions should have a unique Id, an optional QuestionTag and a particular input type. If the input has different options to select from, you may want to include FutherQuestions to allow a related/follow up question (i.e. Yes selected, so now need to provide more details).
Most types are self explanatory and in most cases have they will have built-in validators.
TabularDatais a JSON structure that represents a table storage format (i.e. header and rows).FileUploadis for uploading files. Note that this type should POST the Answer/Files to the File Upload endpoint and not the Save Answers end point.ComplexRadio&ComplexCheckboxListenable the use ofFutherQuestionsbased on the option being selected.
These are the primary mechanism to dictate logic flow within a section. Should a QuestionId or QuestionTag match the Next condition then that specified page will be made active. Any conditions that do not match will make that specified page inactive.
NextPage - Go to the next page
Any other value can be specified. This is intended to allow the calling application to decide the logic. Other actions could be ReturnToSection or TaskList.
There are situations where Next Conditions cannot control the page flow (i.e. determining the entry point to the first page within a section based on a particular value).
NotRequiredConditions is a way for QnA Api to remove pages from the response payload back to the user.
This codebase includes unit tests.
There are two unit test projects, each named after the project that their tests cover. These tests use Moq, FluentAssertions, NewtonSoft, MediatR, and NUnit.
SFA.DAS.QnA.Api.UnitTestsSFA.DAS.QnA.Application.UnitTests