Commit 9766cf2c by Stephen Sanchez

WIP: First pass at TIM-53, TIM-39

* TIM-39 partial: peer evaluators being shown other students' submissions and
  a rubric, and feedback in the form of radio buttions is being solicited.
  This is *mostly* plumbed through to the API.
* TIM-53 complete
* TODO: Needs tests, needs rubric_criteria refactoring

Co-authored-by: Joe Blaylock <jrbl@jrbl.org>
parent 0ba747ef
......@@ -3,8 +3,10 @@
import pkg_resources
from mako.template import Template
from openassessment.peer.api import PeerEvaluationWorkflowError
from submissions import api
from openassessment.peer import api as peer_api
from xblock.core import XBlock
from xblock.fields import List, Scope, String
......@@ -69,18 +71,27 @@ class OpenAssessmentBlock(XBlock):
trace = self._get_xblock_trace()
student_item_dict = self._get_student_item_dict()
previous_submissions = api.get_submissions(student_item_dict)
if previous_submissions: # XXX: until workflow better, move on w/ prev submit
try:
peer_submission = peer_api.get_submission_to_evaluate(student_item_dict)
except PeerEvaluationWorkflowError:
peer_submission = False
if previous_submissions and peer_submission: # XXX: until workflow better, move on w/ prev submit
html = Template(load("static/html/oa_rubric.html"),
default_filters=mako_default_filters,
input_encoding='utf-8',
)
frag = Fragment(html.render_unicode(xblock_trace=trace,
frag = Fragment(html.render_unicode(xblock_trace=trace,
peer_submission=peer_submission,
rubric_instructions=self.rubric_instructions,
rubric_criteria=self.rubric_criteria,
))
frag.add_css(load("static/css/openassessment.css"))
frag.add_javascript(load("static/js/src/oa_assessment.js"))
frag.initialize_js('OpenAssessmentBlock')
elif previous_submissions:
# TODO: TIM-39 They're done grading or there is nothing to grade yet.
pass
else: # XXX: until workflow better, submit until submitted
html = Template(load("static/html/oa_submission.html"),
default_filters=mako_default_filters,
......@@ -95,7 +106,16 @@ class OpenAssessmentBlock(XBlock):
@XBlock.json_handler
def assess(self, data, suffix=''):
"""Place an assessment into Openassessment system"""
return (False, "Assessment handler is not implemented yet.")
# TODO: We're not doing points possible, right way to do points possible
# is to refactor the rubric criteria type, Joe has thoughts on this.
student_item_dict = self._get_student_item_dict()
assessment_dict = {"points_earned": data["points_earned"],
"points_possible": 12,
"feedback": "",
}
evaluation = peer_api.create_evaluation(data["submission_uuid"], student_item_dict["student_id"], assessment_dict)
print "DEBUG: {}".format(evaluation)
return (evaluation, "Assessment handler is not implemented yet.")
@XBlock.json_handler
def submit(self, data, suffix=''):
......
<!-- START OpenAssessmentBlock HTML -->
<div class="openassessment_block" id="openassessment_block_${xblock_trace[0]}">
<div id="peer_submission_uuid" hidden="true">${peer_submission["uuid"]}</div>
<p>${peer_submission["answer"]}</p>
<p class="openassessment_prompt"
id="openassessment_rubric_instructions_${xblock_trace[0]}">${rubric_instructions}</p>
% for criterion in rubric_criteria:
<div>
<p class="openassessment_prompt">${criterion["instructions"]}</p>
% for value in sorted([k for k in criterion.keys() if k != 'name' and k != 'instructions']):
<input type="radio" value="${value}">${criterion[value]}</input>
<input name="${criterion['name']}" type="radio" value="${value}">${criterion[value]}</input>
% endfor
</div>
% endfor
<input type="button"
class="openassessment_submit" id="openassessment_submit_${xblock_trace[0]}" value="Submit" />
% endfor
<input type="button"
class="openassessment_submit" id="openassessment_submit_${xblock_trace[0]}" value="Submit" />
</div>
<div class="openassessment_response_status_block" id=openassessment_response_status_block_${xblock_trace[0]}">
<div class="openassessment_response_status_block" id="openassessment_response_status_block_${xblock_trace[0]}">
This message should be invisible; please upgrade your browser.
</div>
<!-- END OpenAssessmentBlock HTML -->
......@@ -7,6 +7,15 @@ function OpenAssessmentBlock(runtime, element) {
var click_msg = '<p class="clickhere">(click here to dismiss this message)</p>';
/* Sample Debug Console: http://localhost:8000/submissions/Joe_Bloggs/TestCourse/u_3 */
function prepare_assessment_post(element) {
selector = $("input[type=radio]:checked", element);
values = [];
for (i=0; selector.length; i++) {
values.concat(selector[0].value);
}
return {"submission_uuid":$("div#peer_submission_uuid")[0].innerText, "points_earned":values};
}
function displayStatus(result) {
status = result[0]
error_msg = result[1]
......@@ -26,7 +35,7 @@ function OpenAssessmentBlock(runtime, element) {
type: "POST",
url: handlerUrl,
/* data: JSON.stringify({"submission": $('.openassessment_submission', element).val()}), */
data: JSON.stringify({"assessment": "I'm not sure how to stringify a form"}),
data: JSON.stringify(prepare_assessment_post(element)),
success: displayStatus
});
});
......
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