public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/pages/page-user-progress.php
/**
 * Handles saving what the admin wants to do for the user next.
 *
 * @since 1.0.0
 */
Handles saving what the admin wants to do for the user next.
Handles saving what the admin wants to do for the user next .
function WPCW_showPage_UserProgess_quizAnswers_whatsNext_savePreferences( $quizDetails, $results, $page, $userID, $unitID ) {
	if ( isset( $_POST['failed_quiz_next_action'] ) && $_POST['failed_quiz_next_action'] ) {
		global $wpdb, $wpcwdb;
		$wpdb->show_errors();
		$userNextAction = WPCW_arrays_getValue( $_POST, 'wpcw_user_continue_action' );
		$userRetakeMsg  = filter_var( WPCW_arrays_getValue( $_POST, 'wpcw_user_progress_failed_reason' ), FILTER_SANITIZE_STRING );
		if ( ! in_array( $userNextAction, array( 'retake_quiz', 'progress_anyway' ) ) ) {
			return $results;
		}
		$SQL = $wpdb->prepare( "
		    	UPDATE $wpcwdb->user_progress_quiz
		    	  SET quiz_next_step_type = '%s',
		    	      quiz_next_step_msg = %s
		    	WHERE user_id = %d
		    	  AND unit_id = %d
		    	  AND quiz_id = %d
		    	ORDER BY quiz_attempt_id DESC
		    	LIMIT 1
	   		",
			$userNextAction, $userRetakeMsg,
			$userID, $unitID, $quizDetails->quiz_id
		);
		$wpdb->query( $SQL );
		$results->quiz_next_step_type = $userNextAction;
		$results->quiz_next_step_msg  = $userRetakeMsg;
		switch ( $userNextAction ) {
			case 'retake_quiz':
				$results->extraEmailDetail = __( 'Since you didn\'t pass the quiz, the instructor has asked that you re-take this quiz.', 'wp-courseware' );
				if ( $userRetakeMsg ) {
					$results->extraEmailDetail .= "\n\n" . $userRetakeMsg;
				}
				break;
			case 'progress_anyway':
				$results->extraEmailDetail = __( 'Although you didn\'t pass the quiz, the instructor is allowing you to continue.', 'wp-courseware' );
				WPCW_units_saveUserProgress_Complete( $userID, $unitID );
				do_action( 'wpcw_user_completed_unit', $userID, $unitID, WPCW_units_getAssociatedParentData( $unitID ) );
				break;
		}
		$results->sendOutEmails = true;
	}
	$results->quiz_has_just_been_graded = true;
	return $results;
}
function WPCW_showPage_UserProgess_quizAnswers_whatsNext_savePreferences ( $ quizDetails , $ results , $ page , $ userID , $ unitID ) { if ( isset ( $ _POST [ 'failed_quiz_next_action' ] ) && $ _POST [ 'failed_quiz_next_action' ] ) { global $ wpdb , $ wpcwdb ; $ wpdb -> show_errors ( ) ; $ userNextAction = WPCW_arrays_getValue ( $ _POST , 'wpcw_user_continue_action' ) ; $ userRetakeMsg = filter_var ( WPCW_arrays_getValue ( $ _POST , 'wpcw_user_progress_failed_reason' ) , FILTER_SANITIZE_STRING ) ; if ( ! in_array ( $ userNextAction , array ( 'retake_quiz' , 'progress_anyway' ) ) ) { return $ results ; } $ SQL = $ wpdb -> prepare ( " 
		    	UPDATE  $ wpcwdb -> user_progress_quiz 
		    	  SET quiz_next_step_type = '%s',
		    	      quiz_next_step_msg = %s
		    	WHERE user_id = %d
		    	  AND unit_id = %d
		    	  AND quiz_id = %d
		    	ORDER BY quiz_attempt_id DESC
		    	LIMIT 1
	   		 " , $ userNextAction , $ userRetakeMsg , $ userID , $ unitID , $ quizDetails -> quiz_id ) ; $ wpdb -> query ( $ SQL ) ; $ results -> quiz_next_step_type = $ userNextAction ; $ results -> quiz_next_step_msg = $ userRetakeMsg ; switch ( $ userNextAction ) { case 'retake_quiz' : $ results -> extraEmailDetail = __ ( 'Since you didn\'t pass the quiz, the instructor has asked that you re-take this quiz.' , 'wp-courseware' ) ; if ( $ userRetakeMsg ) { $ results -> extraEmailDetail .= " \n \n " . $ userRetakeMsg ; } break ; case 'progress_anyway' : $ results -> extraEmailDetail = __ ( 'Although you didn\'t pass the quiz, the instructor is allowing you to continue.' , 'wp-courseware' ) ; WPCW_units_saveUserProgress_Complete ( $ userID , $ unitID ) ; do_action ( 'wpcw_user_completed_unit' , $ userID , $ unitID , WPCW_units_getAssociatedParentData ( $ unitID ) ) ; break ; } $ results -> sendOutEmails = true ; } $ results -> quiz_has_just_been_graded = true ; return $ results ; }
Handles saving what the admin wants to do for the user next.
Handles saving what the admin wants to do for the user next .
// Admin wants to save the next action to this progress. // Check action is valid. Abort if not // Update the progress item // Need to update the results object for use later. // User needs to retake the course. // User is allowed to progress // Mark the unit as completed. // Unit complete, check if course/module is complete too. // Tell code to send out emails