Closed Scott-James-Hurley closed 1 year ago
Another alternative solution is to version questionnaire changes.
There is already a solution which l think will work .
In the short term, we could look at migrating the old question data in to the new question field for the ISIS instruments - which has the highest impact.
Longer term, we should consider versioning and improved documentation.
For migrating the old question data for ISIS instruments I think we have 2 options run a DB script or do it through the graphql API. I think the DB script is going to be much simpler to write but we would have to run against the DB which could be riskier. The graphql API is going to be more "proper" but requires a more complex script as we will need to get the questionary answers to add the new answer and call the answer topic method for each of the affected proposals which I think is about ~800.
Happy to have a go at implementing either option.
Wrote up a SQL script here:
INSERT into answers (questionary_id, question_id, answer)
SELECT an.questionary_id, 'selection_from_options_1674830891328' as question_id, an.answer from
answers as an join questionaries as qu
on an.questionary_id = qu.questionary_id
where an.question_id in (
SELECT question_id from questions where natural_key in (
'instrument_small_angle_scattering',
'instrument_defraction',
'instrument_engineering',
'instrument_electronics_irradiation',
'instrument_reflectometry',
'instrument_liquid_defraction',
'instrument_excitations',
'instrument_vibrational_spectroscopy',
'instrument_imaging',
'instrument_muon',
'instrument_inelastic_scattering',
'instrument_quasi_elastic_scattering'
)
)
and template_id in (17, 30);
I think I have all the effected questions.
I'm happy with the database approach for this instance. Might want to try and find some way of adding a UI/endpoint to simplify data migration in the future, as I doubt this'll be the only time we need to do something like this.
Forgot to say - database approach seems fine to me to. The script also looks good as best I can tell too.
Cool going to go ahead with the database script and will do some more checks that my script works. Would we like the script in git anywhere maybe internal scripts
Scripts run successfully opened #832 #833 for template versioning
If a questionnaire is changed, the view screen of any proposal submitted using that questionnaire will also change. This means if a question is removed from a questionnaire, its answer will be not be visible when reviewing it. This prevents users from seeing all of a proposals information.
A potential solution could be the view screen of a proposal reflecting the questionnaire when the proposal was submitted, not the questionnaire as it currently is. Further discussion of what the solution should be and how it could be achieved should be had.
To reproduce:
Proposal with missing instrument information after its questionnaire was changed