public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/quiz/multi.php
/**
		 * Extract the list of correct answers for a Multiple Choice question when saving changes to a question,
		 * using the specified answer key to check $_POST.
		 *
		 * @param String $answerListKey The key to use to extract the list of answers.
		 * @param String $answerImageListKey The key to use to extract the list of answer images.
		 *
		 * @return String The list of answers, if found.
		 */
Extract the list of correct answers for a Multiple Choice question when saving changes to a question,
using the specified answer key to check $_POST.

@param String $answerListKey The key to use to extract the list of answers.
@param String $answerImageListKey The key to use to extract the list of answer images.

@return String The list of answers, if found.
Extract the list of correct answers for a Multiple Choice question when saving changes to a question using the specified answer key to check $_POST . @param String $answerListKey The key to use to extract the list of answers . @param String $answerImageListKey The key to use to extract the list of answer images . @return String The list of answers if found .
public static function editSave_extractAnswerList( $answerListKey, $answerImageListKey ) {
			$qAns = array();
			if ( isset( $_POST[ $answerListKey ] ) && is_array( $_POST[ $answerListKey ] ) ) {
				$answersToCheck = $_POST[ $answerListKey ];
				foreach ( $answersToCheck as $idx => $answer ) {
					if ( strlen( trim( $answer ) ) == 0 ) {
					} 
					else {
						$qAns[ $idx ] = array( 'answer' => stripslashes( $answer ) );
					}
				} 
			} 
			if ( count( $qAns ) == 0 ) {
				return false;
			} 
			else {
				if ( isset( $_POST[ $answerImageListKey ] ) && is_array( $_POST[ $answerImageListKey ] ) ) {
					$imagesToCheck = $_POST[ $answerImageListKey ];
					foreach ( $qAns as $idx => $answerDetails ) {
						if ( isset( $imagesToCheck[ $idx ] ) ) {
							$ansImage = trim( substr( strip_tags( $imagesToCheck[ $idx ] ), 0, 300 ) );
							if ( $ansImage ) {
								$qAns[ $idx ]['image'] = $ansImage;
							}
						} 
					}
				} 
			} 
			return $qAns;
		}
public static function editSave_extractAnswerList ( $ answerListKey , $ answerImageListKey ) { $ qAns = array ( ) ; if ( isset ( $ _POST [ $ answerListKey ] ) && is_array ( $ _POST [ $ answerListKey ] ) ) { $ answersToCheck = $ _POST [ $ answerListKey ] ; foreach ( $ answersToCheck as $ idx => $ answer ) { if ( strlen ( trim ( $ answer ) ) == 0 ) { } else { $ qAns [ $ idx ] = array ( 'answer' => stripslashes ( $ answer ) ) ; } } } if ( count ( $ qAns ) == 0 ) { return false ; } else { if ( isset ( $ _POST [ $ answerImageListKey ] ) && is_array ( $ _POST [ $ answerImageListKey ] ) ) { $ imagesToCheck = $ _POST [ $ answerImageListKey ] ; foreach ( $ qAns as $ idx => $ answerDetails ) { if ( isset ( $ imagesToCheck [ $ idx ] ) ) { $ ansImage = trim ( substr ( strip_tags ( $ imagesToCheck [ $ idx ] ) , 0 , 300 ) ) ; if ( $ ansImage ) { $ qAns [ $ idx ] [ 'image' ] = $ ansImage ; } } } } } return $ qAns ; }
Extract the list of correct answers for a Multiple Choice question when saving changes to a question,
 using the specified answer key to check $_POST.
Extract the list of correct answers for a Multiple Choice question when saving changes to a question using the specified answer key to check $_POST .
// ### 1 - Get the list of answers if we have them // Validate each of the answers actually contain something, removing them if not. // 2013-06-10 - Changed from (!trim($answer)) to if (strlen(trim($answer)) == 0) { to allow for // answers that are literally the number '0'. // Do nothing // Clean up each answer if slashes used for escape characters. // end foreach // end if answers are in an array // How many items are there in the list? None? Then make it false. // Got answers, so see if there are any matching images for these answers. // Detected some images to check to see if they're valid. // Only interested in images if we have an answer set up. // See if there's an image for an answer we've validated. // Yep, now just check it's sound and safe. // All is sound, so store the image. // end if (isset($imagesToCheck[$idx])) // end if // end else.