[MediaWiki-commits] [Gerrit] mediawiki...Quiz[master]: Reassign numbering to shuffled questions
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/368993 ) Change subject: Reassign numbering to shuffled questions .. Reassign numbering to shuffled questions Currently the shuffled questions also shuffles the number which distorts the order in which the questions were shuffled.This patch reassigns the numbering by adding shuffleNumbering function. Bug:T170798 Change-Id: I71b0ae7ca47ef9d59a3f2bbba2d92ae35525b8d0 --- M modules/ext.quiz.js 1 file changed, 11 insertions(+), 2 deletions(-) Approvals: jenkins-bot: Verified Mvolz: Looks good to me, approved diff --git a/modules/ext.quiz.js b/modules/ext.quiz.js index 6ea708b..bb98f78 100644 --- a/modules/ext.quiz.js +++ b/modules/ext.quiz.js @@ -72,8 +72,16 @@ } } - /** -* Prepare the quiz for "javascriptable" browsers + // Reassign numbering to shuffled questions + function shuffleNumbering( $area ) { + $area = $area[0]; + var list = $area.getElementsByClassName( 'questionId' ); + for( var i =0; i < list.length ; ++i ) { + list[i].innerHTML = i+1; + } + } + + /** Prepare the quiz for "javascriptable" browsers * * @param {jQuery} $content The content area of the wiki page, * passed by the `wikipage.content` hook @@ -87,6 +95,7 @@ // Display the shuffle buttons $input.filter( '.shuffle' ).click( function () { shuffle( $( this.form ).find( 'div.quizQuestions' ) ); + shuffleNumbering( $( this.form ).find( 'div.quizQuestions' ) ); } ); // Display the reset button $input.filter( '.reset' ).click( function () { -- To view, visit https://gerrit.wikimedia.org/r/368993 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I71b0ae7ca47ef9d59a3f2bbba2d92ae35525b8d0 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/Quiz Gerrit-Branch: master Gerrit-Owner: HarjotsinghGerrit-Reviewer: Mvolz Gerrit-Reviewer: Reedy Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki...Quiz[master]: Reassign numbering to shuffled questions
Harjotsingh has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/368993 ) Change subject: Reassign numbering to shuffled questions .. Reassign numbering to shuffled questions Currently the shuffled questions also shuffles the number which distorts the order in which the questions were shuffled.This patch reassigns the numbering by adding shuffleNumbering function. Bug:T170798 Change-Id: I71b0ae7ca47ef9d59a3f2bbba2d92ae35525b8d0 --- M modules/ext.quiz.js 1 file changed, 9 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Quiz refs/changes/93/368993/1 diff --git a/modules/ext.quiz.js b/modules/ext.quiz.js index 441f44f..701c142 100644 --- a/modules/ext.quiz.js +++ b/modules/ext.quiz.js @@ -65,6 +65,14 @@ area.innerHTML = areaHTML; } + // Reassign numbering to shuffled questions + function shuffleNumbering( area ) { + var list = area.getElementsByClassName( 'questionId' ); + for( var i =0; i < list.length ; ++i ) { + list[i].innerHTML = i+1; + } + } + // Prepare the quiz for "javascriptable" browsers function prepareQuiz() { var bodyContentDiv = document.getElementById( 'mw-content-text' ).getElementsByTagName( 'div' ); @@ -84,6 +92,7 @@ /* jshint loopfunc:true */ input[j].onclick = function() { shuffle( this.form.getElementsByTagName( 'div' )[1] ); + shuffleNumbering( this.form.getElementsByTagName( 'div' )[1] ) var sh_input = this.form.getElementsByTagName( 'input' ); for( var k = 0; k < sh_input.length; ++k ) { // Add the possibility of unchecking radio buttons -- To view, visit https://gerrit.wikimedia.org/r/368993 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I71b0ae7ca47ef9d59a3f2bbba2d92ae35525b8d0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Quiz Gerrit-Branch: master Gerrit-Owner: Harjotsingh___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits