Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dynamic form generation #31

Merged
merged 2 commits into from
Jan 14, 2025
Merged

Conversation

twinkarma
Copy link
Contributor

@twinkarma twinkarma commented Nov 29, 2024

  • I've changed quite a lot so you will likely need to delete all the migrations and start again.
  • Change Questionnaire model to Survey, the survey is the page that only the manager can see and is used to configure the survey
    • The survey_config field stores the json configuration of the survey form
    • A project field needs to be added to indicate what project the survey belongs to
  • Add SurveyResponse model for accepting survey reponses
    • The answers field is for storing a response from a survey
  • Remove Question, Answer and Comment models as they are now handled by the dynamic form generation.
  • The SurveyView is very barebones at the moment, I'll help put together a nice js form editor once I'm back
    • Should only be viewable for a manager
    • Listing and creation of surveys should be done from the Projects page Project page #17
    • I've not added a delete survey functionality yet
    • Listing of responses still not added
  • The SurveyResponseView:
    • The pk variable in the url is the primary key of the Survey object rather than the SurveyResponse object! The SurveyResponse object does not exist until the user completes the questionnaire.
    • Viewable by anyone with a token (I've disabled tokens for now as I didn't have time to get invitations and token generation properly integrated)
    • Stores data in a session object as the user is completing each section of the form
    • A SurveyResponse object is only created at the end when all the sections of the questionnaire are finished
    • I've not styled any of the form components and just used django's default rendering
    • I've not implemented the likert form widget but it the configuration should be exactly the same as radio or checkbox
  • The invitation app has been merged into the survey app, I think it make sense to just put both of them together as invitation is exclusively called from the survey
  • See survey/misc/test_survey_config for an example survey configuration file, the format is not finalised yet but the final version should not be too different from what it is now.
  • Survey answer's root object represents a list of sections corresponding to the section in the survey_config, each section is an dictionary where the key is the field name and value is the response form the participant. eg:
    [ //<-- Section
      {"field_name": "field_value", ...}, {..}, ...
    ]
    

field_value can also be a list for multiple choice widgets such as checkboxes.

@twinkarma twinkarma force-pushed the feat/dynamic-survey-forms branch from b094af8 to dc53e6d Compare December 3, 2024 07:16
@twinkarma twinkarma marked this pull request as ready for review December 3, 2024 07:37
@twinkarma twinkarma requested a review from f-allian December 3, 2024 07:38
@twinkarma twinkarma force-pushed the feat/dynamic-survey-forms branch from dc53e6d to fff075d Compare December 3, 2024 08:08
Copy link
Member

@f-allian f-allian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@twinkarma LGTM - I committed a couple of small fixes before approving. Can you confirm if this is ready for merging please?

@twinkarma
Copy link
Contributor Author

Ok merging it in now then.

@twinkarma twinkarma merged commit 063fc41 into dev Jan 14, 2025
@twinkarma twinkarma deleted the feat/dynamic-survey-forms branch January 14, 2025 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants