Skip to content

Commit

Permalink
Test: Fix Ordering Horizontal Question in LM
Browse files Browse the repository at this point in the history
  • Loading branch information
kergomard committed Jan 30, 2025
1 parent 0238230 commit 479671b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
if (typeof MathJax != "undefined") {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, "container{VAL_ID}"]);
}
il.test.orderinghorizontal.init(document.querySelector('#container{VAL_ID}'));
il.test.orderingvertical.init(document.querySelector('#container{VAL_ID}'));
}
</script>
<!-- END orderingquestion -->
Expand Down Expand Up @@ -339,7 +339,10 @@
<div class="ilc_qtitle_Title question id@id">qtitle</div>
<div style="margin-bottom:10px">
<ul id="order{VAL_ID}" class="ilc_qordul_OrderListHorizontal">
<li class="answers ilc_qordli_OrderListItemHorizontal order@id"><div class="ilc_qanswer_Answer answertext"></div></li>
<li class="answers ilc_qordli_OrderListItemHorizontal order@id" draggable="true">
<div class="ilc_qanswer_Answer answertext"></div>
</li>
<li class="c-test__dropzone"></li>
</ul>
<div style="clear:both;"></div>
</div>
Expand All @@ -351,8 +354,8 @@
{
ilias.questions.shuffle(questions[{VAL_ID}]);
jQuery('div#container{VAL_ID}').autoRender(questions[{VAL_ID}]);
jQuery("#order{VAL_ID}").sortable({containment: '#container{VAL_ID}'});
jQuery("#order{VAL_ID}").css('font-size', questions[{VAL_ID}].textsize+'%');
document.querySelector("#order{VAL_ID}").style.fontSize = questions[{VAL_ID}].textsize+'%';
il.test.orderinghorizontal.init(document.querySelector('#order{VAL_ID}'));
}
</script>
<!-- END orderinghorizontal -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,24 +343,23 @@ ilias.questions.handleOrderingImages = function(a_id) {

ilias.questions.assOrderingHorizontal = function(a_id) {

var result = jQuery('#order'+a_id).sortable('toArray');
var result = document.querySelectorAll(`#order${a_id} > .answers`);

answers[a_id].wrong = 0;
answers[a_id].passed = true;
answers[a_id].choice = [];

for (var i=0;i<result.length;i++) {
if (i+1 != result[i])
if (i+1 !== parseInt(result[i].id))
{
answers[a_id].passed = false;
answers[a_id].wrong ++;
answers[a_id].answer[i]=false;
} else {
answers[a_id].answer[i]=true;
}
answers[a_id].choice.push(result[i]);
answers[a_id].choice.push(result[i].id);
}

ilias.questions.showFeedback(a_id);
};

Expand Down Expand Up @@ -1141,7 +1140,11 @@ ilias.questions.showCorrectAnswers =function(a_id) {
(item, i) => {
item.draggable = false;
item.id = i + 1;
item.firstElementChild.firstElementChild.innerHtml = answers_sorted[i].answertext;
let content_item = item.firstElementChild
if (content_item.firstElementChild !== null) {
content_item = content_item.firstElementChild;
}
content_item.innerHtml = answers_sorted[i].answertext;
}
);
ilias.questions.handleOrderingImages(a_id);
Expand Down

0 comments on commit 479671b

Please sign in to comment.