Exemplo n.º 1
0
def courses(request, show_hidden):
    """
    Renders the courses list for the API.

    :param request: The django HttpRequest object.
    :param show_hidden: True or False, (controlled from the urls.py file) to show courses with
                        upcoming enrollment date.

    :return: JsonResponse with a list of the courses.
    """
    courses_list = branding.get_visible_courses()

    if not show_hidden:
        # Using `AnonymousUser()` to hide unpublished courses
        anonymous_user = AnonymousUser()

        # The logic bellow has been copied (with amendments) from `courseware.courses.get_courses`,
        # Just in case something changes with edX releases.
        permission_name = settings.COURSE_CATALOG_VISIBILITY_PERMISSION

        courses_list = [
            c for c in courses_list
            if has_access(anonymous_user, permission_name, c)
        ]

    courses_list = sort_by_announcement(courses_list)
    courses_list = edraak_courses_logic(courses_list)

    courses_json_list = []

    prefix = get_absolute_url_prefix(request)

    for course in courses_list:
        video_tag = get_course_about_section(course, "video")
        youtube_id = video_tag[video_tag.find("embed") + 6:video_tag.find("?")]

        courses_json_list.append({
            "id": unicode(course.id),
            "number": course.display_number_with_default,
            "name": course.display_name_with_default,
            "organization": course.display_org_with_default,
            "description": get_course_about_section(course, "short_description").strip(),
            "startDate": course.start,
            "endDate": course.end,
            "enrollmentStartDate": course.enrollment_start,
            "enrollmentEndDate": course.enrollment_end,
            "overview": get_course_about_section(course, "overview").strip(),
            "aboutPage": prefix + reverse('about_course', args=[unicode(course.id)]),
            "image": prefix + course_image_url(course),
            "state": _get_course_status(course),
            "youtube_id": youtube_id,
            "effort": get_course_about_section(course, "effort").strip(),
        })

    return JsonResponse(courses_json_list)
Exemplo n.º 2
0
    def test_get_course_about_section_render(self):

        # Test render works okay
        course_about = get_course_about_section(self.request, self.course, "short_description")
        self.assertEqual(course_about, "A course about toys.")

        # Test when render raises an exception
        with mock.patch("courseware.courses.get_module") as mock_module_render:
            mock_module_render.return_value = mock.MagicMock(render=mock.Mock(side_effect=Exception("Render failed!")))
            course_about = get_course_about_section(self.request, self.course, "short_description")
            self.assertIn("this module is temporarily unavailable", course_about)
Exemplo n.º 3
0
def course_about(request, course_id):
    user = request.user
    course = get_course_with_access(user, 'see_exists', SlashSeparatedCourseKey.from_deprecated_string(course_id))

    return JsonResponse({
        'display_number': course.display_number_with_default,
        'display_name': get_course_about_section(course, "title"),
        'display_organization': get_course_about_section(course, "university"),
        'about': get_course_about_section(course, "overview"),
        'registered': CourseEnrollment.is_enrolled(user, course.id) if user is not None and user.is_authenticated() else False,
        'is_full': CourseEnrollment.is_course_full(course) # see if we have already filled up all allowed enrollments
    })
Exemplo n.º 4
0
    def test_get_course_about_section_render(self):

        # Test render works okay
        course_about = get_course_about_section(self.request, self.course, 'short_description')
        self.assertEqual(course_about, "A course about toys.")

        # Test when render raises an exception
        with mock.patch('courseware.courses.get_module') as mock_module_render:
            mock_module_render.return_value = mock.MagicMock(
                render=mock.Mock(side_effect=Exception('Render failed!'))
            )
            course_about = get_course_about_section(self.request, self.course, 'short_description')
            self.assertIn("this module is temporarily unavailable", course_about)
Exemplo n.º 5
0
    def test_get_course_about_section_render(self, mock_get_request):
        course = get_course_by_id(self.toy_course_key)
        request = get_request_for_user(UserFactory.create())
        mock_get_request.return_value = request

        # Test render works okay
        course_about = get_course_about_section(course, 'short_description')
        self.assertEqual(course_about, "A course about toys.")

        # Test when render raises an exception
        with mock.patch('courseware.courses.get_module') as mock_module_render:
            mock_module_render.return_value = mock.MagicMock(
                render=mock.Mock(side_effect=Exception('Render failed!'))
            )
            course_about = get_course_about_section(course, 'short_description')
            self.assertIn("this module is temporarily unavailable", course_about)
Exemplo n.º 6
0
def courses_search(request):
    """
    Render "find courses" page.  The course selection work is done in courseware.courses.
    """
    if request.is_ajax():
        query_string=""
        courses=[]
        query_string = request.GET['search_string']
        if query_string is not None:
            print "----------------------------------"+query_string+"\n"
            entry_query=normalize_query(query_string)
            allCourses = get_courses(request.user, request.META.get('HTTP_HOST'))
            for course in allCourses:
                title=get_course_about_section(course,'title').lower()
                flag=True
                for query in entry_query:
                    if not query.lower() in title:
                        flag=False
                        break
                if flag:
                    courses.append(course)
            courses = sort_by_announcement(courses)
            
            if courses:
                return render_to_response("courseware/courses_search.html", {'courses': courses})
            else:
                return HttpResponse("No Courses Found")
Exemplo n.º 7
0
def get_all_ccx_for_user(user):
    """return all CCXS to which the user is registered

    Returns a list of dicts: {
        ccx_name: <formatted title of CCX course>
        ccx_url: <url to view this CCX>
        ccx_active: True if this ccx is currently the 'active' one
        mooc_name: <formatted title of the MOOC course for this CCX>
        mooc_url: <url to view this MOOC>
    }
    """
    if user.is_anonymous():
        return []
    current_active_ccx = get_current_ccx()
    memberships = []
    for membership in CcxMembership.memberships_for_user(user):
        course = get_course_by_id(membership.ccx.course_id)
        ccx = membership.ccx
        ccx_title = ccx.display_name
        mooc_title = get_course_about_section(course, 'title')
        url = reverse(
            'switch_active_ccx',
            args=[course.id.to_deprecated_string(), membership.ccx.id])
        mooc_url = reverse('switch_active_ccx',
                           args=[
                               course.id.to_deprecated_string(),
                           ])
        memberships.append({
            'ccx_name': ccx_title,
            'ccx_url': url,
            'active': membership.ccx == current_active_ccx,
            'mooc_name': mooc_title,
            'mooc_url': mooc_url,
        })
    return memberships
Exemplo n.º 8
0
def _update_course_context(request, context, course, course_key,
                           platform_name):
    """
    Updates context dictionary with course info.
    """
    context['full_course_image_url'] = request.build_absolute_uri(
        course_image_url(course))
    course_title_from_cert = context['certificate_data'].get(
        'course_title', '')
    accomplishment_copy_course_name = course_title_from_cert if course_title_from_cert else course.display_name
    context[
        'accomplishment_copy_course_name'] = accomplishment_copy_course_name
    course_number = course.display_coursenumber if course.display_coursenumber else course.number
    context['course_number'] = course_number
    if context['organization_long_name']:
        # Translators:  This text represents the description of course
        context['accomplishment_copy_course_description'] = _(
            'a course of study offered by {partner_short_name}, '
            'an online learning initiative of '
            '{partner_long_name}.').format(
                partner_short_name=context['organization_short_name'],
                partner_long_name=context['organization_long_name'],
                platform_name=platform_name)
    else:
        # Translators:  This text represents the description of course
        context['accomplishment_copy_course_description'] = _(
            'a course of study offered by '
            '{partner_short_name}.').format(
                partner_short_name=context['organization_short_name'],
                platform_name=platform_name)

    # Edraak - Add course description from course settings
    context['course_description'] = get_course_about_section(
        request, course, 'short_description')
