public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/classes/unitfrontend.php
/**
		 * In single-page quiz mode, check the answers that have been provided and update the status in the
		 * database.
		 *
		 * @param Array $potentialAnswers The potential answers that need checking.
		 *
		 * @return Boolean Returns true when we have all of our answers, and we're allowed to carry on for grading.
		 */
In single-page quiz mode, check the answers that have been provided and update the status in the
database.

@param Array $potentialAnswers The potential answers that need checking.

@return Boolean Returns true when we have all of our answers, and we're allowed to carry on for grading.
In single - page quiz mode check the answers that have been provided and update the status in the database . @param Array $potentialAnswers The potential answers that need checking . @return Boolean Returns true when we have all of our answers and we ' re allowed to carry on for grading .
public function check_quizzes_canWeContinue_checkAnswersFromOnePageQuiz( $potentialAnswers ) {
			$resultsList = array(
				'answer_list'       => array(),
				'wrong_answer_list' => array(),
				'error_answer_list' => array(),
			);
			$resultsList = $this->check_quizzes_canWeContinue_extractAnswerData( $potentialAnswers );
			$this->unchecked_QuizAnswersToGrade = $resultsList;
			if ( 'expired' == WPCW_arrays_getValue( $potentialAnswers, 'timerexpired' ) ) {
				return true;
			}
			$answerCountSoFar = count( $resultsList['answer_list'] );
			if ( $this->unitQuizDetails->want_uploads ) {
				foreach ( $this->unitQuizDetails->questions as $questionID => $questionDetails ) {
					if ( 'upload' == $questionDetails->question_type && ! isset( $resultsList['answer_list'][ $questionID ] ) && isset( $this->unitQuizProgress->quiz_data[ $questionID ] ) ) {
						$this->unchecked_QuizAnswersToGrade['answer_list'][ $questionID ] = $this->unitQuizProgress->quiz_data[ $questionID ]['their_answer_raw'];
						++ $answerCountSoFar;
					}
				}
			}
			if ( $this->unitQuizDetails->questions && $answerCountSoFar < count( $this->unitQuizDetails->questions ) && ! $this->check_timers_doWeHaveAnActiveTimer_thatHasExpired() ) {
				echo self::message_createMessage_error( __( 'Please provide an answer for all of the questions on this page.', 'wp-courseware' ) );
				return false;
			}
			return true;
		}
public function check_quizzes_canWeContinue_checkAnswersFromOnePageQuiz ( $ potentialAnswers ) { $ resultsList = array ( 'answer_list' => array ( ) , 'wrong_answer_list' => array ( ) , 'error_answer_list' => array ( ) , ) ; $ resultsList = $ this -> check_quizzes_canWeContinue_extractAnswerData ( $ potentialAnswers ) ; $ this -> unchecked_QuizAnswersToGrade = $ resultsList ; if ( 'expired' == WPCW_arrays_getValue ( $ potentialAnswers , 'timerexpired' ) ) { return true ; } $ answerCountSoFar = count ( $ resultsList [ 'answer_list' ] ) ; if ( $ this -> unitQuizDetails -> want_uploads ) { foreach ( $ this -> unitQuizDetails -> questions as $ questionID => $ questionDetails ) { if ( 'upload' == $ questionDetails -> question_type && ! isset ( $ resultsList [ 'answer_list' ] [ $ questionID ] ) && isset ( $ this -> unitQuizProgress -> quiz_data [ $ questionID ] ) ) { $ this -> unchecked_QuizAnswersToGrade [ 'answer_list' ] [ $ questionID ] = $ this -> unitQuizProgress -> quiz_data [ $ questionID ] [ 'their_answer_raw' ] ; ++ $ answerCountSoFar ; } } } if ( $ this -> unitQuizDetails -> questions && $ answerCountSoFar < count ( $ this -> unitQuizDetails -> questions ) && ! $ this -> check_timers_doWeHaveAnActiveTimer_thatHasExpired ( ) ) { echo self :: message_createMessage_error ( __ ( 'Please provide an answer for all of the questions on this page.' , 'wp-courseware' ) ) ; return false ; } return true ; }
In single-page quiz mode, check the answers that have been provided and update the status in the
 database.
In single - page quiz mode check the answers that have been provided and update the status in the database .
// ### 1 - Extract a list of actual answers from the potential answers. // ### 2 - Save the progress so far. This updates the internal progress variable too. No grading goes on // but it stores the answers to be graded in the next bit of code. // ### 3 - Has the timer expired? If so, then do no further checking and return true too allow the code // to continue // ### 4 - See if we expect uploads, because that may explain the difference in answers v.s. expected answer counts if we're // paging and now on the final review page. Uploads are a special case, and we add any missing ones back from what's been saved. // Got an upload question where the answer is not in the final count // Update internal variable of data we have, as we'll need this for saving // ### 5 - Check that we have enough answers given how many questions there are. // If there are not enough answers, then re-render the form with the answered questions // marked, and highlight the fields that have errors. // Error - not all questions are answered // This will trigger the form to show again with missing answers, using the ansers the user provided // through what has been stored in $this->unchecked_QuizAnswersToGrade // User may not continue - as quiz is not complete.