public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/functions.php
/**
 * Get a list of quiz post objects that match the specified parent unit ID.
 *
 * @since 1.0.0
 *
 * @param integer $unitID The ID of the unit to get the quizzes for (0 = unassigned units).
 *
 * @return array A list of quiz objects in the order that they appear.
 */
Get a list of quiz post objects that match the specified parent unit ID.

@param integer $unitID The ID of the unit to get the quizzes for (0 = unassigned units).

@return array A list of quiz objects in the order that they appear.
Get a list of quiz post objects that match the specified parent unit ID . @param integer $unitID The ID of the unit to get the quizzes for ( 0 = unassigned units ) . @return array A list of quiz objects in the order that they appear .
function WPCW_quizzes_getListOfQuizzes( $unitID ) {
	global $wpcwdb, $wpdb;
	$wpdb->show_errors();
	$current_user = wp_get_current_user();
	$SQL_AND = false;
	if ( ! user_can( $current_user, 'manage_wpcw_settings' ) ) {
		$SQL_AND = $wpdb->prepare( ' AND quiz_author = %d', $current_user->ID );
	}
	$SQL = $wpdb->prepare( "
		SELECT *
		FROM $wpcwdb->quiz
		WHERE parent_unit_id = %d
		$SQL_AND
	", $unitID );
	$rawQuizzes = $wpdb->get_results( $SQL );
	if ( ! $rawQuizzes ) {
		return false;
	}
	$quizObjList = array();
	foreach ( $rawQuizzes as $obj ) {
		$quizObjList[ $obj->quiz_id ] = $obj;
	}
	return $quizObjList;
}
function WPCW_quizzes_getListOfQuizzes ( $ unitID ) { global $ wpcwdb , $ wpdb ; $ wpdb -> show_errors ( ) ; $ current_user = wp_get_current_user ( ) ; $ SQL_AND = false ; if ( ! user_can ( $ current_user , 'manage_wpcw_settings' ) ) { $ SQL_AND = $ wpdb -> prepare ( ' AND quiz_author = %d' , $ current_user -> ID ) ; } $ SQL = $ wpdb -> prepare ( " 
		SELECT *
		FROM  $ wpcwdb -> quiz 
		WHERE parent_unit_id = %d
		 $ SQL_AND " , $ unitID ) ; $ rawQuizzes = $ wpdb -> get_results ( $ SQL ) ; if ( ! $ rawQuizzes ) { return false ; } $ quizObjList = array ( ) ; foreach ( $ rawQuizzes as $ obj ) { $ quizObjList [ $ obj -> quiz_id ] = $ obj ; } return $ quizObjList ; }
Get a list of quiz post objects that match the specified parent unit ID.
Get a list of quiz post objects that match the specified parent unit ID .
// Current user // check permissions // No list of associated IDs? Abort, and return false, as no quizzes objects. // Re-order post objects so that they are ID => Object details, rather than 0 => Object, 1 => Object