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

Exception thrown when evaluating disabled models from the CLI

    XMLWordPrintable

Details

    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_400_STABLE
    • MOODLE_310_STABLE, MOODLE_311_STABLE
    • MDL-71973-311
    • Hide
      1. You must have a moodle instance with some data.
      2. By running the below command choose a model that is disabled. (We choose "Students at risk of dropping out" id=1 for example)

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

      3. Evaluate it by running command below.

        php admin/tool/analytics/cli/evaluate_model.php --modelid=1
        

        After evaluating, the cli asks to specify the time splitting (like below)

      4. We can go to the next step by typing

        \core\analytics\time_splitting\single_range
        

      5. If the patch applied we must not see the below output

        : \core\analytics\time_splitting\single_range
        !!! Exception - Call to a mamber function based_on_assumptions() on bool!!!
        

      6. If exception occurs it means either the patch isn't useful or doesn't apply properly.*
      Show
      You must have a moodle instance with some data. By running the below command choose a model that is disabled. (We choose "Students at risk of dropping out" id=1 for example) php admin/tool/analytics/cli/evaluate_model.php --list Evaluate it by running command below. php admin/tool/analytics/cli/evaluate_model.php --modelid= 1 After evaluating, the cli asks to specify the time splitting (like below) We can go to the next step by typing \core\analytics\time_splitting\single_range If the patch applied we must not see the below output : \core\analytics\time_splitting\single_range !!! Exception - Call to a mamber function based_on_assumptions() on bool!!! If exception occurs it means either the patch isn't useful or doesn't apply properly.*

    Description

      Bug reported by mohalisad in MDL-67249 comments.

      When you run model evaluation script from CLI and the model is disabled it should interactively enables your model.

      But it has a bug and an exception occurs in process:

      !!! Exception - Call to a member function based_on_assumptions() on bool !!!

      It happens in here (analytics/classes/model.php: line 1204):

      The get_target method returns false and that causes this exception.

      This problem is due to the fact that in evaluate_model.php cli file we have an undefined variable(admin/tool/analytics/cli/evaluate_model.php):

      The $modelobj is never referenced before this line therefore the $model constructed wrongly in line 140 and in line 143 that causes an exception.

      Stacktrace:

       

      Steps to reproduce:

      1. Go to Analytics model page and choose a model than could be evaluated e.g. 'Students at risk of dropping out'. Remember the id of the model and disable it.
      2. Run 'php admin/tool/analytics/cli/evaluate_model.php --modelid=xx' using modelid of the previous model.
      3. Use a valid subclass of '\core_analytics\local\time_splitting\base' as an analysis interval. e.g. '\core\analytics\time_splitting\single_range'
      4. Script should finish with no error

      Attachments

        Activity

          People

            mohalisad MohammadAli Sadraei
            amaia Amaia Anabitarte
            Simey Lameze Simey Lameze
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Sara Arjona (@sarjona)
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              13/Sep/21

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 6 hours, 37 minutes
                6h 37m