WordPress.org

Forums

SS Quiz
[Bug] Selecting a radio button by clicking its corresponding text (3 posts)

  1. BingDai
    Member
    Posted 2 years ago #

    First of all I want to thank you ssvadim for developing the plugin. It is the best quiz plugin I have found.

    However, I discovered a bug lately that I would need help solving: for a single choice question, it *appears* that I can select the answer by either (1) clicking the radio button of that answer, or (2) by clicking the text of that answer. However, only method (1) will actually select the answer (i.e., the backend registered the selection). The backend will not register method (2).

    Please take a look at this example. Please go to http://aamavancouver.com/test-quiz-3.
    The question is "what is the first month of a year", and the answer is the answer "January". Here is what happens:

    (1) If I select the answer by clicking the *radio button*, the result page tells me that I answered it correctly.
    (2) If I select the answer by clicking the *text* (i.e., "January"), even if the radio button still appears to be selected, the result page tells me that I did not answer that question.

    Any help would be appreciated. Thanks!

    http://wordpress.org/extend/plugins/ssquiz/

  2. BingDai
    Member
    Posted 2 years ago #

    I would also like to add that the bug also exists when I use my phone to access http://aamavancouver.com/test-quiz-3.

    Thanks in advance!

  3. BingDai
    Member
    Posted 2 years ago #

    I went ahead and did some hacking.

    I changed the "function ssquiz_print_question( &$current_question, &$info )" function in client-quiz.php. Now the "click text to select a button" mechanism is gone, so users have to click the actual radio button.

    The part I changed is echo '<span class="ssquiz_answer_span"><input type="radio" name="ssquiz_answer" class="ssquiz_answer"/>'
    . $answer->answer . '</span></br>';

    function ssquiz_print_question( &$current_question, &$info ) {
    	ob_start();
    	$number = $info->questions_counter + 1;
    	echo '<div class="ssquiz_question">';
    	echo "<strong>" . __("Question") . (( $info->all ) ? " $number" : " $number/{$info->total_questions}" ) . ":</strong><br />";
    	echo apply_filters( 'the_content', $current_question->question );
    
    	if ( $current_question->type == 'fill' ) {
    		$input = '<input type="text" name="ssquiz_answer" class="ssquiz_answer" value="" style="width: 130px;" />';
    			echo $input . '</br>';
    		$run_js = '<script>jQuery.fn.run_standard_types();</script>';
    	}
    	if( $current_question->type == 'single' || $current_question->type == 'multi' ) {
    		if( true == $info->arandom )
    			shuffle($current_question->answers);
    		foreach ( $current_question->answers as $answer ) {
    			if ($current_question->type == 'single' )
    				echo '<span class="ssquiz_answer_span"><input type="radio" name="ssquiz_answer" class="ssquiz_answer"/>'
    					. $answer->answer . '</span></br>';
    			else
    				echo '<input type="checkbox" name="ssquiz_answer" class="ssquiz_answer" /><span class="ssquiz_answer_span">'
    					. $answer->answer . '</span></br>';
    		}
    		$run_js = '<script>jQuery.fn.run_standard_types();</script>';
    	}
    
    	if ( ! $info->all )
    		echo $run_js;
    	echo '</div>';
    	$output = ob_get_contents();
    	ob_end_clean();
    	return $output;
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • SS Quiz
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags