premierlangage
premierlangage copied to clipboard
[ENHANCEMENT] grade extraction strategy
I am not an expert on database request optimization but the current state is already not acceptable (at least hugely terribly ugly!!!).
It seems to me (I do not know enough about Django and SQL interactions...) that the current strategy to extract all grades is the following one :
Get a grade state for a single student on a single pl (highest grade of all logs) All Answers --> filtering(by pl, by user) --> selecting or order --> fetch [0] or extract top
So to generate all grade on a course, this become
for student in collection :
for subactivities in activity :
pl_state(user = student, pl = subactivities)
# JUST HORRIBLE because filtering is re-applied each loop from ALL ANSWERS
For AP1, this is already two much (extract grades or teacher dashboard = more than 30 sec...) ! We need some filtering support functions and we need some extraction functions working on subset of data (refilter from all is BEURKKKKK @#^@!#%^$@*%....). A good strategy could be the following one
for subactivities in activity :
sub_list_of_answer = Answer.filter(pl = subactivities)
for student in collection :
sub_list_of_answer_student = sub_list_of_answer.filter(user = student)
pl_state(user = student, pl = subactivities, subtrace = sub_list_of_answer_student)
Perhaps, it is enough to modify methods pl_state
and highest_grade
inside class Answer
of app Playexo
by adding an optional argument from_subset_of_answer = None. I am pretty sure that if filtering are applied only once in good order, all grades will be generated in instant time even for AP1...
Sorry, all this is probably not very clear... It really needs to be fixed rapidly...
Some of the data should computed on the fly. In the activity we can keep the current grade of the student (for each exercice), this would lead to a view of the current state of the student accomplishement in the course an could be used by the teacher to look how a student is doing.
A liste of "interesting values" should be created in this issue to be computed on the fly and kept in the activity json field.
- Current mean/evaluation on each sub-activity (recursively in each sub activity)
- Current time used in the activity (current session time, plus cumulative time), if the computation is not adequate we will change it in the futur. This information should go in the top "menu" when there is room.
i agree with Nicolas the size of the data base is allready important and it will grow !!! in the near futur so two strategies:
- for frequently used information : on the fly computation stored in the userXactitivity space.
- for less frequently used, but time consuming : indexes of course no "inefficient" algorithms please.
I'll close #323 as it is the same issue, I'll work on this for the 0.7.4