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

Activity weight set to 0 on creation

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      Setup
      1. Log in as an admin.
      2. Go to "Site administration / Grades / Grade category settings.
      3. Under "Available aggregation types", select "Natural" and "Weighted mean of grades"
      4. Save the changes.
      5. Go to "Site administration / Advanced features.
      6. Enable outcomes.
      7. Save the changes.
      8. Go to "Site administration / Grades / Outcomes".
      9. Add a new outcome "Outcome 1.
      10. Create a course.
      11. Open the course menu and press "Outcomes"
      12. Add "Outcome 1" in the "Available standard outcomes" to the "Outcomes used in course"
      13. Navigate to "Grades / Grade administration / Setup / Gradebook setup".
      14. Edit the course's grade settings.
      15. Set its "Aggregation" to "Weighted mean of grades"
      16. Save the changes.
      17. Go back to the course page.
      18. Create 2 assignments in the course with the following settings:
        Name Outcomes
        Assign 1  
        Assign 2 with outcome Outcome 1
      Verification
      1. Go back to the grade book setup page.
      2. Confirm the following:
        • Assign 1 and 2's weights are set to 1.0.
      3. Open your favourite SQL tool.
      4. Go to the "mdl_grade_items" table.
      5. Look for the outcome grade item that's assigned to Assign 2. It's "itemname" will be "Outcome 1", and it will have the same "iteminstance" value as "Assign 2"'s.
      6. Confirm that the the records for Outcome 1 and Assign 2 have the same "aggreagtioncoef" and "aggreagtioncoef" values.
      Show
      Setup Log in as an admin. Go to " Site administration / Grades / Grade category settings . Under " Available aggregation types ", select " Natural " and " Weighted mean of grades " Save the changes. Go to " Site administration / Advanced features . Enable outcomes. Save the changes. Go to " Site administration / Grades / Outcomes ". Add a new outcome " Outcome 1 . Create a course. Open the course menu and press " Outcomes " Add " Outcome 1 " in the " Available standard outcomes " to the " Outcomes used in course " Navigate to " Grades / Grade administration / Setup / Gradebook setup ". Edit the course's grade settings. Set its " Aggregation " to " Weighted mean of grades " Save the changes. Go back to the course page. Create 2 assignments in the course with the following settings: Name Outcomes Assign 1   Assign 2 with outcome Outcome 1 Verification Go back to the grade book setup page. Confirm the following: Assign 1 and 2's weights are set to 1.0. Open your favourite SQL tool. Go to the " mdl_grade_items " table. Look for the outcome grade item that's assigned to Assign 2. It's " itemname " will be " Outcome 1 ", and it will have the same " iteminstance " value as " Assign 2 "'s. Confirm that the the records for Outcome 1 and Assign 2 have the same " aggreagtioncoef " and " aggreagtioncoef " values.
    • Affected Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_36_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_38_STABLE
    • Pull Master Branch:
      MDL-52578-master

      Description

      MDL-50062 appears to have caused a regression: it's un-fixed MDL-45029 - new activities added to grade categories set to "Weighted mean of grades" once again default to a weight of 0 (at least in the case where the course aggregation method and chosen category aggregation method are both "weighted mean of grades").

      The following block of code which was removed in MDL-50062 only applied when adding a new course module, so removing it doesn't seem relevant to the commit's stated objective of carrying the aggregation coefficient(s) between categories when possible:

      -            $gradecategory = $grade_item->get_parent_category();
      -            if (!empty($moduleinfo->add)) {
      -                if (grade_category::aggregation_uses_aggregationcoef($gradecategory->aggregation)) {
      -                    $defaults = grade_category::get_default_aggregation_coefficient_values($gradecategory->aggregation);
      -                    $grade_item->aggregationcoef = $defaults['aggregationcoefficient'];
      -                    $grade_item->aggregationcoef2 = $default['aggregationcoefficient2'];
      -                    $grade_item->update();
      -                }
      -            }
      

      The other block removed from course/modlib.php by the same commit, which performed a similar task for outcome items, may or may not be needed (I haven't traced that yet); but as it only applied to new outcome items, it may still apply in some cases.

      The removed code can't quite be simply added back in, as the array keys in the defaults have changed (and there's a typo which needs fixing - $default should be $defaults for coef2). Adding back the block quoted above with these tweaks appears to resolve the issue (though once again, I haven't tested with outcome items, so the second block of code may also need reinstating with tweaks).

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              smbader Steve Bader
              Reporter:
              paul.n Paul Nicholls
              Peer reviewer:
              Jun Pataleta Jun Pataleta
              Integrator:
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Tester:
              Anna Carissa Sadia Anna Carissa Sadia
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
              Votes:
              8 Vote for this issue
              Watchers:
              21 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                13/Jul/20

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day, 15 minutes
                  1d 15m