From 73963212492faf25ec34fef01ca2495daeb89c9d Mon Sep 17 00:00:00 2001 From: toyomoyo Date: Thu, 27 Apr 2006 04:12:58 +0000 Subject: [PATCH] fix for 4976 --- mod/assignment/lib.php | 49 +++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index bb6105c662..ce70c0ef41 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -450,6 +450,16 @@ class assignment_base { if (! delete_records('event', 'modulename', 'assignment', 'instance', $assignment->id)) { $result = false; } + + // Get the cm id to properly clean up the grade_items for this assignment + // bug 4976 + if (! $cm = get_record('modules', 'name', 'assignment')) { + $result = false; + } else { + if (! delete_records('grade_item', 'modid', $cm->id, 'cminstance', $assignment->id)) { + $result = false; + } + } return $result; } @@ -545,9 +555,9 @@ class assignment_base { //IE needs proper header with encoding print_header(get_string('feedback', 'assignment').':'.format_string($this->assignment->name)); print_heading(get_string('changessaved')); - $this->update_main_listing($submission); + print $this->update_main_listing($submission); } - close_window(); + //close_window(); break; case 'single': // We are in a popup window displaying submission @@ -650,11 +660,11 @@ class assignment_base { //first we save the current changes if ($submission = $this->process_feedback()) { //print_heading(get_string('changessaved')); - $this->update_main_listing($submission); + $extra_javascript = $this->update_main_listing($submission); } //then we display the next submission - $this->display_submission(); + $this->display_submission($extra_javascript); break; default: @@ -671,18 +681,20 @@ class assignment_base { function update_main_listing($submission) { global $SESSION; + $output = ''; + $perpage = get_user_preferences('assignment_perpage', 10); $quickgrade = get_user_preferences('assignment_quickgrade', 0); /// Run some Javascript to try and update the parent page - echo '"; - flush(); + $output .= "\n-->\n"; + return $output; } /** @@ -764,7 +776,7 @@ class assignment_base { * to process submissions before they are graded * This method gets its arguments from the page parameters userid and offset */ - function display_submission() { + function display_submission($extra_javascript = '') { global $CFG; @@ -823,6 +835,9 @@ class assignment_base { print_header(get_string('feedback', 'assignment').':'.fullname($user, true).':'.format_string($this->assignment->name)); + /// Print any extra javascript needed for saveandnext + echo $extra_javascript; + ///SOme javascript to help with setting up >.> echo '