Skip to content

Commit

Permalink
Fix a bug in final grades when users submit more than one piece of work
Browse files Browse the repository at this point in the history
(some grades were appearing as zero); workshop_user_outline now returns
number of submissions and date of last submission.
  • Loading branch information
rkingdon committed Sep 8, 2003
1 parent 266d6b7 commit 42fd37e
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions mod/workshop/lib.php
Expand Up @@ -167,12 +167,13 @@ function workshop_delete_instance($id) {
} }


function workshop_user_outline($course, $user, $mod, $workshop) { function workshop_user_outline($course, $user, $mod, $workshop) {
if ($submission = workshop_get_student_submission($workshop, $user)) { if ($submissions = workshop_get_user_submissions($workshop, $user)) {
$result->info = $submission->title; $result->info = count($submissions)." ".get_string("submissions", "workshop");
if ($submission->finalgrade) { // workshop_get_user_submissions returns the newest one first
$result->info .= ", ".get_string("grade").": $submission->finalgrade"; foreach ($submissions as $submission) {
} $result->time = $submission->timecreated;
$result->time = $submission->timecreated; break;
}
return $result; return $result;
} }
return NULL; return NULL;
Expand Down Expand Up @@ -632,9 +633,15 @@ function workshop_print_recent_activity($course, $isteacher, $timestart) {


function workshop_grades($workshopid) { function workshop_grades($workshopid) {
/// Must return an array of grades, indexed by user, and a max grade. /// Must return an array of grades, indexed by user, and a max grade.
global $CFG;


$return->grades = get_records_select_menu("workshop_submissions", if ($bestsubmissions = get_records_sql("SELECT userid, max(finalgrade) finalgrade FROM
"workshopid = $workshopid", "", "userid, finalgrade"); {$CFG->prefix}workshop_submissions WHERE workshopid = $workshopid GROUP
BY userid")) {
foreach ($bestsubmissions as $bestgrade) {
$return->grades[$bestgrade->userid] = $bestgrade->finalgrade;
}
}
$return->maxgrade = get_field("workshop", "grade", "id", "$workshopid"); $return->maxgrade = get_field("workshop", "grade", "id", "$workshopid");
return $return; return $return;
} }
Expand Down Expand Up @@ -955,8 +962,9 @@ function workshop_count_user_assessments_done($workshop, $user) {




function workshop_count_user_submissions($workshop, $user) { function workshop_count_user_submissions($workshop, $user) {
// returns the number of submissions make by this user // returns the number of (real) submissions make by this user
return count_records("workshop_submissions", "workshopid", $workshop->id, "userid", $user->id); return count_records_select("workshop_submissions", "workshopid = $workshop->id AND
userid = $user->id AND timecreated > 0");
} }




Expand Down Expand Up @@ -1222,9 +1230,10 @@ function workshop_get_user_assessments($workshop, $user) {




function workshop_get_user_submissions($workshop, $user) { function workshop_get_user_submissions($workshop, $user) {
// return submission of user newest first, oldest last // return real submissions of user newest first, oldest last. Ignores the dummy submissions
return get_records_select("workshop_submissions ", // which get created to hold the final grades for users for make no submissions)
"workshopid = $workshop->id AND userid = $user->id", "timecreated DESC" ); return get_records_select("workshop_submissions", "workshopid = $workshop->id AND
userid = $user->id AND timecreated > 0", "timecreated DESC" );
} }




Expand Down

0 comments on commit 42fd37e

Please sign in to comment.