public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/functions.php
/**
 * Get all of the quiz details for the specified unit and quiz ID.
 *
 * @since 1.0.0
 *
 * @param integer $userID The ID of the user.
 * @param integer $unitID The ID of the unit.
 * @param integer $quizID The ID of the quiz.
 *
 * @return object The quiz results as an object.
 */
Get all of the quiz details for the specified unit and quiz ID.

@param integer $userID The ID of the user.
@param integer $unitID The ID of the unit.
@param integer $quizID The ID of the quiz.

@return object The quiz results as an object.
Get all of the quiz details for the specified unit and quiz ID . @param integer $userID The ID of the user . @param integer $unitID The ID of the unit . @param integer $quizID The ID of the quiz . @return object The quiz results as an object .
function WPCW_quizzes_getUserResultsForQuiz( $userID, $unitID, $quizID ) {
	global $wpdb, $wpcwdb;
	$wpdb->show_errors();
	$SQL = $wpdb->prepare( "
    	SELECT *, UNIX_TIMESTAMP(quiz_completed_date) AS quiz_completed_date_ts
    	FROM $wpcwdb->user_progress_quiz
    	WHERE user_id = %d
    	  AND unit_id = %d
    	  AND quiz_id = %d
    	ORDER BY quiz_attempt_id DESC
    	LIMIT 1
   	", $userID, $unitID, $quizID );
	$quizObj = $wpdb->get_row( $SQL );
	if ( $quizObj && $quizObj->quiz_data ) {
		$quizObj->quiz_data = maybe_unserialize( $quizObj->quiz_data );
	}
	if ( $quizObj && $quizObj->quiz_needs_marking_list ) {
		$quizObj->quiz_needs_marking_list = unserialize( $quizObj->quiz_needs_marking_list );
	}
	if ( $quizObj ) {
		$quizObj->attempt_count = $wpdb->get_var( $wpdb->prepare( "
	    	SELECT COUNT(*) AS attempt_count
	    	FROM $wpcwdb->user_progress_quiz
	    	WHERE user_id = %d
	    	  AND unit_id = %d
	    	  AND quiz_id = %d
	   	", $userID, $unitID, $quizID ) );
	}
	return $quizObj;
}
function WPCW_quizzes_getUserResultsForQuiz ( $ userID , $ unitID , $ quizID ) { global $ wpdb , $ wpcwdb ; $ wpdb -> show_errors ( ) ; $ SQL = $ wpdb -> prepare ( " 
    	SELECT *, UNIX_TIMESTAMP(quiz_completed_date) AS quiz_completed_date_ts
    	FROM  $ wpcwdb -> user_progress_quiz 
    	WHERE user_id = %d
    	  AND unit_id = %d
    	  AND quiz_id = %d
    	ORDER BY quiz_attempt_id DESC
    	LIMIT 1
   	 " , $ userID , $ unitID , $ quizID ) ; $ quizObj = $ wpdb -> get_row ( $ SQL ) ; if ( $ quizObj && $ quizObj -> quiz_data ) { $ quizObj -> quiz_data = maybe_unserialize ( $ quizObj -> quiz_data ) ; } if ( $ quizObj && $ quizObj -> quiz_needs_marking_list ) { $ quizObj -> quiz_needs_marking_list = unserialize ( $ quizObj -> quiz_needs_marking_list ) ; } if ( $ quizObj ) { $ quizObj -> attempt_count = $ wpdb -> get_var ( $ wpdb -> prepare ( " 
	    	SELECT COUNT(*) AS attempt_count
	    	FROM  $ wpcwdb -> user_progress_quiz 
	    	WHERE user_id = %d
	    	  AND unit_id = %d
	    	  AND quiz_id = %d
	   	 " , $ userID , $ unitID , $ quizID ) ) ; } return $ quizObj ; }
Get all of the quiz details for the specified unit and quiz ID.
Get all of the quiz details for the specified unit and quiz ID .
// Get the latest version of the quiz results, as there may be other versions to check for. // Sort out the array of quiz data. // Unserialize the quiz marking list. // Count how many attempts there were.