Commit ee97c2d6 by gradyward

Javascript changes for Student Training Authoring

parent fbd1e989
......@@ -2,11 +2,13 @@
{% spaceless %}
<li class="openassessment_assessment_module_settings_editor" id="oa_student_training_editor">
<div class = "drag-handle action"></div>
<div class = "openassessment_inclusion_wrapper">
<input type="checkbox" id="include_student_training"
{% if assessments.student_training %} checked="true" {% endif %}>
<label for="include_student_training">{% trans "Step: Student Training" %}</label>
</div>
<div class = "openassessment_assessment_module_editor">
<p id="student_training_description_closed" class="openassessment_description_closed {% if assessments.student_training %} is--hidden {% endif %}">
{% trans "Students learn to assess responses by scoring pre-assessed sample responses that the instructor provides. Students move to the next step when the scores they give match the instructor's scores. Note that Student Training Requires that the Peer Assessment module is also selected." %}
......@@ -15,20 +17,20 @@
<p class="openassessment_description">
{% trans "Enter one or more sample responses that you've created, together with the scores you would give those responses. Be sure to format the responses and scores according to the placeholder text below." %}
</p>
<ol>
<ol id="openassessment_training_example_list">
{% for example in assessments.training.examples %}
{% include "openassessmentblock/edit/oa_training_example.html" with example=example %}
{% endfor %}
</ol>
<div>
<div id="openassessment_add_training_example">
<h2 class='openassessment_add_training_example'>{% trans "Add Scored Response" %}</h2>
</div>
</div>
<ol id="openassessment_training_example_template" class="is--hidden">
{% include "openassessmentblock/edit/oa_training_example.html" with example=assessments.training.template %}
</ol>
</div>
</li>
<div id="openassessment_training_example_template" class="is--hidden">
{% include "openassessmentblock/edit/oa_training_example.html" with example=assessments.training.template %}
</div>
</li>
{% endspaceless %}
\ No newline at end of file
......@@ -23,7 +23,7 @@
<div class="wrapper-comp-setting">
<label class="openassessment_training_example_criterion_name setting-label">
{{criterion.name}}
<select class="openassessment_training_example_criterion_option setting-input">
<select class="openassessment_training_example_criterion_option setting-input" data-criterion={{criterion.name}}>
<option value="Not Scored">{% trans "Not Scored" %}</option>
{% for option in criterion.options %}
<option value={{option.name}}
......
......@@ -90,8 +90,29 @@ describe("OpenAssessment edit assessment views", function() {
});
it("Enables and disables", function() { testEnableAndDisable(view); });
// This test was deleted because it is obsolete due to Context Changes, but has not yet been
// Replaced by functionality in the JavaScript (which will be tested)
it("Loads a description", function () {
// This assumes a particular structure of the DOM,
// which is set by the HTML fixture.
var examples = view.exampleContainer.getItemValues();
expect(examples.length).toEqual(0);
});
it("Modifies a description", function () {
view.exampleContainer.add();
var examples = view.exampleContainer.getItemValues();
expect(examples.length).toEqual(1);
});
it("Returns the correct format", function () {
view.exampleContainer.add();
var examples = view.exampleContainer.getItemValues();
expect(examples).toEqual(
[
{
answer: "",
options_selected: []
}
]
);
});
});
describe("OpenAssessment.EditExampleBasedAssessmentView", function() {
......
......@@ -89,7 +89,7 @@ OpenAssessment.RubricCriterion.prototype = {
'name': 'Real Bad',
'points': 1,
'explanation': 'Essay was primarily composed of emojis.'
}
},
...
]
}
......@@ -126,4 +126,42 @@ OpenAssessment.RubricCriterion.prototype = {
addOption: function() {
this.optionContainer.add();
}
};
/**
The TrainingExample class is used to construct and retrieve information from its element within the DOM
Args:
element (JQuery Object): the selection which identifies the scope of the training example.
Returns:
OpenAssessment.TrainingExample
**/
OpenAssessment.TrainingExample = function(element){
this.element = element;
};
OpenAssessment.TrainingExample.prototype = {
/**
Returns the values currently stored in the fields associated with this training example.
**/
getFieldValues: function () {
// Iterates through all of the options selected by the training example, and adds them
// to a list.
var optionsSelected = [];
$(".openassessment_training_example_criterion_option", this.element) .each( function () {
optionsSelected.push({
criterion: $(this).data('criterion'),
option: $(this).prop('value')
});
});
return {
answer: $('.openassessment_training_example_essay', this.element).first().prop('value'),
options_selected: optionsSelected
};
}
};
\ No newline at end of file
......@@ -271,6 +271,16 @@ OpenAssessment.EditStudentTrainingView = function(element) {
"#student_training_description_closed",
"#student_training_settings_editor"
).install("#include_student_training");
this.exampleContainer = new OpenAssessment.Container(
OpenAssessment.TrainingExample, {
containerElement: $("#openassessment_training_example_list", this.element).get(0),
templateElement: $("#openassessment_training_example_template", this.element).get(0),
addButtonElement: $(".openassessment_add_training_example", this.element).get(0),
removeButtonClass: "openassessment_training_example_remove",
containerItemClass: "openassessment_training_example"
}
)
};
OpenAssessment.EditStudentTrainingView.prototype = {
......@@ -284,13 +294,27 @@ OpenAssessment.EditStudentTrainingView.prototype = {
Example usage:
>>> editTrainingView.description();
{
examples: "XML DEFINITION HERE"
examples: [
{
answer: "I love pokemon",
options_selected: [
{
criterion: "brevity",
option: "suberb"
},
criterion: "accuracy",
option: "alright"
}
...
]
},
...
]
}
**/
description: function() {
return {
examples: this.exampleDefinitions()
examples: this.exampleContainer.getItemValues()
};
},
......
......@@ -59,6 +59,11 @@ class StudioViewTest(XBlockHandlerTestCase):
frag = self.runtime.render(xblock, 'studio_view')
self.assertTrue(frag.body_html().find('openassessment-edit'))
@scenario('data/student_training.xml')
def test_render_studio_with_training(self, xblock):
frag = self.runtime.render(xblock, 'studio_view')
self.assertTrue(frag.body_html().find('openassessment-edit'))
@file_data('data/update_xblock.json')
@scenario('data/basic_scenario.xml')
def test_update_context(self, xblock, data):
......
......@@ -4,10 +4,10 @@
"repository": "https://github.com/edx/edx-ora2.git",
"devDependencies": {
"karma": "~0.12",
"karma-jasmine": "0.1.5",
"karma-chrome-launcher": "0.1.3",
"karma-coverage": "0.2.4",
"karma-phantomjs-launcher": "0.1.4",
"karma-jasmine": "0.1.5",
"karma-phantomjs-launcher": "^0.1.4",
"uglify-js": "2.3.6"
},
"scripts": {
......
......@@ -21,7 +21,7 @@ djangorestframework==2.3.5
lazy==1.1
loremipsum==1.0.2
python-dateutil==2.1
python-memcached==1.53
python-memcached==1.48
pytz==2012h
South==0.7.6
voluptuous==0.8.5
......
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