Poll - how to disable empty user input

Author Message

Marko Žmak

Saturday 22 July 2006 10:17:18 am

The title says it all. I want to disable collecting informaation in poll when the user didn't input anything (e.g. no radio button was selected). The current behaviour of eZ in this case i to increase the number of votes, but not to include this vote in any answer. So the summ of all votes for each answer now doesn't match the total votes count.

Is it possible to disable this?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Andrew Kelly

Tuesday 08 August 2006 3:30:32 am

[Me too post]

I'd also very much like this answer as well.
Not only is the total vote count skewed, but the "voted" cookie is also set, so
if somebody mistakenly hits the vote button without making a selection and then
tries to correct their mistake, they are told they already voted.

For what it's worth, I think a page recycle would be the best solution rather than an error message of some kind. (but let's see if we even get that far first).

Andy

Andrew Kelly

Thursday 10 August 2006 7:24:10 am

Hi Marko,

here's how I dealt with the issue:

1. Edit (or create) settings/override/collect.ini.append.php

In section
[CollectionSettings]
add
CollectionUserDataList[poll]=overwrite (was probably unique)

Then,

2. Edit the active ezoption.tpl file, removing the "checked" sections

Then,

3. Add JavaScript to the poll form so that a blank vote doesn't get sent.
For example,

<b>in poll form</b>
onSubmit="return validatePoll(document.pollForm.ContentObjectAttribute_data_option_value_{$poll.0.data_map.question.id})"

<b>in page head</b>
{literal}
<script type="text/javascript">
<!--
function validatePoll(rObj){
    for (var i=0; i<rObj.length; i++) if (rObj[i].checked) return true;
    alert("Please make a selection before voting.");
    return false;
}
//-->
</script>
{/literal}

It's dependant on JS, which makes it a cheap hack, but it gets the job done.

Andy

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 04:14:45
Script start
Timing: Jan 31 2025 04:14:45
Module start 'layout'
Timing: Jan 31 2025 04:14:45
Module start 'content'
Timing: Jan 31 2025 04:14:46
Module end 'content'
Timing: Jan 31 2025 04:14:46
Script end

Main resources:

Total runtime0.7802 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 588.2500151.2266
Module start 'layout' 0.00510.0021 739.476636.6797
Module start 'content' 0.00720.7724 776.1563945.3984
Module end 'content' 0.77950.0007 1,721.554711.8281
Script end 0.7802  1,733.3828 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00270.3425160.0002
Check MTime0.00120.1486160.0001
Mysql Total
Database connection0.00090.121010.0009
Mysqli_queries0.724692.8711570.0127
Looping result0.00050.0604550.0000
Template Total0.752996.520.3765
Template load0.00190.245520.0010
Template processing0.751096.251420.3755
Template load and register function0.00120.155210.0012
states
state_id_array0.00120.160010.0012
state_identifier_array0.00110.136720.0005
Override
Cache load0.00170.2171320.0001
Sytem overhead
Fetch class attribute can translate value0.00040.047620.0002
Fetch class attribute name0.00170.213750.0003
XML
Image XML parsing0.00560.716320.0028
class_abstraction
Instantiating content class attribute0.00000.001260.0000
General
dbfile0.00690.8835240.0003
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs