include $CFG->dirroot . '/report/studentreport/pChart2.1.4/class/pData.class.php';
include $CFG->dirroot . '/report/studentreport/pChart2.1.4/class/pDraw.class.php';
include $CFG->dirroot . '/report/studentreport/pChart2.1.4/class/pRadar.class.php';
include $CFG->dirroot . '/report/studentreport/pChart2.1.4/class/pImage.class.php';
global $PAGE;
echo "<!DOCTYPE html> \n<html> \n    <head> \n        <script src=\"charts4php/lib/js/jquery.min.js\"></script> \n        <script src=\"charts4php/lib/js/chartphp.js\"></script> \n        <link rel=\"stylesheet\" href=\"charts4php/lib/js/chartphp.css\"> \n\t\t<link rel=\"stylesheet\" href=\"design.css\"> \n\t\t\n\t\t<script type=\"text/javascript\">\n                 function unhide(divID) {\n                 var item = document.getElementById(divID);\n                 if (item) {\n                       item.className=(item.className=='hidden')?'unhidden':'hidden';\n                 }\n                }\n        </script>\n\t\t\t\n    </head> \n    <body> ";
$userid = optional_param('userid', null, PARAM_INT);
if (is_null($userid)) {
    // extract student id
    $userid = $USER->id;
}
require_login();
// check that the user has the right to access this page
$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/studentreport/index.php', array('userid' => $theuser->id)));
$PAGE->set_title(get_string('pluginname', 'report_studentreport'));
$PAGE->set_heading(get_string('pluginname', 'report_studentreport'));
echo $OUTPUT->header();
/*extaction of all courses (id and names) that this user is rolled in */
$courseListDisplay = report_course_manager::get_course_list($theuser->id, $DB);
/*extaction of all domaines */
$courseListDomaine = report_course_manager::extract_list_domaine($courseListDisplay, $DB);
/*mapping courses et domaines*/
$courseListFinal = report_course_manager::mapping_final_course_domaine($courseListDisplay, $courseListDomaine);
/*extraction of the activities related to the course : id,name,maximum_mark, student_mark*/
$listiditems = report_activities_manager::extract_items_id_list_from_db($courseListDisplay, $DB);
$listname = report_activities_manager::extract_info_grades_list_from_db($listiditems, $DB);
 /**
  * Print  settings link
  *
  * @return string
  */
 public function print_settings_link()
 {
     global $DB, $PAGE, $COURSE;
     if (!$PAGE->blocks->is_block_present('settings')) {
         return '';
     }
     $isteacher = has_capability('moodle/course:manageactivities', $PAGE->context);
     $display = false;
     $userid = optional_param('id', false, PARAM_INT);
     if ($isteacher) {
         $display = true;
     } elseif (is_role_switched($COURSE->id)) {
         // IF a teacher or admin switch their role to a student then they still need to be able to see the admin
         // menu in order to be able to switch back to their original role!
         $display = true;
     } elseif ($PAGE->pagetype === 'user-profile') {
         // The admin block needs to be shown on user profile pages as it contains the edit profile link.
         $display = true;
     } elseif ($PAGE->url->get_path() === '/user/view.php' && $userid && has_capability('moodle/user:viewdetails', CONTEXT_USER::instance($userid))) {
         // Test to see if we have a mentor viewing this page, if so we need to display the admin block.
         $display = true;
     }
     if (!$display) {
         return '';
     }
     if (!($instanceid = $DB->get_field('block_instances', 'id', array('blockname' => 'settings')))) {
         $msg = "Moodle appears to be missing a settings block.\n            This shouldn't happen!\n            Please speak to your Moodle administrator";
         throw new coding_exception($msg);
     }
     if (!has_capability('moodle/block:view', context_block::instance($instanceid))) {
         return '';
     }
     // User can view admin block - return the link
     $admin = get_string('admin', 'theme_snap');
     echo '<a id="admin-menu-trigger" class="pull-right" href="#inst' . $instanceid . '" data-toggle="tooltip" data-placement="bottom" title="' . $admin . '" >
     <span class="lines"></span></a>';
 }