Skip to content

Commit

Permalink
Merge pull request #96 from KepaUrzelai/patch-1
Browse files Browse the repository at this point in the history
Issue #95: prevent empty referenced course id coding error
  • Loading branch information
danmarsden authored Sep 19, 2024
2 parents c682037 + ee672f2 commit 5852c2b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,13 @@ function subcourse_update_grades($subcourse, $userid=0, $nullifnone=true) {
require_once($CFG->dirroot . '/mod/subcourse/locallib.php');
require_once($CFG->libdir.'/gradelib.php');

$refgrades = subcourse_fetch_refgrades($subcourse->id, $subcourse->refcourse, false, $userid, false);

if ($subcourse->refcourse) {
$refgrades = subcourse_fetch_refgrades($subcourse->id, $subcourse->refcourse, false, $userid, false);
} else {
// Prevent empty referenced course id coding error.
return GRADE_UPDATE_FAILED;
}

if ($refgrades && $refgrades->grades) {
if (!empty($refgrades->localremotescale)) {
// Unable to fetch remote grades - local scale is used in the remote course.
Expand Down

0 comments on commit 5852c2b

Please sign in to comment.