Commit 77e5d8e3 by Stephen Sanchez

Merge pull request #484 from edx/sanchez/ORA-640-Disallow-Duplicate-Essays

Better handling of duplicate training essays
parents f4661727 fc86f455
{% extends "openassessmentblock/student_training/student_training.html" %}
{% load i18n %}
{% block body %}
<div class="ui-toggle-visibility__content">
<div class="wrapper--step__content">
<div class="step__message message message--incomplete">
<h3 class="message__title">{% trans "Error Loading Student Training Examples" %}</h3>
<div class="message__content">
<p>{% trans "We couldn't load the student training step of this assignment." %}</p>
</div>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
......@@ -6,7 +6,6 @@ from django.utils.translation import ugettext as _
from webob import Response
from xblock.core import XBlock
from openassessment.assessment.api import student_training
import openassessment.workflow.api as workflow_api
from openassessment.workflow.errors import AssessmentWorkflowError
from openassessment.xblock.data_conversion import convert_training_examples_list_to_dict
from .resolve_dates import DISTANT_FUTURE
......@@ -119,9 +118,17 @@ class StudentTrainingMixin(object):
},
examples
)
context['training_essay'] = example['answer']
context['training_rubric'] = example['rubric']
template = 'openassessmentblock/student_training/student_training.html'
if example:
context['training_essay'] = example['answer']
context['training_rubric'] = example['rubric']
template = 'openassessmentblock/student_training/student_training.html'
else:
logger.error(
"No training example was returned from the API for student "
"with Submission UUID {}".format(self.submission_uuid)
)
template = "openassessmentblock/student_training/student_training_error.html"
return template, context
......
......@@ -55,7 +55,15 @@
"valid": true,
"assessments": [
{
"name": "student-training"
"name": "student-training",
"examples": [
{
"answer": "foo"
},
{
"answer": "bar"
}
]
},
{
"name": "self-assessment"
......
......@@ -46,6 +46,72 @@
"is_released": false
},
"training_no_examples": {
"valid": false,
"assessments": [
{
"name": "student-training"
},
{
"name": "peer-assessment",
"must_grade": 5,
"must_be_graded_by": 3
},
{
"name": "self-assessment"
}
],
"current_assessments": null,
"is_released": false
},
"training_duplicate_examples": {
"valid": false,
"assessments": [
{
"name": "student-training",
"examples": [
{
"answer": "тєѕт αηѕωєя",
"options_selected": [
{
"criterion": "vocabulary",
"option": "poor"
},
{
"criterion": "grammar",
"option": "good"
}
]
},
{
"answer": "тєѕт αηѕωєя",
"options_selected": [
{
"criterion": "vocabulary",
"option": "poor"
},
{
"criterion": "grammar",
"option": "good"
}
]
}
]
},
{
"name": "peer-assessment",
"must_grade": 5,
"must_be_graded_by": 3
},
{
"name": "self-assessment"
}
],
"current_assessments": null,
"is_released": false
},
"training_peer": {
"valid": true,
"assessments": [
......
......@@ -131,6 +131,18 @@ def validate_assessments(assessments, current_assessments, is_released):
if must_grade < must_be_graded_by:
return (False, _('The "must_grade" value must be greater than or equal to the "must_be_graded_by" value.'))
# Student Training must have at least one example, and all
# examples must have unique answers.
if assessment_dict.get('name') == 'student-training':
answers = []
examples = assessment_dict.get('examples')
if not examples:
return False, _('You must provide at least one example response for student training.')
for example in examples:
if example.get('answer') in answers:
return False, _('Each example response for student training must be unique.')
answers.append(example.get('answer'))
# Example-based assessment MUST specify 'ease' or 'fake' as the algorithm ID,
# at least for now. Later, we may make this more flexible.
if assessment_dict.get('name') == 'example-based-assessment':
......
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