Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
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
OpenEdx
problem-builder
Commits
43721b0b
Commit
43721b0b
authored
Nov 19, 2013
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move AnswerBlock javascript to a dedicated JS file
parent
55a02fd1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
mentoring/answer.py
+3
-13
static/js/answer.js
+10
-0
No files found.
mentoring/answer.py
View file @
43721b0b
...
...
@@ -10,6 +10,7 @@ from xblock.fields import Any, Scope
from
xblock.fragment
import
Fragment
from
.models
import
Answer
from
.utils
import
load_resource
# Globals ###########################################################
...
...
@@ -41,20 +42,9 @@ class AnswerBlock(XBlock):
html
=
u'<textarea cols="100" rows="10" maxlength="{}" name="input">{}</textarea>'
.
format
(
Answer
.
_meta
.
get_field
(
'student_input'
)
.
max_length
,
self
.
student_input
)
fragment
=
Fragment
(
html
)
fragment
.
add_javascript
(
"""
function AnswerBlock(runtime, element) {
return {
submit: function() {
return $(element).find(':input').serializeArray();
},
handleSubmit: function(result) {
$(element).find('.message').text((result || {}).error || '');
}
}
}
"""
)
fragment
.
add_javascript
(
load_resource
(
'static/js/answer.js'
))
fragment
.
initialize_js
(
'AnswerBlock'
)
return
fragment
...
...
static/js/answer.js
0 → 100644
View file @
43721b0b
function
AnswerBlock
(
runtime
,
element
)
{
return
{
submit
:
function
()
{
return
$
(
element
).
find
(
':input'
).
serializeArray
();
},
handleSubmit
:
function
(
result
)
{
$
(
element
).
find
(
'.message'
).
text
((
result
||
{}).
error
||
''
);
}
}
}
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