Dealing with Poll results

Author Message

Kedar Deshpande

Thursday 29 October 2009 3:28:10 pm

Hi,

Has anyone here handled a situation where they built an interface to store and retrieve poll results? Our current setup allows people to create normal objects but when they are called the view template converts it to xml which is then processed using smarty templates and html/css.

For the Poll, if we were to send the poll object in xml, could anyone recommend how we could send back the selection and also keep track of the results?

thanks.

Gaetano Giunta

Friday 30 October 2009 1:56:23 am

ezsurvey is good enough for polls - it might just need a custom fetch to make it easy to retrieve the results: fetchSurveyResultBySessionID

    static public function fetchSurveyResultBySessionID( $surveyID )
    {
        $http = eZHTTPTool::instance();
        $sessionID = $http->sessionID();
        $surveyResultObject = false;
        if($surveyID)
        {
            $surveyResultObject = eZPersistentObject::fetchObject( eZSurveyResult::definition(),
                                                               null,
                                                               array( 'user_session_id' => $sessionID,
                                                                      'survey_id' => (int)$surveyID ) );
        }
        if ( $surveyResultObject === null || $surveyResultObject === false )
        {
            $retVal = array( 'error' => array( 'error_type' => 'kernel',
                                               'error_code' => eZError::KERNEL_NOT_FOUND ) );
        }
        else
        {
            $retVal = array( 'result' => $surveyResultObject );
        }
        return $retVal;
    } 

or you can use ezvotecollector

Principal Consultant International Business
Member of the Community Project Board

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