Exemplo n.º 9
0
def get_course_info(course):
    """Returns an object containing original edX course and some complementary properties."""
    about_sections = {}
    for field in ABOUT_SECTION_FIELDS:
        about_sections[field] = get_course_about_section(course, field)
    about_sections['effort'] = about_sections['effort'].replace('\n', '')  # clean the many CRs
    if about_sections['video']:
        try:  # edX stores the Youtube iframe HTML code, let's extract the Dailymotion Cloud ID
            about_sections['video'] = re.findall('www.youtube.com/embed/(?P<hash>[\w]+)\?', about_sections['video'])[0]
        except IndexError:
            pass
    try:
        funcourse = Course.objects.get(key=course.id)
    except Course.DoesNotExist:
        funcourse = None

    course_info = FunCourse(course=course,
            fun=funcourse,
            course_image_url=course_image_url(course),
            students_count=CourseEnrollment.objects.filter(course_id=course.id).count(),
            url='https://%s%s' % (settings.LMS_BASE,
                    reverse('about_course', args=[course.id.to_deprecated_string()])),
            studio_url=get_cms_course_link(course),
            **about_sections
            )
    return course_info
Exemplo n.º 10
0
def generate_certificate(request, course_id):
    user = request.user
    course_key = locator.CourseLocator.from_string(course_id)
    course = modulestore().get_course(course_key)

    course_name = course.display_name
    course_end_date = ''
    if course.end:
        course_end_date = str(course.end.date())
    course_short_desc = get_course_about_section(course, 'short_description')

    instructor_name = ''
    role = CourseInstructorRole(course_key)
    if role.users_with_role():
        instructor_user = role.users_with_role()[0]
        instructor_name = UserProfile.objects.get(user=instructor_user).name

    cert = EdraakCertificate(course_name=course_name,
                             course_id=course_id,
                             user_profile_name=user.profile.name,
                             course_org=course.org,
                             course_end_date=course_end_date,
                             course_desc=course_short_desc,
                             instructor=instructor_name)

    cert.generate_and_save()

    return cert.temp_file
Exemplo n.º 11
0
def courses_search(request):
    """
    Render "find courses" page.  The course selection work is done in courseware.courses.
    """
    if request.is_ajax():
        query_string = ""
        courses = []
        query_string = request.GET['search_string']
        if query_string is not None:
            print "----------------------------------" + query_string + "\n"
            entry_query = normalize_query(query_string)
            allCourses = get_courses(request.user,
                                     request.META.get('HTTP_HOST'))
            for course in allCourses:
                title = get_course_about_section(course, 'title').lower()
                flag = True
                for query in entry_query:
                    if not query.lower() in title:
                        flag = False
                        break
                if flag:
                    courses.append(course)
            courses = sort_by_announcement(courses)

            if courses:
                return render_to_response("courseware/courses_search.html",
                                          {'courses': courses})
            else:
                return HttpResponse("No Courses Found")
Exemplo n.º 12
0
    def test_get_course_about_section_render(self, mock_get_request):
        course = get_course_by_id('edX/toy/2012_Fall')
        request = get_request_for_user(UserFactory.create())
        mock_get_request.return_value = request

        # Test render works okay
        course_about = get_course_about_section(course, 'short_description')
        self.assertEqual(course_about, "A course about toys.")

        # Test when render raises an exception
        with mock.patch('courseware.courses.get_module') as mock_module_render:
            mock_module_render.return_value = mock.MagicMock(
                render=mock.Mock(side_effect=Exception('Render failed!'))
            )
            course_about = get_course_about_section(course, 'short_description')
            self.assertIn("this module is temporarily unavailable", course_about)
Exemplo n.º 13
0
def json_courses(request, courses):
    c_list = []
    for c in courses:
        m_list = []
        img_url = course_image_url(c)
        short_disc = get_course_about_section(c, 'short_description')
        about_url = reverse('about_course', args=[c.id.to_deprecated_string()])
        m_list.append(c.id.to_deprecated_string())
        m_list.append(c.is_newish)
        m_list.append(c.display_number_with_default)
        m_list.append(c.display_name_with_default)
        m_list.append(c.display_org_with_default)
        m_list.append(c.start_date_is_still_default)
        m_list.append(c.start_date_text)
        m_list.append(img_url)
        m_list.append(short_disc)
        m_list.append(about_url)
        m_list.append(len(courses))
        c_list.append(m_list)

    json_list = json.dumps([{
        'id': a,
        'is_new': b,
        'number': n,
        'name': m,
        'org': o,
        'start_date_is_still': d,
        'start_date_text': s,
        'img_url': i,
        'short_disc': di,
        'about_url': ab,
        'lenth': l
    } for a, b, n, m, o, d, s, i, di, ab, l in c_list])

    return json_list
Exemplo n.º 14
0
    def format_course(course):
        format_course_json = {
            "id": course.id,
            "is_new": course.is_newish,
            "course_about_url": reverse('about_course', args=[course.id]),
            "course_number": course.display_number_with_default or "",
            "title": get_course_about_section(course, 'title'),
            "short_description": get_course_about_section(course, "short_description"),
            "img_src": course_image_url(course),
            "university": get_course_about_section(course, 'university'),
            "is_start_date_default": course.start_date_is_still_default,
            }

        if not format_course_json["is_start_date_default"]:
            format_course_json.update({"start_date_text": course.start_date_text})

        return format_course_json
Exemplo n.º 15
0
def courses(request):
    """
    Render "find courses" page.  The course selection work is done in courseware.courses.
    """
    courses = sort_by_announcement(get_courses(request.user, request.META.get('HTTP_HOST')))
    course_list = []
    for course in courses:
        course_item = {
            "display_number": course.display_number_with_default,
            "course_title": get_course_about_section(course, 'title'),
            "course_description": get_course_about_section(course, 'short_description'),
            "display_organization": get_course_about_section(course, 'university'),
            "course_image_url": course_image_url(course),
            "course_start": course.start,
            "course_id": course.id.to_deprecated_string(),
        }
        course_list.append(course_item)

    return JsonResponse(course_list)
Exemplo n.º 16
0
 def item_description(self, course):
     course = courses.utils.dates_description(course)
     context = {}
     context['image_url'] = courses.utils.course_image_url(course) + '?width=300'
     context['short_description'] = get_course_about_section(course, 'short_description')
     context['course'] = course
     try:
         context['university'] = University.objects.get(code=course.org)
     except University.DoesNotExist:
         pass
     return render_to_string('courses_api/feed/feed.html', context)
Exemplo n.º 17
0
    def get(self, request, course, *args, **kwargs):
        # There are other fields, but they don't seem to be in use.
        # see courses.py:get_course_about_section.
        #
        # This can also return None, so check for that before calling strip()
        about_section_html = get_course_about_section(course, "overview")
        about_section_html = make_static_urls_absolute(self.request, about_section_html)

        return Response(
            {"overview": about_section_html.strip() if about_section_html else ""}
        )
Exemplo n.º 18
0
    def get(self, request, *args, **kwargs):
        course_id = CourseKey.from_string(kwargs['course_id'])
        course = modulestore().get_course(course_id)

        # There are other fields, but they don't seem to be in use.
        # see courses.py:get_course_about_section.
        #
        # This can also return None, so check for that before calling strip()
        about_section_html = get_course_about_section(course, "overview")
        return Response(
            {"overview": about_section_html.strip() if about_section_html else ""}
        )
Exemplo n.º 19
0
def courses(request):
    """
    Render "find courses" page.  The course selection work is done in courseware.courses.
    """
    courses = get_courses(request.user, request.META.get('HTTP_HOST'))
    courses = sort_by_announcement(courses)
    universities = []
    for course in courses:
        university = get_course_about_section(course,'university')
        if not university in universities:
            universities.append(university)
    universities.sort()
    return render_to_response("courseware/courses.html", {'courses': courses,'universities':universities})
Exemplo n.º 20
0
    def get(self, request, course, *args, **kwargs):
        # There are other fields, but they don't seem to be in use.
        # see courses.py:get_course_about_section.
        #
        # This can also return None, so check for that before calling strip()
        about_section_html = get_course_about_section(course, "overview")
        about_section_html = make_static_urls_absolute(self.request,
                                                       about_section_html)

        return Response({
            "overview":
            about_section_html.strip() if about_section_html else ""
        })
Exemplo n.º 21
0
    def get(self, request, *args, **kwargs):
        course_id = CourseKey.from_string(kwargs['course_id'])
        course = modulestore().get_course(course_id)

        # There are other fields, but they don't seem to be in use.
        # see courses.py:get_course_about_section.
        #
        # This can also return None, so check for that before calling strip()
        about_section_html = get_course_about_section(course, "overview")
        return Response({
            "overview":
            about_section_html.strip() if about_section_html else ""
        })
