Commit 76e560e8 by Christina Roberts

Merge pull request #858 from edx/christina/fix-no-learner

Take care to avoid default behavior of get_workflow_info.
parents 6ddd13f8 815fe008
...@@ -22,10 +22,8 @@ from submissions import api as submission_api ...@@ -22,10 +22,8 @@ from submissions import api as submission_api
from openassessment.assessment.api import peer as peer_api from openassessment.assessment.api import peer as peer_api
from openassessment.assessment.api import self as self_api from openassessment.assessment.api import self as self_api
from openassessment.assessment.api import ai as ai_api from openassessment.assessment.api import ai as ai_api
from openassessment.fileupload import api as file_api
from openassessment.workflow import api as workflow_api from openassessment.workflow import api as workflow_api
from openassessment.assessment.api import staff as staff_api from openassessment.assessment.api import staff as staff_api
from openassessment.fileupload import exceptions as file_exceptions
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -237,11 +235,9 @@ class StaffAreaMixin(object): ...@@ -237,11 +235,9 @@ class StaffAreaMixin(object):
""" """
try: try:
student_username = data.params.get('student_username', '') student_username = data.params.get('student_username', '')
path, context = self.get_student_info_path_and_context(student_username)
expanded_view = data.params.get('expanded_view', []) expanded_view = data.params.get('expanded_view', [])
path, context = self.get_student_info_path_and_context( context.update({'expanded_view': expanded_view})
student_username,
expanded_view=expanded_view
)
return self.render_assessment(path, context) return self.render_assessment(path, context)
except PeerAssessmentInternalError: except PeerAssessmentInternalError:
...@@ -341,15 +337,13 @@ class StaffAreaMixin(object): ...@@ -341,15 +337,13 @@ class StaffAreaMixin(object):
return context return context
def get_student_info_path_and_context(self, student_username, expanded_view=None): def get_student_info_path_and_context(self, student_username):
""" """
Get the proper path and context for rendering the student info Get the proper path and context for rendering the student info
section of the staff area. section of the staff area.
Args: Args:
student_username (unicode): The username of the student to report. student_username (unicode): The username of the student to report.
expanded_view (str): An optional view to be shown initially expanded.
The default is None meaning that all views are shown collapsed.
""" """
anonymous_user_id = None anonymous_user_id = None
student_item = None student_item = None
...@@ -370,8 +364,24 @@ class StaffAreaMixin(object): ...@@ -370,8 +364,24 @@ class StaffAreaMixin(object):
submission = submissions[0] submission = submissions[0]
submission_uuid = submission['uuid'] submission_uuid = submission['uuid']
# This will add submission (which may be None) and username to the context.
context = self.get_student_submission_context(student_username, submission) context = self.get_student_submission_context(student_username, submission)
# Only add the rest of the details to the context if a submission exists.
if submission_uuid:
self.add_submission_context(submission_uuid, context)
path = 'openassessmentblock/staff_area/oa_student_info.html'
return path, context
def add_submission_context(self, submission_uuid, context):
"""
Add the submission information (self asssessment, peer assessments, final grade, etc.)
to the supplied context for display in the "learner info" portion of staff tools.
Args:
submission_uuid (unicode): The uuid of the submission, should NOT be None.
context: the context to update with additional information
"""
assessment_steps = self.assessment_steps assessment_steps = self.assessment_steps
example_based_assessment = None example_based_assessment = None
...@@ -429,7 +439,6 @@ class StaffAreaMixin(object): ...@@ -429,7 +439,6 @@ class StaffAreaMixin(object):
workflow_cancellation = self.get_workflow_cancellation_info(submission_uuid) workflow_cancellation = self.get_workflow_cancellation_info(submission_uuid)
context.update({ context.update({
'expanded_view': expanded_view,
'example_based_assessment': [example_based_assessment] if example_based_assessment else None, 'example_based_assessment': [example_based_assessment] if example_based_assessment else None,
'self_assessment': [self_assessment] if self_assessment else None, 'self_assessment': [self_assessment] if self_assessment else None,
'peer_assessments': peer_assessments, 'peer_assessments': peer_assessments,
...@@ -446,9 +455,6 @@ class StaffAreaMixin(object): ...@@ -446,9 +455,6 @@ class StaffAreaMixin(object):
for criterion in context["rubric_criteria"]: for criterion in context["rubric_criteria"]:
criterion["total_value"] = max_scores[criterion["name"]] criterion["total_value"] = max_scores[criterion["name"]]
path = 'openassessmentblock/staff_area/oa_student_info.html'
return path, context
@XBlock.json_handler @XBlock.json_handler
@require_global_admin("RESCHEDULE_TASKS") @require_global_admin("RESCHEDULE_TASKS")
def reschedule_unfinished_tasks(self, data, suffix=''): # pylint: disable=W0613 def reschedule_unfinished_tasks(self, data, suffix=''): # pylint: disable=W0613
......
...@@ -402,7 +402,7 @@ class TestCourseStaff(XBlockHandlerTestCase): ...@@ -402,7 +402,7 @@ class TestCourseStaff(XBlockHandlerTestCase):
}, ['self']) }, ['self'])
# Mock the file upload API to simulate an error # Mock the file upload API to simulate an error
with patch("openassessment.xblock.staff_area_mixin.file_api.get_download_url") as file_api_call: with patch("openassessment.fileupload.api.get_download_url") as file_api_call:
file_api_call.side_effect = FileUploadInternalError("Error!") file_api_call.side_effect = FileUploadInternalError("Error!")
__, context = xblock.get_student_info_path_and_context("Bob") __, context = xblock.get_student_info_path_and_context("Bob")
......
#!/usr/bin/env bash #!/usr/bin/env bash
MAX_PYLINT_VIOLATIONS=522 MAX_PYLINT_VIOLATIONS=519
mkdir -p test/logs mkdir -p test/logs
PYLINT_VIOLATIONS=test/logs/pylint.txt PYLINT_VIOLATIONS=test/logs/pylint.txt
......
...@@ -544,12 +544,18 @@ class StaffAreaTest(OpenAssessmentTest): ...@@ -544,12 +544,18 @@ class StaffAreaTest(OpenAssessmentTest):
Scenario: staff tools indicates if no submission has been received for a given learner Scenario: staff tools indicates if no submission has been received for a given learner
Given I am viewing the staff area of an ORA problem Given I am viewing the staff area of an ORA problem
And I myself have submitted a response with self-assessment
When I search for a learner in staff tools When I search for a learner in staff tools
And the learner has not submitted a response to the ORA problem And the learner has not submitted a response to the ORA problem
Then I see a message indicating that the learner has not submitted a response Then I see a message indicating that the learner has not submitted a response
And there are no student information sections displayed And there are no student information sections displayed
""" """
self.auto_auth_page.visit() self.auto_auth_page.visit()
# This is to catch a bug that existed when the user viewing staff tools had submitted an assessment,
# and had a grade stored (TNL-4060).
self.do_self_assessment()
self.staff_area_page.visit() self.staff_area_page.visit()
# Click on staff tools and search for user # Click on staff tools and search for user
......
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