r109933 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109932‎ | r109933 | r109934 >
Date:17:29, 24 January 2012
Author:rsterbin
Status:ok (Comments)
Tags:aft 
Comment:
Updated survey CTA to use different links for options 1, 2, and 3:
- modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js:
- New method getSurveyUrl() for the survey CTA, to pull the correct
survey link, or false if the form option was not 1, 2, or 3
- New method verify() for the survey CTA, to kick out if there is no
appropriate survey link
- Updated build() to use getSurveyUrl() and send the feedback id as the
parameter "c"
- ArticleFeedbackv5.php;
- Changed $wgArticleFeedbackv5SurveyUrl to
$wgArticleFeedbackv5SurveyUrls, a map of display buckets to survey urls
- Removed old survey setup
- ArticleFeedbackv5.hooks.php:
- Updated to pass $wgArticleFeedbackv5SurveyUrls to the resource loader
instead of $wgArticleFeedbackv5SurveyUrl
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js
@@ -2025,6 +2025,18 @@
20262026 },
20272027
20282028 // }}}
 2029+ // {{{ verify
 2030+
 2031+ /**
 2032+ * Verifies that this CTA can be displayed
 2033+ *
 2034+ * @return bool whether the CTA can be displayed
 2035+ */
 2036+ verify: function () {
 2037+ return $.articleFeedbackv5.ctas['3'].getSurveyUrl() !== false;
 2038+ },
 2039+
 2040+ // }}}
20292041 // {{{ build
20302042
20312043 /**
@@ -2038,21 +2050,41 @@
20392051 var $block = $( $.articleFeedbackv5.currentCTA().templates.block );
20402052
20412053 // Fill in the go-to-survey link
2042 - var survey_track_id = $.articleFeedbackv5.bucketName() + '-' +
2043 - $.articleFeedbackv5.ctaName() + '-button_click-' +
2044 - ( $.articleFeedbackv5.inDialog ? 'overlay': 'bottom' );
2045 - $block.find( '.articleFeedbackv5-cta-button' )
2046 - .attr( 'href', $.articleFeedbackv5.trackingUrl(
2047 - mw.config.get( 'wgArticleFeedbackv5SurveyUrl' ) +
2048 - '?c=' + $.articleFeedbackv5.bucketId +
2049 - '&f=' + $.articleFeedbackv5.feedbackId,
2050 - survey_track_id
2051 - ) );
 2054+ var survey_url = $.articleFeedbackv5.currentCTA().getSurveyUrl();
 2055+ if ( survey_url ) {
 2056+ var survey_track_id = $.articleFeedbackv5.bucketName() + '-' +
 2057+ $.articleFeedbackv5.ctaName() + '-button_click-' +
 2058+ ( $.articleFeedbackv5.inDialog ? 'overlay': 'bottom' );
 2059+ $block.find( '.articleFeedbackv5-cta-button' )
 2060+ .attr( 'href', $.articleFeedbackv5.trackingUrl(
 2061+ survey_url + '?c=' + $.articleFeedbackv5.feedbackId,
 2062+ survey_track_id
 2063+ ) );
 2064+ }
20522065
20532066 return $block;
20542067 },
20552068
20562069 // }}}
 2070+ // {{{ getSurveyUrl
 2071+
 2072+ /**
 2073+ * Gets the appropriate survey url, or returns false if none was
 2074+ * found
 2075+ *
 2076+ * @return mixed the url, if one is availabe, or false if not
 2077+ */
 2078+ getSurveyUrl: function () {
 2079+ var base = mw.config.get( 'wgArticleFeedbackv5SurveyUrls' );
 2080+ aft5_debug( base );
 2081+ aft5_debug( $.articleFeedbackv5.bucketId );
 2082+ if ( typeof base != 'object' || !( $.articleFeedbackv5.bucketId in base ) ) {
 2083+ return false;
 2084+ }
 2085+ return base[$.articleFeedbackv5.bucketId];
 2086+ },
 2087+
 2088+ // }}}
20572089 // {{{ bindEvents
20582090
20592091 /**
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php
@@ -10,9 +10,6 @@
1111 * @version 0.1.0
1212 */
1313
14 -/* XXX: Survey setup */
15 -require_once( dirname( dirname( __FILE__ ) ) . '/SimpleSurvey/SimpleSurvey.php' );
16 -
1714 /* Configuration */
1815
1916 // How long text-based feedback is allowed to be before returning an error.
@@ -190,42 +187,11 @@
191188 *
192189 * @var string
193190 */
194 -$wgArticleFeedbackv5SurveyUrl = "https://www.surveymonkey.com/s/aft5";
195 -
196 -// Would ordinarily call this articlefeedback but survey names are 16 chars max
197 -$wgPrefSwitchSurveys['articlerating'] = array(
198 - 'updatable' => false,
199 - 'submit-msg' => 'articlefeedbackv5-survey-submit',
200 - 'questions' => array(
201 - 'origin' => array(
202 - 'visibility' => 'hidden',
203 - 'question' => 'articlefeedbackv5-survey-question-origin',
204 - 'type' => 'text',
205 - ),
206 - 'whyrated' => array(
207 - 'question' => 'articlefeedbackv5-survey-question-whyrated',
208 - 'type' => 'checks',
209 - 'answers' => array(
210 - 'contribute-rating' => 'articlefeedbackv5-survey-answer-whyrated-contribute-rating',
211 - 'development' => 'articlefeedbackv5-survey-answer-whyrated-development',
212 - 'contribute-wiki' => 'articlefeedbackv5-survey-answer-whyrated-contribute-wiki',
213 - 'sharing-opinion' => 'articlefeedbackv5-survey-answer-whyrated-sharing-opinion',
214 - 'didntrate' => 'articlefeedbackv5-survey-answer-whyrated-didntrate',
215 - ),
216 - 'other' => 'articlefeedbackv5-survey-answer-whyrated-other',
217 - ),
218 - 'useful' => array(
219 - 'question' => 'articlefeedbackv5-survey-question-useful',
220 - 'type' => 'boolean',
221 - 'iffalse' => 'articlefeedbackv5-survey-question-useful-iffalse',
222 - ),
223 - 'comments' => array(
224 - 'question' => 'articlefeedbackv5-survey-question-comments',
225 - 'type' => 'text',
226 - ),
227 - ),
 191+$wgArticleFeedbackv5SurveyUrls = array(
 192+ '1' => 'https://www.surveymonkey.com/s/aft5-1',
 193+ '2' => 'https://www.surveymonkey.com/s/aft5-2',
 194+ '3' => 'https://www.surveymonkey.com/s/aft5-3',
228195 );
229 -$wgValidSurveys[] = 'articlerating';
230196
231197 // Replace default emailcapture message
232198 $wgEmailCaptureAutoResponse['body-msg'] = 'articlefeedbackv5-emailcapture-response-body';
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php
@@ -269,7 +269,7 @@
270270 $wgArticleFeedbackv5LinkBuckets,
271271 $wgArticleFeedbackv5Namespaces,
272272 $wgArticleFeedbackv5LearnToEdit,
273 - $wgArticleFeedbackv5SurveyUrl;
 273+ $wgArticleFeedbackv5SurveyUrls;
274274 $vars['wgArticleFeedbackv5SMaxage'] = $wgArticleFeedbackv5SMaxage;
275275 $vars['wgArticleFeedbackv5Categories'] = $wgArticleFeedbackv5Categories;
276276 $vars['wgArticleFeedbackv5BlacklistCategories'] = $wgArticleFeedbackv5BlacklistCategories;
@@ -285,7 +285,7 @@
286286 $vars['wgArticleFeedbackv5LearnToEdit'] = $wgArticleFeedbackv5LearnToEdit;
287287 $vars['wgArticleFeedbackv5WhatsThisPage'] = wfMsgForContent( 'articlefeedbackv5-bucket5-form-panel-explanation-link' );
288288 $vars['wgArticleFeedbackv5TermsPage'] = wfMsgForContent( 'articlefeedbackv5-transparency-terms-url' );
289 - $vars['wgArticleFeedbackv5SurveyUrl'] = $wgArticleFeedbackv5SurveyUrl;
 289+ $vars['wgArticleFeedbackv5SurveyUrls'] = $wgArticleFeedbackv5SurveyUrls;
290290 return true;
291291 }
292292

Follow-up revisions

RevisionCommit summaryAuthorDate
r1100191.18wmf1: MFT r109875, r109933, r109943catrope19:34, 25 January 2012

Comments

#Comment by Johnduhart (talk | contribs)   20:36, 24 January 2012

Really? Surveymonkey? I'm pretty sure we don't like relying on thirdparty hosted services.

#Comment by Catrope (talk | contribs)   22:24, 24 January 2012

Yeah, SurveyMonkey. I'm not super psyched about it either, but AFAIK we've run links to 3rd party surveys before.

#Comment by P858snake (talk | contribs)   23:18, 24 January 2012

The messages should probably be blanked and defined elsewhere that is wmf specific, WikimediaMessages?

#Comment by Rsterbin (talk | contribs)   01:23, 25 January 2012

I'm inclined to agree, but I'm not familiar enough with core or wmf-specific stuff to know where it should go.

Status & tagging log