View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 05403 | Bug reports | Print View | public | 2011-08-17 18:01 | 2011-08-24 15:32 |
| Reporter | ronvdburg | Assigned To | c_schmitz | ||
| Priority | normal | Severity | minor | ||
| Status | closed | Resolution | fixed | ||
| Product Version | 1.91+ | ||||
| Summary | 05403: Actually hide questions in Print Answers if they have attribute 'hidden' | ||||
| Description | The 'print answers' at the end of the survey prints also hidden questions. The attached patch file hides these questions from printing answers. | ||||
| Steps To Reproduce | Give a question attribute 'hidden'. | ||||
| Additional Information | If you wish to configure this behaviour with a new variable in config.php, please give me a proper name for the new variable and I will upload a new patch file that has configurable behaviour for hiding hidden questions from 'print answers'. | ||||
| Tags | No tags attached. | ||||
| Attached Files | common_functions.php.diff-u.v2.txt (598 bytes)
--- common_functions.php.org 2011-08-11 20:48:32.000000000 +0200
+++ common_functions.php 2011-08-18 11:37:49.000000000 +0200
@@ -7553,6 +7553,14 @@
$oldqid = 0;
foreach ($aFieldMap as $sKey=>$fname)
{
+ if (!empty($fname['qid']))
+ {
+ $attributes = getQuestionAttributes($fname['qid']);
+ if (getQuestionAttributeValue($attributes, 'hidden') == 1)
+ {
+ continue;
+ }
+ }
$question = $fname['question'];
$subquestion='';
if (isset($fname['gid']) && !empty($fname['gid'])) {
common_functions.php.svn-diff.txt (650 bytes)
Index: common_functions.php
===================================================================
--- common_functions.php (revision 10834)
+++ common_functions.php (working copy)
@@ -7553,6 +7553,14 @@
$oldqid = 0;
foreach ($aFieldMap as $sKey=>$fname)
{
+ if (!empty($fname['qid']))
+ {
+ $attributes = getQuestionAttributes($fname['qid']);
+ if (getQuestionAttributeValue($attributes, 'hidden') == 1)
+ {
+ continue;
+ }
+ }
$question = $fname['question'];
$subquestion='';
if (isset($fname['gid']) && !empty($fname['gid'])) {
| ||||
| Bug heat | 8 | ||||
| Complete LimeSurvey version number (& build) | 10746 | ||||
| I will donate to the project if issue is resolved | No | ||||
| Browser | |||||
| Database type & version | mysql 14.12 | ||||
| Server OS (if known) | Centos 2.2.3 (Linux version 2.6.18-194.3.1.el5) | ||||
| Webserver software & version (if known) | Apache/2.2.3 (CentOS) | ||||
| PHP Version | 5.1.6 | ||||
| Git branch / Pull Request URL | |||||
|
For this line: if (isset($fname['qid']) && !empty($fname['qid'])) a short note: empty() check's already if a variable is set. So could be better written as: if (!empty($fname['qid'])) |
|
|
Ok mot, thanks for your explanation of empty(). By the way, shouldn't this also be done in other places? If you wish, I can upload another patch with those 5 changes. admin/export_structure_xml.php (3x) admin/quota.php (2x) Regards, Ron |
|
|
Hi Ron, yes I have seen there are other places as well. I think it's important for new code we don't use the more complicated expressions, but as long as old code is concerned, I suggest to not touch it (sounds a bit unfair, right :) ). I can understand the itch in the fingers ;), the problem with changing/improving unrelated code is that it can introduce new bugs (as we put a hand on it, mistakes happen) and that it's much work that is better to do in a dedicated code review with a whole team etc. . Currently the codebase gets actually ported as well, so there is even less use in doing that now. For the other indeed complicated looking expressions:
The useless part is, that an unset variable is NULL and never an Array, so there is no Array Value that can be true or false. So this expression never is TRUE. The ORed part only is in action, which leaves
So logically your suggestion is correct. Question is, why did the original author write it that way? Maybe the following was meant? (isset($exclude['answers']) && $exclude['answers'] !== true) We can only assume, but we should not make assumptions in debugging. As long as we don't know and there is no known issue about that part, the code should not be changed. Contacting the original author could help here or testing for flaws that are related to these lines of code. Thank you for taking care. |
|
|
ronvdburg, is it possible to provide a patch created with subversion? |
|
|
Hi Carsten, Sorry, forgot to use svn diff in stead of diff -u. Regards, Ron |
|
|
Thank you! Will be fixed in next 1.91+ release! |
|
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2011-08-17 18:01 | ronvdburg | New Issue | |
| 2011-08-17 18:02 | ronvdburg | File Added: common_functions.php.diff-u | |
| 2011-08-17 18:03 | ronvdburg | Issue Monitored: ronvdburg | |
| 2011-08-17 18:40 | mot | Note Added: 16085 | |
| 2011-08-18 11:39 | ronvdburg | File Added: common_functions.php.diff-u.v2.txt | |
| 2011-08-18 12:26 | ronvdburg | Note Added: 16090 | |
| 2011-08-18 12:54 | mot | Note Added: 16091 | |
| 2011-08-18 12:56 | mot | Note Edited: 16091 | |
| 2011-08-18 12:57 | mot | Note Edited: 16091 | |
| 2011-08-18 13:03 | c_schmitz | Assigned To | => c_schmitz |
| 2011-08-18 13:03 | c_schmitz | Status | new => assigned |
| 2011-08-23 18:34 | c_schmitz | Note Added: 16122 | |
| 2011-08-24 15:01 | ronvdburg | File Added: common_functions.php.svn-diff.txt | |
| 2011-08-24 15:07 | ronvdburg | Note Added: 16129 | |
| 2011-08-24 15:32 | c_schmitz | Note Added: 16134 | |
| 2011-08-24 15:32 | c_schmitz | Status | assigned => closed |
| 2021-08-05 13:51 | guest | Bug heat | 6 => 8 |
| 2026-10-25 16:41 | c_schmitz | Resolution | open => fixed |