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

Add organizer debrief survey #1038

Merged
merged 35 commits into from Sep 26, 2023
Merged

Add organizer debrief survey #1038

merged 35 commits into from Sep 26, 2023

Conversation

renintw
Copy link
Contributor

@renintw renintw commented Sep 13, 2023

Closes #930

This PR implements what has been concluded in the ticket. The logic refers to #997.

Flow

  • Manually published Organizer Survey (event debrief) in Central.

  • When the plugin is activated:

    • Create a tix_email in draft status.
      • The email will contain a token generated by hashing the access token key and WordCamp ID, to prevent the survey page from being accessed and abused by individuals other than the lead organizers.
    • Schedule a daily cron job.
  • When the cron job runs:

    • Check if we already sent an email for this camp.
    • Check to make sure the camp ended exactly 2 days ago.
    • Add the lead organizer as an attendee and associate it with tix_email.
    • Add tix_email to the queue (set to pending)
      • email gets picked up by camptix cron email sending queue tix_scheduled_every_ten_minutes

Screenshots

View Screenshot
Email queue image
Manually published Organizer Survey (event debrief) page in central image
Draft Survey Email image
Survey Email Sent image
Survey image

How to test

  1. Create a Next-Gen Event WordCamp site and fill in Organizer Name and Email Address inside the Organizing Team.
    • Make the Start Date in the past.
    • Make the End Date the current date.
  2. Visit Cenral
    • Go to Pages
      • Manually publish Organizer Survey (event debrief)
      • View the content, which should be the same as the description in ticket.
  3. Visit Next-Gen
    • Go to Ticket -> E-Mail
      • Expect to see an email Organizer Survey (event debrief) in Draft mode.
      • The email content is pending an update from the Tardis Team.
    • Run the following wp cli script to make sure the cron jobs are scheduled
      • wp cron event list --url=https://events.wordpress.test/{city}/{year}/{type}
      • expect to see the following cron job: wc_organizer_debrief_survey_email
    • Go back to the Next-Gen Wordcamp Post type and update the End Date to exact 2 days ago.
    • Run this script to set WordCamp to closed wp post update {post_id} --post_status=wcpt-closed --url=https://central.wordcamp.test/
    • Run the following cli command:
      • run wp cron event run wc_organizer_debrief_survey_email --url=https://events.wordpress.test/{city}/{year}/{type}
        • Should succeed
        • Status of Organizer Survey (event debrief) in Ticket -> E-Mail should be pending.
        • An attendee should be added in Ticket -> Attendees with tix_first_name and tix_email the same as the one you input when creating the event.
      • run wp cron event run tix_scheduled_every_ten_minutes -url=https://events.wordpress.test/{city}/{year}/{type}
        • Organizer Survey (event debrief) in Ticket -> E-Mail should be published.
        • In, http://localhost:1080/, there should be an email with Subject Organizer Survey (event debrief).
          • Visit the survey link on the front end and submit.
  4. Make sure none of this exists on the traditional WordCamp.

