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 And Other Advanced Adjustments

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.

Other Fill The Gaps Adjustments

You can create a “placeholder” for each regular gap (not for drop-downs) to give a hint or remind for the supported format in the gap like this:

One dollar has {{{100|placeholder="numbers only"}}} cents in it.

For gaps that allow multiple correct answers you can do the same – just make sure the placeholder is the last value:

A good apple color can be {{{green|red|yellow|placeholder="type color name"}}}.

On the WatuPRO Settings page you can define the width and height of the gaps. Sometimes you may need to apply specific CSS style to an individual gap. You can do this by passing an inline style as last answer for the gap (in case there is a placeholder, style should be after it). Examples:

One dollar has {{{100|placeholder="numbers only"|style="font-weight:bold;"}}} cents in it.

A good apple color can be {{{green|red|yellow|style="width:150px;"}}}.