Skip to content

Commit

Permalink
Fix incorrect parson validation #5430
Browse files Browse the repository at this point in the history
  • Loading branch information
boryanagoncharenko committed Aug 16, 2024
1 parent 2b504c5 commit 98d1c59
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions static/js/parsons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ export function get_parsons_code() {
let code = "";
let order = new Array();
let mistake = false;
let hiddenElementsCount = 0;
document.querySelectorAll<HTMLElement>('#parsons_code_container > div > div').forEach((element, key) => {
// We are not interested in elements that are hidden
if (!$(element).is(':visible')) {
hiddenElementsCount += 1;
return;
}
// the parent is the one that has the borders...
Expand All @@ -131,7 +133,7 @@ export function get_parsons_code() {
parent.classList.remove('border-green-500');
parent.classList.remove('border-red-500');
const index = element.dataset['index'] || 999;
if (index == key + 1) {
if (index == key + 1 - hiddenElementsCount) {
parent.classList.add('border-green-500');
} else {
mistake = true;
Expand Down Expand Up @@ -172,4 +174,4 @@ export function initializeParsons() {
const editor = editorCreator.initializeReadOnlyEditor(container as HTMLElement, 'ltr');
editorDict[i + 1] = editor;
})
}
}

0 comments on commit 98d1c59

Please sign in to comment.