r95700 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95699‎ | r95700 | r95701 >
Date:21:23, 29 August 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
do not inc removed questions by default
Modified paths:
  • /trunk/extensions/Survey/includes/SurveyQuestion.php (modified) (history)
  • /trunk/extensions/Survey/resources/ext.survey.special.survey.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Survey/includes/SurveyQuestion.php
@@ -172,11 +172,18 @@
173173 * @since 0.1
174174 *
175175 * @param integer $surveyId
 176+ * @param boolean $incRemoved
176177 *
177178 * @return array of SurveyQuestion
178179 */
179 - public static function getQuestionsForSurvey( $surveyId ) {
180 - return self::getQuestionsFromDB( array( 'question_survey_id' => $surveyId ) );
 180+ public static function getQuestionsForSurvey( $surveyId, $incRemoved = false ) {
 181+ $conditions = array( 'question_survey_id' => $surveyId );
 182+
 183+ if ( $incRemoved === false ) {
 184+ $conditions['question_removed'] = 0;
 185+ }
 186+
 187+ return self::getQuestionsFromDB( $conditions );
181188 }
182189
183190 /**
@@ -290,4 +297,17 @@
291298 return $this->required;
292299 }
293300
 301+ /**
 302+ * Gets if the question was removed.
 303+ * This means it should not be shown in the UI,
 304+ * and is only kept to make sense of old answers liked to it.
 305+ *
 306+ * @since 0.1
 307+ *
 308+ * @return boolean
 309+ */
 310+ public function wasRemoved() {
 311+ return $this->removed;
 312+ }
 313+
294314 }
Index: trunk/extensions/Survey/resources/ext.survey.special.survey.js
@@ -5,7 +5,7 @@
66 * @licence GNU GPL v3 or later
77 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
88 */
9 -(function( $ ) { $( document ).ready( function() {
 9+(function( $, mw ) { $( document ).ready( function() {
1010
1111 var _this = this;
1212
@@ -22,10 +22,8 @@
2323
2424 // TODO: defaulting
2525
26 - var id = 'foo';
27 -
2826 $tr.append( $( '<td />' ).attr( { 'class': 'mw-label' } ).html(
29 - $( '<label />' ).attr( { 'for': id } ).text( survey.msg( 'survey-question-label-nr', ++questionNr ) )
 27+ $( '<label />' ).text( mw.msg( 'survey-question-label-nr', ++questionNr ) )
3028 ) );
3129
3230 $tr.append( $( '<td />' ).attr( { 'class': 'mw-input' } ).html(
@@ -100,4 +98,4 @@
10199
102100 setup();
103101
104 -} ); })( jQuery );
\ No newline at end of file
 102+} ); })( jQuery, window.mediaWiki );
\ No newline at end of file

Status & tagging log