Commit 216a6987 by Will Daly

Correctly update the label for student training if called multiple times

parent bb8bb0cd
......@@ -45,7 +45,7 @@ describe("OpenAssessment.StudentTrainingListener", function() {
listener = new OpenAssessment.StudentTrainingListener();
});
it("updates the label of an option", function() {
it("updates the label and points of an option", function() {
// Initial state, set by the fixture
assertExampleLabels(
listener.examplesOptionsLabels(),
......@@ -79,6 +79,48 @@ describe("OpenAssessment.StudentTrainingListener", function() {
);
});
it("updates an option twice", function() {
// Initial state, set by the fixture
assertExampleLabels(
listener.examplesOptionsLabels(),
{
criterion_with_two_options: {
"": "Not Selected",
option_1: "Fair - 1 points",
option_2: "Good - 2 points"
}
}
);
// Update the option label and points,
listener.optionUpdated({
criterionName: "criterion_with_two_options",
name: "option_1",
label: "This is a new label!",
points: 42
});
// Update the option again
listener.optionUpdated({
criterionName: "criterion_with_two_options",
name: "option_1",
label: "This is YET ANOTHER label!",
points: 18
});
// Verify the final state
assertExampleLabels(
listener.examplesOptionsLabels(),
{
criterion_with_two_options: {
"": "Not Selected",
option_1: "This is YET ANOTHER label! - 18 points",
option_2: "Good - 2 points"
}
}
);
});
it("updates the label of an option with invalid points", function() {
// If an option has invalid points, the points will be set to NaN
listener.optionUpdated({
......
......@@ -31,8 +31,8 @@ OpenAssessment.ItemUtilities = {
element (Jquery Element): The element that represents the object.
**/
refreshOptionString: function(element) {
var points = $(element).data('points');
var label = $(element).data('label');
var points = $(element).attr('data-points');
var label = $(element).attr('data-label');
var name = $(element).val();
// We don't want the lack of a label to make it look like - 1 points.
if (label === ""){
......
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