Fix for local variables error for boxplots and histograms 

Based on the conversation on the other pull request I changed the way that I made these updates. These changes were cherry picked off of my previous commit to the develop branch. These are bug fixes so should be in the hotfix branch. I made a branch off of the openwebwork/pg repo's release/2.8.1 and applied the changes. If this is accepted I will rebase my local repo and eliminate this new branch.