Commit 286dcd3c by Andy Armstrong

Address code review feedback

parent 958c15ac
...@@ -58,14 +58,14 @@ ...@@ -58,14 +58,14 @@
{% endfor %} {% endfor %}
<li class="wrapper--input field field--textarea assessment__rubric__question assessment__rubric__question--feedback"> <li class="wrapper--input field field--textarea assessment__rubric__question assessment__rubric__question--feedback">
<label class="question__title" for="{{ rubric_type }}__assessment__rubric__question--feedback__value"> <label class="question__title" for="{{ rubric_type }}__assessment__rubric__question--feedback__value">
<span class="question__title__copy">{{ rubric_feedback_prompt }}</span> <span class="question__title__copy">{% trans rubric_feedback_prompt %}</span>
</label> </label>
<div class="wrapper--input"> <div class="wrapper--input">
<textarea <textarea
id="{{ rubric_type }}__assessment__rubric__question--feedback__value" id="{{ rubric_type }}__assessment__rubric__question--feedback__value"
class="assessment__rubric__question--feedback__value" class="assessment__rubric__question--feedback__value"
placeholder="{{ rubric_feedback_default_text }}" placeholder="{% trans rubric_feedback_default_text %}"
maxlength="500" maxlength="500"
> >
</textarea> </textarea>
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
{% trans "View the file associated with this submission." %} {% trans "View the file associated with this submission." %}
</a> </a>
{% if show_warning %} {% if show_warning %}
<p class="submission_file_warning">{% trans "(Caution: This file was uploaded by another course learner and has not been verified, screened, approved, reviewed or endorsed by edX. If you decide to access it, you do so at your own risk.)" %}</p> <p class="submission_file_warning">{% trans "(Caution: This file was uploaded by another course learner and has not been verified, screened, approved, reviewed, or endorsed by edX. If you decide to access it, you do so at your own risk.)" %}</p>
{% endif %} {% endif %}
{% endif %} {% endif %}
</div> </div>
......
...@@ -3,16 +3,16 @@ ...@@ -3,16 +3,16 @@
{% load tz %} {% load tz %}
{% block list_item %} {% block list_item %}
<li id="openassessment__response" class="openassessment__steps__step step--response ui-toggle-visibility has--error"> <li id="openassessment__response" class="openassessment__steps__step step--response ui-toggle-visibility has--error">
{% endblock %} {% endblock %}
{% block title %} {% block title %}
<span class="step__status"> <span class="step__status">
<span class="step__status__label">{% trans "This step's status" %}:</span> <span class="step__status__label">{% trans "This step's status" %}:</span>
<span class="step__status__value"> <span class="step__status__value">
<i class="icon fa fa-exclamation-triangle" aria-hidden="true"></i> <i class="icon fa fa-exclamation-triangle" aria-hidden="true"></i>
<span class="copy">{% trans "Cancelled" %}</span> <span class="copy">{% trans "Cancelled" %}</span>
</span> </span>
</span> </span>
{% endblock %} {% endblock %}
...@@ -24,26 +24,17 @@ ...@@ -24,26 +24,17 @@
<h3 class="message__title">{% trans "Submission Cancelled" %}</h3> <h3 class="message__title">{% trans "Submission Cancelled" %}</h3>
<div class="message__content"> <div class="message__content">
<p> <p>
{% blocktrans with removed_datetime=workflow_cancellation.cancelled_at|utc|date:"N j, Y H:i e" removed_by_username=workflow_cancellation.cancelled_by %} {% blocktrans with removed_datetime=workflow_cancellation.cancelled_at|utc|date:"N j, Y H:i e" removed_by_username=workflow_cancellation.cancelled_by %}
Your submission has been cancelled by {{ removed_by_username }} on {{ removed_datetime }} Your submission has been cancelled by {{ removed_by_username }} on {{ removed_datetime }}
{% endblocktrans %} {% endblocktrans %}
<br> </p>
<!-- Comments: Reason for Cancellation--> <p>
{% blocktrans with comments=workflow_cancellation.comments %} <!-- Comments: Reason for Cancellation-->
Comments: {{ comments }} {% blocktrans with comments=workflow_cancellation.comments %}
{% endblocktrans %} Comments: {{ comments }}
</p> {% endblocktrans %}
</div> </p>
<div class="step__content">
<article class="submission__answer__display">
<h3 class="submission__answer__display__title">{% trans "Your Response" %}</h3>
<div class="submission__answer__display__content">
{{ student_submission.answer.text|linebreaks }}
</div>
</article>
</div> </div>
</div> </div>
</div> </div>
......
{% load tz %}
{% load i18n %} {% load i18n %}
{% spaceless %} {% spaceless %}
...@@ -6,7 +5,7 @@ ...@@ -6,7 +5,7 @@
<div class="ui-toggle-visibility__content"> <div class="ui-toggle-visibility__content">
<div class="wrapper--staff-assessment"> <div class="wrapper--staff-assessment">
<div class="step__instruction"> <div class="step__instruction">
<p>{% trans "Allows you to override the current learner's grade using the problem's rubric." %}</p> <p>{% trans "Override this learner's current grade using the problem's rubric." %}</p>
</div> </div>
<div class="step__content"> <div class="step__content">
...@@ -42,6 +41,8 @@ ...@@ -42,6 +41,8 @@
<button type="submit" class="action action--submit is--disabled"> <button type="submit" class="action action--submit is--disabled">
<span class="copy">{% trans "Submit your assessment" %}</span> <span class="copy">{% trans "Submit your assessment" %}</span>
</button> </button>
<div class="staff-override-error"></div>
</li> </li>
</ul> </ul>
</div> </div>
......
...@@ -231,7 +231,8 @@ class StaffAreaMixin(object): ...@@ -231,7 +231,8 @@ class StaffAreaMixin(object):
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.
""" """
submission_uuid = None submission_uuid = None
submission = None submission = None
...@@ -269,8 +270,8 @@ class StaffAreaMixin(object): ...@@ -269,8 +270,8 @@ class StaffAreaMixin(object):
example_based_assessment = None example_based_assessment = None
self_assessment = None self_assessment = None
peer_assessments = [] peer_assessments = None
submitted_assessments = [] submitted_assessments = None
if "peer-assessment" in assessment_steps: if "peer-assessment" in assessment_steps:
peer_assessments = peer_api.get_assessments(submission_uuid) peer_assessments = peer_api.get_assessments(submission_uuid)
......
...@@ -758,6 +758,68 @@ ...@@ -758,6 +758,68 @@
"output": "oa_staff_cancelled_submission.html" "output": "oa_staff_cancelled_submission.html"
}, },
{ {
"template": "openassessmentblock/staff_area/oa_student_info.html",
"context": {
"rubric_criteria": [
{
"name": "vocabulary",
"prompt": "vocabulary",
"order_num": 0,
"feedback": "optional",
"options": [
{
"order_num": 0,
"points": 0,
"name": "Bad"
},
{
"order_num": 1,
"points": 1,
"name": "Good"
}
]
},
{
"name": "grammar",
"prompt": "grammar",
"order_num": 1,
"options": [
{
"order_num": 0,
"points": 0,
"name": "Bad"
},
{
"order_num": 1,
"points": 1,
"name": "Good"
}
]
},
{
"name": "feedback_only",
"prompt": "Feedback only, no options!",
"order_num": 2,
"feedback": "required",
"options": []
}
],
"submission": {
"image_url": "/test-url",
"answer": {
"text": "testing response text"
}
},
"score": {
"points_earned": 1,
"points_possible": 2
},
"workflow_status": "done",
"expanded_view": "final-grade"
},
"output": "oa_staff_graded_submission.html"
},
{
"template": "openassessmentblock/peer/oa_peer_assessment.html", "template": "openassessmentblock/peer/oa_peer_assessment.html",
"context": { "context": {
"rubric_criteria": [ "rubric_criteria": [
......
...@@ -4,6 +4,18 @@ ...@@ -4,6 +4,18 @@
describe('OpenAssessment.StaffAreaView', function() { describe('OpenAssessment.StaffAreaView', function() {
'use strict'; 'use strict';
var successPromise = $.Deferred(
function(defer) { defer.resolve(); }
).promise();
var failWith = function(owner, result) {
return function() {
return $.Deferred(function(defer) {
defer.rejectWith(owner, [result]);
}).promise();
};
};
// Stub server that returns dummy data for the staff info view // Stub server that returns dummy data for the staff info view
var StubServer = function() { var StubServer = function() {
this.studentTemplate = 'oa_student_info.html'; this.studentTemplate = 'oa_student_info.html';
...@@ -43,10 +55,6 @@ describe('OpenAssessment.StaffAreaView', function() { ...@@ -43,10 +55,6 @@ describe('OpenAssessment.StaffAreaView', function() {
}).promise(); }).promise();
}; };
var successPromise = $.Deferred(
function(defer) { defer.resolve(); }
).promise();
this.cancelSubmission = function() { this.cancelSubmission = function() {
return successPromise; return successPromise;
}; };
...@@ -300,21 +308,42 @@ describe('OpenAssessment.StaffAreaView', function() { ...@@ -300,21 +308,42 @@ describe('OpenAssessment.StaffAreaView', function() {
'Comments: Cancelled!' 'Comments: Cancelled!'
); );
}); });
it('shows an error message when a cancel submission request fails', function() {
// Show the staff area for the test student
var staffArea = createStaffArea(),
serverErrorMessage = 'Mock server error';
chooseStudent(staffArea, 'testStudent');
// Cancel the student's submission but return a server error
staffArea.comment('Cancellation reason.');
server.cancelSubmission = failWith(server, serverErrorMessage);
staffArea.cancelSubmission('Bob');
// Verify that the error message is shown
expect($('.cancel-submission-error', staffArea.element).first().text().trim()).toBe(serverErrorMessage);
});
}); });
describe('Staff Grade Override', function() { describe('Staff Grade Override', function() {
var fillAssessment = function($assessment) { var fillAssessment = function($assessment) {
$('#staff__assessment__rubric__question--2__feedback', $assessment).val('Text response'); $('#staff__assessment__rubric__question--2__feedback', $assessment).val('Text response');
$('.question__answers', $assessment).each(function(element) { $('.question__answers', $assessment).each(function() {
$('input[type="radio"]', this).first().click(); $('input[type="radio"]', this).first().click();
}); });
}; };
var submitAssessment = function(staffArea) {
var $assessment = $('.wrapper--staff-assessment', staffArea.element),
$submitButton = $('.action--submit', $assessment);
$submitButton.click();
};
it('enables the submit button when all required fields are specified', function() { it('enables the submit button when all required fields are specified', function() {
var staffArea = createStaffArea(), var staffArea = createStaffArea(),
$assessment, $submitButton; $assessment, $submitButton;
chooseStudent(staffArea, 'testStudent'); chooseStudent(staffArea, 'testStudent');
$assessment = $('.wrapper--staff-assessment', staffArea.element) $assessment = $('.wrapper--staff-assessment', staffArea.element);
$submitButton = $('.action--submit', $assessment); $submitButton = $('.action--submit', $assessment);
expect($submitButton).toHaveClass('is--disabled'); expect($submitButton).toHaveClass('is--disabled');
fillAssessment($assessment); fillAssessment($assessment);
...@@ -323,24 +352,39 @@ describe('OpenAssessment.StaffAreaView', function() { ...@@ -323,24 +352,39 @@ describe('OpenAssessment.StaffAreaView', function() {
it('can submit a staff grade override', function() { it('can submit a staff grade override', function() {
var staffArea = createStaffArea(), var staffArea = createStaffArea(),
$assessment, $submitButton; $assessment, $gradeSection;
chooseStudent(staffArea, 'testStudent'); chooseStudent(staffArea, 'testStudent');
$assessment = $('.wrapper--staff-assessment', staffArea.element) $assessment = $('.wrapper--staff-assessment', staffArea.element);
$submitButton = $('.action--submit', $assessment);
fillAssessment($assessment); fillAssessment($assessment);
// Submit the assessment // Submit the assessment
server.studentTemplate = 'oa_staff_cancelled_submission.html'; server.studentTemplate = 'oa_staff_graded_submission.html';
$submitButton.click(); submitAssessment(staffArea);
// Verify that the student info reflects the update // Verify that the student info is visible and shows the correct score
expect($($('.staff-info__student__response p', staffArea.element)[0]).text().trim()).toBe( $gradeSection = $('.staff-info__student__grade', staffArea.element);
'Learner submission removed by staff on October 1, 2015 04:53 UTC' expect($('.ui-toggle-visibility', $gradeSection)).not.toHaveClass('is--collapsed');
); expect($('p', $gradeSection).first().text().trim()).toBe(
expect($($('.staff-info__student__response p', staffArea.element)[1]).text().trim()).toBe( 'Final grade: 1 out of 2'
'Comments: Cancelled!'
); );
}); });
it('shows an error message when a grade override request fails', function() {
var staffArea = createStaffArea(),
serverErrorMessage = 'Mock server error',
$assessment;
chooseStudent(staffArea, 'testStudent');
$assessment = $('.wrapper--staff-assessment', staffArea.element);
fillAssessment($assessment);
// Submit the assessment but return a server error message
staffArea.comment('Cancellation reason.');
server.staffAssess = failWith(server, serverErrorMessage);
submitAssessment(staffArea);
// Verify that the error message is shown
expect($('.staff-override-error', staffArea.element).first().text().trim()).toBe(serverErrorMessage);
});
}); });
}); });
......
...@@ -150,6 +150,7 @@ OpenAssessment.PeerView.prototype = { ...@@ -150,6 +150,7 @@ OpenAssessment.PeerView.prototype = {
return !button.hasClass('is--disabled'); return !button.hasClass('is--disabled');
} else { } else {
button.toggleClass('is--disabled', !enabled); button.toggleClass('is--disabled', !enabled);
return enabled;
} }
}, },
......
...@@ -169,6 +169,7 @@ OpenAssessment.ResponseView.prototype = { ...@@ -169,6 +169,7 @@ OpenAssessment.ResponseView.prototype = {
return !sel.hasClass('is--disabled'); return !sel.hasClass('is--disabled');
} else { } else {
sel.toggleClass('is--disabled', !enabled); sel.toggleClass('is--disabled', !enabled);
return enabled;
} }
}, },
......
...@@ -91,6 +91,7 @@ OpenAssessment.SelfView.prototype = { ...@@ -91,6 +91,7 @@ OpenAssessment.SelfView.prototype = {
return !button.hasClass('is--disabled'); return !button.hasClass('is--disabled');
} else { } else {
button.toggleClass('is--disabled', !enabled); button.toggleClass('is--disabled', !enabled);
return enabled;
} }
}, },
......
...@@ -231,7 +231,7 @@ class TestCourseStaff(XBlockHandlerTestCase): ...@@ -231,7 +231,7 @@ class TestCourseStaff(XBlockHandlerTestCase):
path, context = xblock.get_student_info_path_and_context("Bob") path, context = xblock.get_student_info_path_and_context("Bob")
self.assertEquals("Bob Answer 1", context['submission']['answer']['parts'][0]['text']) self.assertEquals("Bob Answer 1", context['submission']['answer']['parts'][0]['text'])
self.assertEquals([], context['peer_assessments']) self.assertEquals(None, context['peer_assessments'])
self.assertEquals("openassessmentblock/staff_area/oa_student_info.html", path) self.assertEquals("openassessmentblock/staff_area/oa_student_info.html", path)
@scenario('data/basic_scenario.xml', user_id='Bob') @scenario('data/basic_scenario.xml', user_id='Bob')
......
...@@ -399,7 +399,7 @@ class StaffAreaTest(OpenAssessmentTest): ...@@ -399,7 +399,7 @@ class StaffAreaTest(OpenAssessmentTest):
self.staff_area_page.verify_learner_final_score( self.staff_area_page.verify_learner_final_score(
"The learner's submission has been removed from peer assessment. " "The learner's submission has been removed from peer assessment. "
"The learner receives a grade of zero unless you reset the learner's attempts for the " "The learner receives a grade of zero unless you delete the learner's state for the "
"problem to allow them to resubmit a response." "problem to allow them to resubmit a response."
) )
......
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