Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-ora2
Commits
831d2495
Commit
831d2495
authored
Mar 31, 2014
by
Stephen Sanchez
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #231 from edx/sanchez/TIM-403-XML-Validation
Allow Criteria and CriterionOption name changes
parents
d59288cb
c9d38fdd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
25 deletions
+25
-25
apps/openassessment/xblock/test/data/valid_rubrics.json
+16
-16
apps/openassessment/xblock/validation.py
+9
-9
No files found.
apps/openassessment/xblock/test/data/valid_rubrics.json
View file @
831d2495
...
...
@@ -605,7 +605,7 @@
"is_released"
:
true
},
"re
order
_criteria_after_release"
:
{
"re
name
_criteria_after_release"
:
{
"rubric"
:
{
"prompt"
:
"Test Prompt"
,
"criteria"
:
[
...
...
@@ -648,7 +648,7 @@
"criteria"
:
[
{
"order_num"
:
0
,
"name"
:
"
Another c
riterion"
,
"name"
:
"
Renamed Test C
riterion"
,
"prompt"
:
"Test criterion prompt"
,
"options"
:
[
{
...
...
@@ -656,12 +656,18 @@
"points"
:
0
,
"name"
:
"No"
,
"explanation"
:
"No explanation"
},
{
"order_num"
:
1
,
"points"
:
2
,
"name"
:
"Yes"
,
"explanation"
:
"Yes explanation"
}
]
},
{
"order_num"
:
1
,
"name"
:
"
Test
criterion"
,
"name"
:
"
Renamed Another
criterion"
,
"prompt"
:
"Test criterion prompt"
,
"options"
:
[
{
...
...
@@ -669,12 +675,6 @@
"points"
:
0
,
"name"
:
"No"
,
"explanation"
:
"No explanation"
},
{
"order_num"
:
1
,
"points"
:
2
,
"name"
:
"Yes"
,
"explanation"
:
"Yes explanation"
}
]
}
...
...
@@ -683,7 +683,7 @@
"is_released"
:
true
},
"re
order
_options_after_release"
:
{
"re
name
_options_after_release"
:
{
"rubric"
:
{
"prompt"
:
"Test Prompt"
,
"criteria"
:
[
...
...
@@ -718,15 +718,15 @@
"options"
:
[
{
"order_num"
:
0
,
"points"
:
0
,
"name"
:
"
No
"
,
"explanation"
:
"
No
explanation"
"points"
:
2
,
"name"
:
"
Renamed Yes
"
,
"explanation"
:
"
Yes
explanation"
},
{
"order_num"
:
1
,
"points"
:
2
,
"name"
:
"
Yes
"
,
"explanation"
:
"
Yes
explanation"
"points"
:
0
,
"name"
:
"
Renamed No
"
,
"explanation"
:
"
No
explanation"
}
]
}
...
...
apps/openassessment/xblock/validation.py
View file @
831d2495
...
...
@@ -7,24 +7,24 @@ from openassessment.assessment.serializers import rubric_from_dict, InvalidRubri
from
openassessment.xblock.resolve_dates
import
resolve_dates
,
DateValidationError
,
InvalidDateFormat
def
_match_by_
name
(
items
,
others
):
def
_match_by_
order
(
items
,
others
):
"""
Given two lists of dictionaries, each containing "
name
" keys,
Given two lists of dictionaries, each containing "
order_num
" keys,
return a set of tuples, where the items in the tuple are dictionaries
with the same "
name
" keys.
with the same "
order_num
" keys.
Args:
items (list of dict): Items to match, each of which must contain a "
name
" key.
others (list of dict): Items to match, each of which must contain a "
name
" key.
items (list of dict): Items to match, each of which must contain a "
order_num
" key.
others (list of dict): Items to match, each of which must contain a "
order_num
" key.
Returns:
list of tuples, each containing two dictionaries
Raises:
IndexError: A dictionary does no contain a '
name
' key.
IndexError: A dictionary does no contain a '
order_num
' key.
"""
# Sort each dictionary by its "name" key, then zip them and return
key_func
=
lambda
x
:
x
[
'
name
'
]
key_func
=
lambda
x
:
x
[
'
order_num
'
]
return
zip
(
sorted
(
items
,
key
=
key_func
),
sorted
(
others
,
key
=
key_func
))
...
...
@@ -137,12 +137,12 @@ def validate_rubric(rubric_dict, current_rubric, is_released):
return
(
False
,
u'Number of criteria cannot be changed after a problem is released.'
)
# Number of options for each criterion must be the same
for
new_criterion
,
old_criterion
in
_match_by_
name
(
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'
]):
return
(
False
,
u'Number of options cannot be changed after a problem is released.'
)
else
:
for
new_option
,
old_option
in
_match_by_
name
(
new_criterion
[
'options'
],
old_criterion
[
'options'
]):
for
new_option
,
old_option
in
_match_by_
order
(
new_criterion
[
'options'
],
old_criterion
[
'options'
]):
if
new_option
[
'points'
]
!=
old_option
[
'points'
]:
return
(
False
,
u'Point values cannot be changed after a problem is released.'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment