View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
09462Bug reportsExpression Managerpublic2015-08-04 15:10
Reportergtrudel Assigned Toc_schmitz  
PriorityhighSeveritypartial_block 
Status closedResolutionunable to reproduce 
Product Version2.05+ 
Summary09462: Regular expressions for validating fields in questions disappear at the survey level
Description

After adding email and phone regular expression validations through the expression manager for certain questions, tests will work at the question and group level, but not at the survey level. At the survey level, the regular expressions are gone from the generated JavaScript code.

Steps To Reproduce

Add regular expressions to validate email and phone number inputs (as subquestions to a survey question) as follows:
Email: ^\w+([-+.']\w+)@\w+([-.]\w+).\w+([-.]\w+)*$
Phone: ^(+\d{1,2}\s)?(?\d{3})?[\s.-]?\d{3}[\s.-]?\d{4}$
Save the survey.
Test the question (should work).
Test the question group (should work).
Test the question within a survey test (does not work).

Additional Information

Issue is the same on Chrome and FireFox browsers. Used FireBug to validate that the JavaScript regex code in survey_runtime.js disappears when testing the survey in its entirety, but is there at the question and question group level.

TagsNo tags attached.
Attached Files
Bug heat6
Complete LimeSurvey version number (& build)141229
I will donate to the project if issue is resolvedNo
BrowserChrome 39.0.2171.95 m
Database type & versionMySQL 5.0.11
Server OS (if known)Windows 7 Enterprise
Webserver software & version (if known)Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9
PHP Version5.5.9

Users monitoring this issue

gtrudel

Activities

gtrudel

gtrudel

2015-01-20 16:53

reporter   ~31472

It appears that regular expressions (regexMatch) do not work for question validation equations. However, they do work for question validation tips.

gtrudel

gtrudel

2015-01-23 19:24

reporter   ~31484

New information: Validation expressions when applied to sub-questions on the first screen for validation tips will not apply if the survey does not have a welcome screen. Once you add a welcome screen, then the immediate validation tips work.

gtrudel

gtrudel

2015-01-23 20:55

reporter   ~31485

Found the problem: Line 386 of \application\helpers\SurveyRuntimeHelper.php was $moveResult = LimeExpressionManager::GetLastMoveResult(true); which executed if this was true: if (!isset($moveResult) && !($surveyMode != 'survey' && $_SESSION[$LEMsessid]['step'] == 0)). Where there was no welcome screen, that evaluated to true and resulted in a first page that did not have all the validation expressions in it. The stack trace to insert the proper EM code (which only occurs when there is a welcome page for the survey) as JavaScript is as follows:
C:/xampp/htdocs/vm/trunk/application/helpers/expressions/em_core_helper.php.ExpressionManager->sProcessStringContainingExpressions:1855
[1] file:///C:/xampp/htdocs/vm/trunk/application/helpers/expressions/em_manager_helper.php.LimeExpressionManager::ProcessString:4263
[2] file:///C:/xampp/htdocs/vm/trunk/application/helpers/expressions/em_manager_helper.php.LimeExpressionManager->_ValidateQuestion:6376
[3] file:///C:/xampp/htdocs/vm/trunk/application/helpers/expressions/em_manager_helper.php.LimeExpressionManager->_ValidateGroup:5735
[4] file:///C:/xampp/htdocs/vm/trunk/application/helpers/expressions/em_manager_helper.php.LimeExpressionManager::NavigateForwards:5004
[5] file:///C:/xampp/htdocs/vm/trunk/application/helpers/SurveyRuntimeHelper.php.SurveyRuntimeHelper->run:350
[6] file:///C:/xampp/htdocs/vm/trunk/application/controllers/survey/index.php.index->action:579
[7] file:///C:/xampp/htdocs/vm/trunk/application/controllers/survey/index.php.index->run:46
[8] file:///C:/xampp/htdocs/vm/trunk/framework/web/actions/CAction.php.CAction->runWithParams:76
[9] file:///C:/xampp/htdocs/vm/trunk/framework/web/CController.php.CController->runAction:308
[10] file:///C:/xampp/htdocs/vm/trunk/framework/web/CController.php.CController->runActionWithFilters:286
[11] file:///C:/xampp/htdocs/vm/trunk/framework/web/CController.php.CController->run:265
[12] file:///C:/xampp/htdocs/vm/trunk/framework/web/CWebApplication.php.CWebApplication->runController:282
[13] file:///C:/xampp/htdocs/vm/trunk/framework/web/CWebApplication.php.CWebApplication->processRequest:141
[14] file:///C:/xampp/htdocs/vm/trunk/framework/base/CApplication.php.CApplication->run:180
[15] file:///C:/xampp/htdocs/vm/trunk/index.php.{main}:200

To fix, I commented out line 386 and inserted:
$moveResult = LimeExpressionManager::NavigateForwards();

It is too bad I am not able to change the status or priority of my own bug. This is now resolved.

c_schmitz

c_schmitz

2015-01-28 17:07

administrator   ~31517

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

c_schmitz

c_schmitz

2015-01-28 17:08

administrator   ~31518

Last edited: 2015-01-28 17:08

Can you please test the patch above and give us feedback? Code change is minimal, please revert your own code change before you apply ours.

gtrudel

gtrudel

2015-01-28 17:31

reporter   ~31520

I tested your fix which was different to mine. It did not work. After publishing my survey with no welcome page, the EM failed to kick in to immediately validate my email field when I started to type something in on the first page.

c_schmitz

c_schmitz

2015-05-08 15:10

administrator   ~32145

I cannot reproduce your problem using the latest version. Can you create a short sample survey where YOU can reproduce it easily and attach it here?

gtrudel

gtrudel

2015-05-08 15:30

reporter   ~32146

I am sorry you are unable to reproduce this problem, and I am not sure what else I can do to assist you. Our version of LimeSurvey works just fine with the fix I provided, so perhaps something changed in the latest version that already fixed it in another way? My apologies, but I do not have the time to look into this, so I would suggest you just close this issue unless or until this comes up again.
Sound good?

Related Changesets

LimeSurvey: master 27dd87ff

2015-01-28 17:07

c_schmitz


Details Diff
Fixed issue 09462: Regular expressions for validating fields don't validate if survey skips welcome screen Affected Issues
09462
mod - application/helpers/SurveyRuntimeHelper.php Diff File

Issue History

Date Modified Username Field Change
2015-01-16 20:51 gtrudel New Issue
2015-01-16 20:51 gtrudel File Added: limesurvey_survey_423489 (1).lss
2015-01-20 14:38 gtrudel Issue Monitored: gtrudel
2015-01-20 16:53 gtrudel Note Added: 31472
2015-01-23 19:24 gtrudel Note Added: 31484
2015-01-23 20:55 gtrudel Note Added: 31485
2015-01-28 17:07 c_schmitz Changeset attached => LimeSurvey master 27dd87ff
2015-01-28 17:07 c_schmitz Note Added: 31517
2015-01-28 17:07 c_schmitz Assigned To => c_schmitz
2015-01-28 17:07 c_schmitz Resolution open => fixed
2015-01-28 17:08 c_schmitz Note Added: 31518
2015-01-28 17:08 c_schmitz Status new => feedback
2015-01-28 17:08 c_schmitz Note Edited: 31518
2015-01-28 17:31 gtrudel Note Added: 31520
2015-01-28 17:31 gtrudel Status feedback => assigned
2015-05-08 15:10 c_schmitz Note Added: 32145
2015-05-08 15:10 c_schmitz Status assigned => feedback
2015-05-08 15:30 gtrudel Note Added: 32146
2015-05-08 15:30 gtrudel Status feedback => assigned
2015-08-04 15:10 c_schmitz Status assigned => closed
2015-08-04 15:10 c_schmitz Resolution fixed => unable to reproduce
2021-08-02 21:05 guest Bug heat 4 => 6