def _register_course_home_messages(request, course, user_access, course_start_data): """ Register messages to be shown in the course home content page. """ if user_access['is_anonymous']: CourseHomeMessages.register_info_message( request, Text(_( '{sign_in_link} or {register_link} and then enroll in this course.' )).format( sign_in_link=HTML('<a href="/login?next={current_url}">{sign_in_label}</a>').format( sign_in_label=_('Sign in'), current_url=urlquote_plus(request.path), ), register_link=HTML('<a href="/register?next={current_url}">{register_label}</a>').format( register_label=_('register'), current_url=urlquote_plus(request.path), ) ), title=Text(_('You must be enrolled in the course to see course content.')) ) if not user_access['is_anonymous'] and not user_access['is_staff'] and not user_access['is_enrolled']: CourseHomeMessages.register_info_message( request, Text(_( '{open_enroll_link}Enrol now{close_enroll_link} to access the full course.' )).format( open_enroll_link=HTML('<button class="enroll-btn btn-link">'), close_enroll_link=HTML('</button>') ), title=Text(_('Welcome to {course_display_name}')).format( course_display_name=course.display_name ) )
def register_alerts(self, request, course): """ Registers an alert close to the certificate delivery date. """ is_enrolled = CourseEnrollment.get_enrollment(request.user, course.id) if not is_enrolled or not self.is_enabled or course.end > self.current_time: return if self.date > self.current_time: CourseHomeMessages.register_info_message( request, Text( _(u'If you have earned a certificate, you will be able to access it {time_remaining_string}' u' from now. You will also be able to view your certificates on your {learner_profile_link}.' ) ).format( time_remaining_string=self.time_remaining_string, learner_profile_link=HTML( u'<a href="{learner_profile_url}">{learner_profile_name}</a>' ).format( learner_profile_url=reverse( 'learner_profile', kwargs={'username': request.user.username}), learner_profile_name=_('Learner Profile'), ), ), title=Text( _('We are working on generating course certificates.')))
def register_alerts(self, request, course): """ Registers an alert if the end date is approaching. """ is_enrolled = CourseEnrollment.get_enrollment(request.user, course.id) if not course.start or self.current_time < course.start or not is_enrolled: return days_until_end = (course.end - self.current_time).days if course.end > self.current_time and days_until_end <= settings.COURSE_MESSAGE_ALERT_DURATION_IN_DAYS: if days_until_end > 0: CourseHomeMessages.register_info_message( request, Text(self.description), title=Text(_('This course is ending in {time_remaining_string} on {course_end_date}.')).format( time_remaining_string=self.time_remaining_string, course_end_date=self.long_date_html, ) ) else: CourseHomeMessages.register_info_message( request, Text(self.description), title=Text(_('This course is ending in {time_remaining_string} at {course_end_time}.')).format( time_remaining_string=self.time_remaining_string, course_end_time=self.short_time_html, ) )
def register_alerts(self, request, course): """ Registers an alert if the verification deadline is approaching. """ upgrade_price = get_cosmetic_verified_display_price(course) if not UPGRADE_DEADLINE_MESSAGE.is_enabled(course.id) or not self.is_enabled or not upgrade_price: return days_left_to_upgrade = (self.date - self.current_time).days if self.date > self.current_time and days_left_to_upgrade <= settings.COURSE_MESSAGE_ALERT_DURATION_IN_DAYS: CourseHomeMessages.register_info_message( request, Text(_( 'In order to qualify for a certificate, you must meet all course grading ' 'requirements, upgrade before the course deadline, and successfully verify ' 'your identity on {platform_name} if you have not done so already.{button_panel}' )).format( platform_name=settings.PLATFORM_NAME, button_panel=HTML( '<div class="message-actions">' '<a class="btn btn-upgrade"' 'data-creative="original_message" data-position="course_message"' 'href="{upgrade_url}">{upgrade_label}</a>' '</div>' ).format( upgrade_url=self.link, upgrade_label=Text(_('Upgrade ({upgrade_price})')).format(upgrade_price=upgrade_price), ) ), title=Text(_( "Don't forget, you have {time_remaining_string} left to upgrade to a Verified Certificate." )).format( time_remaining_string=self.time_remaining_string, ) )
def register_alerts(self, request, course): """ Registers an alert if the course has not started yet. """ is_enrolled = CourseEnrollment.get_enrollment(request.user, course.id) if not course.start or not is_enrolled: return days_until_start = (course.start - self.current_time).days if course.start > self.current_time: if days_until_start > 0: CourseHomeMessages.register_info_message( request, Text(_( "Don't forget to add a calendar reminder!" )), title=Text(_("Course starts in {time_remaining_string} on {course_start_date}.")).format( time_remaining_string=self.time_remaining_string, course_start_date=self.long_date_html, ) ) else: CourseHomeMessages.register_info_message( request, Text(_("Course starts in {time_remaining_string} at {course_start_time}.")).format( time_remaining_string=self.time_remaining_string, course_start_time=self.short_time_html, ) )
def register_alerts(self, request, course): """ Registers an alert if the end date is approaching. """ is_enrolled = CourseEnrollment.get_enrollment(request.user, course.id) if not course.start or self.current_time < course.start or not is_enrolled: return days_until_end = (course.end - self.current_time).days if course.end > self.current_time and days_until_end <= settings.COURSE_MESSAGE_ALERT_DURATION_IN_DAYS: if days_until_end > 0: CourseHomeMessages.register_info_message( request, Text(self.description), title=Text( _(u'This course is ending in {time_remaining_string} on {course_end_date}.' )).format( time_remaining_string=self.time_remaining_string, course_end_date=self.long_date_html, )) else: CourseHomeMessages.register_info_message( request, Text(self.description), title=Text( _(u'This course is ending in {time_remaining_string} at {course_end_time}.' )).format( time_remaining_string=self.time_remaining_string, course_end_time=self.short_time_html, ))
def register_alerts(self, request, course): """ Registers an alert if the verification deadline is approaching. """ upgrade_price = get_cosmetic_verified_display_price(course) if not UPGRADE_DEADLINE_MESSAGE.is_enabled( course.id) or not self.is_enabled or not upgrade_price: return days_left_to_upgrade = (self.date - self.current_time).days if self.date > self.current_time and days_left_to_upgrade <= settings.COURSE_MESSAGE_ALERT_DURATION_IN_DAYS: CourseHomeMessages.register_info_message( request, Text( _('In order to qualify for a certificate, you must meet all course grading ' 'requirements, upgrade before the course deadline, and successfully verify ' 'your identity on {platform_name} if you have not done so already.{button_panel}' ) ).format( platform_name=settings.PLATFORM_NAME, button_panel=HTML( '<div class="message-actions">' '<a class="btn btn-upgrade"' 'data-creative="original_message" data-position="course_message"' 'href="{upgrade_url}">{upgrade_label}</a>' '</div>').format( upgrade_url=self.link, upgrade_label=Text( _('Upgrade ({upgrade_price})')).format( upgrade_price=upgrade_price), )), title=Text( _("Don't forget, you have {time_remaining_string} left to upgrade to a Verified Certificate." )).format( time_remaining_string=self.time_remaining_string, ))
def _register_course_home_messages(request, course, user_access, course_start_data): """ Register messages to be shown in the course home content page. """ if user_access['is_anonymous']: CourseHomeMessages.register_info_message( request, Text(_( '{sign_in_link} or {register_link} and then enroll in this course.' )).format( sign_in_link=HTML('<a href="/login?next={current_url}">{sign_in_label}</a>').format( sign_in_label=_('Sign in'), current_url=urlquote_plus(request.path), ), register_link=HTML('<a href="/register?next={current_url}">{register_label}</a>').format( register_label=_('register'), current_url=urlquote_plus(request.path), ) ), title=Text(_('You must be enrolled in the course to see course content.')) ) if not user_access['is_anonymous'] and not user_access['is_staff'] and not user_access['is_enrolled']: CourseHomeMessages.register_info_message( request, Text(_( '{open_enroll_link}Enroll now{close_enroll_link} to access the full course.' )).format( open_enroll_link='', close_enroll_link='' ), title=Text(_('Welcome to {course_display_name}')).format( course_display_name=course.display_name ) )
def register_alerts(self, request, course): """ Registers an alert if the course has not started yet. """ is_enrolled = CourseEnrollment.get_enrollment(request.user, course.id) if not course.start or not is_enrolled: return days_until_start = (course.start - self.current_time).days if course.start > self.current_time: if days_until_start > 0: CourseHomeMessages.register_info_message( request, Text(_("Don't forget to add a calendar reminder!")), title=Text( _(u"Course starts in {time_remaining_string} on {course_start_date}." )).format( time_remaining_string=self.time_remaining_string, course_start_date=self.long_date_html, )) else: CourseHomeMessages.register_info_message( request, Text( _(u"Course starts in {time_remaining_string} at {course_start_time}." )).format( time_remaining_string=self.time_remaining_string, course_start_time=self.short_time_html, ))
def _register_course_goal_message(request, course): """ Register a message to let a learner specify a course goal. """ course_goal_options = get_course_goal_options() goal_choices_html = Text( _('To start, set a course goal by selecting the option below that best describes ' 'your learning plan. {goal_options_container}')).format( goal_options_container=HTML( '<div class="row goal-options-container">')) # Add the dismissible option for users that are unsure of their goal goal_choices_html += Text('{initial_tag}{choice}{closing_tag}').format( initial_tag=HTML( '<div tabindex="0" aria-label="{aria_label_choice}" class="goal-option dismissible" ' 'data-choice="{goal_key}">').format( goal_key=GOAL_KEY_CHOICES.unsure, aria_label_choice=Text(_("Set goal to: {choice}")).format( choice=course_goal_options[GOAL_KEY_CHOICES.unsure], ), ), choice=Text(_('{choice}')).format( choice=course_goal_options[GOAL_KEY_CHOICES.unsure], ), closing_tag=HTML('</div>'), ) # Add the option to set a goal to earn a certificate, # complete the course or explore the course course_goal_keys = course_goal_options.keys() course_goal_keys.remove(GOAL_KEY_CHOICES.unsure) for goal_key in course_goal_keys: goal_text = course_goal_options[goal_key] goal_choices_html += HTML( '{initial_tag}{goal_text}{closing_tag}' ).format(initial_tag=HTML( '<button tabindex="0" aria-label="{aria_label_choice}" class="goal-option {col_sel} btn" ' 'data-choice="{goal_key}">').format( goal_key=goal_key, aria_label_choice=Text(_("Set goal to: {goal_text}")).format( goal_text=Text(_(goal_text))), col_sel='col-' + str(int(math.floor(12 / len(course_goal_keys))))), goal_text=goal_text, closing_tag=HTML('</button>')) CourseHomeMessages.register_info_message( request, HTML('{goal_choices_html}{closing_tag}').format( goal_choices_html=goal_choices_html, closing_tag=HTML('</div>')), title=Text(_('Welcome to {course_display_name}')).format( course_display_name=course.display_name))
def _register_course_home_messages(request, course, user_access, course_start_data): """ Register messages to be shown in the course home content page. """ allow_anonymous = allow_public_access(course, [COURSE_VISIBILITY_PUBLIC]) if user_access['is_anonymous'] and not allow_anonymous: CourseHomeMessages.register_info_message( request, Text( _(u'{sign_in_link} or {register_link} and then enroll in this course.' ) ).format( sign_in_link=HTML( u'<a href="/login?next={current_url}">{sign_in_label}</a>' ).format( sign_in_label=_('Sign in'), current_url=urlquote_plus(request.path), ), register_link=HTML( u'<a href="/register?next={current_url}">{register_label}</a>' ).format( register_label=_('register'), current_url=urlquote_plus(request.path), )), title=Text( _('You must be enrolled in the course to see course content.') )) if not user_access['is_anonymous'] and not user_access['is_staff'] and \ not user_access['is_enrolled']: title = Text(_(u'Welcome to {course_display_name}')).format( course_display_name=course.display_name) if CourseMode.is_masters_only(course.id): # if a course is a Master's only course, we will not offer user ability to self-enroll CourseHomeMessages.register_info_message( request, Text( _('You must be enrolled in the course to see course content. ' 'Please contact your degree administrator or edX Support if you have questions.' )), title=title) elif not course.invitation_only: CourseHomeMessages.register_info_message( request, Text( _(u'{open_enroll_link}Enroll now{close_enroll_link} to access the full course.' )).format(open_enroll_link=HTML( '<button class="enroll-btn btn-link">'), close_enroll_link=HTML('</button>')), title=title) else: CourseHomeMessages.register_info_message( request, Text( _('You must be enrolled in the course to see course content.' )), )
def _register_course_goal_message(request, course): """ Register a message to let a learner specify a course goal. """ course_goal_options = get_course_goal_options() goal_choices_html = Text( _('To start, set a course goal by selecting the option below that best describes ' 'your learning plan. {goal_options_container}')).format( goal_options_container=HTML( '<div class="row goal-options-container">')) # Add the dismissible option for users that are unsure of their goal goal_choices_html += Text('{initial_tag}{choice}{closing_tag}').format( initial_tag=HTML( '<div tabindex="0" aria-label="{aria_label_choice}" class="goal-option dismissible" ' 'data-choice="{goal_key}">').format( goal_key=GOAL_KEY_CHOICES.unsure, aria_label_choice=Text(_("Set goal to: {choice}")).format( choice=course_goal_options[GOAL_KEY_CHOICES.unsure], ), ), choice=Text(_('{choice}')).format( choice=course_goal_options[GOAL_KEY_CHOICES.unsure], ), closing_tag=HTML('</div>'), ) # Add the option to set a goal to earn a certificate, # complete the course or explore the course course_goals_by_commitment_level = valid_course_goals_ordered() for goal in course_goals_by_commitment_level: goal_key, goal_text = goal goal_choices_html += HTML( '{initial_tag}{goal_text}{closing_tag}' ).format( initial_tag=HTML( '<button tabindex="0" aria-label="{aria_label_choice}" class="goal-option btn-outline-primary" ' 'data-choice="{goal_key}">').format( goal_key=goal_key, aria_label_choice=Text( _("Set goal to: {goal_text}")).format( goal_text=Text(_(goal_text)) # lint-amnesty, pylint: disable=translation-of-non-string )), goal_text=goal_text, closing_tag=HTML('</button>')) CourseHomeMessages.register_info_message( request, HTML('{goal_choices_html}{closing_tag}').format( goal_choices_html=goal_choices_html, closing_tag=HTML('</div>')), title=Text(_('Welcome to {course_display_name}')).format( course_display_name=course.display_name))
def register_alerts(self, request, course): """ Registers an alert close to the certificate delivery date. """ is_enrolled = CourseEnrollment.get_enrollment(request.user, course.id) if not is_enrolled or not self.is_enabled or course.end > self.current_time: return if self.date > self.current_time: CourseHomeMessages.register_info_message( request, Text( ' ' ), # Edraak: Details of alert message has been deleted. Also see test_date_summary.py title=Text( _('We are working on generating course certificates.')))
def _register_course_home_messages(request, course, user_access, course_start_data): """ Register messages to be shown in the course home content page. """ allow_anonymous = allow_public_access(course, [COURSE_VISIBILITY_PUBLIC]) if user_access['is_anonymous'] and not allow_anonymous: sign_in_or_register_text = (_(u'{sign_in_link} or {register_link} and then enroll in this course.') if not CourseMode.is_masters_only(course.id) else _(u'{sign_in_link} or {register_link}.')) CourseHomeMessages.register_info_message( request, Text(sign_in_or_register_text).format( sign_in_link=HTML(u'<a href="/login?next={current_url}">{sign_in_label}</a>').format( sign_in_label=_('Sign in'), current_url=urlquote_plus(request.path), ), register_link=HTML(u'<a href="/register?next={current_url}">{register_label}</a>').format( register_label=_('register'), current_url=urlquote_plus(request.path), ) ), title=Text(_('You must be enrolled in the course to see course content.')) ) if not user_access['is_anonymous'] and not user_access['is_staff'] and \ not user_access['is_enrolled']: title = Text(_(u'Welcome to {course_display_name}')).format( course_display_name=course.display_name ) if CourseMode.is_masters_only(course.id): # if a course is a Master's only course, we will not offer user ability to self-enroll CourseHomeMessages.register_info_message( request, Text(_('You must be enrolled in the course to see course content. ' 'Please contact your degree administrator or edX Support if you have questions.')), title=title ) elif not course.invitation_only: CourseHomeMessages.register_info_message( request, Text(_( u'{open_enroll_link}Enroll now{close_enroll_link} to access the full course.' )).format( open_enroll_link=HTML('<button class="enroll-btn btn-link">'), close_enroll_link=HTML('</button>') ), title=title ) else: CourseHomeMessages.register_info_message( request, Text(_('You must be enrolled in the course to see course content.')), )
def register_alerts(self, request, course): """ Registers an alert close to the certificate delivery date. """ is_enrolled = CourseEnrollment.get_enrollment(request.user, course.id) if not is_enrolled or not self.is_enabled or course.end > self.current_time: return if self.date > self.current_time: CourseHomeMessages.register_info_message( request, Text( _('If you have earned a certificate, you will be able to access it {time_remaining_string}' ' from now. You will also be able to view your certificates on your {dashboard_link}.' )).format( time_remaining_string=self.time_remaining_string, dashboard_link=HTML('<a href="{dashboard_url}</a>'). format(dashboard_url=reverse('dashboard'))), title=Text( _('We are working on generating course certificates.')))
def register_alerts(self, request, course): """ Registers an alert close to the certificate delivery date. """ is_enrolled = CourseEnrollment.get_enrollment(request.user, course.id) if not is_enrolled or not self.is_enabled or course.end > self.current_time: return if self.date > self.current_time: CourseHomeMessages.register_info_message( request, Text(_( 'If you have earned a certificate, you will be able to access it {time_remaining_string}' ' from now. You will also be able to view your certificates on your {learner_profile_link}.' )).format( time_remaining_string=self.time_remaining_string, learner_profile_link=HTML( '<a href="{learner_profile_url}">{learner_profile_name}</a>' ).format( learner_profile_url=reverse('learner_profile', kwargs={'username': request.user.username}), learner_profile_name=_('Learner Profile'), ), ), title=Text(_('We are working on generating course certificates.')) )
def register_course_home_messages(request, course, user_access, course_start_data): """ Register messages to be shown in the course home content page. """ if user_access['is_anonymous']: CourseHomeMessages.register_info_message( request, Text(_( " {sign_in_link} or {register_link} and then enroll in this course." )).format( sign_in_link=HTML("<a href='/login?next={current_url}'>{sign_in_label}</a>").format( sign_in_label=_("Sign in"), current_url=urlquote_plus(request.path), ), register_link=HTML("<a href='/register?next={current_url}'>{register_label}</a>").format( register_label=_("register"), current_url=urlquote_plus(request.path), ) ), title='You must be enrolled in the course to see course content.' ) if not user_access['is_anonymous'] and not user_access['is_staff'] and not user_access['is_enrolled']: CourseHomeMessages.register_info_message( request, Text(_( "{open_enroll_link} Enroll now{close_enroll_link} to access the full course." )).format( open_enroll_link='', close_enroll_link='' ), title=Text('Welcome to {course_display_name}').format( course_display_name=course.display_name ) ) if user_access['is_enrolled'] and not course_start_data['already_started']: CourseHomeMessages.register_info_message( request, Text(_( "{add_reminder_open_tag}Don't forget to add a calendar reminder!{add_reminder_close_tag}." )).format( add_reminder_open_tag='', add_reminder_close_tag='' ), title=Text("Course starts in {days_until_start_string} on {course_start_date}.").format( days_until_start_string=course_start_data['days_until_start_string'], course_start_date=course_start_data['course_start_date'] ) )
def _register_course_home_messages(request, course, user_access, course_start_data): """ Register messages to be shown in the course home content page. """ allow_anonymous = allow_public_access(course, [COURSE_VISIBILITY_PUBLIC]) if user_access['is_anonymous'] and not allow_anonymous: CourseHomeMessages.register_info_message( request, Text(_( u'{sign_in_link} or {register_link} and then enroll in this course.' )).format( sign_in_link=HTML(u'<a href="/login?next={current_url}">{sign_in_label}</a>').format( sign_in_label=_('Sign in'), current_url=urlquote_plus(request.path), ), register_link=HTML(u'<a href="/register?next={current_url}">{register_label}</a>').format( register_label=_('register'), current_url=urlquote_plus(request.path), ) ), title=Text(_('You must be enrolled in the course to see course content.')) ) if not user_access['is_anonymous'] and not user_access['is_staff'] and \ not user_access['is_enrolled']: if not course.invitation_only: CourseHomeMessages.register_info_message( request, Text(_( u'{open_enroll_link}Enroll now{close_enroll_link} to access the full course.' )).format( open_enroll_link=HTML('<button class="enroll-btn btn-link">'), close_enroll_link=HTML('</button>') ), title=Text(_(u'Welcome to {course_display_name}')).format( course_display_name=course.display_name ) ) else: CourseHomeMessages.register_info_message( request, Text(_('You must be enrolled in the course to see course content.')), )
def _register_course_home_messages(request, course_id, user_access, course_start_data): """ Register messages to be shown in the course home content page. """ course_key = CourseKey.from_string(course_id) course = get_course_with_access(request.user, 'load', course_key) if user_access['is_anonymous']: CourseHomeMessages.register_info_message( request, Text( _(" {sign_in_link} or {register_link} and then enroll in this course." ) ).format( sign_in_link=HTML( "<a href='/login?next={current_url}'>{sign_in_label}</a>"). format( sign_in_label=_("Sign in"), current_url=urlquote_plus(request.path), ), register_link=HTML( "<a href='/register?next={current_url}'>{register_label}</a>" ).format( register_label=_("register"), current_url=urlquote_plus(request.path), )), title=Text( _('You must be enrolled in the course to see course content.') )) if not user_access['is_anonymous'] and not user_access[ 'is_staff'] and not user_access['is_enrolled']: CourseHomeMessages.register_info_message( request, Text( _("{open_enroll_link} Enroll now{close_enroll_link} to access the full course." )).format(open_enroll_link='', close_enroll_link=''), title=Text(_('Welcome to {course_display_name}')).format( course_display_name=course.display_name)) if user_access['is_enrolled'] and not course_start_data['already_started']: CourseHomeMessages.register_info_message( request, Text(_("Don't forget to add a calendar reminder!")), title=Text( _("Course starts in {days_until_start_string} on {course_start_date}." ) ).format(days_until_start_string=course_start_data[ 'days_until_start_string'], course_start_date=course_start_data['course_start_date'])) # Only show the set course goal message for enrolled, unverified # users that have not yet set a goal in a course that allows for # verified statuses. has_verified_mode = CourseMode.has_verified_mode( CourseMode.modes_for_course_dict(unicode(course.id))) is_already_verified = CourseEnrollment.is_enrolled_as_verified( request.user, course_key) user_goal = get_course_goal( auth.get_user(request), course_key) if not request.user.is_anonymous() else None if user_access['is_enrolled'] and has_verified_mode and not is_already_verified and not user_goal \ and ENABLE_COURSE_GOALS.is_enabled(course_key) and settings.FEATURES.get('ENABLE_COURSE_GOALS'): goal_choices_html = Text( _('To start, set a course goal by selecting the option below that best describes ' 'your learning plan. {goal_options_container}')).format( goal_options_container=HTML( '<div class="row goal-options-container">')) # Add the dismissible option for users that are unsure of their goal goal_choices_html += Text('{initial_tag}{choice}{closing_tag}').format( initial_tag=HTML( '<div tabindex="0" aria-label="{aria_label_choice}" class="goal-option dismissible" ' 'data-choice="{goal_key}">').format( goal_key=GOAL_KEY_CHOICES.unsure, aria_label_choice=Text(_("Set goal to: {choice}")).format( choice=GOAL_KEY_CHOICES[GOAL_KEY_CHOICES.unsure]), ), choice=Text(_('{choice}')).format( choice=GOAL_KEY_CHOICES[GOAL_KEY_CHOICES.unsure], ), closing_tag=HTML('</div>'), ) # Add the option to set a goal to earn a certificate, # complete the course or explore the course goal_options = [ GOAL_KEY_CHOICES.certify, GOAL_KEY_CHOICES.complete, GOAL_KEY_CHOICES.explore ] for goal_key in goal_options: goal_text = GOAL_KEY_CHOICES[goal_key] goal_choices_html += HTML( '{initial_tag}{goal_text}{closing_tag}' ).format(initial_tag=HTML( '<div tabindex="0" aria-label="{aria_label_choice}" class="goal-option {col_sel} btn" ' 'data-choice="{goal_key}">').format( goal_key=goal_key, aria_label_choice=Text( _("Set goal to: {goal_text}")).format( goal_text=Text(_(goal_text))), col_sel='col-' + str(int(math.floor(12 / len(goal_options))))), goal_text=goal_text, closing_tag=HTML('</div>')) CourseHomeMessages.register_info_message( request, HTML('{goal_choices_html}{closing_tag}').format( goal_choices_html=goal_choices_html, closing_tag=HTML('</div>')), title=Text(_('Welcome to {course_display_name}')).format( course_display_name=course.display_name))
def _register_course_goal_message(request, course): """ Register a message to let a learner specify a course goal. """ course_goal_options = get_course_goal_options() goal_choices_html = Text(_( 'To start, set a course goal by selecting the option below that best describes ' 'your learning plan. {goal_options_container}' )).format( goal_options_container=HTML('<div class="row goal-options-container">') ) # Add the dismissible option for users that are unsure of their goal goal_choices_html += Text( '{initial_tag}{choice}{closing_tag}' ).format( initial_tag=HTML( '<div tabindex="0" aria-label="{aria_label_choice}" class="goal-option dismissible" ' 'data-choice="{goal_key}">' ).format( goal_key=GOAL_KEY_CHOICES.unsure, aria_label_choice=Text(_("Set goal to: {choice}")).format( choice=course_goal_options[GOAL_KEY_CHOICES.unsure], ), ), choice=Text(_('{choice}')).format( choice=course_goal_options[GOAL_KEY_CHOICES.unsure], ), closing_tag=HTML('</div>'), ) # Add the option to set a goal to earn a certificate, # complete the course or explore the course course_goals_by_commitment_level = valid_course_goals_ordered() for goal in course_goals_by_commitment_level: goal_key, goal_text = goal goal_choices_html += HTML( '{initial_tag}{goal_text}{closing_tag}' ).format( initial_tag=HTML( '<button tabindex="0" aria-label="{aria_label_choice}" class="goal-option btn-outline-primary" ' 'data-choice="{goal_key}">' ).format( goal_key=goal_key, aria_label_choice=Text(_("Set goal to: {goal_text}")).format( goal_text=Text(_(goal_text)) ) ), goal_text=goal_text, closing_tag=HTML('</button>') ) CourseHomeMessages.register_info_message( request, HTML('{goal_choices_html}{closing_tag}').format( goal_choices_html=goal_choices_html, closing_tag=HTML('</div>') ), title=Text(_('Welcome to {course_display_name}')).format( course_display_name=course.display_name ) )