Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-30955

Forum average of ratings incorrectly displayed

    Details

    • Database:
      Any
    • Testing Instructions:
      Hide

      For this test you need a course with 3 users - at least 2 need to be teachers (or admin).

      1. Go to Course Admin > Grades > Scales > Add a nwe scale
      2. Add a scale named 'Cool', with the scale of 'Very Cool, Cool, Not Cool, Ooooh!'
      3. Add a forum to the course use default settings except for ratings. Set the aggregate type of 'Average of Ratings' and 'Scale' as 'Cool'
      4. As user 1 (the student) post a forum post
      5. As teacher 1 rate that forum post as 'Very Cool'
      6. As teacher 2 rate that forum post as 'Very Cool'
      7. As teacher 2 re-rate that forum post as 'Ooooh!'

      Click on the rating aggregate need to the rating. The resulting page should say that teacher1 has rated as: 'Very Cool' and teacher2 as 'Oooh!'

      Create a separate forum set up the same but with the rating scale set to 5.
      Again, have the student post then the teachers/admin rate.
      Check that the rating report page correctly reports the ratings submitted by the two teachers.

      Show
      For this test you need a course with 3 users - at least 2 need to be teachers (or admin). Go to Course Admin > Grades > Scales > Add a nwe scale Add a scale named 'Cool', with the scale of 'Very Cool, Cool, Not Cool, Ooooh!' Add a forum to the course use default settings except for ratings. Set the aggregate type of 'Average of Ratings' and 'Scale' as 'Cool' As user 1 (the student) post a forum post As teacher 1 rate that forum post as 'Very Cool' As teacher 2 rate that forum post as 'Very Cool' As teacher 2 re-rate that forum post as 'Ooooh!' Click on the rating aggregate need to the rating. The resulting page should say that teacher1 has rated as: 'Very Cool' and teacher2 as 'Oooh!' Create a separate forum set up the same but with the rating scale set to 5. Again, have the student post then the teachers/admin rate. Check that the rating report page correctly reports the ratings submitted by the two teachers.
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull Master Branch:
      MDL-30955_forum_ratings

      Description

      As illustrated in the discussion http://moodle.org/mod/forum/discuss.php?d=193117 a forum post rated several times as 'Very cool' has the average of ratings displayed as 'Coolest thing ever!' rather than 'Very cool'.

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            cfollin Chris Follin added a comment -

            Also affects 2.1.x.

            Show
            cfollin Chris Follin added a comment - Also affects 2.1.x.
            Hide
            poltawski Dan Poltawski added a comment -

            Looks like this has been caused by MDL-26461

            Show
            poltawski Dan Poltawski added a comment - Looks like this has been caused by MDL-26461
            Hide
            poltawski Dan Poltawski added a comment -

            Yep, in the example moodle.org forum post the average displayed on posts is correct, but the data displayed n the ratings page is being 'rounded down by 1'.

            Show
            poltawski Dan Poltawski added a comment - Yep, in the example moodle.org forum post the average displayed on posts is correct, but the data displayed n the ratings page is being 'rounded down by 1'.
            Hide
            poltawski Dan Poltawski added a comment -

            So it actually has 2 coolest thing ever ratings and 2 very cool ratings. Not quite sure why this was reduced in the attached bug.

            Show
            poltawski Dan Poltawski added a comment - So it actually has 2 coolest thing ever ratings and 2 very cool ratings. Not quite sure why this was reduced in the attached bug.
            Hide
            poltawski Dan Poltawski added a comment -

            Waiting for some info from people in MDL-26461 as to why this was introduced, otherwise reverting that change should fix this issue..

            Show
            poltawski Dan Poltawski added a comment - Waiting for some info from people in MDL-26461 as to why this was introduced, otherwise reverting that change should fix this issue..
            Hide
            andyjdavis Andrew Davis added a comment -

            Working through this now. It all seems to be working correctly for numeric scales. Testing custom scales now.

            Show
            andyjdavis Andrew Davis added a comment - Working through this now. It all seems to be working correctly for numeric scales. Testing custom scales now.
            Hide
            andyjdavis Andrew Davis added a comment -

            Ok, I see the problem. This is the array for a numeric scale with a maximum rating of 5.

            array(6) { [5]=> string(5) "5 / 5" [4]=> string(5) "4 / 5" [3]=> string(5) "3 / 5" [2]=> string(5) "2 / 5" [1]=> string(5) "1 / 5" [0]=> string(5) "0 / 5" }

            Note that for a max grade of 5 there are 6 items, 0-6. Also, the indexes used are 0-6.

            This is the array for a custom scale containing 4 elements.

            array(4) { [4]=> string(6) "Ooooh!" [3]=> string(8) "Not Cool" [2]=> string(4) "Cool" [1]=> string(9) "Very Cool" } 

            For four elements there four items and the indexes are 1-4.

            The following is the code at fault

            $maxrating = count($scalemenu) - 1;

            To make it work I believe we want to take 1 off for numeric scales but not for custom scales. Implementing and testing this now.

            Show
            andyjdavis Andrew Davis added a comment - Ok, I see the problem. This is the array for a numeric scale with a maximum rating of 5. array(6) { [5]=> string(5) "5 / 5" [4]=> string(5) "4 / 5" [3]=> string(5) "3 / 5" [2]=> string(5) "2 / 5" [1]=> string(5) "1 / 5" [0]=> string(5) "0 / 5" } Note that for a max grade of 5 there are 6 items, 0-6. Also, the indexes used are 0-6. This is the array for a custom scale containing 4 elements. array(4) { [4]=> string(6) "Ooooh!" [3]=> string(8) "Not Cool" [2]=> string(4) "Cool" [1]=> string(9) "Very Cool" } For four elements there four items and the indexes are 1-4. The following is the code at fault $maxrating = count($scalemenu) - 1; To make it work I believe we want to take 1 off for numeric scales but not for custom scales. Implementing and testing this now.
            Hide
            poltawski Dan Poltawski added a comment -

            Thanks Andrew

            Show
            poltawski Dan Poltawski added a comment - Thanks Andrew
            Hide
            andyjdavis Andrew Davis added a comment -

            Added a possible solution and expanded the testing instructions a little.

            Show
            andyjdavis Andrew Davis added a comment - Added a possible solution and expanded the testing instructions a little.
            Hide
            poltawski Dan Poltawski added a comment -

            Makes sense to me

            Show
            poltawski Dan Poltawski added a comment - Makes sense to me
            Hide
            andyjdavis Andrew Davis added a comment -

            Added branches. Up for integration.

            Show
            andyjdavis Andrew Davis added a comment - Added branches. Up for integration.
            Hide
            poltawski Dan Poltawski added a comment -

            The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

            TIA and ciao

            Show
            poltawski Dan Poltawski added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
            Hide
            samhemelryk Sam Hemelryk added a comment -

            Thanks Andrew, changes look spot on and this has been integrated now

            Show
            samhemelryk Sam Hemelryk added a comment - Thanks Andrew, changes look spot on and this has been integrated now
            Hide
            salvetore Michael de Raadt added a comment -

            Test result: Success.

            Tested in 2.1, 2.2 and master.

            Also tested this with student ratings.

            Show
            salvetore Michael de Raadt added a comment - Test result: Success. Tested in 2.1, 2.2 and master. Also tested this with student ratings.
            Hide
            poltawski Dan Poltawski added a comment -

            Bonza mate!

            Your changes have made it into the Moodle release! Its time to celebrate! Put a shrimp on the barbie and grab a stubby.

            Hooroo

            Show
            poltawski Dan Poltawski added a comment - Bonza mate! Your changes have made it into the Moodle release! Its time to celebrate! Put a shrimp on the barbie and grab a stubby. Hooroo

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/May/12