ModernLMS / moodle-availability_othercompleted

This plugin allow to restrict access of activities and resources in your course based on other course completion.
6 stars 12 forks source link

multiple warnings #2

Closed ak4t0sh closed 4 years ago

ak4t0sh commented 5 years ago

Tested on Moodle 3.7 Process

  1. Create course 'a' and 'b' and enrol as student in both
  2. Configure course completion on 'b'.
  3. Add an activity module in 'a' with restriction targeting 'b' On edit page the following warning appears Notice: Undefined property: stdClass::$completiongradeitemnumber in /var/www/html/availability/condition/othercompleted/classes/frontend.php on line 62

Then save and followings warnings should appear : Notice: Undefined property: stdClass::$completiongradeitemnumber in /var/www/html/availability/condition/othercompleted/classes/frontend.php on line 62 Notice: Trying to get property 'id' of non-object in /var/www/html/availability/condition/othercompleted/classes/condition.php on line 91

  1. Go to course 'a' (or 'b') page Notice: Trying to get property 'id' of non-object in /var/www/html/availability/condition/othercompleted/classes/condition.php on line 91
  2. Complete 'b' course.
  3. Repeat 4. The following error should appears :

    
    Invalid course_modinfo property accessed: datcm
    
    line 141 of /lib/modinfolib.php: call to debugging()
    line 205 of /availability/condition/othercompleted/classes/condition.php: call to course_modinfo->__get()
    line 772 of /availability/classes/info.php: call to availability_othercompleted\condition::completion_value_used()
    line 492 of /course/renderer.php: call to core_availability\info::completion_value_used()
    line 898 of /course/renderer.php: call to core_course_renderer->course_section_cm_completion()
    line 800 of /course/renderer.php: call to core_course_renderer->course_section_cm()
    line 993 of /course/renderer.php: call to core_course_renderer->course_section_cm_list_item()
    line 887 of /course/format/renderer.php: call to core_course_renderer->course_section_cm_list()
    line 57 of /course/format/topics/format.php: call to format_section_renderer_base->print_multiple_section_page()
    line 290 of /course/view.php: call to require()

Warning: Invalid argument supplied for foreach() in /var/www/html/availability/condition/othercompleted/classes/condition.php on line 205



Hint for condition.php#L91 issue: To test `course_completions` entry existence you should use `$DB->record_exists()` instead of `$DB->get_record()` ;)