Gradebook preference/user report problems

Gradebook preference/user report problems

by Nick Summers -
Number of replies: 7
Hi

I have been doing alot of work recently to adapt the gradebook to work with individual student targets for APP. During the work I found 2 issues. Not sure if they are bugs or need to be in the tracker, so I am putting them here to see if you can duplicate them.

1. User preference.
In a gradebook with 4 categories deep, when I switch between grade items/category total/full view with the toggle I get a message that the preference string (value field) is too long. The offending preference setting was 288 chars and the field is set to 255.

This doesn't stop any functionality, but it does throw up the error in debug and slows the page loading.

2. User report.
In the same 4 category deep gradebook I had 10+ manual outcome items and one assignment item. A number of the outcome items had grades for all students, but the assignment had only one graded submission. I deleted the assignment item (can't recall why now!) and then found that the user report didn't display correctly.

(BTW this is all on a test server so no harm done!)

To clarify, logged in as admin all gradebook reports were fine both before and after the assignment delete. The only change was that the various totals columns in the grader report for the categories that included the assignment showed as overridden. The user report when viewed as admin was fine and showed the categories nested properly with all manual outcome items showing. All of this is also true for the situation where I logged in as the teacher.

However, when I logged in as a student on the course and looked at the gradebook the user report:
did not show any manual outcome items.
did not have the correct column alignments due to incorrect category nesting.

With the categories, each subcategory was one column further to the right. And categories at the same level appeared to be nested.

We are running 1.9.7, php 5.2.10, mysql 5.1.28.

Any thoughts? Anyone able to reproduce this? Or have I just been sat at this screen for way too long!

Thanks

Nick Summers
In reply to Nick Summers

Re: Gradebook preference/user report problems

by Nick Summers -
Hi again

The user report problem seems more fundamental than being associated with some odd action. I started again after deleting the assignment - I removed everything from the grade book and re-did all categories and items. No assignment in it this time! I checked the gradebook user report logged in as a student before I put in any grades and it was fine. However, when I went back to being a student having put in a significant number of grades through the grader report, the user report was again constructed incorrectly. As before logged in as admin or teacher the user report view was fine. Here are a couple of screen shots to better illustrate the problem.

Logged in as admin, one user selected for user view:
report ok

Logged in as student (same student as selected above):
report bad

Any ideas?

Thanks

Nick Summers
In reply to Nick Summers

Re: Gradebook preference/user report problems

by Elena Ivanova -
Hi Nick,
As far I am aware, students do not see outcomes anywhere, that is why discrepancy in your and student view.
In addition you seem to have hided some category totals. E.g. See Sandman Paragraph category. Currently, if you do so, everything inside such category (and category itself) becomes hidden from a student.
In reply to Elena Ivanova

Re: Gradebook preference/user report problems

by Nick Summers -
Hi Elena

Thanks for reminding me of the hidden category totals. I unhid them and the student view returned to normal (which does include outcomes).

So this looks like a bug. Even if all the category items are hidden, the categories should display nested correctly and not as in the screenshot above.

I would also question the wisdom of providing hide/unhide for individual items and totals in the category tree if the behaviour is inconsistent. I want to have the categories to make the gradebook more readable, but the totals for some of those categories are irrelevant - it is the parent category total that is important. So I would like to be able to hide individual category totals without having the whole category hidden, which is the implied behaviour from the location of the hide/unhide icons.

Now that the problem is isolated I will do a little more investigation and add it to the tracker as necessary.

All the best

Nick.
In reply to Nick Summers

Re: Gradebook preference/user report problems

by Bob Puffer -
Everyone I talk to agrees that the cascading of hides from category to all child items is incorrect logic. The hack to fix is easy:
- in grade/edit/tree/action.php comment out the line that forces cascading of hides (in 1.97 around line 57) and replace it with a line that doesn't. My code looks like this:

// $object->set_hidden(1, true);
$object->set_hidden(1);
In reply to Bob Puffer

Re: Gradebook preference/user report problems

by Steve Copley -
Hi

Thanks for the suggestion (I too share this issue), but your fix does not solve the problem.

It seems to be a bug in the code that calculates the category title's 'rowspan' value to produce the coloured sidebars in the table (see my reply to the parent post)

If you have any other insights, I'd appreciate hearing them!

All the best

Steve C.

In reply to Nick Summers

Re: Gradebook preference/user report problems

by Steve Copley -
I have exactly this issue. As soon as a category is hidden, the user report gets messed up.

The issue is to do with the calculation of the 'rowspan' value for the coloured bars at the left side of the table. When categories are hidden the number of rows spanned by the containing category should reduce, but in fact it doesn't.

You can see from your screenshots, the pale green side bar originally spans 12 rows (from the 'Term 1 Reading' title row, down to the 'category Total' row)

You then hide the categories contained. The pale green sidebar should now span just 2 rows (the title and total rows) since all the other rows belong to hidden categories.

However it still is set to have a 'rowspan' of 12. This creates the messed up table since the sidebar pushes down into rows/categories below.

When I get a moment, I'll have a search for the code that calculates the 'rowspan' value for these category sidebars and see if I can figure out a fix (however I don't know the code at all, so it would be quicker for someone familiar with code to take a look)

It's a rather annoying bug - hope we get a fix soon so that I can hide the 'ungraded' category of assignments from my students' gradebooks - they take up way too much unnecessary space.

All the best

Steve C.
In reply to Nick Summers

Gradebook formatting problem when categories hidden - FIXED

by Steve Copley -
Hi

I have a solution to this issue.

You need to edit a core Moodle file, but it's an easy patch...

  1. Open Moodle --> grade --> report --> user --> lib.php
  2. Find the function inject_rowspans() around line 128
  3. Add the following lines at the start of this function (just below the function name):
        $type = $element['type'];
        $grade_object = $element['object'];
    
        // If this is a hidden grade category, do not increase the parent rowspan - return 0
        if ($type == 'category' && $grade_object->is_hidden() && !$this->canviewhidden && 
            ($this->showhiddenitems == 0 || 
            ($this->showhiddenitems == 1 && !$grade_object->is_hiddenuntil()))) {
            return 0;
        }
    

This should mean that your inject_rowspans() function should look like:

    function inject_rowspans(&$element) {

        $type = $element['type'];
        $grade_object = $element['object'];

        // If this is a hidden grade category, do not increase the parent rowspan - return 0
        if ($type == 'category' && $grade_object->is_hidden() && !$this->canviewhidden && 
            ($this->showhiddenitems == 0 || 
            ($this->showhiddenitems == 1 && !$grade_object->is_hiddenuntil()))) {
            return 0;
        }

        if ($element['depth'] > $this->maxdepth) {
            $this->maxdepth = $element['depth'];
        }
        if (empty($element['children'])) {
            return 1;
        }
        $count = 1;
        foreach ($element['children'] as $key=>$child) {
            $count += $this->inject_rowspans($element['children'][$key]);
        }
        $element['rowspan'] = $count;
        return $count;
    }

I hope that fixes things for you all. I've added a bug to the Tracker along with this fix.

All the best

Steve C.