r69807 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69806‎ | r69807 | r69808 >
Date:18:22, 23 July 2010
Author:nimishg
Status:deferred (Comments)
Tags:
Comment:
Simple Survey classes, building off and modifying PrefSwitch in Usability Initiative
Modified paths:
  • /trunk/extensions/SimpleSurvey/SimpleSurvey.classes.php (added) (history)
  • /trunk/extensions/SimpleSurvey/SimpleSurvey.i18n.php (added) (history)
  • /trunk/extensions/SimpleSurvey/SimpleSurvey.patch-pssuser.sql (added) (history)
  • /trunk/extensions/SimpleSurvey/SimpleSurvey.php (added) (history)
  • /trunk/extensions/SimpleSurvey/SpecialSimpleSurvey.php (added) (history)
  • /trunk/extensions/SimpleSurvey/Surveys.php (added) (history)

Diff [purge]

Index: trunk/extensions/SimpleSurvey/SimpleSurvey.patch-pssuser.sql
@@ -0,0 +1,5 @@
 2+--
 3+-- Schema patch for prefswitch_user to make it a varbinary
 4+--
 5+
 6+ALTER TABLE /*_*/prefswitch_survey modify pss_user varbinary(255);
\ No newline at end of file
Property changes on: trunk/extensions/SimpleSurvey/SimpleSurvey.patch-pssuser.sql
___________________________________________________________________
Added: svn:eol-style
17 + native
Index: trunk/extensions/SimpleSurvey/Surveys.php
@@ -0,0 +1,86 @@
 2+<?php
 3+
 4+
 5+$wgValidSurveys[] = 'vitals-07-2010';
 6+
 7+$wgPrefSwitchSurveys['vitals-07-2010'] = array(
 8+ 'submit-msg' => 'vitals-07-2010-submit',
 9+ 'updatable' => false,
 10+ 'questions' => array(
 11+ 'use' => array(
 12+ 'question' => 'vitals-07-2010-question-use',
 13+ 'type' => 'select',
 14+ 'answers' => array(
 15+ 'blank' => 'vitals-07-2010-blank',
 16+ 'daily' => 'vitals-07-2010-answer-daily',
 17+ 'weekly' => 'vitals-07-2010-answer-weekly',
 18+ 'monthly' => 'vitals-07-2010-answer-monthly',
 19+ 'rarely' => 'vitals-07-2010-answer-rarely',
 20+ 'first' => 'vitals-07-2010-answer-firsttime',
 21+ ),
 22+ ),
 23+ 'edit' => array(
 24+ 'question' => 'vitals-07-2010-question-edit',
 25+ 'type' => 'select',
 26+ 'answers' => array(
 27+ 'blank' => 'vitals-07-2010-blank',
 28+ 'daily' => 'vitals-07-2010-answer-y-daily',
 29+ 'weekly' => 'vitals-07-2010-answer-y-weekly',
 30+ 'monthly' => 'vitals-07-2010-answer-y-monthly',
 31+ 'rarely' => 'vitals-07-2010-answer-y-rarely',
 32+ 'never' => 'vitals-07-2010-answer-n-never',
 33+ 'dunno' => 'vitals-07-2010-answer-dunno-edit',
 34+ ),
 35+ ),
 36+ 'nonprofit' => array(
 37+ 'question' => 'vitals-07-2010-question-nonprofit',
 38+ 'type' => 'select',
 39+ 'answers' => array(
 40+ 'blank' => 'vitals-07-2010-blank',
 41+ 'knew' => 'vitals-07-2010-answer-nonprof-knew',
 42+ 'business' => 'vitals-07-2010-answer-nonprof-business',
 43+ 'nothink' => 'vitals-07-2010-answer-nonprof-think',
 44+ ),
 45+ ),
 46+ 'wikimediafoundation' => array(
 47+ 'question' => 'vitals-07-2010-question-wikimedia',
 48+ 'type' => 'select',
 49+ 'answers' => array(
 50+ 'blank' => 'vitals-07-2010-blank',
 51+ 'notknow' => 'vitals-07-2010-answer-never-heard',
 52+ 'exists' => 'vitals-07-2010-answer-heard-nothing',
 53+ 'hosted' => 'vitals-07-2010-answer-hosted',
 54+ 'familiar' => 'vitals-07-2010-answer-know',
 55+ ),
 56+ ),
 57+ 'computerexp' => array(
 58+ 'question' => 'vitals-07-2010-question-computerexp',
 59+ 'type' => 'select',
 60+ 'answers' => array(
 61+ 'blank' => 'vitals-07-2010-blank',
 62+ 'beginner' => 'vitals-07-2010-answer-beginner',
 63+ 'one' => 'vitals-07-2010-answer-one-lang',
 64+ 'many' => 'vitals-07-2010-answer-many-lang',
 65+ 'none' => 'vitals-07-2010-no-lang',
 66+ ),
 67+ ),
 68+ 'age' => array(
 69+ 'question' => 'vitals-07-2010-question-age',
 70+ 'type' => 'smallinput',
 71+ ),
 72+ 'gender' => array(
 73+ 'question' => 'vitals-07-2010-question-gender',
 74+ 'type' => 'select',
 75+ 'answers' => array(
 76+ 'blank' => 'vitals-07-2010-blank',
 77+ 'm' => 'vitals-07-2010-answer-male',
 78+ 'f' => 'vitals-07-2010-answer-female',
 79+ 'o' => 'vitals-07-2010-answer-other',
 80+ ),
 81+ ),
 82+ 'story' => array(
 83+ 'question' => 'vitals-07-2010-question-story',
 84+ 'type' => 'text',
 85+ ),
 86+ ),
 87+);
