Plugin Directory

Changeset 1327631


Ignore:
Timestamp:
01/13/2016 04:28:00 PM (10 years ago)
Author:
gmichaelguy
Message:

fix for rand not being rand

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mtouch-quiz/trunk/show_quiz.php

    r638075 r1327631  
    1212        $GLOBALS['wpframe_plugin_name'] = basename(dirname(__FILE__));
    1313        $GLOBALS['wpframe_plugin_folder'] = $GLOBALS['wpframe_wordpress'] . '/wp-content/plugins/' . $GLOBALS['wpframe_plugin_name'];
     14        $rand_seed = rand();
    1415
    1516        $quiz_options = $wpdb->get_row($wpdb->prepare("SELECT name,description,answer_mode,single_page,show_hints,show_start,show_final,multiple_chances,final_screen,random_questions,random_answers FROM {$wpdb->prefix}mtouchquiz_quiz WHERE ID=%d", $quiz_id));                 
     
    296297       
    297298        if( $random_questions == 1 && $input_number_questions > 0 ) { // Select questions randomly
    298             $all_question = $wpdb->get_results($wpdb->prepare("SELECT ID,question,explanation, point_value FROM {$wpdb->prefix}mtouchquiz_question WHERE quiz_id=%d AND ID>=$first_id_value AND ID<=$last_id_value ORDER BY RAND() LIMIT 0, $input_number_questions", $quiz_id));
     299            $all_question = $wpdb->get_results($wpdb->prepare("SELECT ID,question,explanation, point_value FROM {$wpdb->prefix}mtouchquiz_question WHERE quiz_id=%d AND ID>=$first_id_value AND ID<=$last_id_value ORDER BY RAND($rand_seed) LIMIT 0, $input_number_questions", $quiz_id));
    299300        } elseif( $random_questions != 1 && $input_number_questions > 0 ) { // Select questions in order
    300301            $all_question = $wpdb->get_results($wpdb->prepare("SELECT ID,question,explanation, point_value FROM {$wpdb->prefix}mtouchquiz_question WHERE quiz_id=%d AND ID>=$first_id_value  AND ID<=$last_id_value ORDER BY ID LIMIT 0, $input_number_questions", $quiz_id)); // Not random
     
    430431                                                 echo   "</colgroup>";
    431432                                                if ( $random_answers == 1 ) {
    432                                                     $dans = $wpdb->get_results("SELECT ID,answer,correct,hint FROM {$wpdb->prefix}mtouchquiz_answer WHERE question_id={$ques->ID} ORDER BY RAND()"); // This will randomize the question answer order
     433                                                    $dans = $wpdb->get_results("SELECT ID,answer,correct,hint FROM {$wpdb->prefix}mtouchquiz_answer WHERE question_id={$ques->ID} ORDER BY RAND($rand_seed)"); // This will randomize the question answer order
    433434                                                } else {
    434435                                                    $dans = $wpdb->get_results("SELECT ID,answer,correct,hint FROM {$wpdb->prefix}mtouchquiz_answer WHERE question_id={$ques->ID} ORDER BY sort_order");
Note: See TracChangeset for help on using the changeset viewer.