View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
05031 | Bug reports | Conditions | public | 2011-03-14 18:33 | 2011-04-11 11:30 |
Reporter | ResearchOnBlogs | Assigned To | lemeur | ||
Priority | normal | Severity | minor | ||
Status | closed | Resolution | fixed | ||
Product Version | 1.90+ | ||||
Fixed in Version | 1.91RC6 | ||||
Summary | 05031: GSOC - update answercodes does not update conditions | ||||
Description | Hi there, | ||||
Tags | No tags attached. | ||||
Attached Files | LSanswer.diff (3,414 bytes)
Index: admin/scripts/answers.js =================================================================== --- admin/scripts/answers.js (revision 9945) +++ admin/scripts/answers.js (working copy) @@ -198,6 +198,8 @@ $(this).addClass('highlight'); } $(this).addClass('row_'+rownumber); + $(this).find('.oldcode').attr('id','oldcode_'+rownumber+'_'+scale_id); + $(this).find('.oldcode').attr('name','oldcode_'+rownumber+'_'+scale_id); $(this).find('.code').attr('id','code_'+rownumber+'_'+scale_id); $(this).find('.code').attr('name','code_'+rownumber+'_'+scale_id); $(this).find('.answer').attr('id','answer_'+language+'_'+rownumber+'_'+scale_id); Index: admin/database.php =================================================================== --- admin/database.php (revision 9945) +++ admin/database.php (working copy) @@ -851,6 +851,7 @@ $maxcount=(int)$_POST['answercount_'.$scale_id]; for ($sortorderid=1;$sortorderid<$maxcount;$sortorderid++) { + $oldcode=sanitize_paranoid_string($_POST['oldcode_'.$sortorderid.'_'.$scale_id]); $code=sanitize_paranoid_string($_POST['code_'.$sortorderid.'_'.$scale_id]); $assessmentvalue=(int) $_POST['assessment_'.$sortorderid.'_'.$scale_id]; foreach ($alllanguages as $language) @@ -882,6 +883,12 @@ $databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"".$clang->gT("Failed to update answers","js")." - ".$query." - ".$connect->ErrorMsg()."\")\n //-->\n</script>\n"; } } // foreach ($alllanguages as $language) + + if($code !== $oldcode) { + $query='UPDATE '.db_table_name('conditions').' SET value='.db_quoteall($code).' WHERE cqid='.db_quote($qid).' AND value='.db_quoteall($oldcode); + $connect->execute($query); + } + } // for ($sortorderid=0;$sortorderid<$maxcount;$sortorderid++) } // for ($scale_id=0; Index: admin/editansweroptions.php =================================================================== --- admin/editansweroptions.php (revision 9945) +++ admin/editansweroptions.php (working copy) @@ -177,7 +177,7 @@ if ($first) { - $vasummary .= "<img class='handle' src='$imageurl/handle.png' /></td><td><input type='text' class='code' id='code_{$position}_{$scale_id}' name='code_{$position}_{$scale_id}' value=\"{$row['code']}\" maxlength='5' size='5'" + $vasummary .= "<img class='handle' src='$imageurl/handle.png' /></td><td><input type='hidden' class='oldcode' id='oldcode_{$position}_{$scale_id}' name='oldcode_{$position}_{$scale_id}' value=\"{$row['code']}\" /><input type='text' class='code' id='code_{$position}_{$scale_id}' name='code_{$position}_{$scale_id}' value=\"{$row['code']}\" maxlength='5' size='5'" ." onkeypress=\"return goodchars(event,'1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWZYZ_')\"" ." />"; } @@ -188,7 +188,7 @@ } $vasummary .= "</td>\n" ."<td\n"; if ($assessmentvisible && $first) { LSanswer_fixed.diff (3,177 bytes)
Index: admin/scripts/answers.js =================================================================== --- admin/scripts/answers.js (revision 9945) +++ admin/scripts/answers.js (working copy) @@ -198,6 +198,8 @@ $(this).addClass('highlight'); } $(this).addClass('row_'+rownumber); + $(this).find('.oldcode').attr('id','oldcode_'+rownumber+'_'+scale_id); + $(this).find('.oldcode').attr('name','oldcode_'+rownumber+'_'+scale_id); $(this).find('.code').attr('id','code_'+rownumber+'_'+scale_id); $(this).find('.code').attr('name','code_'+rownumber+'_'+scale_id); $(this).find('.answer').attr('id','answer_'+language+'_'+rownumber+'_'+scale_id); Index: admin/database.php =================================================================== --- admin/database.php (revision 9945) +++ admin/database.php (working copy) @@ -851,6 +851,7 @@ $maxcount=(int)$_POST['answercount_'.$scale_id]; for ($sortorderid=1;$sortorderid<$maxcount;$sortorderid++) { + $oldcode=sanitize_paranoid_string($_POST['oldcode_'.$sortorderid.'_'.$scale_id]); $code=sanitize_paranoid_string($_POST['code_'.$sortorderid.'_'.$scale_id]); $assessmentvalue=(int) $_POST['assessment_'.$sortorderid.'_'.$scale_id]; foreach ($alllanguages as $language) @@ -882,6 +883,12 @@ $databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"".$clang->gT("Failed to update answers","js")." - ".$query." - ".$connect->ErrorMsg()."\")\n //-->\n</script>\n"; } } // foreach ($alllanguages as $language) + + if($code !== $oldcode) { + $query='UPDATE '.db_table_name('conditions').' SET value='.db_quoteall($code).' WHERE cqid='.db_quote($qid).' AND value='.db_quoteall($oldcode); + $connect->execute($query); + } + } // for ($sortorderid=0;$sortorderid<$maxcount;$sortorderid++) } // for ($scale_id=0; Index: admin/editansweroptions.php =================================================================== --- admin/editansweroptions.php (revision 9945) +++ admin/editansweroptions.php (working copy) @@ -177,7 +177,7 @@ if ($first) { - $vasummary .= "<img class='handle' src='$imageurl/handle.png' /></td><td><input type='text' class='code' id='code_{$position}_{$scale_id}' name='code_{$position}_{$scale_id}' value=\"{$row['code']}\" maxlength='5' size='5'" + $vasummary .= "<img class='handle' src='$imageurl/handle.png' /></td><td><input type='hidden' class='oldcode' id='oldcode_{$position}_{$scale_id}' name='oldcode_{$position}_{$scale_id}' value=\"{$row['code']}\" /><input type='text' class='code' id='code_{$position}_{$scale_id}' name='code_{$position}_{$scale_id}' value=\"{$row['code']}\" maxlength='5' size='5'" ." onkeypress=\"return goodchars(event,'1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWZYZ_')\"" ." />"; } arrayconditions.diff (2,976 bytes)
Index: admin/database.php =================================================================== --- admin/database.php (revision 9976) +++ admin/database.php (working copy) @@ -927,6 +927,7 @@ //Determine ids by evaluating the hidden field $rows=array(); $codes=array(); + $oldcodes=array(); foreach ($_POST as $postkey=>$postvalue) { $postkey=explode('_',$postkey); @@ -938,6 +939,10 @@ { $codes[$postkey[2]][]=$postvalue; } + if ($postkey[0]=='oldcode') + { + $oldcodes[$postkey[2]][]=$postvalue; + } } $count=0; $invalidCode = 0; @@ -972,6 +977,12 @@ { $query='Update '.db_table_name('questions').' set question_order='.($position+1).', title='.db_quoteall($codes[$scale_id][$position]).', question='.db_quoteall($subquestionvalue).', scale_id='.$scale_id.' where qid='.db_quoteall($subquestionkey).' AND language='.db_quoteall($language); $connect->execute($query); + + if($codes[$scale_id][$position] !== $oldcodes[$scale_id][$position]) { + $query='UPDATE '.db_table_name('conditions').' SET cfieldname="+'.$surveyid.'X'.$gid.'X'.$qid.db_quote($codes[$scale_id][$position]).'" WHERE cfieldname="+'.$surveyid.'X'.$gid.'X'.$qid.db_quote($oldcodes[$scale_id][$position]).'"'; + $connect->execute($query); + } + } else { Index: admin/editsubquestions.php =================================================================== --- admin/editsubquestions.php (revision 9976) +++ admin/editsubquestions.php (working copy) @@ -195,7 +195,7 @@ } elseif ($activated != 'Y' && $first) // If survey is decactivated { - $vasummary .= "<img class='handle' src='$imageurl/handle.png' /></td><td><input type='text' id='code_{$row['qid']}_{$row['scale_id']}' class='code' name='code_{$row['qid']}_{$row['scale_id']}' value=\"{$row['title']}\" maxlength='5' size='5'" + $vasummary .= "<img class='handle' src='$imageurl/handle.png' /></td><td><input type='hidden' class='oldcode' id='oldcode_{$row['qid']}_{$row['scale_id']}' name='oldcode_{$row['qid']}_{$row['scale_id']}' value=\"{$row['title']}\" /><input type='text' id='code_{$row['qid']}_{$row['scale_id']}' class='code' name='code_{$row['qid']}_{$row['scale_id']}' value=\"{$row['title']}\" maxlength='5' size='5'" ." onkeypress=\" if(event.keyCode==13) {if (event && event.preventDefault) event.preventDefault(); document.getElementById('saveallbtn_$anslang').click(); return false;} return goodchars(event,'1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWZYZ_')\"" ." />"; | ||||
Bug heat | 12 | ||||
Complete LimeSurvey version number (& build) | 9642 | ||||
I will donate to the project if issue is resolved | No | ||||
Browser | |||||
Database type & version | ?? | ||||
Server OS (if known) | linux | ||||
Webserver software & version (if known) | ? | ||||
PHP Version | 5 | ||||
This is a known limitation of the current version. If a GSOC applicant is interrested in conditions, I would recommend to have a look at this point. (Don't hesitate to post a message on the ticket to get on touch with me.) The answers update code starts in admin/database.php on line 820. Now, let's explain the pb.
Now a quick description of conditions: where: |
|
thanks for your explanation |
|
Please check the patch I uploaded. I tested it and it seems to work correctly. lemeur, thank you for your note explaining how it works, it helped a lot. |
|
Thx for the work ont his ticket.
|
|
Sorry, please try the new patch. |
|
Thx for the new fix. Could you have a look ? Thibault |
|
Do you need help to finish the fix ? |
|
I'll look at it today and I'll post a note if I need any help. Thank you |
|
Boa tarde dionet, No teu GSOC proposicao e muito importante dizer que tu tens trabalhado no correctivo do bug 5031. Obrigado por teu trabalho e interresto no LimeSruevy. Sorry for my very bad Portuguese ;-) But it is important to add the reference to this ticket and your fix on your proposal. Thibault OUPS: haven't seen that you've added the reference already... good. |
|
lemeur, please try the new patch. Don't worry, your Portuguese isn't bad :P dionet |
|
Hi dionet, Thx for beeing indulgent about my Portuguese (promised, next time I'll have my wife or daughter correct my sentences ;-). The proposed extra patch fixes an issue when using single-checkboxes answers in conditions, but not when using group-of-cehckboxes as conditions. This is a little tricky as there are 2 ways to store conditions for multiple choices questions. Here are the 2 queries that must be used in this case:
The second one is for group-of-checkboxes questions Apart from this very specific issue I admit that this wasn't an easy patch and you did it very well. Thanx for your work and all the best with your application. |
|
Thank you, I'll do my best :) dionet |
|
Fixed in rev 9977 and 9978. Thibault |
|
1.91RC6 released. |
|
Date Modified | Username | Field | Change |
---|---|---|---|
2011-03-14 18:33 | ResearchOnBlogs | New Issue | |
2011-03-14 18:33 | ResearchOnBlogs | Status | new => assigned |
2011-03-14 18:33 | ResearchOnBlogs | Assigned To | => lemeur |
2011-03-20 07:04 | lemeur | Summary | update answercodes does not update conditions => GSOC - update answercodes does not update conditions |
2011-03-20 07:35 | lemeur | Note Added: 14468 | |
2011-03-23 14:32 | ResearchOnBlogs | Note Added: 14524 | |
2011-03-29 00:45 | pasmaill | Issue Monitored: pasmaill | |
2011-03-29 18:40 |
|
Issue Monitored: user13064 | |
2011-04-03 00:02 | dionet | File Added: LSanswer.diff | |
2011-04-03 00:02 | dionet | Note Added: 14634 | |
2011-04-03 00:02 | dionet | Issue Monitored: dionet | |
2011-04-03 08:44 | lemeur | Note Added: 14635 | |
2011-04-03 08:44 | lemeur | Status | assigned => new |
2011-04-03 08:45 | lemeur | Status | new => assigned |
2011-04-03 08:45 | lemeur | Status | assigned => feedback |
2011-04-03 12:38 | dionet | File Added: LSanswer_fixed.diff | |
2011-04-03 12:39 | dionet | Note Added: 14636 | |
2011-04-05 00:07 | lemeur | Note Added: 14667 | |
2011-04-06 12:01 | lemeur | Note Added: 14688 | |
2011-04-06 15:20 | dionet | Note Added: 14698 | |
2011-04-06 18:01 | lemeur | Note Added: 14701 | |
2011-04-06 18:06 | lemeur | Note Edited: 14701 | |
2011-04-07 17:46 | dionet | File Added: arrayconditions.diff | |
2011-04-07 17:47 | dionet | Note Added: 14729 | |
2011-04-07 18:23 | lemeur | Note Added: 14730 | |
2011-04-07 18:30 | dionet | Note Added: 14731 | |
2011-04-07 18:32 | lemeur | Note Added: 14732 | |
2011-04-07 18:32 | lemeur | Status | feedback => resolved |
2011-04-07 18:32 | lemeur | Fixed in Version | => 1.91RC6 |
2011-04-07 18:32 | lemeur | Resolution | open => fixed |
2011-04-11 11:30 | c_schmitz | Note Added: 14745 | |
2011-04-11 11:30 | c_schmitz | Status | resolved => closed |
2021-08-02 19:33 | guest | Bug heat | 8 => 12 |