Skip to content

Commit

Permalink
Steps quiz - fix content issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricokola committed Jul 15, 2024
1 parent 6e4a488 commit 82c16e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
17 changes: 14 additions & 3 deletions méli-mélo/2024-04-stepsquiz/js/stepsquiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
( function( $, document ) {
"use strict";

// Fetch page language and set variables accordingly
let relpreposition = " of ",
progressLabel = "Questionnaire progress:";

// Define French progress label
if ( wb.lang === "fr" ) {
relpreposition = " de ";
progressLabel = "Progression du questionnaire : ";

}


//Detect the enhancement of the quiz
var quizSelector = ".provisional.wb-steps.quiz",
instances = document.querySelectorAll( quizSelector );
Expand All @@ -19,8 +31,7 @@ instances.forEach ( ( instance ) => {
let numQuestion = $( "fieldset", $instance ).length;

// Addition to UI (Ex: progress bar)
$( "form", $instance ).prepend( "<p class='progressText' role='status'></p>" );
$( "form", $instance ).prepend( "<p><progress class='progressBar' max='" + numQuestion + "'></progress></p>" );
$( "form", $instance ).prepend( "<label>" + progressLabel + "<progress class='progressBar' max='" + numQuestion + "'></progress><p class='progressText' role='status'></p></label>" );

});

Expand Down Expand Up @@ -52,7 +63,7 @@ var hideOtherSteps = function( e ) {
let numQuestion = $progressBar.attr( "max" );

// Set the progress label
$( "p.progressText", steps ).text( currentTabId + " of " + numQuestion );
$( "p.progressText", steps ).text( currentTabId + relpreposition + numQuestion );

// Update progress bar
$progressBar.val( currentTabId );
Expand Down
3 changes: 2 additions & 1 deletion méli-mélo/2024-04-stepsquiz/stepsquiz.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
}

/* Customisation for the progress bar and text */
.provisional.wb-steps.quiz progress.progressBar{
.provisional.wb-steps.quiz progress.progressBar,
.provisional.wb-steps.quiz label {
/*-webkit-appearance: progress-bar;*/
width: 100%;
}
Expand Down

0 comments on commit 82c16e0

Please sign in to comment.