From 0ade2f33aaea3689d12ed791eb2284aeb8cf9104 Mon Sep 17 00:00:00 2001 From: Rich Bielby Date: Tue, 26 Nov 2024 15:09:18 +0000 Subject: [PATCH 01/16] Created initial accessibility panel function --- NAMESPACE | 1 + R/a11y_panel.R | 176 ++++++++++++++++++++++++++++++++ inst/www/DfE_logo_landscape.svg | 92 +++++++++++++++++ man/a11y_panel.Rd | 48 +++++++++ 4 files changed, 317 insertions(+) create mode 100644 R/a11y_panel.R create mode 100644 inst/www/DfE_logo_landscape.svg create mode 100644 man/a11y_panel.Rd diff --git a/NAMESPACE b/NAMESPACE index 433f608..0ba2b68 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +export(a11y_panel) export(cookies_banner_server) export(cookies_banner_ui) export(cookies_panel_server) diff --git a/R/a11y_panel.R b/R/a11y_panel.R new file mode 100644 index 0000000..7e3f2f6 --- /dev/null +++ b/R/a11y_panel.R @@ -0,0 +1,176 @@ +#' Accessibility panel +#' +#' @param dashboard_title Title of the host dashboard +#' @param dashboard_link URL for the host dashboard +#' @param public_repo_link URL for the dashboard repository +#' @param non_accessible_components String vector containing a list of non accessible components +#' @param specific_issues String vector containing descriptions of specific accessibility issues +#' that have been identified as part of testing +#' @param date_prepared Date the statement was prepared in it's current form +#' @param date_reviewed Date the statement was last reviewed +#' +#' @return shiny$tags$div element containing the html tags and content for the standard +#' accessibility statement +#' @export +#' +#' @examples +#' a11y_panel( +#' "DfE Shiny template", +#' "26th November 2024", +#' "26th November 2024", +#' "https://department-for-education.shinyapps.io/dfe-shiny-template", +#' public_repo_link = "https://github.com/dfe-analytical-services/shiny-template", +#' ) +a11y_panel <- function( + dashboard_title, + dashboard_link, + date_prepared, + date_reviewed, + public_repo_link = NA, + non_accessible_components = NA, + specific_issues = NA) { + shiny::tags$div( + "Accessibility", + shiny::tags$div( + shiny::tags$h1(paste0("Accessibility statement for ", dashboard_title)), + shiny::tags$p( + "This accessibility statement applies to the", + dashboard_link, + "website. This website is run by the ", + external_link( + href = "https://www.gov.uk/government/organisations/department-for-education", + "Department for Education (DfE)" + ), + ".", + "This statement does not cover any other services run by the Department for Education (DfE) or GOV.UK." + ), + shiny::tags$h2("How you should be able to use this website"), + shiny::tags$p("We want as many people as possible to be able to use this website. You should be able to:"), + shiny::tags$div(tags$ul( + shiny::tags$li("change colours, contrast levels and fonts using browser or device settings"), + shiny::tags$li("zoom in up to 400% without the text spilling off the screen"), + shiny::tags$li("navigate most of the website using a keyboard or speech recognition software"), + shiny::tags$li("listen to most of the website using a screen reader + (including the most recent versions of JAWS, NVDA and VoiceOver)") + )), + shiny::tags$p("We’ve also made the website text as simple as possible to understand."), + shiny::tags$p( + external_link(href = "https://mcmw.abilitynet.org.uk/", "AbilityNet"), + " has advice on making your device easier to use if you have a disability." + ), + shiny::tags$h2("How accessible this website is"), + shiny::tags$p("We know some parts of this website are not fully accessible:"), + shiny::tags$div(tags$ul( + tagList(lapply(non_accessible_components, shiny::tags$li)) + )), # TODO + shiny::tags$h2("Feedback and contact information"), + shiny::tags$p( + "If you need information on this website in a different format please see the parent", + "publications", + external_link( + href = "https://explore-education-statistics.service.gov.uk/find-statistics", + "on Explore education statistics" + ), + ", as detailed on the data sources page of this service.", + ". More details are available on that service for alternative formats of this data.", + ), + shiny::tags$p("We’re always looking to improve the accessibility of this website. + If you find any problems not listed on this page or think we’re not meeting + accessibility requirements, contact us:"), + shiny::tags$ul(tags$li( + shiny::tags$a( + href = "mailto:explore.statistics@education.gov.uk", + "explore.statistics@education.gov.uk" + ) + )), + shiny::tags$h2("Enforcement procedure"), + shiny::tags$p("The Equality and Human Rights Commission (EHRC) is responsible for enforcing the Public Sector Bodies + (Websites and Mobile Applications) (No. 2) Accessibility Regulations 2018 + (the ‘accessibility regulations’)."), + shiny::tags$p( + "If you are not happy with how we respond to your complaint, ", + external_link( + href = "https://www.equalityadvisoryservice.com/", + "contact the Equality Advisory and Support Service (EASS)" + ), + "." + ), + shiny::tags$h2("Technical information about this website's accessibility"), + shiny::tags$p("The Department for Education (DfE) is committed to making its website accessible, in accordance with the + Public Sector Bodies (Websites and Mobile Applications) (No. 2) Accessibility Regulations 2018."), + shiny::tags$h3("Compliance status"), + shiny::tags$p( + "This website is partially compliant with the ", + external_link( + href = "https://www.w3.org/TR/WCAG22/", + "Web Content Accessibility Guidelines version 2.2 AA standard" + ), + " due to the non-compliances listed below." + ), + shiny::tags$h3("Non accessible content"), + shiny::tags$p("The content listed below is non-accessible for the following reasons. + We will address these issues to ensure our content is accessible."), + shiny::tags$div(tags$ul( + tagList(lapply(specific_issues, shiny::tags$li)) + )), + shiny::tags$h3("Disproportionate burden"), + shiny::tags$p("Not applicable."), + shiny::tags$h2("How we tested this website"), + shiny::tags$p( + "The template used for this website was last tested on 12 March 2024 against ", + external_link( + href = "https://www.w3.org/TR/WCAG22/", + "Accessibility Guidelines WCAG2.2" + ), + ". The test was carried out by the ", + external_link( + href = "https://digitalaccessibilitycentre.org/", + "Digital accessibility centre (DAC)" + ), + "." + ), + shiny::tags$p("DAC tested a sample of pages to cover the core functionality of the service including:"), + shiny::tags$div(tags$ul( + shiny::tags$li("navigation"), + shiny::tags$li("interactive dropdown selections"), + shiny::tags$li("charts, maps, and tables") + )), + shiny::tags$p( + "This specific website was was last tested on 8th October 2024 against ", + external_link( + href = "https://www.w3.org/TR/WCAG22/", + "Accessibility Guidelines WCAG2.2" + ), + ". The test was carried out by the ", + external_link( + href = "https://www.gov.uk/government/organisations/department-for-education", + "Department for Education (DfE)" + ), + "." + ), + shiny::tags$h2("What we're doing to improve accessibility"), + shiny::tags$p("We plan to continually test the service for accessibility issues, and are working through a prioritised + list of issues to resolve."), + shiny::tags$p( + "Our current list of issues to be resolved is available on our ", + external_link( + href = paste0(public_repo_link, "/issues"), + "GitHub issues page" + ), + "." + ), + shiny::tags$h2("Preparation of this accessibility statement"), + shiny::tags$p("This statement was prepared on 1st July 2024. It was last reviewed on 8th October 2024."), + shiny::tags$p( + "The template used for this website was last tested in March 2024 against the WCAG 2.2 AA standard. + This test of a representative sample of pages was carried out by the ", + external_link( + href = "https://digitalaccessibilitycentre.org/", + "Digital accessibility centre (DAC)" + ), + "." + ), + shiny::tags$p("We also used findings from our own testing when preparing this accessibility statement.") + ) + ) +} diff --git a/inst/www/DfE_logo_landscape.svg b/inst/www/DfE_logo_landscape.svg new file mode 100644 index 0000000..6602add --- /dev/null +++ b/inst/www/DfE_logo_landscape.svg @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/man/a11y_panel.Rd b/man/a11y_panel.Rd new file mode 100644 index 0000000..29746b7 --- /dev/null +++ b/man/a11y_panel.Rd @@ -0,0 +1,48 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/a11y_panel.R +\name{a11y_panel} +\alias{a11y_panel} +\title{Accessibility panel} +\usage{ +a11y_panel( + dashboard_title, + dashboard_link, + date_prepared, + date_reviewed, + public_repo_link = NA, + non_accessible_components = NA, + specific_issues = NA +) +} +\arguments{ +\item{dashboard_title}{Title of the host dashboard} + +\item{dashboard_link}{URL for the host dashboard} + +\item{date_prepared}{Date the statement was prepared in it's current form} + +\item{date_reviewed}{Date the statement was last reviewed} + +\item{public_repo_link}{URL for the dashboard repository} + +\item{non_accessible_components}{String vector containing a list of non accessible components} + +\item{specific_issues}{String vector containing descriptions of specific accessibility issues +that have been identified as part of testing} +} +\value{ +shiny$tags$div element containing the html tags and content for the standard +accessibility statement +} +\description{ +Accessibility panel +} +\examples{ +a11y_panel( +"DfE Shiny template", +"26th November 2024", +"26th November 2024", +"https://department-for-education.shinyapps.io/dfe-shiny-template", +public_repo_link = "https://github.com/dfe-analytical-services/shiny-template", +) +} From 029fa80f62adebc6d811fc5d5a022a75c2028b85 Mon Sep 17 00:00:00 2001 From: Rich Bielby Date: Mon, 2 Dec 2024 15:53:46 +0000 Subject: [PATCH 02/16] Adding to docs --- R/a11y_panel.R | 5 ++++- R/validation.R | 17 +++++++++++++++++ man/a11y_panel.Rd | 1 + man/validate_date.Rd | 17 +++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 R/validation.R create mode 100644 man/validate_date.Rd diff --git a/R/a11y_panel.R b/R/a11y_panel.R index 7e3f2f6..98bfdd7 100644 --- a/R/a11y_panel.R +++ b/R/a11y_panel.R @@ -26,6 +26,7 @@ a11y_panel <- function( dashboard_link, date_prepared, date_reviewed, + date_template_reviewed = "12th March 2024", public_repo_link = NA, non_accessible_components = NA, specific_issues = NA) { @@ -117,7 +118,9 @@ a11y_panel <- function( shiny::tags$p("Not applicable."), shiny::tags$h2("How we tested this website"), shiny::tags$p( - "The template used for this website was last tested on 12 March 2024 against ", + "The template used for this website was last tested on", + date_template_reviewed, + " against ", external_link( href = "https://www.w3.org/TR/WCAG22/", "Accessibility Guidelines WCAG2.2" diff --git a/R/validation.R b/R/validation.R new file mode 100644 index 0000000..ec6d292 --- /dev/null +++ b/R/validation.R @@ -0,0 +1,17 @@ +#' Date validation +#' +#' @param date Element to be validated as a date +#' +#' @return String containing validation message +#' +validate_date <- function(date){ + date.ld <- lubridate::dmy(date) + if(is.na(date.ld)){ + validation_message <- "not in a valid date format." + } else if (date.ld > Sys.time()){ + validation_message <- "is in the future." + } else { + validation_message <- "is a valid date." + } + return(validation_message) +} diff --git a/man/a11y_panel.Rd b/man/a11y_panel.Rd index 29746b7..deb0d30 100644 --- a/man/a11y_panel.Rd +++ b/man/a11y_panel.Rd @@ -9,6 +9,7 @@ a11y_panel( dashboard_link, date_prepared, date_reviewed, + date_template_reviewed = "12th March 2024", public_repo_link = NA, non_accessible_components = NA, specific_issues = NA diff --git a/man/validate_date.Rd b/man/validate_date.Rd new file mode 100644 index 0000000..56d2f85 --- /dev/null +++ b/man/validate_date.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/validation.R +\name{validate_date} +\alias{validate_date} +\title{Date validation} +\usage{ +validate_date(date) +} +\arguments{ +\item{date}{Element to be validated as a date} +} +\value{ +String containing validation message +} +\description{ +Date validation +} From 9720a05e1b55dae5b5ac43dfae104f0af31b4394 Mon Sep 17 00:00:00 2001 From: Rich Bielby Date: Mon, 2 Dec 2024 17:52:08 +0000 Subject: [PATCH 03/16] Added in dynamic variable updates for a11y panel --- DESCRIPTION | 1 + R/a11y_panel.R | 175 ++++++++++++++++++++++++++------------ R/validation.R | 15 ++-- _pkgdown.yml | 1 + man/a11y_panel.Rd | 27 ++++-- tests/test_dashboard/ui.R | 13 +++ 6 files changed, 166 insertions(+), 66 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index eff3d83..f43890d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,6 +18,7 @@ Imports: checkmate, glue, htmltools, + lubridate, magrittr, RCurl, shiny, diff --git a/R/a11y_panel.R b/R/a11y_panel.R index 98bfdd7..79de344 100644 --- a/R/a11y_panel.R +++ b/R/a11y_panel.R @@ -6,8 +6,11 @@ #' @param non_accessible_components String vector containing a list of non accessible components #' @param specific_issues String vector containing descriptions of specific accessibility issues #' that have been identified as part of testing +#' @param date_tested Date the application was last tested #' @param date_prepared Date the statement was prepared in it's current form #' @param date_reviewed Date the statement was last reviewed +#' @param date_template_reviewed Date the underlying template was reviewed +#' (default: 12th March 2024) #' #' @return shiny$tags$div element containing the html tags and content for the standard #' accessibility statement @@ -15,21 +18,36 @@ #' #' @examples #' a11y_panel( -#' "DfE Shiny template", -#' "26th November 2024", -#' "26th November 2024", -#' "https://department-for-education.shinyapps.io/dfe-shiny-template", -#' public_repo_link = "https://github.com/dfe-analytical-services/shiny-template", +#' "DfE Shiny template", +#' "https://department-for-education.shinyapps.io/dfe-shiny-template", +#' "25th April 2024", +#' "26th April 2024", +#' "2nd November 2024", +#' public_repo_link = "https://github.com/dfe-analytical-services/shiny-template", #' ) a11y_panel <- function( dashboard_title, dashboard_link, + date_tested, date_prepared, date_reviewed, date_template_reviewed = "12th March 2024", public_repo_link = NA, - non_accessible_components = NA, - specific_issues = NA) { + non_accessible_components = c( + "Keyboard navigation through the interactive charts is currently limited", + "Alternative text in interactive charts is limited to titles" + ), + specific_issues = c( + "Charts have non-accessible components that are inaccessible for keyboard users.", + "Chart tooltips are not compativle with screen reader use.", + "Some decorative images are not labelled appropriately as yet.", + "Some links are not appropriately labelled." + )) { + # Validate inputs + validate_date(date_tested) + validate_date(date_prepared) + validate_date(date_reviewed) + validate_date(date_template_reviewed) shiny::tags$div( "Accessibility", shiny::tags$div( @@ -43,27 +61,44 @@ a11y_panel <- function( "Department for Education (DfE)" ), ".", - "This statement does not cover any other services run by the Department for Education (DfE) or GOV.UK." + "This statement does not cover any other services run by the Department for Education ", + "(DfE) or GOV.UK." ), shiny::tags$h2("How you should be able to use this website"), - shiny::tags$p("We want as many people as possible to be able to use this website. You should be able to:"), + shiny::tags$p( + "We want as many people as possible to be able to use this website. You should be able to:" + ), shiny::tags$div(tags$ul( - shiny::tags$li("change colours, contrast levels and fonts using browser or device settings"), - shiny::tags$li("zoom in up to 400% without the text spilling off the screen"), - shiny::tags$li("navigate most of the website using a keyboard or speech recognition software"), - shiny::tags$li("listen to most of the website using a screen reader - (including the most recent versions of JAWS, NVDA and VoiceOver)") + shiny::tags$li( + "change colours, contrast levels and fonts using browser or device settings" + ), + shiny::tags$li( + "zoom in up to 400% without the text spilling off the screen" + ), + shiny::tags$li( + "navigate most of the website using a keyboard or speech recognition software" + ), + shiny::tags$li( + "listen to most of the website using a screen reader + (including the most recent versions of JAWS, NVDA and VoiceOver)" + ) )), - shiny::tags$p("We’ve also made the website text as simple as possible to understand."), + shiny::tags$p("We've also made the website text as simple as possible to understand."), shiny::tags$p( external_link(href = "https://mcmw.abilitynet.org.uk/", "AbilityNet"), " has advice on making your device easier to use if you have a disability." ), shiny::tags$h2("How accessible this website is"), - shiny::tags$p("We know some parts of this website are not fully accessible:"), - shiny::tags$div(tags$ul( - tagList(lapply(non_accessible_components, shiny::tags$li)) - )), # TODO + if (all(is.na(non_accessible_components))) { + shiny::tags$p("This website is fully compliant with accessibility standards.") + } else { + shiny::tagList( + shiny::tags$p("We know some parts of this website are not fully accessible:"), + shiny::tags$div(tags$ul( + tagList(lapply(non_accessible_components, shiny::tags$li)) + )) + ) + }, shiny::tags$h2("Feedback and contact information"), shiny::tags$p( "If you need information on this website in a different format please see the parent", @@ -75,8 +110,8 @@ a11y_panel <- function( ", as detailed on the data sources page of this service.", ". More details are available on that service for alternative formats of this data.", ), - shiny::tags$p("We’re always looking to improve the accessibility of this website. - If you find any problems not listed on this page or think we’re not meeting + shiny::tags$p("We're always looking to improve the accessibility of this website. + If you find any problems not listed on this page or think we're not meeting accessibility requirements, contact us:"), shiny::tags$ul(tags$li( shiny::tags$a( @@ -85,9 +120,11 @@ a11y_panel <- function( ) )), shiny::tags$h2("Enforcement procedure"), - shiny::tags$p("The Equality and Human Rights Commission (EHRC) is responsible for enforcing the Public Sector Bodies - (Websites and Mobile Applications) (No. 2) Accessibility Regulations 2018 - (the ‘accessibility regulations’)."), + shiny::tags$p( + "The Equality and Human Rights Commission (EHRC) is responsible for enforcing the Public ", + "Sector Bodies (Websites and Mobile Applications) (No. 2) Accessibility Regulations 2018", + "(the \"accessibility regulations\")." + ), shiny::tags$p( "If you are not happy with how we respond to your complaint, ", external_link( @@ -97,23 +134,39 @@ a11y_panel <- function( "." ), shiny::tags$h2("Technical information about this website's accessibility"), - shiny::tags$p("The Department for Education (DfE) is committed to making its website accessible, in accordance with the - Public Sector Bodies (Websites and Mobile Applications) (No. 2) Accessibility Regulations 2018."), - shiny::tags$h3("Compliance status"), shiny::tags$p( - "This website is partially compliant with the ", - external_link( - href = "https://www.w3.org/TR/WCAG22/", - "Web Content Accessibility Guidelines version 2.2 AA standard" - ), - " due to the non-compliances listed below." + "The Department for Education (DfE) is committed to making its website accessible, in ", + "accordance with the Public Sector Bodies (Websites and Mobile Applications) (No. 2) ", + "Accessibility Regulations 2018." ), - shiny::tags$h3("Non accessible content"), - shiny::tags$p("The content listed below is non-accessible for the following reasons. + shiny::tags$h3("Compliance status"), + if (all(is.na(specific_issues))) { + shiny::tags$p( + "This website is fully compliant with the ", + external_link( + href = "https://www.w3.org/TR/WCAG22/", + "Web Content Accessibility Guidelines version 2.2 AA standard" + ), + "." + ) + } else { + shiny::tagList( + shiny::tags$p( + "This website is partially compliant with the ", + external_link( + href = "https://www.w3.org/TR/WCAG22/", + "Web Content Accessibility Guidelines version 2.2 AA standard" + ), + " due to the non-compliances listed below." + ), + shiny::tags$h3("Non accessible content"), + shiny::tags$p("The content listed below is non-accessible for the following reasons. We will address these issues to ensure our content is accessible."), - shiny::tags$div(tags$ul( - tagList(lapply(specific_issues, shiny::tags$li)) - )), + shiny::tags$div(tags$ul( + tagList(lapply(specific_issues, shiny::tags$li)) + )) + ) + }, shiny::tags$h3("Disproportionate burden"), shiny::tags$p("Not applicable."), shiny::tags$h2("How we tested this website"), @@ -132,14 +185,16 @@ a11y_panel <- function( ), "." ), - shiny::tags$p("DAC tested a sample of pages to cover the core functionality of the service including:"), + shiny::tags$p( + "DAC tested a sample of pages to cover the core functionality of the service including:" + ), shiny::tags$div(tags$ul( shiny::tags$li("navigation"), shiny::tags$li("interactive dropdown selections"), shiny::tags$li("charts, maps, and tables") )), shiny::tags$p( - "This specific website was was last tested on 8th October 2024 against ", + "This specific website was was last tested on ", date_tested, " against ", external_link( href = "https://www.w3.org/TR/WCAG22/", "Accessibility Guidelines WCAG2.2" @@ -152,28 +207,40 @@ a11y_panel <- function( "." ), shiny::tags$h2("What we're doing to improve accessibility"), - shiny::tags$p("We plan to continually test the service for accessibility issues, and are working through a prioritised - list of issues to resolve."), shiny::tags$p( - "Our current list of issues to be resolved is available on our ", - external_link( - href = paste0(public_repo_link, "/issues"), - "GitHub issues page" - ), - "." + "We plan to continually test the service for accessibility issues, and are working ", + "through a prioritised list of issues to resolve." + ), + shiny::tags$p( + if (!is.na(public_repo_link)) { + shiny::tagList( + "Our current list of issues to be resolved is available on our ", + external_link( + href = paste0(public_repo_link, "/issues"), + "GitHub issues page" + ), + "." + ) + } else { + " " + }, ), shiny::tags$h2("Preparation of this accessibility statement"), - shiny::tags$p("This statement was prepared on 1st July 2024. It was last reviewed on 8th October 2024."), shiny::tags$p( - "The template used for this website was last tested in March 2024 against the WCAG 2.2 AA standard. - This test of a representative sample of pages was carried out by the ", + paste0( + "This statement was prepared on ", + date_prepared, + " and last reviewed on ", + date_reviewed, + "." + ), + "The statement was produced based on a combination of testing carried out by the ", external_link( href = "https://digitalaccessibilitycentre.org/", "Digital accessibility centre (DAC)" ), - "." - ), - shiny::tags$p("We also used findings from our own testing when preparing this accessibility statement.") + " and our own testing." + ) ) ) } diff --git a/R/validation.R b/R/validation.R index ec6d292..57e767b 100644 --- a/R/validation.R +++ b/R/validation.R @@ -4,14 +4,19 @@ #' #' @return String containing validation message #' -validate_date <- function(date){ - date.ld <- lubridate::dmy(date) - if(is.na(date.ld)){ +validate_date <- function(date) { + date_ld <- lubridate::dmy(date) + if (is.na(date_ld)) { + valid <- FALSE validation_message <- "not in a valid date format." - } else if (date.ld > Sys.time()){ + } else if (date_ld > Sys.time()) { + valid <- FALSE validation_message <- "is in the future." } else { + valid <- TRUE validation_message <- "is a valid date." } - return(validation_message) + if (!valid) { + stop(paste(date, validation_message)) + } } diff --git a/_pkgdown.yml b/_pkgdown.yml index 7e34b2b..1e51cb2 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -25,6 +25,7 @@ reference: - tidy_code - title: Standard panels contents: + - a11y_panel - support_panel - section_tags - title: Header diff --git a/man/a11y_panel.Rd b/man/a11y_panel.Rd index deb0d30..46712b2 100644 --- a/man/a11y_panel.Rd +++ b/man/a11y_panel.Rd @@ -7,12 +7,19 @@ a11y_panel( dashboard_title, dashboard_link, + date_tested, date_prepared, date_reviewed, date_template_reviewed = "12th March 2024", public_repo_link = NA, - non_accessible_components = NA, - specific_issues = NA + non_accessible_components = + c("Keyboard navigation through the interactive charts is currently limited", + "Alternative text in interactive charts is limited to titles"), + specific_issues = + c("Charts have non-accessible components that are inaccessible for keyboard users.", + "Chart tooltips are not compativle with screen reader use.", + "Some decorative images are not labelled appropriately as yet.", + "Some links are not appropriately labelled.") ) } \arguments{ @@ -20,10 +27,15 @@ a11y_panel( \item{dashboard_link}{URL for the host dashboard} +\item{date_tested}{Date the application was last tested} + \item{date_prepared}{Date the statement was prepared in it's current form} \item{date_reviewed}{Date the statement was last reviewed} +\item{date_template_reviewed}{Date the underlying template was reviewed +(default: 12th March 2024)} + \item{public_repo_link}{URL for the dashboard repository} \item{non_accessible_components}{String vector containing a list of non accessible components} @@ -40,10 +52,11 @@ Accessibility panel } \examples{ a11y_panel( -"DfE Shiny template", -"26th November 2024", -"26th November 2024", -"https://department-for-education.shinyapps.io/dfe-shiny-template", -public_repo_link = "https://github.com/dfe-analytical-services/shiny-template", + "DfE Shiny template", + "https://department-for-education.shinyapps.io/dfe-shiny-template", + "25th April 2024", + "26th April 2024", + "2nd November 2024", + public_repo_link = "https://github.com/dfe-analytical-services/shiny-template", ) } diff --git a/tests/test_dashboard/ui.R b/tests/test_dashboard/ui.R index 1d01f12..782e279 100644 --- a/tests/test_dashboard/ui.R +++ b/tests/test_dashboard/ui.R @@ -38,6 +38,19 @@ ui <- function(input, output, session) { form_url = "https://forms.office.com" ) ), + ## Accessibility panel -------------------------------------------------------- + shiny::tabPanel( + value = "a11y_panel", + "Accessibility", + a11y_panel( + "DfE Shiny template", + "https://department-for-education.shinyapps.io/dfe-shiny-template", + "26th November 2024", + "28th November 2024", + "12th March 2024", + public_repo_link = "https://github.com/dfe-analytical-services/shiny-template" + ) + ), ## Cookies panel -------------------------------------------------------- shiny::tabPanel( From 0c634f6dd52bc8eebb60fe18a06205ab48dd5943 Mon Sep 17 00:00:00 2001 From: Rich Bielby Date: Mon, 2 Dec 2024 18:13:11 +0000 Subject: [PATCH 04/16] Made validate_date to internal only --- R/validation.R | 2 +- man/validate_date.Rd | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/R/validation.R b/R/validation.R index 57e767b..dc3a3f4 100644 --- a/R/validation.R +++ b/R/validation.R @@ -2,8 +2,8 @@ #' #' @param date Element to be validated as a date #' +#' @keywords internal #' @return String containing validation message -#' validate_date <- function(date) { date_ld <- lubridate::dmy(date) if (is.na(date_ld)) { diff --git a/man/validate_date.Rd b/man/validate_date.Rd index 56d2f85..154aef2 100644 --- a/man/validate_date.Rd +++ b/man/validate_date.Rd @@ -15,3 +15,4 @@ String containing validation message \description{ Date validation } +\keyword{internal} From 852c31b2cf4deb4bb29e36f519beb0cd93ff4d4e Mon Sep 17 00:00:00 2001 From: Rich Bielby Date: Wed, 4 Dec 2024 14:02:24 +0000 Subject: [PATCH 05/16] Added tests and validation to a11y_panel --- R/a11y_panel.R | 30 +++--- R/support_panel.R | 18 +--- R/validation.R | 35 +++++-- man/a11y_panel.Rd | 12 +-- man/validate_date.Rd | 18 ---- tests/test_dashboard/ui.R | 2 +- tests/testthat/test-a11y_panel.R | 152 +++++++++++++++++++++++++++++++ 7 files changed, 205 insertions(+), 62 deletions(-) delete mode 100644 man/validate_date.Rd create mode 100644 tests/testthat/test-a11y_panel.R diff --git a/R/a11y_panel.R b/R/a11y_panel.R index 79de344..8fad4e4 100644 --- a/R/a11y_panel.R +++ b/R/a11y_panel.R @@ -1,8 +1,8 @@ #' Accessibility panel #' #' @param dashboard_title Title of the host dashboard -#' @param dashboard_link URL for the host dashboard -#' @param public_repo_link URL for the dashboard repository +#' @param dashboard_url URL for the host dashboard +#' @param repo_url URL for the dashboard repository #' @param non_accessible_components String vector containing a list of non accessible components #' @param specific_issues String vector containing descriptions of specific accessibility issues #' that have been identified as part of testing @@ -23,16 +23,16 @@ #' "25th April 2024", #' "26th April 2024", #' "2nd November 2024", -#' public_repo_link = "https://github.com/dfe-analytical-services/shiny-template", +#' repo_url = "https://github.com/dfe-analytical-services/shiny-template", #' ) a11y_panel <- function( dashboard_title, - dashboard_link, + dashboard_url, date_tested, date_prepared, date_reviewed, - date_template_reviewed = "12th March 2024", - public_repo_link = NA, + date_template_reviewed = "12 March 2024", + repo_url = NA, non_accessible_components = c( "Keyboard navigation through the interactive charts is currently limited", "Alternative text in interactive charts is limited to titles" @@ -44,17 +44,21 @@ a11y_panel <- function( "Some links are not appropriately labelled." )) { # Validate inputs - validate_date(date_tested) - validate_date(date_prepared) - validate_date(date_reviewed) - validate_date(date_template_reviewed) + date_tested <- validate_date(date_tested) + date_prepared <- validate_date(date_prepared) + date_reviewed <- validate_date(date_reviewed) + date_template_reviewed <- validate_date(date_template_reviewed) + validate_dashboard_url(dashboard_url) + if (!is_valid_repo_url(repo_url)) { + stop(repo_url, " is not a valid repository url") + } shiny::tags$div( "Accessibility", shiny::tags$div( shiny::tags$h1(paste0("Accessibility statement for ", dashboard_title)), shiny::tags$p( "This accessibility statement applies to the", - dashboard_link, + dashboard_url, "website. This website is run by the ", external_link( href = "https://www.gov.uk/government/organisations/department-for-education", @@ -212,11 +216,11 @@ a11y_panel <- function( "through a prioritised list of issues to resolve." ), shiny::tags$p( - if (!is.na(public_repo_link)) { + if (!is.na(repo_url)) { shiny::tagList( "Our current list of issues to be resolved is available on our ", external_link( - href = paste0(public_repo_link, "/issues"), + href = paste0(repo_url, "/issues"), "GitHub issues page" ), "." diff --git a/R/support_panel.R b/R/support_panel.R index 58147af..9140a25 100644 --- a/R/support_panel.R +++ b/R/support_panel.R @@ -157,23 +157,13 @@ support_panel <- function( ) } - # Check that the repo_name is a valid dfe repo ------------------------------ - # TODO: Use RCurl to check another step further, if the URL is valid - is_valid_repo_name <- function(url) { - grepl( - "\\https://github.com/dfe-analytical-services/+.", - as.character(url), - ignore.case = TRUE - ) - } - if (repo_name == "") { stop( "The repo_name argument is empty, please specify a value for repo_name" ) } - if (is_valid_repo_name(repo_name) == FALSE) { + if (is_valid_repo_url(repo_name) == FALSE) { stop( "Please ensure the repo_name argument is a valid URL for a repository on the dfe-analytical-services GitHub area. For example: @@ -182,9 +172,6 @@ support_panel <- function( ) } - - - # check for extra text # if it's null, provide an empty string if (is.null(extra_text)) { @@ -194,9 +181,6 @@ support_panel <- function( extra_text <- extra_text } - - - # Build the support page ---------------------------------------------------- shiny::tags$div( shiny::tags$h1("Support and feedback"), diff --git a/R/validation.R b/R/validation.R index dc3a3f4..7142a6e 100644 --- a/R/validation.R +++ b/R/validation.R @@ -1,11 +1,6 @@ -#' Date validation -#' -#' @param date Element to be validated as a date -#' -#' @keywords internal -#' @return String containing validation message validate_date <- function(date) { - date_ld <- lubridate::dmy(date) + date_ld <- lubridate::dmy(date, quiet = TRUE) + date_template <- lubridate::stamp("1 January 2020", orders = "dmy", quiet = TRUE) if (is.na(date_ld)) { valid <- FALSE validation_message <- "not in a valid date format." @@ -19,4 +14,30 @@ validate_date <- function(date) { if (!valid) { stop(paste(date, validation_message)) } + return(date_template(date_ld)) +} + +is_valid_repo_url <- function(url) { + # Check that the repo_name is a valid dfe repo ------------------------------ + # TODO: Use RCurl to check another step further, if the URL is valid + grepl( + "\\https://github.com/dfe-analytical-services/+.|dfe-gov-uk", + as.character(url), + ignore.case = TRUE + ) +} + +validate_dashboard_url <- function(url) { + valid_deploys <- c( + "^https://department-for-education.shinyapps.io/", + "^https://rsconnect/rsc/" + ) + valid <- grepl( + paste(valid_deploys, collapse = "|"), + as.character(url), + ignore.case = TRUE + ) + if (!valid) { + stop(paste(url, "is not a valid DfE dashboard deployment URL")) + } } diff --git a/man/a11y_panel.Rd b/man/a11y_panel.Rd index 46712b2..f7ec8f5 100644 --- a/man/a11y_panel.Rd +++ b/man/a11y_panel.Rd @@ -6,12 +6,12 @@ \usage{ a11y_panel( dashboard_title, - dashboard_link, + dashboard_url, date_tested, date_prepared, date_reviewed, - date_template_reviewed = "12th March 2024", - public_repo_link = NA, + date_template_reviewed = "12 March 2024", + repo_url = NA, non_accessible_components = c("Keyboard navigation through the interactive charts is currently limited", "Alternative text in interactive charts is limited to titles"), @@ -25,7 +25,7 @@ a11y_panel( \arguments{ \item{dashboard_title}{Title of the host dashboard} -\item{dashboard_link}{URL for the host dashboard} +\item{dashboard_url}{URL for the host dashboard} \item{date_tested}{Date the application was last tested} @@ -36,7 +36,7 @@ a11y_panel( \item{date_template_reviewed}{Date the underlying template was reviewed (default: 12th March 2024)} -\item{public_repo_link}{URL for the dashboard repository} +\item{repo_url}{URL for the dashboard repository} \item{non_accessible_components}{String vector containing a list of non accessible components} @@ -57,6 +57,6 @@ a11y_panel( "25th April 2024", "26th April 2024", "2nd November 2024", - public_repo_link = "https://github.com/dfe-analytical-services/shiny-template", + repo_url = "https://github.com/dfe-analytical-services/shiny-template", ) } diff --git a/man/validate_date.Rd b/man/validate_date.Rd deleted file mode 100644 index 154aef2..0000000 --- a/man/validate_date.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/validation.R -\name{validate_date} -\alias{validate_date} -\title{Date validation} -\usage{ -validate_date(date) -} -\arguments{ -\item{date}{Element to be validated as a date} -} -\value{ -String containing validation message -} -\description{ -Date validation -} -\keyword{internal} diff --git a/tests/test_dashboard/ui.R b/tests/test_dashboard/ui.R index 782e279..2b090c7 100644 --- a/tests/test_dashboard/ui.R +++ b/tests/test_dashboard/ui.R @@ -48,7 +48,7 @@ ui <- function(input, output, session) { "26th November 2024", "28th November 2024", "12th March 2024", - public_repo_link = "https://github.com/dfe-analytical-services/shiny-template" + repo_url = "https://github.com/dfe-analytical-services/shiny-template" ) ), diff --git a/tests/testthat/test-a11y_panel.R b/tests/testthat/test-a11y_panel.R new file mode 100644 index 0000000..1ee39e6 --- /dev/null +++ b/tests/testthat/test-a11y_panel.R @@ -0,0 +1,152 @@ +test_that("Accessibility dates are required", { + expect_no_error( + a11y_panel( + "DfE Shiny template", + "https://department-for-education.shinyapps.io/dfe-shiny-template", + date_tested = "26th November 2024", + date_prepared = "28th November 2024", + date_reviewed = "12th March 2024", + repo_url = "https://github.com/dfe-analytical-services/shiny-template" + ) + ) + expect_no_error( + a11y_panel( + "DfE Shiny template", + "https://department-for-education.shinyapps.io/dfe-shiny-template", + date_tested = "26 November 2024", + date_prepared = "28/11/2024", + date_reviewed = "12-03-2024", + repo_url = "https://github.com/dfe-analytical-services/shiny-template" + ) + ) + expect_error( + a11y_panel( + "DfE Shiny template", + "https://department-for-education.shinyapps.io/dfe-shiny-template", + date_prepared = "28th November 2024", + date_reviewed = "12th March 2024", + repo_url = "https://github.com/dfe-analytical-services/shiny-template" + ), + "argument \"date_tested\" is missing, with no default" + ) + expect_error( + a11y_panel( + "DfE Shiny template", + "https://department-for-education.shinyapps.io/dfe-shiny-template", + date_tested = "26/11/24", + date_reviewed = "12th March 2024", + repo_url = "https://github.com/dfe-analytical-services/shiny-template" + ), + "argument \"date_prepared\" is missing, with no default" + ) + expect_error( + a11y_panel( + "DfE Shiny template", + "https://department-for-education.shinyapps.io/dfe-shiny-template", + date_tested = "26th November 2024", + date_prepared = "28th November 2024", + repo_url = "https://github.com/dfe-analytical-services/shiny-template" + ), + "argument \"date_reviewed\" is missing, with no default" + ) + expect_error( + a11y_panel( + "DfE Shiny template", + "https://department-for-education.shinyapps.io/dfe-shiny-template", + date_tested = "26th November 2025", + date_prepared = "28th November 2024", + date_reviewed = "12th March 2024", + repo_url = "https://github.com/dfe-analytical-services/shiny-template" + ), + "26th November 2025 is in the future." + ) + expect_error( + a11y_panel( + "DfE Shiny template", + "https://department-for-education.shinyapps.io/dfe-shiny-template", + date_tested = "Geoff", + date_prepared = "28th November 2024", + date_reviewed = "12th March 2024", + repo_url = "https://github.com/dfe-analytical-services/shiny-template" + ), + "Geoff not in a valid date format." + ) + expect_error( + a11y_panel( + "DfE Shiny template", + "https://department-for-education.shinyapps.io/dfe-shiny-template", + date_tested = "Geoff", + date_prepared = "28th November 2024", + date_reviewed = "12th March 2024", + repo_url = "https://github.com/dfe-analytical-services/shiny-template" + ), + "Geoff not in a valid date format." + ) + expect_error( + a11y_panel( + "DfE Shiny template", + "https://department-for-education.shinyapps.io/dfe-shiny-template", + date_tested = "26th November 2024", + date_prepared = "Bob", + date_reviewed = "12th March 2024", + repo_url = "https://github.com/dfe-analytical-services/shiny-template" + ), + "Bob not in a valid date format." + ) + expect_error( + a11y_panel( + "DfE Shiny template", + "https://department-for-education.shinyapps.io/dfe-shiny-template", + date_tested = "26 November 2024", + date_prepared = "28/11/24", + date_reviewed = "Daisy", + repo_url = "https://github.com/dfe-analytical-services/shiny-template" + ), + "Daisy not in a valid date format." + ) +}) + +test_that("Accessibility name and URLs", { + expect_error( + a11y_panel( + dashboard_url = "https://department-for-education.shinyapps.io/dfe-shiny-template", + date_tested = "26/11/24", + date_prepared = "28/11/24", + date_reviewed = "12/03/24", + repo_url = "https://github.com/dfe-analytical-services/shiny-template" + ), + "argument \"dashboard_title\" is missing, with no default" + ) + expect_error( + a11y_panel( + dashboard_title = "DfE Shiny template", + date_tested = "26/11/24", + date_prepared = "28/11/24", + date_reviewed = "12/03/24", + repo_url = "https://github.com/dfe-analytical-services/shiny-template" + ), + "argument \"dashboard_url\" is missing, with no default" + ) + expect_error( + a11y_panel( + dashboard_title = "DfE Shiny template", + dashboard_url = "Cecil", + date_tested = "26/11/24", + date_prepared = "28/11/24", + date_reviewed = "12/03/24", + repo_url = "https://github.com/dfe-analytical-services/shiny-template" + ), + paste("Cecil", "is not a valid DfE dashboard deployment URL") + ) + expect_error( + a11y_panel( + dashboard_title = "DfE Shiny template", + dashboard_url = "https://department-for-education.shinyapps.io/dfe-shiny-template", + date_tested = "26/11/24", + date_prepared = "28/11/24", + date_reviewed = "12/03/24", + repo_url = "https://github.com/dfe-analytical-services/" + ), + paste("https://github.com/dfe-analytical-services/", "is not a valid repository url") + ) +}) From 87dd0e48ae0bc3d20524379ce8a693f3accd8350 Mon Sep 17 00:00:00 2001 From: Rich Bielby Date: Mon, 9 Dec 2024 10:59:33 +0000 Subject: [PATCH 06/16] Added direct publication link option to accessibility panel --- R/a11y_panel.R | 32 ++++++++++++++++++++++---------- man/a11y_panel.Rd | 7 +++++++ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/R/a11y_panel.R b/R/a11y_panel.R index 8fad4e4..18653dd 100644 --- a/R/a11y_panel.R +++ b/R/a11y_panel.R @@ -3,6 +3,9 @@ #' @param dashboard_title Title of the host dashboard #' @param dashboard_url URL for the host dashboard #' @param repo_url URL for the dashboard repository +#' @param publication_name The parent publication name +#' @param publication_slug The parent publication slug on Explore Education +#' Statistics #' @param non_accessible_components String vector containing a list of non accessible components #' @param specific_issues String vector containing descriptions of specific accessibility issues #' that have been identified as part of testing @@ -33,6 +36,8 @@ a11y_panel <- function( date_reviewed, date_template_reviewed = "12 March 2024", repo_url = NA, + publication_name = NA, + publication_slug = NA, non_accessible_components = c( "Keyboard navigation through the interactive charts is currently limited", "Alternative text in interactive charts is limited to titles" @@ -52,6 +57,12 @@ a11y_panel <- function( if (!is_valid_repo_url(repo_url)) { stop(repo_url, " is not a valid repository url") } + if (is.na(publication_name) && !is.na(publication_slug)) { + stop("Error: If publication_name is provided, then so should publication_slug.") + } + if (!is.na(publication_name) && is.na(publication_slug)) { + stop("Error: If publication_slug is provided, then so should publication_name.") + } shiny::tags$div( "Accessibility", shiny::tags$div( @@ -104,16 +115,17 @@ a11y_panel <- function( ) }, shiny::tags$h2("Feedback and contact information"), - shiny::tags$p( - "If you need information on this website in a different format please see the parent", - "publications", - external_link( - href = "https://explore-education-statistics.service.gov.uk/find-statistics", - "on Explore education statistics" - ), - ", as detailed on the data sources page of this service.", - ". More details are available on that service for alternative formats of this data.", - ), + if (!is.na(publication_slug)) { + shiny::tags$p( + "If you need information on this website in a different format please see the parent ", + external_link(href = publication_slug, link_text = publication_name), + "publication." + ) + shiny::tags$p( + "More details are available on that service for alternative formats of this ", + "data." + ) + }, shiny::tags$p("We're always looking to improve the accessibility of this website. If you find any problems not listed on this page or think we're not meeting accessibility requirements, contact us:"), diff --git a/man/a11y_panel.Rd b/man/a11y_panel.Rd index f7ec8f5..c7f7639 100644 --- a/man/a11y_panel.Rd +++ b/man/a11y_panel.Rd @@ -12,6 +12,8 @@ a11y_panel( date_reviewed, date_template_reviewed = "12 March 2024", repo_url = NA, + publication_name = NA, + publication_slug = NA, non_accessible_components = c("Keyboard navigation through the interactive charts is currently limited", "Alternative text in interactive charts is limited to titles"), @@ -38,6 +40,11 @@ a11y_panel( \item{repo_url}{URL for the dashboard repository} +\item{publication_name}{The parent publication name} + +\item{publication_slug}{The parent publication slug on Explore Education +Statistics} + \item{non_accessible_components}{String vector containing a list of non accessible components} \item{specific_issues}{String vector containing descriptions of specific accessibility issues From 659c129895497f91b85f277a899b6c1d463c4a1e Mon Sep 17 00:00:00 2001 From: Rich Bielby Date: Mon, 9 Dec 2024 11:45:25 +0000 Subject: [PATCH 07/16] Added some extra validation around dates for the accessibility certificate --- R/a11y_panel.R | 24 +++++++++ tests/testthat/test-a11y_panel.R | 91 ++++++++++++++++++++------------ 2 files changed, 82 insertions(+), 33 deletions(-) diff --git a/R/a11y_panel.R b/R/a11y_panel.R index 18653dd..039d6c2 100644 --- a/R/a11y_panel.R +++ b/R/a11y_panel.R @@ -54,6 +54,30 @@ a11y_panel <- function( date_reviewed <- validate_date(date_reviewed) date_template_reviewed <- validate_date(date_template_reviewed) validate_dashboard_url(dashboard_url) + if ( + lubridate::interval( + lubridate::dmy(date_prepared), lubridate::dmy(date_reviewed) + ) / lubridate::days(1) < 0 + ) { + stop("date_reviewed should be later than date_prepared") + } + if ( + lubridate::interval( + lubridate::dmy(date_tested), lubridate::dmy(date_reviewed) + ) / lubridate::days(1) < 0 + ) { + stop("date_reviewed should be later than date_tested") + } + if ( + lubridate::interval( + lubridate::dmy(date_template_reviewed), lubridate::dmy(date_reviewed) + ) / lubridate::days(1) < 0 + ) { + warning( + "The template has been through a review more recently than your dashboard, please get in ", + "touch with the explore education statistics platforms team to request a re-review." + ) + } if (!is_valid_repo_url(repo_url)) { stop(repo_url, " is not a valid repository url") } diff --git a/tests/testthat/test-a11y_panel.R b/tests/testthat/test-a11y_panel.R index 1ee39e6..7ce80c6 100644 --- a/tests/testthat/test-a11y_panel.R +++ b/tests/testthat/test-a11y_panel.R @@ -3,9 +3,9 @@ test_that("Accessibility dates are required", { a11y_panel( "DfE Shiny template", "https://department-for-education.shinyapps.io/dfe-shiny-template", - date_tested = "26th November 2024", - date_prepared = "28th November 2024", - date_reviewed = "12th March 2024", + date_tested = "26th March 2024", + date_prepared = "28th March 2024", + date_reviewed = "12th November 2024", repo_url = "https://github.com/dfe-analytical-services/shiny-template" ) ) @@ -13,9 +13,9 @@ test_that("Accessibility dates are required", { a11y_panel( "DfE Shiny template", "https://department-for-education.shinyapps.io/dfe-shiny-template", - date_tested = "26 November 2024", - date_prepared = "28/11/2024", - date_reviewed = "12-03-2024", + date_tested = "26 March 2024", + date_prepared = "28/03/2024", + date_reviewed = "12-11-2024", repo_url = "https://github.com/dfe-analytical-services/shiny-template" ) ) @@ -23,8 +23,8 @@ test_that("Accessibility dates are required", { a11y_panel( "DfE Shiny template", "https://department-for-education.shinyapps.io/dfe-shiny-template", - date_prepared = "28th November 2024", - date_reviewed = "12th March 2024", + date_prepared = "28th March 2024", + date_reviewed = "12th November 2024", repo_url = "https://github.com/dfe-analytical-services/shiny-template" ), "argument \"date_tested\" is missing, with no default" @@ -33,8 +33,8 @@ test_that("Accessibility dates are required", { a11y_panel( "DfE Shiny template", "https://department-for-education.shinyapps.io/dfe-shiny-template", - date_tested = "26/11/24", - date_reviewed = "12th March 2024", + date_tested = "26/03/24", + date_reviewed = "12th November 2024", repo_url = "https://github.com/dfe-analytical-services/shiny-template" ), "argument \"date_prepared\" is missing, with no default" @@ -53,31 +53,56 @@ test_that("Accessibility dates are required", { a11y_panel( "DfE Shiny template", "https://department-for-education.shinyapps.io/dfe-shiny-template", - date_tested = "26th November 2025", - date_prepared = "28th November 2024", - date_reviewed = "12th March 2024", + date_tested = "26th March 2025", + date_prepared = "28th March 2024", + date_reviewed = "12th November 2024", repo_url = "https://github.com/dfe-analytical-services/shiny-template" ), - "26th November 2025 is in the future." + "26th March 2025 is in the future." ) expect_error( a11y_panel( "DfE Shiny template", "https://department-for-education.shinyapps.io/dfe-shiny-template", - date_tested = "Geoff", + date_tested = "13/11/2023", date_prepared = "28th November 2024", - date_reviewed = "12th March 2024", + date_reviewed = "12th November 2024", repo_url = "https://github.com/dfe-analytical-services/shiny-template" ), - "Geoff not in a valid date format." + "date_reviewed should be later than date_prepared" + ) + expect_error( + a11y_panel( + "DfE Shiny template", + "https://department-for-education.shinyapps.io/dfe-shiny-template", + date_tested = "13/11/2024", + date_prepared = "28th March 2024", + date_reviewed = "12th November 2024", + repo_url = "https://github.com/dfe-analytical-services/shiny-template" + ), + "date_reviewed should be later than date_tested" + ) + expect_warning( + a11y_panel( + "DfE Shiny template", + "https://department-for-education.shinyapps.io/dfe-shiny-template", + date_tested = "13/03/2020", + date_prepared = "28th March 2020", + date_reviewed = "12th November 2020", + repo_url = "https://github.com/dfe-analytical-services/shiny-template" + ), + paste0( + "The template has been through a review more recently than your dashboard, please get in ", + "touch with the explore education statistics platforms team to request a re-review." + ) ) expect_error( a11y_panel( "DfE Shiny template", "https://department-for-education.shinyapps.io/dfe-shiny-template", date_tested = "Geoff", - date_prepared = "28th November 2024", - date_reviewed = "12th March 2024", + date_prepared = "28th March 2024", + date_reviewed = "12th November 2024", repo_url = "https://github.com/dfe-analytical-services/shiny-template" ), "Geoff not in a valid date format." @@ -86,9 +111,9 @@ test_that("Accessibility dates are required", { a11y_panel( "DfE Shiny template", "https://department-for-education.shinyapps.io/dfe-shiny-template", - date_tested = "26th November 2024", + date_tested = "26th March 2024", date_prepared = "Bob", - date_reviewed = "12th March 2024", + date_reviewed = "12th November 2024", repo_url = "https://github.com/dfe-analytical-services/shiny-template" ), "Bob not in a valid date format." @@ -110,9 +135,9 @@ test_that("Accessibility name and URLs", { expect_error( a11y_panel( dashboard_url = "https://department-for-education.shinyapps.io/dfe-shiny-template", - date_tested = "26/11/24", - date_prepared = "28/11/24", - date_reviewed = "12/03/24", + date_tested = "26/03/24", + date_prepared = "28/03/24", + date_reviewed = "12/11/24", repo_url = "https://github.com/dfe-analytical-services/shiny-template" ), "argument \"dashboard_title\" is missing, with no default" @@ -120,9 +145,9 @@ test_that("Accessibility name and URLs", { expect_error( a11y_panel( dashboard_title = "DfE Shiny template", - date_tested = "26/11/24", - date_prepared = "28/11/24", - date_reviewed = "12/03/24", + date_tested = "26/03/24", + date_prepared = "28/03/24", + date_reviewed = "12/11/24", repo_url = "https://github.com/dfe-analytical-services/shiny-template" ), "argument \"dashboard_url\" is missing, with no default" @@ -131,9 +156,9 @@ test_that("Accessibility name and URLs", { a11y_panel( dashboard_title = "DfE Shiny template", dashboard_url = "Cecil", - date_tested = "26/11/24", - date_prepared = "28/11/24", - date_reviewed = "12/03/24", + date_tested = "26/03/24", + date_prepared = "28/03/24", + date_reviewed = "12/11/24", repo_url = "https://github.com/dfe-analytical-services/shiny-template" ), paste("Cecil", "is not a valid DfE dashboard deployment URL") @@ -142,9 +167,9 @@ test_that("Accessibility name and URLs", { a11y_panel( dashboard_title = "DfE Shiny template", dashboard_url = "https://department-for-education.shinyapps.io/dfe-shiny-template", - date_tested = "26/11/24", - date_prepared = "28/11/24", - date_reviewed = "12/03/24", + date_tested = "26/03/24", + date_prepared = "28/03/24", + date_reviewed = "12/11/24", repo_url = "https://github.com/dfe-analytical-services/" ), paste("https://github.com/dfe-analytical-services/", "is not a valid repository url") From 54dc5d32837810d86dd333e66fdc65777a9063b0 Mon Sep 17 00:00:00 2001 From: Rich Bielby Date: Wed, 11 Dec 2024 11:03:35 +0000 Subject: [PATCH 08/16] A few PR comment responses around code documentation etc --- R/a11y_panel.R | 6 +++--- R/validation.R | 11 +++++++++++ tests/test_dashboard/ui.R | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/R/a11y_panel.R b/R/a11y_panel.R index 039d6c2..8496ced 100644 --- a/R/a11y_panel.R +++ b/R/a11y_panel.R @@ -35,9 +35,9 @@ a11y_panel <- function( date_prepared, date_reviewed, date_template_reviewed = "12 March 2024", - repo_url = NA, - publication_name = NA, - publication_slug = NA, + repo_url = NULL, + publication_name = NULL, + publication_slug = NULL, non_accessible_components = c( "Keyboard navigation through the interactive charts is currently limited", "Alternative text in interactive charts is limited to titles" diff --git a/R/validation.R b/R/validation.R index 7142a6e..7dfeeaf 100644 --- a/R/validation.R +++ b/R/validation.R @@ -1,3 +1,7 @@ +# Some standard checks on something that's expected to be a date: +# - Can lubridate parse it as a date? +# - Does it occur in the past / today? +# Where it's valid, the function will return it in a format of dd month yyyy validate_date <- function(date) { date_ld <- lubridate::dmy(date, quiet = TRUE) date_template <- lubridate::stamp("1 January 2020", orders = "dmy", quiet = TRUE) @@ -17,6 +21,11 @@ validate_date <- function(date) { return(date_template(date_ld)) } +# Some of the standard panels have text referring back to the dashboard repo, so +# this function checks for strings being passed to those variables being a link +# to one of our DevOps areas, i.e. DfE Analytical Services on GitHub or our Azure +# platform. I've included both as some teams are starting to use dfeshiny for +# internal dasboards as well. is_valid_repo_url <- function(url) { # Check that the repo_name is a valid dfe repo ------------------------------ # TODO: Use RCurl to check another step further, if the URL is valid @@ -27,6 +36,8 @@ is_valid_repo_url <- function(url) { ) } +# Some of the standard panels have links to the dashboard they're embedded in. This +# validation checks that those links are correctly set to one of our domains. validate_dashboard_url <- function(url) { valid_deploys <- c( "^https://department-for-education.shinyapps.io/", diff --git a/tests/test_dashboard/ui.R b/tests/test_dashboard/ui.R index 2b090c7..d415b91 100644 --- a/tests/test_dashboard/ui.R +++ b/tests/test_dashboard/ui.R @@ -45,8 +45,8 @@ ui <- function(input, output, session) { a11y_panel( "DfE Shiny template", "https://department-for-education.shinyapps.io/dfe-shiny-template", - "26th November 2024", - "28th November 2024", + "26th November 2023", + "28th November 2023", "12th March 2024", repo_url = "https://github.com/dfe-analytical-services/shiny-template" ) From 07f3134e1f4a1f4dc7c8de355c4adee02cfe6528 Mon Sep 17 00:00:00 2001 From: Rich Bielby Date: Wed, 11 Dec 2024 11:15:01 +0000 Subject: [PATCH 09/16] Minor changes to dates validation messages --- R/a11y_panel.R | 12 ++--- R/validation.R | 4 +- inst/www/DfE_logo_landscape.svg | 92 -------------------------------- tests/testthat/test-a11y_panel.R | 10 ++-- 4 files changed, 13 insertions(+), 105 deletions(-) delete mode 100644 inst/www/DfE_logo_landscape.svg diff --git a/R/a11y_panel.R b/R/a11y_panel.R index 8496ced..66a7aa6 100644 --- a/R/a11y_panel.R +++ b/R/a11y_panel.R @@ -81,10 +81,10 @@ a11y_panel <- function( if (!is_valid_repo_url(repo_url)) { stop(repo_url, " is not a valid repository url") } - if (is.na(publication_name) && !is.na(publication_slug)) { + if (is.null(publication_name) && !is.null(publication_slug)) { stop("Error: If publication_name is provided, then so should publication_slug.") } - if (!is.na(publication_name) && is.na(publication_slug)) { + if (!is.null(publication_name) && is.null(publication_slug)) { stop("Error: If publication_slug is provided, then so should publication_name.") } shiny::tags$div( @@ -128,7 +128,7 @@ a11y_panel <- function( " has advice on making your device easier to use if you have a disability." ), shiny::tags$h2("How accessible this website is"), - if (all(is.na(non_accessible_components))) { + if (all(is.null(non_accessible_components))) { shiny::tags$p("This website is fully compliant with accessibility standards.") } else { shiny::tagList( @@ -139,7 +139,7 @@ a11y_panel <- function( ) }, shiny::tags$h2("Feedback and contact information"), - if (!is.na(publication_slug)) { + if (!is.null(publication_slug)) { shiny::tags$p( "If you need information on this website in a different format please see the parent ", external_link(href = publication_slug, link_text = publication_name), @@ -180,7 +180,7 @@ a11y_panel <- function( "Accessibility Regulations 2018." ), shiny::tags$h3("Compliance status"), - if (all(is.na(specific_issues))) { + if (all(is.null(specific_issues))) { shiny::tags$p( "This website is fully compliant with the ", external_link( @@ -252,7 +252,7 @@ a11y_panel <- function( "through a prioritised list of issues to resolve." ), shiny::tags$p( - if (!is.na(repo_url)) { + if (!is.null(repo_url)) { shiny::tagList( "Our current list of issues to be resolved is available on our ", external_link( diff --git a/R/validation.R b/R/validation.R index 7dfeeaf..206e162 100644 --- a/R/validation.R +++ b/R/validation.R @@ -7,7 +7,7 @@ validate_date <- function(date) { date_template <- lubridate::stamp("1 January 2020", orders = "dmy", quiet = TRUE) if (is.na(date_ld)) { valid <- FALSE - validation_message <- "not in a valid date format." + validation_message <- "is not in a valid date format." } else if (date_ld > Sys.time()) { valid <- FALSE validation_message <- "is in the future." @@ -16,7 +16,7 @@ validate_date <- function(date) { validation_message <- "is a valid date." } if (!valid) { - stop(paste(date, validation_message)) + stop(paste0("\"",date,"\" ", validation_message)) } return(date_template(date_ld)) } diff --git a/inst/www/DfE_logo_landscape.svg b/inst/www/DfE_logo_landscape.svg deleted file mode 100644 index 6602add..0000000 --- a/inst/www/DfE_logo_landscape.svg +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/testthat/test-a11y_panel.R b/tests/testthat/test-a11y_panel.R index 7ce80c6..fbc5beb 100644 --- a/tests/testthat/test-a11y_panel.R +++ b/tests/testthat/test-a11y_panel.R @@ -53,12 +53,12 @@ test_that("Accessibility dates are required", { a11y_panel( "DfE Shiny template", "https://department-for-education.shinyapps.io/dfe-shiny-template", - date_tested = "26th March 2025", + date_tested = "26th March 2099", date_prepared = "28th March 2024", date_reviewed = "12th November 2024", repo_url = "https://github.com/dfe-analytical-services/shiny-template" ), - "26th March 2025 is in the future." + "\"26th March 2099\" is in the future." ) expect_error( a11y_panel( @@ -105,7 +105,7 @@ test_that("Accessibility dates are required", { date_reviewed = "12th November 2024", repo_url = "https://github.com/dfe-analytical-services/shiny-template" ), - "Geoff not in a valid date format." + "\"Geoff\" is not in a valid date format." ) expect_error( a11y_panel( @@ -116,7 +116,7 @@ test_that("Accessibility dates are required", { date_reviewed = "12th November 2024", repo_url = "https://github.com/dfe-analytical-services/shiny-template" ), - "Bob not in a valid date format." + "\"Bob\" is not in a valid date format." ) expect_error( a11y_panel( @@ -127,7 +127,7 @@ test_that("Accessibility dates are required", { date_reviewed = "Daisy", repo_url = "https://github.com/dfe-analytical-services/shiny-template" ), - "Daisy not in a valid date format." + "\"Daisy\" is not in a valid date format." ) }) From b25b0fb2125df0c21948b935d838a032ccc48f9a Mon Sep 17 00:00:00 2001 From: Rich Bielby Date: Wed, 11 Dec 2024 16:59:07 +0000 Subject: [PATCH 10/16] Expanding validation and testing on a11y_panel --- R/a11y_panel.R | 68 ++++++++++++++------ R/support_panel.R | 9 --- R/validation.R | 13 +++- man/a11y_panel.Rd | 24 ++++--- tests/test_dashboard/ui.R | 2 +- tests/testthat/test-a11y_panel.R | 106 +++++++++++++++++++++++++------ 6 files changed, 162 insertions(+), 60 deletions(-) diff --git a/R/a11y_panel.R b/R/a11y_panel.R index 66a7aa6..6a17b7e 100644 --- a/R/a11y_panel.R +++ b/R/a11y_panel.R @@ -1,11 +1,20 @@ #' Accessibility panel #' +#' @description +#' Create an accessibility statement for a dashboard. This should always be completed +#' - for all live public dashboards +#' - by or in conjunction with the Explore education statistics and platforms team +#' +#' Note that this model statement has been created based on the +#' [GDS model accessibility statement](https://www.gov.uk/guidance/model-accessibility-statement) +#' #' @param dashboard_title Title of the host dashboard #' @param dashboard_url URL for the host dashboard -#' @param repo_url URL for the dashboard repository -#' @param publication_name The parent publication name +#' @param issues_contact URL for the GitHub Issues log or contact e-mail address +#' for users to flag accessibility issues +#' @param publication_name The parent publication name (optional) #' @param publication_slug The parent publication slug on Explore Education -#' Statistics +#' Statistics (optional) #' @param non_accessible_components String vector containing a list of non accessible components #' @param specific_issues String vector containing descriptions of specific accessibility issues #' that have been identified as part of testing @@ -26,7 +35,7 @@ #' "25th April 2024", #' "26th April 2024", #' "2nd November 2024", -#' repo_url = "https://github.com/dfe-analytical-services/shiny-template", +#' issues_contact = "https://github.com/dfe-analytical-services/shiny-template", #' ) a11y_panel <- function( dashboard_title, @@ -35,7 +44,7 @@ a11y_panel <- function( date_prepared, date_reviewed, date_template_reviewed = "12 March 2024", - repo_url = NULL, + issues_contact = NULL, publication_name = NULL, publication_slug = NULL, non_accessible_components = c( @@ -57,8 +66,8 @@ a11y_panel <- function( if ( lubridate::interval( lubridate::dmy(date_prepared), lubridate::dmy(date_reviewed) - ) / lubridate::days(1) < 0 - ) { + ) / lubridate::days(1) < 0 + ) { stop("date_reviewed should be later than date_prepared") } if ( @@ -78,8 +87,16 @@ a11y_panel <- function( "touch with the explore education statistics platforms team to request a re-review." ) } - if (!is_valid_repo_url(repo_url)) { - stop(repo_url, " is not a valid repository url") + if (!is_valid_repo_url(issues_contact)) { + if (!is_valid_dfe_email(issues_contact)) { + stop( + paste0( + "\"", + issues_contact, + "\" should either be a valid repository URL or a valid DfE e-mail address" + ) + ) + } } if (is.null(publication_name) && !is.null(publication_slug)) { stop("Error: If publication_name is provided, then so should publication_slug.") @@ -133,7 +150,7 @@ a11y_panel <- function( } else { shiny::tagList( shiny::tags$p("We know some parts of this website are not fully accessible:"), - shiny::tags$div(tags$ul( + shiny::tags$div(tags$ol( tagList(lapply(non_accessible_components, shiny::tags$li)) )) ) @@ -202,7 +219,7 @@ a11y_panel <- function( shiny::tags$h3("Non accessible content"), shiny::tags$p("The content listed below is non-accessible for the following reasons. We will address these issues to ensure our content is accessible."), - shiny::tags$div(tags$ul( + shiny::tags$div(tags$ol( tagList(lapply(specific_issues, shiny::tags$li)) )) ) @@ -252,15 +269,26 @@ a11y_panel <- function( "through a prioritised list of issues to resolve." ), shiny::tags$p( - if (!is.null(repo_url)) { - shiny::tagList( - "Our current list of issues to be resolved is available on our ", - external_link( - href = paste0(repo_url, "/issues"), - "GitHub issues page" - ), - "." - ) + if (!is.null(issues_contact)) { + if (is_valid_repo_url(issues_contact)) { + shiny::tagList( + "Our current list of issues to be resolved is available on our ", + external_link( + href = paste0(issues_contact, "/issues"), + "GitHub issues page" + ), + "." + ) + } else { + shiny::tagList( + "To discuss our current list of issues to be resolved contact us at", + shiny::tags$a( + href = paste0("mailto:", issues_contact), + issues_contact + ), + "." + ) + } } else { " " }, diff --git a/R/support_panel.R b/R/support_panel.R index 9140a25..fb3c263 100644 --- a/R/support_panel.R +++ b/R/support_panel.R @@ -141,15 +141,6 @@ support_panel <- function( form_url = NULL, custom_data_info = NULL, extra_text = NULL) { - # Check that the team_email is a valid dfe email ---------------------------- - is_valid_dfe_email <- function(email) { - grepl( - "\\<[A-Z0-9._%+-]+@education.gov.uk\\>", - as.character(email), - ignore.case = TRUE - ) - } - if (is_valid_dfe_email(team_email) == FALSE) { stop( "You have entered an invalid email in the team_email argument. diff --git a/R/validation.R b/R/validation.R index 206e162..57a5332 100644 --- a/R/validation.R +++ b/R/validation.R @@ -7,7 +7,7 @@ validate_date <- function(date) { date_template <- lubridate::stamp("1 January 2020", orders = "dmy", quiet = TRUE) if (is.na(date_ld)) { valid <- FALSE - validation_message <- "is not in a valid date format." + validation_message <- "is not in a valid date format, e.g. 8th Auguest 2024 or 08/08/2024." } else if (date_ld > Sys.time()) { valid <- FALSE validation_message <- "is in the future." @@ -16,7 +16,7 @@ validate_date <- function(date) { validation_message <- "is a valid date." } if (!valid) { - stop(paste0("\"",date,"\" ", validation_message)) + stop(paste0("\"", date, "\" ", validation_message)) } return(date_template(date_ld)) } @@ -52,3 +52,12 @@ validate_dashboard_url <- function(url) { stop(paste(url, "is not a valid DfE dashboard deployment URL")) } } + +# Check that the team_email is a valid dfe email ---------------------------- +is_valid_dfe_email <- function(email) { + grepl( + "\\<[A-Z0-9._%+-]+@education.gov.uk\\>", + as.character(email), + ignore.case = TRUE + ) +} diff --git a/man/a11y_panel.Rd b/man/a11y_panel.Rd index c7f7639..b5e1306 100644 --- a/man/a11y_panel.Rd +++ b/man/a11y_panel.Rd @@ -11,9 +11,9 @@ a11y_panel( date_prepared, date_reviewed, date_template_reviewed = "12 March 2024", - repo_url = NA, - publication_name = NA, - publication_slug = NA, + issues_contact = NULL, + publication_name = NULL, + publication_slug = NULL, non_accessible_components = c("Keyboard navigation through the interactive charts is currently limited", "Alternative text in interactive charts is limited to titles"), @@ -38,12 +38,13 @@ a11y_panel( \item{date_template_reviewed}{Date the underlying template was reviewed (default: 12th March 2024)} -\item{repo_url}{URL for the dashboard repository} +\item{issues_contact}{URL for the GitHub Issues log or contact e-mail address +for users to flag accessibility issues} -\item{publication_name}{The parent publication name} +\item{publication_name}{The parent publication name (optional)} \item{publication_slug}{The parent publication slug on Explore Education -Statistics} +Statistics (optional)} \item{non_accessible_components}{String vector containing a list of non accessible components} @@ -55,7 +56,14 @@ shiny$tags$div element containing the html tags and content for the standard accessibility statement } \description{ -Accessibility panel +Create an accessibility statement for a dashboard. This should always be completed +\itemize{ +\item for all live public dashboards +\item by or in conjunction with the Explore education statistics and platforms team +} + +Note that this model statement has been created based on the +\href{https://www.gov.uk/guidance/model-accessibility-statement}{GDS model accessibility statement} } \examples{ a11y_panel( @@ -64,6 +72,6 @@ a11y_panel( "25th April 2024", "26th April 2024", "2nd November 2024", - repo_url = "https://github.com/dfe-analytical-services/shiny-template", + issues_contact = "https://github.com/dfe-analytical-services/shiny-template", ) } diff --git a/tests/test_dashboard/ui.R b/tests/test_dashboard/ui.R index d415b91..285e6e9 100644 --- a/tests/test_dashboard/ui.R +++ b/tests/test_dashboard/ui.R @@ -48,7 +48,7 @@ ui <- function(input, output, session) { "26th November 2023", "28th November 2023", "12th March 2024", - repo_url = "https://github.com/dfe-analytical-services/shiny-template" + issues_contact = "https://github.com/dfe-analytical-services/shiny-template" ) ), diff --git a/tests/testthat/test-a11y_panel.R b/tests/testthat/test-a11y_panel.R index fbc5beb..756b045 100644 --- a/tests/testthat/test-a11y_panel.R +++ b/tests/testthat/test-a11y_panel.R @@ -6,7 +6,7 @@ test_that("Accessibility dates are required", { date_tested = "26th March 2024", date_prepared = "28th March 2024", date_reviewed = "12th November 2024", - repo_url = "https://github.com/dfe-analytical-services/shiny-template" + issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ) ) expect_no_error( @@ -16,7 +16,7 @@ test_that("Accessibility dates are required", { date_tested = "26 March 2024", date_prepared = "28/03/2024", date_reviewed = "12-11-2024", - repo_url = "https://github.com/dfe-analytical-services/shiny-template" + issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ) ) expect_error( @@ -25,7 +25,7 @@ test_that("Accessibility dates are required", { "https://department-for-education.shinyapps.io/dfe-shiny-template", date_prepared = "28th March 2024", date_reviewed = "12th November 2024", - repo_url = "https://github.com/dfe-analytical-services/shiny-template" + issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ), "argument \"date_tested\" is missing, with no default" ) @@ -35,7 +35,7 @@ test_that("Accessibility dates are required", { "https://department-for-education.shinyapps.io/dfe-shiny-template", date_tested = "26/03/24", date_reviewed = "12th November 2024", - repo_url = "https://github.com/dfe-analytical-services/shiny-template" + issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ), "argument \"date_prepared\" is missing, with no default" ) @@ -45,7 +45,7 @@ test_that("Accessibility dates are required", { "https://department-for-education.shinyapps.io/dfe-shiny-template", date_tested = "26th November 2024", date_prepared = "28th November 2024", - repo_url = "https://github.com/dfe-analytical-services/shiny-template" + issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ), "argument \"date_reviewed\" is missing, with no default" ) @@ -56,7 +56,7 @@ test_that("Accessibility dates are required", { date_tested = "26th March 2099", date_prepared = "28th March 2024", date_reviewed = "12th November 2024", - repo_url = "https://github.com/dfe-analytical-services/shiny-template" + issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ), "\"26th March 2099\" is in the future." ) @@ -67,7 +67,7 @@ test_that("Accessibility dates are required", { date_tested = "13/11/2023", date_prepared = "28th November 2024", date_reviewed = "12th November 2024", - repo_url = "https://github.com/dfe-analytical-services/shiny-template" + issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ), "date_reviewed should be later than date_prepared" ) @@ -78,7 +78,7 @@ test_that("Accessibility dates are required", { date_tested = "13/11/2024", date_prepared = "28th March 2024", date_reviewed = "12th November 2024", - repo_url = "https://github.com/dfe-analytical-services/shiny-template" + issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ), "date_reviewed should be later than date_tested" ) @@ -89,7 +89,7 @@ test_that("Accessibility dates are required", { date_tested = "13/03/2020", date_prepared = "28th March 2020", date_reviewed = "12th November 2020", - repo_url = "https://github.com/dfe-analytical-services/shiny-template" + issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ), paste0( "The template has been through a review more recently than your dashboard, please get in ", @@ -103,9 +103,9 @@ test_that("Accessibility dates are required", { date_tested = "Geoff", date_prepared = "28th March 2024", date_reviewed = "12th November 2024", - repo_url = "https://github.com/dfe-analytical-services/shiny-template" + issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ), - "\"Geoff\" is not in a valid date format." + "\"Geoff\" is not in a valid date format, e.g. 8th Auguest 2024 or 08/08/2024." ) expect_error( a11y_panel( @@ -114,9 +114,9 @@ test_that("Accessibility dates are required", { date_tested = "26th March 2024", date_prepared = "Bob", date_reviewed = "12th November 2024", - repo_url = "https://github.com/dfe-analytical-services/shiny-template" + issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ), - "\"Bob\" is not in a valid date format." + "\"Bob\" is not in a valid date format, e.g. 8th Auguest 2024 or 08/08/2024." ) expect_error( a11y_panel( @@ -125,9 +125,9 @@ test_that("Accessibility dates are required", { date_tested = "26 November 2024", date_prepared = "28/11/24", date_reviewed = "Daisy", - repo_url = "https://github.com/dfe-analytical-services/shiny-template" + issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ), - "\"Daisy\" is not in a valid date format." + "\"Daisy\" is not in a valid date format, e.g. 8th Auguest 2024 or 08/08/2024." ) }) @@ -138,7 +138,7 @@ test_that("Accessibility name and URLs", { date_tested = "26/03/24", date_prepared = "28/03/24", date_reviewed = "12/11/24", - repo_url = "https://github.com/dfe-analytical-services/shiny-template" + issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ), "argument \"dashboard_title\" is missing, with no default" ) @@ -148,7 +148,7 @@ test_that("Accessibility name and URLs", { date_tested = "26/03/24", date_prepared = "28/03/24", date_reviewed = "12/11/24", - repo_url = "https://github.com/dfe-analytical-services/shiny-template" + issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ), "argument \"dashboard_url\" is missing, with no default" ) @@ -159,7 +159,7 @@ test_that("Accessibility name and URLs", { date_tested = "26/03/24", date_prepared = "28/03/24", date_reviewed = "12/11/24", - repo_url = "https://github.com/dfe-analytical-services/shiny-template" + issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ), paste("Cecil", "is not a valid DfE dashboard deployment URL") ) @@ -170,8 +170,74 @@ test_that("Accessibility name and URLs", { date_tested = "26/03/24", date_prepared = "28/03/24", date_reviewed = "12/11/24", - repo_url = "https://github.com/dfe-analytical-services/" + issues_contact = "https://github.com/dfe-analytical-services/" ), - paste("https://github.com/dfe-analytical-services/", "is not a valid repository url") + paste0( + "\"", + "https://github.com/dfe-analytical-services/", + "\"", + " should either be a valid repository URL or a valid DfE e-mail address" + ) ) }) + +output <- a11y_panel( + "DfE Shiny template", + "https://department-for-education.shinyapps.io/dfe-shiny-template", + date_tested = "26th March 2024", + date_prepared = "28th March 2024", + date_reviewed = "12th November 2024", + issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" +) + +test_that("HTML headings output from function", { + # This checks the headings are in the expected positions in the HTML output the function returns + expect_equal(paste(output$children[[1]]), "Accessibility") + expect_equal( + paste(output$children[[2]]$children[[1]]), + "

