Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ guide the learner’s interaction with the component.

**_shouldStoreResponses** (boolean): Optional. You can use this to track the user's responses to a particular Confidence Slider component. This functionality requires the Spoor extension to be installed and **\_spoor.\_tracking.\_shouldStoreResponses** (see *config.json*) set to `true`.

**\_feedback** (object): If the [**Tutor** extension](https://github.com/adaptlearning/adapt-contrib-tutor) is enabled, these various texts will be displayed depending on the submitted answer. **\_feedback** contains values for three seperate elements: generic, comparison and threshold feedback. Generic feedback is always presented to the user. Comparison feedback is presented on submission if the slider has been linked to another slider. Threshold feedback is determined according to the range in which the user's selection falls. All feedback elements are optional. Each element can be separated by one or more characters (such as a space) or, more commonly, by some HTML markup.
**\_feedback** (object): If the [**Tutor** extension](https://github.com/adaptlearning/adapt-contrib-tutor) is enabled, these various texts will be displayed depending on the submitted answer. **\_feedback** contains values for three separate elements: generic, comparison and threshold feedback. Generic feedback is always presented to the user. Comparison feedback is presented on submission if the slider has been linked to another slider. Threshold feedback is determined according to the range in which the user's selection falls. All feedback elements are optional. Each element can be separated by one or more characters (such as a space) or, more commonly, by some HTML markup.

>**title** (string): The text used as the feedback title. Leave empty if no display title is required.

Expand Down Expand Up @@ -121,4 +121,4 @@ Does not currently support a descending step value.
**Author / maintainer:** Adapt Core Team with [contributors](https://github.com/adaptlearning/adapt-contrib-confidenceSlider/graphs/contributors)<br>
**Accessibility support:** WAI AA<br>
**RTL support:** Yes<br>
**Cross-platform coverage:** Chrome, Chrome for Android, Firefox (ESR + latest version), Edge, IE11, Safari 12+13 for macOS/iOS/iPadOS, Opera<br>
**Cross-platform coverage:** Chrome, Chrome for Android, Firefox (ESR + latest version), Edge, Safari 14 for macOS/iOS/iPadOS, Opera<br>
117 changes: 112 additions & 5 deletions migrations/v5.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, whereContent, whereFromPlugin, mutateContent, checkContent, updatePlugin, getCourse, getComponents, testStopWhere, testSuccessWhere } from 'adapt-migrations';
import _ from 'lodash';

describe('adapt-contrib-confidenceSlider - v4.0.0 > v5.2.0', async () => {
describe('adapt-contrib-confidenceSlider - v4.0.0 to v5.2.0', async () => {
let course, courseConfidenceSliderGlobals, confidenceSliders;
const ariaUserAnswer = 'Earlier in the course, you provided {{{linkedValue}}} as an answer to this question.';

Expand Down Expand Up @@ -59,7 +59,7 @@ describe('adapt-contrib-confidenceSlider - v4.0.0 > v5.2.0', async () => {
});
});

describe('adapt-contrib-confidenceSlider - v5.2.0 > v5.2.3', async () => {
describe('adapt-contrib-confidenceSlider - v5.2.0 to v5.2.3', async () => {
let confidenceSliders;

whereFromPlugin('adapt-contrib-confidenceSlider - from v5.2.0', { name: 'adapt-contrib-confidenceSlider', version: '<5.2.3' });
Expand Down Expand Up @@ -128,7 +128,7 @@ describe('adapt-contrib-confidenceSlider - v5.2.0 > v5.2.3', async () => {
});
});

describe('adapt-contrib-confidenceSlider - v5.2.3 > v5.2.4', async () => {
describe('adapt-contrib-confidenceSlider - v5.2.3 to v5.2.4', async () => {
let confidenceSliders;

whereFromPlugin('adapt-contrib-confidenceSlider - from v5.2.3', { name: 'adapt-contrib-confidenceSlider', version: '<5.2.4' });
Expand Down Expand Up @@ -188,7 +188,7 @@ describe('adapt-contrib-confidenceSlider - v5.2.3 > v5.2.4', async () => {
});
});

describe('adapt-contrib-confidenceSlider - v5.2.4 > v5.4.4', async () => {
describe('adapt-contrib-confidenceSlider - v5.2.4 to v5.4.4', async () => {
let course, courseConfidenceSliderGlobals, confidenceSliders;
const newLabelStart = 'Start of the scale';
const newLabelEnd = 'End of the scale';
Expand Down Expand Up @@ -273,7 +273,7 @@ describe('adapt-contrib-confidenceSlider - v5.2.4 > v5.4.4', async () => {
});
});

describe('adapt-contrib-confidenceSlider - v5.4.4 > v5.4.6', async () => {
describe('adapt-contrib-confidenceSlider - v5.4.4 to v5.4.6', async () => {
let confidenceSliders;

whereFromPlugin('adapt-contrib-confidenceSlider - from v5.4.4', { name: 'adapt-contrib-confidenceSlider', version: '<5.4.6' });
Expand Down Expand Up @@ -337,3 +337,110 @@ describe('adapt-contrib-confidenceSlider - v5.4.4 > v5.4.6', async () => {
fromPlugins: [{ name: 'adapt-contrib-confidenceSlider', version: '5.2.4' }]
});
});

describe('adapt-contrib-confidenceSlider - @@CURRENT_VERSION to @@RELEASE_VERSION', async () => {
let confidenceSliders;

whereFromPlugin('adapt-contrib-confidenceSlider - from @@CURRENT_VERSION', { name: 'adapt-contrib-confidenceSlider', version: '<@@RELEASE_VERSION' });

mutateContent('adapt-contrib-confidenceSlider - delete confidenceSlider._correctAnswer', async () => {
confidenceSliders.forEach(confidenceSlider => {
if (_.has(confidenceSlider, '_correctAnswer')) {
delete confidenceSlider._correctAnswer;
}
});
return true;
});

mutateContent('adapt-contrib-confidenceSlider - delete confidenceSlider._correctRange', async () => {
confidenceSliders.forEach(confidenceSlider => {
if (_.has(confidenceSlider, '_correctRange')) {
delete confidenceSlider._correctRange;
}
});
return true;
});

mutateContent('adapt-contrib-confidenceSlider - delete confidenceSlider._showCorrectAnswer', async () => {
confidenceSliders.forEach(confidenceSlider => {
if (_.has(confidenceSlider, '_showCorrectAnswer')) {
delete confidenceSlider._showCorrectAnswer;
}
});
return true;
});

mutateContent('adapt-contrib-confidenceSlider - delete confidenceSlider._hideCorrectAnswer', async () => {
confidenceSliders.forEach(confidenceSlider => {
if (_.has(confidenceSlider, '_hideCorrectAnswer')) {
delete confidenceSlider._hideCorrectAnswer;
}
});
return true;
});

checkContent('adapt-contrib-confidenceSlider - check confidenceSlider._correctAnswer is deleted', async () => {
const isValid = confidenceSliders.every(({ _correctAnswer }) => _correctAnswer === null);
if (!isValid) throw new Error('adapt-contrib-confidenceSlider - _correctAnswer not deleted from every instance of confidenceSlider');
return true;
});

checkContent('adapt-contrib-confidenceSlider - check confidenceSlider._correctRange is deleted', async () => {
const isValid = confidenceSliders.every(({ _correctRange }) => _correctRange === null);
if (!isValid) throw new Error('adapt-contrib-confidenceSlider - _correctRange not deleted from every instance of confidenceSlider');
return true;
});

checkContent('adapt-contrib-confidenceSlider - check confidenceSlider._showCorrectAnswer is deleted', async () => {
const isValid = confidenceSliders.every(({ _showCorrectAnswer }) => _showCorrectAnswer === null);
if (!isValid) throw new Error('adapt-contrib-confidenceSlider - _showCorrectAnswer not deleted from every instance of confidenceSlider');
return true;
});

checkContent('adapt-contrib-confidenceSlider - check confidenceSlider._hideCorrectAnswer is deleted', async () => {
const isValid = confidenceSliders.every(({ _hideCorrectAnswer }) => _hideCorrectAnswer === null);
if (!isValid) throw new Error('adapt-contrib-confidenceSlider - _hideCorrectAnswer not deleted from every instance of confidenceSlider');
return true;
});

updatePlugin('adapt-contrib-confidenceSlider - update to @@RELEASE_VERSION', { name: 'adapt-contrib-confidenceSlider', version: '@@RELEASE_VERSION', framework: '>=5.19.1' });

testSuccessWhere('non/configured confidenceSlider component with empty course', {
fromPlugins: [{ name: 'adapt-contrib-confidenceSlider', version: '@@CURRENT_VERSION' }],
content: [
{ _id: 'c-100', _component: 'confidenceSlider', _feedback: {} },
{ _id: 'c-105', _component: 'confidenceSlider' },
{ _type: 'course' }
]
});

testSuccessWhere('non/configured confidenceSlider component with empty course._globals', {
fromPlugins: [{ name: 'adapt-contrib-confidenceSlider', version: '@@CURRENT_VERSION' }],
content: [
{ _id: 'c-100', _component: 'confidenceSlider', _feedback: {} },
{ _id: 'c-105', _component: 'confidenceSlider' },
{ _type: 'course', _globals: { _components: { _confidenceSlider: {} } } }
]
});

testSuccessWhere('non/configured confidenceSlider component with course._globals', {
fromPlugins: [{ name: 'adapt-contrib-confidenceSlider', version: '@@CURRENT_VERSION' }],
content: [
{ _id: 'c-100', _component: 'confidenceSlider', _feedback: {} },
{ _id: 'c-105', _component: 'confidenceSlider' },
{ _type: 'course', _globals: { _components: { _confidenceSlider: { labelStart: 1, labelEnd: 1 } } } }
]
});

testStopWhere('no confidenceSlider components', {
fromPlugins: [{ name: 'adapt-contrib-confidenceSlider', version: '@@CURRENT_VERSION' }],
content: [
{ _component: 'other' },
{ _type: 'course' }
]
});

testStopWhere('incorrect version', {
fromPlugins: [{ name: 'adapt-contrib-confidenceSlider', version: '@@RELEASE_VERSION' }]
});
});
93 changes: 7 additions & 86 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"title": "Attempts",
"inputType": "Number",
"validators": ["required", "number"],
"help": "How many attempts the learner is allowed"
"help": "How many attempts the learner is allowed. The default is 1 and must be left at this value."
},
"_shouldDisplayAttempts": {
"type": "boolean",
Expand Down Expand Up @@ -200,35 +200,6 @@
"validators": ["number"],
"help": "The amount the scale should increment by"
},
"_correctAnswer": {
"type": "string",
"default": "",
"title": "Correct Answer",
"inputType": "Text",
"validators": [],
"help": "Correct answer on the scale"
},
"_correctRange": {
"type": "object",
"properties": {
"_bottom": {
"type": "number",
"default": 0,
"title": "Correct Range - Bottom",
"inputType": "Number",
"validators": ["number"],
"help": "Correct bottom range answer on the scale -- ignored when 'Correct Answer' is set"
},
"_top": {
"type": "number",
"default": 0,
"title": "Correct Range - Top",
"inputType": "Number",
"validators": ["number"],
"help": "Correct top range answer on the scale -- ignored when 'Correct Answer' is set"
}
}
},
"_showNumber": {
"type": "boolean",
"required": true,
Expand Down Expand Up @@ -303,7 +274,8 @@
"_comparison": {
"type": "object",
"required": true,
"title": "Incorrect Feedback",
"title": "Feedback",
"help": "Text that will be shown on submission if the slider has been linked to another slider.",
"properties": {
"lower": {
"type": "string",
Expand All @@ -312,7 +284,7 @@
"title": "Lower",
"inputType": "TextArea",
"validators": [],
"help": "Lower",
"help": "This text will be shown if the user has selected a lower value than was chosen on the linked slider.",
"translatable": true
},
"same": {
Expand All @@ -322,7 +294,7 @@
"title": "Same",
"inputType": "TextArea",
"validators": [],
"help": "Same",
"help": "This text will be shown if both values are the same.",
"translatable": true
},
"higher": {
Expand All @@ -332,7 +304,7 @@
"title": "Higher",
"inputType": "TextArea",
"validators": [],
"help": "Higher",
"help": "This text will be shown if the user has selected a higher value than was chosen on the linked slider.",
"translatable": true
}
}
Expand All @@ -341,6 +313,7 @@
"type": "array",
"required": true,
"title": "Threshold",
"help": "Each item represents the feedback for a range of slider values.",
"items": {
"type": "object",
"required": true,
Expand Down Expand Up @@ -435,58 +408,6 @@
}
}
},
"_showCorrectAnswer": {
"type": "object",
"title": "Show Correct Answer",
"properties": {
"buttonText": {
"type": "string",
"required": false,
"default": "",
"title": "",
"inputType": "QuestionButton",
"validators": [],
"help": "Button label text to show the model answer",
"translatable": true
},
"ariaLabel": {
"type": "string",
"required": false,
"default": "",
"title": "",
"inputType": "QuestionButton",
"validators": [],
"help": "Aria label for the show model answer button",
"translatable": true
}
}
},
"_hideCorrectAnswer": {
"type": "object",
"title": "Hide Correct Answer",
"properties": {
"buttonText": {
"type": "string",
"required": false,
"default": "",
"title": "",
"inputType": "QuestionButton",
"validators": [],
"help": "Button label text to hide the model answer",
"translatable": true
},
"ariaLabel": {
"type": "string",
"required": false,
"default": "",
"title": "",
"inputType": "QuestionButton",
"validators": [],
"help": "Aria label for the hide model answer button",
"translatable": true
}
}
},
"_showFeedback": {
"type": "object",
"title": "Show Feedback",
Expand Down
Loading