public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/pages/page-quiz-summary.php
/**
 * Handle the quiz deletion from the summary page.
 *
 * @since 1.0.0
 *
 * @param PageBuilder $page The page rendering object.
 */
Handle the quiz deletion from the summary page.

@param PageBuilder $page The page rendering object.
Handle the quiz deletion from the summary page . @param PageBuilder $page The page rendering object .
function WPCW_quizzes_handleQuizDeletion( $page ) {
	global $wpcwdb, $wpdb;
	$wpdb->show_errors();
	if ( isset( $_GET['action'] ) && $_GET['action'] == 'delete' && isset( $_GET['quiz_id'] ) ) {
		$quizID      = $_GET['quiz_id'];
		$quizDetails = WPCW_quizzes_getQuizDetails( $quizID, false, false, false );
		if ( $quizDetails ) {
			$wpdb->query( $wpdb->prepare( "
				DELETE FROM $wpcwdb->quiz_qs_mapping
				WHERE parent_quiz_id = %d
			", $quizDetails->quiz_id ) );
			$wpdb->query( $wpdb->prepare( "
				DELETE FROM $wpcwdb->user_progress_quiz
				WHERE quiz_id = %d
			", $quizDetails->quiz_id ) );
			$wpdb->query( $wpdb->prepare( "
				DELETE FROM $wpcwdb->quiz
				WHERE quiz_id = %d
			", $quizDetails->quiz_id ) );
			$page->showMessage( sprintf( __( 'The quiz \'%s\' was successfully deleted.', 'wp-courseware' ), $quizDetails->quiz_title ) );
		} 
	} 
}
function WPCW_quizzes_handleQuizDeletion ( $ page ) { global $ wpcwdb , $ wpdb ; $ wpdb -> show_errors ( ) ; if ( isset ( $ _GET [ 'action' ] ) && $ _GET [ 'action' ] == 'delete' && isset ( $ _GET [ 'quiz_id' ] ) ) { $ quizID = $ _GET [ 'quiz_id' ] ; $ quizDetails = WPCW_quizzes_getQuizDetails ( $ quizID , false , false , false ) ; if ( $ quizDetails ) { $ wpdb -> query ( $ wpdb -> prepare ( " 
				DELETE FROM  $ wpcwdb -> quiz_qs_mapping 
				WHERE parent_quiz_id = %d
			 " , $ quizDetails -> quiz_id ) ) ; $ wpdb -> query ( $ wpdb -> prepare ( " 
				DELETE FROM  $ wpcwdb -> user_progress_quiz 
				WHERE quiz_id = %d
			 " , $ quizDetails -> quiz_id ) ) ; $ wpdb -> query ( $ wpdb -> prepare ( " 
				DELETE FROM  $ wpcwdb -> quiz 
				WHERE quiz_id = %d
			 " , $ quizDetails -> quiz_id ) ) ; $ page -> showMessage ( sprintf ( __ ( 'The quiz \'%s\' was successfully deleted.' , 'wp-courseware' ) , $ quizDetails -> quiz_title ) ) ; } } }
Handle the quiz deletion from the summary page.
Handle the quiz deletion from the summary page .
// Check that the quiz exists and deletion has been requested // Only do deletion if quiz details are valid. // Delete quiz questions from question map // Delete user progress // Finally delete quiz itself // end of if $quizDetails // end of check for deletion action