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

Analytics models may be restricted to category or course contexts

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Run this in CLI and ensure that there is no mention to a --filter option in the output:

        php admin/tool/analytics/cli/evaluate_model.php

      2. Install https://github.com/dmonllao/moodle-local_testanalytics
      3. Go to site admin > analytics > analytics models
      4. Click on Actions > Edit for the students at risk of dropping out model
      5. Untick Enabled and select the empty option for Analysis interval, save changes
      6. Click on Actions > Edit for the students at risk of dropping out model again
      7. You SHOULD see a Contexts field
      8. Select two options for the Contexts field and save changes
      9. Click on Actions > Edit for the students at risk of dropping out model
      10. Check that the two options you selected are still selected
      11. Remove them both and save changes
      12. Click on Actions > Edit for the students at risk of dropping out model
      13. Check that there are no selected contexts and you see an All text on the right side of the Contexts label
      14. Return back to site admin > analytics > analytics models and click on New model > Create model
      15. Fill the form:
        • Target: Binary
        • Indicators: Test setting is set
        • Contexts: Any option is fine, the result will be the same (note that this text is an explanation, not an option in the dropdown menu )
      16. Save changes
      17. You SHOULD get an error in Contexts field, The selected target does not support context restrictions
      18. Remove the contexts you selected in Contexts field and Save changes
      19. You SHOULD NOT get any form validation error and you SHOULD be back in the models list page
      20. Back in site admin > analytics > analytics models, click on New model > Create model
      21. Fill the form:
        • Target: Students at risk of dropping out
        • Indicators: Any write action
        • Contexts: Any option is fine, the result should be the same (note that this text is an explanation)
      22. Save changes
      23. You SHOULD NOT get any form validation error and you SHOULD be back in the models list page
      Show
      Run this in CLI and ensure that there is no mention to a --filter option in the output: php admin/tool/analytics/cli/evaluate_model.php Install https://github.com/dmonllao/moodle-local_testanalytics Go to site admin > analytics > analytics models Click on Actions > Edit for the students at risk of dropping out model Untick Enabled and select the empty option for Analysis interval , save changes Click on Actions > Edit for the students at risk of dropping out model again You SHOULD see a Contexts field Select two options for the Contexts field and save changes Click on Actions > Edit for the students at risk of dropping out model Check that the two options you selected are still selected Remove them both and save changes Click on Actions > Edit for the students at risk of dropping out model Check that there are no selected contexts and you see an All text on the right side of the Contexts label Return back to site admin > analytics > analytics models and click on New model > Create model Fill the form: Target: Binary Indicators: Test setting is set Contexts: Any option is fine, the result will be the same (note that this text is an explanation, not an option in the dropdown menu ) Save changes You SHOULD get an error in Contexts field, The selected target does not support context restrictions Remove the contexts you selected in Contexts field and Save changes You SHOULD NOT get any form validation error and you SHOULD be back in the models list page Back in site admin > analytics > analytics models , click on New model > Create model Fill the form: Target: Students at risk of dropping out Indicators: Any write action Contexts: Any option is fine, the result should be the same (note that this text is an explanation) Save changes You SHOULD NOT get any form validation error and you SHOULD be back in the models list page
    • Affected Branches:
      MOODLE_37_STABLE
    • Fixed Branches:
      MOODLE_38_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-64739_master

      Description

      MDL-60944 is scheduled for 3.7, it will allow people to create as many prediction models as they want, reusing the same target.

      A new "Restrict model to the following contexts" option would allow people to set up separate predictive models for different course categories or courses. A model restricted to a set of contexts (just CONTEXT_COURSE and CONTEXT_COURSECAT) would limit the analysable elements used by the model to analysable elements whose context is equal to, or a child of, any of the contexts specified in "Restrict to the following contexts".

      The required changes to core could be summarized here:

      1. A new field to 'models' db table (e.g. contexts)
      2. A new field in the edit model form (e.g. an autocomplete field with a list of courses and course categories)
      3. A new \core_analytics\local\analyser\base::supports_context_filtering() method to show/hide the new field (the point right above this one)
      4. Modifications to the analytics API to pre-fill options['filter'] with the list of contexts
      5. Modifications to core's get_analysables_iterator() implementations (core_analytics\local\analyser\by_course and core\analytics\analyser\users) to receive $this->options['filter'] as a parameter and take it into account
      6. A new helper method somewhere in core_analytics to return an SQL that joins with the context table and uses the ctx.path value of the provided context to filter out analysables that do not fit into the restricted list of contexts for the model. This method will be called by get_analysables() implementations where supports_context_filtering == true
      7. A modification to the current evaluation process, which supports a filter by course option. I would vote to just replace this filter by course for the filter by contextid/s
      8. A review of the analytics caching system to ensure we don't break anything
      9. Unit tests should be added to test everything. Specially helpful to detect possible issues in the point right above this one

      I may be missing extra stuff, but those are the most critical points we need to cover.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  18/Nov/19

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 week, 1 day, 5 hours, 15 minutes
                  1w 1d 5h 15m