Gradebook problem

Gradebook problem

by Dee Kramer -
Number of replies: 18

I have a prof who has 139 students with lots of Grades.  When he clicks Edit Grades, he gets the following message: "No Category to View By".  He has 4 categories and each category has 6 or 7 assignment in it. The work-around is to do it the old way-bring each student up individually.  Does anyone have a solution?


No category to view by


Thanks

In reply to Dee Kramer

Re: Gradebook problem

by Michael Penney -
Yes I see this in Rob Barreca's gradebook, trying to debug it. Are you using SchoolEngine's enhanced gradebook or Linux Box/Luther College's?
In reply to Michael Penney

Re: Gradebook problem

by Rob Barreca -
Hmm, first I've heard of it. My installation works great. Did anyone try and email me this bug? And have you tried to download the latest from my CVS?

:pserver:anonymous@cvs.schoolengine.com:/usr/local/cvsroot

And get the moodle_15_stable_mods which only includes the changed files (when compared to MOODLE_15_STABLE).

Please let me know how this is working, whether it be good or bad. I want to make this solid.


And if you can reproduce this at http://demo.schoolengine.com with login teacher/teacher, let me know the exact steps so I can fix it. AIM: School Engine MSN: help@schoolengine.com
In reply to Rob Barreca

Re: Gradebook problem

by Michael Penney -

Hi Rob, with debugging on and using the latest version from your CVS download (10/28), I'm getting:

Error: Turn off debugging to hide this error.

SELECT * FROM mdl_grade_item WHERE courseid=3 ORDER BY category ASC
Found more than one record in get_record_sql !

A bunch of SQL code, and abelow it:

Notice: Trying to get property of non-object in C:\Moodle4Windows\Moodle4Windows\htdocs\153\moodle\grade\lib.php on line 1599

Notice: Trying to get property of non-object in C:\Moodle4Windows\Moodle4Windows\htdocs\153\moodle\grade\lib.php on line 1600

Then the 'No category to view by' error

In reply to Michael Penney

Re: Gradebook problem

by Rob Barreca -
Oddly enough, I just got this error on my live installation of this. I'll try and work through it to fix the bug in CVS. Let me know if you have any suggestions.

Well, I found a quick fix but haven't got to the root of the problem. For those of you who are anxious: In grade/lib.php change lines around 1604...

FROM

//Do a quick SQL to find the first category with items in it. This prevents the empty category view.
//TODO: Figure out No category to view by error
$cat_id = get_record_select("grade_item", "courseid=".$course->id." ORDER BY category DESC");
$cat = get_record("grade_category", "id", $cat_id->category);
$cview = $cat->name;

TO

//Do a quick SQL to find the first category with items in it. This prevents the empty category view.
//TODO: Figure out No category to view by error
$cat_id = get_record_select("grade_item", "courseid=".$course->id." ORDER BY category DESC");
if ($cat = get_record("grade_category", "id", $cat_id->category)) {
$cview = $cat->name;
} else {
$cview = UNCATEGORISED;
}
In reply to Rob Barreca

Re: Gradebook problem

by Rob Barreca -
[EDIT: Sorry, got disconnected]

Oddly enough, I just got this error on my live installation of this. I'll try and work through it to fix the bug in CVS. Let me know if you have any suggestions.

Well, I found a quick fix but haven't got to the root of the problem. For those of you who are anxious: In grade/lib.php change lines around 1604...

FROM

//Do a quick SQL to find the first category with items in it. This prevents the empty category view.
$cat_id = get_record_select("grade_item", "courseid=".$course->id." ORDER BY category ASC");
$cat = get_record("grade_category", "id", $cat_id->category);
$cview = $cat->name;

TO

//Do a quick SQL to find the first category with items in it. This prevents the empty category view.
$cat_id = get_record_select("grade_item", "courseid=".$course->id." ORDER BY category DESC");
if ($cat = get_record("grade_category", "id", $cat_id->category)) {
$cview = $cat->name;
} else {
$cview = UNCATEGORISED;
}
In reply to Michael Penney

Re: Gradebook problem

by Dee Kramer -
I've been told that we are using the Linux Box Luther College's.  Thanks for you interest!
In reply to Dee Kramer

Re: Gradebook problem

by Rob Barreca -
Okay, did a bit more searching and see that the delete_instance() function in the assignment class does not delete the grade_item records with a matching cminstance id. This is why the error was coming up because these deleted assignments may point to old categories. Is there a reason for this? Seems like there should be a delete_records in there for grade_item or is this left out on purpose? Hopefully a more experienced Moodle dev can share some insight.

