From 4bf54b6236eff9fb134232e9df491ac02c3a4443 Mon Sep 17 00:00:00 2001 From: Juliet Zhang Date: Wed, 23 Mar 2022 00:33:31 -0700 Subject: [PATCH] Implement logic (#93) and update quiz choices --- src/components/PathDay/PathDay.js | 2 + src/pages/Pathway/Pathway.js | 76 ++++++++++++++++++++++++++++--- src/pages/Quiz/Quiz.js | 2 +- 3 files changed, 73 insertions(+), 7 deletions(-) diff --git a/src/components/PathDay/PathDay.js b/src/components/PathDay/PathDay.js index 30f28f6..ce74a31 100644 --- a/src/components/PathDay/PathDay.js +++ b/src/components/PathDay/PathDay.js @@ -20,6 +20,8 @@ const PathDay = ({ index, resource }) => { {resource.difficulty} {resource.video != null && video} {resource.article != null && article} + {resource.game != null && game} + {resource.documentation != null && documentation} diff --git a/src/pages/Pathway/Pathway.js b/src/pages/Pathway/Pathway.js index 44b8321..2845e65 100644 --- a/src/pages/Pathway/Pathway.js +++ b/src/pages/Pathway/Pathway.js @@ -8,24 +8,88 @@ import './Pathway.css'; const Pathway = () => { const {quizResults} = useContext(QuizContext); - // start from here... console.log(quizResults); - - const example_resources = resources[3].links; + + // Get resources matching desired category + let resourcesByCategory = resources[0].links; // Default to HTML/CSS track + if (quizResults.category === "HTML/CSS") { + resourcesByCategory = resources[0].links; + } + else if (quizResults.category === "Javascript") { + resourcesByCategory = [...resources[1].links, ...resources[2].links]; + } + else if (quizResults.category === "React") { + resourcesByCategory = resources[3].links; + } + else if (quizResults.category === "Git") { + resourcesByCategory = resources[4].links; + } + else if (quizResults.category === "Graphic Design") { + resourcesByCategory = resources[5].links; + } + else if (quizResults.category === "Accessibility") { + resourcesByCategory = resources[6].links; + } + else if (quizResults.category === "Product Management") { + resourcesByCategory = resources[7].links; + } + + // Put resources of desired type closer to top + let resourcesByType = [...resourcesByCategory.filter((resource) => resource.video != null), + ...resourcesByCategory.filter((resource) => resource.video == null)]; // Default to Video + if (quizResults.type === "Article") { + resourcesByType = [...resourcesByCategory.filter((resource) => resource.article != null), + ...resourcesByCategory.filter((resource) => resource.article == null)]; + } + else if (quizResults.type === "Game") { + resourcesByType = [...resourcesByCategory.filter((resource) => resource.game != null), + ...resourcesByCategory.filter((resource) => resource.game == null)]; + } + else if (quizResults.type === "Documentation") { + resourcesByType = [...resourcesByCategory.filter((resource) => resource.documentation != null), + ...resourcesByCategory.filter((resource) => resource.documentation == null)]; + } + + // Use line below if no need for progression (i.e., only display lessons that match user's current difficulty level) + // let generatedResources = resourcesByCategory.filter((resource) => resource.difficulty === quizResults.difficulty); + + // Get resources from current difficulty level first, then more difficult resources as user progresses + let generatedResources = [...resourcesByType.filter((resource) => resource.difficulty === "Beginner"), + ...resourcesByType.filter((resource) => resource.difficulty === "Intermediate"), + ...resourcesByType.filter((resource) => resource.difficulty === "Advanced")]; // Default to Beginner + if (quizResults.difficulty === "Intermediate") { + generatedResources = [...resourcesByType.filter((resource) => resource.difficulty === "Intermediate"), + ...resourcesByType.filter((resource) => resource.difficulty === "Advanced")]; + } + else if (quizResults.difficulty === "Advanced") { + generatedResources = resourcesByType.filter((resource) => resource.difficulty === "Advanced"); + } + + // Determine how many lessons to display based on timeline + let days = 30; // Default to 1 month + if (quizResults.time === "3 days") { + days = 3; + } + else if (quizResults.time === "1 week") { + days = 7; + } + else if (quizResults.time === "2 weeks") { + days = 14; + } return (
- {example_resources.map((resource, index) => - + {generatedResources.map((resource, index) => + index < days && )}

Come back later?

You can come back later and your pathway will be saved! Alternatively, diff --git a/src/pages/Quiz/Quiz.js b/src/pages/Quiz/Quiz.js index cd45146..1198252 100644 --- a/src/pages/Quiz/Quiz.js +++ b/src/pages/Quiz/Quiz.js @@ -34,7 +34,7 @@ const Quiz = (props) => { { quizResults = { ...quizResults,