public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/functions.php
/**
 * Function called to check if there are any ungraded quizzes left for a specific user now they've completed the unit.
 *
 * @since 1.0.0
 *
 * @param integer $userID The ID of the user that's completed the unit.
 * @param integer $courseID The ID of the course that the user appears to have completed.
 *
 * @return boolean True if they have any ungraded quizzes, false otherwise.
 */
Function called to check if there are any ungraded quizzes left for a specific user now they've completed the unit.

@param integer $userID The ID of the user that's completed the unit.
@param integer $courseID The ID of the course that the user appears to have completed.

@return boolean True if they have any ungraded quizzes, false otherwise.
Function called to check if there are any ungraded quizzes left for a specific user now they ' ve completed the unit . @param integer $userID The ID of the user that ' s completed the unit . @param integer $courseID The ID of the course that the user appears to have completed . @return boolean True if they have any ungraded quizzes false otherwise .
function WPCW_quizzes_doesUserHaveAnyUngradedQuizzes( $userID, $courseID ) {
	$quizzesForCourse = WPCW_quizzes_getAllQuizzesForCourse( $courseID );
	if ( empty( $quizzesForCourse ) ) {
		return false;
	}
	$quizIDList = array();
	foreach ( $quizzesForCourse as $singleQuiz ) {
		$quizIDList[] = $singleQuiz->quiz_id;
	}
	$quizIDListForSQL = '(' . implode( ',', $quizIDList ) . ')';
	global $wpdb, $wpcwdb;
	$wpdb->show_errors();
	$SQL = $wpdb->prepare( "
		SELECT COUNT(*) AS needs_grading
		  FROM $wpcwdb->user_progress_quiz
		WHERE quiz_id IN $quizIDListForSQL
		  AND user_id = %d
		  AND quiz_is_latest = 'latest'
		  AND quiz_needs_marking > 0
	", $userID );
	$quizzesThatNeedMarking = $wpdb->get_var( $SQL );
	return $quizzesThatNeedMarking > 0;
}
function WPCW_quizzes_doesUserHaveAnyUngradedQuizzes ( $ userID , $ courseID ) { $ quizzesForCourse = WPCW_quizzes_getAllQuizzesForCourse ( $ courseID ) ; if ( empty ( $ quizzesForCourse ) ) { return false ; } $ quizIDList = array ( ) ; foreach ( $ quizzesForCourse as $ singleQuiz ) { $ quizIDList [ ] = $ singleQuiz -> quiz_id ; } $ quizIDListForSQL = '(' . implode ( ',' , $ quizIDList ) . ')' ; global $ wpdb , $ wpcwdb ; $ wpdb -> show_errors ( ) ; $ SQL = $ wpdb -> prepare ( " 
		SELECT COUNT(*) AS needs_grading
		  FROM  $ wpcwdb -> user_progress_quiz 
		WHERE quiz_id IN  $ quizIDListForSQL 
		  AND user_id = %d
		  AND quiz_is_latest = 'latest'
		  AND quiz_needs_marking > 0
	 " , $ userID ) ; $ quizzesThatNeedMarking = $ wpdb -> get_var ( $ SQL ) ; return $ quizzesThatNeedMarking > 0 ; }
Function called to check if there are any ungraded quizzes left for a specific user now they've completed the unit.
Function called to check if there are any ungraded quizzes left for a specific user now they ' ve completed the unit .
// No quizzes for this course. // Create a simple list of quiz IDs to use in SQL queries // Convert list of IDs into an SQL list // Find out how many quizzes in this course have questions // that need marking.