• Love the plugin – it so nearly works perfect
    Have latest version Version: 2.5.2 on WordPress 3.2.1.

    2 errors i receive using the survey
    After a completion of quiz the instant email is sent to my inbox
    I click the link ….comwp-admin/admin.php?page=wpsqt-menu&section=results&subsection=mark&id=3

    But it shows an error Warning: Division by zero in /home/human/public_html/wp-content/plugins/wp-survey-and-quiz-tool/pages/admin/results/mark.php on line 121

    and accross the top i get
    No such Wpsqt_Page_Main_Edit_Mark class
    No such Wpsqt_Page_Main_Sections_Mark class
    etc

    any ideas Ollie?

Viewing 7 replies - 61 through 67 (of 67 total)
  • After further examination I have discovered that I am missing some variables from SESSION that is submited trough AJAX. And those are probably the ones I need to setup before I can proceed.

    Dont you know where these are getting inserted into the SESSION?

    [answers] => Array
                            (
                                [2] => Array
                                    (
                                        [mark] => incorrect
                                        [given] => Array
                                            (
                                                [0] => 0
                                            )
                                    )
                            )
                        [stats] => Array
                            (
                                [correct] => 0
                                [incorrect] => 1
                            )
                        [can_automark] => 1

    Thanx

    Never mind now, got it working. I am not sure if this is the right way so here is the code I have added:

    Into Core.php I have added this at the end of the __construct function

    add_action('wp_ajax_ajax_poll', array($this, '_ajax_result') );	//line: 46
    	add_action('wp_ajax_nopriv_ajax_poll', array($this, '_ajax_result') );	//line: 47

    And right after the end of __construct function in Core.php I have created a new functions called _ajax_result()

    public function _ajax_result(){
    	require_once WPSQT_DIR.'lib/Wpsqt/Shortcode.php';
    	$identifer = $_POST['identifier']; $type = $_POST['type'];
    	$objShortcode = new Wpsqt_Shortcode($identifer, $type);
    	die( $objShortcode->display() );
    	return false;
    }

    The funny part is that when I called finishQuiz() the result has not been counted the right way. Now with display() function it works.

    Also have added into pages/site/poll/section.php I have added these lines after line 10

    <input type="hidden" name="type" value="<?php echo ( $_SESSION['wpsqt']['current_type'] ); ?>">
    <input type="hidden" name="identifier" value="<?php echo ( $quizName ); ?>">
    <input type="hidden" name="name" value="<?php echo ( $quizName ); ?>">

    And finally the ajax call in the single template looks like this:

    <script type="text/javascript">
    /* <![CDATA[ */
    	jQuery(document).ready(function($){
    
    		$('.button-secondary').click(function() {
    			;
    			jQuery.post(
    				'<?php bloginfo('wpurl'); ?>/wp-admin/admin-ajax.php',
    		   		$('.poll form').serialize() + '&action=ajax_poll',
    				function(response){
    
    					$('.wpst_question').html(response);
    				}
    			);
    			return false;
    		});
    
    	});
    /* ]]> */
    </script>

    This is probably not a complex solution but I hope it will help you to get started and youll try to implement ajax call at least for polls. Let me know if it worked for you.

    Stefan

    Hi Ollie,

    I have one more question. Can this be applied also to polls? https://catn.com/wordpress/plugins/wpsqt-creating-custom-pages/

    Does the 0 in the directory structure mean something? And also the number after the number after the quiz = “quiz-1” .. does it mean that it will be applied to quiz with ID 1??

    Thanx.
    Stefan

    Me again. I think I keep answering to my questions ??

    So after small research I found out that the first number is the blog_id .. in my case its numero 1. And also it works also for polls ( great news ) and also that the number is the poll ID. But that is not really usable when I want a generic new layout for all of my polls that wont change after update. So I have changed the pageView function in Core.php to this:

    public static function pageView($file){
    
    	global $blog_id;
    
    	$quizPath = ( isset($_SESSION['wpsqt']['item_id'])
    		&& ctype_digit($_SESSION['wpsqt']['item_id']) ) ?
    		$blog_id.'/'.$_SESSION['wpsqt']['current_type'].'-'.$_SESSION['wpsqt']['item_id'].'/' : '';
    
    	$quizPathGeneral = 	$quizPath = ( isset($_SESSION['wpsqt']['item_id'])
    		&& ctype_digit($_SESSION['wpsqt']['item_id']) ) ?
    		$blog_id.'/'.$_SESSION['wpsqt']['current_type'].'/' : '';
    
    	if ( file_exists(WPSQT_DIR.'pages/custom/'.$quizPath.$file) ){
    		return WPSQT_DIR.'pages/custom/'.$quizPath.$file;
    	} elseif ( file_exists(WPSQT_DIR.'pages/custom/'.$quizPathGeneral.$file) ){
    		return WPSQT_DIR.'pages/custom/'.$quizPathGeneral.$file;
    	} elseif (file_exists(WPSQT_DIR.'pages/custom/'.$blog_id.'/shared/'.$file)) {
    		return WPSQT_DIR.'pages/custom/'.$blog_id.'/shared/'.$file;
    	}
    	return WPSQT_DIR.'pages/'.$file;
    }

    So now the new layout will be applied for each quiz, poll or survey and directory for new template will look like this:
    /var/ww/wp-content/plugins/wp-survey-and-quiz-tool/pages/custom/0/poll.

    If you like it, you can add it into the new release. Also have been thinking to remove the blog ID but it probably plays its role in multisite wordpress installations.

    Stefan

    I know that this thread is not about features, but since I have started to write down everything into this thread I have some feature requests:

    A function to pull a random poll/quiz/survey
    A function to pull the latest poll/quiz/survey
    A poll/quiz/survey archive page ( with possibility to modifie dates )

    Also I have seen that there is a possibility to limit submission by IP, but this is a problem when people come from shared IP connections ( tons of providers share one IP to 100s customers) . Would be nice if there is also a Cookie + IP combination.

    All from me for today.
    Thanx
    Stefan

    Plugin Author Ollie Armstrong

    (@olliea95)

    Thanks Stefan, will review your changes if I get a spare few minutes today. Also those features have been noted and I will see what I can do.

    Many thanks,
    Ollie

    i have used %RESULT_URL% to show url to user(member )
    but it shows url as
    https://localhost/website/wp-admin/admin.php?page=wpsqtmenu§ion=results&subsection=mark&id=3&resultid=119

    but when i try to open it in browser it displays you “You do not have sufficient permissions to access this page.”

Viewing 7 replies - 61 through 67 (of 67 total)
  • The topic ‘2 errors i receive using the survey’ is closed to new replies.