Exemplo n.º 22
0
def university_search(request,org_id=""):
    if request.is_ajax():
        query_university=org_id
        courses = []
        allCourses = get_courses(request.user, request.META.get('HTTP_HOST'))
        if query_university is not None:
            for course in allCourses:
                university=get_course_about_section(course,'university')
                if (query_university.lower() in university.lower()) and (university.lower() in query_university.lower()):
                    courses.append(course) 
        if courses:
            return render_to_response("courseware/courses_search.html",{'courses':courses})
        else:
            return HttpResponse("No Courses Found")
Exemplo n.º 23
0
    def add_to_order(cls,
                     order,
                     course_id,
                     mode_slug=CourseMode.DEFAULT_MODE_SLUG,
                     cost=None,
                     currency=None):
        """
        A standardized way to create these objects, with sensible defaults filled in.
        Will update the cost if called on an order that already carries the course.

        Returns the order item
        """
        # TODO: Possibly add checking for whether student is already enrolled in course
        course = course_from_id(
            course_id
        )  # actually fetch the course to make sure it exists, use this to
        # throw errors if it doesn't

        ### handle default arguments for mode_slug, cost, currency
        course_mode = CourseMode.mode_for_course(course_id, mode_slug)
        if not course_mode:
            # user could have specified a mode that's not set, in that case return the DEFAULT_MODE
            course_mode = CourseMode.DEFAULT_MODE
        if not cost:
            cost = course_mode.min_price
        if not currency:
            currency = course_mode.currency

        super(PaidCourseRegistration, cls).add_to_order(order,
                                                        course_id,
                                                        cost,
                                                        currency=currency)

        item, created = cls.objects.get_or_create(order=order,
                                                  user=order.user,
                                                  course_id=course_id)
        item.status = order.status

        item.mode = course_mode.slug
        item.qty = 1
        item.unit_cost = cost
        item.line_desc = 'Registration for Course: {0}. Mode: {1}'.format(
            get_course_about_section(course, "title"), course_mode.name)
        item.currency = currency
        order.currency = currency
        order.save()
        item.save()
        return item
Exemplo n.º 24
0
def courses(request):
    """
    Render "find courses" page.  The course selection work is done in courseware.courses.
    """
    courses = get_courses(request.user, request.META.get('HTTP_HOST'))
    courses = sort_by_announcement(courses)
    universities = []
    for course in courses:
        university = get_course_about_section(course, 'university')
        if not university in universities:
            universities.append(university)
    universities.sort()
    return render_to_response("courseware/courses.html", {
        'courses': courses,
        'universities': universities
    })
Exemplo n.º 25
0
def university_search(request, org_id=""):
    if request.is_ajax():
        query_university = org_id
        courses = []
        allCourses = get_courses(request.user, request.META.get('HTTP_HOST'))
        if query_university is not None:
            for course in allCourses:
                university = get_course_about_section(course, 'university')
                if (query_university.lower() in university.lower()) and (
                        university.lower() in query_university.lower()):
                    courses.append(course)
        if courses:
            return render_to_response("courseware/courses_search.html",
                                      {'courses': courses})
        else:
            return HttpResponse("No Courses Found")
Exemplo n.º 26
0
def generate_certificate(request, course_id):
    course_key = locator.CourseLocator.from_string(course_id)

    path_builder = request.build_absolute_uri
    course = modulestore().get_course(course_key)
    course_short_desc = get_course_about_section(request, course,
                                                 'short_description')

    preview_mode = request.GET.get('preview', None)
    cert = EdraakCertificate(course=course,
                             user=request.user,
                             course_desc=course_short_desc,
                             preview_mode=preview_mode,
                             path_builder=path_builder)

    cert.generate_and_save()
    return cert.temp_file
Exemplo n.º 27
0
def major_search(request):
    major_result = request.POST
    major_s = major_result.get('search').lower()
    major_m = major_result.get('major_name').lower()#choise major
    major_g = major_result.get('grade').lower()#choice grade
    course_select=[]
    courses_L = get_courses(request.user, request.META.get('HTTP_HOST'))

    courses_L = sort_by_announcement(courses_L)
    if major_s==None:
        return render_to_response("courseware/courses.html", {'courses': courses_L})
    else:
        for course in courses_L:
            major_title=get_course_about_section(course, 'title').lower()
            if major_s in major_title:
                course_select.append(course)
        return render_to_response("courseware/courses.html", {'courses': course_select})