Property changes on: trunk/extensions/SimpleSurvey/Surveys.php
___________________________________________________________________
Added: svn:eol-style
188 + native
Index: trunk/extensions/SimpleSurvey/SimpleSurvey.classes.php
@@ -0,0 +1,119 @@
 2+<?php
 3+class SimpleSurvey extends PrefSwitchSurvey {
 4+ // Correlation between names of field types and implementation classes
 5+ private static $fieldTypes = array(
 6+ 'select' => 'PrefSwitchSurveyFieldSelect',
 7+ 'radios' => 'PrefSwitchSurveyFieldRadios',
 8+ 'checks' => 'PrefSwitchSurveyFieldChecks',
 9+ 'boolean' => 'PrefSwitchSurveyFieldBoolean',
 10+ 'dimensions' => 'PrefSwitchSurveyFieldDimensions',
 11+ 'text' => 'PrefSwitchSurveyFieldText',
 12+ 'smallinput' => 'PrefSwitchSurveyFieldSmallInput',
 13+ );
 14+
 15+ /* Static Functions */
 16+
 17+ /* update schema*/
 18+ public static function schema( ){
 19+ global $wgExtModifiedFields;
 20+
 21+ $wgExtModifiedFields[] = array(
 22+ 'prefswitch_survey',
 23+ 'pss_user',
 24+ dirname( __FILE__ ) . '/SimpleSurvey.patch-pssuser.sql'
 25+ );
 26+
 27+ return true;
 28+ }
 29+
 30+ /**
 31+ * creates a random token
 32+ * @return a random token
 33+ */
 34+ public static function generateRandomCookieID() {
 35+ global $wgUser;
 36+ return wfGenerateToken( array( $wgUser, time() ) );
 37+ }
 38+
 39+
 40+ /**
 41+ * Render the HTML for a survey.
 42+ * @param $name string Survey name
 43+ * @param $questions array Array containing question data
 44+ * @param $loadFromDB bool Load previous survey data from the database
 45+ * @return string HTML
 46+ */
 47+ public static function render( $questions ) {
 48+ global $wgUser;
 49+
 50+ $html = Xml::openElement( 'dl' );
 51+ foreach ( $questions as $field => $config ) {
 52+ $answer = null;
 53+ $answerData = null;
 54+ $invisible = false;
 55+ if(isset($config['visibility']) && $config['visibility'] == 'hidden' ){
 56+ $invisible = true;
 57+ }
 58+ if($invisible){
 59+ $html .= Xml::openElement( 'div', array("style" => "display:none;") );
 60+ }
 61+ $html .= call_user_func( array( self::$fieldTypes[$config['type']], 'render' ),
 62+ $field, $config, $answer, $answerData
 63+ );
 64+ if($invisible){
 65+ $html .= Xml::closeElement('div');
 66+ }
 67+ }
 68+ $html .= Xml::closeElement( 'dl' );
 69+ return $html;
 70+ }
 71+
 72+ /**
 73+ * Save a survey to the database
 74+ * @param $name string Survey name
 75+ * @param $survey array Survey configuration data
 76+ */
 77+ public static function save( $name, $survey ) {
 78+ global $wgRequest, $wgUser;
 79+ $dbw = wfGetDb( DB_MASTER );
 80+ $now = $dbw->timestamp();
 81+ $cookieID = $wgRequest->getCookie("vitals-survey");
 82+ if($cookieID == null){
 83+ $cookieID = self::generateRandomCookieID();
 84+ $wgRequest->response()->setcookie("vitals-survey", $cookieID);
 85+ }
 86+
 87+ foreach ( $survey['questions'] as $question => $config ) {
 88+ $dbw->insert(
 89+ 'prefswitch_survey',
 90+ array_merge(
 91+ array(
 92+ 'pss_user' => $cookieID,
 93+ 'pss_timestamp' => $now,
 94+ 'pss_name' => $name,
 95+ 'pss_question' => $question,
 96+ ),
 97+ call_user_func( array( self::$fieldTypes[$config['type']], 'save' ), $question, $wgRequest )
 98+ ),
 99+ __METHOD__
 100+ );
 101+ }
 102+
 103+ //pseudoquestion, logged in? IP address?
 104+ $dbw->insert(
 105+ 'prefswitch_survey',
 106+ array(
 107+ 'pss_user' => $cookieID,
 108+ 'pss_timestamp' => $now,
 109+ 'pss_name' => $name,
 110+ 'pss_question' => "logged_in",
 111+ 'pss_answer' => $wgUser->isLoggedIn()?"yes":"no",
 112+ 'pss_answer_data' => isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:null,
 113+ ),
 114+ __METHOD__
 115+ );
 116+
 117+
 118+
 119+ }
 120+}
