public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/functions.php
/**
 * Calculates the grade for a set of results, taking into account the
 * different types of questions.
 *
 * @since 1.0.0
 *
 * @param array   $quizData The list of quiz results data.
 * @param integer $questionsThatNeedMarking How many questions need marking.
 *
 * @return integer The overall grade for the results.
 */
Calculates the grade for a set of results, taking into account the
different types of questions.



@param array   $quizData The list of quiz results data.
@param integer $questionsThatNeedMarking How many questions need marking.

@return integer The overall grade for the results.
Calculates the grade for a set of results taking into account the different types of questions . @param array $quizData The list of quiz results data . @param integer $questionsThatNeedMarking How many questions need marking . @return integer The overall grade for the results .
function WPCW_quizzes_calculateGradeForQuiz( $quizData, $questionsThatNeedMarking = 0 ) {
	if ( $questionsThatNeedMarking > 0 ) {
		return '-1';
	}
	$questionTotal = 0;
	$gradeTotal    = 0;
	foreach ( $quizData as $questionID => $questionResults ) {
		if ( $questionResults['got_right'] ) {
			if ( $questionResults['got_right'] == 'yes' ) {
				$gradeTotal += 100;
			}
		} else { 
			$gradeTotal += WPCW_arrays_getValue( $questionResults, 'their_grade' );
		}
		$questionTotal ++;
	}
	$grade = 0;
	if ( $questionTotal ) {
		$grade = number_format( $gradeTotal / $questionTotal, 1 );
	}
	return $grade;
}
function WPCW_quizzes_calculateGradeForQuiz ( $ quizData , $ questionsThatNeedMarking = 0 ) { if ( $ questionsThatNeedMarking > 0 ) { return '-1' ; } $ questionTotal = 0 ; $ gradeTotal = 0 ; foreach ( $ quizData as $ questionID => $ questionResults ) { if ( $ questionResults [ 'got_right' ] ) { if ( $ questionResults [ 'got_right' ] == 'yes' ) { $ gradeTotal += 100 ; } } else { $ gradeTotal += WPCW_arrays_getValue ( $ questionResults , 'their_grade' ) ; } $ questionTotal ++ ; } $ grade = 0 ; if ( $ questionTotal ) { $ grade = number_format ( $ gradeTotal / $ questionTotal , 1 ) ; } return $ grade ; }
Calculates the grade for a set of results, taking into account the
 different types of questions.
Calculates the grade for a set of results taking into account the different types of questions .
// It's a truefalse/multi question // Got it right, so add 100%. // It's a graded question. // Making assumption that the grade number exists // Otherwise we'd never get this far as the question still needs marking. // Simple calculation that averages the grade.