public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/functions.php
/**
 * Get a list of questions that match the specified quiz ID.
 *
 * @since 1.0.0
 *
 * @param integer $quizID The ID of the quiz to get the questions for.
 * @param boolean $getTagsToo If true, then get the list of these tags too.
 *
 * @return array A list of questions objects in the order that they appear within the quiz.
 */
Get a list of questions that match the specified quiz ID.

@param integer $quizID The ID of the quiz to get the questions for.
@param boolean $getTagsToo If true, then get the list of these tags too.

@return array A list of questions objects in the order that they appear within the quiz.
Get a list of questions that match the specified quiz ID . @param integer $quizID The ID of the quiz to get the questions for . @param boolean $getTagsToo If true then get the list of these tags too . @return array A list of questions objects in the order that they appear within the quiz .
function WPCW_quizzes_getListOfQuestions( $quizID, $getTagsToo = true ) {
	global $wpcwdb, $wpdb;
	$wpdb->show_errors();
	$SQL = $wpdb->prepare( "
			SELECT *
			FROM $wpcwdb->quiz_qs_mapping qqm
				LEFT JOIN $wpcwdb->quiz_qs qq ON qq.question_id = qqm.question_id
			WHERE qqm.parent_quiz_id = %d
			ORDER BY qqm.question_order ASC
		", $quizID );
	$rawQuestions = $wpdb->get_results( $SQL );
	if ( ! $rawQuestions ) {
		return false;
	}
	$questionObjList = array();
	foreach ( $rawQuestions as $obj ) {
		$obj->tags = false;
		if ( $getTagsToo ) {
			$obj->tags = $wpdb->get_results( $wpdb->prepare( "
				SELECT qt.*
				FROM $wpcwdb->question_tag_mapping qtm
					LEFT JOIN $wpcwdb->question_tags qt ON qtm.tag_id = qt.question_tag_id
				WHERE question_id = %d
				ORDER BY question_tag_name ASC
			", $obj->question_id ) );
		}
		$questionObjList[ $obj->question_id ] = $obj;
	}
	return $questionObjList;
}
function WPCW_quizzes_getListOfQuestions ( $ quizID , $ getTagsToo = true ) { global $ wpcwdb , $ wpdb ; $ wpdb -> show_errors ( ) ; $ SQL = $ wpdb -> prepare ( " 
			SELECT *
			FROM  $ wpcwdb -> quiz_qs_mapping  qqm
				LEFT JOIN  $ wpcwdb -> quiz_qs  qq ON qq.question_id = qqm.question_id
			WHERE qqm.parent_quiz_id = %d
			ORDER BY qqm.question_order ASC
		 " , $ quizID ) ; $ rawQuestions = $ wpdb -> get_results ( $ SQL ) ; if ( ! $ rawQuestions ) { return false ; } $ questionObjList = array ( ) ; foreach ( $ rawQuestions as $ obj ) { $ obj -> tags = false ; if ( $ getTagsToo ) { $ obj -> tags = $ wpdb -> get_results ( $ wpdb -> prepare ( " 
				SELECT qt.*
				FROM  $ wpcwdb -> question_tag_mapping  qtm
					LEFT JOIN  $ wpcwdb -> question_tags  qt ON qtm.tag_id = qt.question_tag_id
				WHERE question_id = %d
				ORDER BY question_tag_name ASC
			 " , $ obj -> question_id ) ) ; } $ questionObjList [ $ obj -> question_id ] = $ obj ; } return $ questionObjList ; }
Get a list of questions that match the specified quiz ID.
Get a list of questions that match the specified quiz ID .
// No list of associated IDs? Abort, and return false, as no question objects. // Re-order post objects so that they are ID => Object details, rather than 0 => Object, 1 => Object // Also grab any tags that this question has.