Skip to content

Commit

Permalink
Merge pull request #2347 from QuizandSurveyMaster/CU-85ztxytqz-core-r…
Browse files Browse the repository at this point in the history
…esult-page-doesnt-count-unanswered-questions

unattempted template variable is created
  • Loading branch information
zubairraeen authored Sep 14, 2023
2 parents 3cf5fb7 + e4673ad commit a71d6ef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions php/admin/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ function qsm_text_template_variable_list() {
'%AMOUNT_CORRECT%' => __( 'The number of correct answers the user had', 'quiz-master-next' ),
'%AMOUNT_INCORRECT%' => __( 'The number of incorrect answers the user had', 'quiz-master-next' ),
'%AMOUNT_ATTEMPTED%' => __( 'The number of questions are attempted', 'quiz-master-next' ),
'%AMOUNT_UNATTEMPTED%' => __( 'The number of questions are not attempted', 'quiz-master-next' ),
'%TOTAL_QUESTIONS%' => __( 'The total number of questions in the quiz', 'quiz-master-next' ),
'%CORRECT_SCORE%' => __( 'Score for the quiz when using correct answers', 'quiz-master-next' ),
'%USER_NAME%' => __( 'The name the user entered before the quiz', 'quiz-master-next' ),
Expand Down
18 changes: 17 additions & 1 deletion php/template-variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
add_filter( 'mlw_qmn_template_variable_results_page', 'qsm_variable_single_answer', 20, 2 );
add_filter( 'mlw_qmn_template_variable_results_page', 'qsm_variable_total_possible_points', 10, 2 );
add_filter( 'mlw_qmn_template_variable_results_page', 'qsm_variable_total_attempted_questions', 10, 2 );
add_filter( 'mlw_qmn_template_variable_results_page', 'qsm_variable_total_unattempted_questions', 10, 2 );
add_filter( 'mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_full_name', 10, 2 );
add_filter( 'mlw_qmn_template_variable_results_page', 'qsm_variable_poll_result', 10, 3 );
add_filter( 'qmn_end_results', 'qsm_variable_poll_result', 10, 3 );
Expand Down Expand Up @@ -187,7 +188,22 @@ function qsm_variable_total_attempted_questions( $content, $mlw_quiz_array ) {
$content = str_replace( '%AMOUNT_ATTEMPTED%', $total_attempted_questions, $content );
return $content;
}

/**
* Function to get the count of not answered questions or not attempted questions
*
* @since 8.1.16
*
* @param string $content
* @param array $mlw_quiz_array
* @return string $content
*/
function qsm_variable_total_unattempted_questions( $content, $mlw_quiz_array ) {
$total_attempted_questions = isset( $mlw_quiz_array['total_attempted_questions'] ) ? $mlw_quiz_array['total_attempted_questions'] : 0;
$total_questions = isset( $mlw_quiz_array['total_questions'] ) ? $mlw_quiz_array['total_questions'] : 0;
$total_unattempted_questions = $total_questions - $total_attempted_questions;
$content = str_replace( '%AMOUNT_UNATTEMPTED%', $total_unattempted_questions, $content );
return $content;
}
/**
* Show poll result
*
Expand Down

0 comments on commit a71d6ef

Please sign in to comment.