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

Notice id property of non-object - frontend.php line 59 #9

Closed mlohoar closed 4 years ago

mlohoar commented 4 years ago

Just did an install via zip and got a notice when creating a new activity. The code at line 56: $course = get_courses(); foreach ($course as $othercm) {

messes up the line 59 if(($othercm->category > 0) && ($othercm->id != $course->id)){

as $course is now an array.

Suggest change lines 56 & 57 to: $others= get_courses(); foreach ($other as $othercm) {

amarizaty commented 4 years ago

fix on 25 Feb 2020

otatarintseva commented 4 years ago

Hi, I have the same issue and it allows to show the current course on the course list in restrictions. It happens because $course variable is overridden in line 56: $course = get_courses(); So the fix is simple: just change variable name in lines 56 and 57 for example like this:

$courses = get_courses();
foreach ($courses as $othercm) {
sam-suresh commented 4 years ago

Fixed