View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
06078Bug reportsSurvey takingpublic2012-05-28 15:11
ReporterTMSWhite Assigned ToTMSWhite  
PriorityhighSeveritycrash 
Status closedResolutionfixed 
Product Version2.00RC1 
Fixed in Version2.00RC1 
Summary06078: invalid LimeExpressionManager->ngT() calls
Description

They can't be used if min/max answers (etc.) are variables, otherwise get errors like this:

PHP notice

Use of undefined constant maxSelect - assumed 'maxSelect'

C:\xampp\htdocs\git\limesurvey_yii\application\third_party\php-gettext\gettext.php(361) : eval()'d code(1)
Stack Trace
#0

C:\xampp\htdocs\git\limesurvey_yii\application\third_party\php-gettext\gettext.php(361): eval()

356 $string = str_replace('plural',"\$plural",$string);
357
358 $total = 0;
359 $plural = 0;
360
361 eval("$string");
362 if ($plural >= $total) $plural = $total - 1;
363 return $plural;
364 }
365
366 /**

#1

C:\xampp\htdocs\git\limesurvey_yii\application\third_party\php-gettext\gettext.php(384): gettext_reader->select_string("maxSelect")

379 else
380 return $single;
381 }
382
383 // find out the appropriate form
384 $select = $this->select_string($number);
385
386 // this should contains all strings separated by NULLs
387 $key = $single . chr(0) . $plural;
388
389

#2

C:\xampp\htdocs\git\limesurvey_yii\application\libraries\Limesurvey_lang.php(59): gettext_reader->ngettext("Please select between %s and %s answer.", "Please select between %s and %s answers.", "maxSelect")

54 */
55 function ngT($single, $plural, $number, $escapemode = 'html')
56 {
57 if ($this->gettextclass)
58 {
59 $basestring=str_replace('‘','\'',$this->gettextclass->ngettext($single, $plural, $number));
60 switch ($escapemode)
61 {
62 case 'html':
63 return $this->HTMLEscape($basestring);
64 break;

#3
+
C:\xampp\htdocs\git\limesurvey_yii\application\helpers\expressions\em_manager_helper.php(5810): Limesurvey_lang->ngT("Please select between %s and %s answer.", "Please select between %s and %s answers.", "maxSelect", "html")
#4

C:\xampp\htdocs\git\limesurvey_yii\application\helpers\expressions\em_manager_helper.php(1539): LimeExpressionManager->ngT("Please select between %s and %s answer.", "Please select between %s and %s answers.", "maxSelect")

1534 // min/max answers
1535 if ($min_answers!='' || $max_answers!='')
1536 {
1537 if ($min_answers!='' && $max_answers!='')
1538 {
1539 $qtips['num_answers']=sprintf($this->ngT("Please select between %s and %s answer.","Please select between %s and %s answers.",$max_answers),'{fixnum('.$min_answers.')}','{fixnum('.$max_answers.')}');
1540 }
1541 else if ($min_answers!='')
1542 {
1543 $qtips['num_answers']=sprintf($this->ngT("Please select at least %s answer.","Please select at least %s answers.",$min_answers),'{fixnum('.$min_answers.')}');
1544

Steps To Reproduce

install sample survey from this link: http://docs.limesurvey.org/Expression+Manager+Sample+Surveys#Traditional_Validation_Re-envisioned

Fill out page 1 and click Next and you will see this error

TagsNo tags attached.
Bug heat4
Complete LimeSurvey version number (& build)120501
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMysql 5.3
Server OS (if known)Windows XP
Webserver software & version (if known)XAMPP
PHP Version5.3

Users monitoring this issue

There are no users monitoring this issue.

Activities

c_schmitz

c_schmitz

2012-05-10 14:07

administrator   ~18660

Can full expressions be used in these attributes? Or just simple variables?

TMSWhite

TMSWhite

2012-05-10 14:17

reporter   ~18661

full expressions can be used in most advanced question attributes

c_schmitz

c_schmitz

2012-05-10 14:28

administrator   ~18662

So do you think could we do something like

"if ({$min_answers}==1,'".sprintf($this->gT("Please select at least %s answer,$min_answers)."','".sprintf($this->gT("Please select at least %s answers,$min_answers)."')"

in there?

TMSWhite

TMSWhite

2012-05-10 17:16

reporter   ~18664

It's a little trickier than that. I'm working on it and should be done soon.

TMSWhite

TMSWhite

2012-05-10 19:19

reporter   ~18665

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=8392

TMSWhite

TMSWhite

2012-05-10 19:20

reporter   ~18666

Fix committed to Yii branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=8393

c_schmitz

c_schmitz

2012-05-28 15:11

administrator   ~18945

Version 2.00RC2 released.

Related Changesets

LimeSurvey: master 7f03e543

2012-05-10 10:17:46

TMSWhite

Details Diff
Fixed issue 06078: invalid LimeExpressionManager->ngT() calls
Dev Since min/max number of answers and min/max values can be dynamic, used EM to act as dynamic version of ngT()
Dev EM will detect cases where the messages are static, and generate static content for them (rather than the nested if() statements)
Dev Fixed printablesurvey so that only uses static tips - showing the pretty-print version with the nested if() statements does not make sense on printable survey
Dev added sample survey to test the dynamic plurals generation.
Affected Issues
06078
add - docs/demosurveys/ls2_plurals_test.lss Diff File
mod - admin/printablesurvey.php Diff File
mod - classes/expressions/LimeExpressionManager.php Diff File

LimeSurvey: Yii 51589bd8

2012-05-10 10:18:38

TMSWhite

Details Diff
Fixed issue 06078: invalid LimeExpressionManager->ngT() calls
Dev Since min/max number of answers and min/max values can be dynamic, used EM to act as dynamic version of ngT()
Dev EM will detect cases where the messages are static, and generate static content for them (rather than the nested if() statements)
Dev Fixed printablesurvey so that only uses static tips - showing the pretty-print version with the nested if() statements does not make sense on printable survey
Dev added sample survey to test the dynamic plurals generation.
Affected Issues
06078
add - docs/demosurveys/ls2_plurals_test.lss Diff File
mod - application/controllers/admin/printablesurvey.php Diff File
mod - application/helpers/expressions/em_manager_helper.php Diff File

Issue History

Date Modified Username Field Change
2012-05-09 18:17 TMSWhite New Issue
2012-05-10 14:07 c_schmitz Note Added: 18660
2012-05-10 14:08 c_schmitz Assigned To => c_schmitz
2012-05-10 14:08 c_schmitz Status new => feedback
2012-05-10 14:17 TMSWhite Note Added: 18661
2012-05-10 14:17 TMSWhite Status feedback => assigned
2012-05-10 14:28 c_schmitz Note Added: 18662
2012-05-10 17:16 TMSWhite Note Added: 18664
2012-05-10 19:19 TMSWhite Changeset attached => LimeSurvey master 7f03e543
2012-05-10 19:19 TMSWhite Note Added: 18665
2012-05-10 19:19 TMSWhite Assigned To c_schmitz => TMSWhite
2012-05-10 19:19 TMSWhite Resolution open => fixed
2012-05-10 19:20 TMSWhite Changeset attached => LimeSurvey Yii 51589bd8
2012-05-10 19:20 TMSWhite Note Added: 18666
2012-05-10 19:21 TMSWhite Status assigned => resolved
2012-05-10 19:21 TMSWhite Fixed in Version => 2.00RC1
2012-05-28 15:11 c_schmitz Note Added: 18945
2012-05-28 15:11 c_schmitz Status resolved => closed