Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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-platform
Commits
dfe438dc
Commit
dfe438dc
authored
Dec 18, 2012
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial work on the rubric input type including the most basic parsing
without error handling
parent
1b8dfadc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
104 additions
and
0 deletions
+104
-0
common/lib/capa/capa/inputtypes.py
+99
-0
common/lib/capa/capa/templates/rubricinput.html
+5
-0
No files found.
common/lib/capa/capa/inputtypes.py
View file @
dfe438dc
...
@@ -783,3 +783,102 @@ class OpenEndedInput(InputTypeBase):
...
@@ -783,3 +783,102 @@ class OpenEndedInput(InputTypeBase):
registry
.
register
(
OpenEndedInput
)
registry
.
register
(
OpenEndedInput
)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
class
RubricInput
(
InputTypeBase
):
"""
This is the logic for parsing and displaying a rubric of type
"""
template
=
"rubricinput.html"
tags
=
[
'rubric'
]
# pulled out for testing
submitted_msg
=
(
"Feedback not yet available. Reload to check again. "
"Once the problem is graded, this message will be "
"replaced with the grader's feedback."
)
@classmethod
def
get_attributes
(
cls
):
"""
Convert options to a convenient format.
"""
return
[
]
def
_extra_context
(
self
):
"""
Add in the various bits and pieces of the
"""
return
{}
def
setup
(
self
):
extract_categories
(
self
.
xml
)
@staticmethod
def
extract_categories
(
element
):
'''
Contstruct a list of categories such that the structure looks like:
[ { category: "Category 1 Name",
options: [{text: "Option 1 Name", points: 0}, {text:"Option 2 Name", points: 5}]
},
{ category: "Category 2 Name",
options: [{text: "Option 1 Name", points: 0},
{text: "Option 2 Name", points: 1},
{text: "Option 3 Name", points: 2]}]
'''
categories
=
[]
for
category
in
element
:
if
category
.
tag
!=
'category'
:
raise
Exception
(
"[capa.inputtypes.extract_categories] Expected a <category> tag: got {0} instead"
.
format
(
category
.
tag
))
else
:
categories
.
append
(
extract_category
(
category
))
self
.
categories
=
categories
@staticmethod
def
extract_category
(
category
):
'''
construct an individual category
{category: "Category 1 Name",
options: [{text: "Option 1 text", points: 1},
{text: "Option 2 text", points: 2}]}
all sorting and auto-point generation occurs in this function
'''
descriptionxml
=
category
[
0
]
optionsxml
=
category
[
1
:]
# parse description
if
descriptionxml
.
tag
!=
'description'
:
raise
Exception
(
"[extract_category: expected description tag, got {0} instead"
.
format
(
descriptionxml
.
tag
))
description
=
descriptionxml
.
text
cur_points
=
0
options
=
[]
# parse options
for
option
in
optionsxml
:
if
option
.
tag
!=
'option'
:
raise
Exception
(
"[extract_category: expected option tag, got {0} instead"
.
format
(
option
.
tag
))
else
:
pointstr
=
option
.
get
(
"points"
)
if
(
pointstr
):
# try to parse this into an int
try
:
points
=
int
(
pointstr
)
except
ValueError
:
raise
Exception
(
"[extract_category: expected int to have points, got {0} instead"
.
format
(
pointstr
))
else
:
# use the generated one
points
=
cur_points
cur_points
=
cur_points
+
1
optiontext
=
option
.
text
options
.
append
({
'text'
:
option
.
text
,
'points'
:
points
})
return
{
'description'
:
description
,
'options'
:
options
}
registry
.
register
(
RubricInput
)
#-----------------------------------------------------------------------------
common/lib/capa/capa/templates/rubricinput.html
0 → 100644
View file @
dfe438dc
<section
id=
"rubric_${id}"
class=
"rubric-section"
>
<table
class=
"rubric"
>
</table>
</section>
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