\ No newline at end of file
Property changes on: trunk/extensions/SimpleSurvey/SimpleSurvey.classes.php
___________________________________________________________________
Added: svn:eol-style
1121 + native
Index: trunk/extensions/SimpleSurvey/SimpleSurvey.i18n.php
@@ -0,0 +1,61 @@
 2+<?php
 3+
 4+$messages = array();
 5+
 6+/** English
 7+ * @author Nimish Gautam
 8+ */
 9+$messages['en'] = array(
 10+ 'simplesurvey' => 'Take a quick survey',
 11+ 'simple-survey-invalid' => 'That is not a valid survey at this time',
 12+ 'simple-survey-back' => 'Go back',
 13+ 'simple-survey-title' => 'Simple Survey',
 14+
 15+ /*vitals 07 2010 */
 16+ 'simple-survey-intro-vitals-07-2010' => 'This is a quick survey to give us a better idea of who you are',
 17+ 'vitals-07-2010-submit' => 'Submit',
 18+
 19+ 'vitals-07-2010-question-use' => 'How often do you use Wikipedia?',
 20+ 'vitals-07-2010-question-edit' => 'Do you edit Wikipedia?',
 21+ 'vitals-07-2010-question-nonprofit' => 'Did you know Wikipedia is a non-profit?',
 22+ 'vitals-07-2010-question-wikimedia'=> 'Please describe your knowledge of the Wikimedia Foundation, the organization that hosts Wikipedia and its sitser projects such as Wiktionary and Wikiquote:',
 23+ 'vitals-07-2010-question-age'=> 'Please tell us your age',
 24+ 'vitals-07-2010-question-programming' => 'Please tell us which one of these describes you:',
 25+ 'vitals-07-2010-question-gender'=> 'Please tell us your gender',
 26+ 'vitals-07-2010-question-story'=> 'We love hearing about ways Wikipedia has impacted your life! Please feel free to share any stories, explain any of your answers, or leave a comment for the Wikimedia Foundation here:',
 27+ 'vitals-07-2010-question-computerexp' => "Which one of the following describes your computer experience?",
 28+
 29+ 'vitals-07-2010-blank'=> '',
 30+ 'vitals-07-2010-answer-daily'=> 'Daily',
 31+ 'vitals-07-2010-answer-weekly'=> 'Weekly',
 32+ 'vitals-07-2010-answer-monthly'=> 'Monthly',
 33+ 'vitals-07-2010-answer-rarely'=> 'less than monthly',
 34+ 'vitals-07-2010-answer-firsttime'=> 'This was my first time',
 35+ 'vitals-07-2010-answer-never'=> 'Never',
 36+
 37+ 'vitals-07-2010-answer-y-daily' => 'Yes, daily',
 38+ 'vitals-07-2010-answer-y-weekly' => 'Yes, weekly',
 39+ 'vitals-07-2010-answer-y-monthly' => 'Yes, monthly',
 40+ 'vitals-07-2010-answer-y-rarely' => 'Yes, but less than monthly',
 41+ 'vitals-07-2010-answer-n-never' => 'No, never',
 42+ 'vitals-07-2010-answer-dunno-edit'=> "I didn't know you could edit",
 43+
 44+ 'vitals-07-2010-answer-nonprof-knew' => "I knew it was a non-profit",
 45+ 'vitals-07-2010-answer-nonprof-business' => "I assumed it was a for-profit business",
 46+ 'vitals-07-2010-answer-nonprof-think' => "I've never thought about it",
 47+
 48+ 'vitals-07-2010-answer-never-heard' => "I've never heard of it",
 49+ 'vitals-07-2010-answer-heard-nothing' => "I guess I've heard of it, but don't know anything about it",
 50+ 'vitals-07-2010-answer-hosted' => "I know that Wikipedia is hosted by the Wikimedia Foundation, but that's about it",
 51+ 'vitals-07-2010-answer-know' => "I'm familiar with the Wikimedia Foundation",
 52+
 53+ 'vitals-07-2010-answer-beginner' => "I am a beginner with at least one programming language (eg HTML, PHP, Java, C)",
 54+ 'vitals-07-2010-answer-one-lang' => "I am comfortable with at least one programming language",
 55+ 'vitals-07-2010-answer-many-lang' => "I am comfortable with many programming languages",
 56+ 'vitals-07-2010-no-lang' => "Programming? Not me!",
 57+
 58+ 'vitals-07-2010-answer-male'=> 'Male',
 59+ 'vitals-07-2010-answer-female'=> 'Female',
 60+ 'vitals-07-2010-answer-other'=> 'Other',
 61+ );
 62+
Property changes on: trunk/extensions/SimpleSurvey/SimpleSurvey.i18n.php
___________________________________________________________________
Added: svn:eol-style
163 + native
Index: trunk/extensions/SimpleSurvey/SimpleSurvey.php
@@ -0,0 +1,99 @@
 2+<?php
 3+
 4+$dir = dirname( __FILE__ ) . '/';
 5+
 6+//from prefswitch in usability initiative
 7+require_once( dirname( dirname( __FILE__ ) ) . "/UsabilityInitiative/UsabilityInitiative.php" );
 8+$prefswitchdir = dirname( dirname( __FILE__ ) ) ."/UsabilityInitiative/PrefSwitch";
 9+
 10+// Adds Autoload Classes
 11+$wgAutoloadClasses = array_merge(
 12+ $wgAutoloadClasses,
 13+ array(
 14+ 'PrefSwitchSurvey' => $prefswitchdir . '/PrefSwitch.classes.php',
 15+ 'PrefSwitchSurveyField' => $prefswitchdir . '/PrefSwitch.classes.php',
 16+ 'PrefSwitchSurveyFieldSelect' => $prefswitchdir . '/PrefSwitch.classes.php',
 17+ 'PrefSwitchSurveyFieldRadios' => $prefswitchdir . '/PrefSwitch.classes.php',
 18+ 'PrefSwitchSurveyFieldChecks' => $prefswitchdir . '/PrefSwitch.classes.php',
 19+ 'PrefSwitchSurveyFieldBoolean' => $prefswitchdir . '/PrefSwitch.classes.php',
 20+ 'PrefSwitchSurveyFieldDimensions' => $prefswitchdir . '/PrefSwitch.classes.php',
 21+ 'PrefSwitchSurveyFieldText' => $prefswitchdir . '/PrefSwitch.classes.php',
 22+ 'SimpleSurvey' => $dir . "SimpleSurvey.classes.php",
 23+ 'SpecialSimpleSurvey' => $dir. 'SpecialSimpleSurvey.php',
 24+ )
 25+);
 26+unset($prefswitchdir);
 27+
 28+
 29+//add special pages
 30+$wgSpecialPages['SimpleSurvey'] = 'SpecialSimpleSurvey';
 31+$wgSpecialPageGroups['SimpleSurvey'] = 'wiki';
 32+$wgExtensionMessagesFiles['SimpleSurvey'] = $dir . 'SimpleSurvey.i18n.php';
 33+
 34+
 35+$wgExtensionCredits['other'][] = array(
 36+ 'path' => __FILE__,
 37+ 'name' => 'SimpleSurvey',
 38+ 'author' => array( 'Nimish Gautam' ),
 39+ 'version' => '0.1',
 40+ 'url' => 'http://www.mediawiki.org/wiki/Extension:UsabilityInitiative',
 41+);
 42+
 43+// Register database operations
 44+$wgHooks['LoadExtensionSchemaUpdates'][] = 'SimpleSurvey::schema';
 45+
 46+$wgValidSurveys = array();
 47+
 48+//add surveys
 49+require_once($dir . "Surveys.php");
 50+unset($dir);
 51+
 52+
 53+// Always include the browser stuff...
 54+foreach ( $wgPrefSwitchSurveys as &$survey ) {
 55+ $survey['questions']['browser'] = array(
 56+ 'visibility' => "hidden",
 57+ 'question' => 'prefswitch-survey-question-browser',
 58+ 'type' => 'select',
 59+ 'answers' => array(
 60+ 'ie5' => 'prefswitch-survey-answer-browser-ie5',
 61+ 'ie6' => 'prefswitch-survey-answer-browser-ie6',
 62+ 'ie7' => 'prefswitch-survey-answer-browser-ie7',
 63+ 'ie8' => 'prefswitch-survey-answer-browser-ie8',
 64+ 'ff1' => 'prefswitch-survey-answer-browser-ff1',
 65+ 'ff2' => 'prefswitch-survey-answer-browser-ff2',
 66+ 'ff3'=> 'prefswitch-survey-answer-browser-ff3',
 67+ 'cb' => 'prefswitch-survey-answer-browser-cb',
 68+ 'c1' => 'prefswitch-survey-answer-browser-c1',
 69+ 'c2' => 'prefswitch-survey-answer-browser-c2',
 70+ 's3' => 'prefswitch-survey-answer-browser-s3',
 71+ 's4' => 'prefswitch-survey-answer-browser-s4',
 72+ 'o9' => 'prefswitch-survey-answer-browser-o9',
 73+ 'o9.5' => 'prefswitch-survey-answer-browser-o9.5',
 74+ 'o10' => 'prefswitch-survey-answer-browser-o10',
 75+ ),
 76+ 'other' => 'prefswitch-survey-answer-browser-other',
 77+ );
 78+ $survey['questions']['os'] = array(
 79+ 'question' => 'prefswitch-survey-question-os',
 80+ 'visibility' => "hidden",
 81+ 'type' => 'select',
 82+ 'answers' => array(
 83+ 'windows' => 'prefswitch-survey-answer-os-windows',
 84+ 'windowsmobile' => 'prefswitch-survey-answer-os-windowsmobile',
 85+ 'macos' => 'prefswitch-survey-answer-os-macos',
 86+ 'iphoneos' => 'prefswitch-survey-answer-os-iphoneos',
 87+ 'linux' => 'prefswitch-survey-answer-os-linux',
 88+ ),
 89+ 'other' => 'prefswitch-survey-answer-os-other',
 90+ );
 91+ $survey['questions']['res'] = array(
 92+ 'question' => 'prefswitch-survey-question-res',
 93+ 'visibility' => "hidden",
 94+ 'type' => 'dimensions',
 95+ );
 96+}
 97+unset( $survey );
 98+
 99+
 100+
