I'm trying to use the moodle Data Manipulation API to get the grades from students to analyse. But when I use the function get_record() inside of another function that I've created I get the message of the tittle. I don't know why the fuction works in the main and don't work inside a function.Any idea? I'm new in php and moodle manipulation, so take easy on me.
<?php
function get_all_quiz ($courseid) {
$quizesid = [];
$quiz = $DB->get_record('moodle.quiz', array('id'=>$courseid));
$quizesid = $quiz.id;
return $quizesid;
}
global $DB;
define('CLI_SCRIPT', true);
require '../../var/www/moodle/config.php';
$coursetest = 3;
$studentgrades = [];
$quizes = get_all_quiz($coursetest);
?>