From 0f52b31ac1f9fa2baf359aea318d9e0ee8ba4653 Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Thu, 21 Jun 2012 15:23:47 -0400 Subject: [PATCH] Make the LMS check_course command work again. --- .../management/commands/check_course.py | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/courseware/management/commands/check_course.py b/lms/djangoapps/courseware/management/commands/check_course.py index 4c80221702..8de29bdd8b 100644 --- a/lms/djangoapps/courseware/management/commands/check_course.py +++ b/lms/djangoapps/courseware/management/commands/check_course.py @@ -14,6 +14,10 @@ import mitxmako.middleware as middleware middleware.MakoMiddleware() def check_names(user, course): + ''' + Complain if any problems have alphanumeric names. + TODO (vshnayder): there are some in 6.002x that don't. Is that actually a problem? + ''' all_ok = True print "Confirming all problems have alphanumeric names" for problem in course.xpath('//problem'): @@ -53,7 +57,10 @@ def check_sections(user, course): print "Checking all section includes are valid XML" for f in os.listdir(sections_dir): sectionfile = sections_dir + '/' + f - print sectionfile + #print sectionfile + # skip non-xml files: + if not sectionfile.endswith('xml'): + continue try: etree.parse(sectionfile) except Exception as ex: @@ -69,12 +76,23 @@ class Command(BaseCommand): help = "Does basic validity tests on course.xml." def handle(self, *args, **options): all_ok = True + + # TODO (vshnayder): create dummy user objects. Anon, authenticated, staff. + # Check that everything works for each. + # The objects probably shouldn't be actual django users to avoid unneeded + # dependency on django. + + # TODO: use args as list of files to check. Fix loading to work for other files. + sample_user = User.objects.all()[0] + print "Attempting to load courseware" course = course_file(sample_user) to_run = [check_names, + # TODO (vshnayder) : make check_rendering work (use module_render.py), + # turn it on # check_rendering, check_sections, ]