Commit f85ebb83 by Stephen Sanchez

Explicit action to begin turbo mode.

parent f4b4a5ff
......@@ -11,11 +11,35 @@
<span class="step__status__value">
<i class="ico icon-ok"></i>
<span class="copy">
{% blocktrans with graded=graded must_grade=must_grade %}Complete (<span class="step__status__value--completed">{{ graded }}</span> of <span class="step__status__value--required">{{ must_grade }}</span>){% endblocktrans %}
<span class="step__status__value--completed">{{ graded }}</span> {% trans "Completed" %}
</span>
</span>
</span>
{% endblock %}
{% block body %}
<div class="ui-toggle-visibility__content">
<div class="wrapper--step__content">
<div class="step__message message message--complete">
<h3 class="message__title">{% trans "Peer Assessments Complete" %}</h3>
<div class="message__content">{% trans "You have successfully completed all of the required peer assessments for this assignment. You may assess additional peer responses if you want to. Completing additional assessments will not affect your final grade." %}</div>
</div>
<div class="step__actions">
<div class="message message--inline message--error message--error-server">
<h3 class="message__title">{% trans "We could not retrieve additional submissions for assessment" %}</h3>
</div>
<ul class="list list--actions">
<li class="list--actions__item">
<button type="submit" id="peer-assessment__continue__grading" class="action action--continue--grading">
<span class="copy">{% trans "Continue Assessing Peers" %}</span>
<i class="ico icon-caret-right"></i>
</button>
</li>
</ul>
</div>
</div>
</div>
{% endblock %}
......@@ -314,6 +314,11 @@
"output": "oa_peer_assessment.html"
},
{
"template": "openassessmentblock/peer/oa_peer_complete.html",
"context": {},
"output": "oa_peer_complete.html"
},
{
"template": "openassessmentblock/grade/oa_grade_complete.html",
"context": {
"score": "",
......
......@@ -19,6 +19,10 @@ describe("OpenAssessment.PeerView", function() {
this.render = function(step) {
return successPromise;
};
this.renderContinuedPeer = function() {
return successPromise;
};
};
// Stub base view
......@@ -98,4 +102,20 @@ describe("OpenAssessment.PeerView", function() {
// Expect the submit button to have been re-enabled
expect(view.peerSubmitEnabled()).toBe(true);
});
it("Re-enables the continued grading button on error", function() {
jasmine.getFixtures().fixturesPath = 'base/fixtures';
loadFixtures('oa_peer_complete.html');
// Simulate a server error
spyOn(server, 'renderContinuedPeer').andCallFake(function() {
expect(view.continueAssessmentEnabled()).toBe(false);
return $.Deferred(function(defer) {
defer.rejectWith(this, ['Error occurred!']);
}).promise();
});
view.loadContinuedAssessment();
// Expect the submit button to have been re-enabled
expect(view.continueAssessmentEnabled()).toBe(true);
});
});
......@@ -45,18 +45,11 @@ OpenAssessment.BaseView.prototype = {
Args:
parentSel (JQuery selector): CSS selector for the container element.
onExpand (function): Function to execute when expanding (if provided). Accepts no args.
**/
setUpCollapseExpand: function(parentSel, onExpand) {
setUpCollapseExpand: function(parentSel) {
parentSel.find('.ui-toggle-visibility__control').click(
function(eventData) {
var sel = $(eventData.target).closest('.ui-toggle-visibility');
// If we're expanding and have an `onExpand` callback defined, execute it.
if (sel.hasClass('is--collapsed') && onExpand !== undefined) {
onExpand();
}
sel.toggleClass('is--collapsed');
}
);
......
......@@ -46,6 +46,7 @@ OpenAssessment.PeerView.prototype = {
**/
loadContinuedAssessment: function() {
var view = this;
view.continueAssessmentEnabled(false);
this.server.renderContinuedPeer().done(
function(html) {
// Load the HTML and install event handlers
......@@ -54,10 +55,31 @@ OpenAssessment.PeerView.prototype = {
}
).fail(function(errMsg) {
view.baseView.showLoadError('peer-assessment');
view.continueAssessmentEnabled(true);
});
},
/**
Enable and disable the continue assessment button.
Args:
enabled (bool): If specified, sets the button as enabled or disabled.
if not specified, return the current value.
Returns:
A boolean. TRUE if the continue assessment button is enabled.
**/
continueAssessmentEnabled: function(enabled) {
var button = $('#peer-assessment__continue__grading', this.element);
if (typeof enabled === 'undefined') {
return !button.hasClass('is--disabled');
} else {
button.toggleClass('is--disabled', !enabled);
}
},
/**
Install event handlers for the view.
Args:
......@@ -70,7 +92,7 @@ OpenAssessment.PeerView.prototype = {
var view = this;
// Install a click handler for collapse/expand
this.baseView.setUpCollapseExpand(sel, $.proxy(view.loadContinuedAssessment, view));
this.baseView.setUpCollapseExpand(sel);
// Initialize the rubric
var rubricSelector = $("#peer-assessment--001__assessment", this.element);
......@@ -95,6 +117,14 @@ OpenAssessment.PeerView.prototype = {
else { view.continuedPeerAssess(); }
}
);
// Install a click handler for continued assessment
sel.find('#peer-assessment__continue__grading').click(
function(eventObject) {
eventObject.preventDefault();
view.loadContinuedAssessment();
}
);
},
/**
......
......@@ -175,3 +175,10 @@
}
// Developer SASS for Continued Grading.
.openassessment__steps__step {
.action--continue--grading {
@extend .action--submit;
}
}
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