Skip to content

Commit

Permalink
Merge pull request #7688 from mehrazmorshed/mehraz
Browse files Browse the repository at this point in the history
replacing rand() by wp_rand()
  • Loading branch information
donnapep authored Jan 17, 2025
2 parents 7430670 + 001ed46 commit f835b0b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions tests/framework/factories/class-sensei-factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public function generate_user_quiz_answers( $quiz_id ) {
if ( 'multiple-choice' == $type ) {
// these answer can be found the question generate and attach answers function
$question_meta = get_post_meta( $question->ID );
$user_quiz_answers[ $question->ID ] = array( 0 => 'wrong1' . rand() );
$user_quiz_answers[ $question->ID ] = array( 0 => 'wrong1' . wp_rand() );

} elseif ( 'boolean' == $type ) {

Expand All @@ -487,15 +487,15 @@ public function generate_user_quiz_answers( $quiz_id ) {

} elseif ( 'single-line' == $type ) {

$user_quiz_answers[ $question->ID ] = 'Single line answer for basic testing ' . rand();
$user_quiz_answers[ $question->ID ] = 'Single line answer for basic testing ' . wp_rand();

} elseif ( 'gap-fill' == $type ) {

$user_quiz_answers[ $question->ID ] = 'OneWordScentencesForSampleAnswer ' . rand();
$user_quiz_answers[ $question->ID ] = 'OneWordScentencesForSampleAnswer ' . wp_rand();

} elseif ( 'multi-line' == $type ) {

$user_quiz_answers[ $question->ID ] = 'Sample paragraph to test the answer ' . rand();
$user_quiz_answers[ $question->ID ] = 'Sample paragraph to test the answer ' . wp_rand();

} elseif ( 'file-upload' == $type ) {

Expand Down Expand Up @@ -798,7 +798,7 @@ public function generate_user_answers_feedback( $quiz_id ) {

foreach ( $answers as $question_id => $answer ) {

$answers_feedback[ $question_id ] = 'Sample Feedback ' . rand();
$answers_feedback[ $question_id ] = 'Sample Feedback ' . wp_rand();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public function get_sample_question_data( $type ) {
'question_type' => $type,
'question_category' => 'undefined',
'action' => 'add',
'question' => 'Is this a sample' . $type . ' question ? _ ' . rand(),
'question' => 'Is this a sample' . $type . ' question ? _ ' . wp_rand(),
'question_grade' => '1',
'answer_feedback' => 'Answer Feedback sample ' . rand(),
'answer_feedback' => 'Answer Feedback sample ' . wp_rand(),
'question_description' => ' Basic description for the question',
'question_media' => '',
'answer_order' => '',
Expand Down
4 changes: 2 additions & 2 deletions tests/unit-tests/test-class-quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@ public function testSaveUserAnswersUniquelyPerQuiz() {
'question_type' => 'single-line',
'question_category' => 'undefined',
'action' => 'add',
'question' => 'Is this a sample' . 'single-line' . ' question ? _ ' . rand(),
'question' => 'Is this a sample' . 'single-line' . ' question ? _ ' . wp_rand(),
'question_grade' => '1',
'answer_feedback' => 'Answer Feedback sample ' . rand(),
'answer_feedback' => 'Answer Feedback sample ' . wp_rand(),
'question_description' => ' Basic description for the question',
'question_media' => '',
'answer_order' => '',
Expand Down

0 comments on commit f835b0b

Please sign in to comment.