Property changes on: trunk/extensions/SimpleSurvey/SimpleSurvey.php
___________________________________________________________________
Added: svn:eol-style
1101 + native
Index: trunk/extensions/SimpleSurvey/SpecialSimpleSurvey.php
@@ -0,0 +1,119 @@
 2+<?php
 3+/**
 4+ * Special:PrefSwitch
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
 9+
 10+class SpecialSimpleSurvey extends SpecialPage {
 11+
 12+ /* Private Members */
 13+
 14+ private $origin = '';
 15+ private $originTitle = null;
 16+ private $originQuery = '';
 17+ private $originLink = '';
 18+ private $originLinkUrl = '';
 19+ private $originFullUrl = '';
 20+
 21+ /* Functions */
 22+
 23+ public function __construct() {
 24+ parent::__construct( 'SimpleSurvey' );
 25+ wfLoadExtensionMessages( 'SimpleSurvey' );
 26+ }
 27+
 28+
 29+ public function execute( $par ) {
 30+ global $wgRequest, $wgOut, $wgUser, $wgPrefSwitchSurveys, $wgPrefSwitchStyleVersion, $wgValidSurveys;
 31+ $this->setHeaders();
 32+ // Set page title
 33+ $wgOut->setPageTitle( wfMsg( 'simple-survey-title' ) );
 34+ $surveyName = $wgRequest->getVal("survey");
 35+
 36+ if($wgRequest->wasPosted()){
 37+ if($surveyName && in_array($surveyName,$wgValidSurveys )){
 38+ SimpleSurvey::save( $surveyName, $wgPrefSwitchSurveys[$surveyName] );
 39+ $wgOut->addHtml("<b>" . wfMsg( 'simple-survey-confirm' ). "</b>");
 40+ }
 41+ //forward to new page
 42+ return;
 43+ }
 44+
 45+ // Get the origin from the request
 46+ $par = $wgRequest->getVal( 'from', $par );
 47+ $this->originTitle = Title::newFromText( $par );
 48+ // $this->originTitle should never be Special:Userlogout
 49+ if (
 50+ $this->originTitle &&
 51+ $this->originTitle->getNamespace() == NS_SPECIAL &&
 52+ SpecialPage::resolveAlias( $this->originTitle->getText() ) == 'Userlogout'
 53+ ) {
 54+ $this->originTitle = null;
 55+ }
 56+ // Get some other useful information about the origin
 57+ if ( $this->originTitle ) {
 58+ $this->origin = $this->originTitle->getPrefixedDBKey();
 59+ $this->originQuery = $wgRequest->getVal( 'fromquery' );
 60+ $this->originLink = $wgUser->getSkin()->link( $this->originTitle, null, array(), $this->originQuery );
 61+ $this->originLinkUrl = $this->originTitle->getLinkUrl( $this->originQuery );
 62+ $this->originFullUrl = $this->originTitle->getFullUrl( $this->originQuery );
 63+ }
 64+
 65+ // Begin output
 66+ $this->setHeaders();
 67+ UsabilityInitiativeHooks::initialize();
 68+ UsabilityInitiativeHooks::addScript( 'PrefSwitch/PrefSwitch.js', $wgPrefSwitchStyleVersion );
 69+ UsabilityInitiativeHooks::addStyle( 'PrefSwitch/PrefSwitch.css', $wgPrefSwitchStyleVersion );
 70+ $wgOut->addHtml( '<div class="plainlinks">' );
 71+ // Handle various modes
 72+
 73+ $this->render( $wgRequest->getVal("survey") );
 74+
 75+
 76+ $wgOut->addHtml( '</div>' );
 77+ }
 78+
 79+ /* Private Functions */
 80+
 81+ private function render( $mode = null ) {
 82+ global $wgUser, $wgOut, $wgPrefSwitchSurveys, $wgValidSurveys;
 83+ // Make sure links will retain the origin
 84+ $query = array( 'from' => $this->origin, 'fromquery' => $this->originQuery );
 85+ if ( isset( $wgPrefSwitchSurveys[$mode] ) && in_array($mode, $wgValidSurveys) ){
 86+ $wgOut->addWikiMsg( "simple-survey-intro-{$mode}" );
 87+
 88+ // Setup a form
 89+ $html = Xml::openElement(
 90+ 'form', array(
 91+ 'method' => 'post',
 92+ 'action' => $this->getTitle()->getLinkURL( $query ),
 93+ 'class' => 'simple-survey',
 94+ 'id' => "simple-survey-{$mode}"
 95+ )
 96+ );
 97+ $html .= Xml::hidden( 'survey', $mode );
 98+ // Render a survey
 99+ $html .= SimpleSurvey::render(
 100+ $wgPrefSwitchSurveys[$mode]['questions']
 101+ );
 102+ // Finish out the form
 103+ $html .= Xml::openElement( 'dt', array( 'class' => 'prefswitch-survey-submit' ) );
 104+ $html .= Xml::submitButton(
 105+ wfMsg( $wgPrefSwitchSurveys[$mode]['submit-msg'] ),
 106+ array( 'id' => "simple-survey-submit-{$mode}", 'class' => 'prefswitch-survey-submit' )
 107+ );
 108+ $html .= Xml::closeElement( 'dt' );
 109+ $html .= Xml::closeElement( 'form' );
 110+ $wgOut->addHtml( $html );
 111+ }
 112+ else{
 113+ $wgOut->addWikiMsg( "simple-survey-invalid" );
 114+ if ( $this->originTitle ) {
 115+ $wgOut->addHTML( wfMsg( "simple-survey-back", $this->originLink ) );
 116+ }
 117+ }
 118+
 119+ }
 120+}
