Merge branch 'MDL-28226_21' of git://github.com/timhunt/moodle into MOODLE_21_STABLE
This commit is contained in:
+8
-12
@@ -544,25 +544,21 @@ function quiz_save_best_grade($quiz, $userid = null, $attempts = array()) {
|
||||
/**
|
||||
* Calculate the overall grade for a quiz given a number of attempts by a particular user.
|
||||
*
|
||||
* @return float The overall grade
|
||||
* @param object $quiz The quiz for which the best grade is to be calculated
|
||||
* @param array $attempts An array of all the attempts of the user at the quiz
|
||||
* @param object $quiz the quiz settings object.
|
||||
* @param array $attempts an array of all the user's attempts at this quiz in order.
|
||||
* @return float the overall grade
|
||||
*/
|
||||
function quiz_calculate_best_grade($quiz, $attempts) {
|
||||
|
||||
switch ($quiz->grademethod) {
|
||||
|
||||
case QUIZ_ATTEMPTFIRST:
|
||||
foreach ($attempts as $attempt) {
|
||||
return $attempt->sumgrades;
|
||||
}
|
||||
return $final;
|
||||
$firstattempt = reset($attempts);
|
||||
return $firstattempt->sumgrades;
|
||||
|
||||
case QUIZ_ATTEMPTLAST:
|
||||
foreach ($attempts as $attempt) {
|
||||
$final = $attempt->sumgrades;
|
||||
}
|
||||
return $final;
|
||||
$lastattempt = end($attempts);
|
||||
return $lastattempt->sumgrades;
|
||||
|
||||
case QUIZ_GRADEAVERAGE:
|
||||
$sum = 0;
|
||||
@@ -578,8 +574,8 @@ function quiz_calculate_best_grade($quiz, $attempts) {
|
||||
}
|
||||
return $sum / $count;
|
||||
|
||||
default:
|
||||
case QUIZ_GRADEHIGHEST:
|
||||
default:
|
||||
$max = null;
|
||||
foreach ($attempts as $attempt) {
|
||||
if ($attempt->sumgrades > $max) {
|
||||
|
||||
Reference in New Issue
Block a user