public static function get_students_list($id_course, $DB, $listactivities)
 {
     $listid = report_students_manager::extract_students_id_list_from_db($id_course, $DB);
     $listgrades = report_students_manager::extract_students_grades_list_from_db($DB, $listactivities);
     $final_result = report_students_manager::mapping_data($listid, $listgrades, $listactivities);
     return $final_result;
 }
$theuser = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
//does the id exists in the database
$usercontext = CONTEXT_USER::instance($theuser->id);
$PAGE->set_pagelayout('report');
$PAGE->set_context(context_system::instance());
$PAGE->set_url(new moodle_url('/report/teacherreport/index.php', array('userid' => $theuser->id)));
$PAGE->set_title(get_string('pluginname', 'report_teacherreport'));
$PAGE->set_heading(get_string('pluginname', 'report_teacherreport'));
echo $OUTPUT->header();
if (!isset($_GET["data"])) {
    echo get_string('T_noid', 'report_teacherreport');
    ////
} else {
    $idcourse = $_GET["data"];
    $activitiesListDisplay = report_activities_manager::get_activities_list($idcourse, $DB);
    $studentsListDisplay = report_students_manager::get_students_list($idcourse, $DB, $activitiesListDisplay);
    $stringOut = "<table class=\"tg\"><tr><th class=\"tg-s6z2\">nom étudiant</th><th class=\"tg-s6z2\">niveau général</th>";
    foreach ($activitiesListDisplay as $var) {
        $stringOut = $stringOut . "<th class=\"tg-s6z2\">  " . $var["name"] . "  </th>";
    }
    $stringOut = $stringOut . "</tr>";
    foreach ($studentsListDisplay as $key1 => $var1) {
        $stringOut = $stringOut . "<tr><td>" . $var1["firstname"] . " " . $var1["lastname"] . "</td>";
        $stringAux = "";
        $ind = 0;
        $nbSupMoy = 0;
        foreach ($var1["grade"] as $key2 => $var2) {
            $Gavg = $activitiesListDisplay[$ind]["moyenne"];
            $ecartType = $activitiesListDisplay[$ind]["ecarttype"];
            $userGrade = $var2;
            if ($userGrade < $Gavg - $ecartType) {