-
Notifications
You must be signed in to change notification settings - Fork 706
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
Prevent access to undefined AttemptLogs while looking at reports #12723
Prevent access to undefined AttemptLogs while looking at reports #12723
Conversation
…n options are computed
Build Artifacts
|
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.
A couple of questions - have not manually tested.
@pcenov @radinamatic this is a PR for planned patch 2 - if we can get manual QA before I tag the release beta, that would be great. |
@@ -63,7 +63,7 @@ | |||
v-for="(section, index) in sections" | |||
:id="`section-questions-${index}`" | |||
:key="`section-questions-${index}`" | |||
:title="displaySectionTitle(section, index) || ''" | |||
:title="displaySectionTitle(section, index) || sectionLabel$({ sectionNumber: index + 1 })" |
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.
Hrm, is this happening when section.title is undefined rather than being an empty string? Perhaps we could just tweak the implementation here:
return section.section_title === '' |
section
is defined, section.title
is defined, and section.title is not empty
?
So could maybe update it to:
export function displaySectionTitle(section, index) {
return section?.section_title
? sectionLabel$({ sectionNumber: index + 1 })
: section.section_title;
}
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.
Yes, this was happening because displaySectionTitle()
is checking for section.section_title
, but it seems that Attemptlogs for practice exercises have section.title
instead. I did try this way, but had some issues with it not working when checking the attempt logs for exams.
export function displaySectionTitle(section, index) {
const title = section.section_title || section.title;
return title === ' '
? sectionLabel$({ sectionNumber: index + 1 })
: title;
}
I could instead try
const title = section.section_title ? section.section_title : section.title;
Edit: I get this console error with this way as well: Invalid prop: type check failed for prop "title". Expected String, got Undefined
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.
Hrm... I suspect that the discrepancy between section_title and title is the root issue here. So, maybe we should trace back where that is coming from and just rectify that instead?
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.e. it should always be section_title
for the title for a section, and not title
.
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.
Hmm, I may have found where it's coming from. Possibly this annotateSections() util 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.
That looks rather like a bug, and one that I caused, looking at the git blame, so I'd be most obliged if you could fix it!
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.
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.
Thank you!
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.
All code review based questions resolved - manual QA sign off should leave this good to merge!
Thanks @LianaHarris360 - I confirm that the console errors are no longer displayed and there are no regressions! |
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.
QA approved - good to go!
Merging with failing check that is fixed on release-v0.17.x |
068f25b
into
learningequality:release-v0.17.x
Summary
This pull request fixes the console errors that would appear when viewing learner exercise attempts. The errors occurred because
AttemptLogItem
was being rendered with an undefinedattemptLog
prop and caused runtime errors when it tried to access properties ofattemptLog
. This pull request also addresses an issue where, on mobile screens, theKSelect
options included selections that did not have associatedattemptLogs
but could still be selected.AttemptLogItem
component only whenattemptLog
is defined.attemptLogsForCurrentSection
has been added for the attempt logs of the current section.selectedAttemptLog
to be displayed as the currentKSelect
item on mobile displays.questionSelectOptions
computed property to filter out any questions that don't have an associatedattemptLog
.Console Errors fixed:
Before:
Before.mov
After:
After.mov
References
Fixes #12550
Reviewer guidance
nakav-mafak
) and assign it to a learner.Testing checklist
PR process
Reviewer checklist
yarn
andpip
)