Skip to content

Commit

Permalink
Merge pull request #2354 from QuizandSurveyMaster/CU-85ztzqn3w-file-u…
Browse files Browse the repository at this point in the history
…pload-question-type-quiz-score

validation for the file upload question type
  • Loading branch information
zubairraeen authored Sep 20, 2023
2 parents 9c396d1 + 8b10151 commit 265719a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 7 additions & 2 deletions php/classes/class-qmn-quiz-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ public function display_pages( $options, $quiz_data ) {
if ( ( 1 == $options->randomness_order || 2 == $options->randomness_order ) && is_array( $pages ) ) {
$pages = QMNPluginHelper::qsm_shuffle_assoc( $pages );
$question_list_array = array();
foreach( $pages as &$question_ids ){
foreach ( $pages as &$question_ids ) {
shuffle( $question_ids );
$question_list_array = array_merge($question_list_array, $question_ids);
}
Expand Down Expand Up @@ -1909,7 +1909,6 @@ public function submit_results( $qmn_quiz_options, $qmn_array_for_variables ) {
* @return array The results of the user's score
*/
public static function check_answers( $options, $quiz_data ) {

global $mlwQuizMasterNext;
$new_questions = array();
// Load the pages and questions
Expand Down Expand Up @@ -2148,7 +2147,13 @@ public static function check_answers( $options, $quiz_data ) {
}
}
}
foreach ( $question_data as $questiontype ) {
if ( 11 == $questiontype['question_type'] ) {
$total_questions = $total_questions - 1;
}
}


// Calculate Total Percent Score And Average Points Only If Total Questions Doesn't Equal Zero To Avoid Division By Zero Error
if ( 0 !== $total_questions ) {
$total_score = round( ( ( $total_correct / ( $total_questions - count( $hidden_questions ) ) ) * 100 ), 2 );
Expand Down
1 change: 0 additions & 1 deletion php/question-types/qsm-question-type-file-upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ function qmn_file_upload_review( $id, $question, $answers ) {
$return_array['user_text'] = ($file_url) ? '<a target="_blank" href="' . $file_url . '">' . __( 'Click here to view', 'quiz-master-next' ) . '</a>' : __( 'No file uploaded', 'quiz-master-next' );
$return_array['correct_text'] = ! empty( $correct_text_array ) ? implode( ', ', $correct_text_array ) : '';
$return_array['correct'] = $current_question->get_answer_status( 'url' );
$return_array['points'] = $current_question->get_points();
$return_array['user_answer'] = $user_text_array;
$return_array['correct_answer'] = $correct_text_array;
/**
Expand Down

0 comments on commit 265719a

Please sign in to comment.