public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/classes/unitfrontend.php
/**
		 * Get the correct answer for a question.
		 *
		 * @param Object $question The question object.
		 * @param Mixed  $providedAnswer If specified, use this to specify the correct answer. Otherwise use the correct answer for the question.
		 *
		 * @return String The answer for the question.
		 */
Get the correct answer for a question.
@param Object $question The question object.
@param Mixed  $providedAnswer If specified, use this to specify the correct answer. Otherwise use the correct answer for the question.

@return String The answer for the question.
Get the correct answer for a question . @param Object $question The question object . @param Mixed $providedAnswer If specified use this to specify the correct answer . Otherwise use the correct answer for the question . @return String The answer for the question .
public function check_quizzes_getCorrectAnswer( $question, $providedAnswer = false ) {
			$correctAnswer = false;
			if ( ! $providedAnswer ) {
				$providedAnswer = $question->question_correct_answer;
			}
			switch ( $question->question_type ) {
				case 'truefalse':
					if ( 'true' == $providedAnswer ) {
						$correctAnswer = __( 'True', 'wp-courseware' );
					} else {
						$correctAnswer = __( 'False', 'wp-courseware' );
					}
					break;
				case 'multi':
					$answerListRaw = WPCW_quizzes_decodeAnswers( $question->question_data_answers );
					$answerIdx     = @unserialize( $providedAnswer );
					if ( ! $answerIdx ) {
						if ( is_array( $providedAnswer ) ) {
							$answerIdx = $providedAnswer;
						} else {
							$answerIdx = array( $providedAnswer );
						}
					}
					$correctAnswer = array();
					foreach ( $answerIdx as $key => $value ) {
						if ( $value >= 0 && $value <= count( $answerListRaw ) && isset( $answerListRaw[ $value ] ) ) {
							$correctAnswer[] = $answerListRaw[ $value ]['answer'];
						}
					}
					break;
			}
			return $correctAnswer;
		}
public function check_quizzes_getCorrectAnswer ( $ question , $ providedAnswer = false ) { $ correctAnswer = false ; if ( ! $ providedAnswer ) { $ providedAnswer = $ question -> question_correct_answer ; } switch ( $ question -> question_type ) { case 'truefalse' : if ( 'true' == $ providedAnswer ) { $ correctAnswer = __ ( 'True' , 'wp-courseware' ) ; } else { $ correctAnswer = __ ( 'False' , 'wp-courseware' ) ; } break ; case 'multi' : $ answerListRaw = WPCW_quizzes_decodeAnswers ( $ question -> question_data_answers ) ; $ answerIdx = @ unserialize ( $ providedAnswer ) ; if ( ! $ answerIdx ) { if ( is_array ( $ providedAnswer ) ) { $ answerIdx = $ providedAnswer ; } else { $ answerIdx = array ( $ providedAnswer ) ; } } $ correctAnswer = array ( ) ; foreach ( $ answerIdx as $ key => $ value ) { if ( $ value >= 0 && $ value <= count ( $ answerListRaw ) && isset ( $ answerListRaw [ $ value ] ) ) { $ correctAnswer [ ] = $ answerListRaw [ $ value ] [ 'answer' ] ; } } break ; } return $ correctAnswer ; }
Get the correct answer for a question.
Get the correct answer for a question .
// Just use true or false if a t/f question // Multiple choice question - so turn list of answers into array // then use 1-indexing to get the text of the result. // Just double check that the selected answer is valid. // 2013-12-06 - Added <= rather than < count for the final answer to accept the final answer. // Because it's 1-indexed, not 0 indexed. // if ($answerIdx >= 0 && $answerIdx <= count($answerListRaw) && isset($answerListRaw[$answerIdx])) { //     $correctAnswer = $answerListRaw[$answerIdx]['answer']; // }