function delete_instance($assignment) {
$result = true;

if (! delete_records('assignment_submissions', 'assignment', $assignment->id)) {
$result = false;
}

if (! delete_records('assignment', 'id', $assignment->id)) {
$result = false;
}

if (! delete_records('event', 'modulename', 'assignment', 'instance', $assignment->id)) {
$result = false;
}
// What about removing grade_item records here?
return $result;
}
In reply to Rob Barreca

Re: Gradebook problem

by Bob Puffer -
I think you're probably on the right track Rob.  We experienced this error due to improperly deleted "Uncategorized" category.  My fix, in this instance was to go in directly to the data and clean up what was messy (I believe a renumbered "Uncategorized" category).  In my estimation (with modest research described above) I don't believe we should allow deletion of the "Uncategorized" category.
In reply to Bob Puffer

Re: Gradebook problem

by Dee Kramer -

This is the message I received from the prof with the "No Categories to View By".

"The last thing I did in grade-book, if my memory is correct, was to enter some new assignments/tests/response papers in the usual way and then categorize them in gradebook.  One thing I do remember doing was to delete the category "uncategorized" since that heading in the gradebook just cluttered up the view.  Would that do anything to the gradebook?  I've done that before with no ill effects, as I recall."
When you talk about "my fix", what exactly can I do. Can I fix the Gradebook on the course site?  Do I have to ask Computer Services to "fix" it?
Thanks for your help.
In reply to Bob Puffer

Re: Gradebook problem

by Dee Kramer -

I just tried to delete an Uncategorized category in a test site, but I was not able to delete it.  BUT, it did cause the "No category to View by" to appear!! Now, how can I remove that, so I can edit Grades.

Thanks,

In reply to Dee Kramer

Re: Gradebook problem

by Dee Kramer -

I accidently fixed the "No Categories to View by". I went to Set Preferences, clicked "Hide Advanced Features".  Saved it.  Then, I went back in and clicked, "Use Advanced Features." The alert had disappeared.



In reply to Dee Kramer

Re: Gradebook problem

by Rob Barreca -
When you turn off advanced features, I think it clears out the categories. So it will fix it temporarily, but the bug is still there.
In reply to Bob Puffer

Re: Gradebook problem

by Michael Penney -

This must represent a difference betweent the way 'edit grades' is building the categories and the way 'View grades' is calling them. You can't delete uncategorized in the standard 1.5.3 gradebook.

In reply to Bob Puffer

Re: Gradebook problem

by Jeff Graham -
Hi Bob,

You are correct. The "uncategorized" category can't be deleted; several of the core features require this since things that effect the gradebook usually happen outside of the gradebook eg. Deleting module instances, or adding new module instances, or changing the grading method for an existing instance.

grade_set_uncategorized() will resolve these issues for you as described in my response to Rob

regards,
Jeff
In reply to Rob Barreca

Re: Gradebook problem

by Jeff Graham -
Hi Rob,

Actually the best way to resolve this issue would be to just call grade_set_uncategorized() defined in grade/lib.php

This function does all of the necessary housekeeping. I haven't reviewed your additions to the gradebook, but the error described is indicative of some sort of mess created when a module instance is deleted or the uncategorized category is deleted.

The uncategorized category was created since there is no communication amongst the various modules and the gradebook. The gradebook needs this to handle quite a few different situations and the afforementioned function makes sure that everything is okay.

The strange "fixing itself" issues posted above are because all core gradebook features call this function as a first step. This is also probably why it is hard to reproduce.

hope that helps, sorry that I didn't catch the thread sooner smile
In reply to Dee Kramer

Re: Gradebook problem

by Rob Barreca -
It seems the error is this:

When deleting the uncategorized category, let's say it has catID of 7. Any deleted assignments that are pointing to catID 7 that haven't had their records properly removed from the grade_item table (this isn't in the delete_instance code of assignment class) will then be pointing to a non-existing "uncategorized" catID 7 since when you delete the uncategorized category it immediately reinserts it with a new ID, let's say 8.

So now, these deleted assignments point to catID 7 and when the grade_view_category_grades() function is called, it just finds the first record for this course in the grade_item table. And in this case it happens to be catID 7 which really doesn't exist anymore.

The grade_set_uncategorized() function is always called in index.php so that isn't the problem in this case I don't think.

I'm working on the fix now and will be in my CVS shortly.
In reply to Dee Kramer

Re: Gradebook problem

by Rob Barreca -
Committed fix to my cvs server. Please test and let me know. The CVS server only includes changed files from the MOODLE_15_STABLE branch. So be sure to be up to date on that too.

CVS String:
:pserver:anonymous@cvs.schoolengine.com:/usr/local/cvsroot

Module Name:
moodle_15_stable_mods
In reply to Rob Barreca

Re: Gradebook problem

by Bob Puffer -
This exchange is exemplary of why Moodle rocks -- with the commercial LMS software I've used, I would have been fortunate to have gotten my problem REPORTED in the amount of time its taken this community to fix this situation.