View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
05323 | Bug reports | Survey taking | public | 2011-07-06 20:25 | 2012-03-14 21:08 |
Reporter | Assigned To | c_schmitz | |||
Priority | normal | Severity | minor | ||
Status | closed | Resolution | fixed | ||
Product Version | 1.91+ | ||||
Fixed in Version | 1.91+ | ||||
Summary | 05323: .missing class added in answered filtered array question "Show question index / allow jumping" modality | ||||
Description | In "Show index/allow jumping" modality .missing class is added at filtered array question even if all subquestions are answered | ||||
Steps To Reproduce |
In the index the first group will be marked as if there are missing answer. Going to the previous page will show that the array question has been marked as missing (class=".missing") an example can be seen at http://www.officair-survey.eu/index.php?sid=19883&lang=en | ||||
Tags | No tags attached. | ||||
Attached Files | floccs.patch (2,846 bytes)
Index: common_functions.php =================================================================== --- common_functions.php (revisione 11141) +++ common_functions.php (copia locale) @@ -7668,12 +7668,14 @@ */ function bCheckQuestionForAnswer($q, $aFieldnamesInfoInv) { - if (@$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['type'] == 'X') + $qtype = $_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['type']; + + if ($qtype == 'X') { // boilerplate have no answers return true; } - else if (@$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['type'] == 'M' || @$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['type'] == 'P' || @$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['type'] == 'O') + else if ($qtype == 'M' || $qtype == 'P' || $qtype == 'O') { // multiple choice and list with comments question types - just one answer is required and comments are not required $bAnsw = false; @@ -7686,8 +7688,56 @@ } } } + else if ($qtype == 'F' || $qtype == ':' || $qtype == ';' || $qtype == '1' || $qtype == 'C' || $qtype == 'B' || $qtype == 'A' || $qtype == 'E') + { + // array question types - if filtered only displayed answer are required + $bAnsw = true; + + $qid=$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['qid']; + + $gquery = "SELECT * FROM ".db_table_name('question_attributes')." WHERE qid={$qid} AND attribute ='array_filter'"; + $qresult = db_execute_assoc($gquery); //checked + $qrows = $qresult->GetRows(); + + $filter=$qrows[0]['value']; + + //if there is no filter checkall answers + if (trim($filter) == '') + goto checkall; + + + foreach($_SESSION['fieldarray'] as $field) + { + //look for the multiple choice filter + if ($field[2] == $filter && $field[4] == 'M') + { + //filter SQG + $array_filter = $field[1]; + break; + } + } + + //if filter not found checkall answers + if ($array_filter == '') + goto checkall; + + foreach($aFieldnamesInfoInv[$q] as $sField) + { + //keep only first SQ for multiple scale answer + $aid = explode('_',$_SESSION['fieldmap'][$sField]['aid']); + $aid = explode('#',$aid[0]); + + if ($_SESSION[$array_filter.$aid[0]]=='Y' && $_SESSION[$sField]=='') + { + $bAnsw = false; + break; + } + } + + } else { + checkall: // all answers required for all other question types $bAnsw = true; foreach($aFieldnamesInfoInv[$q] as $sField) @@ -7698,7 +7748,9 @@ break; } } + } + return $bAnsw; } floccs_01.patch (5,314 bytes)
Index: common_functions.php =================================================================== --- common_functions.php (revisione 11199) +++ common_functions.php (copia locale) @@ -7668,90 +7668,71 @@ */ function bCheckQuestionForAnswer($q, $aFieldnamesInfoInv) { - $qtype = $_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['type']; + $qtype = @$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['type']; - if ($qtype == 'X') - { - // boilerplate have no answers - return true; - } - else if ($qtype == 'M' || $qtype == 'P' || $qtype == 'O') - { - // multiple choice and list with comments question types - just one answer is required and comments are not required - $bAnsw = false; - foreach($aFieldnamesInfoInv[$q] as $sField) - { - if(!strstr($sField, 'comment') && isset($_SESSION[$sField]) && trim($_SESSION[$sField])!='') - { - $bAnsw = true; - break; - } - } - } - else if ($qtype == 'F' || $qtype == ':' || $qtype == ';' || $qtype == '1' || $qtype == 'C' || $qtype == 'B' || $qtype == 'A' || $qtype == 'E') - { - // array question types - if filtered only displayed answer are required - $bAnsw = true; + switch ($qtype) { + case 'X': + return true; + case 'M': + case 'P': + case 'O': + // multiple choice and list with comments question types - just one answer is required and comments are not required + foreach($aFieldnamesInfoInv[$q] as $sField) + if(!strstr($sField, 'comment') && isset($_SESSION[$sField]) && trim($_SESSION[$sField])!='') + return true; + return false; + case 'F': + case ':': + case ';': + case '1': + case 'C': + case 'B': + case 'A': + case 'E': + // array question types - if filtered only displayed answer are required + $qattr = getQuestionAttributes(@$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['qid'], $qtype); - $qid=$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['qid']; + $qcodefilter = @$qattr['array_filter']; - $gquery = "SELECT * FROM ".db_table_name('question_attributes')." WHERE qid={$qid} AND attribute ='array_filter'"; - $qresult = db_execute_assoc($gquery); //checked - $qrows = $qresult->GetRows(); + $sgqfilter = ''; - $filter=$qrows[0]['value']; + foreach($_SESSION['fieldarray'] as $field) + //look for the multiple choice filter + if ($field[2] == $qcodefilter && $field[4] == 'M') + { + //filter SQG + $sgqfilter = $field[1]; + break; + } - //if there is no filter checkall answers - if (trim($filter) == '') - goto checkall; - - - foreach($_SESSION['fieldarray'] as $field) - { - //look for the multiple choice filter - if ($field[2] == $filter && $field[4] == 'M') + //if filter not found checkall answers + if ($sgqfilter == '') { - //filter SQG - $array_filter = $field[1]; - break; + // all answers required + foreach($aFieldnamesInfoInv[$q] as $sField) + if(!isset($_SESSION[$sField]) || trim($_SESSION[$sField])=='') + return false; + return true; } - } - - //if filter not found checkall answers - if ($array_filter == '') - goto checkall; - foreach($aFieldnamesInfoInv[$q] as $sField) - { - //keep only first SQ for multiple scale answer - $aid = explode('_',$_SESSION['fieldmap'][$sField]['aid']); - $aid = explode('#',$aid[0]); - - if ($_SESSION[$array_filter.$aid[0]]=='Y' && $_SESSION[$sField]=='') - { - $bAnsw = false; - break; - } - } - - } - else - { - checkall: - // all answers required for all other question types - $bAnsw = true; - foreach($aFieldnamesInfoInv[$q] as $sField) - { - if(!isset($_SESSION[$sField]) || trim($_SESSION[$sField])=='') + foreach($aFieldnamesInfoInv[$q] as $sField) { - $bAnsw = false; - break; + //keep only first subquestion code for multiple scale answer + $aid = explode('_',$_SESSION['fieldmap'][$sField]['aid']); + $aid = explode('#',$aid[0]); + //if a checked answer in the multiple choice is not present + if ($_SESSION[$sgqfilter.$aid[0]] == 'Y' && $_SESSION[$sField] == '') + return false; } - } - + return true; + default: + // all answers required for all other question types + foreach($aFieldnamesInfoInv[$q] as $sField) + if(!isset($_SESSION[$sField]) || trim($_SESSION[$sField])=='') + return false; + return true; } - return $bAnsw; } /** | ||||
Bug heat | 8 | ||||
Complete LimeSurvey version number (& build) | 10377 | ||||
I will donate to the project if issue is resolved | Yes | ||||
Browser | Chrome, Firefox | ||||
Database type & version | Mysql 5.1.52 | ||||
Server OS (if known) | Linux | ||||
Webserver software & version (if known) | LiteSpeed V5.5 | ||||
PHP Version | 5.2 | ||||
I've made a patch for this issue, can you review it? This should fix the problem. |
|
Thanks for providing a patch. Can you also attach a sample survey for testing? |
|
sample survey attached |
|
For me in the link example , it work like a charm: checked 1 and 2, selext column 1 to each line, I see no problem :) |
|
i'm sorry but the link provided in the description is now working with the patch i've written. try loading the survey attached on a non patched version of limesurvey to reproduce the bug. |
|
Patch looks okay - thank you! |
|
I've attached a patch with more readable code. Don't know if I have to reopen the issue to have it applied |
|
Thank you! Yes, that looks much better since i just found out that goto mark is only supported in 5.3 and up. |
|
New version released |
|
LimeSurvey: Yii d987a83b 2011-10-18 09:58:44 Details Diff |
Fixed issue 05323: .missing class added in answered filtered array question "Show question index / allow jumping" modality - patch by flocs git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@11199 b72ed6b6-b9f8-46b5-92b4-906544132732 |
Affected Issues 05323 |
|
mod - application/helpers/common_helper.php | Diff File | ||
LimeSurvey: Yii 4ec26f3b 2011-10-19 07:00:30 Details Diff |
Fixed issue 05323: .missing class added in answered filtered array question "Show question index / allow jumping" modality - patch by flocs Fixed issue 05508: $printanswershonorsconditions settings doesn't work - all questions are shown in Print Answers page - Dev printanswershonorsconditions config variable is now completely removed and Print answers always honors conditions git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@11207 b72ed6b6-b9f8-46b5-92b4-906544132732 |
Affected Issues 05323, 05508 |
|
mod - application/config/lsconfig.php | Diff File | ||
mod - application/controllers/printanswers.php | Diff File | ||
mod - application/helpers/common_helper.php | Diff File |
Date Modified | Username | Field | Change |
---|---|---|---|
2011-07-06 20:25 |
|
New Issue | |
2011-07-07 12:11 |
|
Issue Monitored: user14785 | |
2011-07-07 12:11 |
|
Issue End Monitor: user14785 | |
2011-07-08 17:02 | c_schmitz | Assigned To | => user9586 |
2011-07-08 17:02 | c_schmitz | Status | new => assigned |
2011-09-05 14:56 | c_schmitz | Assigned To | user9586 => c_schmitz |
2011-10-11 20:12 |
|
File Added: floccs.patch | |
2011-10-11 20:12 |
|
Note Added: 16391 | |
2011-10-12 14:03 | Mazi | Note Added: 16400 | |
2011-10-12 14:14 |
|
File Added: limesurvey_survey_19883.lss | |
2011-10-12 14:14 |
|
Note Added: 16402 | |
2011-10-14 14:42 | DenisChenu | Note Added: 16420 | |
2011-10-14 15:17 |
|
Note Added: 16422 | |
2011-10-18 18:56 | c_schmitz | Note Added: 16455 | |
2011-10-18 18:56 | c_schmitz | Status | assigned => resolved |
2011-10-18 18:56 | c_schmitz | Fixed in Version | => 1.91+ |
2011-10-18 18:56 | c_schmitz | Resolution | open => fixed |
2011-10-18 20:15 |
|
File Added: floccs_01.patch | |
2011-10-18 20:15 |
|
Note Added: 16458 | |
2011-10-19 15:26 | c_schmitz | Note Added: 16472 | |
2011-10-26 18:28 | c_schmitz | Note Added: 16532 | |
2011-10-26 18:28 | c_schmitz | Status | resolved => closed |
2012-03-14 21:08 | c_schmitz | Changeset attached | => Import 2012-03-09 13:30:34 Yii 4ec26f3b |
2012-03-14 21:08 | c_schmitz | Changeset attached | => Import 2012-03-09 13:30:34 Yii d987a83b |