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

Array expected but object provided in mod_lesson\analytics\indicator\cognitive_depth::feedback_submitted()

XMLWordPrintable

    • MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE
    • MOODLE_36_STABLE, MOODLE_37_STABLE
    • MDL-65845_master
    • Hide

      Use PHP 7.2.0 or higher for this test

      1. Enable debugging mode
      2. Log in as admin
      3. Disable 'onlycli' setting in site admin > analytics > analytics settings
      4. Enable 'enablecompletion' in site admin > advanced features
      5. Setup your timezone correctly in site admin > location > location settings
      6. Set up a course so that:
        • It uses topics format
        • completion is enabled
        • startdate to right now (including hour and minute)
      7. Enrol 2 users as students
      8. Enrol the logged in admin user as a course teacher
      9. We need the course to have a lesson activity in a course section different than section 0, if you don't have any add a lesson activity with a single content page, the content page jump should be "End of lesson".
        1. Set the "Expected completed on" time (in Activity completion fieldset) to right now (including hour and minute)
      10. Complete the lesson for each of the 2 users enrolled as students
      11. Set the course end date to right now
      12. Click on the course admin cog and select Course completion
      13. Set Condition: Manual completion by others to Teacher role
      14. Go to course admin > more... > reports > course completion
      15. Flag just one of the students as approved
      16. Run cron so that the course completion status of the student is updated
      17. Go to site admin > analytics > analytics models
      18. Click on new model > create model
      19. Set the following values in the form:
        1. Tick 'enabled'
        2. Target: Students at risk of not meeting the course completion conditions
        3. Indicators: Lesson cognitive
        4. Analysis interval (time-splitting method in 3.7): From start to end ("Single range" in 3.7)
        5. Default value for predictions processor
        6. Save changes
      20. Execute "Execute scheduled analysis" ("Get predictions" in 3.7) or "Evaluate (using the current time-splitting method)" for the model you just created
      21. You SHOULD not see any warning in the error log
      Show
      Use PHP 7.2.0 or higher for this test Enable debugging mode Log in as admin Disable 'onlycli' setting in site admin > analytics > analytics settings Enable 'enablecompletion' in site admin > advanced features Setup your timezone correctly in site admin > location > location settings Set up a course so that: It uses topics format completion is enabled startdate to right now (including hour and minute) Enrol 2 users as students Enrol the logged in admin user as a course teacher We need the course to have a lesson activity in a course section different than section 0, if you don't have any add a lesson activity with a single content page, the content page jump should be "End of lesson". Set the "Expected completed on" time (in Activity completion fieldset) to right now (including hour and minute) Complete the lesson for each of the 2 users enrolled as students Set the course end date to right now Click on the course admin cog and select Course completion Set Condition: Manual completion by others to Teacher role Go to course admin > more... > reports > course completion Flag just one of the students as approved Run cron so that the course completion status of the student is updated Go to site admin > analytics > analytics models Click on new model > create model Set the following values in the form: Tick 'enabled' Target: Students at risk of not meeting the course completion conditions Indicators: Lesson cognitive Analysis interval (time-splitting method in 3.7): From start to end ("Single range" in 3.7) Default value for predictions processor Save changes Execute "Execute scheduled analysis" ("Get predictions" in 3.7) or "Evaluate (using the current time-splitting method)" for the model you just created You SHOULD not see any warning in the error log

      While working on MDLSITE-5663 the following PHP warning has been repeatedly (like dozens if not hundred times) displayed while running the admin/tool/analytics/cli/evaluate_model.php script:

      PHP Warning:  count(): Parameter must be an array or an object that implements
      Countable in /mod/lesson/classes/analytics/indicator/cognitive_depth.php on line 73
      

      The code there in the method mod_lesson\analytics\indicator\cognitive_depth::feedback_submitted() only checks if the array item exists and is not empty, and then it clearly assumes that it must be an array.

      When debugging, I realized that the actual value of the $this->activitylogs[$contextid][$userid]['\mod_lesson\event\lesson_ended'] item is not an array but an object like

      stdClass Object
      (
          [eventname] => \mod_lesson\event\lesson_ended
          [component] => mod_lesson
          [action] => ended
          [target] => lesson
          [objecttable] => lesson
          [objectid] => 1912
          [crud] => r
          [edulevel] => 2
          [contextid] => 350044
          [contextlevel] => 70
          [contextinstanceid] => 94045
          [userid] => 23699
          [courseid] => 17297
          [timecreated] => Array
              (
                  [0] => 1531609232
              )
       
      )
      

      There is likely a bug somewhere, and it is also annoying as it causes the script output to scroll away.

        1. MDL-65845.jpg
          MDL-65845.jpg
          71 kB
        2. MDL-65845(2).jpg
          MDL-65845(2).jpg
          88 kB
        3. screenshot-1.png
          screenshot-1.png
          1.22 MB

            dmonllao David Monllaó
            mudrd8mz David Mudrák (@mudrd8mz)
            Victor Déniz Falcón Victor Déniz Falcón
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Anna Carissa Sadia Anna Carissa Sadia
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.