public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/classes/unitfrontend.php
/**
		 * Checks all of the answers against the list of questions and return which answers are right or wrong.
		 *
		 * @param Array $checkedAnswerList The answers to check.
		 *
		 * @return Array Lists of the correct and wrong answers. (correct => Array, wrong => Array, 'needs_marking' => Array)
		 */
Checks all of the answers against the list of questions and return which answers are right or wrong.
@param Array $checkedAnswerList The answers to check.

@return Array Lists of the correct and wrong answers.
Checks all of the answers against the list of questions and return which answers are right or wrong . @param Array $checkedAnswerList The answers to check . @return Array Lists of the correct and wrong answers .
public function check_quizzes_checkForCorrectAnswers( $checkedAnswerList ) {
			$resultDetails = array(
				'correct'       => array(),
				'wrong'         => array(),
				'needs_marking' => array(),
			);
			foreach ( $this->unitQuizDetails->questions as $questionID => $question ) {
				switch ( $question->question_type ) {
					case 'truefalse':
						if ( ! isset( $checkedAnswerList[ $questionID ] ) || is_null( $checkedAnswerList[ $questionID ] ) ) {
							$resultDetails['wrong'][ $questionID ] = false;
						} 
						elseif ( $checkedAnswerList[ $questionID ] != $question->question_correct_answer ) {
							$resultDetails['wrong'][ $questionID ] = $checkedAnswerList[ $questionID ];
						} 
						else {
							$resultDetails['correct'][ $questionID ] = $checkedAnswerList[ $questionID ];
						}
						break;
					case 'multi':
						$correctAnswers      = $question->question_correct_answer;
						$correctAnswersArray = @unserialize( $correctAnswers );
						if ( ! $correctAnswersArray ) {
							$correctAnswersArray = array( $correctAnswers );
						}
						$correctAnsFlag = false;
						if ( isset( $checkedAnswerList[ $questionID ] ) && count( $checkedAnswerList[ $questionID ] ) == count( $correctAnswersArray ) ) {
							foreach ( $checkedAnswerList[ $questionID ] as $key => $value ) {
								if ( in_array( $value, $correctAnswersArray ) ) {
									$correctAnsFlag = true;
								} else {
									$correctAnsFlag = false;
									break;
								}
							}
						}
						if ( ! isset( $checkedAnswerList[ $questionID ] ) || is_null( $checkedAnswerList[ $questionID ] ) ) {
							$resultDetails['wrong'][ $questionID ] = false;
						} elseif ( ! $correctAnsFlag ) {
							$resultDetails['wrong'][ $questionID ] = $checkedAnswerList[ $questionID ];
						} 
						else {
							$resultDetails['correct'][ $questionID ] = $checkedAnswerList[ $questionID ];
						}
						break;
					case 'upload':
					case 'open':
						$resultDetails['needs_marking'][ $questionID ] = $checkedAnswerList[ $questionID ];
						break;
				}
			}
			return $resultDetails;
		}
public function check_quizzes_checkForCorrectAnswers ( $ checkedAnswerList ) { $ resultDetails = array ( 'correct' => array ( ) , 'wrong' => array ( ) , 'needs_marking' => array ( ) , ) ; foreach ( $ this -> unitQuizDetails -> questions as $ questionID => $ question ) { switch ( $ question -> question_type ) { case 'truefalse' : if ( ! isset ( $ checkedAnswerList [ $ questionID ] ) || is_null ( $ checkedAnswerList [ $ questionID ] ) ) { $ resultDetails [ 'wrong' ] [ $ questionID ] = false ; } elseif ( $ checkedAnswerList [ $ questionID ] != $ question -> question_correct_answer ) { $ resultDetails [ 'wrong' ] [ $ questionID ] = $ checkedAnswerList [ $ questionID ] ; } else { $ resultDetails [ 'correct' ] [ $ questionID ] = $ checkedAnswerList [ $ questionID ] ; } break ; case 'multi' : $ correctAnswers = $ question -> question_correct_answer ; $ correctAnswersArray = @ unserialize ( $ correctAnswers ) ; if ( ! $ correctAnswersArray ) { $ correctAnswersArray = array ( $ correctAnswers ) ; } $ correctAnsFlag = false ; if ( isset ( $ checkedAnswerList [ $ questionID ] ) && count ( $ checkedAnswerList [ $ questionID ] ) == count ( $ correctAnswersArray ) ) { foreach ( $ checkedAnswerList [ $ questionID ] as $ key => $ value ) { if ( in_array ( $ value , $ correctAnswersArray ) ) { $ correctAnsFlag = true ; } else { $ correctAnsFlag = false ; break ; } } } if ( ! isset ( $ checkedAnswerList [ $ questionID ] ) || is_null ( $ checkedAnswerList [ $ questionID ] ) ) { $ resultDetails [ 'wrong' ] [ $ questionID ] = false ; } elseif ( ! $ correctAnsFlag ) { $ resultDetails [ 'wrong' ] [ $ questionID ] = $ checkedAnswerList [ $ questionID ] ; } else { $ resultDetails [ 'correct' ] [ $ questionID ] = $ checkedAnswerList [ $ questionID ] ; } break ; case 'upload' : case 'open' : $ resultDetails [ 'needs_marking' ] [ $ questionID ] = $ checkedAnswerList [ $ questionID ] ; break ; } } return $ resultDetails ; }
Checks all of the answers against the list of questions and return which answers are right or wrong.
Checks all of the answers against the list of questions and return which answers are right or wrong .
// Run through questions, and check each one for correctness. // Got to check the question type, as can't automatically score the open-ended question types. // Answer is completely empty // Answer is just wrong // If the answer is correct, add the question and answer to the correct list. /*
						 *
						 * Unserializes stored answers string to array and  check that all
						 * the correct answers are selected.
						 *
						 */ /*
						 * flag to check that the selected answer is correct or not in case of
						 * multiple answers for the one question.
						 * @var boolean
						 */ /*
						 * Check is the supplied answers count is equal to the stored answers of the current question.
						 */ /*
							 * Check for each selected answers is correct or not if correct set the
							 * correctAnsFlag to true otherwise  set flag to false and break the loop.
							 * @var [type]
							 */ // Answer is completely empty // If the answer is correct, add the question and answer to the correct list. // Uploaded files and open-ended questions need marking