当前位置: 首页>>代码示例>>Python>>正文


Python CourseHomeMessages.register_info_message方法代码示例

本文整理汇总了Python中openedx.features.course_experience.CourseHomeMessages.register_info_message方法的典型用法代码示例。如果您正苦于以下问题:Python CourseHomeMessages.register_info_message方法的具体用法?Python CourseHomeMessages.register_info_message怎么用?Python CourseHomeMessages.register_info_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openedx.features.course_experience.CourseHomeMessages的用法示例。


在下文中一共展示了CourseHomeMessages.register_info_message方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register_alerts

# 需要导入模块: from openedx.features.course_experience import CourseHomeMessages [as 别名]
# 或者: from openedx.features.course_experience.CourseHomeMessages import register_info_message [as 别名]
 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,
                 )
             )
开发者ID:dehamzah,项目名称:edx-platform,代码行数:30,代码来源:date_summary.py

示例2: _register_course_home_messages

# 需要导入模块: from openedx.features.course_experience import CourseHomeMessages [as 别名]
# 或者: from openedx.features.course_experience.CourseHomeMessages import register_info_message [as 别名]
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
            )
        )
开发者ID:TeachAtTUM,项目名称:edx-platform,代码行数:36,代码来源:course_home_messages.py

示例3: register_alerts

# 需要导入模块: from openedx.features.course_experience import CourseHomeMessages [as 别名]
# 或者: from openedx.features.course_experience.CourseHomeMessages import register_info_message [as 别名]
 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,
             )
         )
开发者ID:mattpe,项目名称:edx-platform,代码行数:36,代码来源:date_summary.py

示例4: _register_course_home_messages

# 需要导入模块: from openedx.features.course_experience import CourseHomeMessages [as 别名]
# 或者: from openedx.features.course_experience.CourseHomeMessages import register_info_message [as 别名]
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.')),
            )
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:57,代码来源:course_home_messages.py

示例5: _register_course_home_messages

# 需要导入模块: from openedx.features.course_experience import CourseHomeMessages [as 别名]
# 或者: from openedx.features.course_experience.CourseHomeMessages import register_info_message [as 别名]
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.')),
            )
开发者ID:jolyonb,项目名称:edx-platform,代码行数:45,代码来源:course_home_messages.py

示例6: _register_course_goal_message

# 需要导入模块: from openedx.features.course_experience import CourseHomeMessages [as 别名]
# 或者: from openedx.features.course_experience.CourseHomeMessages import register_info_message [as 别名]
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
        )
    )
开发者ID:TeachAtTUM,项目名称:edx-platform,代码行数:64,代码来源:course_home_messages.py


注:本文中的openedx.features.course_experience.CourseHomeMessages.register_info_message方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。