public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/admin/functions.php
/**
 * Function that generates a sample CSV file from the database using the relevant course IDs.
 *
 * @since 1.0.0
 */
Function that generates a sample CSV file from the database using the relevant course IDs.
Function that generates a sample CSV file from the database using the relevant course IDs .
function WPCW_data_export_questionImportSample() {
	$current_user = wp_get_current_user();
	if ( ! user_can( $current_user, 'manage_wpcw_settings' ) ) {
		wp_die( __( 'You do not have sufficient permissions to import questions.', 'wp-courseware' ) );
	}
	WPCW_data_export_sendHeaders_CSV( 'wpcw-import-quiz-questions-sample.csv' );
	$out = fopen( 'php://output', 'w' );
	$headings = array(
		'quiz_question',
		'question_type',
		'possible_answers',
		'correct_answer',
		'answer_type',
		'hint',
		'explanation',
		'tags',
		'file_extensions',
	);
	fputcsv( $out, $headings );
	$data = array(
		array(
			'Which of the following are blue?',
			'multi',
			'sky | sea | dirt | trees | grass, and other grass like items',
			'sky | grass, and other grass like items',
			'',
			'Above the clouds and below sea level',
			'The sea and sky are blue.',
			'blue',
			'',
		),
		array(
			'Explain the color of the moon.',
			'open',
			'',
			'',
			'single_line',
			'The moon has bright and dark colors',
			'The moon is bright when lit.',
			'yellow,gray',
			'',
		),
		array(
			'Is the sun purple?',
			'truefalse',
			'',
			'FALSE',
			'',
			'The sun is a bright color.',
			'The sun is orange.',
			'orange',
			'',
		),
		array(
			'Upload a picture of a tree',
			'upload',
			'',
			'',
			'',
			'Any kind of tree',
			'Tree’s are green',
			'green,brown',
			'png,jpg,gif',
		),
	);
	foreach ( $data as $rowData ) {
		if ( ! empty( $rowData ) ) {
			fputcsv( $out, $rowData );
		}
	}
	fclose( $out );
	die();
}
function WPCW_data_export_questionImportSample ( ) { $ current_user = wp_get_current_user ( ) ; if ( ! user_can ( $ current_user , 'manage_wpcw_settings' ) ) { wp_die ( __ ( 'You do not have sufficient permissions to import questions.' , 'wp-courseware' ) ) ; } WPCW_data_export_sendHeaders_CSV ( 'wpcw-import-quiz-questions-sample.csv' ) ; $ out = fopen ( 'php://output' , 'w' ) ; $ headings = array ( 'quiz_question' , 'question_type' , 'possible_answers' , 'correct_answer' , 'answer_type' , 'hint' , 'explanation' , 'tags' , 'file_extensions' , ) ; fputcsv ( $ out , $ headings ) ; $ data = array ( array ( 'Which of the following are blue?' , 'multi' , 'sky | sea | dirt | trees | grass, and other grass like items' , 'sky | grass, and other grass like items' , '' , 'Above the clouds and below sea level' , 'The sea and sky are blue.' , 'blue' , '' , ) , array ( 'Explain the color of the moon.' , 'open' , '' , '' , 'single_line' , 'The moon has bright and dark colors' , 'The moon is bright when lit.' , 'yellow,gray' , '' , ) , array ( 'Is the sun purple?' , 'truefalse' , '' , 'FALSE' , '' , 'The sun is a bright color.' , 'The sun is orange.' , 'orange' , '' , ) , array ( 'Upload a picture of a tree' , 'upload' , '' , '' , '' , 'Any kind of tree' , 'Tree’s are green', 'green,brown' , 'png,jpg,gif' , ) , ) ; foreach ( $ data as $ rowData ) { if ( ! empty ( $ rowData ) ) { fputcsv ( $ out , $ rowData ) ; } } fclose ( $ out ) ; die ( ) ; }
Function that generates a sample CSV file from the database using the relevant course IDs.
Function that generates a sample CSV file from the database using the relevant course IDs .
// Check permissions // Start CSV // The headings // Output Headings // Row Data // Insert Data