• Resolved jnthnlstr

    (@jnthnlstr)


    Hello,

    I have a problem – when I create a quiz using the single-choice or multi-choice questions, and enable showing the score at the end, I always receive this message:

    “You got 0 correct out of 0”.

    I have tried this on a local MAMP (mac) server and on a remote linux server.

    I had a poke into the code and found that the score was being kept in the $_SESSION variable. So I did some logging of this as I was going along and found that the session variables are not being preserved.

    I don’t know enough about sessions to get any further, so any help would be hugely appreciated.

    Jonathan

    https://www.ads-software.com/extend/plugins/wp-survey-and-quiz-tool/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter jnthnlstr

    (@jnthnlstr)

    Another thing I have noticed while poking into this, is that the $_SESSION variable doesn’t preserve the questions and answers for a section into the next section (which is should since they’re not unset); and that the “person” variable ends up blank once you’ve gone past the first page after filling in the personal details form.

    So, there is a systematic losing of session data here…

    Hi,
    I have no idea why PHP would be losing session data, however I have written a little tests script that will help be find out the cause of the problem. Which can be found at https://codepad.org/d42cLPi4 if you run this on your server via your browser it should hopefully allow me to figure out the issue.

    Iain

    Thread Starter jnthnlstr

    (@jnthnlstr)

    Hi,

    Thanks for the response!

    I believe I have tracked down the cause of the problem. I did a test to see what session data was being lost, using an independent session variable, and nothing was being lost, so I looked elsewhere.

    It turns out that in /includes/site/quiz.php, line 29, which is:
    if ( $step == 0 ){
    This if is closed too early, at line 34, whereas it should be closed after line 46. As it stands at the moment, the if statement doesn’t wrap around the statements that refresh the quiz_sections and person variables, hence why I was seeing them deleted from the session data.

    J.

    Hi,

    No that if was meant to be closed there. However after another look I see that

    $_SESSION[‘wpsqt’][$quizName][‘person’] = array();
    $_SESSION[‘wpsqt’][‘start’] = microtime(true);

    would be better suited in the original if statement and a && $step == 0 added to the if.

    Thanks for debugging this issue for me.

    ??

    Thread Starter jnthnlstr

    (@jnthnlstr)

    Great stuff!

    Hey Backie or jnthnlstr,

    So what was the definitive solution to this issue? Kind of unclear on this. I am having the same issue where session data is not preserved across sections. The only way I can get results from a quiz is if I have only one section and don’t use a form. Just one single page section with no form.

    Thanks

    Well the solution to this issue was to update. If you’re not on the latest version, update now.

    I just downloaded to I gather i’m on the latest version. I have put a test survey out at wenotice dot com /seo-interview-test/ I am running 1.3.22 of the plugin. If I need to do anything to make this work properly let me know.

    Well I just took the the quiz that was set up at the url given. Sessions do seem to be active, since I managed to get through the quiz and was shown questions all which would have been in the sessions. If you could email me at (iain.cambridge – a t – fubra.com) the contents of a {dbprefix}wpsqt_results.sections it will help figure out what your problem is.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: WP Survey And Quiz Tool] You got 0 correct out of 0’ is closed to new replies.