Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
d6f8def7
Commit
d6f8def7
authored
12 years ago
by
Vik Paruchuri
Browse files
Options
Downloads
Patches
Plain Diff
Move over rubric parsing logic to rubric module
parent
b22bad7f
No related branches found
Branches containing commit
Tags
release-2020-03-24-13.32
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/lib/xmodule/xmodule/combined_open_ended_module.py
+3
-15
3 additions, 15 deletions
common/lib/xmodule/xmodule/combined_open_ended_module.py
common/lib/xmodule/xmodule/combined_open_ended_rubric.py
+15
-0
15 additions, 0 deletions
common/lib/xmodule/xmodule/combined_open_ended_rubric.py
with
18 additions
and
15 deletions
common/lib/xmodule/xmodule/combined_open_ended_module.py
+
3
−
15
View file @
d6f8def7
...
...
@@ -166,26 +166,14 @@ class CombinedOpenEndedModule(XModule):
self
.
_max_score
=
int
(
self
.
metadata
.
get
(
'
max_score
'
,
MAX_SCORE
))
if
self
.
_max_score
>
MAX_SCORE_ALLOWED
:
error_message
=
"
Max score {0} is higher than max score allowed {1}
"
.
format
(
self
.
_max_score
,
MAX_SCORE_ALLOWED
)
error_message
=
"
Max score {0} is higher than max score allowed {1}
for location {2}
"
.
format
(
self
.
_max_score
,
MAX_SCORE_ALLOWED
,
location
)
log
.
error
(
error_message
)
raise
IncorrectMaxScoreError
(
error_message
)
rubric_renderer
=
CombinedOpenEndedRubric
(
system
,
True
)
rubric_string
=
stringify_children
(
definition
[
'
rubric
'
])
success
,
rubric_feedback
=
rubric_renderer
.
render_rubric
(
rubric_string
)
if
not
success
:
error_message
=
"
Could not parse rubric : {0}
"
.
format
(
definition
[
'
rubric
'
])
log
.
error
(
error_message
)
raise
RubricParsingError
(
error_message
)
rubric_categories
=
rubric_renderer
.
extract_categories
(
stringify_children
(
definition
[
'
rubric
'
]))
for
category
in
rubric_categories
:
if
len
(
category
[
'
options
'
])
>
(
MAX_SCORE_ALLOWED
+
1
):
error_message
=
"
Number of score points in rubric {0} higher than the max allowed, which is {1}
"
.
format
(
len
(
category
[
'
options
'
]),
MAX_SCORE_ALLOWED
)
log
.
error
(
error_message
)
raise
RubricParsingError
(
error_message
)
rubric_renderer
.
check_if_rubric_is_parseable
(
rubric_string
,
location
,
MAX_SCORE_ALLOWED
)
#Static data is passed to the child modules to render
self
.
static_data
=
{
...
...
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/combined_open_ended_rubric.py
+
15
−
0
View file @
d6f8def7
...
...
@@ -36,6 +36,21 @@ class CombinedOpenEndedRubric(object):
raise
RubricParsingError
(
"
[render_rubric] Could not parse the rubric with xml: {0}
"
.
format
(
rubric_xml
))
return
success
,
html
def
check_if_rubric_is_parseable
(
self
,
rubric_string
,
location
,
max_score_allowed
):
success
,
rubric_feedback
=
self
.
render_rubric
(
rubric_string
)
if
not
success
:
error_message
=
"
Could not parse rubric : {0} for location {1}
"
.
format
(
rubric_string
,
location
.
url
())
log
.
error
(
error_message
)
raise
RubricParsingError
(
error_message
)
rubric_categories
=
self
.
extract_categories
(
rubric_string
)
for
category
in
rubric_categories
:
if
len
(
category
[
'
options
'
])
>
(
max_score_allowed
+
1
):
error_message
=
"
Number of score points in rubric {0} higher than the max allowed, which is {1}
"
.
format
(
len
(
category
[
'
options
'
]),
max_score_allowed
)
log
.
error
(
error_message
)
raise
RubricParsingError
(
error_message
)
def
extract_categories
(
self
,
element
):
'''
Contstruct a list of categories such that the structure looks like:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment