http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96814

Revision: 96814
Author:   jeroendedauw
Date:     2011-09-11 21:50:05 +0000 (Sun, 11 Sep 2011)
Log Message:
-----------
added control to set survey ratio

Modified Paths:
--------------
    trunk/extensions/Survey/Survey.i18n.php
    trunk/extensions/Survey/Survey.sql
    trunk/extensions/Survey/specials/SpecialSurvey.php

Modified: trunk/extensions/Survey/Survey.i18n.php
===================================================================
--- trunk/extensions/Survey/Survey.i18n.php     2011-09-11 21:14:38 UTC (rev 
96813)
+++ trunk/extensions/Survey/Survey.i18n.php     2011-09-11 21:50:05 UTC (rev 
96814)
@@ -102,6 +102,7 @@
        'survey-special-label-name' => 'Survey ID',
        'survey-special-label-title' => 'Survey title',
        'survey-special-label-enabled' => 'Survey enabled',
+       'survey-special-label-ratio' => 'Percentage of people to show the 
survey to',
        'survey-special-label-add-first' => 'Add question',
        'survey-special-label-add-another' => 'Add another question',
        'survey-special-label-addquestion' => 'New question',

Modified: trunk/extensions/Survey/Survey.sql
===================================================================
--- trunk/extensions/Survey/Survey.sql  2011-09-11 21:14:38 UTC (rev 96813)
+++ trunk/extensions/Survey/Survey.sql  2011-09-11 21:50:05 UTC (rev 96814)
@@ -14,7 +14,7 @@
   survey_user_type         TINYINT             NOT NULL default '0', -- Type 
of users that can participate in the survey
   survey_namespaces        BLOB                NOT NULL, -- Namespaces on 
which the survey can be displayed
   survey_ratio             TINYINT unsigned    NOT NULL, -- Percentage of 
users to show the survey to
-  survey_expiry            INT unsigned        NOT NULL -- Coockie expiry time 
for the survey
+  survey_expiry            INT unsigned        NOT NULL, -- Coockie expiry 
time for the survey
 ) /*$wgDBTableOptions*/;
 
 -- Questions

Modified: trunk/extensions/Survey/specials/SpecialSurvey.php
===================================================================
--- trunk/extensions/Survey/specials/SpecialSurvey.php  2011-09-11 21:14:38 UTC 
(rev 96813)
+++ trunk/extensions/Survey/specials/SpecialSurvey.php  2011-09-11 21:50:05 UTC 
(rev 96814)
@@ -79,7 +79,7 @@
                
                $survey->setField( 'enabled', $wgRequest->getCheck( 
'survey-enabled' ) );
                
-               foreach ( array( 'user_type' ) as $field ) {
+               foreach ( array( 'user_type', 'ratio' ) as $field ) {
                        $survey->setField( $field, $wgRequest->getInt( 
'survey-' . $field ) );
                }
                
@@ -224,7 +224,21 @@
                        ),
                );
                
+               $nrs = array_merge( array( 0.01, 0.1 ), range( 1, 100 ) );
+               
                $fields[] = array(
+                       'type' => 'select',
+                       'default' => $survey->getField( 'ratio' ),
+                       'label-message' => 'survey-special-label-ratio',
+                       'id' => 'survey-ratio',
+                       'name' => 'survey-ratio',
+                       'options' => array_flip( array_map(
+                               function( $n ) { return 
$GLOBALS['wgLang']->formatNum( $n ); },
+                               array_combine( $nrs, $nrs )
+                       ) ),
+               );
+               
+               $fields[] = array(
                        'type' => 'text',
                        'default' => $survey->getField( 'header' ),
                        'label-message' => 'survey-special-label-header',


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to