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 support to send email to cherry-picked students #33463

Closed

Conversation

mariajgrimaldi
Copy link
Member

@mariajgrimaldi mariajgrimaldi commented Oct 10, 2023

Description

This PR supports sending emails to a list of students submitted by the course instructor via the communications MFE:

Screencast.from.10-10-23.15.46.48.webm

This PR depends on the implementation in this communications MFE PR.

Design overview

The following happens when sending emails with the Bulk Email feature in the Instructor dashboard:

  • A request is made to instructor/api/send_email implemented by the send_email view
  • That view gets the necessary information to create the task in charge of sending the course email: send_to, subject and message
  • The course email, targets, and message are created with the information collected from the request.
  • If everything is correct, a new InstructorTaskTypes.BULK_COURSE_EMAIL task is executed, which under the hood calls for perform_delegate_email_batches task.

So, for this feature, we needed to:

  • Add support for the individual email target type so it's recognized: we added a new item to the choice list for the target types of the course emails.
  • Add support for the emails list to be passed down to the perform_delegate_email_batches: when emails are submitted in the MFE new field, the target individual-learners we created before is used. When using this target, the Course Email method to retrieve recipients returns a list of users filtered by the list of emails we sent before.

Supporting information

Open edX Platform roadmap issue, which this PR partially solves: openedx/platform-roadmap#254

Testing instructions

I use tutor stack and npm start for better MFE development, so I'll describe how I'm currently using it. You can use devstack if it's easier for you.

  1. Clone the MFE into your development environment
  2. Add the following configurations to the MFE:
# webpack.dev.config.js
const { createConfig } = require('@edx/frontend-build');
const { merge } = require('webpack-merge');

const config = createConfig('webpack-dev');

const webpack5esmInteropRule = {
  test: /\.m?js/,
  resolve: {
    fullySpecified: false,
  },
};

const otherRules = config.module.rules;

config.module.rules = [webpack5esmInteropRule, ...otherRules];

module.exports = merge(config, {
  // This configuration needs to be defined here, because CLI
  // arguments are ignored by the "npm run start" command
  devServer: {
    // We will have to make changes to thix config in later releases of webpack dev devServer
    // https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md
    allowedHosts: 'all',
  },
});
# .env.development
NODE_ENV='development'
PORT=1990
ACCESS_TOKEN_COOKIE_NAME='edx-jwt-cookie-header-payload'
BASE_URL='http://localhost:1984'
BASE_URL='http://apps.local.overhang.io:1990'
CREDENTIALS_BASE_URL='http://localhost:18150'
CSRF_TOKEN_API_PATH='/csrf/api/v1/token'
ECOMMERCE_BASE_URL='http://localhost:18130'
LANGUAGE_PREFERENCE_COOKIE_NAME='openedx-language-preference'
LMS_BASE_URL='http://localhost:18000'
LOGIN_URL='http://localhost:18000/login'
LOGOUT_URL='http://localhost:18000/logout'
LMS_BASE_URL='http://local.overhang.io:8000'
LOGIN_URL='http://local.overhang.io:8000/login'
LOGOUT_URL='http://local.overhang.io:8000/logout'
LOGO_URL=https://edx-cdn.org/v3/default/logo.svg
LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg
LOGO_WHITE_URL=https://edx-cdn.org/v3/default/logo-white.svg
FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico
MARKETING_SITE_BASE_URL='http://localhost:18000'
MARKETING_SITE_BASE_URL='http://local.overhang.io:8000'
ORDER_HISTORY_URL='http://localhost:1996/orders'
REFRESH_ACCESS_TOKEN_ENDPOINT='http://localhost:18000/login_refresh'
REFRESH_ACCESS_TOKEN_ENDPOINT='http://local.overhang.io:8000/login_refresh'
SEGMENT_KEY=''
SITE_NAME=localhost
USER_INFO_COOKIE_NAME='edx-user-info'
SCHEDULE_EMAIL_SECTION='true'
SESSION_COOKIE_DOMAIN='local.overhang.io'
USER_INFO_COOKIE_NAME='edx-user-info'
APP_ID=''
MFE_CONFIG_API_URL=''
  1. Be sure you're using npm 18.
  2. Now, run: npm i && npm run start
  3. Turn on your tutor environment.
  4. Create a new tutor plugin with the following:
from tutor import hooks

hooks.Filters.ENV_PATCHES.add_item(
    (
        "openedx-lms-development-settings",

        """
COMMUNICATIONS_MICROFRONTEND_URL = "http://{{MFE_HOST}}:1990"
CORS_ORIGIN_WHITELIST.append("http://{{ MFE_HOST }}:1990")
LOGIN_REDIRECT_WHITELIST.append("{{ MFE_HOST }}:1990")
CSRF_TRUSTED_ORIGINS.append("{{ MFE_HOST }}:1990")
"""
    )
)
  1. Turn on the bulk email flag globally:
    image

  2. Turn on the bulk email new experience: FEATURES['ENABLE_NEW_BULK_EMAIL_EXPERIENCE'] = True, you can add it too to your tutor plugin.

Deadline

"None" if there's no rush, or provide a specific date or event (and reason) if there is one.

Other information

More docs on bulk email: https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/named-release-birch/running_course/bulk_email.html

Aditional thoughts

As I mentioned, this PR needs to be reviewed alongside the PR in the MFE. Also, I wish there was a better way of including new targets to bulk emails without running database migrations, so we're open to suggestions for a more extensible solution.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 10, 2023
@openedx-webhooks
Copy link

openedx-webhooks commented Oct 10, 2023

Thanks for the pull request, @mariajgrimaldi! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@mariajgrimaldi mariajgrimaldi force-pushed the MJG/individual-students-emails branch from b6585be to 2614192 Compare October 10, 2023 20:42
@mariajgrimaldi mariajgrimaldi force-pushed the MJG/individual-students-emails branch from 2614192 to 8668276 Compare October 11, 2023 12:07
@mariajgrimaldi mariajgrimaldi marked this pull request as ready for review October 11, 2023 12:08
@mariajgrimaldi
Copy link
Member Author

I'll re-try running tests later since they're failing because of the runner: https://github.com/openedx/edx-platform/actions/runs/6482279061

@mphilbrick211
Copy link

Hi @mariajgrimaldi - just checking in on this :)

@mariajgrimaldi
Copy link
Member Author

I'll close this PR since we're not pursuing this implementation anymore.

@openedx-webhooks
Copy link

@mariajgrimaldi Even though your pull request wasn’t merged, please take a moment to answer a two question survey so we can improve your experience in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants