[MediaWiki-commits] [Gerrit] Model internal and external surveys - change (mediawiki...QuickSurveys)

2015-08-27 Thread Phuedx (Code Review)
Phuedx has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/234267

Change subject: Model internal and external surveys
..

Model internal and external surveys

* Add the Survey abstract base class, and the InternalSurvey and
  ExternalSurvey classes, which model internal and external surveys
  respectively.
* Add the SurveyFactory class that creates an instance of a model based
  on some specification or throws an exception - with an informative
  message - if it is invalid
* Replace most of the logic in the ResourceLoaderGetConfigVars and
  ResourceLoaderRegisterModules handlers with simple manipulations of
  models

Bug: T110196
Change-Id: I90b3ce5c7fb0ef06802cd9e0abe429e67bc742cc
---
M extension.json
A includes/ExternalSurvey.php
A includes/InternalSurvey.php
M includes/QuickSurveys.hooks.php
A includes/Survey.php
A includes/SurveyFactory.php
A tests/phpunit/SurveyFactoryTest.php
7 files changed, 499 insertions(+), 49 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/QuickSurveys 
refs/changes/67/234267/1

diff --git a/extension.json b/extension.json
index 072d0aa..306de24 100644
--- a/extension.json
+++ b/extension.json
@@ -74,7 +74,11 @@
}
},
AutoloadClasses: {
-   QuickSurveys\\Hooks: includes/QuickSurveys.hooks.php
+   QuickSurveys\\Hooks: includes/QuickSurveys.hooks.php,
+   QuickSurveys\\SurveyFactory: includes/SurveyFactory.php,
+   QuickSurveys\\Survey: includes/Survey.php,
+   QuickSurveys\\InternalSurvey: includes/InternalSurvey.php,
+   QuickSurveys\\ExternalSurvey: includes/ExternalSurvey.php
},
manifest_version: 1,
Hooks: {
@@ -101,7 +105,7 @@
@question: survey question message key,
question: 
ext-quicksurveys-example-internal-survey-question,
@description: The message key of the 
description of the survey. Displayed immediately below the survey question.,
-   description: ,
+   description: 
ext-quicksurveys-example-internal-survey-description,
@answers: possible answer message keys for 
positive, neutral, and negative,
answers: {
positive: 
ext-quicksurveys-example-internal-survey-answer-positive,
@@ -113,7 +117,7 @@
@enabled: whether the survey is enabled,
enabled: false,
@coverage: percentage of users that will see 
the survey,
-   coverage: 50,
+   coverage: 0.5,
@platform: for each platform (desktop, 
mobile), which version of it is targeted (stable, beta, alpha),
platform: {
desktop: [stable],
@@ -135,7 +139,7 @@
@enabled: whether the survey is enabled,
enabled: false,
@coverage: percentage of users that will see 
the survey,
-   coverage: 50,
+   coverage: 0.5,
@platform: for each platform (desktop, 
mobile), which version of it is targeted (stable, beta, alpha),
platform: {
desktop: [stable],
diff --git a/includes/ExternalSurvey.php b/includes/ExternalSurvey.php
new file mode 100644
index 000..568de8f
--- /dev/null
+++ b/includes/ExternalSurvey.php
@@ -0,0 +1,43 @@
+?php
+
+namespace QuickSurveys;
+
+class ExternalSurvey extends Survey
+{
+   /**
+* @var string The URL of the external survey.
+*/
+   private $link;
+
+   /**
+* @var string The description of the privacy policy of the website 
that hosts the external survey.
+*/
+   private $privacyPolicy;
+
+   public function __construct(
+   $name,
+   $question,
+   $description,
+   $isEnabled,
+   $coverage,
+   $link,
+   $privacyPolicy
+   ) {
+   parent::__construct( $name, $question, $description, 
$isEnabled, $coverage );
+
+   $this-link = $link;
+   $this-privacyPolicy = $privacyPolicy;
+   }
+
+   public function getMessages() {
+   return array_merge( parent::getMessages(), array( 
$this-privacyPolicy ) );
+   }
+
+   public function toArray() {
+   return parent::toArray() + array(
+   'type' = 'external',
+   'link' = $this-link,
+   

[MediaWiki-commits] [Gerrit] Model internal and external surveys - change (mediawiki...QuickSurveys)

2015-08-27 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Model internal and external surveys
..


Model internal and external surveys

* Add the Survey abstract base class, and the InternalSurvey and
  ExternalSurvey classes, which model internal and external surveys
  respectively.
* Add the SurveyFactory class that creates an instance of a model based
  on some specification or throws an exception - with an informative
  message - if it is invalid
* Replace most of the logic in the ResourceLoaderGetConfigVars and
  ResourceLoaderRegisterModules handlers with simple manipulations of
  models

Bug: T110196
Change-Id: I90b3ce5c7fb0ef06802cd9e0abe429e67bc742cc
---
M extension.json
A includes/ExternalSurvey.php
A includes/InternalSurvey.php
M includes/QuickSurveys.hooks.php
A includes/Survey.php
A includes/SurveyFactory.php
M tests/browser/LocalSettings.php
A tests/phpunit/SurveyFactoryTest.php
8 files changed, 501 insertions(+), 50 deletions(-)

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



diff --git a/extension.json b/extension.json
index 072d0aa..306de24 100644
--- a/extension.json
+++ b/extension.json
@@ -74,7 +74,11 @@
}
},
AutoloadClasses: {
-   QuickSurveys\\Hooks: includes/QuickSurveys.hooks.php
+   QuickSurveys\\Hooks: includes/QuickSurveys.hooks.php,
+   QuickSurveys\\SurveyFactory: includes/SurveyFactory.php,
+   QuickSurveys\\Survey: includes/Survey.php,
+   QuickSurveys\\InternalSurvey: includes/InternalSurvey.php,
+   QuickSurveys\\ExternalSurvey: includes/ExternalSurvey.php
},
manifest_version: 1,
Hooks: {
@@ -101,7 +105,7 @@
@question: survey question message key,
question: 
ext-quicksurveys-example-internal-survey-question,
@description: The message key of the 
description of the survey. Displayed immediately below the survey question.,
-   description: ,
+   description: 
ext-quicksurveys-example-internal-survey-description,
@answers: possible answer message keys for 
positive, neutral, and negative,
answers: {
positive: 
ext-quicksurveys-example-internal-survey-answer-positive,
@@ -113,7 +117,7 @@
@enabled: whether the survey is enabled,
enabled: false,
@coverage: percentage of users that will see 
the survey,
-   coverage: 50,
+   coverage: 0.5,
@platform: for each platform (desktop, 
mobile), which version of it is targeted (stable, beta, alpha),
platform: {
desktop: [stable],
@@ -135,7 +139,7 @@
@enabled: whether the survey is enabled,
enabled: false,
@coverage: percentage of users that will see 
the survey,
-   coverage: 50,
+   coverage: 0.5,
@platform: for each platform (desktop, 
mobile), which version of it is targeted (stable, beta, alpha),
platform: {
desktop: [stable],
diff --git a/includes/ExternalSurvey.php b/includes/ExternalSurvey.php
new file mode 100644
index 000..568de8f
--- /dev/null
+++ b/includes/ExternalSurvey.php
@@ -0,0 +1,43 @@
+?php
+
+namespace QuickSurveys;
+
+class ExternalSurvey extends Survey
+{
+   /**
+* @var string The URL of the external survey.
+*/
+   private $link;
+
+   /**
+* @var string The description of the privacy policy of the website 
that hosts the external survey.
+*/
+   private $privacyPolicy;
+
+   public function __construct(
+   $name,
+   $question,
+   $description,
+   $isEnabled,
+   $coverage,
+   $link,
+   $privacyPolicy
+   ) {
+   parent::__construct( $name, $question, $description, 
$isEnabled, $coverage );
+
+   $this-link = $link;
+   $this-privacyPolicy = $privacyPolicy;
+   }
+
+   public function getMessages() {
+   return array_merge( parent::getMessages(), array( 
$this-privacyPolicy ) );
+   }
+
+   public function toArray() {
+   return parent::toArray() + array(
+   'type' = 'external',
+   'link' = $this-link,
+   'privacyPolicy' =