Aalto-LeTech/a-plus — pull request #108 by Rubinous (2013-04-29 12:44:56+00:00)
Title: Refactored exercise_summary.py

DO NOT MERGE YET!!!!

I want to open this pull request as I would like the review process to start as soon as possible as there is a lot to review. However, do not merge this yet because I haven't tested it thoroughly yet! The code and the comments should be quite polished though (except for the lurking bugs).

The idea here was to refactor all the classes in the exercise_summary.py as they were quite confusing. I think that one of the main issues that caused the confusion was the classes' mixed purpose and use. In my opinion the summary classes should only be used to summarise the submissions that a single user had made to the exercises of a course_instance, course_round, category or to a single exercise (see the names of the summary classes). But in addition to this, these classes were used as a helper structure for rendering the view_instance.html template in the course.views.view_instance.

So in this pull request, I have extracted the responsibility of being a helper structure for the view_instance.html from the summary classes and put that structure helper concept into the course.views.view_instance. That feature of the summary classes was not used in other places anyway, nor could I imagine it to be used anywhere else. However the summarising feature of the summary classes is used in other views too and thus should definitely stay in its own classes and file just like before.

In addition to extracting the spoken responsibility from the summary classes, I completely refactored exercise_summary.py, the view_instance and the view_instance.html.

The summary classes also had some methods that actually belonged to the corresponding model class so there are some small changes in the models too.

Happy reviewing guys!