From 66ed41dcd2fc650e1e7f02aa89147d6f1749ece2 Mon Sep 17 00:00:00 2001 From: Alex Dusenbery Date: Mon, 26 Nov 2018 16:46:19 -0500 Subject: [PATCH] Link to the writable gradebook if feature is enabled. --- .../tests/views/test_instructor_dashboard.py | 18 ++++++++++++++++++ .../instructor/views/instructor_dashboard.py | 5 +++++ lms/envs/aws.py | 3 +++ lms/envs/common.py | 5 +++++ lms/envs/production.py | 3 +++ .../instructor_dashboard_2/student_admin.html | 6 +++++- 6 files changed, 39 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py b/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py index 98bd965cc1..54fcaed5ce 100644 --- a/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py +++ b/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py @@ -19,8 +19,10 @@ from courseware.tabs import get_course_tab_list from courseware.tests.factories import StaffFactory, StudentModuleFactory, UserFactory from courseware.tests.helpers import LoginEnrollmentTestCase from edxmako.shortcuts import render_to_response +from lms.djangoapps.grades.config.waffle import waffle_flags, WRITABLE_GRADEBOOK from lms.djangoapps.instructor.views.gradebook_api import calculate_page_info from openedx.core.djangoapps.site_configuration.models import SiteConfiguration +from openedx.core.djangoapps.waffle_utils.testutils import override_waffle_flag from pyquery import PyQuery as pq from shoppingcart.models import CourseRegCodeItem, Order, PaidCourseRegistration from student.models import CourseEnrollment @@ -213,6 +215,22 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase, XssT self.assertNotIn('

Adjust all enrolled learners', response.content) self.assertIn('

View a specific learner's grades and progress', response.content) + @patch( + 'lms.djangoapps.instructor.views.instructor_dashboard.settings.WRITABLE_GRADEBOOK_URL', + 'http://gradebook.local.edx.org' + ) + def test_staff_can_see_writable_gradebook(self): + """ + Test that, when the writable gradebook featue is enabled, a staff member can see it. + """ + waffle_flag = waffle_flags()[WRITABLE_GRADEBOOK] + with override_waffle_flag(waffle_flag, active=True): + response = self.client.get(self.url) + + expected_gradebook_url = 'http://gradebook.local.edx.org/{}'.format(self.course.id) + self.assertIn(expected_gradebook_url, response.content) + self.assertIn('View Gradebook', response.content) + def test_default_currency_in_the_html_response(self): """ Test that checks the default currency_symbol ($) in the response diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index 2d51870c8c..6a7dbb389b 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -5,6 +5,7 @@ Instructor Dashboard Views import datetime import logging import uuid +from urlparse import urljoin import pytz from django.conf import settings @@ -20,6 +21,7 @@ from django.views.decorators.http import require_POST from mock import patch from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import CourseKey +from six import text_type from xblock.field_data import DictFieldData from xblock.fields import ScopeIds @@ -41,6 +43,7 @@ from django_comment_client.utils import available_division_schemes, has_forum_ac from django_comment_common.models import FORUM_ROLE_ADMINISTRATOR, CourseDiscussionSettings from edxmako.shortcuts import render_to_response from lms.djangoapps.courseware.module_render import get_module_by_usage_id +from lms.djangoapps.grades.config.waffle import waffle_flags, WRITABLE_GRADEBOOK from openedx.core.djangoapps.course_groups.cohorts import DEFAULT_COHORT_NAME, get_course_cohorts, is_course_cohorted from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers from openedx.core.djangoapps.verified_track_content.models import VerifiedTrackCohortedCourse @@ -588,6 +591,8 @@ def _section_student_admin(course, access): kwargs={'course_id': unicode(course_key)}), 'spoc_gradebook_url': reverse('spoc_gradebook', kwargs={'course_id': unicode(course_key)}), } + if waffle_flags()[WRITABLE_GRADEBOOK].is_enabled(course_key) and settings.WRITABLE_GRADEBOOK_URL: + section_data['writable_gradebook_url'] = urljoin(settings.WRITABLE_GRADEBOOK_URL, '/' + text_type(course_key)) return section_data diff --git a/lms/envs/aws.py b/lms/envs/aws.py index 85dc51f145..98285a4eba 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -1105,6 +1105,9 @@ RETIREMENT_STATES = ENV_TOKENS.get('RETIREMENT_STATES', RETIREMENT_STATES) ############## Settings for Course Enrollment Modes ###################### COURSE_ENROLLMENT_MODES = ENV_TOKENS.get('COURSE_ENROLLMENT_MODES', COURSE_ENROLLMENT_MODES) +############## Settings for Writable Gradebook ######################### +WRITABLE_GRADEBOOK_URL = ENV_TOKENS.get('WRITABLE_GRADEBOOK_URL', WRITABLE_GRADEBOOK_URL) + ############################### Plugin Settings ############################### # This is at the bottom because it is going to load more settings after base settings are loaded diff --git a/lms/envs/common.py b/lms/envs/common.py index e9580b614d..dab7b9a675 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -3488,6 +3488,11 @@ RETIREMENT_STATES = [ 'COMPLETE', ] +############## Settings for Writable Gradebook ######################### +# If running a Gradebook container locally, +# modify lms/envs/private.py to give it a non-null value +WRITABLE_GRADEBOOK_URL = None + ############### Settings for django-fernet-fields ################## FERNET_KEYS = [ 'DUMMY KEY CHANGE BEFORE GOING TO PRODUCTION', diff --git a/lms/envs/production.py b/lms/envs/production.py index 0dac57a254..7b24c7e377 100644 --- a/lms/envs/production.py +++ b/lms/envs/production.py @@ -1101,6 +1101,9 @@ RETIREMENT_STATES = ENV_TOKENS.get('RETIREMENT_STATES', RETIREMENT_STATES) ############## Settings for Course Enrollment Modes ###################### COURSE_ENROLLMENT_MODES = ENV_TOKENS.get('COURSE_ENROLLMENT_MODES', COURSE_ENROLLMENT_MODES) +############## Settings for Writable Gradebook ######################### +WRITABLE_GRADEBOOK_URL = ENV_TOKENS.get('WRITABLE_GRADEBOOK_URL', WRITABLE_GRADEBOOK_URL) + ############################### Plugin Settings ############################### # This is at the bottom because it is going to load more settings after base settings are loaded diff --git a/lms/templates/instructor/instructor_dashboard_2/student_admin.html b/lms/templates/instructor/instructor_dashboard_2/student_admin.html index ad47b85ef7..1d39167c60 100644 --- a/lms/templates/instructor/instructor_dashboard_2/student_admin.html +++ b/lms/templates/instructor/instructor_dashboard_2/student_admin.html @@ -2,13 +2,17 @@ <%! from django.utils.translation import ugettext as _ %> %if section_data['access']['staff'] or section_data['access']['instructor']:
- %if section_data['is_small_course']: + %if section_data.get('writable_gradebook_url') or section_data.get('is_small_course'):

${_("View gradebook for enrolled learners")}




+ %if section_data.get('writable_gradebook_url'): + ${_("View Gradebook")} + %elif section_data.get('is_small_course'): ${_("View Gradebook")} + %endif


%endif