Monthly Archives: December 2015

WatuPRO 5.0.2.4 Critical Bug Fix for WordPress 4.4

Yesterday’s WordPress upgrade to 4.4 is causing a database error when submitting a quiz in most WatuPRO versions and some MySQL versions. This is NOT a security issue but it can cause critical malfunction. So we highly recommend to update to the latest version ASAP.

We are sending version 5.0.2.4 via a newsletter today. If you have not received it, feel free to send us email.

If you have customized the plugin in some way and don’t want to update you can replace only lib/watupro.php where the changes are done. In any other case please update the whole plugin.

If Your Free Support Subscription Has Expired

We sent a newsletter when this bug fix was released. If you missed to update your installation back then and your free support subscription has expired, you have two options:

  • To renew using the 60% promo code. It can be provided to you by email, please contact us.
  • To fix the bug yourself. Open lib/watupro.php and fine the following queries:
if(empty($detail->ID)) {
               $wpdb->insert(WATUPRO_STUDENT_ANSWERS,
                array("user_id"=>$user_ID, "exam_id"=>$exam_id, "taking_id"=>$taking_id,
                    "question_id"=>$question_id, "answer"=>$answer,
                    "points"=>$points, "question_text"=>$question_text, 
                    "is_correct" => $is_correct, 'snapshot'=>$snapshot, 'hints_used'=>$hints, 
                    "num_hints_used" => $no_hints, "onpage_question_num" => @$_POST['current_question'],
                    "feedback" => @$_POST['feedback-'.$question_id],
                    "rating" => intval(@$_POST['question_rating_'.$question_id])),
                array("%d","%d","%d","%d","%s","%f","%s", "%d", "%s", "%s", "%d", "%d", "%s", "%d"));    
                $detail_id = $wpdb->insert_id;            
        }
        else {
                // don't remove the snapshot
                if(empty($snapshot) and !empty($detail->snapshot)) $snapshot = stripslashes($detail->snapshot);            
            
            $wpdb->query($wpdb->prepare("UPDATE ".WATUPRO_STUDENT_ANSWERS." SET
               answer=%s, points=%s, question_text=%s, is_correct=%d, snapshot=%s, hints_used = %s, 
               num_hints_used=%d, onpage_question_num=%d, feedback=%s, rating=%d
               WHERE id=%d", $answer, $points, $question_text, $is_correct, $snapshot, $hints, $no_hints,
               @$_POST['current_question'], @$_POST['feedback-'.$question_id], intval(@$_POST['question_rating_'.$question_id]), $detail->ID ));
            $detail_id = $detail->ID;                 
        }

Change them to:

if(empty($detail->ID)) {
    		   $wpdb->insert(WATUPRO_STUDENT_ANSWERS,
    			array("user_id"=>$user_ID, "exam_id"=>$exam_id, "taking_id"=>$taking_id,
    				"question_id"=>$question_id, "answer"=>$answer,
    				"points"=>$points, "question_text"=>$question_text, 
    				"is_correct" => $is_correct, 'snapshot'=>$snapshot, 'hints_used'=>$hints, 
    				"num_hints_used" => $no_hints, "onpage_question_num" => intval(@$_POST['current_question']),
    				"feedback" => @$_POST['feedback-'.$question_id],
    				"rating" => intval(@$_POST['question_rating_'.$question_id])),
    			array("%d","%d","%d","%d","%s","%f","%s", "%d", "%s", "%s", "%d", "%d", "%s", "%d"));    
    			$detail_id = $wpdb->insert_id;			
        }
        else {
				// don't remove the snapshot
				if(empty($snapshot) and !empty($detail->snapshot)) $snapshot = stripslashes($detail->snapshot);        	
        	
            $wpdb->query($wpdb->prepare("UPDATE ".WATUPRO_STUDENT_ANSWERS." SET
               answer=%s, points=%s, question_text=%s, is_correct=%d, snapshot=%s, hints_used = %s, 
               num_hints_used=%d, onpage_question_num=%d, feedback=%s, rating=%d
               WHERE id=%d", $answer, $points, $question_text, $is_correct, $snapshot, $hints, $no_hints,
               intval(@$_POST['current_question']), @$_POST['feedback-'.$question_id], intval(@$_POST['question_rating_'.$question_id]), $detail->ID ));
            $detail_id = $detail->ID;                 
        } 

That’s it.

Turn Multiple-Answer Gaps Into Drop-downs (WatuPRO Intelligence Module v. >= 5.0.2)

You know that the Intelligence module of WatuPRO allows you to create “fill the gaps” questions. Each of the “gaps” (blanks) can have multiple correct answers when you use the following format:

The apple can be {{{green|red|yellow}}}

In the above example if the user fills green, or red, or yellow in the generated text field, their answer will be correct.

From version 5.0.2 the same format can be used for different purpose by selecting the following checkbox on the Edit Question page:

gaps-dropdownsWhen this is selected, all the gaps that have more than one answer within the question will be turned into drop-down selector. The drop-down selector will have one option for each answer given. The first answer that you have given is the only correct answer. But of course, it will not be shown first – the selections will be randomized so the user will not know which is the correct answer.

So if we use the above example, the correct answer will be “green” and red / yellow will not be correct.

This setting is per-question so it will affect all the blanks within the selected question.