diff options
author | matthew <matthew> | 2008-03-06 12:07:35 +0000 |
---|---|---|
committer | matthew <matthew> | 2008-03-06 12:07:35 +0000 |
commit | 15a2de92e7f8e3ae633c7a6599ef970b7fd9e3d6 (patch) | |
tree | 2801ba6b83df24abb6c2b11e5bb5cc52b5485e75 | |
parent | 2bb1106bf3124df175669f3daea6d4e1611d6ba1 (diff) |
Add don't know option to questionnaire.
-rw-r--r-- | templates/emails/questionnaire | 3 | ||||
-rwxr-xr-x | web/confirm.cgi | 12 | ||||
-rw-r--r-- | web/js.js | 5 | ||||
-rwxr-xr-x | web/questionnaire.cgi | 31 |
4 files changed, 35 insertions, 16 deletions
diff --git a/templates/emails/questionnaire b/templates/emails/questionnaire index 0794558b2..eae609fb8 100644 --- a/templates/emails/questionnaire +++ b/templates/emails/questionnaire @@ -5,8 +5,7 @@ Hi <?=$values['name']?>, <?=$values['created']?> ago, you left a problem on FixMyStreet with the details provided at the end of this email. To keep our site up to date and relevant, we'd appreciate it if you could fill in -this short questionnaire updating the status of your problem if -you have any new information: +this short questionnaire updating the status of your problem: <?=$values['url']?> diff --git a/web/confirm.cgi b/web/confirm.cgi index 7ee8816cd..e94ce811d 100755 --- a/web/confirm.cgi +++ b/web/confirm.cgi @@ -6,7 +6,7 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: confirm.cgi,v 1.34 2008-01-31 12:26:11 matthew Exp $ +# $Id: confirm.cgi,v 1.35 2008-03-06 12:07:35 matthew Exp $ use strict; use Standard; @@ -29,7 +29,7 @@ sub main { $out = confirm_update($q, $id); } elsif ($type eq 'problem') { $out = confirm_problem($q, $id); - $extra = 'added-problem'; + $extra = 'added-problem'; } elsif ($type eq 'questionnaire') { $out = add_questionnaire($q, $id, $token); } @@ -50,7 +50,12 @@ Page::do_fastcgi(\&main); sub confirm_update { my ($q, $id) = @_; - dbh()->do("update comment set state='confirmed' where id=? and state='unconfirmed'", {}, $id); + if (dbh()->selectrow_array('select email from abuse where lower(email)=?', {}, lc($email))) { + dbh()->do("update comment set state='hidden' where id=?", {}, $id); + return $q->p('Sorry, there has been an error confirming your update.'); + } else { + dbh()->do("update comment set state='confirmed' where id=? and state='unconfirmed'", {}, $id); + } my ($problem_id, $fixed, $email, $name) = dbh()->selectrow_array( "select problem_id, mark_fixed, email, name from comment where id=?", {}, $id); my $creator_fixed = 0; @@ -87,6 +92,7 @@ sub confirm_problem { if (dbh()->selectrow_array('select email from abuse where lower(email)=?', {}, lc($email))) { dbh()->do("update problem set state='hidden', lastupdate=ms_current_timestamp() where id=?", {}, $id); + return $q->p('Sorry, there has been an error confirming your problem.'); } else { dbh()->do("update problem set state='confirmed', confirmed=ms_current_timestamp(), lastupdate=ms_current_timestamp() where id=? and state='unconfirmed'", {}, $id); @@ -61,12 +61,15 @@ YAHOO.util.Event.onContentReady('mapForm', function() { }); YAHOO.util.Event.onContentReady('another_qn', function() { - if (!document.getElementById('been_fixed_no').checked) { + if (!document.getElementById('been_fixed_no').checked && !document.getElementById('been_fixed_unknown').checked) { YAHOO.util.Dom.setStyle(this, 'display', 'none'); } YAHOO.util.Event.addListener('been_fixed_no', 'click', function(e) { YAHOO.util.Dom.setStyle('another_qn', 'display', 'block'); }); + YAHOO.util.Event.addListener('been_fixed_unknown', 'click', function(e) { + YAHOO.util.Dom.setStyle('another_qn', 'display', 'block'); + }); YAHOO.util.Event.addListener('been_fixed_yes', 'click', function(e) { YAHOO.util.Dom.setStyle('another_qn', 'display', 'none'); }); diff --git a/web/questionnaire.cgi b/web/questionnaire.cgi index 8bea143de..7dd7d3882 100755 --- a/web/questionnaire.cgi +++ b/web/questionnaire.cgi @@ -6,7 +6,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: questionnaire.cgi,v 1.20 2008-03-06 11:52:33 matthew Exp $ +# $Id: questionnaire.cgi,v 1.21 2008-03-06 12:07:35 matthew Exp $ use strict; use Standard; @@ -72,7 +72,7 @@ sub submit_questionnaire { push @errors, 'Please state whether or not the problem has been fixed' unless $input{been_fixed}; push @errors, 'Please say whether you\'ve ever reported a problem to your council before' unless $input{reported} || $prev_questionnaire; push @errors, 'Please indicate whether you\'d like to receive another questionnaire' - if $input{been_fixed} eq 'No' && !$input{another}; + if ($input{been_fixed} eq 'No' || $input{been_fixed} eq 'Unknown') && !$input{another}; push @errors, 'Please provide some explanation as to why you\'re reopening this report' if $input{been_fixed} eq 'No' && $problem->{state} eq 'fixed' && !$input{update}; return display_questionnaire($q, @errors) if @errors; @@ -97,7 +97,9 @@ sub submit_questionnaire { : undef; dbh()->do('update questionnaire set whenanswered=ms_current_timestamp(), ever_reported=?, old_state=?, new_state=? where id=?', {}, - $reported, $problem->{state}, $new_state ? $new_state : $problem->{state}, + $reported, $problem->{state}, $input{been_fixed} eq 'Unknown' + ? 'unknown' + : ($new_state ? $new_state : $problem->{state}), $questionnaire->{id}); # Record an update if they've given one, or if there's a state change @@ -113,9 +115,16 @@ sub submit_questionnaire { # If they've said they want another questionnaire, mark as such dbh()->do("update problem set send_questionnaire = 't' where id=?", {}, $problem->{id}) - if $input{been_fixed} eq 'No' && $input{another} eq 'Yes'; + if ($input{been_fixed} eq 'No' || $input{been_fixed} eq 'Unknown') && $input{another} eq 'Yes'; dbh()->commit(); + my $out; + if ($input{been_fixed} eq 'Unknown') { + $out = <<EOF; +<p style="font-size:200%">Thank you very much for filling in our questionnaire; if you +get some more information about the status of your problem, please come back to the +site and leave an update.</p> +EOF if ($new_state eq 'confirmed' || (!$new_state && $problem->{state} eq 'confirmed')) { return <<EOF; <p style="font-size:200%">We're sorry to hear that. We have two suggestions: why not try @@ -125,12 +134,13 @@ why not <a href="http://www.pledgebank.com/new">make and publicise a pledge</a>? </p> EOF } else { - my $out = <<EOF; -<p>Thank you very much for filling in our questionnaire; glad to hear it's been fixed.</p> + $out = <<EOF; +<p style="font-size:200%">Thank you very much for filling in our questionnaire; glad to hear it's been fixed.</p> EOF - $out .= CrossSell::display_advert($q, $problem->{email}, $problem->{name}, - council => $problem->{council}); } + $out .= CrossSell::display_advert($q, $problem->{email}, $problem->{name}, + council => $problem->{council}); + return $out; } sub display_questionnaire { @@ -164,6 +174,7 @@ sub display_questionnaire { my %been_fixed = ( yes => $input{been_fixed} eq 'Yes' ? ' checked' : '', no => $input{been_fixed} eq 'No' ? ' checked' : '', + unknown => $input{been_fixed} eq 'Unknown' ? ' checked' : '', ); my %reported = ( yes => $input{reported} eq 'Yes' ? ' checked' : '', @@ -194,9 +205,9 @@ EOF <label for="been_fixed_yes">Yes</label> <input type="radio" name="been_fixed" id="been_fixed_no" value="No"$been_fixed{no}> <label for="been_fixed_no">No</label> +<input type="radio" name="been_fixed" id="been_fixed_unknown" value="Unknown"$been_fixed{unknown}> +<label for="been_fixed_unknown">Don’t know</label> </p> -<p><strong>Note:</strong> If you do not know the status of your problem, please just -ignore this questionnaire.</p> EOF $out .= <<EOF unless $prev_questionnaire; <p>Have you ever reported a problem to a council before?</p> |