jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/358539 )

Change subject: Enable numeric input type questions to evaluate zero as valid 
input.
......................................................................


Enable numeric input type questions to evaluate zero as valid input.

Currently numeric input type questions doesn't evaluate zero as valid input
even if the answer is correct.When zero is submitted, the quiz state remains
unanswered.This is caused as empty() in php consider 0 to be empty.This
change checks if the input is zero and exempts it from empty().

Bug:T166439
Change-Id: Icd119ce75561eaea98b7b24d515699b1fe771015
---
M Question.php
1 file changed, 3 insertions(+), 4 deletions(-)

Approvals:
  jenkins-bot: Verified
  Mvolz: Looks good to me, approved



diff --git a/Question.php b/Question.php
index 8b19494..618e1e4 100644
--- a/Question.php
+++ b/Question.php
@@ -393,7 +393,7 @@
                                                } else {
                                                        $strlen = strlen( 
$matches[1] );
                                                }
-                                               if ( $this->mBeingCorrected && 
!empty( $value ) ) {
+                                               if ( $this->mBeingCorrected && 
$value !== "" ) {
                                                        $value = str_replace( 
',', '.', $value );
                                                        if ( is_numeric( $value 
) && (
                                                                        ( 
array_key_exists( 5, $matches )
@@ -412,7 +412,7 @@
                                        } else {
                                                $strlen = preg_match( '` 
\(i\)$`', $possibility ) ? mb_strlen( $possibility ) - 4 : mb_strlen( 
$possibility );
                                                $class = 'words';
-                                               if ( $this->mBeingCorrected && 
!empty( $value ) ) {
+                                               if ( $this->mBeingCorrected && 
$value !== "" ) {
                                                        if ( $value == 
$possibility ||
                                                                ( preg_match( 
'`^' . preg_quote( $value, '`' ) . ' \(i\)$`i', $possibility ) ) ||
                                                                ( 
!$this->mCaseSensitive && preg_match( '`^' . preg_quote( $value, '`' ) . '$`i', 
$possibility ) )
@@ -437,7 +437,6 @@
                                        $poss .= $possibility . '<br />';
                                }
                        }
-                       $value = empty( $value ) ? '' : str_replace( '"', 
'&quot;', $value );
                        if ( $this->mBeingCorrected ) {
                                $big = '▼';
                                $bigDisplay = ' ';
@@ -447,7 +446,7 @@
                        global $wgContLang;
                        $border = $wgContLang->isRTL() ? 'border-right' : 
'border-left';
                        $style = $border . ':3px solid ' . Quiz::getColor( 
$state ) . ';';
-                       $this->setState( empty( $value ) ? 'new_NA' : $state );
+                       $this->setState( $value === "" ? 'new_NA' : $state );
                        if ( $state == 'error' ) {
                                $size = '';
                                $maxlength = '';

-- 
To view, visit https://gerrit.wikimedia.org/r/358539
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Icd119ce75561eaea98b7b24d515699b1fe771015
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Quiz
Gerrit-Branch: master
Gerrit-Owner: Harjotsingh <harjo...@ymail.com>
Gerrit-Reviewer: Harjotsingh <harjo...@ymail.com>
Gerrit-Reviewer: Mvolz <mv...@wikimedia.org>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to