Exemplo n.º 28
0
def render_body(context, **pageargs):
    __M_caller = context.caller_stack._push_frame()
    try:
        __M_locals = __M_dict_builtin(pageargs=pageargs)
        course = context.get('course', UNDEFINED)
        request = context.get('request', UNDEFINED)
        __M_writer = context.writer()
        __M_writer(u'\n')
        __M_writer(
            u'\n\n<div id="video-modal" class="modal video-modal">\n  <div class="inner-wrapper">\n    '
        )
        __M_writer(
            filters.decode.utf8(
                get_course_about_section(request, course, "video")))
        __M_writer(u'\n  </div>\n</div>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()
Exemplo n.º 29
0
def major_search(request):
    major_result = request.POST
    major_s = major_result.get('search').lower()
    major_m = major_result.get('major_name').lower()  #choise major
    major_g = major_result.get('grade').lower()  #choice grade
    course_select = []

    courses_L = get_courses(request.user, request.META.get('HTTP_HOST'))
    courses_L = sort_by_announcement(courses_L)

    if major_s == None and major_g == None and major_m == None:
        return render_to_response("courseware/courses.html",
                                  {'courses': courses_L})
    elif major_s is not None:
        for course in courses_L:
            major_title = get_course_about_section(course, 'title').lower()
            if major_s in major_title:
                course_select.append(course)
        return render_to_response("courseware/courses.html",
                                  {'courses': course_select})
Exemplo n.º 30
0
def get_course_enrollment(request):
    if not request.user.is_authenticated():
        return JsonResponse({ "status": False })

    # for microsites, we want to filter and only show enrollments for courses
    # within the microsites 'ORG'
    course_org_filter = microsite.get_value('course_org_filter')

    # Let's filter out any courses in an "org" that has been declared to be
    # in a Microsite
    org_filter_out_set = microsite.get_all_orgs()

    # remove our current Microsite from the "filter out" list, if applicable
    if course_org_filter:
        org_filter_out_set.remove(course_org_filter)

    # Build our (course, enrollment) list for the user, but ignore any courses
    # that no longer exist (because the course IDs have changed). Still, we don't
    # delete those enrollments, because it could have been a data push snafu.
    course_enrollment_pairs = list(get_course_enrollment_pairs(request.user, course_org_filter, org_filter_out_set))

    enrollment_list = []
    for course, enrollment in course_enrollment_pairs:
        item = {
            "course_image_url": course_image_url(course),
            "course_id": course.id.to_deprecated_string(),
            "display_organization": get_course_about_section(course, 'university'),
            "display_number": course.display_number_with_default,
            "display_name": course.display_name_with_default,
            "course_start": course.start,
            "course_end": course.end,
            "enrollment_start": course.enrollment_start,
            "enrollment_end": course.enrollment_end,
            "advertised_start": course.advertised_start,
            "enrollment_date": enrollment.created,
            "active": enrollment.is_active,
        }
    enrollment_list.append(item)
    
    return JsonResponse({ "status": True, "enrollment": enrollment_list })
Exemplo n.º 31
0
def mobi_course_info(request, course, action=None):
    course_logo = course_image_url(course)
    host = request.get_host()

    try:
        user = request.user
    except:
        user = AnonymousUser()

    result = {
        "id": course.id.replace('/', '.'),
        "name": course.display_name_with_default,
        "logo": host + course_logo,
        "org": course.display_org_with_default,
        "course_number": course.display_number_with_default,
        "start_date": course.start.strftime("%Y-%m-%d"),
        "course_category": course.course_category,
        "course_level": course.course_level,
        "registered": registered_for_course(course, user),
        "about": get_course_about_section(course, 'short_description'),
        "category": course.category,
        "course_price": course.display_course_price_with_default
    }

    def compute_action_imgurl(imgname):
        course_mini_info = course.id.split('/')
        asset_location = StaticContent.compute_location(course_mini_info[0], course_mini_info[1], imgname)

        return host + StaticContent.get_url_path_from_location(asset_location)


    for imgname in ['mobi', 'mobi_r', 'ott_r']:
        try:
            result[imgname] = compute_action_imgurl(imgname + '_logo.jpg')
        except:
            result[imgname] = host + course_logo

    return result
Exemplo n.º 32
0
def mobi_course_info(request, course, action=None):
    course_logo = course_image_url(course)
    host = request.get_host()

    try:
        user = request.user
    except:
        user = AnonymousUser()

    result = {
        "id": course.id.replace('/', '.'),
        "name": course.display_name_with_default,
        "logo": host + course_logo,
        "org": course.display_org_with_default,
        "course_number": course.display_number_with_default,
        "start_date": course.start.strftime("%Y-%m-%d"),
        "course_category": course.course_category,
        "course_level": course.course_level,
        "registered": registered_for_course(course, user),
        "about": get_course_about_section(course, 'short_description'),
        "category": course.category,
        "course_price": course.display_course_price_with_default
    }

    def compute_action_imgurl(imgname):
        course_mini_info = course.id.split('/')
        asset_location = StaticContent.compute_location(
            course_mini_info[0], course_mini_info[1], imgname)

        return host + StaticContent.get_url_path_from_location(asset_location)

    for imgname in ['mobi', 'mobi_r', 'ott_r']:
        try:
            result[imgname] = compute_action_imgurl(imgname + '_logo.jpg')
        except:
            result[imgname] = host + course_logo

    return result
Exemplo n.º 33
0
def mobi_course_info(request, course, action=None):
    course_logo = course_image_url(course)
    imgurl = course_logo
    if action in ["homefalls", "all", "hot", "latest", "my", "search"]:
        try:
            course_mini_info = course.id.split('/')
            asset_location = StaticContent.compute_location(course_mini_info[0], course_mini_info[1], 'mobi-logo-img.jpg')
            imgurl = StaticContent.get_url_path_from_location(asset_location)
        except:
            print "=========================fail load mobi image==============================="
            print "We will load this info to log"

    return {
        "id": course.id.replace('/', '.'),
        "name": course.display_name_with_default,
        "logo": request.get_host() + course_image_url(course),
        "org": course.display_org_with_default,
        "course_number": course.display_number_with_default,
        "start_date": course.start.strftime("%Y-%m-%d"),
        "about": get_course_about_section(course, 'short_description'),
        "category": course.category,
        "imgurl": request.get_host() + imgurl
    }
Exemplo n.º 34
0
def mobi_course_info(request, course, action=None):
    course_logo = course_image_url(course)
    imgurl = course_logo
    if action in ["homefalls", "all", "hot", "latest", "my", "search"]:
        try:
            course_mini_info = course.id.split('/')
            asset_location = StaticContent.compute_location(course_mini_info[0], course_mini_info[1], 'mobi-logo-img.jpg')
            imgurl = StaticContent.get_url_path_from_location(asset_location)
        except:
            print "=========================fail load mobi image==============================="
            print "We will load this info to log"

    return {
        "id": course.id.replace('/', '.'),
        "name": course.display_name_with_default,
        "logo": request.get_host() + course_image_url(course),
        "org": course.display_org_with_default,
        "course_number": course.display_number_with_default,
        "start_date": course.start.strftime("%Y-%m-%d"),
        "about": get_course_about_section(course, 'short_description'),
        "category": course.category,
        "imgurl": request.get_host() + imgurl
    }
Exemplo n.º 35
0
def json_courses(request,courses):
    c_list=[]
    for c in courses:
        m_list=[]
        img_url=course_image_url(c)
        short_disc=get_course_about_section(c, 'short_description')
        about_url=reverse('about_course', args=[c.id.to_deprecated_string()])
        m_list.append(c.id.to_deprecated_string())
        m_list.append(c.is_newish)
        m_list.append(c.display_number_with_default)
        m_list.append(c.display_name_with_default)
        m_list.append(c.display_org_with_default)
        m_list.append(c.start_date_is_still_default)
        m_list.append(c.start_date_text)
        m_list.append(img_url)
        m_list.append(short_disc)
        m_list.append(about_url)
        m_list.append(len(courses))
        c_list.append(m_list)
		
    json_list=json.dumps([{'id': a, 'is_new':b, 'number':n, 'name':m, 'org':o, 'start_date_is_still':d,'start_date_text':s,'img_url':i,'short_disc':di,'about_url':ab,'lenth':l} for a,b,n,m,o,d,s,i,di,ab,l in c_list])
    
    return json_list
Exemplo n.º 36
0
    def add_to_order(cls, order, course_id, mode_slug=CourseMode.DEFAULT_MODE_SLUG, cost=None, currency=None):
        """
        A standardized way to create these objects, with sensible defaults filled in.
        Will update the cost if called on an order that already carries the course.

        Returns the order item
        """
        # TODO: Possibly add checking for whether student is already enrolled in course
        course = course_from_id(course_id)  # actually fetch the course to make sure it exists, use this to
        # throw errors if it doesn't

        ### handle default arguments for mode_slug, cost, currency
        course_mode = CourseMode.mode_for_course(course_id, mode_slug)
        if not course_mode:
            # user could have specified a mode that's not set, in that case return the DEFAULT_MODE
            course_mode = CourseMode.DEFAULT_MODE
        if not cost:
            cost = course_mode.min_price
        if not currency:
            currency = course_mode.currency

        super(PaidCourseRegistration, cls).add_to_order(order, course_id, cost, currency=currency)

        item, created = cls.objects.get_or_create(order=order, user=order.user, course_id=course_id)
        item.status = order.status

        item.mode = course_mode.slug
        item.qty = 1
        item.unit_cost = cost
        item.line_desc = "Registration for Course: {0}. Mode: {1}".format(
            get_course_about_section(course, "title"), course_mode.name
        )
        item.currency = currency
        order.currency = currency
        order.save()
        item.save()
        return item
Exemplo n.º 37
0
def get_all_ccx_for_user(user):
    """return all CCXS to which the user is registered

    Returns a list of dicts: {
        ccx_name: <formatted title of CCX course>
        ccx_url: <url to view this CCX>
        ccx_active: True if this ccx is currently the 'active' one
        mooc_name: <formatted title of the MOOC course for this CCX>
        mooc_url: <url to view this MOOC>
    }
    """
    if user.is_anonymous():
        return []
    current_active_ccx = get_current_ccx()
    memberships = []
    for membership in CcxMembership.memberships_for_user(user):
        course = get_course_by_id(membership.ccx.course_id)
        ccx = membership.ccx
        ccx_title = ccx.display_name
        mooc_title = get_course_about_section(course, 'title')
        url = reverse(
            'switch_active_ccx',
            args=[course.id.to_deprecated_string(), membership.ccx.id]
        )
        mooc_url = reverse(
            'switch_active_ccx',
            args=[course.id.to_deprecated_string(), ]
        )
        memberships.append({
            'ccx_name': ccx_title,
            'ccx_url': url,
            'active': membership.ccx == current_active_ccx,
            'mooc_name': mooc_title,
            'mooc_url': mooc_url,
        })
    return memberships
def render_body(context,course,**pageargs):
    __M_caller = context.caller_stack._push_frame()
    try:
        __M_locals = __M_dict_builtin(course=course,pageargs=pageargs)
        _import_ns = {}
        _mako_get_namespace(context, '__anon_0x81b7fd0')._populate(_import_ns, [u'stanford_theme_enabled'])
        def format_courseOrg(orgStr):
            return render_format_courseOrg(context.locals_(__M_locals),orgStr)
        __M_writer = context.writer()
        # SOURCE LINE 1
        __M_writer(u'\n')
        # SOURCE LINE 2
        __M_writer(u'\n')
        # SOURCE LINE 3
        __M_writer(u'\n\n<!--@begin:Show wireframes before implementing the functionalities of the page-->\n<!--@date:2013-11-02-->\n<style type="text/css" media="screen">\n  a.btnx:hover {\n  background:#638194;\n  transition-delay: 0s, 0s, 0s;\n  transition-duration: 0.25s, 0.25s, 0.25s;\n  transition-property:color, background,\u200b box-shadow;\n  transition-timing-function:cubic-bezier(0.42, 0, 0.58, 1), cubic-bezier(0.42, 0, 0.58, 1), cubic-bezier(0.42, 0, 0.58, 1);\n  transition-duration:0.25s,\u200b 0.25s,\u200b 0.25s;\n  color:#fff;\n  }\n  a.btnx {\n  background-color:#556370;\n  text-decoration: none;\n  padding-bottom: 7px;\n  padding-left: 10px;\n  padding-right: 10px;\n  padding-top: 7px;\n  cursor: pointer;\n  font-family: \'Open Sans\',Verdana,Geneva,sans-serif;\n  color:#fff;\n  transition-timing-function:cubic-bezier(0.42, 0, 0.58, 1), cubic-bezier(0.42, 0, 0.58, 1), cubic-bezier(0.42, 0, 0.58, 1);\n  }\n  a.btnx:normal {\n  background-color:#126F9A;\n  text-decoration: none;\n  cursor: pointer;\n  font-family: \'Open Sans\',Verdana,Geneva,sans-serif;\n  color:#fff;\n  transition-timing-function:cubic-bezier(0.42, 0, 0.58, 1), cubic-bezier(0.42, 0, 0.58, 1), cubic-bezier(0.42, 0, 0.58, 1);\n  }\n  #blocks *{font-family:\'Open Sans\',\u200bArial;}\n  #blocks p{margin-top:10px;}\n/*@begin:tag \'p\' sytle of short_description read from course_overview*/\n/*@date:2013-12-09*/\n  p{line-height:15px;}\n/*@end*/\n</style>\n\n')
        # SOURCE LINE 49
        __M_writer(u'\n')
        # SOURCE LINE 55
        __M_writer(u'\n')
        # SOURCE LINE 62
        __M_writer(u'\n')
        # SOURCE LINE 63
        __M_writer(u'\n<style type="text/css" media="screen">\n  *{font-family: \'Open Sans\'}\n  .course-card{\n    background-color: #FFFFFF;\n    border-radius: 6px;\n    -moz-border-radius: 6px;\n    -webkit-border-radius: 6px;\n    box-shadow: 3px 3px 7px 0px rgba(0,0,0,0.1);\n    float: left;\n    width: 242px;\n    min-height: 242px;\n    margin: 20px;\n    position: relative;\n    cursor: auto!important;\n  }\n  .card-top{position: relative;}\n  .image-style{\n    border-radius: 6px 6px 0px 0px;\n    -moz-border-radius: 6px 6px 0px 0px;\n    -webkit-border-radius: 6px 6px 0px 0px;\n    display: block;\n  }\n  .card-link{\n    display: table-cell;\n    width: 242px;\n    height: 60px;\n    vertical-align: middle;\n    padding: 0 17px;\n    font-size: 22px;\n    color: #FFFFFF;\n    background: rgba(18,111,154,0.95);\n    text-decoration: none!important;\n  }\n  .course-title {\n    display: table;\n    height: 60px;\n    position: absolute;\n    bottom: 0;\n    font-size:14px;\n  }\n</style>\n<script>\n  $(function()\n  {\n    $(".card-link").hover(\n      function () {\n        $(this).find("span").html("<span style=\'margin-right:80px;\'>Course Details</span><span>\u203a</span>");\n      },\n      function () {\n        $(this).find("span").html($(this).attr("title"));\n      });\n      $(".card-link").each(function(){\n        if($(this).height()>60)\n        {\n          $(this).css("fontSize","12px");\n        }\n    });\n  })\n</script>\n\n<div class="course-card" style="cursor:pointer;margin-left:45px;">\n  <div class="card-top">\n    <div><div class="field-items"><figure><img typeof="foaf:Image" class="image-style" src="')
        # SOURCE LINE 126
        __M_writer(filters.decode.utf8(course_image_url(course)))
        __M_writer(u'" width="242" height="150" alt="')
        __M_writer(filters.html_escape(filters.decode.utf8(course.display_number_with_default )))
        __M_writer(u' ')
        __M_writer(filters.decode.utf8(get_course_about_section(course, 'title')))
        __M_writer(u' Cover Image"></figure></div></div>\n    <div class="course-title"><div class="field-content"><a href="')
        # SOURCE LINE 127
        __M_writer(filters.decode.utf8(reverse('cabout', args=[course.id])))
        __M_writer(u'" class="card-link" title="')
        __M_writer(filters.decode.utf8(get_course_about_section(course, 'title')))
        __M_writer(u'"><span>')
        __M_writer(filters.decode.utf8(get_course_about_section(course, 'title')))
        __M_writer(u'</span></a></div></div>  \n  </div>\n    <div class="card-bottom" style="text-align:left;padding:10px 0 0 10px;">\n    <table><tr>\n    <td height="45"><div class="field-content"><span class="course-org" style="font-size:14px;font-weight:bold;color:#146C99">')
        # SOURCE LINE 131
        __M_writer(filters.decode.utf8(format_courseOrg(course.display_organization)))
        __M_writer(u'</span> | <span class="course-number" style="font-size:14px;font-weight:bold;">')
        __M_writer(filters.html_escape(filters.decode.utf8(course.display_number_with_default )))
        __M_writer(u'</span></div>\n    <div class="course-grade" style="font-size:14px;font-weight:bold;margin-top:5px;">')
        # SOURCE LINE 132
        __M_writer(filters.decode.utf8(course.display_grades))
        __M_writer(u'</div></td>\n    <td style="text-align:center;">\n')
        # SOURCE LINE 134
        if course.display_credit:
            # SOURCE LINE 135
            __M_writer(u'      <img src="/static/images/credit.jpg" width="30" height="30" title="Qualifies for Credit"/>\n')
        # SOURCE LINE 137
        __M_writer(u'    </td>\n    </tr>\n    <tr>\n    <td width="190">\n')
        # SOURCE LINE 141
        if course.display_prerequisite:
            # SOURCE LINE 142
            __M_writer(u'        <span style="font-size:12px;">')
            __M_writer(filters.decode.utf8(_("Prerequisite Recommended")))
            __M_writer(u'</span>\n')
        # SOURCE LINE 144
        __M_writer(u'    </td>\n    <td width="40" style="text-align:center;">\n')
        # SOURCE LINE 146
        if course.is_newish:
            # SOURCE LINE 147
            __M_writer(u'        <span style="font-size:10px;background:#99cc33;color:#fff;padding:2px;width:27px;">NEW</span>\n')
        # SOURCE LINE 149
        __M_writer(u'      </td></tr></table>\n</div>\n</div>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()
Exemplo n.º 39
0
def notify_enrollment_by_email(course, user, request):
    """
    Updates the user about the course enrollment by email.

    If the Course has already started, use post_enrollment_email
    If the Course has not yet started, use pre_enrollment_email
    """
    if (not (settings.FEATURES.get('AUTOMATIC_AUTH_FOR_TESTING')) and course.enable_enrollment_email):
        from_address = configuration_helpers.get_value(
            'email_from_address',
            settings.DEFAULT_FROM_EMAIL,
        )
        try:
            if course.has_started():
                subject = get_course_about_section(
                    request,
                    course,
                    'post_enrollment_email_subject',
                )
                message = get_course_about_section(
                    request,
                    course,
                    'post_enrollment_email',
                )
            else:
                subject = get_course_about_section(
                    request,
                    course,
                    'pre_enrollment_email_subject',
                )
                message = get_course_about_section(
                    request,
                    course,
                    'pre_enrollment_email',
                )
            subject = ''.join(subject.splitlines())
            context = {
                'username': user.username,
                'user_id': user.id,
                'name': user.profile.name,
                'course_title': course.display_name,
                'course_id': course.id,
                'course_start_date': get_default_time_display(course.start),
                'course_end_date': get_default_time_display(course.end),
            }
            message = substitute_keywords_with_data(message, context)
            user.email_user(subject, message, from_address)
        except Exception:
            log.error(
                "unable to send course enrollment verification email to user from '{from_address}'".format(
                    from_address=from_address,
                ),
                exc_info=True,
            )
            return JsonResponse({
                'is_success': False,
                'error': _('Could not send enrollment email to the user'),
            })
        return JsonResponse({
            'is_success': True,
            'subject': subject,
            'message': message,
        })
    else:
        return JsonResponse({
            'email_did_fire': False,
        })
Exemplo n.º 40
0
def courses(request, show_hidden):
    """
    Renders the courses list for the API.

    :param request: The django HttpRequest object.
    :param show_hidden: True or False, (controlled from the urls.py file) to show courses with
                        upcoming enrollment date.

    :return: JsonResponse with a list of the courses.
    """
    courses_list = branding.get_visible_courses()

    if not show_hidden:
        # Using `AnonymousUser()` to hide unpublished courses
        anonymous_user = AnonymousUser()

        # The logic bellow has been copied (with amendments) from `courseware.courses.get_courses`,
        # Just in case something changes with edX releases.
        permission_name = settings.COURSE_CATALOG_VISIBILITY_PERMISSION

        courses_list = [
            c for c in courses_list
            if has_access(anonymous_user, permission_name, c)
        ]

    courses_list = sort_by_announcement(courses_list)
    courses_list = edraak_courses_logic(courses_list)

    courses_json_list = []

    prefix = get_absolute_url_prefix(request)

    for course_overview in courses_list:

        try:
            course = get_course(course_overview.id)

            video_tag = get_course_about_section(request, course, "video")
            youtube_id = video_tag[video_tag.find("embed") + 6:video_tag.find("?")]

            courses_json_list.append({
                "id": unicode(course.id),
                "number": course.display_number_with_default,
                "name": course.display_name_with_default_escaped,
                "organization": course.display_org_with_default,
                "description": get_course_about_section(request, course, "short_description").strip(),
                "startDate": course.start,
                "endDate": course.end,
                "enrollmentStartDate": course.enrollment_start,
                "enrollmentEndDate": course.enrollment_end,
                "overview": get_course_about_section(request, course, "overview").strip(),
                "aboutPage": prefix + reverse('about_course', args=[unicode(course.id)]),
                "image": prefix + course_image_url(course),
                "state": _get_course_status(course),
                "youtube_id": youtube_id,
                "effort": get_course_about_section(request, course, "effort").strip(),
            })
        except ValueError:
            log.error(u"Course with id '{0}' not found".format(course_overview.id))


    return JsonResponse(courses_json_list)
Exemplo n.º 41
0
 def title(self):
     title = get_course_about_section(self.course_descriptor, 'title')
     return title or ''
Exemplo n.º 42
0
 def get_course_title(self):
     """Get course title"""
     from courseware.courses import get_course_about_section  # pylint: disable=import-error
     return get_course_about_section(self.course, 'title')
Exemplo n.º 43
0
def community_edit(request, community_id="new"):
    """
    Sets up the community add/edit form.
    :param request: Request object.
    :param community_id: Which community to edit, or 'new' if adding one.
    :return: Form page.
    """
    # Get a list of courses for the course drop-down in the form.
    courses_drop = get_courses(request.user)
    data = {"courses_drop": []}
    for course in courses_drop:
        data["courses_drop"].append(
            {
                "id": course.id,
                "number": course.display_number_with_default,
                "name": get_course_about_section(course, "title"),
                "logo": course_image_url(course),
            }
        )

    # If we are adding a new community, and the user making the request is a superuser, return a blank form.
    if community_id == "new" and request.user.is_superuser:
        data.update(
            {
                "community_id": "new",
                "community": "",
                "name": "",
                "motto": "",
                "logo": "",
                "facilitator": "",
                "state": "",
                "district": "",
                "hangout": "",
                "private": "",
                "courses": [""],
                "resources": [{"name": "", "link": "", "logo": ""}],
                "user_type": "super",
            }
        )
        return render_to_response("communities/community_edit.html", data)
    # If we are editing a community, make sure the user is either a superuser or facilitator for this community, and if
    # so, return a populated form for editing.
    elif community_id != "new" and (request.user.is_superuser or is_facilitator(request.user, community_id)):
        if request.user.is_superuser:
            user_type = "super"
        elif is_facilitator(request.user, community_id):
            user_type = "facilitator"
        # Grab the data from the DB.
        community_object = CommunityCommunities.objects.get(id=community_id)
        courses = CommunityCourses.objects.filter(community=community_object)
        resources = CommunityResources.objects.filter(community=community_object)
        facilitator = CommunityUsers.objects.filter(community=community_object, facilitator=True)

        # Build the lists of courses and resources.
        course_list = list()
        resource_list = list()
        for course in courses:
            course_list.append(course.course)
        if not len(course_list):
            course_list.append("")
        for resource in resources:
            resource_list.append({"name": resource.name, "link": resource.link, "logo": resource.logo})
        if not len(resource_list):
            resource_list.append({"name": "", "link": "", "logo": ""})

        # Put together the data to send to the template.
        data.update(
            {
                "community_id": community_object.id,
                "community": community_object.id,
                "name": community_object.name,
                "motto": community_object.motto,
                "logo": community_object.logo.upload.url if community_object.logo else "",
                "facilitator": facilitator[0].user.email if len(facilitator) else None,
                "state": community_object.state.id if community_object.state else "",
                "district": community_object.district.id if community_object.district else "",
                "hangout": community_object.hangout if community_object.hangout else "",
                "private": community_object.private,
                "courses": course_list,
                "resources": resource_list,
                "user_type": user_type,
            }
        )

        return render_to_response("communities/community_edit.html", data)

    # If neither of the other tests worked, the user isn't allowed to do this.
    return HttpResponseForbidden()
Exemplo n.º 44
0
 def get_course_title(self):
     """Get course title"""
     from courseware.courses import get_course_about_section  # pylint: disable=import-error
     return get_course_about_section(self.course, 'title')
def render_body(context,**pageargs):
    __M_caller = context.caller_stack._push_frame()
    try:
        __M_locals = __M_dict_builtin(pageargs=pageargs)
        cert_statuses = context.get('cert_statuses', UNDEFINED)
        settings = context.get('settings', UNDEFINED)
        external_times = context.get('external_times', UNDEFINED)
        float = context.get('float', UNDEFINED)
        request = context.get('request', UNDEFINED)
        show_courseware_links_for = context.get('show_courseware_links_for', UNDEFINED)
        exam_registrations = context.get('exam_registrations', UNDEFINED)
        curr_user = context.get('curr_user', UNDEFINED)
        course_times = context.get('course_times', UNDEFINED)
        courses_complated = context.get('courses_complated', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 1
        __M_writer(u'\n\n')
        # SOURCE LINE 10
        __M_writer(u'\n\n<!--@begin:information of user who have no COMPLETED COURSES-->\n<!--@date:2013-12-13-->\n')
        # SOURCE LINE 14
        if not courses_complated:
            # SOURCE LINE 15
            __M_writer(u'   <section class="empty-dashboard-message">\n        <p>')
            # SOURCE LINE 16
            __M_writer(filters.decode.utf8(_("You haven’t completed any course yet.")))
            __M_writer(u'</p>\n   </section>\n')
        # SOURCE LINE 19
        __M_writer(u'<!--@end-->\n\n')
        # SOURCE LINE 21
        for course in courses_complated:
            # SOURCE LINE 22
            __M_writer(u'        <article class="my-course">\n          ')
            # SOURCE LINE 23

            course_target = reverse('courseware', args=[course.id])
                      
            
            __M_locals_builtin_stored = __M_locals_builtin()
            __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['course_target'] if __M_key in __M_locals_builtin_stored]))
            # SOURCE LINE 25
            __M_writer(u'\n')
            # SOURCE LINE 26
            if course.id in show_courseware_links_for:
                # SOURCE LINE 27
                if curr_user==request.user:
                    # SOURCE LINE 28
                    __M_writer(u'            <a href="')
                    __M_writer(filters.decode.utf8(course_target))
                    __M_writer(u'" class="cover">\n')
                    # SOURCE LINE 29
                else:
                    # SOURCE LINE 30
                    __M_writer(u'            <a href="" class="cover" style="cursor:default;" onclick="return false;">\n')
                # SOURCE LINE 32
                __M_writer(u'              <img src="')
                __M_writer(filters.decode.utf8(course_image_url(course)))
                __M_writer(u'" style="width:200px;height:104px;" alt="')
                __M_writer(filters.html_escape(filters.decode.utf8(_('{course_number} {course_name} Cover Image').format(course_number=course.number, course_name=course.display_name_with_default) )))
                __M_writer(u'" />\n            </a>\n')
                # SOURCE LINE 34
            else:
                # SOURCE LINE 35
                __M_writer(u'            <div class="cover">\n              <img src="')
                # SOURCE LINE 36
                __M_writer(filters.decode.utf8(course_image_url(course)))
                __M_writer(u'" alt="')
                __M_writer(filters.html_escape(filters.decode.utf8(_('{course_number} {course_name} Cover Image').format(course_number=course.number, course_name=course.display_name_with_default) )))
                __M_writer(u'" />\n            </div>\n')
            # SOURCE LINE 39
            __M_writer(u'          <section class="info">\n            <hgroup>\n              <p class="date-block">\n                ')
            # SOURCE LINE 42
            __M_writer(filters.decode.utf8(_("Course Completed - {end_date:%B %d,%Y}").format(end_date=course.student_enrollment_date)))
            __M_writer(u'\n              </p>\n              <h2 class="university">')
            # SOURCE LINE 44
            __M_writer(filters.decode.utf8(get_course_about_section(course, 'university')))
            __M_writer(u'</h2>\n              <h3>\n')
            # SOURCE LINE 46
            if course.id in show_courseware_links_for:
                # SOURCE LINE 47
                if curr_user==request.user:
                    # SOURCE LINE 48
                    __M_writer(u'                  <a href="')
                    __M_writer(filters.decode.utf8(course_target))
                    __M_writer(u'">')
                    __M_writer(filters.html_escape(filters.decode.utf8(course.display_number_with_default )))
                    __M_writer(u' ')
                    __M_writer(filters.decode.utf8(course.display_name_with_default))
                    __M_writer(u'</a>\n')
                    # SOURCE LINE 49
                else:
                    # SOURCE LINE 50
                    __M_writer(u'                  <a href="" style="cursor:default;" onclick="return false;" course_number="')
                    __M_writer(filters.html_escape(filters.decode.utf8(course.display_number_with_default )))
                    __M_writer(u'">')
                    __M_writer(filters.html_escape(filters.decode.utf8(course.display_number_with_default )))
                    __M_writer(u' ')
                    __M_writer(filters.decode.utf8(course.display_name_with_default))
                    __M_writer(u'</a>\n')
                # SOURCE LINE 52
            else:
                # SOURCE LINE 53
                __M_writer(u'                  <span>')
                __M_writer(filters.html_escape(filters.decode.utf8(course.display_number_with_default )))
                __M_writer(u' ')
                __M_writer(filters.decode.utf8(course.display_name_with_default))
                __M_writer(u'</span>\n')
            # SOURCE LINE 55
            __M_writer(u'              </h3>\n            </hgroup>\n            ')
            # SOURCE LINE 57

            testcenter_exam_info = course.current_test_center_exam
            registration = exam_registrations.get(course.id)
            testcenter_register_target = reverse('begin_exam_registration', args=[course.id])
                        
            
            __M_locals_builtin_stored = __M_locals_builtin()
            __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['testcenter_register_target','testcenter_exam_info','registration'] if __M_key in __M_locals_builtin_stored]))
            # SOURCE LINE 61
            __M_writer(u'\n')
            # SOURCE LINE 62
            if testcenter_exam_info is not None:
                # SOURCE LINE 63
                if registration is None and testcenter_exam_info.is_registering():
                    # SOURCE LINE 64
                    __M_writer(u'                <div class="message message-status is-shown exam-register">\n                  <a href="')
                    # SOURCE LINE 65
                    __M_writer(filters.decode.utf8(testcenter_register_target))
                    __M_writer(u'" class="button exam-button" id="exam_register_button">')
                    __M_writer(filters.decode.utf8(_("Register for Pearson exam")))
                    __M_writer(u'</a>\n                  <p class="message-copy">')
                    # SOURCE LINE 66
                    __M_writer(filters.decode.utf8(_("Registration for the Pearson exam is now open and will close on {end_date}").format(end_date="<strong>{}</strong>".format(testcenter_exam_info.registration_end_date_text))))
                    __M_writer(u'</p>\n                </div>\n')
                # SOURCE LINE 69
                __M_writer(u'                <!-- display a registration for a current exam, even if the registration period is over -->\n')
                # SOURCE LINE 70
                if registration is not None:
                    # SOURCE LINE 71
                    if registration.is_accepted:
                        # SOURCE LINE 72
                        __M_writer(u'                <div class="message message-status is-shown exam-schedule">\n                   <a href="')
                        # SOURCE LINE 73
                        __M_writer(filters.decode.utf8(registration.registration_signup_url))
                        __M_writer(u'" class="button exam-button">')
                        __M_writer(filters.decode.utf8(_("Schedule Pearson exam")))
                        __M_writer(u'</a>\n                   <p class="exam-registration-number">')
                        # SOURCE LINE 74
                        __M_writer(filters.decode.utf8(_("{link_start}Registration{link_end} number: {number}").format(
                      link_start='<a href="{url}" id="exam_register_link">'.format(url=testcenter_register_target),
                      link_end='</a>',
                      number=registration.client_candidate_id,
                    )))
                        # SOURCE LINE 78
                        __M_writer(u'</p>\n                   <p class="message-copy">')
                        # SOURCE LINE 79
                        __M_writer(filters.decode.utf8(_("Write this down! You'll need it to schedule your exam.")))
                        __M_writer(u'</p>\n                </div>\n')
                    # SOURCE LINE 82
                    if  registration.is_rejected:
                        # SOURCE LINE 83
                        __M_writer(u'                <div class="message message-status is-shown exam-schedule">\n                  <p class="message-copy">\n                    <strong>')
                        # SOURCE LINE 85
                        __M_writer(filters.decode.utf8(_("Your registration for the Pearson exam has been rejected. Please {link_start}see your registration status details{link_end}.").format(
                      link_start='<a href="{url}" id="exam_register_link">'.format(url=testcenter_register_target),
                      link_end='</a>')))
                        # SOURCE LINE 87
                        __M_writer(u'</strong>\n                    ')
                        # SOURCE LINE 88
                        __M_writer(filters.decode.utf8(_("Otherwise {link_start}contact edX at {email}{link_end} for further help.").format(
                      link_start='<a class="contact-link" href="mailto:{email}?subject=Pearson VUE Exam - {about} {number}">'.format(email="*****@*****.**", about=get_course_about_section(course, 'university'), number=course.display_number_with_default),
                      link_end='</a>',
                      email="*****@*****.**",
                     )))
                        # SOURCE LINE 92
                        __M_writer(u'\n                </div>\n')
                    # SOURCE LINE 95
                    if not registration.is_accepted and not registration.is_rejected:
                        # SOURCE LINE 96
                        __M_writer(u'\t            <div class="message message-status is-shown">\n                  <p class="message-copy"><strong>')
                        # SOURCE LINE 97
                        __M_writer(filters.decode.utf8(_("Your {link_start}registration for the Pearson exam{link_end} is pending.").format(link_start='<a href="{url}" id="exam_register_link">'.format(url=testcenter_register_target), link_end='</a>')))
                        __M_writer(u'</strong>\n                  ')
                        # SOURCE LINE 98
                        __M_writer(filters.decode.utf8(_("Within a few days, you should see a confirmation number here, which can be used to schedule your exam.")))
                        __M_writer(u'\n                  </p>\n                </div>\n')
            # SOURCE LINE 104
            __M_writer(u'            ')

            cert_status = cert_statuses.get(course.id)
            
            
            __M_locals_builtin_stored = __M_locals_builtin()
            __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['cert_status'] if __M_key in __M_locals_builtin_stored]))
            # SOURCE LINE 106
            __M_writer(u'\n')
            # SOURCE LINE 107
            if course.has_ended() and cert_status:
                # SOURCE LINE 108
                __M_writer(u'                ')

                if cert_status['status'] == 'generating':
                    status_css_class = 'course-status-certrendering'
                elif cert_status['status'] == 'ready':
                    status_css_class = 'course-status-certavailable'
                elif cert_status['status'] == 'notpassing':
                    status_css_class = 'course-status-certnotavailable'
                else:
                    status_css_class = 'course-status-processing'
                
                
                __M_locals_builtin_stored = __M_locals_builtin()
                __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['status_css_class'] if __M_key in __M_locals_builtin_stored]))
                # SOURCE LINE 117
                __M_writer(u'\n                <div class="message message-status ')
                # SOURCE LINE 118
                __M_writer(filters.decode.utf8(status_css_class))
                __M_writer(u' is-shown">\n')
                # SOURCE LINE 119
                if cert_status['status'] == 'processing':
                    # SOURCE LINE 120
                    __M_writer(u'                      <p class="message-copy">')
                    __M_writer(filters.decode.utf8(_("Final course details are being wrapped up at this time. Your final standing will be available shortly.")))
                    __M_writer(u'</p>\n')
                    # SOURCE LINE 121
                elif cert_status['status'] in ('generating', 'ready', 'notpassing', 'restricted'):
                    # SOURCE LINE 122
                    __M_writer(u'                      <p class="message-copy">')
                    __M_writer(filters.decode.utf8(_("Your final grade:")))
                    __M_writer(u'\n                      <span class="grade-value">')
                    # SOURCE LINE 123
                    __M_writer(filters.decode.utf8("{0:.0f}%".format(float(cert_status['grade'])*100)))
                    __M_writer(u'</span>.\n')
                    # SOURCE LINE 124
                    if cert_status['status'] == 'notpassing':
                        # SOURCE LINE 125
                        __M_writer(u'                         ')
                        __M_writer(filters.decode.utf8(_("Grade required for a certificate:")))
                        __M_writer(u' <span class="grade-value">\n                           ')
                        # SOURCE LINE 126
                        __M_writer(filters.decode.utf8("{0:.0f}%".format(float(course.lowest_passing_grade)*100)))
                        __M_writer(u'</span>.\n')
                        # SOURCE LINE 127
                    elif cert_status['status'] == 'restricted':
                        # SOURCE LINE 128
                        __M_writer(u'                          <p class="message-copy">\n                          ')
                        # SOURCE LINE 129
                        __M_writer(filters.decode.utf8(_("Your certificate is being held pending confirmation that the issuance of your certificate is in compliance with strict U.S. embargoes on Iran, Cuba, Syria and Sudan. If you think our system has mistakenly identified you as being connected with one of those countries, please let us know by contacting {email}.").format(email='<a class="contact-link" href="mailto:{email}">{email}</a>.'.format(email=settings.CONTACT_EMAIL))))
                        __M_writer(u'\n                          </p>\n')
                    # SOURCE LINE 132
                    __M_writer(u'                      </p>\n')
                # SOURCE LINE 134
                if cert_status['show_disabled_download_button'] or cert_status['show_download_url'] or cert_status['show_survey_button']:
                    # SOURCE LINE 135
                    __M_writer(u'                  <ul class="actions">\n')
                    # SOURCE LINE 136
                    if cert_status['show_disabled_download_button']:
                        # SOURCE LINE 137
                        __M_writer(u'                      <li class="action"><span class="disabled">\n                          ')
                        # SOURCE LINE 138
                        __M_writer(filters.decode.utf8(_("Your Certificate is Generating")))
                        __M_writer(u'</span></li>\n')
                        # SOURCE LINE 139
                    elif cert_status['show_download_url']:
                        # SOURCE LINE 140
                        if curr_user==request.user:      
                            # SOURCE LINE 141
                            __M_writer(u'                      <li class="action">\n                      <a class="btn" href="')
                            # SOURCE LINE 142
                            __M_writer(filters.decode.utf8(cert_status['download_url']))
                            __M_writer(u'"\n                         title="')
                            # SOURCE LINE 143
                            __M_writer(filters.decode.utf8(_('This link will open/download a PDF document')))
                            __M_writer(u'">\n                         Download Your PDF Certificate</a>\n                      </li>\n')
                    # SOURCE LINE 148
                    if cert_status['show_survey_button']:
                        # SOURCE LINE 149
                        __M_writer(u'                      <li class="action"><a class="cta" href="')
                        __M_writer(filters.decode.utf8(cert_status['survey_url']))
                        __M_writer(u'">\n                             ')
                        # SOURCE LINE 150
                        __M_writer(filters.decode.utf8(_('Complete our course feedback survey')))
                        __M_writer(u'</a></li>\n')
                    # SOURCE LINE 152
                    __M_writer(u'                  </ul>\n')
                # SOURCE LINE 154
                __M_writer(u'                </div>\n')
            # SOURCE LINE 156
            __M_writer(u'                <link rel="stylesheet" href="/static/tmp-resource/css/main.css" type="text/css" media="screen" />\n\n')
            # SOURCE LINE 158
            if course.id in show_courseware_links_for:
                # SOURCE LINE 159
                if curr_user==request.user:              
                    # SOURCE LINE 160
                    __M_writer(u'\t\t\t\t<a href="')
                    __M_writer(filters.decode.utf8(reverse('portfolio_about_me',args=[course.id])))
                    __M_writer(u'" class="enter-course dashboard-btn1">')
                    __M_writer(filters.decode.utf8(_('View Portfolio')))
                    __M_writer(u'</a>\n')
                    # SOURCE LINE 161
                else:
                    # SOURCE LINE 162
                    __M_writer(u'                <a href="javascript:void(0)" class="enter-course dashboard-btn1 portfolio-btn" link="')
                    __M_writer(filters.decode.utf8(reverse('portfolio_about_me',args=[course.id,curr_user.id])))
                    __M_writer(u'">')
                    __M_writer(filters.decode.utf8(_('View Portfolio')))
                    __M_writer(u'</a>\n')
                # SOURCE LINE 164
                __M_writer(u'\n')
                # SOURCE LINE 165
                if curr_user==request.user:      
                    # SOURCE LINE 166
                    __M_writer(u'                <a href="')
                    __M_writer(filters.decode.utf8(course_target))
                    __M_writer(u'" class="enter-course dashboard-btn2" style="margin-left:10px;">')
                    __M_writer(filters.decode.utf8(_('View Course')))
                    __M_writer(u'</a>\n')
            # SOURCE LINE 169
            __M_writer(u'\n')
            # SOURCE LINE 170
            if settings.MITX_FEATURES['ENABLE_INSTRUCTOR_EMAIL'] and modulestore().get_modulestore_type(course.id) == MONGO_MODULESTORE_TYPE:
                # SOURCE LINE 171
                __M_writer(u'  \t      <!-- Only show the Email Settings link/modal if this course has bulk email feature enabled -->\n')
                # SOURCE LINE 172
                if curr_user==request.user:      
                    # SOURCE LINE 173
                    __M_writer(u'              <a href="')
                    __M_writer(filters.decode.utf8(reverse('download_certificate',args=[course.id,("{end_date:%Y-%m-%d}").format(end_date=course.student_enrollment_date)])))
                    __M_writer(u'" target="blank" class="enter-course dashboard-btn1" style="margin-left:10px;float:right;">')
                    __M_writer(filters.decode.utf8(_('Download Your PDF Certificate')))
                    __M_writer(u'</a>\n')
                    # SOURCE LINE 174
                    if course.hide_timer == False:
                        # SOURCE LINE 175
                        if course.show_external_timer == False:
                            # SOURCE LINE 176
                            __M_writer(u'                  <div class="course-time-completed" time_type="course" course_id="')
                            __M_writer(filters.decode.utf8(course.id))
                            __M_writer(u'">Course Time: <span>')
                            __M_writer(filters.decode.utf8(course_times[course.id]))
                            __M_writer(u'</span></div>\n')
                            # SOURCE LINE 177
                        else:
                            # SOURCE LINE 178
                            __M_writer(u'                  <div class="course-time-completed" time_type="external" course_id="')
                            __M_writer(filters.decode.utf8(course.id))
                            __M_writer(u'">External Time: <span>')
                            __M_writer(filters.decode.utf8(external_times[course.id]))
                            __M_writer(u'<span></div>\n')
            # SOURCE LINE 183
            __M_writer(u'            </section>\n          </article>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()
Exemplo n.º 46
0
def course_infos(course):
    d = {}
    for section in ABOUT_SECTION_FIELDS:
        d[section] = get_course_about_section(course, section)
    d['course_image_url'] = course_image_url(course)
    return d
Exemplo n.º 47
0
 def item_title(self, course):
     return get_course_about_section(course, 'title')