Example #1
0
def get_celebrations_dict(user, enrollment, course, browser_timezone):
    """
    Returns a dict of celebrations that should be performed.
    """
    if not enrollment:
        return {
            'first_section': False,
            'streak_length_to_celebrate': None,
            'streak_discount_enabled': False,
            'weekly_goal': False,
        }

    streak_length_to_celebrate = UserCelebration.perform_streak_updates(
        user, course.id, browser_timezone
    )
    celebrations = {
        'first_section': CourseEnrollmentCelebration.should_celebrate_first_section(enrollment),
        'streak_length_to_celebrate': streak_length_to_celebrate,
        'streak_discount_enabled': False,
        'weekly_goal': CourseEnrollmentCelebration.should_celebrate_weekly_goal(enrollment),
    }

    if streak_length_to_celebrate:
        # We only want to offer the streak discount
        # if the course has not ended, is upgradeable and the user is not an enterprise learner

        if can_show_streak_discount_coupon(user, course):
            # Send course streak coupon event
            course_key = str(course.id)
            modes_dict = CourseMode.modes_for_course_dict(course_id=course_key, include_expired=False)
            verified_mode = modes_dict.get('verified', None)
            if verified_mode:
                celebrations['streak_discount_enabled'] = True

    return celebrations
Example #2
0
def get_celebrations_dict(user, enrollment, course, browser_timezone):
    """
    Returns a dict of celebrations that should be performed.
    """
    if not enrollment:
        return {
            'first_section': False,
            'streak_length_to_celebrate': None,
            'streak_discount_experiment_enabled': False,
        }

    streak_length_to_celebrate = UserCelebration.perform_streak_updates(
        user, course.id, browser_timezone)
    celebrations = {
        'first_section':
        CourseEnrollmentCelebration.should_celebrate_first_section(enrollment),
        'streak_length_to_celebrate':
        streak_length_to_celebrate,
        'streak_discount_experiment_enabled':
        False,
    }

    # We only want to bucket people into the AA-759 experiment if they are going to see the streak celebration
    if streak_length_to_celebrate:
        # We only want to bucket people into the AA-759 experiment
        # if the course has not ended, is upgradeable and the user is not an enterprise learner
        if can_show_streak_discount_experiment_coupon(user, course):
            celebrations[
                'streak_discount_experiment_enabled'] = STREAK_DISCOUNT_EXPERIMENT_FLAG.is_enabled(
                )
    return celebrations
Example #3
0
 def celebrations(self):
     """
     Returns a list of celebrations that should be performed.
     """
     return {
         'first_section': CourseEnrollmentCelebration.should_celebrate_first_section(self.enrollment_object),
     }
Example #4
0
 def celebrations(self):
     """
     Returns a list of celebrations that should be performed.
     """
     browser_timezone = self.request.query_params.get('browser_timezone', None)
     return {
         'first_section': CourseEnrollmentCelebration.should_celebrate_first_section(self.enrollment_object),
         'streak_length_to_celebrate': UserCelebration.perform_streak_updates(
             self.effective_user, self.course_key, browser_timezone
         ),
     }