-
Notifications
You must be signed in to change notification settings - Fork 479
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
Changes from 7 commits
230227c
4fb8dc9
d231ca4
f7369ce
549baec
f35273f
3ec3594
948b52f
e6c4526
3260af7
47b70ee
c547f58
fc904b1
9fae7d1
e7d313f
7374363
afc67e8
a48213f
49374e1
fd61e59
3899573
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,13 +20,34 @@ const alphabetMapper = [ | |
commonMsg.answerOptionG(), | ||
]; | ||
|
||
const calculateNotAnswered = (multipleChoiceDataArr) => { | ||
let total = 0; | ||
multipleChoiceDataArr.forEach (studentsAnswersObj => { | ||
if (studentsAnswersObj.percentAnswered) { | ||
total += studentsAnswersObj.percentAnswered; | ||
} | ||
}); | ||
|
||
return (100 - total); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. If students can select multiple answer options, I'm still concerned about There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I concur!! Tests will be covered in the next PR. |
||
}; | ||
|
||
const answerColumnsFormatter = (percentAnswered, {rowData, columnIndex, rowIndex, property}) => { | ||
const cell = rowData.answers[columnIndex - 1]; | ||
|
||
let percentValue = 0; | ||
|
||
if (property === 'notAnswered') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, Thanks |
||
percentValue = calculateNotAnswered(rowData.answers); | ||
} else { | ||
percentValue = (cell && cell.percentAnswered) || '-'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you set You have a few choices: 1.) Instead of "-" you could set Which option are you leaning toward? Other idea? If you want to chat through the pros/cons of each, let me know. |
||
} | ||
|
||
return ( | ||
<MultipleChoiceAnswerCell | ||
id={rowData.id} | ||
percentValue={(cell && `${cell.percentAnswered}%`) || '-'} | ||
percentValue={percentValue} | ||
isCorrectAnswer={cell && cell.isCorrectAnswer} | ||
|
||
/> | ||
); | ||
}; | ||
|
@@ -36,7 +57,6 @@ const questionAnswerDataPropType = PropTypes.shape({ | |
question: PropTypes.string, | ||
percentAnswered: PropTypes.string, | ||
isCorrectAnswer: PropTypes.bool, | ||
notAnswered: PropTypes.string, | ||
}); | ||
|
||
class MultipleChoiceOverviewTable extends Component { | ||
|
@@ -77,6 +97,7 @@ class MultipleChoiceOverviewTable extends Component { | |
props: {style: tableLayoutStyles.headerCell}, | ||
}, | ||
cell: { | ||
format: answerColumnsFormatter, | ||
props: {style: tableLayoutStyles.cell}, | ||
} | ||
} | ||
|
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