Assignment won't be deleted if following steps:
1. Create an assignment which report to gradebook
2. Go to Gradebook -> Course Grades -> click on "Calculate Course Grades".
3. Go back to assignment -> Edit that assignment created in step 1 -> choose "Do not add assignment to Gradebook" -> Post
4. Go back to gradebook, you will see the assignment is still there, not deleted; whereas it was expected to be deleted if working correctly.
In server log, it throws this error:
2010-06-03 10:46:39,391 INFO http-8084-Processor17 org.sakaiproject.component.gradebook.GradebookExternalAssessmentServiceImpl - External assessment removed from gradebookUid=33c04bbb-ccd4-4f7c-a76d-f8fbf563521e, externalId=/assignment/a/33c04bbb-ccd4-4f7c-a76d-f8fbf563521e/d55eb857-9f5f-43a6-9ec8-0a37ede4187d by userUid=8a5767b8-2991-4ba9-84b4-6b7dc1ddbdb2
2010-06-03 10:46:39,422 WARN http-8084-Processor17 org.hibernate.util.JDBCExceptionReporter - SQL Error: 1451, SQLState: 23000
2010-06-03 10:46:39,422 ERROR http-8084-Processor17 org.hibernate.util.JDBCExceptionReporter - Cannot delete or update a parent row: a foreign key constraint fails (`sakai/GB_GRADING_EVENT_T`, CONSTRAINT `FK4C9D99E06F98CFF` FOREIGN KEY (`GRADABLE_OBJECT_ID`) REFERENCES `GB_GRADABLE_OBJECT_T` (`ID`))
Here is the problem:
Use "Calculate Course Grades" button in Course Grades page will create records in GB_GRADING_EVENT_T table which has a foreign key referencing GB_GRADABLE_OBJECT_T table;
note: without using recalculate button, there won't be records created in GB_GRADING_EVENT_T
Therefore, to reproduce the problem:
"Calculate Course Grades" button is the one to trigger the problem.
To fix it, delete the record from GB_GRADING_EVENT_T (if there is any) before deleting the assignment object from gradebook.
I reproduced this problem in sakai 2.6.2, 2.6.x, 2.7.x. Looking at the trunk, much likely have the same issue. I hereby attach our local fix and hope that could help others.