Skip to content

Commit 60a6ddc

Browse files
gsideboshaidar
authored andcommitted
Reimplemented legacy dashboard enrollment data functionality
(cherry picked from commit 9987097) (cherry picked from commit 62cf6a4)
1 parent 567f1b5 commit 60a6ddc

File tree

23 files changed

+1364
-8
lines changed

23 files changed

+1364
-8
lines changed

lms/djangoapps/instructor/views/api.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@
7878
unenroll_email
7979
)
8080
from lms.djangoapps.instructor.views import INVOICE_KEY
81-
from lms.djangoapps.instructor.views.instructor_task_helpers import extract_email_features, extract_task_features
81+
from lms.djangoapps.instructor.views.instructor_task_helpers import (
82+
extract_email_features,
83+
extract_task_features,
84+
)
8285
from lms.djangoapps.instructor_task import api as task_api
8386
from lms.djangoapps.instructor_task.api_helper import AlreadyRunningError, QueueConnectionError
8487
from lms.djangoapps.instructor_task.models import ReportStore
@@ -148,7 +151,7 @@
148151
parse_datetime,
149152
require_student_from_identifier,
150153
set_due_date_extension,
151-
strip_if_string
154+
strip_if_string,
152155
)
153156

154157
log = logging.getLogger(__name__)
@@ -587,7 +590,9 @@ def create_and_enroll_user(email, username, name, country, password, course_id,
587590
except Exception as ex: # pylint: disable=broad-except
588591
log.exception(type(ex).__name__)
589592
errors.append({
590-
'username': username, 'email': email, 'response': type(ex).__name__,
593+
'username': username,
594+
'email': email,
595+
'response': type(ex).__name__
591596
})
592597
else:
593598
try:
@@ -2408,6 +2413,7 @@ def list_instructor_tasks(request, course_id):
24082413
- `problem_location_str` and `unique_student_identifier` lists task
24092414
history for problem AND student (intersection)
24102415
"""
2416+
include_remote_gradebook = request.GET.get('include_remote_gradebook') is not None
24112417
course_id = CourseKey.from_string(course_id)
24122418
problem_location_str = strip_if_string(request.POST.get('problem_location_str', False))
24132419
student = request.POST.get('unique_student_identifier', None)
@@ -2430,6 +2436,11 @@ def list_instructor_tasks(request, course_id):
24302436
else:
24312437
# Specifying for single problem's history
24322438
tasks = task_api.get_instructor_task_history(course_id, module_state_key)
2439+
elif include_remote_gradebook:
2440+
tasks = lms.djangoapps.instructor_task.api.get_running_instructor_rgb_tasks(
2441+
course_id,
2442+
user=request.user
2443+
)
24332444
else:
24342445
# If no problem or student, just get currently running tasks
24352446
tasks = task_api.get_running_instructor_tasks(course_id)

lms/djangoapps/instructor/views/instructor_dashboard.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ def instructor_dashboard_2(request, course_id):
146146
if access['data_researcher']:
147147
sections.append(_section_data_download(course, access))
148148

149+
if settings.FEATURES.get('ENABLE_INSTRUCTOR_REMOTE_GRADEBOOK_CONTROLS', False):
150+
sections.append(_section_remote_gradebook(course))
151+
149152
analytics_dashboard_message = None
150153
if show_analytics_dashboard_message(course_key) and (access['staff'] or access['instructor']):
151154
# Construct a URL to the external analytics dashboard
@@ -726,6 +729,57 @@ def _section_data_download(course, access):
726729
return section_data
727730

728731

732+
def _section_remote_gradebook(course):
733+
""" Provide data for the corresponding dashboard section """
734+
rg_course_setting = course.remote_gradebook or {}
735+
rg_name = rg_course_setting.get('name') or settings.REMOTE_GRADEBOOK.get('DEFAULT_NAME')
736+
section_data = {
737+
'section_key': 'remote_gradebook',
738+
'section_display_name': _('Remote Gradebook'),
739+
'course': course,
740+
'remote_gradebook_name': rg_name,
741+
'get_remote_gradebook_sections_url': reverse(
742+
'get_remote_gradebook_sections', kwargs={'course_id': unicode(course.id)}
743+
),
744+
'get_assignment_names_url': reverse(
745+
'get_assignment_names', kwargs={'course_id': unicode(course.id)}
746+
),
747+
'get_non_staff_enrollments_url': reverse(
748+
'get_non_staff_enrollments', kwargs={'course_id': unicode(course.id)}
749+
),
750+
'list_remote_enrolled_students_url': reverse(
751+
'list_remote_enrolled_students', kwargs={'course_id': unicode(course.id)}
752+
),
753+
'list_remote_students_in_section_url': reverse(
754+
'list_remote_students_in_section', kwargs={'course_id': unicode(course.id)}
755+
),
756+
'add_enrollments_using_remote_gradebook_url': reverse(
757+
'add_enrollments_using_remote_gradebook', kwargs={'course_id': unicode(course.id)}
758+
),
759+
'list_remote_assignments_url': reverse(
760+
'list_remote_assignments', kwargs={'course_id': unicode(course.id)}
761+
),
762+
'display_assignment_grades_url': reverse(
763+
'display_assignment_grades', kwargs={'course_id': unicode(course.id)}
764+
),
765+
'export_assignment_grades_to_rg_url': reverse(
766+
'export_assignment_grades_to_rg', kwargs={'course_id': unicode(course.id)}
767+
),
768+
'export_assignment_grades_csv_url': reverse(
769+
'export_assignment_grades_csv', kwargs={'course_id': unicode(course.id)}
770+
),
771+
'list_instructor_tasks_url': '{}?include_remote_gradebook=true'.format(
772+
reverse(
773+
'list_instructor_tasks', kwargs={'course_id': unicode(course.id)}
774+
)
775+
),
776+
'list_report_downloads_url': reverse(
777+
'list_report_downloads', kwargs={'course_id': unicode(course.id)}
778+
),
779+
}
780+
return section_data
781+
782+
729783
def null_applicable_aside_types(block): # pylint: disable=unused-argument
730784
"""
731785
get_aside method for monkey-patching into applicable_aside_types

lms/djangoapps/instructor_task/api.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
arguments.
77
88
"""
9-
9+
import datetime
1010

1111
import hashlib
1212
from collections import Counter
13+
from pytz import UTC
1314

1415
import six
1516
from celery.states import READY_STATES
@@ -42,8 +43,9 @@
4243
proctored_exam_results_csv,
4344
rescore_problem,
4445
reset_problem_attempts,
45-
send_bulk_course_email
46+
send_bulk_course_email,
4647
)
48+
from remote_gradebook.constants import RGB_TASK_TYPES
4749
from util import milestones_helpers
4850
from xmodule.modulestore.django import modulestore
4951

@@ -68,6 +70,24 @@ def get_running_instructor_tasks(course_id):
6870
return instructor_tasks.order_by('-id')
6971

7072

73+
def get_running_instructor_rgb_tasks(course_id, user):
74+
"""
75+
Returns a query of InstructorTask objects of running tasks for a given course
76+
including remote gradebook-specific tasks.
77+
"""
78+
instructor_tasks = get_running_instructor_tasks(course_id)
79+
now = datetime.datetime.now(UTC)
80+
rgb_tasks = InstructorTask.objects.filter(
81+
course_id=course_id,
82+
task_type__in=RGB_TASK_TYPES,
83+
updated__lte=now,
84+
updated__gte=now - datetime.timedelta(days=2),
85+
requester=user
86+
).order_by('-updated')[0:3]
87+
88+
return (instructor_tasks | rgb_tasks).distinct()
89+
90+
7191
def get_instructor_task_history(course_id, usage_key=None, student=None, task_type=None):
7292
"""
7393
Returns a query of InstructorTask objects of historical tasks for a given course,

lms/djangoapps/instructor_task/tasks_helper/misc.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,10 @@ def upload_ora2_data(
340340
TASK_LOG.info(u'%s, Task type: %s, Upload complete.', task_info_string, action_name)
341341

342342
return UPDATE_STATUS_SUCCEEDED
343+
344+
345+
def _progress_error(error_msg, task_progress):
346+
task_progress.failed = 1
347+
curr_step = {'step': error_msg}
348+
task_progress.update_task_state(extra_meta=curr_step)
349+
return UPDATE_STATUS_FAILED

lms/djangoapps/remote_gradebook/__init__.py

Whitespace-only changes.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
Remote Gradebook Application Configuration
3+
"""
4+
5+
from django.apps import AppConfig
6+
from openedx.core.constants import COURSE_ID_PATTERN
7+
from openedx.core.djangoapps.plugins.constants import ProjectType, SettingsType, PluginURLs, PluginSettings
8+
9+
10+
class RemoteGradebookConfig(AppConfig):
11+
"""
12+
Configuration class for Remote Gradebook Django app
13+
"""
14+
name = u'lms.djangoapps.remote_gradebook'
15+
16+
plugin_app = {
17+
PluginURLs.CONFIG: {
18+
ProjectType.LMS: {
19+
PluginURLs.NAMESPACE: u'',
20+
PluginURLs.REGEX: u'courses/{}/remote_gradebook/api/'.format(COURSE_ID_PATTERN),
21+
PluginURLs.RELATIVE_PATH: u'urls',
22+
}
23+
},
24+
PluginSettings.CONFIG: {
25+
ProjectType.LMS: {
26+
SettingsType.AWS: {PluginSettings.RELATIVE_PATH: u'settings.aws'},
27+
SettingsType.COMMON: {PluginSettings.RELATIVE_PATH: u'settings.common'},
28+
}
29+
}
30+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""
2+
Remote gradebook constants
3+
"""
4+
5+
TASK_TYPE_RGB_EXPORT_GRADES = "export_grades_to_rgb"
6+
TASK_TYPE_RGB_EXPORT_ASSIGNMENT_GRADES = "export_assignment_grades_csv"
7+
RGB_TASK_TYPES = [
8+
TASK_TYPE_RGB_EXPORT_GRADES,
9+
TASK_TYPE_RGB_EXPORT_ASSIGNMENT_GRADES
10+
]

lms/djangoapps/remote_gradebook/settings/__init__.py

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""AWS settings unique to the remote gradebook plugin."""
2+
3+
4+
def plugin_settings(settings):
5+
"""Settings for the remote gradebook plugin."""
6+
settings.REMOTE_GRADEBOOK = settings.ENV_TOKENS.get(
7+
"REMOTE_GRADEBOOK", settings.REMOTE_GRADEBOOK
8+
)
9+
settings.REMOTE_GRADEBOOK_USER = settings.AUTH_TOKENS.get(
10+
"REMOTE_GRADEBOOK_USER", settings.REMOTE_GRADEBOOK_USER
11+
)
12+
settings.REMOTE_GRADEBOOK_PASSWORD = settings.AUTH_TOKENS.get(
13+
"REMOTE_GRADEBOOK_PASSWORD", settings.REMOTE_GRADEBOOK_PASSWORD
14+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""Common settings unique to the remote gradebook plugin."""
2+
3+
4+
def plugin_settings(settings):
5+
"""Settings for the remote gradebook plugin."""
6+
settings.REMOTE_GRADEBOOK = {}
7+
settings.REMOTE_GRADEBOOK_USER = None
8+
settings.REMOTE_GRADEBOOK_PASSWORD = None
9+
settings.FEATURES['ENABLE_INSTRUCTOR_REMOTE_GRADEBOOK_CONTROLS'] = False

0 commit comments

Comments
 (0)