Support » Plugin: SS Quiz » How to set 3 attempts to make the quiz?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Dirty hack – will break on update most likely

    open client-quiz.php

    replace (line 83-90)

    // Did current user tried this quiz
    if( $info->one_chance ) {
    		$attempts = $wpdb->get_var( "
    			SELECT count(*) FROM {$wpdb->base_prefix}ssquiz_history WHERE user_id = {$info->user->id} AND quiz_id = {$info->quiz->id}
    		");
    		if( $attempts > 0 )
    			return ssquiz_return_quiz_body( '<h2>'.__('You already took this quiz', 'ssquiz').'</h2>' );
    	}

    with

    //remove one_change and replaced with chances
    	if( isset( $params["chances"])) {
    		$attempts = $wpdb->get_var( "
    			SELECT count(*) FROM {$wpdb->base_prefix}ssquiz_history WHERE user_id = {$info->user->id} AND quiz_id = {$info->quiz->id}
    		");
    		if( $attempts >= intval( $params["chances"]) )
    			return ssquiz_return_quiz_body( '<h2>'.__('You already took this quiz', 'ssquiz').'</h2>' );
    	}

    then in your yourcode, add chances=3 to make 3 attempts. (1 for once_change)

    I’ve replaced the code, and in my quiz page, I’ve put this:
    [ssquiz id=3 qrandom timer=300 not_correct arandom chances=3]

    But it didn’t work. It says that I already took the quiz, even with the statistics cleared.

    What am I doing wrong?

    Thank you!

    you sure you published the page?

    dont use the back button to retake the quiz

    it work fine here, multiple browsers

    what happens if you add? it will show a dirty attemps and maxtries (it will only look a the attemps when loading the page, so use back for browser = no worky.

    if( isset( $params["chances"])) {
    		$attempts = $wpdb->get_var( "
    			SELECT count(*) FROM {$wpdb->base_prefix}ssquiz_history WHERE user_id = {$info->user->id} AND quiz_id = {$info->quiz->id}
    		");
    		echo "Attempts Saved: ".$attempts." Max_chances". intval( $params["chances"]);
    		if( $attempts >= intval( $params["chances"]) )
    			return ssquiz_return_quiz_body( '<h2>'.__('You already took this quiz', 'ssquiz').'</h2>' );
    	}

    ps, tried both logged in and logout users

    I have used Ctrl+F5 to clear cache and refresh the page.

    Now with this new code it runs perfectly!

    Thank you very much!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to set 3 attempts to make the quiz?’ is closed to new replies.