Clone
Marcin Cieslak
committed
on 02 Feb 21
LDEV-5162 Fix Ordering answers saving to DB
To reflect an order that a learner put his answers, a TreeSet was used.
Its comparing function u… Show more
LDEV-5162 Fix Ordering answers saving to DB

To reflect an order that a learner put his answers, a TreeSet was used.

Its comparing function uses displayOrder.

It works fine when elements are put into the set during the first save,

i.e. the first autosave or a submit before the first autosave.

But when another save occurs (another autosave or a submit after the

first autosave), the set of answers is not recreated. Only displayOrder

of answers is modified. But TreeSet is not aware of it and keeps old

ordering. The iteration that happens during the save picks up answers in

the old order.

The fix uses real displayOrder value instead of counting on correct

order in TreeSet.

Another solution would be to rebuild the set after modifying answers'

displayOrder. Show less