Improve draft survey logic

Surveys that are started and published without saving as Draft first are marked as (draft) in the All Surveys list. Test: as a group admin, create a new survey. Add a text input question to the survey. Publish the survey (don't save, hit publish directly). Repeat the same, but this time hit "Save" then "Publish".

@manuel-ch: we have seen this some days ago. We could try to make sure that direct publish also writes a new version "2". Anyways, detecting draft state based on latestVersion=1 does not seem to be an ideal solution as later versions could also be empty. I suggest to step back to the requirements regarding the display of that state: what's the problem we want to solve with detecting a draft state? how is draft defined? how can we detect it? where should we use it?

@gbathree: There's a few options, but I'd propose this as best: simply always initiate two actions (Save and Publish) when user hits Publish. You can test this - it solves the problem when starting a new survey. It addresses the issue by creating a saved draft first (creating version 1) and then the published draft (creating version 2). On any future Save/Publish beyond version 2, it has no effect (ie if it's version 3 and you hit Save then Publish, it goes to version 4. If you just hit Publish, it also goes to version 4 -- so it's the same). It only impacts the first first event. Actually, I think this is kind of a bug that we've never noticed before :) because publish should be doing that anyway.

Recommendation

  • Always initiate two actions (Save and Publish) when user hits Publish.
    • I understand that we have additional questions about visibility state as Manuel pointed out (Serena has also identified this). However, that's a broader conversation about visibility, state, etc that is beyond the scope of this issue. If we simply initiate two actions every time, the current bug is solved and we can pick up the visibility and state questions later.
    • @desousab are there downsides to this, or am I oversimplifying? My hope is to knock out this bug quickly with minimal side effects - if I'm off please let me know.
Edited by Benoît DE SOUSA