Commit d57d3553 by Will Daly

Validation: cannot rename criteria post-release

parent 10df7db7
...@@ -396,5 +396,135 @@ ...@@ -396,5 +396,135 @@
] ]
}, },
"is_released": true "is_released": true
},
"rename_criterion_name_after_release": {
"rubric": {
"prompt": "Test Prompt",
"criteria": [
{
"order_num": 0,
"name": "Changed criterion",
"prompt": "Test criterion prompt",
"options": [
{
"order_num": 0,
"points": 0,
"name": "No",
"explanation": "No explanation"
},
{
"order_num": 1,
"points": 2,
"name": "Yes",
"explanation": "Yes explanation"
}
]
}
]
},
"current_rubric": {
"prompt": "Test Prompt",
"criteria": [
{
"order_num": 0,
"name": "Test criterion",
"prompt": "Test criterion prompt",
"options": [
{
"order_num": 0,
"points": 0,
"name": "No",
"explanation": "No explanation"
},
{
"order_num": 1,
"points": 2,
"name": "Yes",
"explanation": "Yes explanation"
}
]
}
]
},
"is_released": true
},
"rename_multiple_criteria_after_release": {
"rubric": {
"prompt": "Test Prompt",
"criteria": [
{
"order_num": 0,
"name": "Test criterion",
"prompt": "Test criterion prompt",
"options": [
{
"order_num": 0,
"points": 0,
"name": "No",
"explanation": "No explanation"
},
{
"order_num": 1,
"points": 2,
"name": "Yes",
"explanation": "Yes explanation"
}
]
},
{
"order_num": 1,
"name": "Another criterion",
"prompt": "Test criterion prompt",
"options": [
{
"order_num": 0,
"points": 0,
"name": "No",
"explanation": "No explanation"
}
]
}
]
},
"current_rubric": {
"prompt": "Test Prompt",
"criteria": [
{
"order_num": 0,
"name": "Renamed Test Criterion",
"prompt": "Test criterion prompt",
"options": [
{
"order_num": 0,
"points": 0,
"name": "No",
"explanation": "No explanation"
},
{
"order_num": 1,
"points": 2,
"name": "Yes",
"explanation": "Yes explanation"
}
]
},
{
"order_num": 1,
"name": "Renamed Another criterion",
"prompt": "Test criterion prompt",
"options": [
{
"order_num": 0,
"points": 0,
"name": "No",
"explanation": "No explanation"
}
]
}
]
},
"is_released": true
} }
} }
...@@ -294,9 +294,7 @@ ...@@ -294,9 +294,7 @@
} }
] ]
}, },
"current_rubric": null,
"is_released": false "is_released": false
}, },
"remove_options_before_release": { "remove_options_before_release": {
...@@ -449,58 +447,6 @@ ...@@ -449,58 +447,6 @@
"is_released": true "is_released": true
}, },
"change_criteria_name_after_release": {
"rubric": {
"prompt": "Test Prompt",
"criteria": [
{
"order_num": 0,
"name": "Changed criterion",
"prompt": "Test criterion prompt",
"options": [
{
"order_num": 0,
"points": 0,
"name": "No",
"explanation": "No explanation"
},
{
"order_num": 1,
"points": 2,
"name": "Yes",
"explanation": "Yes explanation"
}
]
}
]
},
"current_rubric": {
"prompt": "Test Prompt",
"criteria": [
{
"order_num": 0,
"name": "Test criterion",
"prompt": "Test criterion prompt",
"options": [
{
"order_num": 0,
"points": 0,
"name": "No",
"explanation": "No explanation"
},
{
"order_num": 1,
"points": 2,
"name": "Yes",
"explanation": "Yes explanation"
}
]
}
]
},
"is_released": true
},
"change_option_name_after_release": { "change_option_name_after_release": {
"rubric": { "rubric": {
"prompt": "Test Prompt", "prompt": "Test Prompt",
...@@ -605,84 +551,6 @@ ...@@ -605,84 +551,6 @@
"is_released": true "is_released": true
}, },
"rename_criteria_after_release": {
"rubric": {
"prompt": "Test Prompt",
"criteria": [
{
"order_num": 0,
"name": "Test criterion",
"prompt": "Test criterion prompt",
"options": [
{
"order_num": 0,
"points": 0,
"name": "No",
"explanation": "No explanation"
},
{
"order_num": 1,
"points": 2,
"name": "Yes",
"explanation": "Yes explanation"
}
]
},
{
"order_num": 1,
"name": "Another criterion",
"prompt": "Test criterion prompt",
"options": [
{
"order_num": 0,
"points": 0,
"name": "No",
"explanation": "No explanation"
}
]
}
]
},
"current_rubric": {
"prompt": "Test Prompt",
"criteria": [
{
"order_num": 0,
"name": "Renamed Test Criterion",
"prompt": "Test criterion prompt",
"options": [
{
"order_num": 0,
"points": 0,
"name": "No",
"explanation": "No explanation"
},
{
"order_num": 1,
"points": 2,
"name": "Yes",
"explanation": "Yes explanation"
}
]
},
{
"order_num": 1,
"name": "Renamed Another criterion",
"prompt": "Test criterion prompt",
"options": [
{
"order_num": 0,
"points": 0,
"name": "No",
"explanation": "No explanation"
}
]
}
]
},
"is_released": true
},
"rename_options_after_release": { "rename_options_after_release": {
"rubric": { "rubric": {
"prompt": "Test Prompt", "prompt": "Test Prompt",
......
...@@ -177,6 +177,19 @@ def validate_rubric(rubric_dict, current_rubric, is_released): ...@@ -177,6 +177,19 @@ def validate_rubric(rubric_dict, current_rubric, is_released):
if len(rubric_dict['criteria']) != len(current_rubric['criteria']): if len(rubric_dict['criteria']) != len(current_rubric['criteria']):
return (False, u'The number of criteria cannot be changed after a problem is released.') return (False, u'The number of criteria cannot be changed after a problem is released.')
# Criteria names must be the same
# We use criteria names as unique identifiers (unfortunately)
# throughout the system. Changing them mid-flight can cause
# the grade page, for example, to raise 500 errors.
# When we implement non-XML authoring, we might be able to fix this
# the right way by assigning unique identifiers for criteria;
# but for now, this is the safest way to avoid breaking problems
# post-release.
current_criterion_names = set(criterion.get('name') for criterion in current_rubric['criteria'])
new_criterion_names = set(criterion.get('name') for criterion in rubric_dict['criteria'])
if current_criterion_names != new_criterion_names:
return (False, u'Criteria names cannot be changed after a problem is released')
# Number of options for each criterion must be the same # Number of options for each criterion must be the same
for new_criterion, old_criterion in _match_by_order(rubric_dict['criteria'], current_rubric['criteria']): for new_criterion, old_criterion in _match_by_order(rubric_dict['criteria'], current_rubric['criteria']):
if len(new_criterion['options']) != len(old_criterion['options']): if len(new_criterion['options']) != len(old_criterion['options']):
......
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