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
4240ebab
Commit
4240ebab
authored
May 11, 2012
by
Isaac Chuang
Committed by
Piotr Mitros
May 11, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More minor cleanups
parent
e4a783b1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletions
+24
-1
djangoapps/courseware/capa/inputtypes.py
+24
-1
No files found.
djangoapps/courseware/capa/inputtypes.py
View file @
4240ebab
#
# File: courseware/capa/inputtypes.py
#
'''
Module containing the problem elements which render into input objects
- textline
- textbox (change this to textarea?)
- schemmatic
These are matched by *.html files templates/*.html which are mako templates with the actual html.
'''
from
lxml.etree
import
Element
from
lxml
import
etree
from
mitxmako.shortcuts
import
render_to_string
#-----------------------------------------------------------------------------
#takes the xml tree as 'element', the student's previous answer as 'value', and the graded status as 'state'
def
choicegroup
(
element
,
value
,
state
):
'''
Radio button inputs: multiple choice or true/false
TODO: allow order of choices to be randomized, following lon-capa spec. Use "location" attribute,
ie random, top, bottom.
'''
eid
=
element
.
get
(
'id'
)
if
element
.
get
(
'type'
)
==
"MultipleChoice"
:
type
=
"radio"
...
...
@@ -16,7 +39,7 @@ def choicegroup(element, value, state):
choices
=
{}
for
choice
in
element
:
assert
choice
.
tag
==
"choice"
,
"only <choice> tags should be immediate children of a <choicegroup>"
choices
[
choice
.
get
(
"name"
)]
=
etree
.
tostring
(
choice
[
0
])
choices
[
choice
.
get
(
"name"
)]
=
etree
.
tostring
(
choice
[
0
])
# TODO: what if choice[0] has math tags in it?
context
=
{
'id'
:
eid
,
'value'
:
value
,
'state'
:
state
,
'type'
:
type
,
'choices'
:
choices
}
html
=
render_to_string
(
"choicegroup.html"
,
context
)
return
etree
.
XML
(
html
)
...
...
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