@renintw renintw self-assigned this Sep 13, 2023
@renintw renintw changed the title Add/organizer debrief survey Add organizer debrief survey Sep 13, 2023
@renintw renintw mentioned this pull request Sep 13, 2023
5 tasks
@renintw renintw force-pushed the add/organizer_debrief_survey branch 7 times, most recently from c4777f1 to 6d32335 Compare September 15, 2023 13:16
@renintw renintw marked this pull request as ready for review September 17, 2023 19:27
function add_temp_attendee() {
if ( ! get_wordcamp_attendees_id() ) {
$attendees_id = wp_insert_post( array(
'post_title' => 'Organizer debrief survey',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

image
image

The title is (no title) even though the post_title is specified and updated to DB. And after moving it to the Trash, the Title appears. I'm not entirely sure why this happens, but it doesn't affect the overall process.

Copy link
Member

@iandunn iandunn left a comment

Choose a reason for hiding this comment

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

I left a few suggestions but this looks good overall


<!-- wp:jetpack/contact-form {"subject":"New feedback received from your website","style":{"spacing":{"padding":{"top":"16px","right":"16px","bottom":"16px","left":"16px"}}}} -->
<div class="wp-block-jetpack-contact-form" style="padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px"><!-- wp:group {"layout":{"type":"constrained"}} -->
<div class="wp-block-group"><!-- wp:jetpack/field-text {"label":"What event did you organize?","required":true,"requiredText":"(required)"} /--></div>
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't need to ask this, since we already know it based on the current site, who the email is sent to, etc. We can remove the question, but have some code that automatically adds it to the response before it's saved in the database.

Copy link
Contributor Author

@renintw renintw Sep 21, 2023

Choose a reason for hiding this comment

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

It seems there's no proper filter or approach to add the predefined data before inserting the response to Feedback for Jetpack contact form. What's the common way to do so?

Also tried grunion_pre_message_sent and wp_insert_post_data, but I feel they aren't the best solution here.

Maybe using JavaScript to set the default values? I feel like there's a more elegant way to do so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Known data was added in ad40047

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I wish there were more filters there 😦

It seems like it might work to hook into template_redirect at priority 5, since process_form_submission() runs at priority 10. Then you might be able to modify $_POST directly.

<!-- /wp:heading -->

<!-- wp:group {"layout":{"type":"constrained"}} -->
<div class="wp-block-group"><!-- wp:jetpack/field-text {"label":"How many tickets were sold?","required":true,"requiredText":"(required)"} /--></div>
Copy link
Member

Choose a reason for hiding this comment

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

This can also be pulled from existing data. There may be other questions that can also be removed for that reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this PR, I've pre-populated the value for the question "What event did you organize?". The data sources for the other questions are different and might need to look for proper functions to retrieve the existing data. I'll handle that in a separate PR.

The Jetpack contact form fails to submit when there's a query string present.The Jetpack contact form's source code has been traced and no usable hooks found. Although the query string can be removed via JavaScript, the form still can't be submitted successfully. Therefore, it's temporarily disabled.
Copy link
Member

@iandunn iandunn left a comment

Choose a reason for hiding this comment

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

I left some questions/suggestions, but nothing that blocks merging 👍🏻

.docker/wp-config.php Outdated Show resolved Hide resolved
$labels = $dom->getElementsByTagName('label');
foreach ( $labels as $label ) {
// phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
if ( 'What event did you organize?' === $label->nodeValue ) {
Copy link
Member

Choose a reason for hiding this comment

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

🤔 I suspect there may an easier way to do this. Do we need to show the question to the user if we're just going to fill it in anyway?

Another problem is that, If it's in the page, it could be edited by an admin who wouldn't realize that doing that would break this.

If we don't need to show the question, we could insert the value in $_POST some time before Grunion_Contact_Form_Plugin::process_form_submission() runs.

If you do want to show it, it might be possible to add an id/class value to the post content in the database, and then use that in this function. That'd still break if someone edited it, but they'd be less likely to.

if ( 'What event did you organize?' === $label->nodeValue ) {
$input_id = $label->getAttribute('for');
$event_name_field = $dom->getElementById($input_id);
$event_name_field->setAttribute('value', $wordcamp_post_data->post_title);
Copy link
Member

Choose a reason for hiding this comment

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

I think it'd be best to save the ID rather than the title, since the title can change. It also won't have the year, unless passed through get_wordcamp_name(). That function might not work well for NextGen camps though, since some of them are monthly, etc.

If we don't remove the question from the user-facing form (see above), then it would be good to show the user the title, but we could still save the ID. Maybe just by modifying $_POST before the value gets saved. Or it could be in a separate field if that's easier.

@renintw renintw merged commit 0f1c5fe into production Sep 26, 2023
3 checks passed
@renintw renintw deleted the add/organizer_debrief_survey branch September 26, 2023 13:19
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.

New event debrief survey for organizers
3 participants