示例#1
0
// 2. Exercise button
// Notice we not add there the lp_item_view_id because is not already generated
$exercise_url = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_submit.php?' . api_get_cidreq() . '&exerciseId=' . $objExercise->id . '&origin=' . $origin . '&learnpath_id=' . $learnpath_id . '&learnpath_item_id=' . $learnpath_item_id . $extra_params;
$exercise_url_button = Display::url($label, $exercise_url, array('class' => 'btn btn-primary btn-large'));
//3. Checking visibility of the exercise (overwrites the exercise button)
$visible_return = $objExercise->is_visible($learnpath_id, $learnpath_item_id, null, false);
// Exercise is not visible remove the button
if ($visible_return['value'] == false) {
    if ($is_allowed_to_edit) {
        $message = Display::return_message(get_lang('ThisItemIsInvisibleForStudentsButYouHaveAccessAsTeacher'), 'warning');
    } else {
        $message = $visible_return['message'];
        $exercise_url_button = null;
    }
}
$attempts = get_exercise_results_by_user(api_get_user_id(), $objExercise->id, api_get_course_id(), api_get_session_id(), $learnpath_id, $learnpath_item_id, 'desc');
$counter = count($attempts);
$my_attempt_array = array();
$table_content = '';
/* Make a special case for IE, which doesn't seem to be able to handle the
 * results popup -> send it to the full results page */
require_once api_get_path(LIBRARY_PATH) . 'browser/Browser.php';
$browser = new Browser();
$current_browser = $browser->getBrowser();
$url_suffix = '';
$btn_class = 'ajax ';
if ($current_browser == 'Internet Explorer') {
    $url_suffix = '&show_headers=1';
    $btn_class = '';
}
if (!empty($attempts)) {
示例#2
0
                    1
                );

                $course['name'] = $course_info['name'];
                $course['id']   = $course_info['real_id'];
                if (!empty($exercise_list)) {
                    foreach ($exercise_list as $exercise_item) {
                        //Loading the exercise
                        $exercise = new Exercise($course_info['real_id']);
                        $exercise->read($exercise_item['id']);
                        $visible_return = $exercise->is_visible();
                        if ($visible_return['value'] != false) {
                            // Reading all Exercise results by user, exercise_id, code, and session.
                            $user_results = get_exercise_results_by_user(
                                api_get_user_id(),
                                $exercise_item['id'],
                                $my_course['code'],
                                $my_session_id
                            );
                            $course['exercises'][$exercise_item['id']]['data']['exercise_data'] =  $exercise;
                            $course['exercises'][$exercise_item['id']]['data']['results']       =  $user_results;
                        }
                    }
                    $final_array[$my_session_id]['data'][$my_course['code']] = $course;
                }
            }
        }
        $my_session_list[] =  $my_session_id;
    }
}
$new_course_list = array();
$_SESSION['duration_time'][$current_expired_time_key] = $current_timestamp;
if ($time_control) {
    // Get the expired time of the current exercice in track_e_exercices
    $total_seconds = $objExercise->expired_time * 60;
}
$show_clock = true;
$user_id = api_get_user_id();
if ($objExercise->selectAttempts() > 0) {
    $attempt_html = '';
    $attempt_count = get_attempt_count($user_id, $exerciseId, $learnpath_id, $learnpath_item_id, $learnpath_item_view_id);
    if ($attempt_count >= $objExercise->selectAttempts()) {
        $show_clock = false;
        if (!api_is_allowed_to_edit(null, true)) {
            if ($objExercise->results_disabled == 0 && $origin != 'learnpath') {
                // Showing latest attempt according with task BT#1628
                $exercise_stat_info = get_exercise_results_by_user($user_id, $exerciseId, api_get_course_id(), api_get_session_id());
                if (!empty($exercise_stat_info)) {
                    $max_exe_id = max(array_keys($exercise_stat_info));
                    $last_attempt_info = $exercise_stat_info[$max_exe_id];
                    $attempt_html .= Display::div(get_lang('Date') . ': ' . api_get_local_time($last_attempt_info['exe_date']), array('id' => ''));
                    $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
                    if (!empty($last_attempt_info['question_list'])) {
                        foreach ($last_attempt_info['question_list'] as $question_data) {
                            $question_id = $question_data['question_id'];
                            $marks = $question_data['marks'];
                            $question_info = Question::read($question_id);
                            $attempt_html .= Display::div($question_info->question, array('class' => 'question_title'));
                            $attempt_html .= Display::div(get_lang('Score') . ' ' . $marks, array('id' => 'question_score'));
                        }
                    }
                    $score = show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);