hmpf / easydmp

MIT License
7 stars 2 forks source link

Changing field type is not possible if there are answers #207

Open frafra opened 3 years ago

frafra commented 3 years ago

I cannot switch field type if there are answers linked to the current question. The platform would just confirm that I saved, but the field type would not change. I think it would be better to stop the save action entirely if it is not possible to apply some changes.

hmpf commented 3 years ago

What you're seeing is an unintended feature, not a bug. Though I expect what you really want is that when field type is changed, any test-plan using that template has its answers deleted. There's the issue #107 for fixing plans when a question is removed, this sounds like a variant of that.

(To be technical, there are the actual answers in Plan.data and the support table Answer. If the latter exists that should not affect this, if so we have a bug/thinko.)

Once upon a time, templates didn't have the "published"-state. This state has two purposes (they will be split in a future update):

  1. Select the templates to be publicly available. It used to be that anyone logged inn could make a plan using any available template even before they were finished, which means that changing the template (by changing field types) would ruin the plan (it would no longer be valid and contain garbage data).
  2. Highlight which templates should no longer be changed.

The plan is to split this into two states, one for visbility and one to enforce that a template may no longer be changed. Until then...

A workaround is to create a new question, until we can get around to upping the smarts a little. (Superusers can get at the actual raw answers of any plan and delete/update them directly.) You could also try deleting a plan using that template.

You are the first person to seriously use the non-superuser "Template Designer" functionality, so it is to be expected that you run into unforeseen problems and edge cases.

hmpf commented 3 years ago

To do:

  1. Test to see what currently happens when changing a field type.
  2. Solve #107
  3. Delete answers (or at least answer choice structure) from plans if the field type changes.
frafra commented 3 years ago

The proposed workaround (define a new question and delete the previous one) works.

I think that it would be better to return an error and suggest deleting the related answers first, as deleting them without confirmation could be a bit excessive.

hmpf commented 2 years ago

I have solved #107 now (validating a plan will remove "dead" answers to questions that no longer exist) so I'm thinking of automatically deleting such answers on any template save.

Which still doesn't fix the field type change issue but does give me ideas as to how to fix it.