public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/classes/unitfrontend.php
/**
		 * Function called to work out what the pass status details are for this quiz.
		 */
Function called to work out what the pass status details are for this quiz.
Function called to work out what the pass status details are for this quiz .
public function check_quizzes_workoutQuizPassStatusDetails() {
			$rtnDetails = array(
				'error_mode' => false,
			);
			if ( $this->check_quizzes_validQuizDetails() &&
			     $this->unitQuizProgress &&
			     'survey' != $this->unitQuizDetails->quiz_type ) {
				$errorMode = false;
				if ( $this->unitQuizProgress->quiz_needs_marking == 0 ) {
					$rtnDetails['button_dl_results_url'] = apply_filters( 'wpcw_results_generated_url', add_query_arg( array(
						'page'   => 'wpcw_pdf_create_results',
						'unitid' => $this->unitPost->ID,
						'quizid' => $this->unitQuizDetails->quiz_id,
					), esc_url( site_url( '/' ) ) ) );
					if ( $this->unitQuizDetails->has_open_questions ) {
						$rtnDetails[0]['msg_overall_grade'] = sprintf(
							__( 'Your grade for this quiz is <strong>%s%%</strong>.', 'wp-courseware' ), $this->unitQuizProgress->quiz_grade
						);
					} 
					else {
						$rtnDetails[0]['msg_overall_grade'] = sprintf(
							__( 'You got %1$d out of %2$d questions <strong>(%3$s%%)</strong> correct!', 'wp-courseware' ), $this->unitQuizProgress->quiz_correct_questions, $this->unitQuizProgress->quiz_question_total, $this->unitQuizProgress->quiz_grade
						);
					}
					$attemptCount = $this->unitQuizProgress->attempt_count;
					if ( 'quiz_noblock' == $this->unitQuizDetails->quiz_type ) {
						$rtnDetails[0]['msg_nonblock_completion_status'] = sprintf( __( '%s', 'wp-courseware' ), $this->parentData->course_message_unit_complete );
												if ( $this->check_quizzes_NonBlockingQuizOffersRetakeButton() && $attemptCount > 0 ) {
							$rtnDetails[1]['msg_attempts'] = ( $attemptCount == 1 ? __( 'You have had <strong>1 previous attempt</strong> at this quiz.', 'wp-courseware' ) : sprintf( __( 'You have had <strong>%d previous attempts</strong> at this quiz.', 'wp-courseware' ), $attemptCount )
							);
						}
					} 
					else {
						$rtnDetails[0]['msg_block_pass_grade'] = sprintf( __( 'The pass grade for this quiz is <strong>(%d%%)</strong>', 'wp-courseware' ), $this->unitQuizDetails->quiz_pass_mark );
						if ( $this->check_quizzes_hasUserPassedQuiz() ) {
							$rtnDetails[1]['msg_block_pass_has_passed']               = sprintf( __( 'Congratulations, you have <strong>passed</strong> this quiz!', 'wp-courseware' ), $this->unitQuizDetails->quiz_pass_mark );
							$rtnDetails[1]['msg_block_pass_has_passed_unit_complete'] = sprintf( __( '%s', 'wp-courseware' ), $this->parentData->course_message_unit_complete );
						} else {
							$errorMode                                  = true;
							$rtnDetails[1]['msg_block_pass_has_failed'] = sprintf( __( 'Unfortunately, this means you have <strong>failed</strong> this quiz.', 'wp-courseware' ), $this->unitQuizDetails->quiz_pass_mark );
							if ( 'progress_anyway' == $this->unitQuizProgress->quiz_next_step_type ) {
								$rtnDetails[1]['msg_block_pass_next_action'] = sprintf( __( 'However, the instructor is allowing you to continue anyway.', 'wp-courseware' ), $this->unitQuizDetails->quiz_pass_mark );
							} else {
								$rtnDetails[1]['msg_block_pass_next_action'] = sprintf( __( 'To progress to the next %s, you need to pass this quiz.', 'wp-courseware' ), strtolower( wpcw_get_unit_label() ) );
							}
														$rtnDetails[2]['msg_attempts'] = ( $attemptCount == 1 ? __( 'You have had <strong>1 previous attempt</strong> at this quiz.', 'wp-courseware' ) : sprintf( __( 'You have had <strong>%d previous attempts</strong> at this quiz.', 'wp-courseware' ), $attemptCount )
							);
						}
					} 
					if ( 'on' == $this->unitQuizDetails->quiz_results_by_tag ) {
						$rtnDetails['msg_results_by_tag'] = $this->render_quizzes_questionResultsByTag_forFrontend();
					}
					if ( 'quiz_block' == $this->unitQuizDetails->quiz_type && 
					     'on' == $this->unitQuizDetails->quiz_results_by_timer && 
					     $this->check_timers_doWeHaveTimerDataForThisQuiz()            
					) {
						$rtnDetails['msg_results_by_timer'] = sprintf(
							'<strong>%s:</strong> %s (%s %s)', __( 'Completion Time', 'wp-courseware' ), WPCW_time_convertSecondsToHumanLabel( $this->unitQuizProgress->quiz_completion_time_seconds ), WPCW_time_convertMinutesToHumanLabel( $this->unitQuizDetails->quiz_timer_mode_limit ), __( 'allowed', 'wp-courseware' )
						);
					} 
				} 
				else {
					$courseDetails = WPCW_courses_getCourseDetails( $this->unitQuizDetails->parent_course_id );
					if ( 'quiz_noblock' == $this->unitQuizDetails->quiz_type ) {
						$rtnDetails['msg_noblock_grading'] = sprintf( __( '%s', 'wp-courseware' ), $courseDetails->course_message_quiz_open_grading_non_blocking );
					} else {
						$rtnDetails['msg_block_grading'] = sprintf( __( '%s', 'wp-courseware' ), $courseDetails->course_message_quiz_open_grading_blocking );
					}
				}
				if ( $errorMode ) {
					$rtnDetails['error_mode'] = true;
				}
			} 
			return $rtnDetails;
		}
public function check_quizzes_workoutQuizPassStatusDetails ( ) { $ rtnDetails = array ( 'error_mode' => false , ) ; if ( $ this -> check_quizzes_validQuizDetails ( ) && $ this -> unitQuizProgress && 'survey' != $ this -> unitQuizDetails -> quiz_type ) { $ errorMode = false ; if ( $ this -> unitQuizProgress -> quiz_needs_marking == 0 ) { $ rtnDetails [ 'button_dl_results_url' ] = apply_filters ( 'wpcw_results_generated_url' , add_query_arg ( array ( 'page' => 'wpcw_pdf_create_results' , 'unitid' => $ this -> unitPost -> ID , 'quizid' => $ this -> unitQuizDetails -> quiz_id , ) , esc_url ( site_url ( '/' ) ) ) ) ; if ( $ this -> unitQuizDetails -> has_open_questions ) { $ rtnDetails [ 0 ] [ 'msg_overall_grade' ] = sprintf ( __ ( 'Your grade for this quiz is <strong>%s%%</strong>.' , 'wp-courseware' ) , $ this -> unitQuizProgress -> quiz_grade ) ; } else { $ rtnDetails [ 0 ] [ 'msg_overall_grade' ] = sprintf ( __ ( 'You got %1$d out of %2$d questions <strong>(%3$s%%)</strong> correct!' , 'wp-courseware' ) , $ this -> unitQuizProgress -> quiz_correct_questions , $ this -> unitQuizProgress -> quiz_question_total , $ this -> unitQuizProgress -> quiz_grade ) ; } $ attemptCount = $ this -> unitQuizProgress -> attempt_count ; if ( 'quiz_noblock' == $ this -> unitQuizDetails -> quiz_type ) { $ rtnDetails [ 0 ] [ 'msg_nonblock_completion_status' ] = sprintf ( __ ( '%s' , 'wp-courseware' ) , $ this -> parentData -> course_message_unit_complete ) ; if ( $ this -> check_quizzes_NonBlockingQuizOffersRetakeButton ( ) && $ attemptCount > 0 ) { $ rtnDetails [ 1 ] [ 'msg_attempts' ] = ( $ attemptCount == 1 ? __ ( 'You have had <strong>1 previous attempt</strong> at this quiz.' , 'wp-courseware' ) : sprintf ( __ ( 'You have had <strong>%d previous attempts</strong> at this quiz.' , 'wp-courseware' ) , $ attemptCount ) ) ; } } else { $ rtnDetails [ 0 ] [ 'msg_block_pass_grade' ] = sprintf ( __ ( 'The pass grade for this quiz is <strong>(%d%%)</strong>' , 'wp-courseware' ) , $ this -> unitQuizDetails -> quiz_pass_mark ) ; if ( $ this -> check_quizzes_hasUserPassedQuiz ( ) ) { $ rtnDetails [ 1 ] [ 'msg_block_pass_has_passed' ] = sprintf ( __ ( 'Congratulations, you have <strong>passed</strong> this quiz!' , 'wp-courseware' ) , $ this -> unitQuizDetails -> quiz_pass_mark ) ; $ rtnDetails [ 1 ] [ 'msg_block_pass_has_passed_unit_complete' ] = sprintf ( __ ( '%s' , 'wp-courseware' ) , $ this -> parentData -> course_message_unit_complete ) ; } else { $ errorMode = true ; $ rtnDetails [ 1 ] [ 'msg_block_pass_has_failed' ] = sprintf ( __ ( 'Unfortunately, this means you have <strong>failed</strong> this quiz.' , 'wp-courseware' ) , $ this -> unitQuizDetails -> quiz_pass_mark ) ; if ( 'progress_anyway' == $ this -> unitQuizProgress -> quiz_next_step_type ) { $ rtnDetails [ 1 ] [ 'msg_block_pass_next_action' ] = sprintf ( __ ( 'However, the instructor is allowing you to continue anyway.' , 'wp-courseware' ) , $ this -> unitQuizDetails -> quiz_pass_mark ) ; } else { $ rtnDetails [ 1 ] [ 'msg_block_pass_next_action' ] = sprintf ( __ ( 'To progress to the next %s, you need to pass this quiz.' , 'wp-courseware' ) , strtolower ( wpcw_get_unit_label ( ) ) ) ; } $ rtnDetails [ 2 ] [ 'msg_attempts' ] = ( $ attemptCount == 1 ? __ ( 'You have had <strong>1 previous attempt</strong> at this quiz.' , 'wp-courseware' ) : sprintf ( __ ( 'You have had <strong>%d previous attempts</strong> at this quiz.' , 'wp-courseware' ) , $ attemptCount ) ) ; } } if ( 'on' == $ this -> unitQuizDetails -> quiz_results_by_tag ) { $ rtnDetails [ 'msg_results_by_tag' ] = $ this -> render_quizzes_questionResultsByTag_forFrontend ( ) ; } if ( 'quiz_block' == $ this -> unitQuizDetails -> quiz_type && 'on' == $ this -> unitQuizDetails -> quiz_results_by_timer && $ this -> check_timers_doWeHaveTimerDataForThisQuiz ( ) ) { $ rtnDetails [ 'msg_results_by_timer' ] = sprintf ( '<strong>%s:</strong> %s (%s %s)' , __ ( 'Completion Time' , 'wp-courseware' ) , WPCW_time_convertSecondsToHumanLabel ( $ this -> unitQuizProgress -> quiz_completion_time_seconds ) , WPCW_time_convertMinutesToHumanLabel ( $ this -> unitQuizDetails -> quiz_timer_mode_limit ) , __ ( 'allowed' , 'wp-courseware' ) ) ; } } else { $ courseDetails = WPCW_courses_getCourseDetails ( $ this -> unitQuizDetails -> parent_course_id ) ; if ( 'quiz_noblock' == $ this -> unitQuizDetails -> quiz_type ) { $ rtnDetails [ 'msg_noblock_grading' ] = sprintf ( __ ( '%s' , 'wp-courseware' ) , $ courseDetails -> course_message_quiz_open_grading_non_blocking ) ; } else { $ rtnDetails [ 'msg_block_grading' ] = sprintf ( __ ( '%s' , 'wp-courseware' ) , $ courseDetails -> course_message_quiz_open_grading_blocking ) ; } } if ( $ errorMode ) { $ rtnDetails [ 'error_mode' ] = true ; } } return $ rtnDetails ; }
Function called to work out what the pass status details are for this quiz.
Function called to work out what the pass status details are for this quiz .
// See if we have a quiz for this unit? If so, render it and allow the trainee to complete it. // All questions have been graded. // 1) Add button download //$rtnDetails['button_dl_results_url'] = apply_filters('wpcw_results_generated_url', WPCW_plugin_getPluginPath().'pdf_create_results.php?unitid='.$this->unitPost->ID.'&quizid='.$this->unitQuizDetails->quiz_id); // 2) Show how many they have correct // Open-ended - just show grade. // Just closed questions, show out of message. // 3) Non-Blocking quiz - show say that the unit is now complete. // How many attempts have they now had?
 // 4) Blocking quiz - show if they have passed or failed this quiz. // 5) Show the pass mark. // 6) Show if they have passed or failed. // 6) Show message that they need to pass to progress (as long as admin says that they can't progress anyway). /* translators: %s - Unit Label */ // 7) How many attempts have they now had?
 // end of blocking quiz check // 8) - Show the quiz breakdown by tag (if wanted) // 9) - Show the time needed for this quiz and breakdown of results // Timers only appear on blocking quizzes // User actually wants to show the timer results // Check if there is any timer data to show // end of timer check // Still have questions to grade. // Show the pending message if the quiz needs grading. // Finally - show the message with the right style of box (error or success) // end complex if