-
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
Open
prd-duy-huynh
wants to merge
57
commits into
master
Choose a base branch
from
TD-2500-render-results
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
f265c16
setup generic
prd-duy-huynh 48dc4be
add generic component graphql
prd-duy-huynh ddad0df
render questions
prd-duy-huynh 07d1ad5
render questions and collect answers
prd-duy-huynh d065fc4
refactor
prd-duy-huynh 662aecb
handle multi questions set
prd-duy-huynh b0cf037
add conclusions view
prd-duy-huynh aeeb84b
add show instructions
prd-duy-huynh 612d3fe
update Modal common
prd-duy-huynh 0ca367b
submit answers
prd-duy-huynh 26c932f
Merge branch 'master' into TD-2435-generic-assessment-ui
prd-duy-huynh aa365bb
use assessmentID
prd-duy-huynh 2874102
bump version
prd-duy-huynh 8a997c1
refactor
prd-duy-huynh a17c8c4
update graphql responses
prd-duy-huynh 8e04610
refactor code
prd-duy-huynh 0664436
add retry attempts
prd-duy-huynh 4295879
render score
prd-duy-huynh 317f1d0
remove secret key
prd-duy-huynh 57db093
Merge branch 'master' into TD-2435-generic-assessment-ui
prd-duy-huynh 869c028
render breakdown
prd-duy-huynh 398f21f
apply space-between
prd-duy-huynh b262188
show hide all
prd-duy-huynh 7ce3439
format
prd-duy-huynh cfb3a3c
handle question with set image
prd-duy-huynh 33408ce
Merge branch 'TD-2435-generic-assessment-ui' into TD-2500-render-results
prd-duy-huynh 02fde09
handle locale
prd-duy-huynh a2537ab
update heading and hr tag
prd-duy-huynh cd2a674
helper
prd-duy-huynh 91a5ed8
rearrange css class
prd-duy-huynh c4bd1f8
use translate
prd-duy-huynh a50b734
parse completedAt by millisecond
prd-duy-huynh 4152072
Merge branch 'master' into TD-2500-render-results
prd-duy-huynh 43315d5
Added loading state
tomprats 80c930f
remove header and actions
prd-duy-huynh e416ea3
Merge branch 'master' into TD-2500-render-results
prd-duy-huynh 3241452
set loaded active assessment + remove redundant generic result css
prd-duy-huynh bfafcb5
bump version to 3.9.0
prd-duy-huynh 1770629
extend box and container
prd-duy-huynh 1d57f34
extend container
prd-duy-huynh 2825d0f
refactor btn border
prd-duy-huynh 4529d36
return after setActive
prd-duy-huynh 71e7faf
name format
prd-duy-huynh a51a651
get result if completed
prd-duy-huynh 2c2def5
not return cached survey if completed
prd-duy-huynh 1ba75f1
not call to result api
prd-duy-huynh 5d42077
render totalCorrectResponses
prd-duy-huynh 4a48daf
let question set in column for mobile
prd-duy-huynh 5ac1e92
survey mobile
prd-duy-huynh 9df964e
refactor direction class
prd-duy-huynh e17e6a3
update btn mobile
prd-duy-huynh 173ecda
update reserved words
prd-duy-huynh e8f085c
refactor with early return
prd-duy-huynh d52a623
refactor progress bar
prd-duy-huynh 034eb57
add Generic components
prd-duy-huynh 9b84208
render score from api
prd-duy-huynh 23896f8
Merge branch 'master' into TD-2500-render-results
prd-duy-huynh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| 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"}); | ||
| if(!result) { return null; } | ||
|
|
||
| return ( | ||
| <div> | ||
| <div className={style.container}> | ||
| <div className={style.contentBody}> | ||
| <Score assessmentResult={result} /> | ||
| <Breakdown assessmentResult={result} /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| 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 longTextCondition = (option) => option.responseOptionText.length > 20; | ||
| const longTextResponses = question.responseOptions.some(longTextCondition); | ||
| const directionClass = (longTextResponses || question.setImage) ? style.flexDirectionColumn : ""; | ||
| const responsesClassName = (question.setImage) | ||
| ? [style.responsesWithImage, directionClass].join(" ") | ||
| : [style.responsesWithoutImage, directionClass].join(" "); | ||
|
|
||
| useEffect(() => { | ||
| setShowContent(showState); | ||
| }, [showState]); | ||
|
|
||
| const toggleContent = () => { | ||
| setShowContent(!showContent); | ||
| }; | ||
|
|
||
| const optionClassName = (option) => { | ||
| if(question.isCorrect) { | ||
prd-duy-huynh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return option.isCorrect ? style.correctResponse : ""; | ||
| } | ||
| if(option.isCorrect) { | ||
| return style.correctOption; | ||
| } | ||
| if(option.responseOptionId === question.selectedResponseOptionId) { | ||
| return style.incorrectResponse; | ||
| } | ||
| return ""; | ||
| }; | ||
|
|
||
| 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}> | ||
| {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 | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.