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
2020923f
Commit
2020923f
authored
May 20, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent invalid numeric entries.
parent
c3569040
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
10 deletions
+38
-10
cms/static/client_templates/metadata_number_entry.html
+1
-1
cms/static/js/base.js
+0
-4
cms/static/js/views/metadata_editor_view.js
+36
-4
common/lib/xmodule/xmodule/capa_module.py
+1
-1
No files found.
cms/static/client_templates/metadata_number_entry.html
View file @
2020923f
<div
class=
"wrapper-comp-setting"
>
<label
class=
"label setting-label"
for=
"<%= uniqueId %>"
><
%=
model
.
get
('
display_name
')
%
></label>
<input
class=
"input setting-input setting-input-number"
type=
"number"
id=
"<%= uniqueId %>"
value=
'<%= model.get("value") %>'
onkeyup=
"checkNumberValidity(this)"
/>
<input
class=
"input setting-input setting-input-number"
type=
"number"
id=
"<%= uniqueId %>"
value=
'<%= model.get("value") %>'
/>
<button
class=
"action setting-clear inactive"
type=
"button"
name=
"setting-clear"
value=
"Clear"
data-tooltip=
"Clear"
>
<i
class=
"ss-icon ss-symbolicons-block undo"
>
↩
</i><span
class=
"sr"
>
Clear Value
</span>
</button>
...
...
cms/static/js/base.js
View file @
2020923f
...
...
@@ -897,9 +897,5 @@ function saveSetSectionScheduleDate(e) {
});
}
function
checkNumberValidity
(
e
)
{
//e.preventDefault;
//$(e).val($(e).val().match(/\d*\.?\d+/));
}
cms/static/js/views/metadata_editor_view.js
View file @
2020923f
...
...
@@ -150,7 +150,8 @@ CMS.Views.Metadata.Number = CMS.Views.Metadata.AbstractEditor.extend({
events
:
{
"change input"
:
"updateModel"
,
"keypress .setting-input"
:
"showClearButton"
,
"keypress .setting-input"
:
"keyPressed"
,
"change .setting-input"
:
"changed"
,
"click .setting-clear"
:
"clear"
},
...
...
@@ -162,14 +163,17 @@ CMS.Views.Metadata.Number = CMS.Views.Metadata.AbstractEditor.extend({
var
step
=
"step"
;
var
options
=
this
.
model
.
getOptions
();
if
(
options
.
hasOwnProperty
(
min
))
{
this
.
$el
.
find
(
'input'
).
attr
(
min
,
options
[
min
].
toString
());
this
.
min
=
Number
(
options
[
min
]);
this
.
$el
.
find
(
'input'
).
attr
(
min
,
this
.
min
.
toFixed
(
4
));
}
if
(
options
.
hasOwnProperty
(
max
))
{
this
.
$el
.
find
(
'input'
).
attr
(
max
,
options
[
max
].
toString
());
this
.
max
=
Number
(
options
[
max
]);
this
.
$el
.
find
(
'input'
).
attr
(
max
,
this
.
max
.
toFixed
(
4
));
}
var
stepValue
=
undefined
;
if
(
options
.
hasOwnProperty
(
step
))
{
stepValue
=
options
[
step
].
toString
();
// Parse step and convert to String. Polyfill doesn't like float values like ".1" (expects "0.1").
stepValue
=
Number
(
options
[
step
]).
toFixed
(
4
);
}
else
if
(
this
.
model
.
getType
()
===
'Integer'
)
{
stepValue
=
"1"
;
...
...
@@ -195,7 +199,35 @@ CMS.Views.Metadata.Number = CMS.Views.Metadata.AbstractEditor.extend({
setValueInEditor
:
function
(
value
)
{
this
.
$el
.
find
(
'input'
).
val
(
value
);
},
keyPressed
:
function
(
e
)
{
this
.
showClearButton
();
// This first filtering if statement is take from polyfill to prevent
// non-numeric input (for browsers that don't use polyfill because they DO have a number input type).
var
_ref
,
_ref1
;
if
(((
_ref
=
e
.
keyCode
)
!==
8
&&
_ref
!==
9
&&
_ref
!==
35
&&
_ref
!==
36
&&
_ref
!==
37
&&
_ref
!==
39
)
&&
((
_ref1
=
e
.
which
)
!==
45
&&
_ref1
!==
46
&&
_ref1
!==
48
&&
_ref1
!==
49
&&
_ref1
!==
50
&&
_ref1
!==
51
&&
_ref1
!==
52
&&
_ref1
!==
53
&&
_ref1
!==
54
&&
_ref1
!==
55
&&
_ref1
!==
56
&&
_ref1
!==
57
))
{
e
.
preventDefault
();
}
// For integers, prevent decimal points.
if
(
this
.
model
.
getType
()
===
'Integer'
&&
e
.
keyCode
===
46
)
{
e
.
preventDefault
();
}
},
changed
:
function
()
{
// Limit value to the range specified by min and max (necessary for browsers that aren't using polyfill).
var
value
=
this
.
getValueFromEditor
();
if
((
this
.
max
!==
undefined
)
&&
value
>
this
.
max
)
{
value
=
this
.
max
;
}
else
if
((
this
.
min
!=
undefined
)
&&
value
<
this
.
min
)
{
value
=
this
.
min
;
}
this
.
setValueInEditor
(
value
);
}
});
...
...
common/lib/xmodule/xmodule/capa_module.py
View file @
2020923f
...
...
@@ -92,7 +92,7 @@ class CapaFields(object):
seed
=
StringyInteger
(
help
=
"Random seed for this student"
,
scope
=
Scope
.
user_state
)
weight
=
StringyFloat
(
display_name
=
"Problem Weight"
,
help
=
"Specifies the number of points the problem is worth. If unset, each response field in the problem is worth one point."
,
values
=
{
"min"
:
0
,
"step"
:
".1"
},
values
=
{
"min"
:
0
,
"step"
:
.
1
},
scope
=
Scope
.
settings
)
markdown
=
String
(
help
=
"Markdown source of this module"
,
scope
=
Scope
.
settings
)
source_code
=
String
(
help
=
"Source code for LaTeX and Word problems. This feature is not well-supported."
,
...
...
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