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
Assessments: Overview table - calculate not answered value #22156
Conversation
@balderdash Please review |
/> | ||
); | ||
}; | ||
const alphabetMapper = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if this was named something like "multipleChoiceAnswerOptions"? Might be more descriptive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! Thanks
{percentAnswered: 20, isCorrectAnswer: false}, | ||
{percentAnswered: 20, isCorrectAnswer: false}, | ||
{percentAnswered: 20, isCorrectAnswer: false}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I'm confused, but I'm a little concerned that we're relying on order to match percentAnswered to specific answer options (eg. "A"). What if we had something like {multipleChoiceOption: "A", percentAnswered: 40, isCorrectAnswer: true}
? Then all of the relevant data gets bundled together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want the translatable string, I think you could do:
{multipleChoiceOption: {i18n.answerOptionA()}, percentAnswered: 40, isCorrectAnswer: true}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Erin007 This is a valid point! After our in-person discussion, there is a tremendous payoff being able to identify which percentAnswered is associated with the answer choice. Additionally, debugging is easier. Thanks!
I changed the base on this PR to your original branch so that we only see the new changes :) |
We chatted about component organization offline and @nkiruka will update. |
if (property === 'notAnswered') { | ||
percentValue = calculateNotAnswered(rowData.answers); | ||
} else { | ||
percentValue = (cell && cell.percentAnswered) || '-'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you set percentValue
to "-" rather than to a number here, MultipleChoiceAnswerCell
will be confused because it's expecting that propType to be a number.
You have a few choices:
1.) Instead of "-" you could set percentValue
to 0, then have MultipleChoiceAnswerCell
just render "0%"
2.) Instead of "-" you could set percentValue
to 0. Then, you could introduce some logic in MultipleChoiceAnswerCell
if percentValue === 0 render "-"
3.) Adjust the propTypes in MultipleChoiceAnswerCell
to use oneOfType, explained here
Which option are you leaning toward? Other idea? If you want to chat through the pros/cons of each, let me know.
} | ||
}); | ||
|
||
return (100 - total); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked "Do we have any multiple choice questions where students can select multiple answers, like a "select all that apply..." ?" in Slack because, if that's the case, you could run into a situation where calculateNotAnswered
returns a negative number. For example, let's say there are only two answer choices: "A" and "B" and students are allowed to select: only "A", only "B", none, or "A" AND "B". If 100% of the students selected "A" AND "B", total
in this function is 200, and you'd return -100. Let's confirm the requirements with Poorva.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. Since this is an overview table of all the students' assessments, I do not think this will be an issue. For the individual student tables, this will be applicable (a good test :-) to check). Thoughts!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If students can select multiple answer options, I'm still concerned about calculateNotAnswered
for this overview table. For example we could have a scenario like:
In this case we would want the % not answered to be 25% because 1 out of 4 students did not answer the question; however the function as written would return 0%.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a great unit test case!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I concur!! Tests will be covered in the next PR.
@caleybrock @Erin007 Please see updated code for review |
<span>{`${percentValue}%`}</span> | ||
} | ||
{(percentValue < 0 ) && | ||
<span>{'-'}</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you said Poorva likes it without -
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Poorva also likes it with the dash and she is open to either option. I ran a mini survey with Maddie and Erin and the 'dash' option is preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
const NOT_ANSWERED = 'notAnswered'; | ||
|
||
const calculateNotAnswered = (multipleChoiceDataArr) => { | ||
let total = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indentation in this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, Thanks
|
||
let percentValue = 0; | ||
|
||
if (property === 'notAnswered') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use your constant here instead of this string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, Thanks
const maxAnswerChoicesLength = this.props.questionAnswerData.reduce((answersTotal, currentAnswerCount) => { | ||
return Math.max(answersTotal, currentAnswerCount.answers.length); | ||
}, 0); | ||
|
||
let dataColumns = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I totally understand the reason for the re-factoring in this function but I do have some suggestions to make it easier to read.
Your new code creates an empty dataColumns
, pushes one element to it, and then deconstructs it to add it to an array. Would it be simpler to just add this.getQuestionColumn(sortable)
to your array like this?
return [
this.getQuestionColumn(sortable),
...columnLabelNames,
this.getNotAnsweredColumn()},
];
I think it could make your final constructed array easier to read.
Note: you could make this.getNotAnsweredColumn()
return an object that already has the property NOT_ANSWERED
so you don't have to reconstruct it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it does make it easier to read. Fixed.
Please review. Next PR will contain the refactored code with the new data structures. Thanks. |
@caleybrock Please see updated changes. Thanks |
let dataColumns = []; | ||
|
||
dataColumns.push(this.getQuestionColumn(sortable)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dataColumns
is not longer used - so you can delete it.
@caleybrock Please review. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good given we address Erin's concerns in a follow up PR
This PR is to calculate the percent of students that did not answer a question and to display the value in the "not Answered column".
-In PR 22118, a dash is displayed in empty columns.
-The Not Answered column shows a teacher the percent of students that did not answer a question.
Implementation
Next Steps: