NUBIC/surveyor — Issue #246: Surveyor does not preserve question order
Author: rsutphin
Created: 2011-11-08 18:29:30+00:00
State: open
Labels: parser

While surveyor's question model has a `display_order` attribute, the DSL interpreter does not appear to ensure that this attribute is set to reflect the actual order of the questions in the survey definition — `display_order` is always zero. This means that surveyor presents questions in the order they are retrieved from the database, which is arbitrary.

This behavior was observed under Rails 3.1.1.

A workaround for this issue is to override the question model and change the default scope ordering to consider the surrogate key:

```ruby
class Question < ActiveRecord::Base
include Surveyor::Models::QuestionMethods

default_scope :order => "display_order ASC, id ASC"

end
```

This will display in the questions in their insertion order, which is usually good enough. However, surveyor ought to explicitly preserve the ordering from the survey definition.