Skip to content

Commit

Permalink
#35 As a coach I can see and edit the json for the grading policy.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Rossi authored and cewing committed Jan 15, 2015
1 parent b72e5ea commit 8b9fdd6
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lms/djangoapps/pocs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def dashboard(request, course):
"""
poc = get_poc_for_coach(course, request.user)
schedule = get_poc_schedule(course, poc)
grading_policy = get_override_for_poc(poc, course, 'grading_policy',
course.grading_policy)
context = {
'course': course,
'poc': poc,
Expand All @@ -87,6 +89,9 @@ def dashboard(request, course):
kwargs={'course_id': course.id}),
'grades_csv_url': reverse('poc_grades_csv',
kwargs={'course_id': course.id}),
'grading_policy': json.dumps(grading_policy, indent=4),
'grading_policy_url': reverse('poc_set_grading_policy',
kwargs={'course_id': course.id}),
}
if not poc:
context['create_poc_url'] = reverse(
Expand Down Expand Up @@ -175,6 +180,21 @@ def override_fields(parent, data, earliest=None):
content_type='application/json')


@ensure_csrf_cookie
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
@coach_dashboard
def set_grading_policy(request, course):
"""
Set grading policy for the POC.
"""
poc = get_poc_for_coach(course, request.user)
override_field_for_poc(
poc, course, 'grading_policy', json.loads(request.POST['policy']))

url = reverse('poc_coach_dashboard', kwargs={'course_id': course.id})
return redirect(url)


def parse_date(datestring):
"""
Generate a UTC datetime.datetime object from a string of the form
Expand Down
6 changes: 6 additions & 0 deletions lms/templates/pocs/coach_dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ <h1>${_("POC Coach Dashboard")}</h1>
<li class="nav-item">
<a href="#" data-section="student_admin">${_("Student Admin")}</a>
</li>
<li class="nav-item">
<a href="#" data-section="grading_policy">${_("Grading Policy")}</a>
</li>
</ul>
<section id="membership" class="idash-section">
<%include file="enrollment.html" args="" />
Expand All @@ -52,6 +55,9 @@ <h1>${_("POC Coach Dashboard")}</h1>
<section id="student_admin" class="idash-section">
<%include file="student_admin.html" args="" />
</section>
<section id="grading_policy" class="idash-section">
<%include file="grading_policy.html" args="" />
</section>
%endif

</section>
Expand Down
10 changes: 10 additions & 0 deletions lms/templates/pocs/grading_policy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<%! from django.utils.translation import ugettext as _ %>

<h2>${_("Grading Policy")}</h2>

<form action="${grading_policy_url}" method="POST">
<input type="hidden" name="csrfmiddlewaretoken" value="${csrf_token}"/>
<textarea cols="80" style="height: 500px;"
name="policy">${grading_policy}</textarea><br/>
<button type="submit">${_("Save Grading Policy")}</button>
</form>
2 changes: 2 additions & 0 deletions lms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@
'pocs.views.poc_gradebook', name='poc_gradebook'),
url(r'^courses/{}/poc_grades.csv$'.format(settings.COURSE_ID_PATTERN),
'pocs.views.poc_grades_csv', name='poc_grades_csv'),
url(r'^courses/{}/poc_set_grading_policy$'.format(settings.COURSE_ID_PATTERN),
'pocs.views.set_grading_policy', name='poc_set_grading_policy'),
url(r'^courses/{}/set_course_mode_price$'.format(settings.COURSE_ID_PATTERN),
'instructor.views.instructor_dashboard.set_course_mode_price', name="set_course_mode_price"),
url(r'^courses/{}/instructor/api/'.format(settings.COURSE_ID_PATTERN),
Expand Down

0 comments on commit 8b9fdd6

Please sign in to comment.