Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tidy up return of grades in exercise_grades routine.

  • Loading branch information...
commit d33986dbe6d2b4311937b302e1f35e195c42831a 1 parent d1e5e63
rkingdon authored
Showing with 13 additions and 4 deletions.
  1. +13 −4 mod/exercise/lib.php
View
17 mod/exercise/lib.php
@@ -345,7 +345,7 @@ function exercise_grades($exerciseid) {
// first get the teacher's grade for the best submission
if ($bestgrades = exercise_get_best_submission_grades($exercise)) {
foreach ($bestgrades as $grade) {
- $return->grades[$grade->userid] = $grade->grade *
+ $usergrade[$grade->userid] = $grade->grade *
$EXERCISE_FWEIGHTS[$exercise->teacherweight] * $scaling;
}
}
@@ -353,7 +353,7 @@ function exercise_grades($exerciseid) {
else { // use mean values
if ($meangrades = exercise_get_mean_submission_grades($exercise)) {
foreach ($meangrades as $grade) {
- $return->grades[$grade->userid] = $grade->grade *
+ $usergrade[$grade->userid] = $grade->grade *
$EXERCISE_FWEIGHTS[$exercise->teacherweight] * $scaling;
}
}
@@ -362,12 +362,18 @@ function exercise_grades($exerciseid) {
if ($assessments = exercise_get_teacher_submission_assessments($exercise)) {
foreach ($assessments as $assessment) {
// add the grading grade if the student's work has been assessed
- if (isset($return->grades[$assessment->userid])) {
- $return->grades[$assessment->userid] += $assessment->gradinggrade *
+ if (isset($usergrade[$assessment->userid])) {
+ $usergrade[$assessment->userid] += $assessment->gradinggrade *
$EXERCISE_FWEIGHTS[$exercise->gradingweight] * $scaling * 100.0 / COMMENTSCALE;
}
}
}
+ // tidy the numbers and set up the return array
+ if (isset($usergrade)) {
+ foreach ($usergrade as $userid => $g) {
+ $return->grades[$userid] = number_format($g, 1);
+ }
+ }
$return->maxgrade = $exercise->grade;
return $return;
@@ -1088,8 +1094,10 @@ function exercise_get_mean_grade($submission) {
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_mean_submission_grades($exercise) {
// Returns the mean grades of students' submissions
+// ignores hot assessments
global $CFG;
+ $timenow = time();
$grades = get_records_sql("SELECT DISTINCT u.userid, AVG(a.grade) grade FROM
{$CFG->prefix}exercise_submissions s,
{$CFG->prefix}exercise_assessments a, {$CFG->prefix}user_students u
@@ -1097,6 +1105,7 @@ function exercise_get_mean_submission_grades($exercise) {
AND s.userid = u.userid
AND s.exerciseid = $exercise->id
AND a.submissionid = s.id
+ AND a.timecreated < $timenow
GROUP BY u.userid");
return $grades;
}
Please sign in to comment.
Something went wrong with that request. Please try again.