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

Summer Workshop Pre Survey #33278

Merged
merged 15 commits into from Feb 26, 2020
Merged

Summer Workshop Pre Survey #33278

merged 15 commits into from Feb 26, 2020

Conversation

molly-moen
Copy link
Contributor

@molly-moen molly-moen commented Feb 24, 2020

Foorm work building on 33182, which adds some generic functionality as well as new foorm survey for the local summer workshop pre-survey ('day 0' survey)

New generic functionality:

  • Building on 33297, adds a new model workshop_survey_foorm_submission. This holds metadata for (ideally) all workshop surveys. Metadata included in the table is:
    • foorm_submission_id
    • user_id
    • pd_workshop_id
    • pd_session_id (optional)
    • day (optional)
  • Add api controller WorkshopSurveyFoormSubmissionsController which can be used by Foorm.jsx to write foorm results to submissions and workshop_submissions tables.
  • Add new view new_general_foorm which directs to Foorm.jsx
  • Update Foorm.jsx to take in some new props:
    • submitApi (required): api path to send submission data to
    • surveyData (optional): data to send over to survey (ex. parameters for survey such as course name)
    • submitParams (optional): data to send along to submitApi to contextualize form submission

Local Summer Workshop functionality:

  • Add initial version of local summer workshop pre-survey (based on questions in jotform). This survey is accessible at /pd/workshop_survey/foorm/day/0 (any other day parameter will show a 404 since we don't have a new survey for those days yet).
    • this is aligned with current jotform but will most likely be need updates based on feedback from stakeholders

@molly-moen molly-moen changed the base branch from forrm-initial to staging February 25, 2020 20:04
@molly-moen molly-moen requested a review from a team February 25, 2020 20:06
if form_name
# if any submission has the given form name return true, otherwise return false
submissions.each {|submission| return true if submission.foorm_submission.form_name == form_name}
return false
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Unless there's eager loading going on, I think .foorm_submission is a query in a loop here.

I think you could modify your search before it runs and achieve a similar effect with one query. Something like (and apologies, not sure I've got this right):

    submissions = Pd::WorkshopSurveyFoormSubmission.where(
      user_id: user_id,
      pd_workshop_id: pd_workshop_id,
      pd_session_id: pd_session_id,
      day: day
    )
    
    if form_name
      submissions = submissions.join(:foorm_submission).where(foorm_submission: {form_name: form_name})
    end

    submissions.exists?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, not sure if things still feel too prototype-y to you, but this business logic is a great candidate for a unit test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed! your syntax was very close, only difference is .where(foorm_submissions...)
Will do tests in follow-up PR

Copy link
Member

@breville breville left a comment

Choose a reason for hiding this comment

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

Love the factoring on this. What an impactful change!

@molly-moen molly-moen merged commit 07fb23f into staging Feb 26, 2020
@molly-moen molly-moen mentioned this pull request Feb 27, 2020
7 tasks
@molly-moen molly-moen deleted the molly/local_workshop_pre_survey branch March 26, 2020 16:12
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.

None yet

3 participants