$onlyBestAttempts = false;
        if (isset($_REQUEST['only_best_attempts']) && $_REQUEST['only_best_attempts'] == 1) {
            $onlyBestAttempts = true;
        }
        require_once 'exercise_result.class.php';
        $export = new ExerciseResult();
        $export->setIncludeAllUsers($includeAllUsers);
        $export->setOnlyBestAttempts($onlyBestAttempts);
        switch ($_GET['export_format']) {
            case 'xls':
                $export->exportCompleteReportXLS($documentPath, null, $loadExtraData, null, $_GET['exerciseId']);
                exit;
                break;
            case 'csv':
            default:
                $export->exportCompleteReportCSV($documentPath, null, $loadExtraData, null, $_GET['exerciseId']);
                exit;
                break;
        }
    } else {
        api_not_allowed(true);
    }
}
//Send student email @todo move this code in a class, library
if (isset($_REQUEST['comments']) && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor || $allowCoachFeedbackExercises)) {
    //filtered by post-condition
    $id = intval($_GET['exeid']);
    $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id);
    if (empty($track_exercise_info)) {
        api_not_allowed();
    }
    if (api_is_platform_admin() || api_is_course_admin() || api_is_course_tutor() || api_is_course_coach()) {
        $load_extra_data = false;
        if (isset($_REQUEST['extra_data']) && $_REQUEST['extra_data'] == 1) {
            $load_extra_data = true;
        }
        require_once 'exercise_result.class.php';
        switch ($_GET['export_format']) {
            case 'xls':
                $export = new ExerciseResult();
                $export->exportCompleteReportXLS($documentPath, null, $load_extra_data, null, $_GET['exerciseId'], $_GET['hotpotato_name']);
                exit;
                break;
            case 'csv':
            default:
                $export = new ExerciseResult();
                $export->exportCompleteReportCSV($documentPath, null, $load_extra_data, null, $_GET['exerciseId'], $_GET['hotpotato_name']);
                exit;
                break;
        }
    } else {
        api_not_allowed(true);
    }
}
$actions = null;
if (isset($origin) && $origin == 'learnpath') {
    $actions .= '<a href="exercice.php">' . Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM) . '</a>';
} else {
    if ($is_allowedToEdit) {
        // the form
        if (api_is_platform_admin() || api_is_course_admin() || api_is_course_tutor() || api_is_course_coach()) {
            // @todo check if $path is used