Commit 5ab22ca4 by Adam

Merge pull request #2700 from edx/adam/i18n-instructor-tab

add i18n scraping to tabs.py (LMS-2166)
parents c9a4de60 8d2db056
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -7,8 +7,8 @@ msgid "" ...@@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 0.1a\n" "Project-Id-Version: 0.1a\n"
"Report-Msgid-Bugs-To: openedx-translation@googlegroups.com\n" "Report-Msgid-Bugs-To: openedx-translation@googlegroups.com\n"
"POT-Creation-Date: 2014-02-24 11:55-0500\n" "POT-Creation-Date: 2014-02-24 14:19-0500\n"
"PO-Revision-Date: 2014-02-24 16:55:44.121259\n" "PO-Revision-Date: 2014-02-24 19:20:10.799089\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: openedx-translation <openedx-translation@googlegroups.com>\n" "Language-Team: openedx-translation <openedx-translation@googlegroups.com>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
......
...@@ -27,6 +27,11 @@ from open_ended_grading import open_ended_notifications ...@@ -27,6 +27,11 @@ from open_ended_grading import open_ended_notifications
import waffle import waffle
# We only need to scrape strings for i18n in this file, since ugettext is
# called on them in the template:
# https://github.com/edx/edx-platform/blob/master/lms/templates/courseware/course_navigation.html#L29
_ = lambda text: text
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -63,9 +68,13 @@ def _courseware(tab, user, course, active_page, request): ...@@ -63,9 +68,13 @@ def _courseware(tab, user, course, active_page, request):
""" """
link = reverse('courseware', args=[course.id]) link = reverse('courseware', args=[course.id])
if waffle.flag_is_active(request, 'merge_course_tabs'): if waffle.flag_is_active(request, 'merge_course_tabs'):
return [CourseTab('Course Content', link, active_page == "courseware")] # Translators: 'Course Content' refers to the tab in the courseware
# that leads to the content of a course
return [CourseTab(_('Course Content'), link, active_page == "courseware")]
else: else:
return [CourseTab('Courseware', link, active_page == "courseware")] # Translators: 'Courseware' refers to the tab in the courseware
# that leads to the content of a course
return [CourseTab(_('Courseware'), link, active_page == "courseware")]
def _course_info(tab, user, course, active_page, request): def _course_info(tab, user, course, active_page, request):
...@@ -111,7 +120,9 @@ def _external_discussion(tab, user, course, active_page, request): ...@@ -111,7 +120,9 @@ def _external_discussion(tab, user, course, active_page, request):
""" """
This returns a tab that links to an external discussion service This returns a tab that links to an external discussion service
""" """
return [CourseTab('Discussion', tab['link'], active_page == 'discussion')] # Translators: 'Discussion' refers to the tab in the courseware
# that leads to the discussion forums
return [CourseTab(_('Discussion'), tab['link'], active_page == 'discussion')]
def _external_link(tab, user, course, active_page, request): def _external_link(tab, user, course, active_page, request):
...@@ -165,7 +176,9 @@ def _staff_grading(tab, user, course, active_page, request): ...@@ -165,7 +176,9 @@ def _staff_grading(tab, user, course, active_page, request):
if has_access(user, course, 'staff'): if has_access(user, course, 'staff'):
link = reverse('staff_grading', args=[course.id]) link = reverse('staff_grading', args=[course.id])
tab_name = "Staff grading" # Translators: "Staff grading" appears on a tab that allows
# staff to view openended problems that require staff grading
tab_name = _("Staff grading")
notifications = open_ended_notifications.staff_grading_notifications(course, user) notifications = open_ended_notifications.staff_grading_notifications(course, user)
pending_grading = notifications['pending_grading'] pending_grading = notifications['pending_grading']
...@@ -179,13 +192,16 @@ def _staff_grading(tab, user, course, active_page, request): ...@@ -179,13 +192,16 @@ def _staff_grading(tab, user, course, active_page, request):
def _syllabus(tab, user, course, active_page, request): def _syllabus(tab, user, course, active_page, request):
"""Display the syllabus tab""" """Display the syllabus tab"""
link = reverse('syllabus', args=[course.id]) link = reverse('syllabus', args=[course.id])
return [CourseTab('Syllabus', link, active_page == 'syllabus')] return [CourseTab(_('Syllabus'), link, active_page == 'syllabus')]
def _peer_grading(tab, user, course, active_page, request): def _peer_grading(tab, user, course, active_page, request):
if user.is_authenticated(): if user.is_authenticated():
link = reverse('peer_grading', args=[course.id]) link = reverse('peer_grading', args=[course.id])
tab_name = "Peer grading"
# Translators: "Peer grading" appears on a tab that allows
# students to view openended problems that require grading
tab_name = _("Peer grading")
notifications = open_ended_notifications.peer_grading_notifications(course, user) notifications = open_ended_notifications.peer_grading_notifications(course, user)
pending_grading = notifications['pending_grading'] pending_grading = notifications['pending_grading']
...@@ -199,7 +215,11 @@ def _peer_grading(tab, user, course, active_page, request): ...@@ -199,7 +215,11 @@ def _peer_grading(tab, user, course, active_page, request):
def _combined_open_ended_grading(tab, user, course, active_page, request): def _combined_open_ended_grading(tab, user, course, active_page, request):
if user.is_authenticated(): if user.is_authenticated():
link = reverse('open_ended_notifications', args=[course.id]) link = reverse('open_ended_notifications', args=[course.id])
tab_name = "Open Ended Panel"
# Translators: "Open Ended Panel" appears on a tab that, when clicked,
# opens up a panel that displays information about openended problems
# that a user has submitted or needs to grade
tab_name = _("Open Ended Panel")
notifications = open_ended_notifications.combined_notifications(course, user) notifications = open_ended_notifications.combined_notifications(course, user)
pending_grading = notifications['pending_grading'] pending_grading = notifications['pending_grading']
...@@ -216,17 +236,24 @@ def _notes_tab(tab, user, course, active_page, request): ...@@ -216,17 +236,24 @@ def _notes_tab(tab, user, course, active_page, request):
return [CourseTab(tab['name'], link, active_page == 'notes')] return [CourseTab(tab['name'], link, active_page == 'notes')]
return [] return []
def _instructor(course, active_page):
link = reverse('instructor_dashboard', args=[course.id])
# Translators: 'Instructor' appears on the tab that leads to
# the instructor dashboard, which is a portal where an instructor
# can get data and perform various actions on their course
return CourseTab(_('Instructor'), link, active_page == 'instructor')
#### Validators #### Validators
def key_checker(expected_keys): def key_checker(expected_keys):
""" """
Returns a function that checks that specified keys are present in a dict Returns a function that checks that specified keys are present in a dict
""" """
def check(d): def check(dictionary):
for k in expected_keys: for key in expected_keys:
if k not in d: if key not in dictionary:
raise InvalidTabsException("Key {0} not present in {1}" raise InvalidTabsException(
.format(k, d)) "Key {0} not present in {1}".format(key, dictionary)
)
return check return check
...@@ -259,7 +286,7 @@ VALID_TAB_TYPES = { ...@@ -259,7 +286,7 @@ VALID_TAB_TYPES = {
'open_ended': TabImpl(null_validator, _combined_open_ended_grading), 'open_ended': TabImpl(null_validator, _combined_open_ended_grading),
'notes': TabImpl(null_validator, _notes_tab), 'notes': TabImpl(null_validator, _notes_tab),
'syllabus': TabImpl(null_validator, _syllabus) 'syllabus': TabImpl(null_validator, _syllabus)
} }
### External interface below this. ### External interface below this.
...@@ -329,9 +356,7 @@ def get_course_tabs(user, course, active_page, request): ...@@ -329,9 +356,7 @@ def get_course_tabs(user, course, active_page, request):
# Instructor tab is special--automatically added if user is staff for the course # Instructor tab is special--automatically added if user is staff for the course
if has_access(user, course, 'staff'): if has_access(user, course, 'staff'):
tabs.append(CourseTab('Instructor', tabs.append(_instructor(course, active_page))
reverse('instructor_dashboard', args=[course.id]),
active_page == 'instructor'))
return tabs return tabs
...@@ -386,8 +411,7 @@ def get_default_tabs(user, course, active_page, request): ...@@ -386,8 +411,7 @@ def get_default_tabs(user, course, active_page, request):
tabs.extend(_progress({'name': 'Progress'}, user, course, active_page, request)) tabs.extend(_progress({'name': 'Progress'}, user, course, active_page, request))
if has_access(user, course, 'staff'): if has_access(user, course, 'staff'):
link = reverse('instructor_dashboard', args=[course.id]) tabs.append(_instructor(course, active_page))
tabs.append(CourseTab('Instructor', link, active_page == 'instructor'))
return tabs return tabs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment