Skip to content
Snippets Groups Projects
Commit 398fe37d authored by Eliott Sammier's avatar Eliott Sammier
Browse files

Add size hint attribute to open gaps

parent 6677057d
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,10 @@ export const gapfillOpenWidget = {
// It's a gap
// Create the <input> element
segmentElem = gapTemplate.cloneNode(true);
// Add the size attribute if present
if (segment.hasOwnProperty("size")) {
segmentElem.setAttribute("size", segment.size);
}
segmentElem.setAttribute("data-index", nbGaps); // The node knows its index
// Add listener to update the question's value when the input value changes
segmentElem.addEventListener("change", (e) => {
......
......@@ -44,9 +44,15 @@ export const json = {
title: "Open-ended gapfill",
segments: [
"Lorem ",
{size: 5}, // gaps can have a "size" attribute to hint how many characters are expected
" dolor sit ",
{},
" dolor sit amet [...]"
], correctAnswer: ["ipsum"]
", consectetur adipiscing elit [...]"
],
correctAnswer: [
"ipsum",
"amet"
]
}
]
};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment