Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
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-ora2
Commits
f66e07ac
Commit
f66e07ac
authored
Jul 30, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Checkpoint -- option point validation
parent
8d668c5f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
118 additions
and
8 deletions
+118
-8
openassessment/xblock/static/js/spec/studio/oa_edit_rubric.js
+3
-3
openassessment/xblock/static/js/src/studio/oa_container_item.js
+69
-1
openassessment/xblock/static/js/src/studio/oa_edit_fields.js
+1
-1
openassessment/xblock/static/js/src/studio/oa_edit_rubric.js
+17
-2
scripts/render_templates.py
+28
-1
No files found.
openassessment/xblock/static/js/spec/studio/oa_edit_rubric.js
View file @
f66e07ac
...
@@ -227,8 +227,8 @@ describe("OpenAssessment.EditRubricView", function() {
...
@@ -227,8 +227,8 @@ describe("OpenAssessment.EditRubricView", function() {
// Valid option point values
// Valid option point values
testValidateOptionPoints
(
"0"
,
true
);
testValidateOptionPoints
(
"0"
,
true
);
testValidateOptionPoints
(
"1"
,
true
);
testValidateOptionPoints
(
"1"
,
true
);
testValidateOptionPoints
(
"2"
,
fals
e
);
testValidateOptionPoints
(
"2"
,
tru
e
);
testValidateOptionPoints
(
"998"
,
fals
e
);
testValidateOptionPoints
(
"998"
,
tru
e
);
testValidateOptionPoints
(
"999"
,
fals
e
);
testValidateOptionPoints
(
"999"
,
tru
e
);
});
});
});
});
openassessment/xblock/static/js/src/studio/oa_container_item.js
View file @
f66e07ac
...
@@ -38,6 +38,7 @@ Returns:
...
@@ -38,6 +38,7 @@ Returns:
OpenAssessment
.
RubricOption
=
function
(
element
,
notifier
)
{
OpenAssessment
.
RubricOption
=
function
(
element
,
notifier
)
{
this
.
element
=
element
;
this
.
element
=
element
;
this
.
notifier
=
notifier
;
this
.
notifier
=
notifier
;
this
.
MAX_POINTS
=
1000
;
$
(
this
.
element
).
focusout
(
$
.
proxy
(
this
.
updateHandler
,
this
));
$
(
this
.
element
).
focusout
(
$
.
proxy
(
this
.
updateHandler
,
this
));
};
};
...
@@ -164,6 +165,37 @@ OpenAssessment.RubricOption.prototype = {
...
@@ -164,6 +165,37 @@ OpenAssessment.RubricOption.prototype = {
"points"
:
optionPoints
"points"
:
optionPoints
}
}
);
);
},
/**
TODO
**/
validate
:
function
()
{
var
pointString
=
$
(
".openassessment_criterion_option_points"
,
this
.
element
).
val
();
var
matches
=
pointString
.
trim
().
match
(
/^
\d{1,3}
$/g
);
var
isValid
=
(
matches
!==
null
);
if
(
!
isValid
)
{
$
(
".openassessment_criterion_option_points"
,
this
.
element
)
.
addClass
(
"openassessment_highlighted_field"
);
}
return
isValid
;
},
/**
TODO
**/
validationErrors
:
function
()
{
var
sel
=
$
(
".openassessment_criterion_option_points"
,
this
.
element
);
var
hasError
=
sel
.
hasClass
(
"openassessment_highlighted_field"
);
return
hasError
?
[
"Option points are invalid"
]
:
[];
},
/**
TODO
**/
clearValidationErrors
:
function
()
{
$
(
".openassessment_criterion_option_points"
,
this
.
element
)
.
removeClass
(
"openassessment_highlighted_field"
);
}
}
};
};
...
@@ -301,6 +333,37 @@ OpenAssessment.RubricCriterion.prototype = {
...
@@ -301,6 +333,37 @@ OpenAssessment.RubricCriterion.prototype = {
"criterionUpdated"
,
"criterionUpdated"
,
{
'criterionName'
:
criterionName
,
'criterionLabel'
:
criterionLabel
}
{
'criterionName'
:
criterionName
,
'criterionLabel'
:
criterionLabel
}
);
);
},
/**
TODO
**/
validate
:
function
()
{
var
isValid
=
true
;
$
.
each
(
this
.
optionContainer
.
getAllItems
(),
function
()
{
isValid
=
(
isValid
&&
this
.
validate
());
});
return
isValid
;
},
/**
TODO
**/
validationErrors
:
function
()
{
var
errors
=
[];
$
.
each
(
this
.
optionContainer
.
getAllItems
(),
function
()
{
errors
=
errors
.
concat
(
this
.
validationErrors
());
});
return
errors
;
},
/**
TODO
**/
clearValidationErrors
:
function
()
{
$
.
each
(
this
.
optionContainer
.
getAllItems
(),
function
()
{
this
.
clearValidationErrors
();
});
}
}
};
};
...
@@ -343,5 +406,9 @@ OpenAssessment.TrainingExample.prototype = {
...
@@ -343,5 +406,9 @@ OpenAssessment.TrainingExample.prototype = {
addHandler
:
function
()
{},
addHandler
:
function
()
{},
removeHandler
:
function
()
{},
removeHandler
:
function
()
{},
updateHandler
:
function
()
{}
updateHandler
:
function
()
{},
validate
:
function
()
{
return
true
;
},
validationErrors
:
function
()
{
return
[];
},
clearValidationErrors
:
function
()
{}
};
};
\ No newline at end of file
openassessment/xblock/static/js/src/studio/oa_edit_fields.js
View file @
f66e07ac
...
@@ -155,7 +155,7 @@ OpenAssessment.DatetimeControl.prototype = {
...
@@ -155,7 +155,7 @@ OpenAssessment.DatetimeControl.prototype = {
var
dateHasError
=
$
(
this
.
datePicker
,
this
.
element
).
hasClass
(
"openassessment_highlighted_field"
);
var
dateHasError
=
$
(
this
.
datePicker
,
this
.
element
).
hasClass
(
"openassessment_highlighted_field"
);
var
timeHasError
=
$
(
this
.
timePicker
,
this
.
element
).
hasClass
(
"openassessment_highlighted_field"
);
var
timeHasError
=
$
(
this
.
timePicker
,
this
.
element
).
hasClass
(
"openassessment_highlighted_field"
);
if
(
dateHasError
)
{
errors
.
push
(
"Date is invalid"
);
}
if
(
dateHasError
)
{
errors
.
push
(
"Date is invalid"
);
}
if
(
timeHasError
)
{
errors
.
push
(
"Time is invalid"
);
}
if
(
timeHasError
)
{
errors
.
push
(
"Time is invalid"
);
}
return
errors
;
return
errors
;
...
...
openassessment/xblock/static/js/src/studio/oa_edit_rubric.js
View file @
f66e07ac
...
@@ -195,19 +195,34 @@ OpenAssessment.EditRubricView.prototype = {
...
@@ -195,19 +195,34 @@ OpenAssessment.EditRubricView.prototype = {
TODO
TODO
**/
**/
validate
:
function
()
{
validate
:
function
()
{
return
true
;
var
isValid
=
true
;
$
.
each
(
this
.
getAllCriteria
(),
function
()
{
isValid
=
(
isValid
&&
this
.
validate
());
});
return
isValid
;
},
},
/**
/**
TODO
TODO
**/
**/
validationErrors
:
function
()
{
validationErrors
:
function
()
{
return
[];
var
errors
=
[];
$
.
each
(
this
.
getAllCriteria
(),
function
()
{
errors
=
errors
.
concat
(
this
.
validationErrors
());
});
return
errors
;
},
},
/**
/**
TODO
TODO
**/
**/
clearValidationErrors
:
function
()
{
clearValidationErrors
:
function
()
{
$
.
each
(
this
.
getAllCriteria
(),
function
()
{
this
.
clearValidationErrors
();
});
}
}
};
};
scripts/render_templates.py
View file @
f66e07ac
...
@@ -25,6 +25,9 @@ templates.json file's directory.
...
@@ -25,6 +25,9 @@ templates.json file's directory.
import
sys
import
sys
import
os.path
import
os.path
import
json
import
json
import
re
import
dateutil.parser
import
pytz
# This is a bit of a hack to ensure that the root repo directory
# This is a bit of a hack to ensure that the root repo directory
# is in the Python path, so Django can find the settings module.
# is in the Python path, so Django can find the settings module.
...
@@ -36,6 +39,29 @@ from django.template.loader import get_template
...
@@ -36,6 +39,29 @@ from django.template.loader import get_template
USAGE
=
u"{prog} TEMPLATE_DESC"
USAGE
=
u"{prog} TEMPLATE_DESC"
ISO_DATE_REGEX
=
re
.
compile
(
"^
\
d{4}-
\
d{2}-
\
d{2}T
\
d{2}:
\
d{2}$"
)
def
parse_dates
(
context
):
"""
TODO
"""
if
isinstance
(
context
,
dict
):
return
{
key
:
parse_dates
(
value
)
for
key
,
value
in
context
.
iteritems
()
}
elif
isinstance
(
context
,
list
):
return
[
parse_dates
(
item
)
for
item
in
context
]
elif
isinstance
(
context
,
basestring
):
if
ISO_DATE_REGEX
.
match
(
context
)
is
not
None
:
return
dateutil
.
parser
.
parse
(
context
)
.
replace
(
tzinfo
=
pytz
.
utc
)
return
context
def
render_templates
(
root_dir
,
template_json
):
def
render_templates
(
root_dir
,
template_json
):
"""
"""
Create rendered templates.
Create rendered templates.
...
@@ -51,7 +77,8 @@ def render_templates(root_dir, template_json):
...
@@ -51,7 +77,8 @@ def render_templates(root_dir, template_json):
"""
"""
for
template_dict
in
template_json
:
for
template_dict
in
template_json
:
template
=
get_template
(
template_dict
[
'template'
])
template
=
get_template
(
template_dict
[
'template'
])
rendered
=
template
.
render
(
Context
(
template_dict
[
'context'
]))
context
=
parse_dates
(
template_dict
[
'context'
])
rendered
=
template
.
render
(
Context
(
context
))
output_path
=
os
.
path
.
join
(
root_dir
,
template_dict
[
'output'
])
output_path
=
os
.
path
.
join
(
root_dir
,
template_dict
[
'output'
])
try
:
try
:
...
...
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