exit;
        }
    }
}
$actions = null;
if ($is_allowedToEdit && $origin != 'learnpath') {
    // the form
    if (api_is_platform_admin() || api_is_course_admin() || api_is_course_tutor() || api_is_course_coach()) {
        $actions .= '<a href="admin.php?exerciseId=' . intval($_GET['exerciseId']) . '">' . Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM) . '</a>';
        $actions .= '<a href="live_stats.php?' . api_get_cidreq() . '&exerciseId=' . $exercise_id . '">' . Display::return_icon('activity_monitor.png', get_lang('LiveResults'), '', ICON_SIZE_MEDIUM) . '</a>';
        $actions .= '<a href="stats.php?' . api_get_cidreq() . '&exerciseId=' . $exercise_id . '">' . Display::return_icon('statistics.png', get_lang('ReportByQuestion'), '', ICON_SIZE_MEDIUM) . '</a>';
        $actions .= '<a id="export_opener" href="' . api_get_self() . '?export_report=1&exerciseId=' . intval($_GET['exerciseId']) . '" >' . Display::return_icon('save.png', get_lang('Export'), '', ICON_SIZE_MEDIUM) . '</a>';
        // clean result before a selected date icon
        $actions .= Display::url(Display::return_icon('clean_before_date.png', get_lang('CleanStudentsResultsBeforeDate'), '', ICON_SIZE_MEDIUM), '#', array('onclick' => "javascript:display_date_picker()"));
        // clean result before a selected date datepicker popup
        $actions .= Display::span(Display::input('input', 'datepicker_start', get_lang('SelectADateOnTheCalendar'), array('onmouseover' => 'datepicker_input_mouseover()', 'id' => 'datepicker_start', 'onchange' => 'datepicker_input_changed()', 'readonly' => 'readonly')) . Display::button('delete', get_lang('Delete'), array('onclick' => 'submit_datepicker()')), array('style' => 'display:none', 'id' => 'datepicker_span'));
    }
} else {
    $actions .= '<a href="exercise.php">' . Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM) . '</a>';
}
//Deleting an attempt
if (($is_allowedToEdit || $is_tutor || api_is_coach()) && isset($_GET['delete']) && $_GET['delete'] == 'delete' && !empty($_GET['did']) && $locked == false) {
    $exe_id = intval($_GET['did']);
    if (!empty($exe_id)) {
        $sql = 'DELETE FROM ' . $TBL_TRACK_EXERCISES . ' WHERE exe_id = ' . $exe_id;
        Database::query($sql);
        $sql = 'DELETE FROM ' . $TBL_TRACK_ATTEMPT . ' WHERE exe_id = ' . $exe_id;
        Database::query($sql);
        header('Location: exercise_report.php?' . api_get_cidreq() . '&exerciseId=' . $exercise_id);
        exit;
    }
 /**
  * Direct course link see #5299
  *
  * You can send to your students an URL like this
  * http://chamilodev.beeznest.com/main/auth/inscription.php?c=ABC&e=3
  * Where "c" is the course code and "e" is the exercise Id, after a successful
  * registration the user will be sent to the course or exercise
  *
  */
 public static function redirectToCourse($form_data)
 {
     $course_code_redirect = Session::read('course_redirect');
     $_user = api_get_user_info();
     $user_id = api_get_user_id();
     if (!empty($course_code_redirect)) {
         $course_info = api_get_course_info($course_code_redirect);
         if (!empty($course_info)) {
             if (in_array($course_info['visibility'], array(COURSE_VISIBILITY_OPEN_PLATFORM, COURSE_VISIBILITY_OPEN_WORLD))) {
                 if (CourseManager::is_user_subscribed_in_course($user_id, $course_info['code'])) {
                     $form_data['action'] = $course_info['course_public_url'];
                     $form_data['message'] = sprintf(get_lang('YouHaveBeenRegisteredToCourseX'), $course_info['title']);
                     $form_data['button'] = Display::button('next', get_lang('GoToCourse', null, $_user['language']), array('class' => 'btn btn-primary btn-large'));
                     $exercise_redirect = intval(Session::read('exercise_redirect'));
                     // Specify the course id as the current context does not
                     // hold a global $_course array
                     $objExercise = new Exercise($course_info['real_id']);
                     $result = $objExercise->read($exercise_redirect);
                     if (!empty($exercise_redirect) && !empty($result)) {
                         $form_data['action'] = api_get_path(WEB_CODE_PATH) . 'exercice/overview.php?exerciseId=' . $exercise_redirect . '&cidReq=' . $course_info['code'];
                         $form_data['message'] .= '<br />' . get_lang('YouCanAccessTheExercise');
                         $form_data['button'] = Display::button('next', get_lang('Go', null, $_user['language']), array('class' => 'btn btn-primary btn-large'));
                     }
                     if (!empty($form_data['action'])) {
                         header('Location: ' . $form_data['action']);
                         exit;
                     }
                 }
             }
         }
     }
     return $form_data;
 }
         }
         $form_data['action'] = '../create_course/add_course.php';
         if (api_get_setting('course.course_validation') == 'true') {
             $form_data['button'] = Display::button('next', get_lang('CreateCourseRequest', null, $_user['language']), array('class' => 'btn btn-primary btn-large'));
         } else {
             $form_data['button'] = Display::button('next', get_lang('CourseCreate', null, $_user['language']), array('class' => 'btn btn-primary btn-large'));
             $form_data['go_button'] = '&nbsp;&nbsp;<a href="' . api_get_path(WEB_PATH) . 'index.php' . '">' . Display::span(get_lang('Next', null, $_user['language']), array('class' => 'btn btn-primary btn-large')) . '</a>';
         }
     } else {
         if (api_get_setting('display.allow_students_to_browse_courses') == 'true') {
             $form_data['action'] = 'courses.php?action=subscribe';
             $form_data['message'] = '<p>' . get_lang('NowGoChooseYourCourses', null, $_user['language']) . ".</p>";
         } else {
             $form_data['action'] = api_get_path(WEB_PATH) . 'user_portal.php';
         }
         $form_data['button'] = Display::button('next', get_lang('Next', null, $_user['language']), array('class' => 'btn btn-primary btn-large'));
     }
 }
 $form_data = CourseManager::redirectToCourse($form_data);
 $form_register = new FormValidator('form_register', 'post', $form_data['action']);
 if (!empty($form_data['message'])) {
     $form_register->addElement('html', $form_data['message'] . '<br /><br />');
 }
 if ($usersCanCreateCourse) {
     $form_register->addElement('html', $form_data['button']);
 } else {
     $form_register->addElement('html', $form_data['go_button']);
 }
 $text_after_registration .= $form_register->returnForm();
 // Just in case
 Session::erase('course_redirect');
 /**
  * Function that creates a html list of learning path items so that we can add audio files to them
  * @author Kevin Van Den Haute
  * @param int $lp_id
  * @return string
  */
 public function overview()
 {
     if ($this->debug > 0) {
         error_log('New LP - In learnpath::overview()', 0);
     }
     $return = '';
     $update_audio = isset($_GET['updateaudio']) ? $_GET['updateaudio'] : null;
     // we need to start a form when we want to update all the mp3 files
     if ($update_audio == 'true') {
         $return .= '<form action="' . api_get_self() . '?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&updateaudio=' . Security::remove_XSS($_GET['updateaudio']) . '&action=' . Security::remove_XSS($_GET['action']) . '&lp_id=' . $_SESSION['oLP']->lp_id . '" method="post" enctype="multipart/form-data" name="updatemp3" id="updatemp3">';
     }
     $return .= '<div id="message"></div>';
     if (count($this->items) == 0) {
         $return .= Display::display_normal_message(get_lang('YouShouldAddItemsBeforeAttachAudio'));
     } else {
         $return_audio = '<table class="data_table">';
         $return_audio .= '<tr>';
         $return_audio .= '<th width="40%">' . get_lang('Title') . '</th>';
         $return_audio .= '<th>' . get_lang('Audio') . '</th>';
         $return_audio .= '</tr>';
         if ($update_audio != 'true') {
             $return .= '<div class="col-md-12">';
             $return .= self::return_new_tree($update_audio);
             $return .= '</div>';
             $return .= Display::div(Display::url(get_lang('Save'), '#', array('id' => 'listSubmit', 'class' => 'btn btn-primary')), array('style' => 'float:left; margin-top:15px;width:100%'));
         } else {
             $return_audio .= self::return_new_tree($update_audio);
             $return .= $return_audio . '</table>';
         }
         // We need to close the form when we are updating the mp3 files.
         if ($update_audio == 'true') {
             $return .= '<div class="footer-audio">';
             $return .= Display::button('save_audio', '<em class="fa fa-file-audio-o"></em> ' . get_lang('SaveAudioAndOrganization'), array('class' => 'btn btn-primary', 'type' => 'submit'));
             $return .= '</div>';
             //$return .= '<div><button class="btn btn-primary" type="submit" name="save_audio" id="save_audio">' . get_lang('SaveAudioAndOrganization') . '</button></div>'; // TODO: What kind of language variable is this?
         }
     }
     // We need to close the form when we are updating the mp3 files.
     if ($update_audio == 'true' && count($this->arrMenu) != 0) {
         $return .= '</form>';
     }
     return $return;
 }