Skip to content

Commit

Permalink
Merge pull request Scottish-Tech-Army#5 from Scottish-Tech-Army/conte…
Browse files Browse the repository at this point in the history
…ntCapitalisation

Content capitalisation
  • Loading branch information
donal-s authored Jan 12, 2021
2 parents 0a1e197 + b0ac756 commit b67742a
Show file tree
Hide file tree
Showing 38 changed files with 696 additions and 592 deletions.
115 changes: 51 additions & 64 deletions adminclient/src/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState, useRef } from "react";
import React, { useEffect, useState } from "react";
import "./App.css";
import AppBar from "@material-ui/core/AppBar";
import Toolbar from "@material-ui/core/Toolbar";
Expand Down Expand Up @@ -65,15 +65,23 @@ const useStyles = makeStyles((theme) => ({
},
}));

function getSurveyIdsToRetrieve(selectedSurveyIds, fullSurveyResponses) {
return selectedSurveyIds.filter(
(surveyId) =>
fullSurveyResponses.find(
(fullSurveyResponse) => surveyId === fullSurveyResponse.id
) === undefined
);
}

function App() {
const classes = useStyles();
const [surveyResponses, setSurveyResponses] = useState([]);
const [fullSurveyResponses, setFullSurveyResponses] = useState([]);
const [dataRows, setDataRows] = useState([]);
const [openSurveyResponses, setOpenSurveyResponses] = useState(false);
const [selectedSurveyIds, setSelectedSurveyIds] = useState([]);
const exportCsvRequested = useRef(false);
const allResponsesRetrieved = useRef(true);
const [exportCsvRequested, setExportCsvRequested] = useState(false);

useEffect(() => {
if (surveyResponses != null && surveyResponses.length > 0) {
Expand Down Expand Up @@ -118,85 +126,64 @@ function App() {
}, []);

useEffect(() => {
if (selectedSurveyIds.length === 0) {
allResponsesRetrieved.current = true;
return;
}
const surveyIdsToRetrieve = selectedSurveyIds.filter(
(surveyId) =>
fullSurveyResponses.find(
(fullSurveyResponse) => surveyId === fullSurveyResponse.id
) === undefined
const surveyIdsToRetrieve = getSurveyIdsToRetrieve(
selectedSurveyIds,
fullSurveyResponses
);
if (surveyIdsToRetrieve.length === 0) {
allResponsesRetrieved.current = true;
return;
}

allResponsesRetrieved.current = false;

Auth.currentCredentials()
.then((credentials) => {
const dynamodbClient = new DynamoDBClient({
region: REGION,
credentials: credentials,
if (surveyIdsToRetrieve.length > 0) {
Auth.currentCredentials()
.then((credentials) => {
const dynamodbClient = new DynamoDBClient({
region: REGION,
credentials: credentials,
});
const params = {
RequestItems: {},
ReturnConsumedCapacity: "TOTAL",
};
params.RequestItems[SURVEY_RESPONSES_TABLE] = {
Keys: surveyIdsToRetrieve.map((id) => {
return { id: { S: id } };
}),
};
console.log("Retrieving full responses data", params);
return dynamodbClient.send(new BatchGetItemCommand(params));
})
.then((result) => {
console.log("Survey responses", result);
const retrievedResponses = result.Responses[
SURVEY_RESPONSES_TABLE
].map((item) => unmarshall(item));
setFullSurveyResponses((fullSurveyResponses) => [
...fullSurveyResponses,
...retrievedResponses,
]);
})
.catch((error) => {
console.log("User not logged in", error);
});
const params = {
RequestItems: {},
ReturnConsumedCapacity: "TOTAL",
};
params.RequestItems[SURVEY_RESPONSES_TABLE] = {
Keys: surveyIdsToRetrieve.map((id) => {
return { id: { S: id } };
}),
};
console.log("Retrieving full responses data", params);
return dynamodbClient.send(new BatchGetItemCommand(params));
})
.then((result) => {
console.log("Survey responses", result);
const retrievedResponses = result.Responses[
SURVEY_RESPONSES_TABLE
].map((item) => unmarshall(item));
setFullSurveyResponses((fullSurveyResponses) => [
...fullSurveyResponses,
...retrievedResponses,
]);
allResponsesRetrieved.current = true;
})
.catch((error) => {
console.log("User not logged in", error);
});
}
}, [selectedSurveyIds, fullSurveyResponses]);

useEffect(() => {
console.log(
"export status",
exportCsvRequested,
allResponsesRetrieved,
const surveyIdsToRetrieve = getSurveyIdsToRetrieve(
selectedSurveyIds,
fullSurveyResponses
);
if (exportCsvRequested.current && allResponsesRetrieved.current) {
exportCsvRequested.current = false;
if (exportCsvRequested && surveyIdsToRetrieve.length === 0) {
setExportCsvRequested(false);

exportSurveysAsCsv(
fullSurveyResponses.filter((surveyResponse) =>
selectedSurveyIds.includes(surveyResponse.id)
)
);
}
}, [
selectedSurveyIds,
fullSurveyResponses,
exportCsvRequested,
allResponsesRetrieved,
]);
}, [selectedSurveyIds, fullSurveyResponses, exportCsvRequested]);

function requestExportCsv(surveyIds) {
allResponsesRetrieved.current = false;
exportCsvRequested.current = true;
setSelectedSurveyIds(surveyIds);
setExportCsvRequested(true);
}

return (
Expand Down
36 changes: 18 additions & 18 deletions sharedmodel/src/Content.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,25 +114,25 @@ export const sectionsContent = [
{addQuestion(
SCALE_WITH_COMMENT,
"classroom",
"We have an outdoor classroom area that can be used by a whole class"
"we have an outdoor classroom area that can be used by a whole class"
)}
<hr className="question-divider" />
{addQuestion(
SCALE_WITH_COMMENT,
"seating",
"We have outdoor seating areas for working in smaller groups"
"we have outdoor seating areas for working in smaller groups"
)}
<hr className="question-divider" />
{addQuestion(
SCALE_WITH_COMMENT,
"sheltered",
"Outdoor classrooms and seating areas are reasonably sheltered and comfortable to use"
"outdoor classrooms and seating areas are reasonably sheltered and comfortable to use"
)}
<hr className="question-divider" />
{addQuestion(
SCALE_WITH_COMMENT,
"disturbance",
"Using outdoor classrooms and curriculum features doesn't cause significant disturbance to indoor classes"
"using outdoor classrooms and curriculum features doesn't cause significant disturbance to indoor classes"
)}
</>
),
Expand Down Expand Up @@ -538,7 +538,7 @@ export const sectionsContent = [
{addQuestion(
TEXT_AREA,
"namegreenspace",
"What area of nearby local greenspace has the most potential for regular school use for outdoor learning and play?"
"what area of nearby local greenspace has the most potential for regular school use for outdoor learning and play?"
)}
<hr className="subsection-divider" />
<p>
Expand All @@ -552,51 +552,51 @@ export const sectionsContent = [
{addQuestion(
SCALE_WITH_COMMENT,
"accessible",
"This area is readily accessible for regular use by the school"
"this area is readily accessible for regular use by the school"
)}
<hr className="question-divider" />
{addQuestion(
TEXT_AREA,
"improveaccessible",
"How might you be able to improve its accessibility - for example with a gate, clearing a path, bridging a ditch etc?"
"how might you be able to improve its accessibility - for example with a gate, clearing a path, bridging a ditch etc?"
)}
<hr className="question-divider" />
{addQuestion(
SCALE_WITH_COMMENT,
"frequentuse",
"The school uses this space alot (e.g. at least monthly)"
"the school uses this space alot (e.g. at least monthly)"
)}
<hr className="question-divider" />
{addQuestion(
SCALE_WITH_COMMENT,
"wildlife",
"The area is really valuable for wildlife"
"the area is really valuable for wildlife"
)}
<hr className="question-divider" />
{addQuestion(
TEXT_AREA,
"improvewildlife",
"How might you improve the area for wildlife?"
"how might you improve the area for wildlife?"
)}
<hr className="question-divider" />
{addQuestion(
SCALE_WITH_COMMENT,
"teaching",
"As it is, the area is a really useful space for teaching and play"
"as it is, the area is a really useful space for teaching and play"
)}
<hr className="question-divider" />
{addQuestion(
TEXT_AREA,
"improveteaching",
"How could it be made more useful for teaching and play?"
"how could it be made more useful for teaching and play?"
)}
<hr className="question-divider" />
{addQuestion(TEXT_AREA, "listowner", "Who owns this area of land?")}
{addQuestion(TEXT_AREA, "listowner", "who owns this area of land?")}
<hr className="question-divider" />
{addQuestion(
SCALE_WITH_COMMENT,
"changes",
"Will it be straightforward to agree any changes you'd like to make with the land owner?"
"will it be straightforward to agree any changes you'd like to make with the land owner?"
)}
</>
),
Expand Down Expand Up @@ -708,13 +708,13 @@ export const sectionsContent = [
{addQuestion(
SCALE_WITH_COMMENT,
"groundsadvisor",
"If there was a school grounds advisor available in this area then would you make use of them in your school?"
"if there was a school grounds advisor available in this area then would you make use of them in your school?"
)}
<hr className="question-divider" />
{addQuestion(
SCALE_WITH_COMMENT,
"onlineresources",
"Would it be helpful to have online information and resources on how to develop some of the ideas suggested in this audit?"
"would it be helpful to have online information and resources on how to develop some of the ideas suggested in this audit?"
)}
<hr className="question-divider" />
{addQuestion(
Expand All @@ -726,13 +726,13 @@ export const sectionsContent = [
{addQuestion(
SCALE_WITH_COMMENT,
"straightforward",
"Would you say it was fairly straightforward to answer the questions in this audit?"
"would you say it was fairly straightforward to answer the questions in this audit?"
)}
<hr className="question-divider" />
{addQuestion(
SCALE_WITH_COMMENT,
"ideas",
"Would you say that the process of completing this audit has given you some ideas for how to improve your outdoor learning and play provision?"
"would you say that the process of completing this audit has given you some ideas for how to improve your outdoor learning and play provision?"
)}
</>
),
Expand Down
37 changes: 22 additions & 15 deletions surveyclient/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ textarea {

/** Active shadows **/

.app-bar #auth-signin-signout,
.app-bar #auth-signout,
.app-bar .download-button,
.app-bar #restart-button,
.section.authenticator button,
.dialog button,
.submit-survey-button,
Expand All @@ -125,8 +126,9 @@ textarea {
box-shadow: 0px 2px 4px #00000080;
}

.app-bar #auth-signin-signout:active,
.app-bar #auth-signout:active,
.app-bar .download-button:active,
.app-bar #restart-button:active,
.section.authenticator button:disabled,
.section.authenticator button:active,
.dialog button:active,
Expand Down Expand Up @@ -194,8 +196,9 @@ textarea {
margin-right: 130px;
}

.app-bar #auth-signin-signout,
.app-bar .download-button {
.app-bar #auth-signout,
.app-bar .download-button,
.app-bar #restart-button {
position: absolute;
width: 100px;
height: 40px;
Expand All @@ -204,11 +207,16 @@ textarea {
font-weight: normal;
border: none;
}
.app-bar #auth-signin-signout {
.app-bar #auth-signout {
background-color: var(--colour-ltl-blue);
color: white;
top: 70px;
}
.app-bar #restart-button {
background-color: var(--colour-ltl-orange);
color: black;
top: 120px;
}
.app-bar .download-button {
background-color: var(--colour-ltl-green);
color: black;
Expand All @@ -225,7 +233,7 @@ textarea {
.app-bar .auth-current-user {
display: block;
position: absolute;
right: 20px;
left: 20px;
top: 150px;
font-weight: bold;
font-size: 15px;
Expand Down Expand Up @@ -875,13 +883,6 @@ textarea {
padding: 0;
}

.section.authenticator button#continue-signed-out-button {
margin-left: 40px;
background-color: var(--colour-ltl-orange);
color: black;
font-weight: bold;
}

.section.authenticator h2,
.section.get-started h2 {
font-family: var(--font-family-ltl-heading);
Expand Down Expand Up @@ -1187,16 +1188,22 @@ textarea {
}

.app-bar .download-button,
.app-bar #auth-signin-signout {
.app-bar #restart-button,
.app-bar #auth-signout {
width: 75px;
height: 30px;
}

.app-bar #auth-signin-signout {
.app-bar #auth-signout {
right: 20px;
top: 60px;
}

.app-bar #restart-button {
right: 20px;
top: 100px;
}

.app-bar .download-button {
right: 20px;
top: 20px;
Expand Down
Loading

0 comments on commit b67742a

Please sign in to comment.