Skip to content

Commit

Permalink
validation for the file upload question type
Browse files Browse the repository at this point in the history
  • Loading branch information
vibina-et committed Sep 19, 2023
1 parent d4c9c98 commit 8b10151
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 ) ) {
shuffle( $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 @@ -1896,7 +1896,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 @@ -2135,7 +2134,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 8b10151

Please sign in to comment.