Commit 17186016 by cahrens

WIP for showing staff grading section

parent f909a109
{% extends "openassessmentblock/peer/oa_peer_assessment.html" %}
{% load i18n %}
{% block list_item %}
<li id="openassessment__staff-assessment" class="openassessment__steps__step step--peer-assessment ui-toggle-visibility is--empty is--complete is--collapsed">
{% endblock %}
{% block title %}
<span class="step__status">
<span class="step__status__label">{% trans "This step's status" %}:</span>
<span class="step__status__value">
<i class="icon fa fa-check" aria-hidden="true"></i>
<span class="copy">
<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 "Staff 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>
</div>
{% endblock %}
......@@ -342,11 +342,13 @@ def _get_workflow_model(submission_uuid):
raise AssessmentWorkflowRequestError("submission_uuid must be a string type")
try:
workflow = AssessmentWorkflow.objects.get(submission_uuid=submission_uuid)
except AssessmentWorkflow.DoesNotExist:
raise AssessmentWorkflowNotFoundError(
u"No assessment workflow matching submission_uuid {}".format(submission_uuid)
)
workflow = AssessmentWorkflow.get_by_submission_uuid(submission_uuid)
if workflow is None:
raise AssessmentWorkflowNotFoundError(
u"No assessment workflow matching submission_uuid {}".format(submission_uuid)
)
except AssessmentWorkflowError as exc:
raise AssessmentWorkflowInternalError(repr(exc))
except Exception as exc:
# Something very unexpected has just happened (like DB misconfig)
err_msg = (
......@@ -423,3 +425,7 @@ def is_workflow_cancelled(submission_uuid):
return workflow.is_cancelled if workflow else False
except AssessmentWorkflowError:
return False
def staff_score_exists(submission_uuid):
return _get_workflow_model(submission_uuid).staff_score_exists()
......@@ -568,10 +568,10 @@ class AssessmentWorkflow(TimeStampedModel, StatusModel):
return cls.objects.get(submission_uuid=submission_uuid)
except cls.DoesNotExist:
return None
except DatabaseError:
error_message = u"Error finding workflow for submission UUID {}.".format(submission_uuid)
logger.exception(error_message)
raise AssessmentWorkflowError(error_message)
except DatabaseError as exc:
message = u"Error finding workflow for submission UUID {} due to error: {}.".format(submission_uuid, exc)
logger.exception(message)
raise AssessmentWorkflowError(message)
@property
def is_cancelled(self):
......
......@@ -456,7 +456,8 @@ class OpenAssessmentBlock(
"""
ui_models = [UI_MODELS["submission"]]
for assessment in self.valid_assessments:
if assessment["name"] == "staff-assessment" and assessment["required"] == False:
if assessment["name"] == "staff-assessment" and assessment["required"] == False \
and self.has_staff_score() == False:
# If we don't have a staff grade, and it's not required, hide
# this UI model.
if not self.staff_assessment_exists(self.submission_uuid):
......
......@@ -69,3 +69,36 @@ class StaffAssessmentMixin(object):
return {'success': False, 'msg': msg}
else:
return {'success': True, 'msg': u""}
@XBlock.handler
def render_staff_assessment(self, data, suffix=''):
"""Renders the Staff Assessment HTML section of the XBlock
Generates the staff assessment HTML for the Open
Assessment XBlock. See OpenAssessmentBlock.render_assessment() for
more information on rendering XBlock sections.
Args:
data (dict):
"""
# if "peer-assessment" not in self.assessment_steps:
# return Response(u"")
path, context_dict = self.staff_path_and_context()
return self.render_assessment(path, context_dict)
def staff_path_and_context(self):
"""
Retrieve the correct template path and template context for the handler to render.
"""
# TODO: what is actually necessary here?
context_dict = {
"rubric_criteria": self.rubric_criteria_with_labels,
"allow_latex": self.allow_latex,
}
# # Determine if file upload is supported for this XBlock.
# context["allow_file_upload"] = self.allow_file_upload
# context['self_file_url'] = self.get_download_url_from_submission(submission)
path = 'openassessmentblock/staff/oa_staff_complete.html'
return path, context_dict
......@@ -20,6 +20,7 @@ OpenAssessment.BaseView = function(runtime, element, server, data) {
this.trainingView = new OpenAssessment.StudentTrainingView(this.element, this.server, this);
this.selfView = new OpenAssessment.SelfView(this.element, this.server, this);
this.peerView = new OpenAssessment.PeerView(this.element, this.server, this);
this.staffView = new OpenAssessment.StaffView(this.element, this.server, this);
this.gradeView = new OpenAssessment.GradeView(this.element, this.server, this);
this.leaderboardView = new OpenAssessment.LeaderboardView(this.element, this.server, this);
this.messageView = new OpenAssessment.MessageView(this.element, this.server, this);
......@@ -72,6 +73,7 @@ OpenAssessment.BaseView.prototype = {
loadAssessmentModules: function() {
this.trainingView.load();
this.peerView.load();
this.staffView.load();
this.selfView.load();
this.gradeView.load();
this.leaderboardView.load();
......
/**
Interface for staff asssessment view.
Args:
element (DOM element): The DOM element representing the XBlock.
server (OpenAssessment.Server): The interface to the XBlock server.
baseView (OpenAssessment.BaseView): Container view.
Returns:
OpenAssessment.PeerView
**/
OpenAssessment.StaffView = function(element, server, baseView) {
this.element = element;
this.server = server;
this.baseView = baseView;
this.rubric = null;
};
OpenAssessment.StaffView.prototype = {
/**
Load the peer assessment view.
**/
load: function () {
var view = this;
this.server.render('staff_assessment').done(
function (html) {
// Load the HTML and install event handlers
$('#openassessment__staff-assessment', view.element).replaceWith(html);
view.server.renderLatex($('#openassessment__staff-assessment', view.element));
//view.installHandlers(false);
}
).fail(function () {
view.baseView.showLoadError('staff-assessment');
});
//// Called to update Messageview with info on whether or not it was able to grab a submission
//// See detailed explanation/Methodology in oa_base.loadAssessmentModules
//view.baseView.loadMessageView();
}
}
\ No newline at end of file
......@@ -63,6 +63,9 @@ class WorkflowMixin(object):
}
workflow_api.create_workflow(submission_uuid, steps, on_init_params=on_init_params)
def staff_score_exists(self, submission_uuid):
return workflow_api.staff_score_exists(submission_uuid)
def workflow_requirements(self):
"""
Retrieve the requirements from each assessment module
......
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