Commit 197f9015 by Adam Palay

disable buttons for large courses on legacy and beta instr dash

set max enrollment for downloads to 200
parent 4bb9dcf1
...@@ -9,6 +9,7 @@ from mitxmako.shortcuts import render_to_response ...@@ -9,6 +9,7 @@ from mitxmako.shortcuts import render_to_response
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.utils.html import escape from django.utils.html import escape
from django.http import Http404 from django.http import Http404
from django.conf import settings
from courseware.access import has_access from courseware.access import has_access
from courseware.courses import get_course_by_id from courseware.courses import get_course_by_id
...@@ -45,10 +46,19 @@ def instructor_dashboard_2(request, course_id): ...@@ -45,10 +46,19 @@ def instructor_dashboard_2(request, course_id):
_section_analytics(course_id), _section_analytics(course_id),
] ]
enrollment_count = sections[0]['enrollment_count']
disable_buttons = False
max_enrollment_for_buttons = settings.MITX_FEATURES.get("MAX_ENROLLMENT_INSTR_BUTTONS")
if max_enrollment_for_buttons is not None:
disable_buttons = enrollment_count > max_enrollment_for_buttons
context = { context = {
'course': course, 'course': course,
'old_dashboard_url': reverse('instructor_dashboard', kwargs={'course_id': course_id}), 'old_dashboard_url': reverse('instructor_dashboard', kwargs={'course_id': course_id}),
'sections': sections, 'sections': sections,
'disable_buttons': disable_buttons,
} }
return render_to_response('instructor/instructor_dashboard_2/instructor_dashboard_2.html', context) return render_to_response('instructor/instructor_dashboard_2/instructor_dashboard_2.html', context)
......
...@@ -105,12 +105,15 @@ def instructor_dashboard(request, course_id): ...@@ -105,12 +105,15 @@ def instructor_dashboard(request, course_id):
else: else:
idash_mode = request.session.get('idash_mode', 'Grades') idash_mode = request.session.get('idash_mode', 'Grades')
enrollment_number = CourseEnrollment.objects.filter(course_id=course_id, is_active=1).count()
# assemble some course statistics for output to instructor # assemble some course statistics for output to instructor
def get_course_stats_table(): def get_course_stats_table():
datatable = {'header': ['Statistic', 'Value'], datatable = {
'header': ['Statistic', 'Value'],
'title': _u('Course Statistics At A Glance'), 'title': _u('Course Statistics At A Glance'),
} }
data = [['# Enrolled', CourseEnrollment.objects.filter(course_id=course_id, is_active=1).count()]] data = [['# Enrolled', enrollment_number]]
data += [['Date', timezone.now().isoformat()]] data += [['Date', timezone.now().isoformat()]]
data += compute_course_stats(course).items() data += compute_course_stats(course).items()
if request.user.is_staff: if request.user.is_staff:
...@@ -832,10 +835,17 @@ def instructor_dashboard(request, course_id): ...@@ -832,10 +835,17 @@ def instructor_dashboard(request, course_id):
if not datatable: if not datatable:
course_stats = get_course_stats_table() course_stats = get_course_stats_table()
# disable buttons for large courses
disable_buttons = False
max_enrollment_for_buttons = settings.MITX_FEATURES.get("MAX_ENROLLMENT_INSTR_BUTTONS")
if max_enrollment_for_buttons is not None:
disable_buttons = enrollment_number > max_enrollment_for_buttons
#---------------------------------------- #----------------------------------------
# context for rendering # context for rendering
context = {'course': course, context = {
'course': course,
'staff_access': True, 'staff_access': True,
'admin_access': request.user.is_staff, 'admin_access': request.user.is_staff,
'instructor_access': instructor_access, 'instructor_access': instructor_access,
...@@ -860,6 +870,7 @@ def instructor_dashboard(request, course_id): ...@@ -860,6 +870,7 @@ def instructor_dashboard(request, course_id):
'cohorts_ajax_url': reverse('cohorts', kwargs={'course_id': course_id}), 'cohorts_ajax_url': reverse('cohorts', kwargs={'course_id': course_id}),
'analytics_results': analytics_results, 'analytics_results': analytics_results,
'disable_buttons': disable_buttons
} }
if settings.MITX_FEATURES.get('ENABLE_INSTRUCTOR_BETA_DASHBOARD'): if settings.MITX_FEATURES.get('ENABLE_INSTRUCTOR_BETA_DASHBOARD'):
......
...@@ -182,6 +182,10 @@ MITX_FEATURES = { ...@@ -182,6 +182,10 @@ MITX_FEATURES = {
# Automatically approve student identity verification attempts # Automatically approve student identity verification attempts
'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING': False, 'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING': False,
# Disable instructor dash buttons for downloading course data
# when enrollment exceeds this number
'MAX_ENROLLMENT_INSTR_BUTTONS': 200,
} }
# Used for A/B testing # Used for A/B testing
......
...@@ -150,31 +150,46 @@ function goto( mode) ...@@ -150,31 +150,46 @@ function goto( mode)
<input type='checkbox' name='use_offline_grades' value='${_("yes")}'></font> </p> <input type='checkbox' name='use_offline_grades' value='${_("yes")}'></font> </p>
%endif %endif
<hr width="40%" style="align:left">
<h2>${_("Grade Downloads")}</h2>
% if disable_buttons:
<p><font color="red">
${_("Note: some of these buttons are known to time out for larger "
"courses. We have temporarily disabled those features for courses "
"with more than {max_enrollment} students. We are urgently working on "
"fixing this issue. Thank you for your patience as we continue "
"working to improve the platform!").format(
max_enrollment=settings.MITX_FEATURES['MAX_ENROLLMENT_INSTR_BUTTONS']
)}
</font></p>
% endif
<p> <p>
<a href="${reverse('gradebook', kwargs=dict(course_id=course.id))}">${_("Gradebook")}</a> <a href="${reverse('gradebook', kwargs=dict(course_id=course.id))}" class="${'is-disabled' if disable_buttons else ''}">${_("Gradebook")}</a>
</p> </p>
<p> <p>
<a href="${reverse('grade_summary', kwargs=dict(course_id=course.id))}">${_("Grade summary")}</a> <a href="${reverse('grade_summary', kwargs=dict(course_id=course.id))}" class="${'is-disabled' if disable_buttons else ''}">${_("Grade summary")}</a>
</p> </p>
<p> <p>
<input type="submit" name="action" value="Dump list of enrolled students"> <input type="submit" name="action" value="Dump list of enrolled students" class="${'is-disabled' if disable_buttons else ''}">
</p> </p>
<p> <p>
<input type="submit" name="action" value="Dump Grades for all students in this course"> <input type="submit" name="action" value="Dump Grades for all students in this course" class="${'is-disabled' if disable_buttons else ''}">
<input type="submit" name="action" value="Download CSV of all student grades for this course"> <input type="submit" name="action" value="Download CSV of all student grades for this course" class="${'is-disabled' if disable_buttons else ''}">
</p> </p>
<p> <p>
<input type="submit" name="action" value="Dump all RAW grades for all students in this course"> <input type="submit" name="action" value="Dump all RAW grades for all students in this course" class="${'is-disabled' if disable_buttons else ''}">
<input type="submit" name="action" value="Download CSV of all RAW grades"> <input type="submit" name="action" value="Download CSV of all RAW grades" class="${'is-disabled' if disable_buttons else ''}">
</p> </p>
<p> <p>
<input type="submit" name="action" value="Download CSV of answer distributions"> <input type="submit" name="action" value="Download CSV of answer distributions" class="${'is-disabled' if disable_buttons else ''}">
<input type="submit" name="action" value="Dump description of graded assignments configuration"> <input type="submit" name="action" value="Dump description of graded assignments configuration" class="${'is-disabled' if disable_buttons else ''}">
</p> </p>
<hr width="40%" style="align:left"> <hr width="40%" style="align:left">
...@@ -369,9 +384,22 @@ function goto( mode) ...@@ -369,9 +384,22 @@ function goto( mode)
%if modeflag.get('Enrollment'): %if modeflag.get('Enrollment'):
<hr width="40%" style="align:left"> <hr width="40%" style="align:left">
<p> <h2>${_("Enrollment Data")}</h2>
<input type="submit" name="action" value="List enrolled students"> % if disable_buttons:
<input type="submit" name="action" value="List students who may enroll but may not have yet signed up"> <p><font color="red">
${_("Note: some of these buttons are known to time out for larger "
"courses. We have temporarily disabled those features for courses "
"with more than {max_enrollment} students. We are urgently working on "
"fixing this issue. Thank you for your patience as we continue "
"working to improve the platform!").format(
max_enrollment=settings.MITX_FEATURES['MAX_ENROLLMENT_INSTR_BUTTONS']
)}
</font></p>
<br>
% endif
<input type="submit" name="action" value="List enrolled students" class="${'is-disabled' if disable_buttons else ''}">
<input type="submit" name="action" value="List students who may enroll but may not have yet signed up" class="${'is-disabled' if disable_buttons else ''}">
<hr width="40%" style="align:left"> <hr width="40%" style="align:left">
%if settings.MITX_FEATURES.get('REMOTE_GRADEBOOK_URL','') and instructor_access: %if settings.MITX_FEATURES.get('REMOTE_GRADEBOOK_URL','') and instructor_access:
...@@ -392,7 +420,7 @@ function goto( mode) ...@@ -392,7 +420,7 @@ function goto( mode)
<hr width="40%" style="align:left"> <hr width="40%" style="align:left">
%endif %endif
<h2>${_("Batch Enrollment")}</h2>
<p>${_("Enroll or un-enroll one or many students: enter emails, separated by new lines or commas;")}</p> <p>${_("Enroll or un-enroll one or many students: enter emails, separated by new lines or commas;")}</p>
<textarea rows="6" cols="70" name="multiple_students"></textarea> <textarea rows="6" cols="70" name="multiple_students"></textarea>
<p> <p>
......
<%! from django.utils.translation import ugettext as _ %> <%! from django.utils.translation import ugettext as _ %>
<%page args="section_data"/> <%page args="section_data"/>
<input type="button" name="list-profiles" value="${_("List enrolled students with profile information")}" data-endpoint="${ section_data['get_students_features_url'] }" >
<input type="button" name="list-profiles" value="CSV" data-csv="true" class="csv" data-endpoint="${ section_data['get_students_features_url'] }" > <h2>${_("Data Download")}</h2>
% if disable_buttons:
<p><font color="red">
${_("Note: some of these buttons are known to time out for larger "
"courses. We have temporarily disabled those features for courses "
"with more than {max_enrollment} students. We are urgently working on "
"fixing this issue. Thank you for your patience as we continue "
"working to improve the platform!").format(
max_enrollment=settings.MITX_FEATURES['MAX_ENROLLMENT_INSTR_BUTTONS']
)}
</font></p>
<br>
% endif
<input type="button" name="list-profiles" value="${_("List enrolled students with profile information")}" data-endpoint="${ section_data['get_students_features_url'] }" class="${'is-disabled' if disable_buttons else ''}">
<input type="button" name="list-profiles" value="CSV" data-csv="true" class="csv ${'is-disabled' if disable_buttons else ''}" data-endpoint="${ section_data['get_students_features_url'] }" >
<br> <br>
## <input type="button" name="list-grades" value="Student grades"> ## <input type="button" name="list-grades" value="Student grades">
## <input type="button" name="list-profiles" value="CSV" data-csv="true" class="csv"> ## <input type="button" name="list-profiles" value="CSV" data-csv="true" class="csv">
...@@ -10,8 +25,7 @@ ...@@ -10,8 +25,7 @@
## <input type="button" name="list-answer-distributions" value="Answer distributions (x students got y points)"> ## <input type="button" name="list-answer-distributions" value="Answer distributions (x students got y points)">
## <br> ## <br>
<input type="button" name="dump-gradeconf" value="${_("Grading Configuration")}" data-endpoint="${ section_data['get_grading_config_url'] }"> <input type="button" name="dump-gradeconf" value="${_("Grading Configuration")}" data-endpoint="${ section_data['get_grading_config_url'] }">
<input type="button" name="list-anon-ids" value="${_("Get Student Anonymized IDs CSV")}" data-csv="true" class="csv" data-endpoint="${ section_data['get_anon_ids_url'] }"> <input type="button" name="list-anon-ids" value="${_("Get Student Anonymized IDs CSV")}" data-csv="true" class="csv" data-endpoint="${ section_data['get_anon_ids_url'] }" class="${'is-disabled' if disable_buttons else ''}">
<div class="data-display"> <div class="data-display">
<div class="data-display-text"></div> <div class="data-display-text"></div>
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
%if settings.MITX_FEATURES.get('ENABLE_INSTRUCTOR_BACKGROUND_TASKS') and section_data['access']['instructor']: %if settings.MITX_FEATURES.get('ENABLE_INSTRUCTOR_BACKGROUND_TASKS') and section_data['access']['instructor']:
<div class="course-specific-container action-type-container"> <div class="course-specific-container action-type-container">
<H2>${_('Course-specific grade adjustment')}</h2> <h2>${_('Course-specific grade adjustment')}</h2>
<div class="request-response-error"></div> <div class="request-response-error"></div>
<p> <p>
......
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