Skip to content

Commit

Permalink
#12 add support for roles and workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Rossi committed Jul 17, 2014
1 parent 4b3605c commit b7938d7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
24 changes: 22 additions & 2 deletions edx_sga/sga.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ class StaffGradedAssignmentXBlock(XBlock):
scope=Scope.user_state
)

score_approved = Boolean(
display_name="Whether the score has been approved by an instructor",
help=("Course staff may submit grades but an instructor must approve "
"grades before they become visible."),
default=False,
scope=Scope.user_state
)

comment = String(
display_name="Instructor comment",
default='',
Expand Down Expand Up @@ -192,7 +200,7 @@ def student_state(self):
else:
annotated = None

if self.score is not None:
if self.score is not None and self.score_approved:
graded = {'score': self.score, 'comment': self.comment}
else:
graded = None
Expand All @@ -209,14 +217,21 @@ def student_state(self):
def staff_grading_data(self):
def get_student_data(module):
state = json.loads(module.state)
instructor = self.is_instructor()
score = state.get('score')
approved = state.get('score_approved')
return {
'module_id': module.id,
'username': module.student.username,
'fullname': module.student.profile.name,
'filename': state.get("uploaded_filename"),
'timestamp': state.get("uploaded_timestamp"),
'published': state.get("score_published"),
'score': state.get("score"),
'score': score,
'approved': approved,
'needs_approval': instructor and score is not None
and not approved,
'may_grade': instructor or not approved,
'annotated': state.get("annotated_filename"),
'comment': state.get("comment", ''),
}
Expand Down Expand Up @@ -387,6 +402,7 @@ def enter_grade(self, request, suffix=''):
state['score'] = float(request.params['grade'])
state['comment'] = request.params.get('comment', '')
state['score_published'] = False # see student_view
state['score_approved'] = self.is_instructor()
module.state = json.dumps(state)

# This is how we'd like to do it. See student_view
Expand All @@ -407,6 +423,7 @@ def remove_grade(self, request, suffix=''):
state['score'] = None
state['comment'] = ''
state['score_published'] = False # see student_view
state['score_approved'] = False
state['annotated_sha1'] = None
state['annotated_filename'] = None
state['annotated_mimetype'] = None
Expand All @@ -418,6 +435,9 @@ def remove_grade(self, request, suffix=''):
def is_course_staff(self):
return getattr(self.xmodule_runtime, 'user_is_staff', False)

def is_instructor(self):
return self.xmodule_runtime.get_user_role() == 'instructor'

def show_staff_grading_interface(self):
in_studio_preview = self.scope_ids.user_id is None
return self.is_course_staff() and not in_studio_preview
Expand Down
25 changes: 19 additions & 6 deletions edx_sga/templates/staff_graded_assignment/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@
</td>
<td><%= assignment.timestamp %></td>
<td>
<%= assignment.score %> /
<%= max_score %>
<% if (assignment.score !== null) { %>
<%= assignment.score %> /
<%= max_score %>
<% if (! assignment.approved) { %>
({% trans "Awaiting instructor approval" %})
<% } %>
<% } %>
</td>
<td><%= assignment.comment %></td>
<td>
Expand All @@ -81,9 +86,15 @@
<% } %>
</td>
<td>
<a class="enter-grade-button" href="#{{ id }}-enter-grade">
{% trans "Enter grade" %}
</a>
<% if (assignment.may_grade) { %>
<a class="enter-grade-button" href="#{{ id }}-enter-grade">
<% if (assignment.needs_approval) { %>
{% trans "Approve grade" %}
<% } else { %>
{% trans "Enter grade" %}
<% } %>
</a>
<% } %>
</td>
<td>
<div class="upload">
Expand Down Expand Up @@ -113,7 +124,9 @@

<section aria-hidden="true" class="modal grade-modal" id="{{ id }}-enter-grade">
<div class="inner-wrapper" style="color: black">
<header><h2>{% trans "Enter Grade" %}</h2></header>
<header><h2>
{% trans "Enter Grade" %}
</h2></header>
<br/>
<div style="display: block;">
<form id="enter-grade-form">
Expand Down

0 comments on commit b7938d7

Please sign in to comment.