MDL-43338 quiz statistics : refactoring question statistics code

to improve readability and maintainability.