View Issue Details

This bug affects 1 person(s).
 2
IDProjectCategoryView StatusLast Update
05092Bug reportsSurvey editingpublic2011-05-04 19:31
Reporteruser13194Assigned Toc_schmitz  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Fixed in Version1.91 
Summary05092: Error during Preview of Questions that have replacement field from a previous question
Description

Error is shown when trying to preview a question that has a replacement field from the answer of a previous question

Steps To Reproduce

Version 1.9.2dev
1.Create a survey, group by group mode
2.Create Group 1
3.Create Question 1 in Group 1 e.g: What is your name?
4.Create Group 2
5.Create Question 1 in Group 2 with a Replacement Field from Group1-Question1
5.1.Insert Replacement field by clicking the Insert/Edit Limesurvey Replacement Field in the Toolbar above the text box
5.2.In the resulting Limesurvey replacement field properties, select the previous answer from the Previous Answers Fields
e.g: How old are you, {INSERTANS:66243X4X4}

  1. Save the question, and Preview Group 2 or Question 1 in Group 2.
    In the resulting question, an error is shown:
    "How old are you, Error(66243X4X4)"
TagsNo tags attached.
Attached Files
replacementfield_questions_preview_error_patch.diff (909 bytes)   
--- preview_orgnl.php	2011-04-06 14:12:40.691583000 +0530
+++ preview.php	2011-04-06 16:05:31.983582999 +0530
@@ -87,6 +87,18 @@
 $question['class'] = question_class($qrows['type']);
 $question['essentials'] = 'id="question'.$qrows['qid'].'"';
 $question['sgq']=$ia[1];
+
+//Temporary fix for error condition arising from linked question via replacement fields
+//@todo: find a consistent way to check and handle this - I guess this is already handled but the wrong values are entered into the DB
+
+$search_for = '{INSERTANS';
+if(strpos($question['text'],$search_for)!==false){
+    $pattern_text = '/{([A-Z])*:([0-9])*X([0-9])*X([0-9])*}/';
+    $replacement_text = '[Dependancy on Another Question ID: $4]';
+    $text = preg_replace($pattern_text,$replacement_text,$question['text']);    
+    $question['text']=$text;
+}
+
 if ($qrows['mandatory'] == 'Y')
 {
     $question['man_class'] = ' mandatory';
Bug heat2
Complete LimeSurvey version number (& build)9971
I will donate to the project if issue is resolvedNo
BrowserFirefox3
Database type & versionMySQL 5.1
Server OS (if known)Ubuntu 10.10
Webserver software & version (if known)Apache2
PHP Version5.3.3

Users monitoring this issue

There are no users monitoring this issue.

Activities

user13194

2011-04-06 20:01

  ~14706

I've attached a patch for this which currently handles the Error message - I guess it doesn't make sense to preview the question beforehand in this case, but it should fail gracefully without producing an Error message. I've handled this by doing a search for INSERTANS and proving a dependency message - the next step would be to give information of actual dependency question itself. Please let me know whether I've got this right, or whether I'm barking up the wrong bush :)

Issue History

Date Modified Username Field Change
2011-04-06 19:53 user13194 New Issue
2011-04-06 19:59 user13194 File Added: replacementfield_questions_preview_error_patch.diff
2011-04-06 20:01 user13194 Note Added: 14706
2011-04-06 23:35 c_schmitz Assigned To => c_schmitz
2011-04-06 23:35 c_schmitz Status new => assigned
2011-04-11 11:27 c_schmitz Status assigned => resolved
2011-04-11 11:27 c_schmitz Fixed in Version => 1.91RC6
2011-04-11 11:27 c_schmitz Resolution open => fixed
2011-04-11 11:29 c_schmitz Fixed in Version 1.91RC6 => 1.91
2011-05-04 19:31 c_schmitz Status resolved => closed
2019-11-01 17:25 c_schmitz Category Survey design => Survey editing