Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 94a00f8

Browse files
authored
Merge pull request #1206 from vqum/master
Add Parsons distractor helptext
2 parents fb1370a + ef2343f commit 94a00f8

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

runestone/parsons/js/parsons.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,18 @@ export default class Parsons extends RunestoneBase {
279279
// Remove the options from the code
280280
// only options are #paired or #distractor
281281
var options = {};
282+
var distractIndex;
283+
var distractHelptext = "";
284+
if (textBlock.includes("#paired:")) {
285+
distractIndex = textBlock.indexOf("#paired:");
286+
distractHelptext = textBlock.substring(distractIndex + 8, textBlock.length).trim();
287+
textBlock = textBlock.substring(0, distractIndex + 7);
288+
}
289+
else if (textBlock.includes("#distractor:")) {
290+
distractIndex = textBlock.indexOf("#distractor:");
291+
distractHelptext = textBlock.substring(distractIndex + 12, textBlock.length).trim();
292+
textBlock = textBlock.substring(0, distractIndex + 11);
293+
}
282294
textBlock = textBlock.replace(
283295
/#(paired|distractor)/,
284296
function (mystring, arg1) {
@@ -298,9 +310,11 @@ export default class Parsons extends RunestoneBase {
298310
if (options["paired"]) {
299311
line.distractor = true;
300312
line.paired = true;
313+
line.distractHelptext = distractHelptext;
301314
} else if (options["distractor"]) {
302315
line.distractor = true;
303316
line.paired = false;
317+
line.distractHelptext = distractHelptext;
304318
} else {
305319
line.distractor = false;
306320
line.paired = false;
@@ -1491,6 +1505,10 @@ export default class Parsons extends RunestoneBase {
14911505
feedbackArea.attr("class", "alert alert-info");
14921506
feedbackArea.html($.i18n("msg_parson_not_solution"));
14931507
// Stop ability to select
1508+
if (block.lines[0].distractHelptext) {
1509+
block.view.setAttribute("data-toggle","tooltip");
1510+
block.view.setAttribute("title", block.lines[0].distractHelptext);
1511+
}
14941512
block.disable();
14951513
// If in answer area, move to source area
14961514
if (!block.inSourceArea()) {

0 commit comments

Comments
 (0)