View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
03799 | Bug reports | Survey taking | public | 2009-10-28 14:35 | 2010-10-19 21:12 |
Reporter | ronvdburg | Assigned To | c_schmitz | ||
Priority | normal | Severity | minor | ||
Status | closed | Resolution | fixed | ||
Product Version | 1.85+ | ||||
Fixed in Version | 1.90+ | ||||
Summary | 03799: Assure that the submit button appears if the last group has no questions | ||||
Description | Suppose: In other words: the last group of the survey should be skipped. Then the "submit" button does not show anywhere, leaving the user questioning if the survey was submitted or not. | ||||
Additional Information | I included a "diff -u" to solve this issue. The solution I chose is to change the function checkgroupfordisplay in index.php with a leading statement:if (this is the last group) then return true;The reasons for this solution: b) A survey admin could create a boilerplate question in the last group with a condition that holds true if all the other questions in the last group evaluate to false. c) You may also change code after the false return of the function:If "checkgroupfordisplay" returns false AND it is the last group then show an empty page with the "prev" + "save" + "submit" button.This appeared to me to be much more work to code. d) The solution I posted is also capable of handling an explicit "submit" button if the last n (> 1) groups all evaluate to 0 questions. | ||||
Tags | No tags attached. | ||||
Attached Files | ShowSubmitOnLastEmptyGroup.txt (739 bytes)
--- index-185plus-build7593-20090907.php 2009-08-24 00:37:55.000000000 +0200 +++ index.php 2009-10-28 13:46:12.000000000 +0100 @@ -936,6 +936,10 @@ //the function will return false, to indicate that the whole group //should not display at all. global $dbprefix, $connect; + if (isset($_SESSION['step']) && ($_SESSION['step'] == $_SESSION['totalsteps'])) + { + return true; // If this is the last group then show it, even if there are no questions. Otherwise you won't get a <Submit> button. + } $countQuestionsInThisGroup=0; $countConditionalQuestionsInThisGroup=0; foreach ($_SESSION['fieldarray'] as $ia) //Run through all the questions feature03799-v1.diff (4,435 bytes)
Index: group.php =================================================================== --- group.php (revision 7789) +++ group.php (working copy) @@ -59,6 +59,9 @@ } //SEE IF THIS GROUP SHOULD DISPLAY +global $show_empty_group_if_the_last_group_is_hidden; +my $show_empty_group = false; + if (isset($move) && $_SESSION['step'] != 0 && $move != "movesubmit") { while(checkgroupfordisplay($_SESSION['grouplist'][$_SESSION['step']-1][0]) === false) @@ -73,9 +76,19 @@ } if ($_SESSION['step']>$_SESSION['totalsteps']) { - $move = "movesubmit"; - submitanswer(); // complete this answer (submitdate) - break; + // We are skipping groups, but we moved 'off' the last group. + // Now choose to implement an implicit submit (old behaviour), + // or create an empty page giving the user the explicit option to submit. + if (isset($show_empty_group_if_the_last_group_is_hidden) && $show_empty_group_if_the_last_group_is_hidden == true) + { + $show_empty_group = true; + break; + } else + { + $move = "movesubmit"; + submitanswer(); // complete this answer (submitdate) + break; + } } } } @@ -297,10 +310,17 @@ //****************************************************************************************************** //GET GROUP DETAILS -$grouparrayno=$_SESSION['step']-1; -$gid=$_SESSION['grouplist'][$grouparrayno][0]; -$groupname=$_SESSION['grouplist'][$grouparrayno][1]; -$groupdescription=$_SESSION['grouplist'][$grouparrayno][2]; +if ($show_empty_group) { + $gid=-1; // Make sure the gid is unused. This will assure that the foreach (fieldarray as ia) has no effect. + $groupname=$clang->gT("Finalising your survey"); + $groupdescription=$clang->gT("There are no more questions. If you are satisfied, press the <submit> button"); +} else +{ + $grouparrayno=$_SESSION['step']-1; + $gid=$_SESSION['grouplist'][$grouparrayno][0]; + $groupname=$_SESSION['grouplist'][$grouparrayno][1]; + $groupdescription=$_SESSION['grouplist'][$grouparrayno][2]; +} require_once("qanda.php"); //This should be qanda.php when finished @@ -376,7 +396,12 @@ } //end iteration -$percentcomplete = makegraph($_SESSION['step'], $_SESSION['totalsteps']); +if ($show_empty_group) { + $percentcomplete = makegraph($_SESSION['totalsteps'], $_SESSION['totalsteps']); +} else +{ + $percentcomplete = makegraph($_SESSION['step'], $_SESSION['totalsteps']); +} $languagechanger = makelanguagechanger(); //READ TEMPLATES, INSERT DATA AND PRESENT PAGE @@ -409,7 +434,12 @@ <!--\n"; // Find out if there are any array_filter questions in this group -$array_filterqs = getArrayFiltersForGroup($surveyid,$gid); +if ($show_empty_group) { + unset($array_filterqs); +} else +{ + $array_filterqs = getArrayFiltersForGroup($surveyid,$gid); +} print <<<END function noop_checkconditions(value, name, type) Index: config-defaults.php =================================================================== --- config-defaults.php (revision 7789) +++ config-defaults.php (working copy) @@ -345,6 +345,31 @@ */ $hide_groupdescr_allinone=true; +/** + * Before 1.87, the user may not see a <submit> button. + * The variable show_empty_group_if_the_last_group_is_hidden can change this behaviour. + * The default is true; to get the old behaviour, change the variable to false. + * + * DETAILS OF THE OLD BEHAVIOUR (set variable to false) + * Suppose: + * = The survey is in group mode. + * = The last group has only conditional questions. + * = None of the last group's conditions are satisfied. + * + * In other words: the last group of the survey should be skipped. + * + * Then the <submit> button does not show anywhere, leaving the user questioning + * if the survey was submitted or not. + * The effect is that the <next> button on the previous group's screen is actually + * not only a <next>, but also a <submit> without the user seeing it. + * + * DETAILS OF THE NEW BEHAVIOUR (set variable to true) + * If the user of a group survey presses <next> and the last group has no questions + * (due to unsatisfied conditions), present an "empty" group, with a <submit> button. + * The group title is something descriptive, the <prev> and other buttons are also + * available (if appropriate). + */ +$show_empty_group_if_the_last_group_is_hidden=true; /** * Use FireBug Lite for JavaScript and template development and testing. index.php.diff (820 bytes)
Index: index.php =================================================================== --- index.php (revision 9091) +++ index.php (working copy) @@ -2571,7 +2571,7 @@ $surveymover .= "\t<input class='submit' type='submit' onclick=\"javascript:document.limesurvey.move.value = 'movenext';\" value=' " . $clang->gT("Next")." >> ' name='move2' />\n"; } - if ($_SESSION['step'] && ($_SESSION['step'] == $_SESSION['totalsteps']) && !$presentinggroupdescription) + if ($_SESSION['step'] && ($_SESSION['step'] >= $_SESSION['totalsteps']) && !$presentinggroupdescription) { $surveymover .= "\t<input class='submit' type='submit' accesskey='l' onclick=\"javascript:document.limesurvey.move.value = 'movesubmit';\" value=' " . $clang->gT("Submit")." ' name='move2' />\n"; | ||||
Bug heat | 10 | ||||
Complete LimeSurvey version number (& build) | 7593 | ||||
I will donate to the project if issue is resolved | |||||
Browser | |||||
Database type & version | Mysql | ||||
Server OS (if known) | Linux | ||||
Webserver software & version (if known) | Apache | ||||
PHP Version | 5.1.6 | ||||
@ Lemeur: can you please have a look at this patch? |
|
I'm not sure this is the correct fix for 2 reasons: 2- the last 'empty' group page will be shown with the true title of last group (which is not relevant and even should be hidden to the participant). So to sum up: I think the best solution would be to:
What do you think ? @ronvdburg, do you think you could submit such a patch ? Thanks in advance, |
|
Hi Thibault, You are right. With my patch, I wanted to cut some corners: I thought I could do with only 4 lines of extra code... ;-) 1- Good idea. I will see whether I can submit a patch. This may take a little while, because:
Regards, |
|
Hi Ron, I know this fix won't be difficult for you (knowing what you've already done in the past ;-) ). Why move from SVN to Git ?? Yes, a fix applied to latest SVN would be better. Fix in config.php is nothing more that to declare a new "$myoption = true;" line and to add a litle comment ;-) Fix in group.php might be nothing more that your 4 lines + something to overwrite the text displayed as Group Title... I'm just saying this, but I haven't openned group.php to check ;-) |
|
Hi Thibault, I implemented the feature as you suggested. The SVN to GIT: sorry my fault, I was thinking about another great project RT (request tracker), who moved to using GIT. I uploaded the "svn di" file (w.r.t. rev 7789). Please note that I haven't tested it, I have just been typing code in one go. I am currently running a very important rev 7593 survey that I do not want to disturb. Furthermore, I used two texts (groupname + groupdescription) using the clang->gT construct. However, I did not add both texts to all the language files because I want to be sure that the default version of the texts are confirmed. |
|
Fixed in 7847. Thibault |
|
I have had the time to check the official patch (in 7847) for solving this issue. In my opinion, there needs to be a change from '==' to '>=', because 'step' is now 1 larger than 'totalsteps'. I cannot attach the svn diff file, so here it is. Index: index.php--- index.php (revision 9091)
|
|
Thank you! Fixed in rev 9232 |
|
Released in 1.90 plus release. |
|
Date Modified | Username | Field | Change |
---|---|---|---|
2009-10-28 14:35 | ronvdburg | New Issue | |
2009-10-28 14:35 | ronvdburg | Status | new => assigned |
2009-10-28 14:35 | ronvdburg | Assigned To | => user372 |
2009-10-28 14:35 | ronvdburg | File Added: ShowSubmitOnLastEmptyGroup.txt | |
2009-10-28 14:35 | ronvdburg | LimeSurvey build number | => 7593 |
2009-10-28 14:35 | ronvdburg | Database & DB-Version | => Mysql |
2009-10-28 14:35 | ronvdburg | Operating System (Server) | => Linux |
2009-10-28 14:35 | ronvdburg | Webserver | => Apache |
2009-10-28 14:35 | ronvdburg | PHP Version | => 5.1.6 |
2009-10-28 16:26 |
|
Note Added: 09893 | |
2009-10-28 16:26 |
|
Assigned To | user372 => lemeur |
2009-10-28 17:25 | lemeur | Note Added: 09898 | |
2009-10-28 17:25 | lemeur | Status | assigned => feedback |
2009-10-28 17:25 | lemeur | Note Edited: 09898 | |
2009-10-28 17:27 | lemeur | Note Edited: 09898 | |
2009-10-28 18:01 | ronvdburg | Note Added: 09901 | |
2009-10-28 18:07 | lemeur | Note Added: 09902 | |
2009-10-29 15:10 | ronvdburg | File Added: feature03799-v1.diff | |
2009-10-29 15:18 | ronvdburg | Note Added: 09916 | |
2009-11-07 14:12 | lemeur | Status | feedback => acknowledged |
2009-11-07 14:33 | lemeur | Note Added: 09991 | |
2009-11-07 14:33 | lemeur | Status | acknowledged => resolved |
2009-11-07 14:33 | lemeur | Fixed in Version | => 1.87RC1 |
2009-11-07 14:33 | lemeur | Resolution | open => fixed |
2009-11-13 16:40 | c_schmitz | Status | resolved => closed |
2010-08-26 14:52 | ronvdburg | Issue Monitored: ronvdburg | |
2010-08-26 14:59 | ronvdburg | Note Added: 12714 | |
2010-08-26 14:59 | ronvdburg | Status | closed => feedback |
2010-08-26 14:59 | ronvdburg | Resolution | fixed => reopened |
2010-08-26 15:00 | ronvdburg | File Added: index.php.diff | |
2010-09-09 13:21 | Mazi | Status | feedback => assigned |
2010-10-13 20:43 | c_schmitz | Assigned To | lemeur => c_schmitz |
2010-10-13 20:45 | c_schmitz | Note Added: 13150 | |
2010-10-13 20:45 | c_schmitz | Status | assigned => resolved |
2010-10-13 20:45 | c_schmitz | Fixed in Version | 1.87RC1 => 1.90+ |
2010-10-13 20:45 | c_schmitz | Resolution | reopened => fixed |
2010-10-19 21:12 | c_schmitz | Note Added: 13281 | |
2010-10-19 21:12 | c_schmitz | Status | resolved => closed |
2010-10-25 00:18 | c_schmitz | Category | Survey at Runtime => Survey taking |
2021-08-03 18:57 | guest | Bug heat | 8 => 10 |