jenkins-bot has submitted this change and it was merged.

Change subject: Add GuidedTour survey about user gender
......................................................................


Add GuidedTour survey about user gender

Disabled by default, enabled with $wgVisualEditorEnableGenderSurvey.

Change-Id: I2b4aba6a95a33474c3e68423d478aa78e57d86ad
---
M VisualEditor.hooks.php
M VisualEditor.i18n.php
M VisualEditor.php
A modules/ve/init/mw/tours/vegendersurvey.js
A modules/ve/init/mw/ve.init.mw.genderSurvey.css
A modules/ve/init/mw/ve.init.mw.genderSurvey.js
6 files changed, 122 insertions(+), 2 deletions(-)

Approvals:
  Krinkle: Looks good to me, but someone else must approve
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php
index 0e5e0f5..03461bc 100644
--- a/VisualEditor.hooks.php
+++ b/VisualEditor.hooks.php
@@ -13,7 +13,8 @@
        protected static $supportedSkins = array( 'vector', 'apex', 'monobook' 
);
 
        public static function onSetup() {
-               global $wgVisualEditorEnableEventLogging, $wgResourceModules;
+               global $wgVisualEditorEnableEventLogging, $wgResourceModules,
+                       $wgVisualEditorEnableGenderSurvey;
 
                if ( $wgVisualEditorEnableEventLogging ) {
                        if ( class_exists( 'ResourceLoaderSchemaModule' ) ) {
@@ -24,6 +25,14 @@
                                        'schema' => 'Edit',
                                        'revision' => 5570274,
                                );
+
+                               if ( $wgVisualEditorEnableGenderSurvey ) {
+                                       
$wgResourceModules['schema.GenderSurvey'] = array(
+                                               'class' => 
'ResourceLoaderSchemaModule',
+                                               'schema' => 'GenderSurvey',
+                                               'revision' => '5607845',
+                                       );
+                               }
                        } else {
                                wfWarn( 'VisualEditor is configured to use 
EventLogging, but the extension is ' .
                                                ' not available. Disabling 
wgVisualEditorEnableEventLogging.' );
@@ -79,6 +88,23 @@
                return true;
        }
 
+       // Temporary survey in conjuction with split test (bug 49604)
+       // To be removed once no longer needed.
+       // Depends on GuidedTour and EventLogging
+       public static function onBeforeWelcomeCreation( &$welcomeCreationMsg, 
&$injectHtml ) {
+               global $wgOut, $wgVisualEditorEnableGenderSurvey;
+
+               if ( $wgVisualEditorEnableGenderSurvey ) {
+                       $wgOut->addModules( array(
+                               'ext.guidedTour.lib',
+                               'ext.guidedTour.tour.vegendersurvey',
+                               'ext.visualEditor.genderSurvey'
+                       ) );
+               }
+
+               return true;
+       }
+
        public static function onGetPreferences( $user, &$preferences ) {
                $preferences['visualeditor-enable'] = array(
                        'type' => 'toggle',
diff --git a/VisualEditor.i18n.php b/VisualEditor.i18n.php
index 171c980..d09172b 100644
--- a/VisualEditor.i18n.php
+++ b/VisualEditor.i18n.php
@@ -147,6 +147,11 @@
        'visualeditor-usernamespacepagelink' => 'Project:User namespace',
        'visualeditor-viewpage-savewarning' => 'Are you sure you want to go 
back to view mode without saving first?',
        'visualeditor-window-title' => 'Inspect',
+       'guidedtour-tour-vegendersurvey-title' => 'Please select your gender',
+       'guidedtour-tour-vegendersurvey-description' => 'By participating in 
this survey, you consent to the transfer of the information you submit to the 
Wikimedia Foundation in the United States and elsewhere.  The information 
collected is for internal research purposes only and will not be publicly 
associated with your account.  However, we may share the results of this survey 
with the public in anonymized or aggregated forms.',
+       'guidedtour-tour-vegendersurvey-male' => 'Male',
+       'guidedtour-tour-vegendersurvey-female' => 'Female',
+       'guidedtour-tour-vegendersurvey-optout' => 'Prefer not to say',
 );
 
 /** Message documentation (Message documentation)
@@ -396,6 +401,11 @@
 {{doc-important|Do not translate "Project"; it is automatically converted to 
the wiki\'s project namespace.}}',
        'visualeditor-viewpage-savewarning' => 'Text shown when the user tries 
to leave the editor without saving their changes',
        'visualeditor-window-title' => 'Title of an unnamed inspector',
+       'guidedtour-tour-vegendersurvey-title' => 'Title of gender survey 
guider',
+       'guidedtour-tour-vegendersurvey-description' => 'Description of gender 
survey guider',
+       'guidedtour-tour-vegendersurvey-male' => 'Button on gender survey for 
choosing \'male\'',
+       'guidedtour-tour-vegendersurvey-female' => 'Button on gender survey for 
choosing \'female\'',
+       'guidedtour-tour-vegendersurvey-optout' => 'Button on gender survey for 
those who prefer not to answer',
 );
 
 /** Arabic (العربية)
diff --git a/VisualEditor.php b/VisualEditor.php
index 55a0387..3052cda 100644
--- a/VisualEditor.php
+++ b/VisualEditor.php
@@ -30,7 +30,10 @@
 // * add: Adds #ca-ve-edit.
 // * replace: Re-creates #ca-edit for VisualEditor and adds #ca-editsource.
 $wgVisualEditorTabLayout = 'replace';
-
+// Conduct an optional survey (the user can decline to answer) on the user's 
gender
+// upon signup.
+// Depends on GuidedTour and EventLogging extensions.
+$wgVisualEditorEnableGenderSurvey = false;
 /* Setup */
 
 $wgExtensionCredits['other'][] = array(
@@ -98,6 +101,37 @@
                        've/init/mw/ve.init.mw.splitTest.js',
                )
        ),
+
+       'ext.guidedTour.tour.vegendersurvey' => $wgVisualEditorResourceTemplate 
+ array(
+               'scripts' => array(
+                       've/init/mw/tours/vegendersurvey.js',
+               ),
+               'dependencies' => array(
+                       'ext.guidedTour.lib',
+               ),
+               'messages' => array(
+                       'guidedtour-tour-vegendersurvey-title',
+                       'guidedtour-tour-vegendersurvey-description',
+                       'guidedtour-tour-vegendersurvey-male',
+                       'guidedtour-tour-vegendersurvey-female',
+                       'guidedtour-tour-vegendersurvey-optout'
+               ),
+       ),
+
+       'ext.visualEditor.genderSurvey' => $wgVisualEditorResourceTemplate + 
array(
+               'scripts' => array(
+                       've/init/mw/ve.init.mw.genderSurvey.js',
+               ),
+               'styles' => array(
+                       've/init/mw/ve.init.mw.genderSurvey.css',
+               ),
+               'dependencies' => array(
+                       'ext.guidedTour.lib',
+                       'ext.guidedTour.tour.vegendersurvey',
+                       'ext.visualEditor.mediawiki',
+               ),
+       ),
+
        // Alias for backwards compat, safe to remove after
        'ext.visualEditor.editPageInit' => $wgVisualEditorResourceTemplate + 
array(
                'dependencies' => array(
@@ -663,7 +697,9 @@
 $wgHooks['ResourceLoaderTestModules'][] = 
'VisualEditorHooks::onResourceLoaderTestModules';
 
 // Bug 49604: Running split test in production if 
$wgVisualEditorEnableSplitTest is true.
+// This requires that GuidedTour and EventLogging are also enabled on the wiki.
 $wgHooks['AddNewAccount'][] = 'VisualEditorHooks::onAddNewAccount';
+$wgHooks['BeforeWelcomeCreation'][] = 
'VisualEditorHooks::onBeforeWelcomeCreation';
 
 $wgExtensionFunctions[] = 'VisualEditorHooks::onSetup';
 
diff --git a/modules/ve/init/mw/tours/vegendersurvey.js 
b/modules/ve/init/mw/tours/vegendersurvey.js
new file mode 100644
index 0000000..651e32a
--- /dev/null
+++ b/modules/ve/init/mw/tours/vegendersurvey.js
@@ -0,0 +1,31 @@
+/*global mw */
+( function ( $, gt ) {
+       gt.defineTour( {
+               name: 'vegendersurvey',
+               isSinglePage: true,
+               // shouldLog tells GuidedTour to provide additional logging 
(step impressions, etc.)
+               shouldLog: true,
+               steps: [ {
+                       titlemsg: 'guidedtour-tour-vegendersurvey-title',
+                       descriptionmsg: 
'guidedtour-tour-vegendersurvey-description',
+                       allowAutomaticOkay: false,
+                       overlay: true,
+                       buttons: [ {
+                               namemsg: 'guidedtour-tour-vegendersurvey-male',
+                               onclick: function () {
+                                       ve.init.mw.genderSurvey.logAndEndTour( 
'male' );
+                               }
+                       }, {
+                               namemsg: 
'guidedtour-tour-vegendersurvey-female',
+                               onclick: function () {
+                                       ve.init.mw.genderSurvey.logAndEndTour( 
'female' );
+                               }
+                       }, {
+                               namemsg: 
'guidedtour-tour-vegendersurvey-optout',
+                               onclick: function () {
+                                       ve.init.mw.genderSurvey.logAndEndTour( 
'opt-out' );
+                               }
+                       } ]
+               } ]
+       } );
+} ( jQuery, mw.guidedTour ) );
\ No newline at end of file
diff --git a/modules/ve/init/mw/ve.init.mw.genderSurvey.css 
b/modules/ve/init/mw/ve.init.mw.genderSurvey.css
new file mode 100644
index 0000000..19851a5
--- /dev/null
+++ b/modules/ve/init/mw/ve.init.mw.genderSurvey.css
@@ -0,0 +1,3 @@
+.mw-guidedtour-tour-vegendersurvey .guider_description {
+       font-size: small;
+}
diff --git a/modules/ve/init/mw/ve.init.mw.genderSurvey.js 
b/modules/ve/init/mw/ve.init.mw.genderSurvey.js
new file mode 100644
index 0000000..edb83df
--- /dev/null
+++ b/modules/ve/init/mw/ve.init.mw.genderSurvey.js
@@ -0,0 +1,14 @@
+/*global mw */
+mw.loader.using( 'schema.GenderSurvey', function () {
+       ve.init.mw.genderSurvey = {
+               logAndEndTour: function ( buttonType ) {
+                       mw.eventLog.logEvent( 'GenderSurvey', {
+                               userId: mw.config.get( 'wgUserId' ),
+                               buttonType: buttonType
+                       } );
+                       mw.guidedTour.endTour( 'vegendersurvey' );
+               }
+       };
+
+       mw.guidedTour.launchTour( 'vegendersurvey' );
+} );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2b4aba6a95a33474c3e68423d478aa78e57d86ad
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Spage <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to