-
Notifications
You must be signed in to change notification settings - Fork 2
Td 2500 render results #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 44 commits
f265c16
48dc4be
ddad0df
07d1ad5
d065fc4
662aecb
b0cf037
aeeb84b
612d3fe
0ca367b
26c932f
aa365bb
2874102
8a997c1
a17c8c4
8e04610
0664436
4295879
317f1d0
57db093
869c028
398f21f
b262188
7ce3439
cfb3a3c
33408ce
02fde09
a2537ab
cd2a674
91a5ed8
c4bd1f8
a50b734
4152072
43315d5
80c930f
e416ea3
3241452
bfafcb5
1770629
1d57f34
2825d0f
4529d36
71e7faf
a51a651
2c2def5
1ba75f1
5d42077
4a48daf
5ac1e92
9df964e
e17e6a3
173ecda
e8f085c
d52a623
034eb57
9b84208
23896f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ import RecommendationChart from "./results/recommendation/chart"; | |
| import Status from "./status"; | ||
| import Survey from "./survey"; | ||
| import CognitiveSurvey from "./survey/cognitive"; | ||
| import GenericSurvey from "./survey/generic"; | ||
| import PersonalitySurvey from "./survey/personality"; | ||
|
|
||
| export default { | ||
|
|
@@ -90,6 +91,7 @@ export default { | |
| Survey: { | ||
| Cognitive: CognitiveSurvey, | ||
| Container: Survey, | ||
| GenericSurvey, | ||
|
||
| Personality: PersonalitySurvey | ||
| } | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import PropTypes from "prop-types"; | ||
| import {useState} from "react"; | ||
| import useTranslate from "lib/hooks/use-translate"; | ||
| import Question from "./question"; | ||
| import style from "./style.scss"; | ||
|
|
||
| export default function Breakdown({assessmentResult}) { | ||
| const [showAll, setShowAll] = useState(false); | ||
| const translate = useTranslate(); | ||
| const showHideAll = () => { | ||
| setShowAll(!showAll); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className={style.breakdown}> | ||
| <div className={style.description}> | ||
| <div> | ||
| <div className={style.title}>{translate("results.generic.breakdown")}</div> | ||
| <span>{translate("results.generic.breakdown_description")}</span> | ||
| </div> | ||
| <div> | ||
| <button className={style.toggleButton} type="button" onClick={showHideAll}> | ||
| {translate("show_hide_all")} | ||
| </button> | ||
| </div> | ||
| </div> | ||
| <div className={style.questions}> | ||
| {assessmentResult.responses.map((question, index) => ( | ||
| <Question | ||
| key={question.questionId} | ||
| question={question} | ||
| index={index} | ||
| showState={showAll} | ||
| /> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| Breakdown.propTypes = { | ||
| assessmentResult: PropTypes.shape({ | ||
| responses: PropTypes.arrayOf( | ||
| PropTypes.shape({ | ||
| questionId: PropTypes.string.isRequired, | ||
| questionText: PropTypes.string, | ||
| isCorrect: PropTypes.bool.isRequired, | ||
| selectedResponseOptionId: PropTypes.string, | ||
| responseOptions: PropTypes.arrayOf( | ||
| PropTypes.shape({ | ||
| responseOptionId: PropTypes.string.isRequired, | ||
| responseOptionText: PropTypes.string.isRequired, | ||
| isCorrect: PropTypes.bool | ||
| }) | ||
| ).isRequired | ||
| }) | ||
| ).isRequired | ||
| }).isRequired | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import useResults from "lib/hooks/use-results"; | ||
| import Breakdown from "./breakdown"; | ||
| import Score from "./score"; | ||
| import style from "./style.scss"; | ||
|
|
||
| export default function GenericResults() { | ||
| const result = useResults({surveyType: "generic"}); | ||
|
|
||
| return ( | ||
| <div> | ||
| {result && ( | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <div className={style.container}> | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <div className={style.contentBody}> | ||
| <Score assessmentResult={result} /> | ||
| <Breakdown assessmentResult={result} /> | ||
| </div> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import {faCheck, faXmark, faChevronDown, faChevronUp} from "@fortawesome/free-solid-svg-icons"; | ||
| import PropTypes from "prop-types"; | ||
| import {useState, useEffect} from "react"; | ||
| import Icon from "components/common/icon"; | ||
| import useTranslate from "lib/hooks/use-translate"; | ||
| import style from "./style.scss"; | ||
|
|
||
| export default function Question({question, index, showState}) { | ||
| const translate = useTranslate(); | ||
| const [showContent, setShowContent] = useState(false); | ||
| const responsesClassName = question.setImage | ||
| ? style.responsesWithImage | ||
| : style.responsesWithoutImage; | ||
| const longTextCondition = (option) => option.responseOptionText.length > 20; | ||
| const longTextResponses = question.responseOptions.some(longTextCondition); | ||
| const optionsDirection = (longTextResponses || responsesClassName === style.responsesWithImage) | ||
| ? "column" | ||
| : "row"; | ||
|
|
||
| useEffect(() => { | ||
| setShowContent(showState); | ||
| }, [showState]); | ||
|
|
||
| const toggleContent = () => { | ||
| setShowContent(!showContent); | ||
| }; | ||
|
|
||
| const optionClassName = (option) => { | ||
| let className = ""; | ||
| if(question.isCorrect) { | ||
This conversation was marked as resolved.
Show resolved
Hide resolved
|
||
| className = option.isCorrect ? style.correctResponse : ""; | ||
| } else { | ||
| if(option.isCorrect) { | ||
| className = style.correctOption; | ||
| } else if(option.responseOptionId === question.selectedResponseOptionId) { | ||
| className = style.incorrectResponse; | ||
| } | ||
| } | ||
| return className; | ||
| }; | ||
|
|
||
| return ( | ||
| <div key={question.questionId} className={style.question}> | ||
| <div className={style.questionTitle}> | ||
| <div> | ||
| {question.isCorrect | ||
| ? <Icon className={style.iconCorrect} alt="Checked" icon={faCheck} /> | ||
| : <Icon className={style.iconIncorrect} alt="X Mark" icon={faXmark} />} | ||
| </div> | ||
| <div> {translate("cognitive_question_alt_text")} {index + 1}</div> | ||
| <div> | ||
| <button type="button" onClick={toggleContent} className={style.toggleButton}> | ||
| <Icon className={style.icon} alt="Expand" icon={showContent ? faChevronUp : faChevronDown} /> | ||
| </button> | ||
| </div> | ||
| </div> | ||
| {showContent && ( | ||
| <div className={style.questionContent}> | ||
| <div className={style.responseOptions}> | ||
| <div className={style.questionText}>{question.questionText}</div> | ||
| <div className={responsesClassName} style={{flexDirection: optionsDirection}}> | ||
| {question.responseOptions.map((option) => ( | ||
| <div | ||
| key={option.responseOptionId} | ||
| className={`${optionClassName(option)} ${style.responseOption}`} | ||
| > | ||
| {option.responseOptionText} | ||
| </div> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| {question.setImage && ( | ||
| <div className={style.questionImage}> | ||
| <img src={question.setImage} alt={question.questionText} /> | ||
| </div> | ||
| )} | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| Question.propTypes = { | ||
| question: PropTypes.shape({ | ||
| questionText: PropTypes.string, | ||
| questionId: PropTypes.string.isRequired, | ||
| isCorrect: PropTypes.bool.isRequired, | ||
| selectedResponseOptionId: PropTypes.string, | ||
| setImage: PropTypes.string, | ||
| responseOptions: PropTypes.arrayOf(PropTypes.shape({ | ||
| responseOptionId: PropTypes.string.isRequired, | ||
| responseOptionText: PropTypes.string.isRequired, | ||
| isCorrect: PropTypes.bool.isRequired | ||
| })).isRequired | ||
| }).isRequired, | ||
| index: PropTypes.number.isRequired, | ||
| showState: PropTypes.bool.isRequired | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.