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 attendee survey to wordcamps. #997

Merged

Conversation

StevenDufresne
Copy link
Contributor

@StevenDufresne StevenDufresne commented Aug 4, 2023

Fixes #929

This PR is an attempt at implementing the user flow described in this comment.

How does this work programmatically?

  • When the plugin is activated:

    • Create a survey page in draft status
    • Create a tix_email in draft status
    • Add Admin page to central.wordpress.org
    • Schedule a daily cron job that looks if camp ended 2 days ago.
  • When the cron job runs:

    • Check if we already sent an email for this camp
    • Check to make sure the camp ended 2 days ago
    • Publish Survey page
    • Associate attendees to 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
    • Schedule single event to unpublish the Survey page 2 weeks later.

Screenshots

View Screenshot
Email queue Screenshot 2023-09-01 at 12 53 00 PM
Email Screenshot 2023-08-28 at 3 11 52 PM
Admin Screenshot 2023-08-11 at 1 03 13 PM
Survey Email Screenshot 2023-08-11 at 10 55 18 AM

How to test

  1. Create a Next-Gen Event WordCamp
    • Make the Start Date in the past
    • Make the End Date the current date (we'll update this later)
    • Create the site in the network
      • Create a ticket: wp-admin/edit.php?post_type=tix_ticket
        • Make sure you update the Ticket Options.
      • Setup Stripe for testing:
        • wp-admin/edit.php?post_type=tix_ticket&page=camptix_options&tix_section=payment
          • You can you these keys:
            • Test Secret: sk_test_4eC39HqLyjWDarjtT1zdp7dc
            • Test Publishable: pk_test_TYooMQauvdEDq54NiTphI7jx
      • Publish the "tickets" page
      • Purchase a ticket using this test stripe credit card
        • Visa | 4242424242424242 | Any 3 digits | Any future date
  2. Create a "traditional" WordCamp
    • Create it in the network
  3. Visit Next-Gen
    • Go to Pages
      • Expect to see Attendee Survey in `draft mode
      • Check out the content (if you don't have JetPack setup locally, you'll see and error when viewing the content, saying the JetPack form black is missing
    • Go to Ticket -> E-Mail
      • Expect to see an email in draft mode.
    • 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_attendee_survey_email
    • Go back to the Next-Gen Wordcamp Post type and update the End Date to 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_attendee_survey_email --url=https://events.wordpress.test/{city}/{year}/{type}
      • Should succeed
    • run wp cron event list --url=https://events.wordpress.test/{city}/{year}/{type}
      • Should see a new scheduled taskwc_attendee_disable_survey.
    • Visit Ticket -> E-Mail -> [[first_name], tell us what you thought: Post-event survey]
      • It should be set to pending (or published if it has been picked up (the job runs every 10 mins )
      • If you are running the docker environment you can check out mailcatcher
        • http://localhost:1080/
    • Visit the survey link on the front end an submit
    • run wp cron event run wc_attendee_disable_survey --url=https://events.wordpress.test/{city}/{year}/{type}
    • Revisit the link, the page should be unpublished.
    • Head over to https://central.wordcamp.test/ click on "Attendee Survey"
      • Verify the list is accurate
  4. Make sure none of this exists on the traditional WordCamp :)

@StevenDufresne StevenDufresne changed the title Add/attendee survey Add attendee survey to wordcamps. Aug 11, 2023
@StevenDufresne StevenDufresne requested a review from iandunn August 28, 2023 06:13
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.

Looks good so far 👍🏻

I didn't read most of the code yet, though, since you mentioned wanting to discuss some things before going further. I mostly just responded to the things in the PR description.

LMK if there's anything else you'd like me to review at this point.

$email .= "Thank you in advance, we really appreciate your time!\r\n\r\n";
$email .= "Best regards,\r\n";
$email .= "Organising Team,\r\n";
$email .= esc_html( $wordcamp_name );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm curious what is a better way to do this. It also isn't localized.

Copy link
Contributor

@renintw renintw Sep 6, 2023

Choose a reason for hiding this comment

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

Maybe something like below would work? (exclude shortcodes and HTML tags from the i18n functions)

$email  = "Hi [first_name] [last_name],\r\n\r\n";
$email .= sprintf( 
	/* translators: %s: wordcamp name. */
	__( "%s is over, thank you to everyone who joined us! \r\n\r\n", 'wordcamporg' ),
	esc_html( $wordcamp_name ) 
);
$email .= __( "As a community-led event, feedback is really important to us. It helps us improve our events and to keep providing high quality content.\r\n\r\n", 'wordcamporg' );
$email .= sprintf( __( 
	/* translators: Please leave %1$s and %2$s untranslated. They represent the opening and closing anchor tags, respectively. */
	'Please take a moment to answer our %1$spost-event survey%2$s and help us to do amazing WordPress events!\r\n', 'wordcamporg' ), 
	'<a href="' . esc_url( $survey_page_url ) . '">', '</a>' 
);
$email .= __( "(If you can't open the link, copy and paste the following URL)\r\n", 'wordcamporg' );
$email .= $survey_page_url . "\r\n\r\n";
$email .= sprintf( 
	/* translators: %s: closing date. */
	__( "Please complete the survey by %s.\r\n\r\n", 'wordcamporg' ),
	$closing_date );
$email .= __( "Please also note that all responses will be kept confidential, and we will not share your personal information with any third parties.\r\n\r\nThank you in advance, we really appreciate your time!\r\n\r\nBest regards,\r\nOrganising Team,\r\n", 'wordcamporg' );
$email .= esc_html( $wordcamp_name );

* @return bool
*/
function can_load() {
$skip_feature = wcorg_skip_feature( get_feature_id() );
Copy link
Member

@iandunn iandunn Sep 1, 2023

Choose a reason for hiding this comment

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

It may be good to open an issue in the milestone that reminds us to remove this after iterating, otherwise it'd be easy for it to get overlooked and no one ends up using the plugin.

Copy link
Contributor

@renintw renintw left a comment

Choose a reason for hiding this comment

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

Have gone through all the test cases I could think of, and everything appears to work as described 👍 Will delve deeper into the code.

Copy link
Contributor

@renintw renintw left a comment

Choose a reason for hiding this comment

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

LGTM 👍! Thanks for handling this issue, it's great.

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.

LGTM 👍🏻

*
* @return array
*/
function get_site_ids_without_skip_flag() {
Copy link
Member

Choose a reason for hiding this comment

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

Since we've needed this here and in the Speaker Feedback plugin, I think it makes sense to extract it into a generic function in mu-plugins/wp-cli-commands/miscellaneous.php, next to set_skip_feature_flag().

That way any plugin can use it, rather than duplicating it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also wondered about just removing it since we're limiting it to events and this survey will probably apply across the board.

I think I'll remove it. Yep.

Comment on lines 72 to 75
// TODO: This should be tested elsewhere.
if ( 'events.wordpress.test' !== $blog_details->domain ) {
continue;
}
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 this'll need to be updated to work on production.

You could use get_top_level_domain() in place of a hardcoded .test, but I think it'd be a bit more clear to check if $site->blog_id === EVENTS_NETWORK_ID.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. Makes sense.

@StevenDufresne StevenDufresne merged commit 1606461 into WordPress:production Sep 13, 2023
3 checks passed
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.

NextGen WP Event Attendee Satisfaction Survey
3 participants