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
074fde67
Commit
074fde67
authored
May 28, 2012
by
ichuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add mode and linenumbers options to textbox inputtype
parent
436a39ed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
djangoapps/courseware/capa/inputtypes.py
+4
-1
templates/textbox.html
+6
-1
No files found.
djangoapps/courseware/capa/inputtypes.py
View file @
074fde67
...
...
@@ -251,8 +251,11 @@ def textbox(element, value, status, msg=''):
eid
=
element
.
get
(
'id'
)
count
=
int
(
eid
.
split
(
'_'
)[
-
2
])
-
1
# HACK
size
=
element
.
get
(
'size'
)
mode
=
element
.
get
(
'mode'
)
or
'python'
# mode for CodeMirror, eg "python" or "xml"
linenumbers
=
element
.
get
(
'linenumbers'
)
# for CodeMirror
if
not
value
:
value
=
element
.
text
# if no student input yet, then use the default input given by the problem
context
=
{
'id'
:
eid
,
'value'
:
value
,
'state'
:
status
,
'count'
:
count
,
'size'
:
size
,
'msg'
:
msg
}
context
=
{
'id'
:
eid
,
'value'
:
value
,
'state'
:
status
,
'count'
:
count
,
'size'
:
size
,
'msg'
:
msg
,
'mode'
:
mode
,
'linenumbers'
:
linenumbers
}
html
=
render_to_string
(
"textbox.html"
,
context
)
return
etree
.
XML
(
html
)
...
...
templates/textbox.html
View file @
074fde67
...
...
@@ -24,7 +24,12 @@
// work.
$
(
function
(){
var
cm
=
CodeMirror
.
fromTextArea
(
document
.
getElementById
(
"input_${id}"
),
{
'mode'
:
"python"
});
{
'mode'
:
"${mode}"
%
if
linenumbers
==
'true'
:
,
lineNumbers
:
true
%
endif
});
// codemirror_set["${id}"] = cm; // track it for refreshes
});
</script>
<style
type=
"text/css"
>
...
...
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