-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathself-assess.qmd
145 lines (107 loc) · 3.1 KB
/
self-assess.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
---
title: "RAP Self Assessment"
format:
html:
theme: [default, styles.scss]
title-block-banner: true
template-partials: partials/title-block.html
logo: images/SG-logo.jpg
toc: true
toc-depth: 3
toc-location: left
toc-title: "Contents"
anchor-sections: false
smooth-scroll: true
header-includes: |
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto">
embed-resources: true
server: shiny
---
```{r setup, include = FALSE}
#| context: setup
# Load packages
library(shiny)
library(dplyr)
library(tidyr)
library(here)
library(readr)
library(purrr)
library(tibble)
library(stringr)
library(knitr)
# Load Shiny modules
walk(list.files("modules", ".R$", full.names = TRUE), source)
# Read in criteria list
criteria <- read_rds(here("data", "criteria.rds"))
# Check help text available for all criteria
if(any(!criteria$id %in% str_extract(list.files(here("quarto-docs", "help")),
"id_\\d+_\\d+"))) {
stop("All IDs in `data/criteria.rds` must have a corresponding file in ",
"`quarto-docs/help/`.")
}
# Read in lookup data
all_options <- read_rds(here("data", "options.rds"))
all_levels <- read_rds(here("data", "levels.rds"))
# Set project directory as root when using knit_child
opts_knit$set(root.dir = here())
```
## About this tool
```{r about, results = "asis", warning = FALSE}
cat(knit_child(here("quarto-docs", "_about-this-tool.qmd"),
envir = environment(),
quiet = TRUE))
```
## Self assessment
### About your project
```{r metadata}
metadata_ui("metadata")
```
```{r form, results = "asis", warning = FALSE}
out <- map(
all_levels,
function(level) {
knit_child(here("quarto-docs", "_level-form.qmd"),
envir = environment(),
quiet = TRUE)
}
)
cat(unlist(out), sep = "\n")
```
## Download report
```{r download}
tagList(
download_report_ui("report"),
download_csv_ui("csv")
)
```
## Further support
```{r support, results = "asis", warning = FALSE}
cat(knit_child(here("quarto-docs", "_further-support.qmd"),
envir = environment(),
quiet = TRUE))
```
## Licence
All content is available under the [Open Government Licence v3.0](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/), except where otherwise stated.
<!-- Shiny server -->
```{r server}
#| context: server
form_responses <- map(
set_names(unique(criteria$id)),
~ possibly(callModule)(form_server, .x)
)
data_output <- reactive({
form_responses <- map_dfr(form_responses, ~ .x(), .id = "id")
criteria |>
left_join(form_responses, by = "id") |>
mutate(
status = replace_na(status, "not_assessed"),
status_label = case_when(
status == "not_assessed" ~ "Not assessed",
TRUE ~ names(all_options)[match(status, all_options)]
)
)
})
metadata <- callModule(metadata_server, "metadata")
callModule(download_csv_server, "csv", data_output, all_levels)
callModule(download_report_server, "report", data_output, metadata)
```