Commit d580f825 by Stephen Sanchez

Some tuning for peer

parent 61ab0d3a
......@@ -5,25 +5,18 @@ from webob import Response
class AssessmentMixin(object):
def render(self, path):
def render(self, path, context_dict=None):
"""Render an Assessment Module's HTML
Given the name of an assessment module, find it in the list of
configured modules, and ask for its rendered HTML.
"""
context_dict = {
"xblock_trace": self._get_xblock_trace(),
"rubric_instructions": self.rubric_instructions,
"rubric_criteria": self.rubric_criteria,
}
if not context_dict: context_dict = {}
context_dict["xblock_trace"] = self.get_xblock_trace()
context_dict["rubric_instructions"] = self.rubric_instructions
context_dict["rubric_criteria"] = self.rubric_criteria
template = get_template(path)
context = Context(context_dict)
return Response(template.render(context), content_type='application/html', charset='UTF-8')
def _get_assessment_module(self, mixin_name):
"""Get a configured assessment module by name.
"""
for assessment in self.rubric_assessments:
if assessment.name == mixin_name:
return assessment
\ No newline at end of file
......@@ -179,7 +179,7 @@ class OpenAssessmentBlock(XBlock, SubmissionMixin, PeerAssessmentMixin, SelfAsse
help="The course_id associated with this prompt (until we can get it from runtime).",
)
def _get_xblock_trace(self):
def get_xblock_trace(self):
"""Uniquely identify this xblock by context.
Every XBlock has a scope_ids, which is a NamedTuple describing
......@@ -191,12 +191,12 @@ class OpenAssessmentBlock(XBlock, SubmissionMixin, PeerAssessmentMixin, SelfAsse
Useful for logging, debugging, and uniqueification."""
return self.scope_ids.usage_id, self.scope_ids.user_id
def _get_student_item_dict(self):
def get_student_item_dict(self):
"""Create a student_item_dict from our surrounding context.
See also: submissions.api for details.
"""
item_id, student_id = self._get_xblock_trace()
item_id, student_id = self.get_xblock_trace()
student_item_dict = dict(
student_id=student_id,
item_id=item_id,
......@@ -209,10 +209,10 @@ class OpenAssessmentBlock(XBlock, SubmissionMixin, PeerAssessmentMixin, SelfAsse
"""The main view of OpenAssessmentBlock, displayed when viewing courses.
"""
trace = self._get_xblock_trace()
student_item_dict = self._get_student_item_dict()
trace = self.get_xblock_trace()
student_item_dict = self.get_student_item_dict()
grade_state = self._get_grade_state()
grade_state = self.get_grade_state()
# All data we intend to pass to the front end.
context_dict = {
"xblock_trace": trace,
......@@ -262,7 +262,7 @@ class OpenAssessmentBlock(XBlock, SubmissionMixin, PeerAssessmentMixin, SelfAsse
block = sparser.parse()
return block
def _get_grade_state(self):
def get_grade_state(self):
# TODO: Determine if we want to build out grade state right now.
grade_state = {
......
......@@ -8,9 +8,9 @@ class PeerAssessmentMixin(AssessmentMixin):
@XBlock.json_handler
def assess(self, data, suffix=''):
"""Place an assessment into Openassessment system
"""Place an assessment into OpenAssessment system
"""
with self._get_assessment_module('peer-assessment') as assessment:
with self.get_assessment_module('peer-assessment') as assessment:
assessment_dict = {
"points_earned": map(int, data["points_earned"]),
......@@ -19,7 +19,7 @@ class PeerAssessmentMixin(AssessmentMixin):
}
assessment = peer_api.create_assessment(
data["submission_uuid"],
self._get_student_item_dict()["student_id"],
self.get_student_item_dict()["student_id"],
int(assessment.must_grade),
int(assessment.must_be_graded_by),
assessment_dict
......@@ -32,7 +32,14 @@ class PeerAssessmentMixin(AssessmentMixin):
@XBlock.handler
def render_peer_assessment(self, data, suffix=''):
return super(PeerAssessmentMixin, self).render('static/html/oa_peer_assessment.html')
with self.get_assessment_module('peer-assessment') as assessment:
context_dict = {"peer_submission": self.get_peer_submission(
self.get_student_item_dict(),
assessment
)}
return super(PeerAssessmentMixin, self).render(
'static/html/oa_peer_assessment.html',
context_dict)
def get_peer_submission(self, student_item_dict, assessment):
peer_submission = False
......@@ -40,7 +47,6 @@ class PeerAssessmentMixin(AssessmentMixin):
peer_submission = peer_api.get_submission_to_assess(
student_item_dict, assessment.must_be_graded_by
)
# context_dict["peer_submission"] = peer_submission
peer_submission = peer_api.get_submission_to_assess(
student_item_dict,
......@@ -51,3 +57,10 @@ class PeerAssessmentMixin(AssessmentMixin):
# TODO: Log?
pass
return peer_submission
def get_assessment_module(self, mixin_name):
"""Get a configured assessment module by name.
"""
for assessment in self.rubric_assessments:
if assessment.name == mixin_name:
return assessment
\ No newline at end of file
/* START Javascript for OpenassessmentXBlock. */
/* START Javascript for OpenAssessmentXBlock. */
function OpenAssessmentBlock(runtime, element) {
var handlerUrl = runtime.handlerUrl(element, 'submit');
......@@ -8,7 +8,7 @@ function OpenAssessmentBlock(runtime, element) {
/* Sample Debug Console: http://localhost:8000/submissions/Joe_Bloggs/TestCourse/u_3 */
/*
Submission Functions
* Submission Functions
*/
function render_submissions(data) {
$('#submission', element).replaceWith(data);
......@@ -38,8 +38,8 @@ function OpenAssessmentBlock(runtime, element) {
}
/*
Peer Assessment Functions
*/
* Peer Assessment Functions
*/
function render_peer_assessment(data) {
$('#peer-assessment', element).replaceWith(data);
......@@ -89,4 +89,4 @@ function OpenAssessmentBlock(runtime, element) {
});
});
}
/* END Javascript for OpenassessmentXBlock. */
/* END Javascript for OpenAssessmentXBlock. */
......@@ -18,7 +18,7 @@ class SubmissionMixin(AssessmentMixin):
"""
Place the submission text into Openassessment system
"""
student_item_dict = self._get_student_item_dict()
student_item_dict = self.get_student_item_dict()
status = False
status_text = None
student_sub = data['submission']
......
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