diff --git a/lms/djangoapps/instructor/views/legacy.py b/lms/djangoapps/instructor/views/legacy.py index 12b0d6f9f7..6f26e13fe7 100644 --- a/lms/djangoapps/instructor/views/legacy.py +++ b/lms/djangoapps/instructor/views/legacy.py @@ -60,7 +60,7 @@ from student.views import course_from_id import track.views from xblock.field_data import DictFieldData from xblock.fields import ScopeIds -from django.utils.translation import ugettext as _u +from django.utils.translation import ugettext as _ from microsite_configuration import microsite @@ -115,7 +115,7 @@ def instructor_dashboard(request, course_id): def get_course_stats_table(): datatable = { 'header': ['Statistic', 'Value'], - 'title': _u('Course Statistics At A Glance'), + 'title': _('Course Statistics At A Glance'), } data = [['# Enrolled', enrollment_number]] data += [['Date', timezone.now().isoformat()]] @@ -184,11 +184,11 @@ def instructor_dashboard(request, course_id): student = User.objects.get(email=unique_student_identifier) else: student = User.objects.get(username=unique_student_identifier) - msg += _u("Found a single student. ") + msg += _("Found a single student. ") except User.DoesNotExist: student = None msg += "{text}".format( - text=_u("Couldn't find student with that email or username.") + text=_("Couldn't find student with that email or username.") ) return msg, student @@ -227,20 +227,20 @@ def instructor_dashboard(request, course_id): if action == 'Dump list of enrolled students' or action == 'List enrolled students': log.debug(action) datatable = get_student_grade_summary_data(request, course, course_id, get_grades=False, use_offline=use_offline) - datatable['title'] = _u('List of students enrolled in {0}').format(course_id) + datatable['title'] = _('List of students enrolled in {0}').format(course_id) track.views.server_track(request, "list-students", {}, page="idashboard") elif 'Dump Grades' in action: log.debug(action) datatable = get_student_grade_summary_data(request, course, course_id, get_grades=True, use_offline=use_offline) - datatable['title'] = _u('Summary Grades of students enrolled in {0}').format(course_id) + datatable['title'] = _('Summary Grades of students enrolled in {0}').format(course_id) track.views.server_track(request, "dump-grades", {}, page="idashboard") elif 'Dump all RAW grades' in action: log.debug(action) datatable = get_student_grade_summary_data(request, course, course_id, get_grades=True, get_raw_scores=True, use_offline=use_offline) - datatable['title'] = _u('Raw Grades of students enrolled in {0}').format(course_id) + datatable['title'] = _('Raw Grades of students enrolled in {0}').format(course_id) track.views.server_track(request, "dump-grades-raw", {}, page="idashboard") elif 'Download CSV of all student grades' in action: @@ -269,18 +269,18 @@ def instructor_dashboard(request, course_id): instructor_task = submit_rescore_problem_for_all_students(request, course_id, problem_url) if instructor_task is None: msg += '{text}'.format( - text=_u('Failed to create a background task for rescoring "{0}".').format(problem_url) + text=_('Failed to create a background task for rescoring "{0}".').format(problem_url) ) else: track.views.server_track(request, "rescore-all-submissions", {"problem": problem_url, "course": course_id}, page="idashboard") except ItemNotFoundError as err: msg += '{text}'.format( - text=_u('Failed to create a background task for rescoring "{0}": problem not found.').format(problem_url) + text=_('Failed to create a background task for rescoring "{0}": problem not found.').format(problem_url) ) except Exception as err: log.error("Encountered exception from rescore: {0}".format(err)) msg += '{text}'.format( - text=_u('Failed to create a background task for rescoring "{url}": {message}.').format( + text=_('Failed to create a background task for rescoring "{url}": {message}.').format( url=problem_url, message=err.message ) ) @@ -292,19 +292,19 @@ def instructor_dashboard(request, course_id): instructor_task = submit_reset_problem_attempts_for_all_students(request, course_id, problem_url) if instructor_task is None: msg += '{text}'.format( - text=_u('Failed to create a background task for resetting "{0}".').format(problem_url) + text=_('Failed to create a background task for resetting "{0}".').format(problem_url) ) else: track.views.server_track(request, "reset-all-attempts", {"problem": problem_url, "course": course_id}, page="idashboard") except ItemNotFoundError as err: log.error('Failure to reset: unknown problem "{0}"'.format(err)) msg += '{text}'.format( - text=_u('Failed to create a background task for resetting "{0}": problem not found.').format(problem_url) + text=_('Failed to create a background task for resetting "{0}": problem not found.').format(problem_url) ) except Exception as err: log.error("Encountered exception from reset: {0}".format(err)) msg += '{text}'.format( - text=_u('Failed to create a background task for resetting "{url}": {message}.').format( + text=_('Failed to create a background task for resetting "{url}": {message}.').format( url=problem_url, message=err.message ) ) @@ -348,9 +348,9 @@ def instructor_dashboard(request, course_id): course_id=course_id, module_state_key=module_state_key ) - msg += _u("Found module. ") + msg += _("Found module. ") except StudentModule.DoesNotExist as err: - error_msg = _u("Couldn't find module with that urlname: {url}. ").format(url=problem_urlname) + error_msg = _("Couldn't find module with that urlname: {url}. ").format(url=problem_urlname) msg += "{err_msg} ({err})".format(err_msg=error_msg, err=err) log.debug(error_msg) @@ -360,7 +360,7 @@ def instructor_dashboard(request, course_id): try: student_module.delete() msg += "{text}".format( - text=_u("Deleted student module state for {state}!").format(state=module_state_key) + text=_("Deleted student module state for {state}!").format(state=module_state_key) ) event = { "problem": module_state_key, @@ -374,7 +374,7 @@ def instructor_dashboard(request, course_id): page="idashboard" ) except Exception as err: - error_msg = _u("Failed to delete module state for {id}/{url}. ").format( + error_msg = _("Failed to delete module state for {id}/{url}. ").format( id=unique_student_identifier, url=problem_urlname ) msg += "{err_msg} ({err})".format(err_msg=error_msg, err=err) @@ -398,10 +398,10 @@ def instructor_dashboard(request, course_id): } track.views.server_track(request, "reset-student-attempts", event, page="idashboard") msg += "{text}".format( - text=_u("Module state successfully reset!") + text=_("Module state successfully reset!") ) except Exception as err: - error_msg = _u("Couldn't reset module state for {id}/{url}. ").format( + error_msg = _("Couldn't reset module state for {id}/{url}. ").format( id=unique_student_identifier, url=problem_urlname ) msg += "{err_msg} ({err})".format(err_msg=error_msg, err=err) @@ -412,7 +412,7 @@ def instructor_dashboard(request, course_id): instructor_task = submit_rescore_problem_for_student(request, course_id, module_state_key, student) if instructor_task is None: msg += '{text}'.format( - text=_u('Failed to create a background task for rescoring "{key}" for student {id}.').format( + text=_('Failed to create a background task for rescoring "{key}" for student {id}.').format( key=module_state_key, id=unique_student_identifier ) ) @@ -420,7 +420,7 @@ def instructor_dashboard(request, course_id): track.views.server_track(request, "rescore-student-submission", {"problem": module_state_key, "student": unique_student_identifier, "course": course_id}, page="idashboard") except Exception as err: msg += '{text}'.format( - text=_u('Failed to create a background task for rescoring "{key}": {id}.').format( + text=_('Failed to create a background task for rescoring "{key}": {id}.').format( key=module_state_key, id=err.message ) ) @@ -439,7 +439,7 @@ def instructor_dashboard(request, course_id): track.views.server_track(request, "get-student-progress-page", {"student": unicode(student), "instructor": unicode(request.user), "course": course_id}, page="idashboard") msg += "{text}.".format( url=progress_url, - text=_u("Progress page for username: {username} with email address: {email}").format( + text=_("Progress page for username: {username} with email address: {email}").format( username=student.username, email=student.email ) ) @@ -456,7 +456,7 @@ def instructor_dashboard(request, course_id): allgrades = get_student_grade_summary_data(request, course, course_id, get_grades=True, use_offline=use_offline) assignments = [[x] for x in allgrades['assignments']] - datatable = {'header': [_u('Assignment Name')]} + datatable = {'header': [_('Assignment Name')]} datatable['data'] = assignments datatable['title'] = action @@ -480,16 +480,16 @@ def instructor_dashboard(request, course_id): datatable = {} aname = request.POST.get('assignment_name', '') if not aname: - msg += "{text}".format(text=_u("Please enter an assignment name")) + msg += "{text}".format(text=_("Please enter an assignment name")) else: allgrades = get_student_grade_summary_data(request, course, course_id, get_grades=True, use_offline=use_offline) if aname not in allgrades['assignments']: msg += "{text}".format( - text=_u("Invalid assignment name '{name}'").format(name=aname) + text=_("Invalid assignment name '{name}'").format(name=aname) ) else: aidx = allgrades['assignments'].index(aname) - datatable = {'header': [_u('External email'), aname]} + datatable = {'header': [_('External email'), aname]} ddata = [] for x in allgrades['students']: # do one by one in case there is a student who has only partial grades try: @@ -500,7 +500,7 @@ def instructor_dashboard(request, course_id): ) datatable['data'] = ddata - datatable['title'] = _u('Grades for assignment "{name}"').format(name=aname) + datatable['title'] = _('Grades for assignment "{name}"').format(name=aname) if 'Export CSV' in action: # generate and return CSV file @@ -511,7 +511,7 @@ def instructor_dashboard(request, course_id): return_csv('', datatable, file_pointer=file_pointer) file_pointer.seek(0) files = {'datafile': file_pointer} - msg2, _ = _do_remote_gradebook(request.user, course, 'post-grades', files=files) + msg2, __ = _do_remote_gradebook(request.user, course, 'post-grades', files=files) msg += msg2 #---------------------------------------- @@ -519,12 +519,12 @@ def instructor_dashboard(request, course_id): elif 'List course staff' in action: role = CourseStaffRole(course.location) - datatable = _role_members_table(role, _u("List of Staff"), course_id) + datatable = _role_members_table(role, _("List of Staff"), course_id) track.views.server_track(request, "list-staff", {}, page="idashboard") elif 'List course instructors' in action and GlobalStaff().has_user(request.user): role = CourseInstructorRole(course.location) - datatable = _role_members_table(role, _u("List of Instructors"), course_id) + datatable = _role_members_table(role, _("List of Instructors"), course_id) track.views.server_track(request, "list-instructors", {}, page="idashboard") elif action == 'Add course staff': @@ -564,7 +564,7 @@ def instructor_dashboard(request, course_id): return [u.username, u.email] + [getattr(p, x, '') for x in profkeys] datatable['data'] = [getdat(u) for u in enrolled_students] - datatable['title'] = _u('Student profile data for course {course_id}').format(course_id = course_id) + datatable['title'] = _('Student profile data for course {course_id}').format(course_id = course_id) return return_csv('profiledata_{course_id}.csv'.format(course_id = course_id), datatable) elif 'Download CSV of all responses to problem' in action: @@ -580,10 +580,10 @@ def instructor_dashboard(request, course_id): module_state_key=module_state_key ) smdat = smdat.order_by('student') - msg += _u("Found {num} records to dump.").format(num=smdat) + msg += _("Found {num} records to dump.").format(num=smdat) except Exception as err: msg += "{text}
{err}".format(
- text=_u("Couldn't find module with that urlname."),
+ text=_("Couldn't find module with that urlname."),
err=escape(err)
)
smdat = []
@@ -591,7 +591,7 @@ def instructor_dashboard(request, course_id):
if smdat:
datatable = {'header': ['username', 'state']}
datatable['data'] = [[x.student.username, x.state] for x in smdat]
- datatable['title'] = _u('Student state for problem {problem}').format(problem = problem_to_dump)
+ datatable['title'] = _('Student state for problem {problem}').format(problem = problem_to_dump)
return return_csv('student_state_from_{problem}.csv'.format(problem = problem_to_dump), datatable)
elif 'Download CSV of all student anonymized IDs' in action:
@@ -608,7 +608,7 @@ def instructor_dashboard(request, course_id):
elif 'List beta testers' in action:
role = CourseBetaTesterRole(course.location)
- datatable = _role_members_table(role, _u("List of Beta Testers"), course_id)
+ datatable = _role_members_table(role, _("List of Beta Testers"), course_id)
track.views.server_track(request, "list-beta-testers", {}, page="idashboard")
elif action == 'Add beta testers':
@@ -747,14 +747,14 @@ def instructor_dashboard(request, course_id):
else:
# If sending the task succeeds, deliver a success message to the user.
if email_to_option == "all":
- text = _u(
+ text = _(
"Your email was successfully queued for sending. "
"Please note that for large classes, it may take up to an hour "
"(or more, if other courses are simultaneously sending email) "
"to send all emails."
)
else:
- text = _u('Your email was successfully queued for sending.')
+ text = _('Your email was successfully queued for sending.')
email_msg = '{text}