public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/functions.php
/**
 * Retrieve all of the questions associated with this course.
 *
 * @since 1.0.0
 *
 * @param int $courseID The ID of the course to get the questions for.
 *
 * @return array The list of question objects.
 */
Retrieve all of the questions associated with this course.

@param int $courseID The ID of the course to get the questions for.

@return array The list of question objects.
Retrieve all of the questions associated with this course . @param int $courseID The ID of the course to get the questions for . @return array The list of question objects .
function WPCW_questions_getAllQuestionsforCourse( $courseID ) {
	global $wpcwdb, $wpdb;
	$wpdb->show_errors();
	$quizIDList = $wpdb->get_col( $wpdb->prepare( "
    	SELECT quiz_id
    	FROM $wpcwdb->quiz q
    		LEFT JOIN $wpcwdb->units_meta um ON um.unit_id = q.parent_unit_id
    	WHERE q.parent_course_id = %d
   	", $courseID ) );
	if ( empty( $quizIDList ) ) {
		return false;
	}
	$quizIDListStr = implode( ',', $quizIDList );
	$questions = $wpdb->get_results( "
			SELECT qq.question_id, qq.question_type, qq.question_question
			FROM $wpcwdb->quiz_qs qq
				LEFT JOIN $wpcwdb->quiz_qs_mapping qqm ON qqm.question_id = qq.question_id
			WHERE qqm.parent_quiz_id IN ($quizIDListStr)
			GROUP BY qq.question_id
			" );
	$list = array();
	if ( ! empty( $questions ) ) {
		foreach ( $questions as $singleQuestion ) {
			$list[ $singleQuestion->question_id ] = $singleQuestion;
		}
		return $list;
	}
	return false;
}
function WPCW_questions_getAllQuestionsforCourse ( $ courseID ) { global $ wpcwdb , $ wpdb ; $ wpdb -> show_errors ( ) ; $ quizIDList = $ wpdb -> get_col ( $ wpdb -> prepare ( " 
    	SELECT quiz_id
    	FROM  $ wpcwdb -> quiz  q
    		LEFT JOIN  $ wpcwdb -> units_meta  um ON um.unit_id = q.parent_unit_id
    	WHERE q.parent_course_id = %d
   	 " , $ courseID ) ) ; if ( empty ( $ quizIDList ) ) { return false ; } $ quizIDListStr = implode ( ',' , $ quizIDList ) ; $ questions = $ wpdb -> get_results ( " 
			SELECT qq.question_id, qq.question_type, qq.question_question
			FROM  $ wpcwdb -> quiz_qs  qq
				LEFT JOIN  $ wpcwdb -> quiz_qs_mapping  qqm ON qqm.question_id = qq.question_id
			WHERE qqm.parent_quiz_id IN ( $ quizIDListStr )
			GROUP BY qq.question_id
			 " ) ; $ list = array ( ) ; if ( ! empty ( $ questions ) ) { foreach ( $ questions as $ singleQuestion ) { $ list [ $ singleQuestion -> question_id ] = $ singleQuestion ; } return $ list ; } return false ; }
Retrieve all of the questions associated with this course.
Retrieve all of the questions associated with this course .
// Get a list of all quizzes, as we'll need this to build a list of questions. // Now we need to get a list of all question IDs being used in all of these quizzes. // Just getting IDs and type to save memory. // Create ID => details