Link to the writable gradebook if feature is enabled.

This commit is contained in:
Alex Dusenbery
2018-11-26 16:46:19 -05:00
committed by Alex Dusenbery
parent a7ab4be972
commit 66ed41dcd2
6 changed files with 39 additions and 1 deletions

View File

@@ -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('<h4 class="hd hd-4">Adjust all enrolled learners', response.content)
self.assertIn('<h4 class="hd hd-4">View a specific learner&#39;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

View File

@@ -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

View File

@@ -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

View File

@@ -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',

View File

@@ -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

View File

@@ -2,13 +2,17 @@
<%! from django.utils.translation import ugettext as _ %>
%if section_data['access']['staff'] or section_data['access']['instructor']:
<div class="action-type-container">
%if section_data['is_small_course']:
%if section_data.get('writable_gradebook_url') or section_data.get('is_small_course'):
<br><br>
<h4 class="hd hd-4">${_("View gradebook for enrolled learners")}</h4>
<br>
<label for="gradebook-link">${_("Note: This feature is available only to courses with a small number of enrolled learners.")}</label>
<br><br>
%if section_data.get('writable_gradebook_url'):
<span name="gradebook-link"><a href="${ section_data['writable_gradebook_url'] }" class="gradebook-link"> ${_("View Gradebook")} </a></span>
%elif section_data.get('is_small_course'):
<span name="gradebook-link"><a href="${ section_data['spoc_gradebook_url'] }" class="gradebook-link"> ${_("View Gradebook")} </a></span>
%endif
<br><br>
<hr>
%endif