jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/362793 )
Change subject: Use CSS and jQuery, JavaScript hook instead of window.onload ...................................................................... Use CSS and jQuery, JavaScript hook instead of window.onload Rewrite the JavaScript file using jQuery, use the `wikipage.content` hook instead of `window.onload` to make it work in certain situations like live preview or after VisualEditor save. Change style attributes added by JavaScript and PHP to CSS classes; also make CSS work in JavaScript-less environment. Make JavaScript and CSS available on mobile (MobileFrontend). Bug: T146370 Change-Id: I0872fafce8cd50aafbc1f1c134eb89236f16c16a --- M Question.php M Quiz.class.php M extension.json M modules/ext.quiz.css M modules/ext.quiz.js M templates/Answer.mustache M templates/Question.mustache M templates/Quiz.mustache M templates/Setting.mustache M tests/phpunit/QuestionTest.php M tests/phpunit/QuizTest.php 11 files changed, 247 insertions(+), 244 deletions(-) Approvals: jenkins-bot: Verified Mvolz: Looks good to me, approved diff --git a/Question.php b/Question.php index 4868061..f6916b6 100644 --- a/Question.php +++ b/Question.php @@ -174,7 +174,9 @@ $typeId = substr( $this->mType, 0, 1 ); $typeId .= array_key_exists( 1, $matches ) ? 'c' : 'n'; foreach ( $matches as $signId => $sign ) { - $title = $disabled = $inputStyle = ''; + $attribs = []; + $attribs['type'] = $inputType; + $attribs['class'] = 'check'; // Determine the input's name and value. switch ( $typeId ) { case 'mn': @@ -195,9 +197,9 @@ break; } // Determine if the input had to be checked. - $checked = $this->mBeingCorrected && $this->mRequest->getVal( $name ) == $value - ? 'checked="checked"' - : null; + if ( $this->mBeingCorrected && $this->mRequest->getVal( $name ) == $value ) { + $attribs['checked'] = 'checked'; + } // Determine the color of the cell and modify the state of the question. switch ( $sign ) { case '+': @@ -205,42 +207,30 @@ // A single choice object with many correct proposal is a syntax error. if ( $this->mType == 'singleChoice' && $expectOn > 1 ) { $this->setState( 'error' ); - $inputStyle = 'style="outline: ' . Quiz::getColor( 'error' ) . - ' solid 3px; *border: 3px solid ' . Quiz::getColor( 'error' ) . - ';"'; - $title = 'title="' . - wfMessage( 'quiz_colorError' )->escaped() . '"'; - $disabled = 'disabled="disabled"'; + $attribs['class'] .= ' error'; + $attribs['title'] = wfMessage( 'quiz_colorError' )->escaped(); + $attribs['disabled'] = 'disabled'; } if ( $this->mBeingCorrected ) { - if ( $checked ) { + if ( array_key_exists( 'checked', $attribs ) ) { $checkedCount++; $this->setState( 'right' ); - $inputStyle = 'style="outline: ' . Quiz::getColor( 'right' ) . - ' solid 3px; *border: 3px solid ' . - Quiz::getColor( 'right' ) . ';"'; - $title = 'title="' . wfMessage( 'quiz_colorRight' )->escaped() . - '"'; + $attribs['class'] .= ' right'; + $attribs['title'] = wfMessage( 'quiz_colorRight' )->escaped(); } else { $this->setState( 'na_wrong' ); - $inputStyle = 'style="outline: ' . Quiz::getColor( 'wrong' ) . - ' solid 3px; *border: 3px solid ' . - Quiz::getColor( 'wrong' ) . ';"'; - $title = 'title="' . wfMessage( 'quiz_colorWrong' )->escaped() . - '"'; + $attribs['class'] .= ' wrong'; + $attribs['title'] = wfMessage( 'quiz_colorWrong' )->escaped(); } } break; case '-': if ( $this->mBeingCorrected ) { - if ( $checked ) { + if ( array_key_exists( 'checked', $attribs ) ) { $checkedCount++; $this->setState( 'wrong' ); - $inputStyle = 'style="outline: ' . Quiz::getColor( 'wrong' ) . - ' solid 3px; *border: 3px solid ' . - Quiz::getColor( 'wrong' ) . ';"'; - $title = 'title="' . wfMessage( 'quiz_colorWrong' )->escaped() . - '"'; + $attribs['class'] .= ' wrong'; + $attribs['title'] = wfMessage( 'quiz_colorWrong' )->escaped(); } else { $this->setState( 'na_right' ); } @@ -248,17 +238,13 @@ break; default: $this->setState( 'error' ); - $inputStyle = 'style="outline: ' . Quiz::getColor( 'error' ) . - ' solid 3px; *border: 3px solid ' . Quiz::getColor( 'error' ) . - ';"'; - $title = 'title="' . wfMessage( 'quiz_colorError' )->escaped() . "\""; - $disabled = 'disabled="disabled"'; + $attribs['class'] .= ' error'; + $attribs['title'] = wfMessage( 'quiz_colorError' )->escaped(); + $attribs['disabled'] = 'disabled'; break; } $signesOutput .= '<td class="sign">'; - $signesOutput .= '<input class="check" ' . $inputStyle . ' type="' . - $inputType . '" ' . $title . ' name="' . $name . '" value="' . $value . - '" ' . $checked . ' ' . $disabled . ' />'; + $signesOutput .= Xml::input( $name, false, $value, $attribs ); $signesOutput .= '</td>'; } if ( $typeId == 'sc' ) { @@ -379,6 +365,7 @@ $wqInputId++; $title = ''; $state = ''; + $spanClass = ''; $size = ''; $maxlength = ''; $class = ''; @@ -497,9 +484,7 @@ } } if ( $state == 'error' || $this->mBeingCorrected ) { - global $wgContLang; - $border = $wgContLang->isRTL() ? 'border-right' : 'border-left'; - $style = $border . ':3px solid ' . Quiz::getColor( $state ) . ';'; + $spanClass .= " border $state"; $this->setState( $value === "" ? 'new_NA' : $state ); if ( $state == 'error' ) { $size = ''; @@ -512,9 +497,9 @@ $temp = $templateParser->processTemplate( 'Answer', [ - 'style' => $style, 'title' => $title, 'class' => $class, + 'spanClass' => trim( $spanClass ), 'value' => $value, 'correction' => $this->mBeingCorrected, 'possibility' => $poss, diff --git a/Quiz.class.php b/Quiz.class.php index 0a43cfa..ffa930d 100644 --- a/Quiz.class.php +++ b/Quiz.class.php @@ -3,14 +3,6 @@ * Processes quiz markup */ class Quiz { - // Quiz colors - private static $mColors = [ - 'right' => '#1FF72D', - 'wrong' => '#F74245', - 'correction' => '#F9F9F9', - 'NA' => '#2834FF', - 'error' => '#D700D7' - ]; private static $sQuizId = 0; protected $mScore; @@ -102,21 +94,6 @@ } /** - * Accessor for the color array - * Displays an error message if the colorId doesn't exists. - * - * @param $colorId Integer: color hex code - * @return string - * @throws Exception - */ - public static function getColor( $colorId ) { - if ( array_key_exists( $colorId, self::$mColors ) ) { - return self::$mColors[$colorId]; - } - throw new Exception( 'Invalid color ID: ' . $colorId ); - } - - /** * Convert the input text to an HTML output. * * @param $input String: text between <quiz> and </quiz> tags, in quiz syntax. @@ -125,8 +102,8 @@ function parseQuiz( $input ) { // Ouput the style and the script to the header once for all. if ( $this->mQuizId == 0 ) { - global $wgOut; - $wgOut->addModules( 'ext.quiz' ); + $this->mParser->getOutput()->addModules( 'ext.quiz' ); + $this->mParser->getOutput()->addModuleStyles( 'ext.quiz.styles' ); } // Process the input @@ -157,12 +134,6 @@ 'quiz_colorNA' => wfMessage( 'quiz_colorNA' )->text(), 'quiz_colorError' => wfMessage( 'quiz_colorError' )->text(), 'quiz_shuffle' => wfMessage( 'quiz_shuffle' )->text() - ], - 'color' => [ - 'colorWrong' => self::getColor( 'wrong' ), - 'colorRight' => self::getColor( 'right' ), - 'colorNA' => self::getColor( 'NA' ), - 'colorError' => self::getColor( 'error' ) ], 'mAddedPoints' => $this->mAddedPoints, 'mCutoffPoints' => $this->mCutoffPoints, @@ -342,16 +313,10 @@ // Set default table title and style $tableTitle = ""; - $tableStyle = ""; $lState = $question->getState(); // right wrong or unanswered? if ( $lState != '' ) { - // TODO: convert to CSS classes - global $wgContLang; - $border = $wgContLang->isRTL() ? 'border-right' : 'border-left'; - $tableStyle = $border . ': 3px solid ' . self::getColor( $lState ) . ';'; - // if the question is of type=simple if ( $this->mIgnoringCoef ) { $question->mCoef = 1; @@ -396,7 +361,7 @@ } $stateObject = [ - 'tableStyle' => $tableStyle, + 'state' => $lState, 'tableTitle' => $tableTitle ]; diff --git a/extension.json b/extension.json index e8b52e5..5987d5f 100644 --- a/extension.json +++ b/extension.json @@ -19,8 +19,12 @@ "ResourceModules": { "ext.quiz": { "scripts": "ext.quiz.js", + "position": "top", + "targets": [ "desktop", "mobile" ] + }, + "ext.quiz.styles": { "styles": "ext.quiz.css", - "position": "top" + "targets": [ "desktop", "mobile" ] } }, "ResourceFileModulePaths": { diff --git a/modules/ext.quiz.css b/modules/ext.quiz.css index ace8216..fb14907 100644 --- a/modules/ext.quiz.css +++ b/modules/ext.quiz.css @@ -1,5 +1,5 @@ .quiz .settings input.numerical { - width: 2em; + width: 3em; } * > .quiz .header .questionId { @@ -28,6 +28,90 @@ .quiz .margin { padding-left: 20px; +} + +.quiz .margin.right { + background-color: #1ff72d; +} + +.quiz .margin.wrong { + background-color: #f74245; +} + +.quiz .margin.correction { + background-color: #f9f9f9; +} + +.quiz .margin.NA { + background-color: #2834ff; +} + +.quiz .margin.error { + background-color: #d700d7; +} + +/* This should be based on content direction, not interface direction */ +/* @noflip */ +.mw-content-ltr .quiz .question .border { + border-width: 0 0 0 3px; +} + +/* @noflip */ +.mw-content-rtl .quiz .question .border { + border-width: 0 3px 0 0; +} + +.quiz .question .border.right, +.quiz .question .border.wrong, +.quiz .question .border.correction, +.quiz .question .border.NA, +.quiz .question .border.error { + border-style: solid; +} + +.quiz .question .border.right { + border-color: #1ff72d; +} + +.quiz .question .border.wrong { + border-color: #f74245; +} + +.quiz .question .border.correction { + border-color: #f9f9f9; +} + +.quiz .question .border.NA { + border-color: #2834ff; +} + +.quiz .question .border.error { + border-color: #d700d7; +} + +.quiz .question .check.right { + outline: 3px solid #1ff72d; + *border: 3px solid #1ff72d; +} + +.quiz .question .check.wrong { + outline: 3px solid #f74245; + *border: 3px solid #f74245; +} + +.quiz .question .check.correction { + outline: 3px solid #f9f9f9; + *border: 3px solid #f9f9f9; +} + +.quiz .question .check.NA { + outline: 3px solid #2834ff; + *border: 3px solid #2834ff; +} + +.quiz .question .check.error { + outline: 3px solid #d700d7; + *border: 3px solid #d700d7; } .quiz .header .questionId { @@ -83,3 +167,8 @@ position: absolute; margin: 1.8em 0 0 0.1em; } + +.client-nojs .quiz .shuffle, +.client-nojs .quiz .reset { + display: none; +} diff --git a/modules/ext.quiz.js b/modules/ext.quiz.js index 441f44f..6ea708b 100644 --- a/modules/ext.quiz.js +++ b/modules/ext.quiz.js @@ -25,7 +25,7 @@ * * Create a new directory named Quiz into the "extensions" directory of MediaWiki. * * Place this file and the files Quiz.i18n.php and Quiz.php there. * * Add this line at the end of your LocalSettings.php file : - * require_once 'extensions/Quiz/Quiz.php'; + * wfLoadExtension( 'Quiz' ); * * @file * @version 1.0 @@ -36,119 +36,98 @@ (function () { 'use strict'; - // Shuffle questions - function shuffle( area ) { - var div = area.childNodes; - var quizText; + /** + * Shuffle questions + * + * @private + * + * @param {jQuery} $area The quiz area to shuffle. + */ + function shuffle( $area ) { + var $div = $area.children(), + questions = []; - for( var i = 0, questions = []; i < div.length; ++i ) { - if( div[i].className ) { - if( questions.length === 0 && div[i].className === 'quizText' ) { - quizText = div[i]; - } else { - questions.push( div[i] ); - if( div[i].className === 'shuffle' || div[i].className === 'noshuffle' ) { - shuffle( div[i] ); - } + $div.each( function () { + // Leave quiz text in place + if ( questions.length > 0 || !$( this ).hasClass( 'quizText' ) ) { + questions.push( this ); + if ( $( this ).hasClass( 'shuffle' ) || $( this ).hasClass( 'noshuffle' ) ) { + shuffle( $( this ) ); } + $( this ).detach(); + } + } ); + + if ( !$area.hasClass( 'noshuffle' ) ) { + var l, x; + for ( var m = questions.length - 1; m >= 0; m-- ) { + l = parseInt( Math.random() * m ); + x = questions[ m ]; + questions[ m ] = questions[ l ]; + questions[ l ] = x; } } - if( area.className !== 'noshuffle' ) { - for( var l, x, m = questions.length; m; l = parseInt( Math.random() * m ), x = questions[--m], questions[m] = questions[l], questions[l] = x ); + for ( var i = 0; i < questions.length; i++ ) { + $area.append( questions[ i ] ); } - if( quizText ) { - questions.unshift( quizText ); - } - for( var j = 0, areaHTML = ''; j < questions.length; ++j ) { - areaHTML += '<div class="' + questions[j].className + '">' + questions[j].innerHTML + '</div>'; - } - area.innerHTML = areaHTML; } - // Prepare the quiz for "javascriptable" browsers - function prepareQuiz() { - var bodyContentDiv = document.getElementById( 'mw-content-text' ).getElementsByTagName( 'div' ); - for( var i = 0; i < bodyContentDiv.length; ++i ) { - if( bodyContentDiv[i].className === 'quiz' ) { - var input = bodyContentDiv[i].getElementsByTagName( 'input' ); - for( var j = 0; j < input.length; ++j ) { - // Add the possibility of unchecking radio buttons - if( input[j].type === 'radio' ) { - input[j].ondblclick = function() { - this.checked = false; - }; - } - // Displays the shuffle buttons. - else if( input[j].className === 'shuffle' ) { - input[j].style.display = 'inline'; - /* jshint loopfunc:true */ - input[j].onclick = function() { - shuffle( 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 - if( input[k].type === 'radio' ) { - input[k].ondblclick = function() { - this.checked = false; - }; - } - } - }; - /* jshint loopfunc:false */ - } - // Display the reset button - else if( input[j].className === 'reset' ) { - input[j].style.display = 'inline'; - input[j].onclick = function() { - this.form.quizId.value = ''; - this.form.submit(); - }; - } - // Correct the bug of ie6 on textfields - else if( input[j].className === 'numbers' || input[j].className === 'words' ) { - if( typeof document.body.style.maxHeight === 'undefined' ) { - input[j].parentNode.onclick = function() { - this.parentNode.firstChild.style.display = 'inline'; - this.parentNode.firstChild.style.position = 'absolute'; - this.parentNode.firstChild.style.marginTop = '1.7em'; - }; - input[j].parentNode.onmouseout = function() { - this.parentNode.firstChild.style.display = 'none'; - }; - } - input[j].onkeydown = function() { - if( this.form.shuffleButton ) { - this.form.shuffleButton.disabled = true; - } - }; - } - if( input[j].className === 'check' ) { - input[j].onclick = function() { - if( this.form.shuffleButton ) { - this.form.shuffleButton.disabled = true; - } - }; - } - // Disable the submit button if the page is in preview mode - if( input[j].type === 'submit' && document.editform ) { - input[j].disabled = true; - } - } + /** + * Prepare the quiz for "javascriptable" browsers + * + * @param {jQuery} $content The content area of the wiki page, + * passed by the `wikipage.content` hook + */ + function prepareQuiz( $content ) { + var $input = $content.find( 'div.quiz input' ); + // Add the possibility of unchecking radio buttons + $input.filter( ':radio' ).dblclick( function () { + this.checked = false; + } ); + // Display the shuffle buttons + $input.filter( '.shuffle' ).click( function () { + shuffle( $( this.form ).find( 'div.quizQuestions' ) ); + } ); + // Display the reset button + $input.filter( '.reset' ).click( function () { + this.form.quizId.value = ''; + this.form.submit(); + } ); + // Correct the bug of IE6 on textfields + // TODO: Is it still necessary? (IE<10 has no JS at all) + if ( document.body.style.maxHeight === undefined ) { + $input.filter( '.numbers, .words' ).parent() + .click( function () { + $( this ).parent().children( ':first' ).css( { + display: 'inline', + position: 'absolute', + marginTop: '1.7em' + } ); + } ) + .mouseout( function () { + $( this ).parent().children( ':first' ).css( 'display', 'inline' ); + } ); + } + $input.filter( '.numbers, .words' ).keydown( function () { + if ( this.form.shuffleButton ) { + this.form.shuffleButton.disabled = true; } - } + } ); + $input.filter( '.check' ).click( function () { + if ( this.form.shuffleButton ) { + this.form.shuffleButton.disabled = true; + } + } ); + // Disable submit button while previewing the quiz as submitting would start a POST request + // without the edit data. + // This should be done after full page load as #editform may be outside $content. + // TODO: Use AJAX for quiz correction so that it can be corrected also while editing + $( function () { + if ( $( '#editform' ).length ) { + $input.filter( ':submit' ).prop( 'disabled', true ); + } + } ); } - function addLoadListener( func ) { - if ( window.addEventListener ) { - window.addEventListener( 'load', func, false ); - } else if ( document.addEventListener ) { - document.addEventListener( 'load', func, false ); - } else if ( window.attachEvent ) { - window.attachEvent( 'onload', func ); - } - } - - if ( document.getElementById && document.createTextNode ) { - addLoadListener( prepareQuiz ); - } + mw.hook( 'wikipage.content' ).add( prepareQuiz ); })(); diff --git a/templates/Answer.mustache b/templates/Answer.mustache index 1025a13..50e773f 100644 --- a/templates/Answer.mustache +++ b/templates/Answer.mustache @@ -3,7 +3,7 @@ <a class="input" href="#nogo"> <span class="correction">{{{ possibility }}} </span> - {{/if}} <span style="{{ style }}"> + {{/if}} <span class="{{ spanClass }}"> <input type="text" name="{{ name }}" class="{{ class }}" title="{{ title }}" {{ disabled }} size="{{ size }}" maxlength="{{ maxlength }}" autocomplete="off" value="{{ value }}" /> <em style="{{ bigDisplay }}">{{ big }} </em> diff --git a/templates/Question.mustache b/templates/Question.mustache index 6c66951..21eef73 100644 --- a/templates/Question.mustache +++ b/templates/Question.mustache @@ -5,7 +5,7 @@ {{/if}} <span class="questionText">{{{ question.text }}}</span> </div> - <table class="object" style="{{ state.tableStyle }}" title="{{ state.tableTitle }}"> + <table class="object border {{ state.state }}" title="{{ state.tableTitle }}"> <tbody> {{{ question.answers }}} </tbody> diff --git a/templates/Quiz.mustache b/templates/Quiz.mustache index 155cbec..d33bf74 100644 --- a/templates/Quiz.mustache +++ b/templates/Quiz.mustache @@ -12,7 +12,7 @@ <p> <input type="submit" value="{{ wfMessage.quiz_correction }}"/> {{#if quiz.beingCorrected }} - <input class="reset" type="submit" value="{{ wfMessage.quiz_reset }}" style="display: none;"> + <input class="reset" type="submit" value="{{ wfMessage.quiz_reset }}"> {{/if}} </p> {{#if quiz.beingCorrected }} diff --git a/templates/Setting.mustache b/templates/Setting.mustache index f6496d4..41f0add 100644 --- a/templates/Setting.mustache +++ b/templates/Setting.mustache @@ -1,43 +1,43 @@ {{# isSettingFirstRow}} <tr> - {{# notSimple}} - <td>{{ wfMessage.quiz_added }}</td> - <td><input class="numerical" type="text" name="addedPoints" value="{{ mAddedPoints }}"/>  </td> - {{/ notSimple}} - {{# corrected}} - <td class="margin" style="background:{{ color.colorRight }}"></td> + {{# notSimple}} + <td><label for="addedPoints">{{ wfMessage.quiz_added }}</label></td> + <td><input class="numerical" type="number" name="addedPoints" id="addedPoints" value="{{ mAddedPoints }}"/>  </td> + {{/ notSimple}} + {{# corrected}} + <td class="margin right"></td> <td style="background: transparent;">{{ wfMessage.quiz_colorRight }}</td> + {{/corrected}} + {{# error}} + {{^ corrected}} + <td class="margin error"></td> + <td>{{ wfMessage.quiz_colorError }}</td> {{/corrected}} - {{# error}} - {{^ corrected}} - <td class="margin" style="background:{{ color.colorError }}"></td> - <td>{{ wfMessage.quiz_colorError }}</td> - {{/corrected}} - {{/ error}} + {{/ error}} </tr> {{/ isSettingFirstRow}} {{# isSettingOtherRow}} <tr> - {{# notSimple}} - <td>{{ wfMessage.quiz_cutoff }}</td> - <td><input class="numerical" type="text" name="cutoffPoints" value="{{ mCutoffPoints }}"/></td> - {{/ notSimple}} - {{# corrected}} - <td class="margin" style="background:{{ color.colorWrong }}"></td> - <td style="background: transparent;">{{ wfMessage.quiz_colorWrong }}</td> - {{/ corrected}} + {{# notSimple}} + <td><label for="cutoffPoints">{{ wfMessage.quiz_cutoff }}</label></td> + <td><input class="numerical" type="number" name="cutoffPoints" id="cutoffPoints" value="{{ mCutoffPoints }}"/></td> + {{/ notSimple}} + {{# corrected}} + <td class="margin wrong"></td> + <td style="background: transparent;">{{ wfMessage.quiz_colorWrong }}</td> + {{/ corrected}} </tr> {{/ isSettingOtherRow}} {{# isSettingOtherRow}} <tr> - {{# notSimple}} - <td>{{{ wfMessage.quiz_ignoreCoef }}}</td> - <td><input type="checkbox" name="ignoringCoef" {{{ checked }}}/></td> - {{/ notSimple}} - {{# corrected}} - <td class="margin" style="background:{{ color.colorNA }}"></td> - <td style="background: transparent;">{{ wfMessage.quiz_colorNA }}</td> - {{/ corrected}} + {{# notSimple}} + <td><label for="ignoringCoef">{{{ wfMessage.quiz_ignoreCoef }}}</label></td> + <td><input type="checkbox" name="ignoringCoef" id="ignoringCoef" {{{ checked }}}/></td> + {{/ notSimple}} + {{# corrected}} + <td class="margin NA"></td> + <td style="background: transparent;">{{ wfMessage.quiz_colorNA }}</td> + {{/ corrected}} </tr> {{/ isSettingOtherRow}} {{# notSimple}} @@ -45,7 +45,7 @@ {{# shuffle}} {{^ corrected}} {{# shuffleDisplay}} - <td><input class="shuffle" name="shuffleButton" type="button" value="{{ wfMessage.quiz_shuffle }}" style="display: none;"/></td> + <td><input class="shuffle" name="shuffleButton" type="button" value="{{ wfMessage.quiz_shuffle }}"/></td> {{/ shuffleDisplay}} {{/ corrected}} {{/ shuffle}} @@ -57,7 +57,7 @@ {{/ corrected}} {{# error}} {{# corrected}} - <td class="margin" style="background:{{ color.colorError }}"></td> + <td class="margin error"></td> <td>{{ wfMessage.quiz_colorError }}</td> {{/ corrected}} {{/ error}} diff --git a/tests/phpunit/QuestionTest.php b/tests/phpunit/QuestionTest.php index 4f90b9f..1fb10e5 100644 --- a/tests/phpunit/QuestionTest.php +++ b/tests/phpunit/QuestionTest.php @@ -173,7 +173,7 @@ [ '1', '1', [ '{ Stageira | Plato | Greece }', 'Stageira | Plato | Greece', '' ], '<div style="display:inline-block">' . "\n\t\n\t\t" . '<a class="input" href="#nogo">' . "\n\t\t\t" . '<span class="correction"> Stageira<br />Plato<br />Greece<br />' - . "\n\t\t\t" . '</span>' . "\n\t\t\t" . '<span style="border-left:3px solid #2834FF;">' + . "\n\t\t\t" . '</span>' . "\n\t\t\t" . '<span class="border NA">' . "\n\t\t\t\t" . '<input type="text" name="1" class="words" title="Not answered" size="" ' . 'maxlength="" autocomplete="off" value="" />' @@ -186,7 +186,7 @@ '2', '0', [ '{ Stageira | Plato | Greece }', 'Stageira | Plato | Greece', '' ], '<div style="display:inline-block">' . "\n\t\n\t\t" . '<a class="input" href="#nogo">' . "\n\t\t\t" . '<span class="correction">' . " \n\t\t\t" . '</span>' . "\n\t\t\t" - . '<span style="">' . "\n\t\t\t\t" + . '<span class="">' . "\n\t\t\t\t" . '<input type="text" name="2" class="words" title="" size="" maxlength="" ' . 'autocomplete="off" value="" />' . "\n\t\t\t\t\t" . '<em style="display: none">' . "\n\t\t\t\t\t" . '</em>' . "\n\t\t\t" . '</span>' . "\n\t\n" . '</div>' . "\n" @@ -198,7 +198,7 @@ '3', '1', [ '{ Plato (i) _6 }', 'Plato (i)', '_6', '6' ], '<div style="display:inline-block">' . "\n\t\n\t\t" . '<a class="input" href="#nogo">' . "\n\t\t\t" . '<span class="correction"> Plato<br />' . "\n\t\t\t" . '</span>' . "\n\t\t\t" - . '<span style="border-left:3px solid #2834FF;">' . "\n\t\t\t\t" + . '<span class="border NA">' . "\n\t\t\t\t" . '<input type="text" name="3" class="words" title="Not answered" size="4" ' . 'maxlength="6" autocomplete="off" value="" />' . "\n\t\t\t\t\t" . '<em style=" ">▼' . "\n\t\t\t\t\t" . '</em>' @@ -209,7 +209,7 @@ [ '4', '1', [ '{ Stageira | Plato | Greece }', 'Stageira | Plato | Greece', '' ], '<div style="display:inline-block">' . "\n\t\n\t\t" . '<a class="input" href="#nogo">' . "\n\t\t\t" . '<span class="correction"> Stageira<br />Plato<br />Greece<br />'. "\n\t\t\t" - . '</span>' . "\n\t\t\t" . '<span style="border-left:3px solid #1FF72D;">' . "\n\t\t\t\t" + . '</span>' . "\n\t\t\t" . '<span class="border right">' . "\n\t\t\t\t" . '<input type="text" name="4" class="words" title="Right" size="" ' . 'maxlength="" autocomplete="off" value="Greece" />' . "\n\t\t\t\t\t" . '<em style=" ">▼' . "\n\t\t\t\t\t" . '</em>' . "\n\t\t\t" . '</span>' @@ -221,7 +221,7 @@ '5', '1', [ '{ Plato (i) _6 }', 'Plato (i)', '_6', '6' ], '<div style="display:inline-block">' . "\n\t\n\t\t" . '<a class="input" href="#nogo">' . "\n\t\t\t" . '<span class="correction"> Plato<br />' . "\n\t\t\t" . '</span>' . "\n\t\t\t" - . '<span style="border-left:3px solid #F74245;">' . "\n\t\t\t\t" + . '<span class="border wrong">' . "\n\t\t\t\t" . '<input type="text" name="5" class="words" title="Wrong" size="4" ' . 'maxlength="6" autocomplete="off" value="morethansix" />' . "\n\t\t\t\t\t" . '<em style=" ">▼' . "\n\t\t\t\t\t" . '</em>' @@ -233,7 +233,7 @@ '6', '1', [ '{ }', '', '' ], '<div style="display:inline-block">' . "\n\t\n\t\t" . '<a class="input" href="#nogo">' . "\n\t\t\t" . '<span class="correction">' . "\n\t\t\t" . '</span>' . "\n\t\t\t" - . '<span style="border-left:3px solid #D700D7;">' . "\n\t\t\t\t" + . '<span class="border error">' . "\n\t\t\t\t" . '<input type="text" name="6" class="" title="Syntax error" disabled size="" ' . 'maxlength="" autocomplete="off" value="value="???"" />' . "\n\t\t\t\t\t" . '<em style="">' . "\n\t\t\t\t\t" . '</em>' @@ -245,7 +245,7 @@ '7', '1', [ '{ 0 }', '0', '' ], '<div style="display:inline-block">' . "\n\t\n\t\t" . '<a class="input" href="#nogo">' . "\n\t\t\t" . '<span class="correction"> 0<br />' . "\n\t\t\t" . '</span>' . "\n\t\t\t" - . '<span style="border-left:3px solid #1FF72D;">' . "\n\t\t\t\t" + . '<span class="border right">' . "\n\t\t\t\t" . '<input type="text" name="7" class="numbers" title="Right" size="" ' . 'maxlength="" autocomplete="off" value="0" />' . "\n\t\t\t\t\t" . '<em style=" ">▼' . "\n\t\t\t\t\t" . '</em>' diff --git a/tests/phpunit/QuizTest.php b/tests/phpunit/QuizTest.php index 561d575..5c9e68f 100644 --- a/tests/phpunit/QuizTest.php +++ b/tests/phpunit/QuizTest.php @@ -35,25 +35,6 @@ ); } - public function provideGetColor() { - return [ - [ 'right', '#1FF72D' ], - [ 'wrong', '#F74245' ], - [ 'correction', '#F9F9F9' ], - [ 'NA', '#2834FF' ], - [ 'error', '#D700D7' ], - ]; - } - - /** - * @dataProvider provideGetColor - * @covers Question::getColor - */ - public function testGetColor( $colorId, $expected ) { - $color = $this->quiz->getColor( $colorId ); - $this->assertEquals( $color, $expected ); - } - public function testQuizHasQuizId() { $this->assertClassHasStaticAttribute( 'sQuizId', Quiz::class ); } -- To view, visit https://gerrit.wikimedia.org/r/362793 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0872fafce8cd50aafbc1f1c134eb89236f16c16a Gerrit-PatchSet: 11 Gerrit-Project: mediawiki/extensions/Quiz Gerrit-Branch: master Gerrit-Owner: Tacsipacsi <tacsipa...@jnet.hu> Gerrit-Reviewer: Harjotsingh <harjo...@ymail.com> Gerrit-Reviewer: Mvolz <mv...@wikimedia.org> Gerrit-Reviewer: Reedy <re...@wikimedia.org> Gerrit-Reviewer: Tacsipacsi <tacsipa...@jnet.hu> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits