mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 18:06:51 +02:00
Merge branch 'MDL-28226' of git://github.com/timhunt/moodle
This commit is contained in:
commit
c04b098343
1 changed files with 8 additions and 12 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue