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
fdf7d331
Commit
fdf7d331
authored
Jul 22, 2014
by
gradyward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reverted to some of the old logic now that we are not using codemirror
parent
d3729038
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
59 additions
and
88 deletions
+59
-88
openassessment/xblock/defaults.py
+2
-2
openassessment/xblock/static/js/openassessment-studio.min.js
+0
-0
openassessment/xblock/static/js/spec/studio/oa_edit.js
+0
-28
openassessment/xblock/static/js/src/studio/oa_edit_assessment.js
+1
-9
openassessment/xblock/static/js/src/studio/oa_edit_fields.js
+1
-11
openassessment/xblock/studio_mixin.py
+18
-4
openassessment/xblock/test/data/invalid_update_xblock.json
+24
-28
openassessment/xblock/test/data/update_xblock.json
+4
-4
openassessment/xblock/test/test_studio.py
+0
-2
openassessment/xblock/xml.py
+9
-0
No files found.
openassessment/xblock/defaults.py
View file @
fdf7d331
...
...
@@ -133,8 +133,8 @@ DEFAULT_ASSESSMENT_MODULES = [
]
DEFAULT_EDITOR_ASSESSMENTS_ORDER
=
[
"example-based-assessment"
,
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
"self-assessment"
]
openassessment/xblock/static/js/openassessment-studio.min.js
View file @
fdf7d331
This diff is collapsed.
Click to expand it.
openassessment/xblock/static/js/spec/studio/oa_edit.js
View file @
fdf7d331
...
...
@@ -205,32 +205,4 @@ describe("OpenAssessment.StudioView", function() {
}
});
});
it
(
"installs checkbox listeners with callback"
,
function
()
{
this
.
funct
=
function
(){};
spyOn
(
this
,
'funct'
);
var
toggler
=
new
OpenAssessment
.
ToggleControl
(
view
.
element
,
"#ai_assessment_description_closed"
,
"#ai_assessment_settings_editor"
);
toggler
.
show
();
toggler
.
hide
();
expect
(
this
.
funct
.
calls
.
length
).
toEqual
(
0
);
toggler
=
new
OpenAssessment
.
ToggleControl
(
view
.
element
,
"#ai_assessment_description_closed"
,
"#ai_assessment_settings_editor"
,
this
.
funct
);
toggler
.
show
();
toggler
.
hide
();
expect
(
this
.
funct
.
calls
.
length
).
toEqual
(
2
);
});
});
openassessment/xblock/static/js/src/studio/oa_edit_assessment.js
View file @
fdf7d331
...
...
@@ -372,20 +372,12 @@ OpenAssessment.EditExampleBasedAssessmentView = function(element) {
this
.
element
=
element
;
this
.
name
=
"example-based-assessment"
;
this
.
codeBox
=
CodeMirror
.
fromTextArea
(
$
(
element
).
find
(
'#ai_training_examples'
).
first
().
get
(
0
),
{
mode
:
"xml"
,
lineNumbers
:
true
,
lineWrapping
:
true
}
);
var
view
=
this
;
new
OpenAssessment
.
ToggleControl
(
this
.
element
,
"#ai_assessment_description_closed"
,
"#ai_assessment_settings_editor"
,
function
()
{
view
.
codeBox
.
refresh
();
}
"#ai_assessment_settings_editor"
).
install
(
"#include_ai_assessment"
);
};
...
...
openassessment/xblock/static/js/src/studio/oa_edit_fields.js
View file @
fdf7d331
...
...
@@ -21,7 +21,6 @@ OpenAssessment.Fields = {
/**
Show and hide elements based on a checkbox.
Optionally includes a function to call when the checkbox is changed.
Args:
element (DOM element): The parent element, used to scope the selectors.
...
...
@@ -29,18 +28,11 @@ Args:
to show when the checkbox is in the "off" state.
shownSelector (string): The CSS selector string for elements
to show when the checkbox is in the "on" state.
updateFunction (function): OPTIONAL (defaults to function(){})
a parameter-less function to execute after control has been toggled
**/
OpenAssessment
.
ToggleControl
=
function
(
element
,
hiddenSelector
,
shownSelector
,
updateFunction
)
{
OpenAssessment
.
ToggleControl
=
function
(
element
,
hiddenSelector
,
shownSelector
)
{
this
.
element
=
element
;
this
.
hiddenSelector
=
hiddenSelector
;
this
.
shownSelector
=
shownSelector
;
if
(
typeof
updateFunction
===
"undefined"
){
this
.
updateFunction
=
function
()
{};
}
else
{
this
.
updateFunction
=
updateFunction
;
}
};
OpenAssessment
.
ToggleControl
.
prototype
=
{
...
...
@@ -68,13 +60,11 @@ OpenAssessment.ToggleControl.prototype = {
show
:
function
()
{
$
(
this
.
hiddenSelector
,
this
.
element
).
addClass
(
'is--hidden'
);
$
(
this
.
shownSelector
,
this
.
element
).
removeClass
(
'is--hidden'
);
this
.
updateFunction
();
},
hide
:
function
()
{
$
(
this
.
hiddenSelector
,
this
.
element
).
removeClass
(
'is--hidden'
);
$
(
this
.
shownSelector
,
this
.
element
).
addClass
(
'is--hidden'
);
this
.
updateFunction
();
}
};
...
...
openassessment/xblock/studio_mixin.py
View file @
fdf7d331
...
...
@@ -17,7 +17,7 @@ from openassessment.xblock.validation import validator
from
openassessment.xblock.data_conversion
import
create_rubric_dict
,
make_django_template_key
from
openassessment.xblock.schema
import
EDITOR_UPDATE_SCHEMA
from
openassessment.xblock.resolve_dates
import
resolve_dates
from
openassessment.xblock.xml
import
serialize_examples_to_xml_str
,
parse_examples_from_xml_str
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -144,8 +144,9 @@ class StudioMixin(object):
logger
.
exception
(
'Editor context is invalid'
)
return
{
'success'
:
False
,
'msg'
:
_
(
'Error updating XBlock configuration'
)}
# Check that the editor assessment order contains all the assessments
if
set
(
DEFAULT_EDITOR_ASSESSMENTS_ORDER
)
!=
set
(
data
[
'editor_assessments_order'
]):
# Check that the editor assessment order contains all the assessments. We are more flexible on example-based.
if
(
set
(
DEFAULT_EDITOR_ASSESSMENTS_ORDER
)
-
{
'example-based-assessment'
})
\
!=
(
set
(
data
[
'editor_assessments_order'
])
-
{
'example-based-assessment'
}):
logger
.
exception
(
'editor_assessments_order does not contain all expected assessment types'
)
return
{
'success'
:
False
,
'msg'
:
_
(
'Error updating XBlock configuration'
)}
...
...
@@ -162,6 +163,12 @@ class StudioMixin(object):
if
'name'
not
in
option
:
option
[
'name'
]
=
uuid4
()
.
hex
# If example based assessment is enabled, we replace it's xml definition with the dictionary
# definition we expect for validation and storing.
for
assessment
in
data
[
'assessments'
]:
if
assessment
[
'name'
]
==
'example-based-assessment'
:
assessment
[
'examples'
]
=
parse_examples_from_xml_str
(
assessment
[
'examples'
])
xblock_validator
=
validator
(
self
)
success
,
msg
=
xblock_validator
(
create_rubric_dict
(
data
[
'prompt'
],
data
[
'criteria'
]),
...
...
@@ -260,6 +267,13 @@ class StudioMixin(object):
else
:
assessments
[
'training'
]
=
{
'examples'
:
[
student_training_template
],
'template'
:
student_training_template
}
example_based_assessment
=
self
.
get_assessment_module
(
'example-based-assessment'
)
if
example_based_assessment
:
assessments
[
'example_based_assessment'
]
=
{
'examples'
:
serialize_examples_to_xml_str
(
example_based_assessment
)
}
return
assessments
def
_editor_assessments_order_context
(
self
):
...
...
@@ -285,7 +299,7 @@ class StudioMixin(object):
if
asmnt_name
in
order
]
if
problem_order_indices
!=
sorted
(
problem_order_indices
):
unused_assessments
=
list
(
set
(
DEFAULT_EDITOR_ASSESSMENTS_ORDER
)
-
set
(
used_assessments
))
unused_assessments
=
list
(
set
(
DEFAULT_EDITOR_ASSESSMENTS_ORDER
)
-
{
'example-based-assessment'
}
-
set
(
used_assessments
))
return
sorted
(
unused_assessments
)
+
used_assessments
# Forwards compatibility:
...
...
openassessment/xblock/test/data/invalid_update_xblock.json
View file @
fdf7d331
...
...
@@ -18,7 +18,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"submission_due"
:
"2014-02-27T09:46"
,
"submission_start"
:
"2014-02-10T09:46"
},
...
...
@@ -45,7 +45,7 @@
"explanation"
:
"Yes explanation"
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"feedback"
:
"optional"
}
],
...
...
@@ -108,7 +108,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"submission_due"
:
"2014-02-27T09:46"
,
"submission_start"
:
"2014-02-10T09:46"
},
...
...
@@ -154,7 +154,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"submission_start"
:
"2014-02-10T09:46"
},
...
...
@@ -199,7 +199,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"submission_due"
:
"2012-02-27T09:46"
,
"submission_start"
:
"2015-02-10T09:46"
,
"expected_error"
:
"the start date '2015-02-10 09:46:00+00:00' cannot be later than the due date '2012-02-27 09:46:00+00:00'"
...
...
@@ -246,7 +246,7 @@
"due"
:
"2003-01-02T00:00"
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"submission_due"
:
"2012-02-27T09:46"
,
"submission_start"
:
null
,
"expected_error"
:
"cannot be later"
...
...
@@ -286,7 +286,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"submission_due"
:
null
,
"submission_start"
:
null
},
...
...
@@ -324,7 +324,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"submission_due"
:
null
,
"submission_start"
:
null
},
...
...
@@ -344,7 +344,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"submission_due"
:
null
,
"submission_start"
:
null
},
...
...
@@ -382,7 +382,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"submission_due"
:
null
,
"submission_start"
:
null
},
...
...
@@ -408,7 +408,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"submission_due"
:
null
,
"submission_start"
:
null
},
...
...
@@ -442,7 +442,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"submission_due"
:
null
,
"submission_start"
:
null
},
...
...
@@ -480,7 +480,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"submission_due"
:
null
,
"submission_start"
:
null
},
...
...
@@ -519,7 +519,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"submission_due"
:
null
,
"submission_start"
:
null
,
"expected_error"
:
"error updating xblock configuration"
...
...
@@ -559,7 +559,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"submission_due"
:
null
,
"submission_start"
:
null
,
"expected_error"
:
"error updating xblock configuration"
...
...
@@ -599,7 +599,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"submission_due"
:
null
,
"submission_start"
:
null
},
...
...
@@ -652,7 +652,7 @@
"due"
:
"4014-03-10T00:00"
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
]
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
]
},
"student_training_example_missing_options_selected"
:
{
...
...
@@ -701,7 +701,7 @@
"due"
:
"4014-03-10T00:00"
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
]
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
]
},
"student_training_example_missing_criterion"
:
{
...
...
@@ -753,7 +753,7 @@
"due"
:
"4014-03-10T00:00"
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
]
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
]
},
"student_training_example_missing_option"
:
{
...
...
@@ -805,7 +805,7 @@
"due"
:
"4014-03-10T00:00"
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
]
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
]
},
"student_training_no_examples"
:
{
...
...
@@ -850,7 +850,7 @@
"due"
:
"4014-03-10T00:00"
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"expected_error"
:
"you must provide at least one example response for student training"
},
...
...
@@ -903,7 +903,7 @@
"due"
:
"4014-03-10T00:00"
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
],
"expected_error"
:
"example 1 has an extra option"
},
...
...
@@ -995,7 +995,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"self-assessment"
,
"example-based-assessment"
]
"editor_assessments_order"
:
[
"student-training"
,
"self-assessment"
]
},
"unrecognized_assessment_in_editor_assessments_order"
:
{
...
...
@@ -1041,10 +1041,6 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
,
"NOT A VALID ASSESSMENT"
]
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"NOT A VALID ASSESSMENT"
]
}
}
openassessment/xblock/test/data/update_xblock.json
View file @
fdf7d331
...
...
@@ -42,7 +42,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
]
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
]
},
"unicode"
:
{
...
...
@@ -88,7 +88,7 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
]
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
]
},
"student_training"
:
{
...
...
@@ -149,7 +149,7 @@
"due"
:
"4014-03-10T00:00"
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
]
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
]
},
"already_has_criteria_and_options_names_assigned"
:
{
...
...
@@ -198,6 +198,6 @@
"due"
:
null
}
],
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
"example-based-assessment"
]
"editor_assessments_order"
:
[
"student-training"
,
"peer-assessment"
,
"self-assessment"
]
}
}
openassessment/xblock/test/test_studio.py
View file @
fdf7d331
...
...
@@ -24,7 +24,6 @@ class StudioViewTest(XBlockHandlerTestCase):
"allow_file_upload"
:
False
,
"assessments"
:
[{
"name"
:
"self-assessment"
}],
"editor_assessments_order"
:
[
"example-based-assessment"
,
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
...
...
@@ -117,7 +116,6 @@ class StudioViewTest(XBlockHandlerTestCase):
# Update the XBlock with a different editor assessment order
data
=
copy
.
deepcopy
(
self
.
UPDATE_EDITOR_DATA
)
data
[
'editor_assessments_order'
]
=
[
"example-based-assessment"
,
"student-training"
,
"peer-assessment"
,
"self-assessment"
,
...
...
openassessment/xblock/xml.py
View file @
fdf7d331
...
...
@@ -803,3 +803,12 @@ def _unicode_to_xml(xml):
return
safe_etree
.
fromstring
(
xml
.
encode
(
'utf-8'
))
except
(
ValueError
,
safe_etree
.
ParseError
):
raise
UpdateFromXmlError
(
_
(
"An error occurred while parsing the XML content."
))
def
parse_examples_from_xml_str
(
xml
):
examples_root
=
_unicode_to_xml
(
xml
)
examples
=
examples_root
.
findall
(
'example'
)
return
parse_examples_xml
(
examples
)
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