def test_course_page_names(self): """ Test the defined course pages. """ course = CourseFactory.create(org='mitX', number='666', display_name='URL Reverse Course') self.assertEquals( '/manage_users/i4x://mitX/666/course/URL_Reverse_Course', utils.get_url_reverse('ManageUsers', course) ) self.assertEquals( '/mitX/666/settings-details/URL_Reverse_Course', utils.get_url_reverse('SettingsDetails', course) ) self.assertEquals( '/mitX/666/settings-grading/URL_Reverse_Course', utils.get_url_reverse('SettingsGrading', course) ) self.assertEquals( '/mitX/666/course/URL_Reverse_Course', utils.get_url_reverse('CourseOutline', course) ) self.assertEquals( '/mitX/666/checklists/URL_Reverse_Course', utils.get_url_reverse('Checklists', course) )
def test_unknown_passes_through(self): """ Test that unknown values pass through. """ course = CourseFactory.create(org="mitX", number="666", display_name="URL Reverse Course") self.assertEquals("foobar", utils.get_url_reverse("foobar", course)) self.assertEquals( "https://edge.edx.org/courses/edX/edX101/How_to_Create_an_edX_Course/about", utils.get_url_reverse("https://edge.edx.org/courses/edX/edX101/How_to_Create_an_edX_Course/about", course), )
def test_unknown_passes_through(self): """ Test that unknown values pass through. """ course = CourseFactory.create(org='mitX', number='666', display_name='URL Reverse Course') self.assertEquals('foobar', utils.get_url_reverse('foobar', course)) self.assertEquals( 'https://edge.edx.org/courses/edX/edX101/How_to_Create_an_edX_Course/about', utils.get_url_reverse( 'https://edge.edx.org/courses/edX/edX101/How_to_Create_an_edX_Course/about', course))
def test_unknown_passes_through(self): """ Test that unknown values pass through. """ course = CourseFactory.create(org='mitX', number='666', display_name='URL Reverse Course') self.assertEquals( 'foobar', utils.get_url_reverse('foobar', course) ) self.assertEquals( 'https://edge.edx.org/courses/edX/edX101/How_to_Create_an_edX_Course/about', utils.get_url_reverse('https://edge.edx.org/courses/edX/edX101/How_to_Create_an_edX_Course/about', course) )
def index(request): """ List all courses available to the logged in user """ courses = modulestore('direct').get_items( ['i4x', None, None, 'course', None]) # filter out courses that we don't have access too def course_filter(course): return (has_access(request.user, course.location) and course.location.course != 'templates' and course.location.org != '' and course.location.course != '' and course.location.name != '') courses = filter(course_filter, courses) return render_to_response( 'index.html', { 'new_course_template': Location('i4x', 'edx', 'templates', 'course', 'Empty'), 'courses': [ (course.display_name, get_url_reverse('CourseOutline', course), get_lms_link_for_item(course.location, course_id=course.location.course_id)) for course in courses ], 'user': request.user, 'disable_course_creation': settings.MITX_FEATURES.get('DISABLE_COURSE_CREATION', False) and not request.user.is_staff })
def index(request): """ List all courses available to the logged in user """ courses = modulestore('direct').get_items(['i4x', None, None, 'course', None]) # filter out courses that we don't have access too def course_filter(course): return (has_access(request.user, course.location) # TODO remove this condition when templates purged from db and course.location.course != 'templates' and course.location.org != '' and course.location.course != '' and course.location.name != '') courses = filter(course_filter, courses) return render_to_response('index.html', { 'courses': [(course.display_name, get_url_reverse('CourseOutline', course), get_lms_link_for_item(course.location, course_id=course.location.course_id)) for course in courses], 'user': request.user, 'request_course_creator_url': reverse('request_course_creator'), 'course_creator_status': _get_course_creator_status(request.user), 'csrf': csrf(request)['csrf_token'] })
def index(request): """ List all courses available to the logged in user """ courses = modulestore("direct").get_items(["i4x", None, None, "course", None]) # filter out courses that we don't have access too def course_filter(course): return ( has_access(request.user, course.location) # TODO remove this condition when templates purged from db and course.location.course != "templates" and course.location.org != "" and course.location.course != "" and course.location.name != "" ) courses = filter(course_filter, courses) return render_to_response( "index.html", { "courses": [ ( course.display_name, get_url_reverse("CourseOutline", course), get_lms_link_for_item(course.location, course_id=course.location.course_id), ) for course in courses ], "user": request.user, "disable_course_creation": settings.MITX_FEATURES.get("DISABLE_COURSE_CREATION", False) and not request.user.is_staff, }, )
def index(request): """ List all courses available to the logged in user """ courses = modulestore('direct').get_items( ['i4x', None, None, 'course', None]) # filter out courses that we don't have access too def course_filter(course): return (has_access(request.user, course.location) # TODO remove this condition when templates purged from db and course.location.course != 'templates' and course.location.org != '' and course.location.course != '' and course.location.name != '') courses = filter(course_filter, courses) return render_to_response( 'index.html', { 'courses': [(course.display_name, get_url_reverse('CourseOutline', course), get_lms_link_for_item(course.location, course_id=course.location.course_id)) for course in courses], 'user': request.user, 'request_course_creator_url': reverse('request_course_creator'), 'course_creator_status': _get_course_creator_status(request.user), 'csrf': csrf(request)['csrf_token'] })
def test_course_page_names(self): """ Test the defined course pages. """ course = CourseFactory.create(org="mitX", number="666", display_name="URL Reverse Course") self.assertEquals( "/manage_users/i4x://mitX/666/course/URL_Reverse_Course", utils.get_url_reverse("ManageUsers", course) ) self.assertEquals( "/mitX/666/settings-details/URL_Reverse_Course", utils.get_url_reverse("SettingsDetails", course) ) self.assertEquals( "/mitX/666/settings-grading/URL_Reverse_Course", utils.get_url_reverse("SettingsGrading", course) ) self.assertEquals("/mitX/666/course/URL_Reverse_Course", utils.get_url_reverse("CourseOutline", course)) self.assertEquals("/mitX/666/checklists/URL_Reverse_Course", utils.get_url_reverse("Checklists", course))
def test_get_checklists(self): """ Tests the get checklists method. """ checklists_url = get_url_reverse('Checklists', self.course) response = self.client.get(checklists_url) self.assertContains(response, "Getting Started With Studio") payload = response.content # Now delete the checklists from the course and verify they get repopulated (for courses # created before checklists were introduced). self.course.checklists = None modulestore = get_modulestore(self.course.location) modulestore.update_metadata(self.course.location, own_metadata(self.course)) self.assertEqual(self.get_persisted_checklists(), None) response = self.client.get(checklists_url) self.assertEqual(payload, response.content)
def index(request): """ List all courses available to the logged in user """ courses = modulestore('direct').get_items(['i4x', None, None, 'course', None]) # filter out courses that we don't have access too def course_filter(course): return (has_access(request.user, course.location) and course.location.course != 'templates' and course.location.org != '' and course.location.course != '' and course.location.name != '') courses = filter(course_filter, courses) return render_to_response('index.html', { 'new_course_template': Location('i4x', 'edx', 'templates', 'course', 'Empty'), 'courses': [(course.display_name, get_url_reverse('CourseOutline', course), get_lms_link_for_item(course.location, course_id=course.location.course_id)) for course in courses], 'user': request.user, 'disable_course_creation': settings.MITX_FEATURES.get('DISABLE_COURSE_CREATION', False) and not request.user.is_staff })