• Resolved joeyblack

    (@joeyblack)


    Is there any way to customize quiz results evaluation? E.g. I want to give -1 point for the wrong answer etc.
    Yes, I’ve found the corresponding piece of code in the plugin. But it seems it is a hard coded logic:
    $results['mark'] += !empty( $check['mark'] ) ? $check['mark'] : 0;
    Do you have any suggestions?
    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi,

    Please try this code and let us know how it goes:

    add_filter( 'learn_press_evaluate_quiz_results', 'xxx_custom_quiz_mark' );
    function xxx_custom_quiz_mark( $results, $quiz_id, $user_id ) {
     if ( !empty( $results['wrong'] ) ) {
      $results['mark'] = $results['mark'] - absint( $results['wrong'] );//minus each wrong question 1 point
     }
     return $results;
    }

    Regards,

    Hien Phan.

    Thread Starter joeyblack

    (@joeyblack)

    Hien Phan,

    In the history list (below the quiz results) it shows warnings:

    Warning: Missing argument 2 for xxx_custom_quiz_mark()...
    Warning: Missing argument 3 for xxx_custom_quiz_mark()...
    Thread Starter joeyblack

    (@joeyblack)

    Is this correct?

    add_filter( 'learn_press_evaluate_quiz_results', 'xxx_custom_quiz_mark', 10, 3 );

    That’s right. Please try it on.

    Regards,

    Hien Phan.

    Thread Starter joeyblack

    (@joeyblack)

    It works. Thanks so much.

    You’re welcome -)))

    One more thing, hope you like my LMS LearnPress and consider rating 5* at https://wordpress.org/support/plugin/learnpress/reviews/?rate=5#new-post.

    Regards,

    Hien Phan.

    • This reply was modified 9 years, 5 months ago by hienphan.
Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Quiz results evaluation customization’ is closed to new replies.