Property changes on: trunk/extensions/SimpleSurvey/SpecialSimpleSurvey.php
___________________________________________________________________
Added: svn:eol-style
1121 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r71744Followup r69807...reedy20:27, 26 August 2010
r71752Followup r71744, r69807 Use getId/getName and store both...reedy21:04, 26 August 2010

Comments

#Comment by Catrope (talk | contribs)   16:28, 3 August 2010
+--
+-- Schema patch for prefswitch_user to make it a varbinary	
+--
+
+ALTER TABLE /*_*/prefswitch_survey modify pss_user varbinary(255);

That's scary. I suggest adding a user_text field instead, and adding it in the PrefSwitch extension itself rather than in this extension.

Also, why are you putting a random token in the pss_user field only to store logged-in-ness and IP address in a pseudo-question? A traditional pss_user+pss_user_text combo with pss_user=0 meaning anon and storing the IP in user_text in that case (as is done in e.g. the revision table) sounds saner to me.

+	'simplesurvey' => 'Take a quick survey',
+	'simple-survey-invalid' => 'That is not a valid survey at this time',
+	'simple-survey-back' => 'Go back',
+    'simple-survey-title' => 'Simple Survey',

Bad indent there.

Generally, there's some code being duplicated from PrefSwitch but I don't see offhand how that could be handled cleanly, so never mind.

Status & tagging log