Accessibility statement for DfE Shiny template

" + ) + expect_equal( + paste(output$children[[2]]$children[[3]]), + "

How you should be able to use this website

" + ) + expect_equal(paste(output$children[[2]]$children[[8]]), "

How accessible this website is

") + expect_equal( + paste(output$children[[2]]$children[[10]]), + "

Feedback and contact information

" + ) + expect_equal(paste(output$children[[2]]$children[[14]]), "

Enforcement procedure

") + expect_equal( + paste(output$children[[2]]$children[[17]]), + "

Technical information about this website's accessibility

" + ) + expect_equal(paste(output$children[[2]]$children[[19]]), "

Compliance status

") + expect_equal(paste(output$children[[2]]$children[[21]]), "

Disproportionate burden

") + expect_equal(paste(output$children[[2]]$children[[23]]), "

How we tested this website

") + expect_equal( + paste(output$children[[2]]$children[[28]]), + "

What we're doing to improve accessibility

" + ) + expect_equal( + paste(output$children[[2]]$children[[31]]), + "

Preparation of this accessibility statement

" + ) +}) + +test_that( + "Params occur in expected places", + { + expect_true( + grepl( + "https://department-for-education.shinyapps.io/dfe-shiny-template", + paste0(output$children[[2]]$children[[2]]) + ) + ) + expect_true( + grepl( + "https://github.com/dfe-analytical-services/shiny-template/issues", + paste0(output$children[[2]]$children[[30]]) + ) + ) + } +) From ab265f914db2c7d2c2ce7f4d2c436d504a06dd45 Mon Sep 17 00:00:00 2001 From: Rich Bielby Date: Wed, 11 Dec 2024 17:05:58 +0000 Subject: [PATCH 11/16] Bumping up package version +1patch --- .lintr | 3 ++- DESCRIPTION | 2 +- NEWS.md | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.lintr b/.lintr index 934db5c..26589b1 100644 --- a/.lintr +++ b/.lintr @@ -1,3 +1,4 @@ linters: linters_with_defaults( - line_length_linter = line_length_linter(100L) # limit CRAN sets for lines in PDF documentation + line_length_linter = line_length_linter(100L), # limit CRAN sets for lines in PDF documentation + cyclocomp_linter = cyclocomp_linter(25L) ) diff --git a/DESCRIPTION b/DESCRIPTION index f85d8ca..c09e439 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: dfeshiny Title: DfE R Shiny Standards -Version: 0.5.2 +Version: 0.5.3 Authors@R: c( person("Rich", "Bielby", , "richard.bielby@education.gov.uk", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-9070-9969")), diff --git a/NEWS.md b/NEWS.md index b10baaf..f5e0b64 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# dfeshiny 0.5.3 + +* Added `dfeshiny::a11y_panel()` to create model accessibility statement with custom +issue listings. + # dfeshiny 0.5.2 * Added `dfeshiny::header()` function to produce a standardised header incorporating From 0a383996b713e2b3e6f1223fa797dfd9915ce2dc Mon Sep 17 00:00:00 2001 From: Rich Bielby Date: Thu, 12 Dec 2024 16:16:37 +0000 Subject: [PATCH 12/16] Update R/a11y_panel.R Co-authored-by: Cam Race <52536248+cjrace@users.noreply.github.com> --- R/a11y_panel.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/a11y_panel.R b/R/a11y_panel.R index 6a17b7e..6c844bc 100644 --- a/R/a11y_panel.R +++ b/R/a11y_panel.R @@ -183,10 +183,10 @@ a11y_panel <- function( "(the \"accessibility regulations\")." ), shiny::tags$p( - "If you are not happy with how we respond to your complaint, ", + "If you are not happy with how we respond to your complaint, contact the ", external_link( href = "https://www.equalityadvisoryservice.com/", - "contact the Equality Advisory and Support Service (EASS)" + "Equality Advisory and Support Service (EASS)" ), "." ), From 51c92c395b75ae66183d5e397508aeea3324ade6 Mon Sep 17 00:00:00 2001 From: Rich Bielby Date: Thu, 12 Dec 2024 16:16:56 +0000 Subject: [PATCH 13/16] Update R/a11y_panel.R Co-authored-by: Cam Race <52536248+cjrace@users.noreply.github.com> --- R/a11y_panel.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/a11y_panel.R b/R/a11y_panel.R index 6c844bc..7fe0b77 100644 --- a/R/a11y_panel.R +++ b/R/a11y_panel.R @@ -24,7 +24,7 @@ #' @param date_template_reviewed Date the underlying template was reviewed #' (default: 12th March 2024) #' -#' @return shiny$tags$div element containing the html tags and content for the standard +#' @return shiny$tags$div element containing the HTML tags and content for the standard #' accessibility statement #' @export #' From 02c007e206fc2dddd75ea3abd5a135e9dfae4876 Mon Sep 17 00:00:00 2001 From: Rich Bielby Date: Thu, 12 Dec 2024 16:17:03 +0000 Subject: [PATCH 14/16] Update R/a11y_panel.R Co-authored-by: Cam Race <52536248+cjrace@users.noreply.github.com> --- R/a11y_panel.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/a11y_panel.R b/R/a11y_panel.R index 7fe0b77..7615c00 100644 --- a/R/a11y_panel.R +++ b/R/a11y_panel.R @@ -53,7 +53,7 @@ a11y_panel <- function( ), specific_issues = c( "Charts have non-accessible components that are inaccessible for keyboard users.", - "Chart tooltips are not compativle with screen reader use.", + "Chart tooltips are not compatible with screen reader use.", "Some decorative images are not labelled appropriately as yet.", "Some links are not appropriately labelled." )) { From 846cbc33149db3ddb660c00e324c977361d25ec7 Mon Sep 17 00:00:00 2001 From: Rich Bielby Date: Thu, 12 Dec 2024 16:17:41 +0000 Subject: [PATCH 15/16] Some fixes for a11y_panel based on PR comments --- R/a11y_panel.R | 27 +++++++++++++++++++-------- R/header.R | 2 +- R/validation.R | 2 +- tests/testthat/test-a11y_panel.R | 2 +- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/R/a11y_panel.R b/R/a11y_panel.R index 6a17b7e..9bc3733 100644 --- a/R/a11y_panel.R +++ b/R/a11y_panel.R @@ -36,6 +36,8 @@ #' "26th April 2024", #' "2nd November 2024", #' issues_contact = "https://github.com/dfe-analytical-services/shiny-template", +#' publication_slug = "la-and-school-expenditure", +#' publication_name = "LA and school expenditure" #' ) a11y_panel <- function( dashboard_title, @@ -157,14 +159,23 @@ a11y_panel <- function( }, shiny::tags$h2("Feedback and contact information"), if (!is.null(publication_slug)) { - shiny::tags$p( - "If you need information on this website in a different format please see the parent ", - external_link(href = publication_slug, link_text = publication_name), - "publication." - ) - shiny::tags$p( - "More details are available on that service for alternative formats of this ", - "data." + shiny::tagList( + shiny::tags$p( + "If you need information on this website in a different format please see the", + " parent publication, ", + external_link( + href = paste0( + "https://explore-education-statistics.service.gov.uk/find-statistics/", + publication_slug + ), + link_text = publication_name + ), + "." + ), + shiny::tags$p( + "More details are available on that service for alternative formats of this ", + "data." + ) ) }, shiny::tags$p("We're always looking to improve the accessibility of this website. diff --git a/R/header.R b/R/header.R index 4f6d736..4f7142b 100644 --- a/R/header.R +++ b/R/header.R @@ -24,7 +24,7 @@ #' } header <- function(header) { shinyGovstyle::header( - logo = "/dfeshiny/DfE_logo_landscape.png", + logo = "dfeshiny/DfE_logo_landscape.png", main_text = "", secondary_text = header, main_link = "https://www.gov.uk/government/organisations/department-for-education", diff --git a/R/validation.R b/R/validation.R index 57a5332..0265756 100644 --- a/R/validation.R +++ b/R/validation.R @@ -7,7 +7,7 @@ validate_date <- function(date) { date_template <- lubridate::stamp("1 January 2020", orders = "dmy", quiet = TRUE) if (is.na(date_ld)) { valid <- FALSE - validation_message <- "is not in a valid date format, e.g. 8th Auguest 2024 or 08/08/2024." + validation_message <- "is not in a valid date format, e.g. 8th August 2024 or 08/08/2024." } else if (date_ld > Sys.time()) { valid <- FALSE validation_message <- "is in the future." diff --git a/tests/testthat/test-a11y_panel.R b/tests/testthat/test-a11y_panel.R index 756b045..db7b464 100644 --- a/tests/testthat/test-a11y_panel.R +++ b/tests/testthat/test-a11y_panel.R @@ -105,7 +105,7 @@ test_that("Accessibility dates are required", { date_reviewed = "12th November 2024", issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ), - "\"Geoff\" is not in a valid date format, e.g. 8th Auguest 2024 or 08/08/2024." + "\"Geoff\" is not in a valid date format, e.g. 8th August 2024 or 08/08/2024." ) expect_error( a11y_panel( From e245c3ab727c3cce4bcbf1f08e49e5abe6bd1f7e Mon Sep 17 00:00:00 2001 From: Rich Bielby Date: Thu, 12 Dec 2024 16:20:20 +0000 Subject: [PATCH 16/16] Test update on header function and documentation update --- man/a11y_panel.Rd | 6 ++++-- tests/testthat/test-a11y_panel.R | 4 ++-- tests/testthat/test-header.R | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/man/a11y_panel.Rd b/man/a11y_panel.Rd index b5e1306..16955da 100644 --- a/man/a11y_panel.Rd +++ b/man/a11y_panel.Rd @@ -19,7 +19,7 @@ a11y_panel( "Alternative text in interactive charts is limited to titles"), specific_issues = c("Charts have non-accessible components that are inaccessible for keyboard users.", - "Chart tooltips are not compativle with screen reader use.", + "Chart tooltips are not compatible with screen reader use.", "Some decorative images are not labelled appropriately as yet.", "Some links are not appropriately labelled.") ) @@ -52,7 +52,7 @@ Statistics (optional)} that have been identified as part of testing} } \value{ -shiny$tags$div element containing the html tags and content for the standard +shiny$tags$div element containing the HTML tags and content for the standard accessibility statement } \description{ @@ -73,5 +73,7 @@ a11y_panel( "26th April 2024", "2nd November 2024", issues_contact = "https://github.com/dfe-analytical-services/shiny-template", + publication_slug = "la-and-school-expenditure", + publication_name = "LA and school expenditure" ) } diff --git a/tests/testthat/test-a11y_panel.R b/tests/testthat/test-a11y_panel.R index db7b464..f074a78 100644 --- a/tests/testthat/test-a11y_panel.R +++ b/tests/testthat/test-a11y_panel.R @@ -116,7 +116,7 @@ test_that("Accessibility dates are required", { date_reviewed = "12th November 2024", issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ), - "\"Bob\" is not in a valid date format, e.g. 8th Auguest 2024 or 08/08/2024." + "\"Bob\" is not in a valid date format, e.g. 8th August 2024 or 08/08/2024." ) expect_error( a11y_panel( @@ -127,7 +127,7 @@ test_that("Accessibility dates are required", { date_reviewed = "Daisy", issues_contact = "https://github.com/dfe-analytical-services/shiny-template/issues" ), - "\"Daisy\" is not in a valid date format, e.g. 8th Auguest 2024 or 08/08/2024." + "\"Daisy\" is not in a valid date format, e.g. 8th August 2024 or 08/08/2024." ) }) diff --git a/tests/testthat/test-header.R b/tests/testthat/test-header.R index fb3194f..9a257ce 100644 --- a/tests/testthat/test-header.R +++ b/tests/testthat/test-header.R @@ -16,6 +16,6 @@ test_that("outputs are as expected", { output[["children"]][[2]][["children"]][[1]][["children"]][[1]] [["children"]][[1]][["children"]][[1]][["attribs"]][["src"]] ), - "/dfeshiny/DfE_logo_landscape.png" + "dfeshiny/DfE_logo_landscape.png" ) })