• Resolved d2092001

    (@d2092001)


    I want to display the result 2 less than the actual result.
    although tried with %YourNum-1% or %{YourNum-1}% everything is not working please help

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hello @d2092001 !

    Hope you’re doing well today!

    At the moment this is not possible out of the box, but I’ve asked our Second Line Support team to check if this would be possible and if so to prepare a code snippet for you.

    We’ll update you here as soon as we receive feedback form them.

    Warm regards,
    Pawel

    Plugin Support Dimitris – WPMU DEV Support

    (@wpmudev-support6)

    Hello @d2092001

    Could you please try the following snippet inside a MU plugin (ref: https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins)

    <?php
    add_filter( 'forminator_quizzes_render_knowledge_result', 'wpmudev_reduce_total_count_quiz', 10, 3 );
    function wpmudev_reduce_total_count_quiz( $knowledge_result_html, $text, $model ){
    	if( $model->id != 1356 ){
    		return $knowledge_result_html;
    	}
    	preg_match_all('!\d+!', $knowledge_result_html, $matches);
    	if( is_array( $matches ) ){
    		if( is_array( $matches[0] ) ){
    			$your_num = $matches[0][0];
    			$total = $matches[0][1];
    			if( $your_num > 0 ){
    				$pos = strpos($knowledge_result_html, $your_num);
    				if ($pos !== false) {
    					$knowledge_result_html = substr_replace($knowledge_result_html, $your_num-2, $pos, strlen($your_num));
    				}
    			}
    			if( $total > 0 ){
    				$pos = strpos($knowledge_result_html, $total);
    				if ($pos !== false) {
    					$knowledge_result_html = substr_replace($knowledge_result_html, $total-2, $pos, strlen($total));
    				}
    			}
    		}
    	}
    
    	return $knowledge_result_html;
    }

    If you just want to reduce the count of %YourNum% and not %Total%, then you can remove this condition from the snippet above:

    if( $total > 0 ){
    	$pos = strpos($knowledge_result_html, $total);
    	if ($pos !== false) {
    		$knowledge_result_html = substr_replace($knowledge_result_html, $total-2, $pos, strlen($total));
    	}
    }

    Warm regards,
    Dimitris

    Thread Starter d2092001

    (@d2092001)

    How to configure difficult sentences to score higher than easy ones? score for each different sentence

    Plugin Support Nebu John – WPMU DEV Support

    (@wpmudevsupport14)

    Hi @d2092001,

    I am sorry, I didn’t understand what you are precisely looking forward to.

    Do you need a custom score for each question based on its complexity?

    Can you please briefly explain so that we can better understand it and try to help you?

    Kind Regards,
    Nebu John

    Thread Starter d2092001

    (@d2092001)

    i tried mu-plugin with your code above but it still doesn’t show the score minus 2

    Thread Starter d2092001

    (@d2092001)

    How do I enter the information in the code? How do I set it to apply to all quizzes?

    • This reply was modified 2 years, 6 months ago by d2092001.
    Thread Starter d2092001

    (@d2092001)

    $model->id != 1356 what is 1356 and where did you get it

    Thread Starter d2092001

    (@d2092001)

    I have configured it, thank you very much

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘I want to modify the display of %YourNum% and %Total% values’ is closed to new replies.