Commit 17750a7d by cahrens

Use min, max, and step values from server.

parent 5bd0442f
<div class="wrapper-comp-setting">
<label class="label setting-label" for="<%= uniqueId %>"><%= model.get('display_name') %></label>
<input class="input setting-input" type="number" min="1" max= "10" step="1" id="<%= uniqueId %>" value='<%= model.get("value") %>'/>
<input class="input setting-input" 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">&#x21A9;</i><span class="sr">Clear Value</span>
</button>
......
......@@ -8,7 +8,8 @@ CMS.Models.Metadata = Backbone.Model.extend({
"value" : null,
"explicitly_set": null,
"default_value" : null,
"options" : null
"options" : null,
"type" : null
},
initialize: function() {
......@@ -55,6 +56,10 @@ CMS.Models.Metadata = Backbone.Model.extend({
return this.get('options');
},
getType: function() {
return this.get('type');
},
clear: function() {
this.set('explicitly_set', false);
this.set('value', this.get('default_value'));
......
......@@ -159,6 +159,33 @@ CMS.Views.Metadata.Number = CMS.Views.Metadata.AbstractEditor.extend({
"click .setting-clear" : "clear"
},
render: function () {
CMS.Views.Metadata.AbstractEditor.prototype.render.apply(this);
if (!this.inputAttributesSet) {
var min = "min";
var max = "max";
var step = "step";
var options = this.model.getOptions();
if (options.hasOwnProperty(min)) {
this.$el.find('input').attr(min, options[min].toString());
}
if (options.hasOwnProperty(max)) {
this.$el.find('input').attr(max, options[max].toString());
}
var stepValue = undefined;
if (options.hasOwnProperty(step)) {
stepValue = options[step].toString();
}
else if (this.model.getType() === 'Integer') {
stepValue = "1";
}
if (stepValue !== undefined) {
this.$el.find('input').attr(step, stepValue);
}
this.inputAttributesSet = true;
}
},
getTemplateName : function () {
return "metadata_number_entry";
},
......
......@@ -89,7 +89,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 },
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.",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment