Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2,324 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Question and Answer API

UK Government logo

Build Status Quality Gate Status Confluence Project License

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 QnA API Client
  • Common types to interact with the QnA Api QnA API Types
  • Asp.Net Core Views using GOV UK Design System QnA API Views

Developer Setup

Requirements

Environment Setup

  • Clone this repository
  • Open Visual Studio as an administrator
  • Database - Build the solution SFA.DAS.QnA.sln. Either use Visual Studio's Publish Database tool to publish the database project SFA.DAS.QnA.Database to 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 ProjectPath variable 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.
  • or create a database manually named {{database name}} on {{local instance name}} and run each of the .sql scripts in the SFA.DAS.QnA.Database project.
  • json file - Get the das-qna-api configuration 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.0 with data { "SqlConnectionstring":"Server={{local instance name}};Initial Catalog={{database name}};Trusted_Connection=True;" }

Running

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.API as 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

SFA.DAS.QnA.Application

This project contains all of the application logic to handle requests.

SFA.DAS.QnA.Configuration

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

SFA.DAS.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.

QnA Structure

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.

Question

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).

Question Type

Most types are self explanatory and in most cases have they will have built-in validators.

  • TabularData is a JSON structure that represents a table storage format (i.e. header and rows).
  • FileUpload is 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 & ComplexCheckboxList enable the use of FutherQuestions based on the option being selected.
Next Conditions

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.

Next Actions

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.

NotRequired Conditions

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.

Tests

This codebase includes unit tests.

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.UnitTests
  • SFA.DAS.QnA.Application.UnitTests

Releases

Packages

Used by

Contributors

Languages