public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/pages/page-user-progress.php
/**
 * Function that shows details to the admin telling them what to do next.
 *
 * @since 1.0.0
 */
Function that shows details to the admin telling them what to do next.
Function that shows details to the admin telling them what to do next .
function WPCW_showPage_UserProgess_quizAnswers_whatsNext( $quizDetails, $results, $page, $userID, $unitID ) {
	if ( $results->quiz_needs_marking > 0 ) {
		printf( '<div id="message" class="wpcw_msg wpcw_msg_info"><span class="wpcw_icon_pending"><b>%s</b></span></div>',
			__( 'This quiz has questions that need grading.', 'wp-courseware' )
		);
	} else {
		if ( 'quiz_block' == $quizDetails->quiz_type && $results->quiz_grade < $quizDetails->quiz_pass_mark ) {
			$showAdminProgressForm  = true;
			$showAdminMessageCustom = false;
			if ( $results->quiz_next_step_type ) {
				switch ( $results->quiz_next_step_type ) {
					case 'progress_anyway':
						printf( '<div id="message" class="wpcw_msg wpcw_msg_info">%s</span></div>',
							__( 'You have allowed the user to <b>progress anyway</b>, despite failing the quiz.', 'wp-courseware' )
						);
						$showAdminProgressForm = false;
						break;
					case 'retake_quiz':
						printf( '<div id="message" class="wpcw_msg wpcw_msg_info">%s</span></div>',
							__( 'You have requested that the user <b>re-takes the quiz</b>.', 'wp-courseware' )
						);
						$showAdminProgressForm = false;
						break;
					case 'retake_waiting':
						printf( '<div id="message" class="wpcw_msg wpcw_msg_info">%s</span></div>',
							__( 'The user has requested a retake, but they have not yet completed the quiz.', 'wp-courseware' )
						);
						$showAdminProgressForm = false;
						break;
					case 'quiz_fail_no_retakes':
						$showAdminMessageCustom = __( 'The user has <b>exhausted all of their retakes</b>.', 'wp-courseware' );
						$showAdminProgressForm  = true;
						break;
				}
			}
			if ( $showAdminProgressForm ) {
				$attempts_taken  = WPCW_quizzes_getUserResultsForQuiz( $userID, $unitID, $quizDetails->quiz_id );
				$unitQuizDetails = WPCW_quizzes_getAssociatedQuizForUnit( $unitID, true, $userID );
				printf( '<div class="wpcw_user_progress_failed"><form method="POST">' );
				printf( '<div id="message" class="wpcw_msg wpcw_msg_error">%s %s</span></div>',
					$showAdminMessageCustom, __( 'Since this is a <b>blocking quiz</b>, and the user has <b>failed</b>, what would you like to do?', 'wp-courseware' )
				);
				printf( '
					<div class="wpcw_user_progress_failed_next_action">
						<label><input type="radio" name="wpcw_user_continue_action" class="wpcw_next_action_progress_anyway" value="progress_anyway" checked="checked" /> <span><b>%s</b> %s</span></label><br/>
					',
					__( 'Allow the user to continue anyway.', 'wp-courseware' ),
					__( ' (User is emailed saying they can continue)', 'wp-courseware' )
				);
				if ( $attempts_taken->attempt_count >= $unitQuizDetails->quiz_attempts_allowed && $unitQuizDetails->quiz_attempts_allowed != - 1 ) {
					printf( '
							<label><input type="radio" name="wpcw_user_continue_action" class="wpcw_next_action_retake_quiz" value="retake_quiz" /> <span><b>%s</b> %s</span></label>
						',
						__( 'Allow the user one more attempt.', 'wp-courseware' ),
						__( ' (User is emailed saying they need to re-take the quiz)', 'wp-courseware' )
					);
				} else {
					printf( '
						<label><input type="radio" name="wpcw_user_continue_action" class="wpcw_next_action_retake_quiz" value="retake_quiz" /> <span><b>%s</b> %s</span></label>
					',
						__( 'Require the user to re-take the quiz.', 'wp-courseware' ),
						__( ' (User is emailed saying they need to re-take the quiz)', 'wp-courseware' )
					);
				}
				printf( '
					</div>
					<div class="wpcw_user_progress_failed_reason" style="display: none;">
						<label><b>%s</b></label><br/>
						<textarea name="wpcw_user_progress_failed_reason"></textarea><br/>
						<small>%s</small>
					</div>
					<div class="wpcw_user_progress_failed_btns">
						<input type="submit" name="failed_quiz_next_action" value="%s" class="button-primary" />
					</div>
				',
					__( 'Require the user to re-take the quiz.', 'wp-courseware' ),
					__( ' (User is emailed saying they need to re-take the quiz)', 'wp-courseware' ),
					__( 'Custom Message:', 'wp-courseware' ),
					__( 'Custom message for the user that\'s sent to the user when asking them to retake the quiz.', 'wp-courseware' ),
					__( 'Save Preference', 'wp-courseware' )
				);
				printf( '</form></div>' );
			}
		}
	}
}
function WPCW_showPage_UserProgess_quizAnswers_whatsNext ( $ quizDetails , $ results , $ page , $ userID , $ unitID ) { if ( $ results -> quiz_needs_marking > 0 ) { printf ( '<div id="message" class="wpcw_msg wpcw_msg_info"><span class="wpcw_icon_pending"><b>%s</b></span></div>' , __ ( 'This quiz has questions that need grading.' , 'wp-courseware' ) ) ; } else { if ( 'quiz_block' == $ quizDetails -> quiz_type && $ results -> quiz_grade < $ quizDetails -> quiz_pass_mark ) { $ showAdminProgressForm = true ; $ showAdminMessageCustom = false ; if ( $ results -> quiz_next_step_type ) { switch ( $ results -> quiz_next_step_type ) { case 'progress_anyway' : printf ( '<div id="message" class="wpcw_msg wpcw_msg_info">%s</span></div>' , __ ( 'You have allowed the user to <b>progress anyway</b>, despite failing the quiz.' , 'wp-courseware' ) ) ; $ showAdminProgressForm = false ; break ; case 'retake_quiz' : printf ( '<div id="message" class="wpcw_msg wpcw_msg_info">%s</span></div>' , __ ( 'You have requested that the user <b>re-takes the quiz</b>.' , 'wp-courseware' ) ) ; $ showAdminProgressForm = false ; break ; case 'retake_waiting' : printf ( '<div id="message" class="wpcw_msg wpcw_msg_info">%s</span></div>' , __ ( 'The user has requested a retake, but they have not yet completed the quiz.' , 'wp-courseware' ) ) ; $ showAdminProgressForm = false ; break ; case 'quiz_fail_no_retakes' : $ showAdminMessageCustom = __ ( 'The user has <b>exhausted all of their retakes</b>.' , 'wp-courseware' ) ; $ showAdminProgressForm = true ; break ; } } if ( $ showAdminProgressForm ) { $ attempts_taken = WPCW_quizzes_getUserResultsForQuiz ( $ userID , $ unitID , $ quizDetails -> quiz_id ) ; $ unitQuizDetails = WPCW_quizzes_getAssociatedQuizForUnit ( $ unitID , true , $ userID ) ; printf ( '<div class="wpcw_user_progress_failed"><form method="POST">' ) ; printf ( '<div id="message" class="wpcw_msg wpcw_msg_error">%s %s</span></div>' , $ showAdminMessageCustom , __ ( 'Since this is a <b>blocking quiz</b>, and the user has <b>failed</b>, what would you like to do?' , 'wp-courseware' ) ) ; printf ( '
					<div class="wpcw_user_progress_failed_next_action">
						<label><input type="radio" name="wpcw_user_continue_action" class="wpcw_next_action_progress_anyway" value="progress_anyway" checked="checked" /> <span><b>%s</b> %s</span></label><br/>
					' , __ ( 'Allow the user to continue anyway.' , 'wp-courseware' ) , __ ( ' (User is emailed saying they can continue)' , 'wp-courseware' ) ) ; if ( $ attempts_taken -> attempt_count >= $ unitQuizDetails -> quiz_attempts_allowed && $ unitQuizDetails -> quiz_attempts_allowed != - 1 ) { printf ( '
							<label><input type="radio" name="wpcw_user_continue_action" class="wpcw_next_action_retake_quiz" value="retake_quiz" /> <span><b>%s</b> %s</span></label>
						' , __ ( 'Allow the user one more attempt.' , 'wp-courseware' ) , __ ( ' (User is emailed saying they need to re-take the quiz)' , 'wp-courseware' ) ) ; } else { printf ( '
						<label><input type="radio" name="wpcw_user_continue_action" class="wpcw_next_action_retake_quiz" value="retake_quiz" /> <span><b>%s</b> %s</span></label>
					' , __ ( 'Require the user to re-take the quiz.' , 'wp-courseware' ) , __ ( ' (User is emailed saying they need to re-take the quiz)' , 'wp-courseware' ) ) ; } printf ( '
					</div>

					<div class="wpcw_user_progress_failed_reason" style="display: none;">
						<label><b>%s</b></label><br/>
						<textarea name="wpcw_user_progress_failed_reason"></textarea><br/>
						<small>%s</small>
					</div>

					<div class="wpcw_user_progress_failed_btns">
						<input type="submit" name="failed_quiz_next_action" value="%s" class="button-primary" />
					</div>
				' , __ ( 'Require the user to re-take the quiz.' , 'wp-courseware' ) , __ ( ' (User is emailed saying they need to re-take the quiz)' , 'wp-courseware' ) , __ ( 'Custom Message:' , 'wp-courseware' ) , __ ( 'Custom message for the user that\'s sent to the user when asking them to retake the quiz.' , 'wp-courseware' ) , __ ( 'Save Preference' , 'wp-courseware' ) ) ; printf ( '</form></div>' ) ; } } } }
Function that shows details to the admin telling them what to do next.
Function that shows details to the admin telling them what to do next .
// Tell admin still questions that need marking // Show the form only if the quiz is blocking and they've failed. // Show admin which method was selected. // No need to show progress form if there are attempts left. Also no need to show for unlimited attemps. // if ($quizDetails->quiz_attempts_allowed > $results->attempt_count || $quizDetails->quiz_attempts_allowed == -1){ // 	$showAdminProgressForm = false; // } // Next step has not been specified, allow the admin to choose one. // Show the main message or a custom message from above. //if ($results->quiz_next_step_type == 'quiz_fail_no_retakes'){