Skip to content

Commit

Permalink
Respove the other files code
Browse files Browse the repository at this point in the history
  • Loading branch information
etchirag committed Sep 24, 2024
1 parent bf9a7a5 commit be628fa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
4 changes: 2 additions & 2 deletions js/qsm-quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ var qsmTimerInterval = [];
// Calculates starting time.
var timerTotal = parseFloat(qmn_quiz_data[quizID].timer_limit) * 60;
var timerStarted = localStorage.getItem('mlw_started_quiz' + quizID);
var timerConsumed = parseInt(localStorage.getItem('mlw_time_consumed_quiz' + quizID));
var timerConsumed = parseInt(localStorage.getItem('mlw_time_consumed_quiz' + quizID)) || 1;
var timerRemaning = timerTotal - timerConsumed;
if ('yes' == timerStarted && 0 < timerRemaning) {
seconds = parseInt(timerRemaning);
Expand Down Expand Up @@ -357,7 +357,7 @@ var qsmTimerInterval = [];

// Calculates starting time.
let timerStarted = localStorage.getItem('mlw_started_quiz' + quizID);
let timerConsumed = parseInt(localStorage.getItem('mlw_time_consumed_quiz' + quizID));
let timerConsumed = parseInt(localStorage.getItem('mlw_time_consumed_quiz' + quizID)) || 1;
let seconds = parseFloat(qmn_quiz_data[quizID].timer_limit) * 60;
let timerRemaning = seconds - timerConsumed;
if ('yes' == timerStarted && 0 < timerRemaning) {
Expand Down
29 changes: 21 additions & 8 deletions php/classes/class-qmn-quiz-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -929,14 +929,6 @@ public function load_questions( $quiz_id, $quiz_options, $is_quiz_page, $questio
$question_ids = apply_filters( 'qsm_load_questions_ids', $question_ids, $quiz_id, $quiz_options );
$question_ids = QMNPluginHelper::qsm_shuffle_assoc( $question_ids );
$question_sql = implode( ',', $question_ids );
?>
<script>
const d = new Date();
d.setTime(d.getTime() + (365*24*60*60*1000));
let expires = "expires="+ d.toUTCString();
document.cookie = "question_ids_<?php echo esc_attr( $quiz_id ); ?> = <?php echo esc_attr( $question_sql ) ?>; "+expires+"; path=/";
</script>
<?php
}
$order_by_sql = 'ORDER BY FIELD(question_id,'. esc_sql( $question_sql ) .')';
}
Expand Down Expand Up @@ -980,6 +972,27 @@ public function load_questions( $quiz_id, $quiz_options, $is_quiz_page, $questio
$questions = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mlw_questions WHERE quiz_id=%d AND deleted=0 %1s %2s %3s", $quiz_id, $question_sql, $order_by_sql, $limit_sql ) );

}
if (
in_array( intval( $quiz_options->randomness_order ), [ 1, 2 ], true) &&
! empty($questions) &&
is_array($questions) &&
! isset($_COOKIE[ 'question_ids_' . $quiz_id ])
) {
$question_ids = array();
foreach ( $questions as $question ) {
$question_ids[] = $question->question_id;
}

$question_sql = implode(',', array_unique($question_ids)); // Prevent duplicates
?>
<script>
const d = new Date();
d.setTime(d.getTime() + (365 * 24 * 60 * 60 * 1000)); // Set cookie for 1 year
let expires = "expires=" + d.toUTCString();
document.cookie = "question_ids_<?php echo esc_js($quiz_id); ?>=" + "<?php echo esc_js($question_sql); ?>" + "; " + expires + "; path=/";
</script>
<?php
}
return apply_filters( 'qsm_load_questions_filter', $questions, $quiz_id, $quiz_options );
}

Expand Down
1 change: 0 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ QSM is designed to be compatible with most WordPress plugins and themes. However
* Feature: Added placeholder customization for short answer and paragraph questions
* Bug: Resolved vulnerability issue with question settings
* Bug: Fixed issue with undefined page redirection
* Bug: Enter key issue resolved in paragraph question type

= 9.1.2 ( August 22, 2024 ) =
* Bug: Resolved issue preventing global settings from being saved
Expand Down

0 comments on commit be628fa

Please sign in to comment.