diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py index 30ca38728a..c92cbb1425 100644 --- a/lms/djangoapps/courseware/courses.py +++ b/lms/djangoapps/courseware/courses.py @@ -141,6 +141,35 @@ def get_course_info_section(course, section_key): raise KeyError("Invalid about key " + str(section_key)) +# TODO: Fix this such that these are pulled in as extra course-specific tabs. +# arjun will address this by the end of October if no one does so prior to +# then. +def get_course_syllabus_section(course, section_key): + """ + This returns the snippet of html to be rendered on the syllabus page, + given the key for the section. + + Valid keys: + - syllabus + - guest_syllabus + """ + + # Many of these are stored as html files instead of some semantic + # markup. This can change without effecting this interface when we find a + # good format for defining so many snippets of text/html. + + if section_key in ['syllabus', 'guest_syllabus']: + try: + with course.system.resources_fs.open(path("syllabus") / section_key + ".html") as htmlFile: + return replace_urls(htmlFile.read().decode('utf-8'), + course.metadata['data_dir']) + except ResourceNotFoundError: + log.exception("Missing syllabus section {key} in course {url}".format( + key=section_key, url=course.location.url())) + return "! Syllabus missing !" + + raise KeyError("Invalid about key " + str(section_key)) + def get_courses_by_university(user, domain=None): ''' diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index 6e8fe6fd23..98444c176d 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -232,6 +232,19 @@ def course_info(request, course_id): return render_to_response('courseware/info.html', {'course': course, 'staff_access': staff_access,}) +# TODO arjun: remove when custom tabs in place, see courseware/syllabus.py +@ensure_csrf_cookie +def syllabus(request, course_id): + """ + Display the course's syllabus.html, or 404 if there is no such course. + + Assumes the course_id is in a valid format. + """ + course = get_course_with_access(request.user, course_id, 'load') + staff_access = has_access(request.user, course, 'staff') + + return render_to_response('courseware/syllabus.html', {'course': course, + 'staff_access': staff_access,}) def registered_for_course(course, user): '''Return CourseEnrollment if user is registered for course, else False''' diff --git a/lms/envs/common.py b/lms/envs/common.py index 55282bbd6f..151bffaa32 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -55,6 +55,10 @@ MITX_FEATURES = { # course_ids (see dev_int.py for an example) 'SUBDOMAIN_COURSE_LISTINGS' : False, + # TODO: This will be removed once course-specific tabs are in place. see + # courseware/courses.py + 'ENABLE_SYLLABUS' : True, + 'ENABLE_TEXTBOOK' : True, 'ENABLE_DISCUSSION' : False, 'ENABLE_DISCUSSION_SERVICE': True, diff --git a/lms/static/sass/course.scss b/lms/static/sass/course.scss index d3a74cb91b..93296aead6 100644 --- a/lms/static/sass/course.scss +++ b/lms/static/sass/course.scss @@ -29,6 +29,7 @@ // pages @import "course/info"; +@import "course/syllabus"; // TODO arjun replace w/ custom tabs, see courseware/courses.py @import "course/textbook"; @import "course/profile"; @import "course/gradebook"; diff --git a/lms/static/sass/course/_syllabus.scss b/lms/static/sass/course/_syllabus.scss new file mode 100644 index 0000000000..2f2b9eedcd --- /dev/null +++ b/lms/static/sass/course/_syllabus.scss @@ -0,0 +1,64 @@ +div.syllabus { + + padding: 0px 10px; + + text-align: center; + + h1 { + @extend .top-header + } + + .notes { + width: 740px; + margin: 0px auto 10px; + } + + table { + + text-align: left; + + margin: 10px auto; + + thead { + font-weight: bold; + border-bottom: 1px solid black; + } + + tr.first { + td { + padding-top: 15px; + } + } + + td { + + vertical-align: middle; + + padding: 5px 10px; + + &.day, &.due { + white-space: nowrap; + } + + &.no_class { + text-align: center; + } + + &.important { + color: red; + } + + &.week_separator { + padding: 0px; + + hr { + margin: 10px; + } + + } + + } + + } + +} diff --git a/lms/templates/courseware/course_navigation.html b/lms/templates/courseware/course_navigation.html index 904b81517b..63fec53c4c 100644 --- a/lms/templates/courseware/course_navigation.html +++ b/lms/templates/courseware/course_navigation.html @@ -19,6 +19,9 @@ def url_class(url):