Merge pull request #20367 from edx/dcs/ada-reason

Added a reason field for due date extensions
This commit is contained in:
Dave St.Germain
2019-05-02 14:27:07 -04:00
committed by GitHub
4 changed files with 27 additions and 16 deletions

View File

@@ -2856,7 +2856,9 @@ def change_due_date(request, course_id):
student = require_student_from_identifier(request.POST.get('student'))
unit = find_unit(course, request.POST.get('url'))
due_date = parse_datetime(request.POST.get('due_datetime'))
set_due_date_extension(course, unit, student, due_date, request.user)
reason = strip_tags(request.POST.get('reason', ''))
set_due_date_extension(course, unit, student, due_date, request.user, reason=reason)
return JsonResponse(_(
u'Successfully changed due date for student {0} for {1} '
@@ -2877,7 +2879,9 @@ def reset_due_date(request, course_id):
course = get_course_by_id(CourseKey.from_string(course_id))
student = require_student_from_identifier(request.POST.get('student'))
unit = find_unit(course, request.POST.get('url'))
set_due_date_extension(course, unit, student, None, request.user)
reason = strip_tags(request.POST.get('reason', ''))
set_due_date_extension(course, unit, student, None, request.user, reason=reason)
if not getattr(unit, "due", None):
# It's possible the normal due date was deleted after an extension was granted:
return JsonResponse(

View File

@@ -150,20 +150,20 @@ def title_or_url(node):
return title
def set_due_date_extension(course, unit, student, due_date, actor=None):
def set_due_date_extension(course, unit, student, due_date, actor=None, reason=''):
"""
Sets a due date extension. Raises DashboardError if the unit or extended
due date is invalid.
"""
if due_date:
try:
api.set_date_for_block(course.id, unit.location, 'due', due_date, user=student, reason=None, actor=actor)
api.set_date_for_block(course.id, unit.location, 'due', due_date, user=student, reason=reason, actor=actor)
except api.MissingDateError:
raise DashboardError(_(u"Unit {0} has no due date to extend.").format(unit.location))
except api.InvalidDateError:
raise DashboardError(_("An extended due date must be later than the original due date."))
else:
api.set_date_for_block(course.id, unit.location, 'due', None, user=student, reason=None, actor=actor)
api.set_date_for_block(course.id, unit.location, 'due', None, user=student, reason=reason, actor=actor)
def dump_module_extensions(course, unit):

View File

@@ -25,10 +25,13 @@
ext.$student_input = ext.$section.find("#set-extension input[name='student']");
ext.$url_input = ext.$section.find("#set-extension select[name='url']");
ext.$due_datetime_input = ext.$section.find("#set-extension input[name='due_datetime']");
ext.$reason_input = ext.$section.find("#set-extension input[name='reason']");
sendData = {
student: ext.$student_input.val(),
url: ext.$url_input.val(),
due_datetime: ext.$due_datetime_input.val()
due_datetime: ext.$due_datetime_input.val(),
reason: ext.$reason_input.val()
};
return $.ajax({
type: 'POST',
@@ -48,9 +51,12 @@
ext.clear_display();
ext.$student_input = ext.$section.find("#reset-extension input[name='student']");
ext.$url_input = ext.$section.find("#reset-extension select[name='url']");
ext.$reason_input = ext.$section.find("#reset-extension input[name='reason']");
sendData = {
student: ext.$student_input.val(),
url: ext.$url_input.val()
url: ext.$url_input.val(),
reason: ext.$reason_input.val()
};
return $.ajax({
type: 'POST',

View File

@@ -7,7 +7,7 @@ from django.utils.translation import ugettext as _
<h3 class="hd hd-3">${_("Individual due date extensions")}</h3>
<p>
${_("In this section, you have the ability to grant extensions on specific "
"units to individual students. Please note that the latest date is always "
"subsections to individual students. Please note that the latest date is always "
"taken; you cannot use this tool to make an assignment due earlier for a "
"particular student.")}
</p>
@@ -17,7 +17,7 @@ from django.utils.translation import ugettext as _
<input type="text" name="student" placeholder="${_("Student Email or Username")}">
</p>
<p>
${_("Choose the graded unit:")}
${_("Choose the graded subsection:")}
<select name="url">
<option value="">Choose one</option>
%for title, url in section_data['units_with_due_dates']:
@@ -30,7 +30,7 @@ from django.utils.translation import ugettext as _
## Translators: "format_string" is the string MM/DD/YYYY HH:MM, as that is the format the system requires.
${_("Specify the extension due date and time (in UTC; please specify {format_string}).").format(format_string=format_string)}</p>
<p><input type="text" name="due_datetime"
placeholder="${format_string}"/>
placeholder="${format_string}"/> <input type="text" name="reason" placeholder="${_('Reason for extension')}" size=40 />
</p>
<p class="request-response"></p>
<p class="request-response-error"></p>
@@ -45,14 +45,14 @@ from django.utils.translation import ugettext as _
<h3 class="hd hd-3">${_("Viewing granted extensions")}</h3>
<p>
${_("Here you can see what extensions have been granted on particular "
"units or for a particular student.")}
"subsection or for a particular student.")}
</p>
<p>
${_("Choose a graded unit and click the button to obtain a list of all "
"students who have extensions for the given unit.")}
${_("Choose a graded subsection and click the button to obtain a list of all "
"students who have extensions for the given subsection.")}
</p>
<p>
${_("Choose the graded unit:")}
${_("Choose the graded subsection:")}
<select name="url">
<option value="">Choose one</option>
%for title, url in section_data['units_with_due_dates']:
@@ -86,7 +86,7 @@ from django.utils.translation import ugettext as _
<h3 class="hd hd-3">${_("Resetting extensions")}</h3>
<p>
${_("Resetting a problem's due date rescinds a due date extension for a "
"student on a particular unit. This will revert the due date for the "
"student on a particular subsection. This will revert the due date for the "
"student back to the problem's original due date.")}
</p>
<p>
@@ -95,13 +95,14 @@ from django.utils.translation import ugettext as _
<input type="text" name="student" placeholder="${_("Student Email or Username")}">
</p>
<p>
${_("Choose the graded unit:")}
${_("Choose the graded subsection:")}
<select name="url">
<option value="">Choose one</option>
%for title, url in section_data['units_with_due_dates']:
<option value="${url}">${title}</option>
%endfor
</select>
<input type="text" name="reason" placeholder="${_('Reason for reset')}" size=40 />
</p>
<p class="request-response"></p>
<p class="request-response-error"></p>